diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.cpp b/renderdoc/driver/shaders/spirv/spirv_debug.cpp index da5ab07d3..52f9e9ec1 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug.cpp @@ -1147,6 +1147,27 @@ void ThreadState::StepNext(ShaderDebugState *state, SetDst(state, math.result, var); break; } + case Op::FNegate: + case Op::SNegate: + { + OpFNegate math(it); + + ShaderVariable var = GetSrc(math.operand); + + if(opdata.op == Op::FNegate) + { + for(uint8_t c = 0; c < var.columns; c++) + var.value.fv[c] = -var.value.fv[c]; + } + else if(opdata.op == Op::SNegate) + { + for(uint8_t c = 0; c < var.columns; c++) + var.value.iv[c] = -var.value.iv[c]; + } + + SetDst(state, math.result, var); + break; + } ////////////////////////////////////////////////////////////////////////////// // diff --git a/util/test/demos/vk/vk_shader_debug_zoo.cpp b/util/test/demos/vk/vk_shader_debug_zoo.cpp index f25e5a191..99c1c9048 100644 --- a/util/test/demos/vk/vk_shader_debug_zoo.cpp +++ b/util/test/demos/vk/vk_shader_debug_zoo.cpp @@ -407,6 +407,8 @@ void main() 16 %test_16 17 %test_17 18 %test_18 + 19 %test_19 + 20 %test_20 ; test OpVectorShuffle %test_0 = OpLabel @@ -565,6 +567,38 @@ void main() OpStore %Color %Color_18 OpBranch %break + ; test fnegate + %test_19 = OpLabel + %a_19 = OpFAdd %float %zerof %float_4 + %b_19 = OpFAdd %float %zerof %float_neg15 + %c_19 = OpFAdd %float %zerof %zerof + %d_19 = OpFAdd %float %zerof %float_3 + %x_19 = OpFNegate %float %a_19 + %y_19 = OpFNegate %float %b_19 + %z_19 = OpFNegate %float %c_19 + %w_19 = OpFNegate %float %d_19 + %Color_19 = OpCompositeConstruct %float4 %x_19 %y_19 %z_19 %w_19 + OpStore %Color %Color_19 + OpBranch %break + + ; test snegate + %test_20 = OpLabel + %a_20 = OpIAdd %int %zeroi %int_4 + %b_20 = OpIAdd %int %zeroi %int_neg15 + %c_20 = OpIAdd %int %zeroi %zeroi + %d_20 = OpIAdd %int %zeroi %int_7 + %x_20 = OpSNegate %int %a_20 + %y_20 = OpSNegate %int %b_20 + %z_20 = OpSNegate %int %c_20 + %w_20 = OpSNegate %int %d_20 + %xf_20 = OpConvertSToF %float %x_20 + %yf_20 = OpConvertSToF %float %y_20 + %zf_20 = OpConvertSToF %float %z_20 + %wf_20 = OpConvertSToF %float %w_20 + %Color_20 = OpCompositeConstruct %float4 %xf_20 %yf_20 %zf_20 %wf_20 + OpStore %Color %Color_20 + OpBranch %break + %default = OpLabel OpStore %Color %float_0000 OpBranch %break