diff options
| author | 2018-07-17 20:11:41 -0400 | |
|---|---|---|
| committer | 2018-07-17 20:13:17 -0400 | |
| commit | c3dd456d513a989315d4e8a00ad8a1223bb8f9c4 (patch) | |
| tree | 25e349c1885d70d9338841faaa16f31976e09994 /src/video_core | |
| parent | Merge pull request #675 from Subv/stencil (diff) | |
| download | yuzu-c3dd456d513a989315d4e8a00ad8a1223bb8f9c4.tar.gz yuzu-c3dd456d513a989315d4e8a00ad8a1223bb8f9c4.tar.xz yuzu-c3dd456d513a989315d4e8a00ad8a1223bb8f9c4.zip | |
vi: Partially implement buffer crop parameters.
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/gpu.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 22 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 1 |
3 files changed, 20 insertions, 4 deletions
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index cc5ca656e..60930e997 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -67,6 +67,7 @@ struct FramebufferConfig { | |||
| 67 | 67 | ||
| 68 | using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags; | 68 | using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags; |
| 69 | TransformFlags transform_flags; | 69 | TransformFlags transform_flags; |
| 70 | MathUtil::Rectangle<int> crop_rect; | ||
| 70 | }; | 71 | }; |
| 71 | 72 | ||
| 72 | namespace Engines { | 73 | namespace Engines { |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 1930fa6ef..7810b9147 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -154,6 +154,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf | |||
| 154 | 154 | ||
| 155 | // Framebuffer orientation handling | 155 | // Framebuffer orientation handling |
| 156 | framebuffer_transform_flags = framebuffer.transform_flags; | 156 | framebuffer_transform_flags = framebuffer.transform_flags; |
| 157 | framebuffer_crop_rect = framebuffer.crop_rect; | ||
| 157 | 158 | ||
| 158 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default | 159 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default |
| 159 | // only allows rows to have a memory alignement of 4. | 160 | // only allows rows to have a memory alignement of 4. |
| @@ -320,11 +321,24 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, | |||
| 320 | } | 321 | } |
| 321 | } | 322 | } |
| 322 | 323 | ||
| 324 | ASSERT_MSG(framebuffer_crop_rect.top == 0, "Unimplemented"); | ||
| 325 | ASSERT_MSG(framebuffer_crop_rect.left == 0, "Unimplemented"); | ||
| 326 | |||
| 327 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering | ||
| 328 | // (e.g. handheld mode) on a 1920x1080 framebuffer. | ||
| 329 | f32 scale_u = 1.f, scale_v = 1.f; | ||
| 330 | if (framebuffer_crop_rect.GetWidth() > 0) { | ||
| 331 | scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / screen_info.texture.width; | ||
| 332 | } | ||
| 333 | if (framebuffer_crop_rect.GetHeight() > 0) { | ||
| 334 | scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) / screen_info.texture.height; | ||
| 335 | } | ||
| 336 | |||
| 323 | std::array<ScreenRectVertex, 4> vertices = {{ | 337 | std::array<ScreenRectVertex, 4> vertices = {{ |
| 324 | ScreenRectVertex(x, y, texcoords.top, left), | 338 | ScreenRectVertex(x, y, texcoords.top * scale_u, left * scale_v), |
| 325 | ScreenRectVertex(x + w, y, texcoords.bottom, left), | 339 | ScreenRectVertex(x + w, y, texcoords.bottom * scale_u, left * scale_v), |
| 326 | ScreenRectVertex(x, y + h, texcoords.top, right), | 340 | ScreenRectVertex(x, y + h, texcoords.top * scale_u, right * scale_v), |
| 327 | ScreenRectVertex(x + w, y + h, texcoords.bottom, right), | 341 | ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v), |
| 328 | }}; | 342 | }}; |
| 329 | 343 | ||
| 330 | state.texture_units[0].texture_2d = screen_info.display_texture; | 344 | state.texture_units[0].texture_2d = screen_info.display_texture; |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index fd0267cf5..59d92a3dc 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h | |||
| @@ -97,4 +97,5 @@ private: | |||
| 97 | 97 | ||
| 98 | /// Used for transforming the framebuffer orientation | 98 | /// Used for transforming the framebuffer orientation |
| 99 | Tegra::FramebufferConfig::TransformFlags framebuffer_transform_flags; | 99 | Tegra::FramebufferConfig::TransformFlags framebuffer_transform_flags; |
| 100 | MathUtil::Rectangle<int> framebuffer_crop_rect; | ||
| 100 | }; | 101 | }; |