2
0
Эх сурвалжийг харах

[spirv] Put constants in the right spot.

Ehsan 6 жил өмнө
parent
commit
d8102a2a66

+ 10 - 0
tools/clang/lib/SPIRV/EmitVisitor.cpp

@@ -192,6 +192,16 @@ void EmitVisitor::finalizeInstruction() {
     annotationsBinary.insert(annotationsBinary.end(), curInst.begin(),
                              curInst.end());
     break;
+  case spv::Op::OpConstant:
+  case spv::Op::OpConstantNull:
+  case spv::Op::OpConstantFalse:
+  case spv::Op::OpConstantTrue:
+  case spv::Op::OpSpecConstantTrue:
+  case spv::Op::OpSpecConstantFalse:
+  case spv::Op::OpSpecConstant:
+    typeConstantBinary.insert(typeConstantBinary.end(), curInst.begin(),
+                              curInst.end());
+    break;
   default:
     mainBinary.insert(mainBinary.end(), curInst.begin(), curInst.end());
     break;

+ 10 - 10
tools/clang/test/CodeGenSPIRV/bezier.hull.hlsl2spv

@@ -140,7 +140,17 @@ BEZIER_CONTROL_POINT SubDToBezierHS(InputPatch<VS_CONTROL_POINT_OUTPUT, MAX_POIN
 //        %uint = OpTypeInt 32 0
 //      %uint_0 = OpConstant %uint 0
 //       %float = OpTypeFloat 32
+//     %float_1 = OpConstant %float 1
 //         %int = OpTypeInt 32 1
+//       %int_0 = OpConstant %int 0
+//     %float_2 = OpConstant %float 2
+//       %int_1 = OpConstant %int 1
+//     %float_3 = OpConstant %float 3
+//       %int_2 = OpConstant %int 2
+//     %float_4 = OpConstant %float 4
+//       %int_3 = OpConstant %int 3
+//     %float_5 = OpConstant %float 5
+//     %float_6 = OpConstant %float 6
 //      %uint_3 = OpConstant %uint 3
 //     %v3float = OpTypeVector %float 3
 // %_arr_v3float_uint_3 = OpTypeArray %v3float %uint_3
@@ -179,16 +189,6 @@ BEZIER_CONTROL_POINT SubDToBezierHS(InputPatch<VS_CONTROL_POINT_OUTPUT, MAX_POIN
 // %_ptr_Function_VS_CONTROL_POINT_OUTPUT = OpTypePointer Function %VS_CONTROL_POINT_OUTPUT
 // %_ptr_Function_BEZIER_CONTROL_POINT = OpTypePointer Function %BEZIER_CONTROL_POINT
 // %_ptr_Function_v3float = OpTypePointer Function %v3float
-//     %float_1 = OpConstant %float 1
-//       %int_0 = OpConstant %int 0
-//     %float_2 = OpConstant %float 2
-//       %int_1 = OpConstant %int 1
-//     %float_3 = OpConstant %float 3
-//       %int_2 = OpConstant %int 2
-//     %float_4 = OpConstant %float 4
-//       %int_3 = OpConstant %int 3
-//     %float_5 = OpConstant %float 5
-//     %float_6 = OpConstant %float 6
 // %in_var_WORLDPOS = OpVariable %_ptr_Input__arr_v3float_uint_3 Input
 // %in_var_TEXCOORD0 = OpVariable %_ptr_Input__arr_v2float_uint_3 Input
 // %in_var_TANGENT = OpVariable %_ptr_Input__arr_v3float_uint_3 Input

+ 1 - 1
tools/clang/test/CodeGenSPIRV/passthru-cs.hlsl2spv

@@ -50,6 +50,7 @@ void main( uint3 DTid : SV_DispatchThreadID )
 //                OpMemberDecorate %type_RWByteAddressBuffer 0 Offset 0
 //                OpDecorate %type_RWByteAddressBuffer BufferBlock
 //         %int = OpTypeInt 32 1
+//       %int_0 = OpConstant %int 0
 //        %uint = OpTypeInt 32 0
 //      %uint_4 = OpConstant %uint 4
 //      %uint_2 = OpConstant %uint 2
@@ -67,7 +68,6 @@ void main( uint3 DTid : SV_DispatchThreadID )
 //          %26 = OpTypeFunction %void %_ptr_Function_v3uint
 // %_ptr_Function_uint = OpTypePointer Function %uint
 // %_ptr_Uniform_uint = OpTypePointer Uniform %uint
-//       %int_0 = OpConstant %int 0
 //     %Buffer0 = OpVariable %_ptr_Uniform_type_ByteAddressBuffer Uniform
 //   %BufferOut = OpVariable %_ptr_Uniform_type_RWByteAddressBuffer Uniform
 // %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input

+ 2 - 2
tools/clang/test/CodeGenSPIRV/passthru-vs.hlsl2spv

@@ -44,6 +44,8 @@ PSInput main(float4 position: POSITION, float4 color: COLOR) {
 //                OpMemberDecorate %PSInput 0 Offset 0
 //                OpMemberDecorate %PSInput 1 Offset 16
 //         %int = OpTypeInt 32 1
+//       %int_0 = OpConstant %int 0
+//       %int_1 = OpConstant %int 1
 //       %float = OpTypeFloat 32
 //     %v4float = OpTypeVector %float 4
 // %_ptr_Input_v4float = OpTypePointer Input %v4float
@@ -54,8 +56,6 @@ PSInput main(float4 position: POSITION, float4 color: COLOR) {
 //     %PSInput = OpTypeStruct %v4float %v4float
 //          %26 = OpTypeFunction %PSInput %_ptr_Function_v4float %_ptr_Function_v4float
 // %_ptr_Function_PSInput = OpTypePointer Function %PSInput
-//       %int_0 = OpConstant %int 0
-//       %int_1 = OpConstant %int 1
 // %in_var_POSITION = OpVariable %_ptr_Input_v4float Input
 // %in_var_COLOR = OpVariable %_ptr_Input_v4float Input
 // %gl_Position = OpVariable %_ptr_Output_v4float Output