diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index ebbddccbe47..ffbeedad285 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -68,7 +68,9 @@ void ShaderCreateInfo::finalize() if (info.early_fragment_test_) { early_fragment_test_ = true; } - if (info.depth_write_ != DepthWrite::ANY) { + /* Override depth-write with additional info if this specifies a writing mode + * other than the default. */ + if (info.depth_write_ != DepthWrite::UNCHANGED) { depth_write_ = info.depth_write_; } diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh index 25a79dd26ac..79164ca37f7 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.hh +++ b/source/blender/gpu/intern/gpu_shader_create_info.hh @@ -189,10 +189,11 @@ ENUM_OPERATORS(BuiltinBits, BuiltinBits::USE_DEBUG_PRINT); * https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_conservative_depth.txt */ enum class DepthWrite { - ANY = 0, + /* UNCHANGED specified as default to indicate gl_FragDepth is not used. */ + UNCHANGED = 0, + ANY, GREATER, LESS, - UNCHANGED, }; /* Samplers & images. */ @@ -343,7 +344,7 @@ struct ShaderCreateInfo { /** If true, force the use of the GL shader introspection for resource location. */ bool legacy_resource_location_ = false; /** Allow optimization when fragment shader writes to `gl_FragDepth`. */ - DepthWrite depth_write_ = DepthWrite::ANY; + DepthWrite depth_write_ = DepthWrite::UNCHANGED; /** * Maximum length of all the resource names including each null terminator. * Only for names used by #gpu::ShaderInterface. diff --git a/source/blender/gpu/metal/kernels/depth_2d_update_info.hh b/source/blender/gpu/metal/kernels/depth_2d_update_info.hh index 0a3281a98f2..4f8b15b9784 100644 --- a/source/blender/gpu/metal/kernels/depth_2d_update_info.hh +++ b/source/blender/gpu/metal/kernels/depth_2d_update_info.hh @@ -17,6 +17,7 @@ GPU_SHADER_CREATE_INFO(depth_2d_update_info_base) .push_constant(Type::VEC2, "size") .push_constant(Type::INT, "mip") .sampler(0, ImageType::FLOAT_2D, "source_data", Frequency::PASS) + .depth_write(DepthWrite::ANY) .vertex_source("depth_2d_update_vert.glsl"); GPU_SHADER_CREATE_INFO(depth_2d_update_float)