On Thu Apr 20 04:33:16 2023 +0000, Ethan Lee wrote:
Thought about this a little bit more and realized that if FNA was working and vkd3d wasn't, this likely meant that DXBC was fine and SPIR-V was not - I skimmed through spirv.c and, remembering that TEXKILL and DISCARD got separated, I tried to match all the instances of both and realized that there was a missing case! I made this change and now the "9 8 7 6" test mostly works:
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index b49f25c7..89346c1a 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9574,6 +9574,7 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, case VKD3DSIH_RET: case VKD3DSIH_RETP: case VKD3DSIH_SWITCH: + case VKD3DSIH_DISCARD: case VKD3DSIH_TEXKILL: ret = spirv_compiler_emit_control_flow_instruction(compiler, instruction); break;
The test did need some tweaking, as did the Vulkan runner; I assume this has more to do with the aforementioned clearing issues (EDIT: Had some extra lines in the test diff, woops):
diff --git a/tests/hlsl-discard.shader_test b/tests/hlsl-discard.shader_test index d99c49c6..f543f877 100644 --- a/tests/hlsl-discard.shader_test +++ b/tests/hlsl-discard.shader_test @@ -3,14 +3,14 @@ uniform float4 x; float4 main() : sv_target { - if (x.x == 0.0f) discard; - return float4(1, 2, 3, 4); + if (x.x == 9.0f) discard; + return x; } [test] -uniform 0 float4 1 0 0 0 +uniform 0 float4 1 2 3 4 draw quad probe all rgba (1, 2, 3, 4) -uniform 0 float4 0 0 0 0 +uniform 0 float4 9 8 7 6 draw quad probe all rgba (1, 2, 3, 4) diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index aca17a1a..8aff9c69 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -966,8 +966,6 @@ static bool vulkan_runner_draw(struct shader_runner *r, clear_rect.baseArrayLayer = 0; clear_rect.layerCount = 1; - VK_CALL(vkCmdClearAttachments(cmd_buffer, 1, &clear_attachment, 1, &clear_rect)); - VK_CALL(vkCmdBindPipeline(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline)); bind_resources(runner, VK_PIPELINE_BIND_POINT_GRAPHICS, set_layout, pipeline_layout);
This gets all tests to pass on my lab boxes!
I think all of that makes sense, yeah.