From e3bddf81375ce5b13666d64cbf534c802a74b8d3 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 20 Aug 2018 21:57:56 -0500 Subject: Shaders: Implement depth writing in fragment shaders. We'll write to gl_FragDepth. --- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 6fb663bbc..aeb908744 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -918,7 +918,6 @@ private: FragmentHeader header; std::memcpy(&header, program_code.data(), PROGRAM_HEADER_SIZE); - ASSERT_MSG(header.writes_depth == 0, "Depth write is unimplemented"); ASSERT_MSG(header.writes_samplemask == 0, "Samplemask write is unimplemented"); // Write the color outputs using the data in the shader registers, disabled @@ -935,6 +934,12 @@ private: } } } + + if (header.writes_depth) { + // The depth output is always 2 registers after the last color output, and current_reg + // already contains one past the last color register. + shader.AddLine("gl_FragDepth = " + regs.GetRegisterAsFloat(current_reg + 1) + ';'); + } } /** -- cgit v1.2.3