From 8984abfc76ec82cba2c919934981a5a5bf9216e7 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 15 Sep 2021 20:14:39 +0200 Subject: Spir-V: Rescale the frag depth to 0,1 mode when -1,1 mode is used in Vulkan. --- .../backend/spirv/emit_spirv_context_get_set.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 68f360b3c..6f60c6574 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -477,7 +477,13 @@ void EmitSetSampleMask(EmitContext& ctx, Id value) { } void EmitSetFragDepth(EmitContext& ctx, Id value) { - ctx.OpStore(ctx.frag_depth, value); + if (!ctx.runtime_info.convert_depth_mode) { + ctx.OpStore(ctx.frag_depth, value); + return; + } + const Id unit{ctx.Const(0.5f)}; + const Id new_depth{ctx.OpFma(ctx.F32[1], value, unit, unit)}; + ctx.OpStore(ctx.frag_depth, new_depth); } void EmitGetZFlag(EmitContext&) { -- cgit v1.2.3