diff options
| author | 2016-01-03 15:46:54 -0800 | |
|---|---|---|
| committer | 2016-01-20 21:57:59 -0500 | |
| commit | f53dbafdae6b6ca8ab718d2299437df469441389 (patch) | |
| tree | ddf1b234c2440f8ade62be48ddf1e32ee22c8801 /src | |
| parent | Merge pull request #1327 from Subv/unmap_memblock (diff) | |
| download | yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.gz yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.xz yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.zip | |
hwrasterizer: Use depth offset
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 4 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 092351dce..291ef737d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -126,6 +126,7 @@ void RasterizerOpenGL::InitObjects() { | |||
| 126 | 126 | ||
| 127 | void RasterizerOpenGL::Reset() { | 127 | void RasterizerOpenGL::Reset() { |
| 128 | SyncCullMode(); | 128 | SyncCullMode(); |
| 129 | SyncDepthModifiers(); | ||
| 129 | SyncBlendEnabled(); | 130 | SyncBlendEnabled(); |
| 130 | SyncBlendFuncs(); | 131 | SyncBlendFuncs(); |
| 131 | SyncBlendColor(); | 132 | SyncBlendColor(); |
| @@ -194,6 +195,12 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { | |||
| 194 | SyncCullMode(); | 195 | SyncCullMode(); |
| 195 | break; | 196 | break; |
| 196 | 197 | ||
| 198 | // Depth modifiers | ||
| 199 | case PICA_REG_INDEX(viewport_depth_range): | ||
| 200 | case PICA_REG_INDEX(viewport_depth_far_plane): | ||
| 201 | SyncDepthModifiers(); | ||
| 202 | break; | ||
| 203 | |||
| 197 | // Blending | 204 | // Blending |
| 198 | case PICA_REG_INDEX(output_merger.alphablend_enable): | 205 | case PICA_REG_INDEX(output_merger.alphablend_enable): |
| 199 | SyncBlendEnabled(); | 206 | SyncBlendEnabled(); |
| @@ -602,6 +609,15 @@ void RasterizerOpenGL::SyncCullMode() { | |||
| 602 | } | 609 | } |
| 603 | } | 610 | } |
| 604 | 611 | ||
| 612 | void RasterizerOpenGL::SyncDepthModifiers() { | ||
| 613 | float depth_scale = -Pica::float24::FromRawFloat24(Pica::g_state.regs.viewport_depth_range).ToFloat32(); | ||
| 614 | float depth_offset = Pica::float24::FromRawFloat24(Pica::g_state.regs.viewport_depth_far_plane).ToFloat32() / 2.0f; | ||
| 615 | |||
| 616 | // TODO: Implement scale modifier | ||
| 617 | uniform_block_data.data.depth_offset = depth_offset; | ||
| 618 | uniform_block_data.dirty = true; | ||
| 619 | } | ||
| 620 | |||
| 605 | void RasterizerOpenGL::SyncBlendEnabled() { | 621 | void RasterizerOpenGL::SyncBlendEnabled() { |
| 606 | state.blend.enabled = (Pica::g_state.regs.output_merger.alphablend_enable == 1); | 622 | state.blend.enabled = (Pica::g_state.regs.output_merger.alphablend_enable == 1); |
| 607 | } | 623 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 92b1f812e..c8a2d8f16 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -197,7 +197,8 @@ private: | |||
| 197 | std::array<GLfloat, 4> const_color[6]; | 197 | std::array<GLfloat, 4> const_color[6]; |
| 198 | std::array<GLfloat, 4> tev_combiner_buffer_color; | 198 | std::array<GLfloat, 4> tev_combiner_buffer_color; |
| 199 | GLint alphatest_ref; | 199 | GLint alphatest_ref; |
| 200 | INSERT_PADDING_BYTES(12); | 200 | GLfloat depth_offset; |
| 201 | INSERT_PADDING_BYTES(8); | ||
| 201 | }; | 202 | }; |
| 202 | 203 | ||
| 203 | static_assert(sizeof(UniformData) == 0x80, "The size of the UniformData structure has changed, update the structure in the shader"); | 204 | static_assert(sizeof(UniformData) == 0x80, "The size of the UniformData structure has changed, update the structure in the shader"); |
| @@ -218,6 +219,9 @@ private: | |||
| 218 | /// Syncs the cull mode to match the PICA register | 219 | /// Syncs the cull mode to match the PICA register |
| 219 | void SyncCullMode(); | 220 | void SyncCullMode(); |
| 220 | 221 | ||
| 222 | /// Syncs the depth scale and offset to match the PICA registers | ||
| 223 | void SyncDepthModifiers(); | ||
| 224 | |||
| 221 | /// Syncs the blend enabled status to match the PICA register | 225 | /// Syncs the blend enabled status to match the PICA register |
| 222 | void SyncBlendEnabled(); | 226 | void SyncBlendEnabled(); |
| 223 | 227 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 38de5d469..22022f7f4 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -334,6 +334,7 @@ layout (std140) uniform shader_data { | |||
| 334 | vec4 const_color[NUM_TEV_STAGES]; | 334 | vec4 const_color[NUM_TEV_STAGES]; |
| 335 | vec4 tev_combiner_buffer_color; | 335 | vec4 tev_combiner_buffer_color; |
| 336 | int alphatest_ref; | 336 | int alphatest_ref; |
| 337 | float depth_offset; | ||
| 337 | }; | 338 | }; |
| 338 | 339 | ||
| 339 | uniform sampler2D tex[3]; | 340 | uniform sampler2D tex[3]; |
| @@ -360,7 +361,8 @@ void main() { | |||
| 360 | out += ") discard;\n"; | 361 | out += ") discard;\n"; |
| 361 | } | 362 | } |
| 362 | 363 | ||
| 363 | out += "color = last_tex_env_out;\n}"; | 364 | out += "color = last_tex_env_out;\n"; |
| 365 | out += "gl_FragDepth = gl_FragCoord.z + depth_offset;\n}"; | ||
| 364 | 366 | ||
| 365 | return out; | 367 | return out; |
| 366 | } | 368 | } |