Module: vkd3d Branch: master Commit: cfcc789b42ea707ed701cbcb0600be6156cfbbb1 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/cfcc789b42ea707ed701cbcb0600be...
Author: Conor McCarthy cmccarthy@codeweavers.com Date: Tue Apr 23 21:35:27 2024 +1000
vkd3d-shader/spirv: Implement the WAVE_OP_* instructions.
---
libs/vkd3d-shader/spirv.c | 26 +++++++++++++++++++++++++- tests/hlsl/wave-ops-float.shader_test | 12 ++++++------ tests/hlsl/wave-ops-int.shader_test | 4 ++-- tests/hlsl/wave-ops-uint.shader_test | 6 +++--- tests/hlsl/wave-reconvergence.shader_test | 4 ++-- 5 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 60c08be2..7ac9f3cd 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9826,6 +9826,22 @@ static SpvOp map_wave_alu_op(enum vkd3d_shader_opcode handler_idx, bool is_float return SpvOpGroupNonUniformBitwiseOr; case VKD3DSIH_WAVE_ACTIVE_BIT_XOR: return SpvOpGroupNonUniformBitwiseXor; + case VKD3DSIH_WAVE_OP_ADD: + return is_float ? SpvOpGroupNonUniformFAdd : SpvOpGroupNonUniformIAdd; + case VKD3DSIH_WAVE_OP_IMAX: + return SpvOpGroupNonUniformSMax; + case VKD3DSIH_WAVE_OP_IMIN: + return SpvOpGroupNonUniformSMin; + case VKD3DSIH_WAVE_OP_MAX: + return SpvOpGroupNonUniformFMax; + case VKD3DSIH_WAVE_OP_MIN: + return SpvOpGroupNonUniformFMin; + case VKD3DSIH_WAVE_OP_MUL: + return is_float ? SpvOpGroupNonUniformFMul : SpvOpGroupNonUniformIMul; + case VKD3DSIH_WAVE_OP_UMAX: + return SpvOpGroupNonUniformUMax; + case VKD3DSIH_WAVE_OP_UMIN: + return SpvOpGroupNonUniformUMin; default: vkd3d_unreachable(); } @@ -9849,7 +9865,7 @@ static void spirv_compiler_emit_wave_alu_op(struct spirv_compiler *compiler, vkd3d_spirv_enable_capability(builder, SpvCapabilityGroupNonUniformArithmetic); val_id = vkd3d_spirv_build_op_tr3(builder, &builder->function_stream, op, type_id, vkd3d_spirv_get_op_scope_subgroup(builder), - SpvGroupOperationReduce, + (instruction->flags & VKD3DSI_WAVE_PREFIX) ? SpvGroupOperationExclusiveScan : SpvGroupOperationReduce, val_id);
spirv_compiler_emit_store_dst(compiler, dst, val_id); @@ -10210,6 +10226,14 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, case VKD3DSIH_WAVE_ACTIVE_BIT_AND: case VKD3DSIH_WAVE_ACTIVE_BIT_OR: case VKD3DSIH_WAVE_ACTIVE_BIT_XOR: + case VKD3DSIH_WAVE_OP_ADD: + case VKD3DSIH_WAVE_OP_IMAX: + case VKD3DSIH_WAVE_OP_IMIN: + case VKD3DSIH_WAVE_OP_MAX: + case VKD3DSIH_WAVE_OP_MIN: + case VKD3DSIH_WAVE_OP_MUL: + case VKD3DSIH_WAVE_OP_UMAX: + case VKD3DSIH_WAVE_OP_UMIN: spirv_compiler_emit_wave_alu_op(compiler, instruction); break; case VKD3DSIH_DCL: diff --git a/tests/hlsl/wave-ops-float.shader_test b/tests/hlsl/wave-ops-float.shader_test index 2c402db1..60774fa8 100644 --- a/tests/hlsl/wave-ops-float.shader_test +++ b/tests/hlsl/wave-ops-float.shader_test @@ -133,7 +133,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgba (14.0, 4.5, 16.5, 10.0) probe uav 1 (1) rgba (14.0, 4.5, 16.5, 10.0) probe uav 1 (2) rgba (14.0, 4.5, 16.5, 10.0) @@ -151,7 +151,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgba (150.0625, 1.5, 288.0, 39.0625) probe uav 1 (1) rgba (150.0625, 1.5, 288.0, 39.0625) probe uav 1 (2) rgba (150.0625, 1.5, 288.0, 39.0625) @@ -169,7 +169,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgba (3.5, 1.0, 4.0, 2.5) probe uav 1 (1) rgba (3.5, 1.0, 4.0, 2.5) probe uav 1 (2) rgba (3.5, 1.0, 4.0, 2.5) @@ -187,7 +187,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgba (3.5, 1.5, 4.5, 2.5) probe uav 1 (1) rgba (3.5, 1.5, 4.5, 2.5) probe uav 1 (2) rgba (3.5, 1.5, 4.5, 2.5) @@ -205,7 +205,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgba (0.0, 0.0, 0.0, 0.0) probe uav 1 (1) rgba (3.5, 1.0, 4.0, 2.5) probe uav 1 (2) rgba (7.0, 2.0, 8.0, 5.0) @@ -223,7 +223,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgba (1.0, 1.0, 1.0, 1.0) probe uav 1 (1) rgba (3.5, 1.0, 4.0, 2.5) probe uav 1 (2) rgba (12.25, 1.0, 16.0, 6.25) diff --git a/tests/hlsl/wave-ops-int.shader_test b/tests/hlsl/wave-ops-int.shader_test index 5c9a365f..bc6976ba 100644 --- a/tests/hlsl/wave-ops-int.shader_test +++ b/tests/hlsl/wave-ops-int.shader_test @@ -31,7 +31,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgbai (-3, 1, -4, 2) probe uav 1 (1) rgbai (-3, 1, -4, 2) probe uav 1 (2) rgbai (-3, 1, -4, 2) @@ -49,7 +49,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rgbai (3, 5, -1, 2) probe uav 1 (1) rgbai (3, 5, -1, 2) probe uav 1 (2) rgbai (3, 5, -1, 2) diff --git a/tests/hlsl/wave-ops-uint.shader_test b/tests/hlsl/wave-ops-uint.shader_test index cb502e86..c16adab4 100644 --- a/tests/hlsl/wave-ops-uint.shader_test +++ b/tests/hlsl/wave-ops-uint.shader_test @@ -101,7 +101,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rui (8) probe uav 1 (1) rui (8) probe uav 1 (2) rui (8) @@ -214,7 +214,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rui (41) probe uav 1 (1) rui (41) probe uav 1 (2) rui (41) @@ -298,7 +298,7 @@ void main(uint id : SV_GroupIndex)
[test] uniform 0 uint4 1 5 0 0 -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 1 (0) rui (29) probe uav 1 (1) rui (29) probe uav 1 (2) rui (29) diff --git a/tests/hlsl/wave-reconvergence.shader_test b/tests/hlsl/wave-reconvergence.shader_test index 66698da8..0a1da3ee 100644 --- a/tests/hlsl/wave-reconvergence.shader_test +++ b/tests/hlsl/wave-reconvergence.shader_test @@ -56,7 +56,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 2 (0) rui (0xf01) probe uav 2 (1) rui (0x503) probe uav 2 (2) rui (0x511) @@ -124,7 +124,7 @@ void main(uint id : SV_GroupIndex) }
[test] -todo dispatch 4 1 1 +dispatch 4 1 1 probe uav 2 (0) rui (0x701) probe uav 2 (1) rui (0x503) probe uav 2 (2) rui (0x511)