// 7. inputC.a.r[?][?].(x|y)[?][?] or inputC.b.r[?][?].(x|y)[?][?] = scalars
const int numLevels = 7;
- const string decorations (
+ const string commonDecorations (
// Decorations
"OpDecorate %id BuiltIn GlobalInvocationId \n"
- "OpDecorate %inputA DescriptorSet 0 \n"
- "OpDecorate %inputB DescriptorSet 0 \n"
- "OpDecorate %inputC DescriptorSet 0 \n"
"OpDecorate %outdata DescriptorSet 0 \n"
- "OpDecorate %inputA Binding 0 \n"
- "OpDecorate %inputB Binding 1 \n"
- "OpDecorate %inputC Binding 2 \n"
"OpDecorate %outdata Binding 3 \n"
// Set the Block decoration
- "OpDecorate %outer_struct Block \n"
- "OpDecorate %input_buffer Block \n"
"OpDecorate %output_buffer Block \n"
// Set the Offsets
"OpDecorate %v4f32_ptr ArrayStride 16 \n"
);
+ const string inputABDecorations (
+ "OpDecorate %inputA DescriptorSet 0 \n"
+ "OpDecorate %inputB DescriptorSet 0 \n"
+ "OpDecorate %inputA Binding 0 \n"
+ "OpDecorate %inputB Binding 1 \n"
+
+ // inputA and inputB have type outer_struct so it needs Block
+ "OpDecorate %outer_struct Block \n"
+ );
+
+ const string inputCDecorations (
+ "OpDecorate %inputC DescriptorSet 0 \n"
+ "OpDecorate %inputC Binding 2 \n"
+
+ // inputC has type input_buffer so it needs Block
+ "OpDecorate %input_buffer Block \n"
+ );
+
const string types (
///////////////
// CONSTANTS //
// VARIABLES //
///////////////
"%id = OpVariable %uvec3ptr Input \n"
+ "%outdata = OpVariable %output_buffer_ptr StorageBuffer \n"
+ );
+
+ const string inputABVariables (
"%inputA = OpVariable %outer_struct_ptr StorageBuffer \n"
"%inputB = OpVariable %outer_struct_ptr StorageBuffer \n"
+ );
+
+ const string inputCVariables (
"%inputC = OpVariable %input_buffer_ptr StorageBuffer \n"
- "%outdata = OpVariable %output_buffer_ptr StorageBuffer \n"
+ );
+
+ const string inputCIntermediates (
+ // Here are the 2 nested structures within InputC.
+ "%inputC_a = OpAccessChain %outer_struct_ptr %inputC %c_i32_0\n"
+ "%inputC_b = OpAccessChain %outer_struct_ptr %inputC %c_i32_1\n"
);
const StringTemplate shaderTemplate (
"OpName %main \"main\"\n"
"OpName %id \"gl_GlobalInvocationID\"\n"
- + decorations
+ + commonDecorations +
+
+ "${input_decorations}\n"
+ string(getComputeAsmCommonTypes())
+ types +
+ "${input_variables}\n"
+
// These selector functions return variable pointers.
// These functions are used by tests that use OpFunctionCall to obtain the variable pointer
"%selector_func_type = OpTypeFunction ${selected_type} %bool ${selected_type} ${selected_type}\n"
"%main = OpFunction %void None %voidf\n"
"%label = OpLabel\n"
- // Here are the 2 nested structures within InputC.
- "%inputC_a = OpAccessChain %outer_struct_ptr %inputC %c_i32_0\n"
- "%inputC_b = OpAccessChain %outer_struct_ptr %inputC %c_i32_1\n"
+ "${input_intermediates}\n"
// Define the 2 pointers from which we're going to choose one.
"${a_loc} \n"
for (int selectInputA = 0; selectInputA < 2; ++selectInputA)
{
const string extraCap = isSingleInputBuffer ? "OpCapability VariablePointersStorageBuffer\n" : "OpCapability VariablePointers\n";
+ const string inputDecorations = isSingleInputBuffer ? inputCDecorations : inputABDecorations;
+ const string inputVariables = isSingleInputBuffer ? inputCVariables : inputABVariables;
+ const string inputIntermediates = isSingleInputBuffer ? inputCIntermediates : "";
const vector<float>& selectedInput = isSingleInputBuffer ? inputC : (selectInputA ? inputA : inputB);
const string bufferType = isSingleInputBuffer ? "single_buffer_" : "two_buffers_";
const string baseA = isSingleInputBuffer ? "%inputC_a" : "%inputA";
string opCodeForTests = "opselect";
string name = opCodeForTests + indexLevelNames[indexLevel] + bufferType + selectedInputStr;
specs["extra_capability"] = extraCap;
+ specs["input_decorations"] = inputDecorations;
+ specs["input_variables"] = inputVariables;
+ specs["input_intermediates"] = inputIntermediates;
specs["selected_type"] = pointerTypeAtLevel[indexLevel];
specs["select_inputA"] = spirvSelectInputA;
specs["a_loc"] = inputALocations[indexLevel];
string opCodeForTests = "opfunctioncall";
string name = opCodeForTests + indexLevelNames[indexLevel] + bufferType + selectedInputStr;
specs["extra_capability"] = extraCap;
+ specs["input_decorations"] = inputDecorations;
+ specs["input_variables"] = inputVariables;
+ specs["input_intermediates"] = inputIntermediates;
specs["selected_type"] = pointerTypeAtLevel[indexLevel];
specs["select_inputA"] = spirvSelectInputA;
specs["a_loc"] = inputALocations[indexLevel];
string opCodeForTests = "opphi";
string name = opCodeForTests + indexLevelNames[indexLevel] + bufferType + selectedInputStr;
specs["extra_capability"] = extraCap;
+ specs["input_decorations"] = inputDecorations;
+ specs["input_variables"] = inputVariables;
+ specs["input_intermediates"] = inputIntermediates;
specs["selected_type"] = pointerTypeAtLevel[indexLevel];
specs["select_inputA"] = spirvSelectInputA;
specs["a_loc"] = inputALocations[indexLevel];
string opCodeForTests = "opcopyobject";
string name = opCodeForTests + indexLevelNames[indexLevel] + bufferType + selectedInputStr;
specs["extra_capability"] = extraCap;
+ specs["input_decorations"] = inputDecorations;
+ specs["input_variables"] = inputVariables;
+ specs["input_intermediates"] = inputIntermediates;
specs["selected_type"] = pointerTypeAtLevel[indexLevel];
specs["select_inputA"] = spirvSelectInputA;
specs["a_loc"] = inputALocations[indexLevel];
string opCodeForTests = "opptraccesschain";
string name = opCodeForTests + indexLevelNames[indexLevel] + bufferType + selectedInputStr;
specs["extra_capability"] = extraCap;
+ specs["input_decorations"] = inputDecorations;
+ specs["input_variables"] = inputVariables;
+ specs["input_intermediates"] = inputIntermediates;
specs["selected_type"] = pointerTypeAtLevel[indexLevel];
specs["select_inputA"] = spirvSelectInputA;
specs["a_loc"] = inputAPtrAccessChain[indexLevel];