diff options
| author | 2022-08-20 18:31:31 -0400 | |
|---|---|---|
| committer | 2022-08-20 18:31:31 -0400 | |
| commit | 776bcec3e10cc18001d8658ca8e5015582d1c22e (patch) | |
| tree | 138e021a497311f543c4cd71c2fe1d0529f5d360 /src | |
| parent | Merge pull request #8794 from vonchenplus/clkrst_service (diff) | |
| parent | video_core: support framebuffer crop rect top not zero (diff) | |
| download | yuzu-776bcec3e10cc18001d8658ca8e5015582d1c22e.tar.gz yuzu-776bcec3e10cc18001d8658ca8e5015582d1c22e.tar.xz yuzu-776bcec3e10cc18001d8658ca8e5015582d1c22e.zip | |
Merge pull request #8795 from vonchenplus/support_framebuffer_crop_rect_top_not_zero
video_core: support framebuffer crop rect top not zero
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 19 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.cpp | 18 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 01028cee0..34f3f7a67 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -478,13 +478,16 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 478 | } | 478 | } |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | ASSERT_MSG(framebuffer_crop_rect.top == 0, "Unimplemented"); | ||
| 482 | ASSERT_MSG(framebuffer_crop_rect.left == 0, "Unimplemented"); | 481 | ASSERT_MSG(framebuffer_crop_rect.left == 0, "Unimplemented"); |
| 483 | 482 | ||
| 483 | f32 left_start{}; | ||
| 484 | if (framebuffer_crop_rect.Top() > 0) { | ||
| 485 | left_start = static_cast<f32>(framebuffer_crop_rect.Top()) / | ||
| 486 | static_cast<f32>(framebuffer_crop_rect.Bottom()); | ||
| 487 | } | ||
| 484 | f32 scale_u = static_cast<f32>(framebuffer_width) / static_cast<f32>(screen_info.texture.width); | 488 | f32 scale_u = static_cast<f32>(framebuffer_width) / static_cast<f32>(screen_info.texture.width); |
| 485 | f32 scale_v = | 489 | f32 scale_v = |
| 486 | static_cast<f32>(framebuffer_height) / static_cast<f32>(screen_info.texture.height); | 490 | static_cast<f32>(framebuffer_height) / static_cast<f32>(screen_info.texture.height); |
| 487 | |||
| 488 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering | 491 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering |
| 489 | // (e.g. handheld mode) on a 1920x1080 framebuffer. | 492 | // (e.g. handheld mode) on a 1920x1080 framebuffer. |
| 490 | if (framebuffer_crop_rect.GetWidth() > 0) { | 493 | if (framebuffer_crop_rect.GetWidth() > 0) { |
| @@ -503,10 +506,14 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 503 | 506 | ||
| 504 | const auto& screen = layout.screen; | 507 | const auto& screen = layout.screen; |
| 505 | const std::array vertices = { | 508 | const std::array vertices = { |
| 506 | ScreenRectVertex(screen.left, screen.top, texcoords.top * scale_u, left * scale_v), | 509 | ScreenRectVertex(screen.left, screen.top, texcoords.top * scale_u, |
| 507 | ScreenRectVertex(screen.right, screen.top, texcoords.bottom * scale_u, left * scale_v), | 510 | left_start + left * scale_v), |
| 508 | ScreenRectVertex(screen.left, screen.bottom, texcoords.top * scale_u, right * scale_v), | 511 | ScreenRectVertex(screen.right, screen.top, texcoords.bottom * scale_u, |
| 509 | ScreenRectVertex(screen.right, screen.bottom, texcoords.bottom * scale_u, right * scale_v), | 512 | left_start + left * scale_v), |
| 513 | ScreenRectVertex(screen.left, screen.bottom, texcoords.top * scale_u, | ||
| 514 | left_start + right * scale_v), | ||
| 515 | ScreenRectVertex(screen.right, screen.bottom, texcoords.bottom * scale_u, | ||
| 516 | left_start + right * scale_v), | ||
| 510 | }; | 517 | }; |
| 511 | glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices)); | 518 | glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices)); |
| 512 | 519 | ||
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 27e6ebf94..444c29f68 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -1402,12 +1402,15 @@ void BlitScreen::SetVertexData(BufferData& data, const Tegra::FramebufferConfig& | |||
| 1402 | break; | 1402 | break; |
| 1403 | } | 1403 | } |
| 1404 | 1404 | ||
| 1405 | UNIMPLEMENTED_IF(framebuffer_crop_rect.top != 0); | ||
| 1406 | UNIMPLEMENTED_IF(framebuffer_crop_rect.left != 0); | 1405 | UNIMPLEMENTED_IF(framebuffer_crop_rect.left != 0); |
| 1407 | 1406 | ||
| 1407 | f32 left_start{}; | ||
| 1408 | if (framebuffer_crop_rect.Top() > 0) { | ||
| 1409 | left_start = static_cast<f32>(framebuffer_crop_rect.Top()) / | ||
| 1410 | static_cast<f32>(framebuffer_crop_rect.Bottom()); | ||
| 1411 | } | ||
| 1408 | f32 scale_u = static_cast<f32>(framebuffer.width) / static_cast<f32>(screen_info.width); | 1412 | f32 scale_u = static_cast<f32>(framebuffer.width) / static_cast<f32>(screen_info.width); |
| 1409 | f32 scale_v = static_cast<f32>(framebuffer.height) / static_cast<f32>(screen_info.height); | 1413 | f32 scale_v = static_cast<f32>(framebuffer.height) / static_cast<f32>(screen_info.height); |
| 1410 | |||
| 1411 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering | 1414 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering |
| 1412 | // (e.g. handheld mode) on a 1920x1080 framebuffer. | 1415 | // (e.g. handheld mode) on a 1920x1080 framebuffer. |
| 1413 | if (!fsr) { | 1416 | if (!fsr) { |
| @@ -1426,10 +1429,13 @@ void BlitScreen::SetVertexData(BufferData& data, const Tegra::FramebufferConfig& | |||
| 1426 | const auto y = static_cast<f32>(screen.top); | 1429 | const auto y = static_cast<f32>(screen.top); |
| 1427 | const auto w = static_cast<f32>(screen.GetWidth()); | 1430 | const auto w = static_cast<f32>(screen.GetWidth()); |
| 1428 | const auto h = static_cast<f32>(screen.GetHeight()); | 1431 | const auto h = static_cast<f32>(screen.GetHeight()); |
| 1429 | data.vertices[0] = ScreenRectVertex(x, y, texcoords.top * scale_u, left * scale_v); | 1432 | data.vertices[0] = ScreenRectVertex(x, y, texcoords.top * scale_u, left_start + left * scale_v); |
| 1430 | data.vertices[1] = ScreenRectVertex(x + w, y, texcoords.bottom * scale_u, left * scale_v); | 1433 | data.vertices[1] = |
| 1431 | data.vertices[2] = ScreenRectVertex(x, y + h, texcoords.top * scale_u, right * scale_v); | 1434 | ScreenRectVertex(x + w, y, texcoords.bottom * scale_u, left_start + left * scale_v); |
| 1432 | data.vertices[3] = ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v); | 1435 | data.vertices[2] = |
| 1436 | ScreenRectVertex(x, y + h, texcoords.top * scale_u, left_start + right * scale_v); | ||
| 1437 | data.vertices[3] = | ||
| 1438 | ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, left_start + right * scale_v); | ||
| 1433 | } | 1439 | } |
| 1434 | 1440 | ||
| 1435 | void BlitScreen::CreateFSR() { | 1441 | void BlitScreen::CreateFSR() { |