45ad58a903
In some cases we need to bitcast when dealing with int vs. uint. SPIR-V allows inputs to be of different integer signedness, so we need to deal with this somehow. Add testing system to test SPIR-V assembly. For now, test all possible combination for all major cases. - IAdd (which doesn't care about input type as long as they're equal) - SDiv/UDiv operations which case about input type. - Arith/Logical right shifts. - IEqual to test outputs to bvec, which shouldn't get output cast. Also tests casting in function-like calls.
78 lines
3.1 KiB
Plaintext
78 lines
3.1 KiB
Plaintext
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: Khronos Glslang Reference Front End; 1
|
|
; Bound: 30
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint GLCompute %func "main"
|
|
OpExecutionMode %func LocalSize 1 1 1
|
|
OpSource ESSL 310
|
|
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
|
|
OpSourceExtension "GL_GOOGLE_include_directive"
|
|
OpMemberDecorate %input_struct 0 Offset 0
|
|
OpMemberDecorate %input_struct 1 Offset 16
|
|
OpMemberDecorate %output_struct 0 Offset 0
|
|
OpMemberDecorate %output_struct 1 Offset 16
|
|
OpDecorate %input_struct BufferBlock
|
|
OpDecorate %inputs DescriptorSet 0
|
|
OpDecorate %inputs Binding 0
|
|
OpDecorate %output_struct BufferBlock
|
|
OpDecorate %outputs DescriptorSet 0
|
|
OpDecorate %outputs Binding 1
|
|
|
|
%void = OpTypeVoid
|
|
%main_func = OpTypeFunction %void
|
|
|
|
%uint = OpTypeInt 32 0
|
|
%uvec4 = OpTypeVector %uint 4
|
|
|
|
%int = OpTypeInt 32 1
|
|
%ivec4 = OpTypeVector %int 4
|
|
|
|
%ivec4_ptr = OpTypePointer Uniform %ivec4
|
|
%uvec4_ptr = OpTypePointer Uniform %uvec4
|
|
|
|
%zero = OpConstant %int 0
|
|
%one = OpConstant %int 1
|
|
|
|
%input_struct = OpTypeStruct %ivec4 %uvec4
|
|
%input_struct_ptr = OpTypePointer Uniform %input_struct
|
|
%inputs = OpVariable %input_struct_ptr Uniform
|
|
%output_struct = OpTypeStruct %uvec4 %ivec4
|
|
%output_struct_ptr = OpTypePointer Uniform %output_struct
|
|
%outputs = OpVariable %output_struct_ptr Uniform
|
|
|
|
%func = OpFunction %void None %main_func
|
|
%block = OpLabel
|
|
|
|
%input1_ptr = OpAccessChain %ivec4_ptr %inputs %zero
|
|
%input0_ptr = OpAccessChain %uvec4_ptr %inputs %one
|
|
%input1 = OpLoad %ivec4 %input1_ptr
|
|
%input0 = OpLoad %uvec4 %input0_ptr
|
|
|
|
%output_ptr_uvec4 = OpAccessChain %uvec4_ptr %outputs %zero
|
|
%output_ptr_ivec4 = OpAccessChain %ivec4_ptr %outputs %one
|
|
|
|
; Test all variants of ShiftRightLogical
|
|
%result_iadd_0 = OpShiftRightLogical %uvec4 %input0 %input1
|
|
%result_iadd_1 = OpShiftRightLogical %uvec4 %input1 %input0
|
|
%result_iadd_2 = OpShiftRightLogical %uvec4 %input0 %input0
|
|
%result_iadd_3 = OpShiftRightLogical %uvec4 %input1 %input1
|
|
%result_iadd_4 = OpShiftRightLogical %ivec4 %input0 %input0
|
|
%result_iadd_5 = OpShiftRightLogical %ivec4 %input1 %input1
|
|
%result_iadd_6 = OpShiftRightLogical %ivec4 %input0 %input1
|
|
%result_iadd_7 = OpShiftRightLogical %ivec4 %input1 %input0
|
|
OpStore %output_ptr_uvec4 %result_iadd_0
|
|
OpStore %output_ptr_uvec4 %result_iadd_1
|
|
OpStore %output_ptr_uvec4 %result_iadd_2
|
|
OpStore %output_ptr_uvec4 %result_iadd_3
|
|
OpStore %output_ptr_ivec4 %result_iadd_4
|
|
OpStore %output_ptr_ivec4 %result_iadd_5
|
|
OpStore %output_ptr_ivec4 %result_iadd_6
|
|
OpStore %output_ptr_ivec4 %result_iadd_7
|
|
|
|
OpReturn
|
|
OpFunctionEnd
|