" OpDecorate %selector Binding 1\n"
" %void = OpTypeVoid\n"
" %3 = OpTypeFunction %void\n"
- " %idx = OpTypeInt ${idxsize} ${idxsign}\n"
- " %idx_0 = OpConstant %idx 0\n"
- " %idx_1 = OpConstant %idx 1\n"
- " %idx_2 = OpConstant %idx 2\n"
- " %idx_3 = OpConstant %idx 3\n"
- " %uint32 = OpTypeInt 32 0\n"
- " %_ptr_Function_uint32 = OpTypePointer Function %uint32\n"
- " %v3uint32 = OpTypeVector %uint32 3\n"
+ " %u32 = OpTypeInt 32 0\n"
+ " %i32 = OpTypeInt 32 1\n"
+ "${intdecl:opt}"
+ " %idx_0 = OpConstant ${idx_int} 0\n"
+ " %idx_1 = OpConstant ${idx_int} 1\n"
+ " %idx_2 = OpConstant ${idx_int} 2\n"
+ " %idx_3 = OpConstant ${idx_int} 3\n"
+ " %_ptr_Function_uint32 = OpTypePointer Function %u32\n"
+ " %v3uint32 = OpTypeVector %u32 3\n"
" %_ptr_Input_v3uint32 = OpTypePointer Input %v3uint32\n"
" %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint32 Input\n"
- " %_ptr_Input_uint32 = OpTypePointer Input %uint32\n"
+ " %_ptr_Input_uint32 = OpTypePointer Input %u32\n"
" %float = OpTypeFloat 32\n"
- " %uint_128 = OpConstant %uint32 128\n"
- " %uint_32 = OpConstant %uint32 32\n"
- " %uint_2 = OpConstant %uint32 2\n"
+ " %uint_128 = OpConstant %u32 128\n"
+ " %uint_32 = OpConstant %u32 32\n"
+ " %uint_2 = OpConstant %u32 2\n"
" %_arr_float_uint_128 = OpTypeArray %float %uint_128\n"
" %Output = OpTypeStruct %_arr_float_uint_128\n"
" %_ptr_Uniform_Output = OpTypePointer Uniform %Output\n"
" %_ptr_buffer_Input = OpTypePointer ${inputstorageclass} %Input\n"
" %dataInput = OpVariable %_ptr_buffer_Input ${inputstorageclass}\n"
" %_ptr_buffer_InputStruct = OpTypePointer ${inputstorageclass} %InputStruct\n"
- " %v4uint32 = OpTypeVector %uint32 4\n"
+ " %v4uint32 = OpTypeVector %u32 4\n"
" %_arr_v4uint_uint_128 = OpTypeArray %v4uint32 %uint_128\n"
" %DataSelector = OpTypeStruct %_arr_v4uint_uint_128\n"
"%_ptr_Uniform_DataSelector = OpTypePointer Uniform %DataSelector\n"
" %selector = OpVariable %_ptr_Uniform_DataSelector Uniform\n"
- " %_ptr_Uniform_uint32 = OpTypePointer Uniform %uint32\n"
+ " %_ptr_Uniform_uint32 = OpTypePointer Uniform %u32\n"
" %_ptr_Uniform_float = OpTypePointer Uniform %float\n"
- " %_ptr_buffer_float = OpTypePointer ${inputstorageclass} %float\n"
+ " ${ptr_buffer_float:opt}\n"
" %main = OpFunction %void None %3\n"
" %5 = OpLabel\n"
" %i = OpVariable %_ptr_Function_uint32 Function\n"
" %14 = OpAccessChain %_ptr_Input_uint32 %gl_GlobalInvocationID %idx_0\n"
- " %15 = OpLoad %uint32 %14\n"
+ " %15 = OpLoad %u32 %14\n"
" OpStore %i %15\n"
- " %uint_i = OpLoad %uint32 %i\n"
+ " %uint_i = OpLoad %u32 %i\n"
" %39 = OpAccessChain %_ptr_Uniform_uint32 %selector %idx_0 %uint_i %idx_0\n"
- " %40 = OpLoad %uint32 %39\n"
+ " %40 = OpLoad %u32 %39\n"
" %43 = OpAccessChain %_ptr_Uniform_uint32 %selector %idx_0 %uint_i %idx_1\n"
- " %44 = OpLoad %uint32 %43\n"
+ " %44 = OpLoad %u32 %43\n"
" %47 = OpAccessChain %_ptr_Uniform_uint32 %selector %idx_0 %uint_i %idx_2\n"
- " %48 = OpLoad %uint32 %47\n"
+ " %48 = OpLoad %u32 %47\n"
" %51 = OpAccessChain %_ptr_Uniform_uint32 %selector %idx_0 %uint_i %idx_3\n"
- " %52 = OpLoad %uint32 %51\n"
- " %i0 = OpUConvert %idx %40\n"
- " %i1 = OpUConvert %idx %44\n"
- " %i2 = OpUConvert %idx %48\n"
- " %i3 = OpUConvert %idx %52\n"
+ " %52 = OpLoad %u32 %51\n"
+ " %i0 = ${convert} ${idx_int} %40\n"
+ " %i1 = ${convert} ${idx_int} %44\n"
+ " %i2 = ${convert} ${idx_int} %48\n"
+ " %i3 = ${convert} ${idx_int} %52\n"
" %inputFirstElement = OpAccessChain %_ptr_buffer_InputStruct %dataInput %idx_0 %idx_0\n"
" %54 = ${accesschain}\n"
" %55 = OpLoad %float %54\n"
switch (chainOpIdx)
{
case CHAIN_OP_ACCESS_CHAIN:
- specs["accesschain"] = "OpAccessChain %_ptr_buffer_float %inputFirstElement %idx_0 %i0 %i1 %i2 %i3\n";
+ specs["accesschain"] = "OpAccessChain %_ptr_Uniform_float %inputFirstElement %idx_0 %i0 %i1 %i2 %i3\n";
specs["inputdecoration"] = "BufferBlock";
specs["inputstorageclass"] = "Uniform";
break;
case CHAIN_OP_IN_BOUNDS_ACCESS_CHAIN:
- specs["accesschain"] = "OpInBoundsAccessChain %_ptr_buffer_float %inputFirstElement %idx_0 %i0 %i1 %i2 %i3\n";
+ specs["accesschain"] = "OpInBoundsAccessChain %_ptr_Uniform_float %inputFirstElement %idx_0 %i0 %i1 %i2 %i3\n";
specs["inputdecoration"] = "BufferBlock";
specs["inputstorageclass"] = "Uniform";
break;
default:
DE_ASSERT(chainOpIdx == CHAIN_OP_PTR_ACCESS_CHAIN);
- specs["accesschain"] = "OpPtrAccessChain %_ptr_buffer_float %inputFirstElement %idx_1 %idx_0 %i0 %i1 %i2 %i3\n";
+ specs["accesschain"] = "OpPtrAccessChain %_ptr_StorageBuffer_float %inputFirstElement %idx_1 %idx_0 %i0 %i1 %i2 %i3\n";
specs["inputdecoration"] = "Block";
specs["inputstorageclass"] = "StorageBuffer";
- specs["variablepointercaps"] = "OpCapability VariablePointersStorageBuffer";
- specs["extensions"] = "OpExtension \"SPV_KHR_variable_pointers\"\n "
+ specs["variablepointercaps"] = "OpCapability VariablePointersStorageBuffer";
+ specs["ptr_buffer_float"] = "%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float";
+ specs["extensions"] = "OpExtension \"SPV_KHR_variable_pointers\"\n "
"OpExtension \"SPV_KHR_storage_buffer_storage_class\"";
element = 1;
vulkanFeatures.extVariablePointers = EXTVARIABLEPOINTERSFEATURES_VARIABLE_POINTERS_STORAGEBUFFER;
}
if (idxSize == 16)
+ {
specs["intcaps"] = "OpCapability Int16";
+ specs["convert"] = "OpSConvert";
+ specs["intdecl"] = " %u16 = OpTypeInt 16 0\n"
+ " %i16 = OpTypeInt 16 1\n";
+ }
else if (idxSize == 64)
+ {
specs["intcaps"] = "OpCapability Int64";
+ specs["convert"] = "OpSConvert";
+ specs["intdecl"] = " %u64 = OpTypeInt 64 0\n"
+ " %i64 = OpTypeInt 64 1\n";
+ } else {
+ specs["convert"] = "OpCopyObject";
+ }
+
+ specs["idx_uint"] = "%u" + de::toString(idxSize);
+ specs["idx_int"] = (sign ? "%i" : "%u") + de::toString(idxSize);
- specs["idxsize"] = de::toString(idxSize);
- specs["idxsign"] = de::toString(sign);
spec.assembly = shaderSource.specialize(specs);
spec.numWorkGroups = IVec3(numItems, 1, 1);
spec.requestedVulkanFeatures = vulkanFeatures;
GraphicsResources resources;
const StringTemplate preMain(
+ "${intdecl:opt}"
" %c_i32_128 = OpConstant %i32 128\n"
- " %uint = OpTypeInt ${idxsize} 0\n"
- " %_ptr_Function_uint32 = OpTypePointer Function %u32\n"
- " %v3uint32 = OpTypeVector %u32 3\n"
- " %_ptr_Input_v3uint32 = OpTypePointer Input %v3uint32\n"
- " %uint_0 = OpConstant %uint 0\n"
- " %_ptr_Input_uint32 = OpTypePointer Input %u32\n"
+ " %uint_0 = OpConstant ${idx_uint} 0\n"
" %uint_128 = OpConstant %u32 128\n"
" %uint_32 = OpConstant %u32 32\n"
- " %uint_1 = OpConstant %uint 1\n"
- " %uint_2 = OpConstant %uint 2\n"
- " %uint_3 = OpConstant %uint 3\n"
+ " %uint_1 = OpConstant ${idx_uint} 1\n"
+ " %uint_2 = OpConstant ${idx_uint} 2\n"
+ " %uint_3 = OpConstant ${idx_uint} 3\n"
" %_arr_float_uint_128 = OpTypeArray %f32 %uint_128\n"
" %Output = OpTypeStruct %_arr_float_uint_128\n"
" %_ptr_Uniform_Output = OpTypePointer Uniform %Output\n"
" %dataOutput = OpVariable %_ptr_Uniform_Output Uniform\n"
- " %int = OpTypeInt ${idxsize} ${idxsign}\n"
- " %int_0 = OpConstant %int 0\n"
- " %v4float = OpTypeVector %f32 4\n"
- " %mat4v4float = OpTypeMatrix %v4float 4\n"
+ " %int_0 = OpConstant ${idx_int} 0\n"
+ " %mat4v4float = OpTypeMatrix %v4f32 4\n"
" %_arr_mat4v4float_uint_32 = OpTypeArray %mat4v4float %uint_32\n"
" %_arr__arr_mat4v4float_uint_32_uint_32 = OpTypeArray %_arr_mat4v4float_uint_32 %uint_32\n"
" %InputStruct = OpTypeStruct %_arr__arr_mat4v4float_uint_32_uint_32\n"
" %_ptr_buffer_Input = OpTypePointer ${inputstorageclass} %Input\n"
" %dataInput = OpVariable %_ptr_buffer_Input ${inputstorageclass}\n"
" %_ptr_buffer_InputStruct = OpTypePointer ${inputstorageclass} %InputStruct\n"
- " %v4uint32 = OpTypeVector %u32 4\n"
- " %_arr_v4uint_uint_128 = OpTypeArray %v4uint32 %uint_128\n"
+ " %_arr_v4uint_uint_128 = OpTypeArray %v4u32 %uint_128\n"
" %DataSelector = OpTypeStruct %_arr_v4uint_uint_128\n"
"%_ptr_Uniform_DataSelector = OpTypePointer Uniform %DataSelector\n"
" %selector = OpVariable %_ptr_Uniform_DataSelector Uniform\n"
" %_ptr_Uniform_uint32 = OpTypePointer Uniform %u32\n"
" %_ptr_Uniform_float = OpTypePointer Uniform %f32\n"
- " %_ptr_buffer_float = OpTypePointer ${inputstorageclass} %f32\n");
+ " ${ptr_buffer_float:opt}\n");
const StringTemplate decoration(
" %48 = OpLoad %u32 %47\n"
" %51 = OpAccessChain %_ptr_Uniform_uint32 %selector %int_0 %int_i %uint_3\n"
" %52 = OpLoad %u32 %51\n"
- " %i0 = OpUConvert %uint %40\n"
- " %i1 = OpUConvert %uint %44\n"
- " %i2 = OpUConvert %uint %48\n"
- " %i3 = OpUConvert %uint %52\n"
+ " %i0 = ${convert} ${idx_uint} %40\n"
+ " %i1 = ${convert} ${idx_uint} %44\n"
+ " %i2 = ${convert} ${idx_uint} %48\n"
+ " %i3 = ${convert} ${idx_uint} %52\n"
"%inputFirstElement = OpAccessChain %_ptr_buffer_InputStruct %dataInput %uint_0 %uint_0\n"
" %54 = ${accesschain}\n"
" %55 = OpLoad %f32 %54\n"
{
fragments["capability"] = "OpCapability Int16\n";
features.push_back("shaderInt16");
+ specs["convert"] = "OpUConvert";
+ specs["intdecl"] = " %u16 = OpTypeInt 16 0\n"
+ " %i16 = OpTypeInt 16 1\n";
}
else if (idxSize == 64)
{
fragments["capability"] = "OpCapability Int64\n";
features.push_back("shaderInt64");
+ specs["convert"] = "OpUConvert";
+ specs["intdecl"] = " %u64 = OpTypeInt 64 0\n"
+ " %i64 = OpTypeInt 64 1\n";
+ } else {
+ specs["convert"] = "OpCopyObject";
}
- specs["idxsize"] = de::toString(idxSize);
- specs["idxsign"] = de::toString(sign);
+ specs["idx_uint"] = "%u" + de::toString(idxSize);
+ specs["idx_int"] = (sign ? "%i" : "%u") + de::toString(idxSize);
switch (chainOpIdx)
{
case CHAIN_OP_ACCESS_CHAIN:
- specs["accesschain"] = "OpAccessChain %_ptr_buffer_float %inputFirstElement %int_0 %i0 %i1 %i2 %i3\n";
+ specs["accesschain"] = "OpAccessChain %_ptr_Uniform_float %inputFirstElement %int_0 %i0 %i1 %i2 %i3\n";
specs["inputdecoration"] = "BufferBlock";
specs["inputstorageclass"] = "Uniform";
break;
case CHAIN_OP_IN_BOUNDS_ACCESS_CHAIN:
- specs["accesschain"] = "OpInBoundsAccessChain %_ptr_buffer_float %inputFirstElement %int_0 %i0 %i1 %i2 %i3\n";
+ specs["accesschain"] = "OpInBoundsAccessChain %_ptr_Uniform_float %inputFirstElement %int_0 %i0 %i1 %i2 %i3\n";
specs["inputdecoration"] = "BufferBlock";
specs["inputstorageclass"] = "Uniform";
break;
default:
DE_ASSERT(chainOpIdx == CHAIN_OP_PTR_ACCESS_CHAIN);
- specs["accesschain"] = "OpPtrAccessChain %_ptr_buffer_float %inputFirstElement %uint_1 %int_0 %i0 %i1 %i2 %i3\n";
+ specs["accesschain"] = "OpPtrAccessChain %_ptr_StorageBuffer_float %inputFirstElement %uint_1 %int_0 %i0 %i1 %i2 %i3\n";
specs["inputdecoration"] = "Block";
specs["inputstorageclass"] = "StorageBuffer";
+ specs["ptr_buffer_float"] = "%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %f32";
fragments["capability"] += "OpCapability VariablePointersStorageBuffer";
fragments["extension"] = "OpExtension \"SPV_KHR_variable_pointers\"\nOpExtension \"SPV_KHR_storage_buffer_storage_class\"";
extensions.push_back ("VK_KHR_variable_pointers");
const NameCodePair tests[] =
{
{"bool", "", "%bool"},
- {"vec2uint32", "%type = OpTypeVector %u32 2", "%type"},
+ {"vec2uint32", "", "%v2u32"},
{"image", "%type = OpTypeImage %f32 2D 0 0 0 1 Unknown", "%type"},
{"sampler", "%type = OpTypeSampler", "%type"},
{"sampledimage", "%img = OpTypeImage %f32 2D 0 0 0 1 Unknown\n" "%type = OpTypeSampledImage %img", "%type"},
return "OpTypeInt " + getBitWidthStr(type) + sign;
}
+const string getAsmTypeName (IntegerType type)
+{
+ const string prefix = isSigned(type) ? "%i" : "%u";
+ return prefix + getBitWidthStr(type);
+}
+
template<typename T>
BufferSp getSpecializedBuffer (deInt64 number)
{
, m_inputBuffer (getBuffer(from, number))
, m_outputBuffer (getBuffer(to, number))
{
- m_asmTypes["inputType"] = getAsmTypeDeclaration(from);
- m_asmTypes["outputType"] = getAsmTypeDeclaration(to);
+ m_asmTypes["inputType"] = getAsmTypeName(from);
+ m_asmTypes["outputType"] = getAsmTypeName(to);
if (m_features == COMPUTE_TEST_USES_INT16)
{
m_asmTypes["int_capabilities"] = "OpCapability Int16\n";
+ m_asmTypes["int_additional_decl"] = "%i16 = OpTypeInt 16 1\n%u16 = OpTypeInt 16 0\n";
}
else if (m_features == COMPUTE_TEST_USES_INT64)
{
m_asmTypes["int_capabilities"] = "OpCapability Int64\n";
+ m_asmTypes["int_additional_decl"] = "%i64 = OpTypeInt 64 1\n%u64 = OpTypeInt 64 0\n";
}
else if (m_features == COMPUTE_TEST_USES_INT16_INT64)
{
m_asmTypes["int_capabilities"] = string("OpCapability Int16\n") +
"OpCapability Int64\n";
+ m_asmTypes["int_additional_decl"] = "%i16 = OpTypeInt 16 1\n%u16 = OpTypeInt 16 0\n"
+ "%i64 = OpTypeInt 64 1\n%u64 = OpTypeInt 64 0\n";
}
else
{
"%voidf = OpTypeFunction %void\n"
"%u32 = OpTypeInt 32 0\n"
"%i32 = OpTypeInt 32 1\n"
+ "${int_additional_decl}"
"%uvec3 = OpTypeVector %u32 3\n"
"%uvec3ptr = OpTypePointer Input %uvec3\n"
- // Custom types
- "%in_type = ${inputType}\n"
- "%out_type = ${outputType}\n"
// Derived types
- "%in_ptr = OpTypePointer Uniform %in_type\n"
- "%out_ptr = OpTypePointer Uniform %out_type\n"
- "%in_arr = OpTypeRuntimeArray %in_type\n"
- "%out_arr = OpTypeRuntimeArray %out_type\n"
+ "%in_ptr = OpTypePointer Uniform ${inputType}\n"
+ "%out_ptr = OpTypePointer Uniform ${outputType}\n"
+ "%in_arr = OpTypeRuntimeArray ${inputType}\n"
+ "%out_arr = OpTypeRuntimeArray ${outputType}\n"
"%in_buf = OpTypeStruct %in_arr\n"
"%out_buf = OpTypeStruct %out_arr\n"
"%in_bufptr = OpTypePointer Uniform %in_buf\n"
"%out_bufptr = OpTypePointer Uniform %out_buf\n"
"%indata = OpVariable %in_bufptr Uniform\n"
"%outdata = OpVariable %out_bufptr Uniform\n"
- "%inputptr = OpTypePointer Input %in_type\n"
+ "%inputptr = OpTypePointer Input ${inputType}\n"
"%id = OpVariable %uvec3ptr Input\n"
// Constants
"%zero = OpConstant %i32 0\n"
"%x = OpCompositeExtract %u32 %idval 0\n"
"%inloc = OpAccessChain %in_ptr %indata %zero %x\n"
"%outloc = OpAccessChain %out_ptr %outdata %zero %x\n"
- "%inval = OpLoad %in_type %inloc\n"
- "%conv = ${instruction} %out_type %inval\n"
+ "%inval = OpLoad ${inputType} %inloc\n"
+ "%conv = ${instruction} ${outputType} %inval\n"
" OpStore %outloc %conv\n"
" OpReturn\n"
" OpFunctionEnd\n"
// Vec2 to Vec4
for (int width = 2; width <= 4; ++width)
{
- string randomConst = numberToString(getInt(rnd));
- string widthStr = numberToString(width);
- int index = rnd.getInt(0, width-1);
-
- params["type"] = "vec";
- params["name"] = params["type"] + "_" + widthStr;
- params["compositeType"] = "%composite = OpTypeVector %custom " + widthStr +"\n";
- params["filler"] = string("%filler = OpConstant %custom ") + getRandomConstantString(type, rnd) + "\n";
- params["compositeConstruct"] = "%instance = OpCompositeConstruct %composite" + repeatString(" %filler", width) + "\n";
- params["indexes"] = numberToString(index);
+ const string randomConst = numberToString(getInt(rnd));
+ const string widthStr = numberToString(width);
+ const string composite_type = "${customType}vec" + widthStr;
+ const int index = rnd.getInt(0, width-1);
+
+ params["type"] = "vec";
+ params["name"] = params["type"] + "_" + widthStr;
+ params["compositeDecl"] = composite_type + " = OpTypeVector ${customType} " + widthStr +"\n";
+ params["compositeType"] = composite_type;
+ params["filler"] = string("%filler = OpConstant ${customType} ") + getRandomConstantString(type, rnd) + "\n";
+ params["compositeConstruct"] = "%instance = OpCompositeConstruct " + composite_type + repeatString(" %filler", width) + "\n";
+ params["indexes"] = numberToString(index);
testCases.push_back(params);
}
}
string widthStr = numberToString(width);
int index = rnd.getInt(0, width-1);
- params["type"] = "array";
- params["name"] = params["type"] + "_" + widthStr;
- params["compositeType"] = string("%arraywidth = OpConstant %u32 " + widthStr + "\n")
- + "%composite = OpTypeArray %custom %arraywidth\n";
-
- params["filler"] = string("%filler = OpConstant %custom ") + getRandomConstantString(type, rnd) + "\n";
+ params["type"] = "array";
+ params["name"] = params["type"] + "_" + widthStr;
+ params["compositeDecl"] = string("%arraywidth = OpConstant %u32 " + widthStr + "\n")
+ + "%composite = OpTypeArray ${customType} %arraywidth\n";
+ params["compositeType"] = "%composite";
+ params["filler"] = string("%filler = OpConstant ${customType} ") + getRandomConstantString(type, rnd) + "\n";
params["compositeConstruct"] = "%instance = OpCompositeConstruct %composite" + repeatString(" %filler", width) + "\n";
- params["indexes"] = numberToString(index);
+ params["indexes"] = numberToString(index);
testCases.push_back(params);
}
}
string randomConst = numberToString(getInt(rnd));
int index = rnd.getInt(0, width-1);
- params["type"] = "struct";
- params["name"] = params["type"] + "_" + numberToString(width);
- params["compositeType"] = "%composite = OpTypeStruct" + repeatString(" %custom", width) + "\n";
- params["filler"] = string("%filler = OpConstant %custom ") + getRandomConstantString(type, rnd) + "\n";
+ params["type"] = "struct";
+ params["name"] = params["type"] + "_" + numberToString(width);
+ params["compositeDecl"] = "%composite = OpTypeStruct" + repeatString(" ${customType}", width) + "\n";
+ params["compositeType"] = "%composite";
+ params["filler"] = string("%filler = OpConstant ${customType} ") + getRandomConstantString(type, rnd) + "\n";
params["compositeConstruct"] = "%instance = OpCompositeConstruct %composite" + repeatString(" %filler", width) + "\n";
- params["indexes"] = numberToString(index);
+ params["indexes"] = numberToString(index);
testCases.push_back(params);
}
}
int index_1 = rnd.getInt(0, width-1);
string columnStr = numberToString(column);
- params["type"] = "matrix";
- params["name"] = params["type"] + "_" + widthStr + "x" + columnStr;
- params["compositeType"] = string("%vectype = OpTypeVector %custom " + widthStr + "\n")
+ params["type"] = "matrix";
+ params["name"] = params["type"] + "_" + widthStr + "x" + columnStr;
+ params["compositeDecl"] = string("%vectype = OpTypeVector ${customType} " + widthStr + "\n")
+ "%composite = OpTypeMatrix %vectype " + columnStr + "\n";
+ params["compositeType"] = "%composite";
- params["filler"] = string("%filler = OpConstant %custom ") + getRandomConstantString(type, rnd) + "\n"
+ params["filler"] = string("%filler = OpConstant ${customType} ") + getRandomConstantString(type, rnd) + "\n"
+ "%fillerVec = OpConstantComposite %vectype" + repeatString(" %filler", width) + "\n";
params["compositeConstruct"] = "%instance = OpCompositeConstruct %composite" + repeatString(" %fillerVec", column) + "\n";
- params["indexes"] = numberToString(index_0) + " " + numberToString(index_1);
+ params["indexes"] = numberToString(index_0) + " " + numberToString(index_1);
testCases.push_back(params);
}
}
}
}
+const string getAssemblyTypeName (const NumberType type)
+{
+ switch (type)
+ {
+ case NUMBERTYPE_INT32: return "%i32";
+ case NUMBERTYPE_UINT32: return "%u32";
+ case NUMBERTYPE_FLOAT32: return "%f32";
+ default: DE_ASSERT(false); return "";
+ }
+}
+
const string specializeCompositeInsertShaderTemplate (const NumberType type, const map<string, string>& params)
{
map<string, string> parameters(params);
- parameters["typeDeclaration"] = getAssemblyTypeDeclaration(type);
-
+ const string customType = getAssemblyTypeName(type);
+ map<string, string> substCustomType;
+ substCustomType["customType"] = customType;
+ parameters["compositeDecl"] = StringTemplate(parameters.at("compositeDecl")).specialize(substCustomType);
+ parameters["compositeType"] = StringTemplate(parameters.at("compositeType")).specialize(substCustomType);
+ parameters["compositeConstruct"] = StringTemplate(parameters.at("compositeConstruct")).specialize(substCustomType);
+ parameters["filler"] = StringTemplate(parameters.at("filler")).specialize(substCustomType);
+ parameters["customType"] = customType;
parameters["compositeDecorator"] = (parameters["type"] == "array") ? "OpDecorate %composite ArrayStride 4\n" : "";
- return StringTemplate (
+ if (parameters.at("compositeType") != "%u32vec3")
+ {
+ parameters["u32vec3Decl"] = "%u32vec3 = OpTypeVector %u32 3\n";
+ }
+
+ return StringTemplate(
"OpCapability Shader\n"
"OpCapability Matrix\n"
"OpMemoryModel Logical GLSL450\n"
"%voidf = OpTypeFunction %void\n"
"%u32 = OpTypeInt 32 0\n"
"%i32 = OpTypeInt 32 1\n"
- "%uvec3 = OpTypeVector %u32 3\n"
- "%uvec3ptr = OpTypePointer Input %uvec3\n"
+ "%f32 = OpTypeFloat 32\n"
- // Custom type
- "%custom = ${typeDeclaration}\n"
- "${compositeType}"
+ // Composite declaration
+ "${compositeDecl}"
// Constants
"${filler}"
+ "${u32vec3Decl:opt}"
+ "%uvec3ptr = OpTypePointer Input %u32vec3\n"
+
// Inherited from custom
- "%customptr = OpTypePointer Uniform %custom\n"
- "%customarr = OpTypeRuntimeArray %custom\n"
+ "%customptr = OpTypePointer Uniform ${customType}\n"
+ "%customarr = OpTypeRuntimeArray ${customType}\n"
"%buf = OpTypeStruct %customarr\n"
"%bufptr = OpTypePointer Uniform %buf\n"
"%main = OpFunction %void None %voidf\n"
"%label = OpLabel\n"
- "%idval = OpLoad %uvec3 %id\n"
+ "%idval = OpLoad %u32vec3 %id\n"
"%x = OpCompositeExtract %u32 %idval 0\n"
"%inloc = OpAccessChain %customptr %indata %zero %x\n"
"%outloc = OpAccessChain %customptr %outdata %zero %x\n"
// Read the input value
- "%inval = OpLoad %custom %inloc\n"
+ "%inval = OpLoad ${customType} %inloc\n"
// Create the composite and fill it
"${compositeConstruct}"
// Insert the input value to a place
- "%instance2 = OpCompositeInsert %composite %inval %instance ${indexes}\n"
+ "%instance2 = OpCompositeInsert ${compositeType} %inval %instance ${indexes}\n"
// Read back the value from the position
- "%out_val = OpCompositeExtract %custom %instance2 ${indexes}\n"
+ "%out_val = OpCompositeExtract ${customType} %instance2 ${indexes}\n"
// Store it in the output position
" OpStore %outloc %out_val\n"
" OpReturn\n"
vector<string> indexes = de::splitString(fullIndex, ' ');
map<string, string> parameters (params);
- parameters["typeDeclaration"] = getAssemblyTypeDeclaration(type);
- parameters["structType"] = repeatString(" %composite", structInfo.components);
+ parameters["structType"] = repeatString(" ${compositeType}", structInfo.components);
parameters["structConstruct"] = repeatString(" %instance", structInfo.components);
- parameters["insertIndexes"] = fullIndex;
+ parameters["insertIndexes"] = fullIndex;
// In matrix cases the last two index is the CompositeExtract indexes
const deUint32 extractIndexes = (parameters["type"] == "matrix") ? 2 : 1;
parameters["compositeDecorator"] = (parameters["type"] == "array") ? "OpDecorate %composite ArrayStride 4\n" : "";
- return StringTemplate (
+ const string customType = getAssemblyTypeName(type);
+ map<string, string> substCustomType;
+ substCustomType["customType"] = customType;
+ parameters["compositeDecl"] = StringTemplate(parameters.at("compositeDecl")).specialize(substCustomType);
+ parameters["compositeType"] = StringTemplate(parameters.at("compositeType")).specialize(substCustomType);
+ parameters["compositeConstruct"] = StringTemplate(parameters.at("compositeConstruct")).specialize(substCustomType);
+ parameters["filler"] = StringTemplate(parameters.at("filler")).specialize(substCustomType);
+ parameters["customType"] = customType;
+
+ const string compositeType = parameters.at("compositeType");
+ map<string, string> substCompositeType;
+ substCompositeType["compositeType"] = compositeType;
+ parameters["structType"] = StringTemplate(parameters.at("structType")).specialize(substCompositeType);
+ if (compositeType != "%u32vec3")
+ {
+ parameters["u32vec3Decl"] = "%u32vec3 = OpTypeVector %u32 3\n";
+ }
+
+ return StringTemplate(
"OpCapability Shader\n"
"OpCapability Matrix\n"
"OpMemoryModel Logical GLSL450\n"
// General types
"%void = OpTypeVoid\n"
"%voidf = OpTypeFunction %void\n"
+ "%i32 = OpTypeInt 32 1\n"
"%u32 = OpTypeInt 32 0\n"
- "%uvec3 = OpTypeVector %u32 3\n"
- "%uvec3ptr = OpTypePointer Input %uvec3\n"
- // Custom type
- "%custom = ${typeDeclaration}\n"
+ "%f32 = OpTypeFloat 32\n"
// Custom types
- "${compositeType}"
+ "${compositeDecl}"
+ // %u32vec3 if not already declared in ${compositeDecl}
+ "${u32vec3Decl:opt}"
+ "%uvec3ptr = OpTypePointer Input %u32vec3\n"
// Inherited from composite
- "%composite_p = OpTypePointer Function %composite\n"
+ "%composite_p = OpTypePointer Function ${compositeType}\n"
"%struct_t = OpTypeStruct${structType}\n"
"%struct_p = OpTypePointer Function %struct_t\n"
// Constants
"${filler}"
"${accessChainConstDeclaration}"
// Inherited from custom
- "%customptr = OpTypePointer Uniform %custom\n"
- "%customarr = OpTypeRuntimeArray %custom\n"
+ "%customptr = OpTypePointer Uniform ${customType}\n"
+ "%customarr = OpTypeRuntimeArray ${customType}\n"
"%buf = OpTypeStruct %customarr\n"
"%bufptr = OpTypePointer Uniform %buf\n"
"%indata = OpVariable %bufptr Uniform\n"
"%main = OpFunction %void None %voidf\n"
"%label = OpLabel\n"
"%struct_v = OpVariable %struct_p Function\n"
- "%idval = OpLoad %uvec3 %id\n"
+ "%idval = OpLoad %u32vec3 %id\n"
"%x = OpCompositeExtract %u32 %idval 0\n"
// Create the input/output type
"%inloc = OpInBoundsAccessChain %customptr %indata %zero %x\n"
"%outloc = OpInBoundsAccessChain %customptr %outdata %zero %x\n"
// Read the input value
- "%inval = OpLoad %custom %inloc\n"
+ "%inval = OpLoad ${customType} %inloc\n"
// Create the composite and fill it
"${compositeConstruct}"
// Create the struct and fill it with the composite
" OpStore %struct_v %comp_obj\n"
// Get deepest possible composite pointer
"%inner_ptr = OpInBoundsAccessChain %composite_p %struct_v${accessChainIndexes}\n"
- "%read_obj = OpLoad %composite %inner_ptr\n"
+ "%read_obj = OpLoad ${compositeType} %inner_ptr\n"
// Read back the stored value
- "%read_val = OpCompositeExtract %custom %read_obj${extractIndexes}\n"
+ "%read_val = OpCompositeExtract ${customType} %read_obj${extractIndexes}\n"
" OpStore %outloc %read_val\n"
" OpReturn\n"
- " OpFunctionEnd\n").specialize(parameters);
+ " OpFunctionEnd\n"
+ ).specialize(parameters);
}
tcu::TestCaseGroup* createOpInBoundsAccessChainGroup (tcu::TestContext& testCtx)
{
map<string, string> parameters(params);
- parameters["typeDeclaration"] = getAssemblyTypeDeclaration(type);
+ parameters["customType"] = getAssemblyTypeName(type);
// Declare the const value, and use it in the initializer
if (params.find("constValue") != params.end())
{
- parameters["constDeclaration"] = "%const = OpConstant %in_type " + params.at("constValue") + "\n";
- parameters["variableInitializer"] = "%const";
+ parameters["variableInitializer"] = " %const";
}
// Uninitialized case
else
{
- parameters["constDeclaration"] = "";
- parameters["variableInitializer"] = "";
+ parameters["commentDecl"] = ";";
}
return StringTemplate(
"%voidf = OpTypeFunction %void\n"
"%u32 = OpTypeInt 32 0\n"
"%i32 = OpTypeInt 32 1\n"
+ "%f32 = OpTypeFloat 32\n"
"%uvec3 = OpTypeVector %u32 3\n"
"%uvec3ptr = OpTypePointer Input %uvec3\n"
- // Custom types
- "%in_type = ${typeDeclaration}\n"
- // "%const = OpConstant %in_type ${constValue}\n"
- "${constDeclaration}\n"
+ "${commentDecl:opt}%const = OpConstant ${customType} ${constValue:opt}\n"
// Derived types
- "%in_ptr = OpTypePointer Uniform %in_type\n"
- "%in_arr = OpTypeRuntimeArray %in_type\n"
+ "%in_ptr = OpTypePointer Uniform ${customType}\n"
+ "%in_arr = OpTypeRuntimeArray ${customType}\n"
"%in_buf = OpTypeStruct %in_arr\n"
"%in_bufptr = OpTypePointer Uniform %in_buf\n"
"%indata = OpVariable %in_bufptr Uniform\n"
"%outdata = OpVariable %in_bufptr Uniform\n"
"%id = OpVariable %uvec3ptr Input\n"
- "%var_ptr = OpTypePointer Function %in_type\n"
+ "%var_ptr = OpTypePointer Function ${customType}\n"
// Constants
"%zero = OpConstant %i32 0\n"
// Main function
"%main = OpFunction %void None %voidf\n"
"%label = OpLabel\n"
- "%out_var = OpVariable %var_ptr Function ${variableInitializer}\n"
+ "%out_var = OpVariable %var_ptr Function${variableInitializer:opt}\n"
"%idval = OpLoad %uvec3 %id\n"
"%x = OpCompositeExtract %u32 %idval 0\n"
"%inloc = OpAccessChain %in_ptr %indata %zero %x\n"
"%outloc = OpAccessChain %in_ptr %outdata %zero %x\n"
- "%outval = OpLoad %in_type %out_var\n"
+ "%outval = OpLoad ${customType} %out_var\n"
" OpStore %outloc %outval\n"
" OpReturn\n"
" OpFunctionEnd\n"