vkd3d-shader/spirv: Implement the WAVE_OP_* instructions.

This commit is contained in:
Conor McCarthy 2024-04-23 21:35:27 +10:00 committed by Alexandre Julliard
parent c71751edc9
commit cfcc789b42
Notes: Alexandre Julliard 2024-05-06 22:37:06 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/827
5 changed files with 38 additions and 14 deletions

View File

@ -9826,6 +9826,22 @@ static SpvOp map_wave_alu_op(enum vkd3d_shader_opcode handler_idx, bool is_float
return SpvOpGroupNonUniformBitwiseOr; return SpvOpGroupNonUniformBitwiseOr;
case VKD3DSIH_WAVE_ACTIVE_BIT_XOR: case VKD3DSIH_WAVE_ACTIVE_BIT_XOR:
return SpvOpGroupNonUniformBitwiseXor; 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: default:
vkd3d_unreachable(); vkd3d_unreachable();
} }
@ -9849,7 +9865,7 @@ static void spirv_compiler_emit_wave_alu_op(struct spirv_compiler *compiler,
vkd3d_spirv_enable_capability(builder, SpvCapabilityGroupNonUniformArithmetic); vkd3d_spirv_enable_capability(builder, SpvCapabilityGroupNonUniformArithmetic);
val_id = vkd3d_spirv_build_op_tr3(builder, &builder->function_stream, op, type_id, val_id = vkd3d_spirv_build_op_tr3(builder, &builder->function_stream, op, type_id,
vkd3d_spirv_get_op_scope_subgroup(builder), vkd3d_spirv_get_op_scope_subgroup(builder),
SpvGroupOperationReduce, (instruction->flags & VKD3DSI_WAVE_PREFIX) ? SpvGroupOperationExclusiveScan : SpvGroupOperationReduce,
val_id); val_id);
spirv_compiler_emit_store_dst(compiler, dst, 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_AND:
case VKD3DSIH_WAVE_ACTIVE_BIT_OR: case VKD3DSIH_WAVE_ACTIVE_BIT_OR:
case VKD3DSIH_WAVE_ACTIVE_BIT_XOR: 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); spirv_compiler_emit_wave_alu_op(compiler, instruction);
break; break;
case VKD3DSIH_DCL: case VKD3DSIH_DCL:

View File

@ -133,7 +133,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [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 (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 (1) rgba (14.0, 4.5, 16.5, 10.0)
probe uav 1 (2) 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] [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 (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 (1) rgba (150.0625, 1.5, 288.0, 39.0625)
probe uav 1 (2) 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] [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 (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 (1) rgba (3.5, 1.0, 4.0, 2.5)
probe uav 1 (2) 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] [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 (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 (1) rgba (3.5, 1.5, 4.5, 2.5)
probe uav 1 (2) 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] [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 (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 (1) rgba (3.5, 1.0, 4.0, 2.5)
probe uav 1 (2) rgba (7.0, 2.0, 8.0, 5.0) probe uav 1 (2) rgba (7.0, 2.0, 8.0, 5.0)
@ -223,7 +223,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [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 (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 (1) rgba (3.5, 1.0, 4.0, 2.5)
probe uav 1 (2) rgba (12.25, 1.0, 16.0, 6.25) probe uav 1 (2) rgba (12.25, 1.0, 16.0, 6.25)

View File

@ -31,7 +31,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [test]
todo dispatch 4 1 1 dispatch 4 1 1
probe uav 1 (0) rgbai (-3, 1, -4, 2) probe uav 1 (0) rgbai (-3, 1, -4, 2)
probe uav 1 (1) rgbai (-3, 1, -4, 2) probe uav 1 (1) rgbai (-3, 1, -4, 2)
probe uav 1 (2) 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] [test]
todo dispatch 4 1 1 dispatch 4 1 1
probe uav 1 (0) rgbai (3, 5, -1, 2) probe uav 1 (0) rgbai (3, 5, -1, 2)
probe uav 1 (1) rgbai (3, 5, -1, 2) probe uav 1 (1) rgbai (3, 5, -1, 2)
probe uav 1 (2) rgbai (3, 5, -1, 2) probe uav 1 (2) rgbai (3, 5, -1, 2)

View File

@ -101,7 +101,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [test]
todo dispatch 4 1 1 dispatch 4 1 1
probe uav 1 (0) rui (8) probe uav 1 (0) rui (8)
probe uav 1 (1) rui (8) probe uav 1 (1) rui (8)
probe uav 1 (2) rui (8) probe uav 1 (2) rui (8)
@ -214,7 +214,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [test]
todo dispatch 4 1 1 dispatch 4 1 1
probe uav 1 (0) rui (41) probe uav 1 (0) rui (41)
probe uav 1 (1) rui (41) probe uav 1 (1) rui (41)
probe uav 1 (2) rui (41) probe uav 1 (2) rui (41)
@ -298,7 +298,7 @@ void main(uint id : SV_GroupIndex)
[test] [test]
uniform 0 uint4 1 5 0 0 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 (0) rui (29)
probe uav 1 (1) rui (29) probe uav 1 (1) rui (29)
probe uav 1 (2) rui (29) probe uav 1 (2) rui (29)

View File

@ -56,7 +56,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [test]
todo dispatch 4 1 1 dispatch 4 1 1
probe uav 2 (0) rui (0xf01) probe uav 2 (0) rui (0xf01)
probe uav 2 (1) rui (0x503) probe uav 2 (1) rui (0x503)
probe uav 2 (2) rui (0x511) probe uav 2 (2) rui (0x511)
@ -124,7 +124,7 @@ void main(uint id : SV_GroupIndex)
} }
[test] [test]
todo dispatch 4 1 1 dispatch 4 1 1
probe uav 2 (0) rui (0x701) probe uav 2 (0) rui (0x701)
probe uav 2 (1) rui (0x503) probe uav 2 (1) rui (0x503)
probe uav 2 (2) rui (0x511) probe uav 2 (2) rui (0x511)