diff options
| author | 2016-06-27 22:16:04 -0700 | |
|---|---|---|
| committer | 2016-06-27 22:16:04 -0700 | |
| commit | ecf6ecf32537634db15946630d62ac3bdc4fe8c9 (patch) | |
| tree | 02bf917874b79e350e5f3c29c16599dc869b3d57 /src | |
| parent | PICA: Scissor fixes and cleanups (diff) | |
| download | yuzu-ecf6ecf32537634db15946630d62ac3bdc4fe8c9.tar.gz yuzu-ecf6ecf32537634db15946630d62ac3bdc4fe8c9.tar.xz yuzu-ecf6ecf32537634db15946630d62ac3bdc4fe8c9.zip | |
OpenGL: Add scaled resolution support to scissor
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/pica_to_gl.h | 1 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index ab02aadc9..f8393c618 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -196,6 +196,14 @@ void RasterizerOpenGL::DrawTriangles() { | |||
| 196 | (GLint)(rect.bottom + regs.viewport_corner.y * color_surface->res_scale_height), | 196 | (GLint)(rect.bottom + regs.viewport_corner.y * color_surface->res_scale_height), |
| 197 | (GLsizei)(viewport_width * color_surface->res_scale_width), (GLsizei)(viewport_height * color_surface->res_scale_height)); | 197 | (GLsizei)(viewport_width * color_surface->res_scale_width), (GLsizei)(viewport_height * color_surface->res_scale_height)); |
| 198 | 198 | ||
| 199 | if (uniform_block_data.data.framebuffer_scale[0] != color_surface->res_scale_width || | ||
| 200 | uniform_block_data.data.framebuffer_scale[1] != color_surface->res_scale_height) { | ||
| 201 | |||
| 202 | uniform_block_data.data.framebuffer_scale[0] = color_surface->res_scale_width; | ||
| 203 | uniform_block_data.data.framebuffer_scale[1] = color_surface->res_scale_height; | ||
| 204 | uniform_block_data.dirty = true; | ||
| 205 | } | ||
| 206 | |||
| 199 | // Sync and bind the texture surfaces | 207 | // Sync and bind the texture surfaces |
| 200 | const auto pica_textures = regs.GetTextures(); | 208 | const auto pica_textures = regs.GetTextures(); |
| 201 | for (unsigned texture_index = 0; texture_index < pica_textures.size(); ++texture_index) { | 209 | for (unsigned texture_index = 0; texture_index < pica_textures.size(); ++texture_index) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 653ac9cd9..c5029432b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -328,6 +328,7 @@ private: | |||
| 328 | // the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not. | 328 | // the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not. |
| 329 | // Not following that rule will cause problems on some AMD drivers. | 329 | // Not following that rule will cause problems on some AMD drivers. |
| 330 | struct UniformData { | 330 | struct UniformData { |
| 331 | alignas(8) GLvec2 framebuffer_scale; | ||
| 331 | GLint alphatest_ref; | 332 | GLint alphatest_ref; |
| 332 | GLfloat depth_scale; | 333 | GLfloat depth_scale; |
| 333 | GLfloat depth_offset; | 334 | GLfloat depth_offset; |
| @@ -342,7 +343,7 @@ private: | |||
| 342 | alignas(16) GLvec4 tev_combiner_buffer_color; | 343 | alignas(16) GLvec4 tev_combiner_buffer_color; |
| 343 | }; | 344 | }; |
| 344 | 345 | ||
| 345 | static_assert(sizeof(UniformData) == 0x3B0, "The size of the UniformData structure has changed, update the structure in the shader"); | 346 | static_assert(sizeof(UniformData) == 0x3C0, "The size of the UniformData structure has changed, update the structure in the shader"); |
| 346 | static_assert(sizeof(UniformData) < 16384, "UniformData structure must be less than 16kb as per the OpenGL spec"); | 347 | static_assert(sizeof(UniformData) < 16384, "UniformData structure must be less than 16kb as per the OpenGL spec"); |
| 347 | 348 | ||
| 348 | /// Sets the OpenGL shader in accordance with the current PICA register state | 349 | /// Sets the OpenGL shader in accordance with the current PICA register state |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index b2e452afe..36513dedc 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -554,6 +554,7 @@ struct LightSrc { | |||
| 554 | }; | 554 | }; |
| 555 | 555 | ||
| 556 | layout (std140) uniform shader_data { | 556 | layout (std140) uniform shader_data { |
| 557 | vec2 framebuffer_scale; | ||
| 557 | int alphatest_ref; | 558 | int alphatest_ref; |
| 558 | float depth_scale; | 559 | float depth_scale; |
| 559 | float depth_offset; | 560 | float depth_offset; |
| @@ -595,8 +596,10 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 595 | if (state.scissor_test_mode == Regs::ScissorMode::Include) | 596 | if (state.scissor_test_mode == Regs::ScissorMode::Include) |
| 596 | out += "!"; | 597 | out += "!"; |
| 597 | // x2,y2 have +1 added to cover the entire pixel area | 598 | // x2,y2 have +1 added to cover the entire pixel area |
| 598 | out += "(gl_FragCoord.x >= scissor_x1 && gl_FragCoord.x < scissor_x2 + 1 && " | 599 | out += "(gl_FragCoord.x >= scissor_x1 * framebuffer_scale.x && " |
| 599 | "gl_FragCoord.y >= scissor_y1 && gl_FragCoord.y < scissor_y2 + 1)) discard;\n"; | 600 | "gl_FragCoord.y >= scissor_y1 * framebuffer_scale.y && " |
| 601 | "gl_FragCoord.x < (scissor_x2 + 1) * framebuffer_scale.x && " | ||
| 602 | "gl_FragCoord.y < (scissor_y2 + 1) * framebuffer_scale.y)) discard;\n"; | ||
| 600 | } | 603 | } |
| 601 | 604 | ||
| 602 | out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; | 605 | out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; |
diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index 6dc2758c5..d9b9c9cc2 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include "video_core/pica.h" | 18 | #include "video_core/pica.h" |
| 19 | 19 | ||
| 20 | using GLvec2 = std::array<GLfloat, 2>; | ||
| 20 | using GLvec3 = std::array<GLfloat, 3>; | 21 | using GLvec3 = std::array<GLfloat, 3>; |
| 21 | using GLvec4 = std::array<GLfloat, 4>; | 22 | using GLvec4 = std::array<GLfloat, 4>; |
| 22 | 23 | ||