diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-03-30 16:12:11 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-03-30 16:13:25 +0300 |
commit | fb524d1675cf74e4d9e11e6b070f2158dfd0a57a (patch) | |
tree | c07cccdddd2be777e2051ed5dab4b2d4e913469b /source/blender/gpu/opengl | |
parent | 5aa81594e6d931de01cb67399373eddae2fc7622 (diff) |
GPUShaderCreateInfo: Add DepthWrite option
This option lets specify explicitely how the fragment shader will change
the fragment's depth.
Diffstat (limited to 'source/blender/gpu/opengl')
-rw-r--r-- | source/blender/gpu/opengl/gl_shader.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 71428633d79..5938444ce49 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -217,6 +217,20 @@ static const char *to_string(const PrimitiveOut &layout) } } +static const char *to_string(const DepthWrite &value) +{ + switch (value) { + case DepthWrite::ANY: + return "depth_any"; + case DepthWrite::GREATER: + return "depth_greater"; + case DepthWrite::LESS: + return "depth_less"; + default: + return "depth_unchanged"; + } +} + static void print_image_type(std::ostream &os, const ImageType &type, const ShaderCreateInfo::Resource::BindType bind_type) @@ -585,6 +599,9 @@ std::string GLShader::fragment_interface_declare(const ShaderCreateInfo &info) c if (info.early_fragment_test_) { ss << "layout(early_fragment_tests) in;\n"; } + if (GLEW_VERSION_4_2 || GLEW_ARB_conservative_depth) { + ss << "layout(" << to_string(info.depth_write_) << ") out float gl_FragDepth;\n"; + } ss << "\n/* Outputs. */\n"; for (const ShaderCreateInfo::FragOut &output : info.fragment_outputs_) { ss << "layout(location = " << output.index; |