case OpAccessChain:
case OpPtrAccessChain:
case OpCopyObject:
+ break;
case OpFConvert:
case OpSConvert:
case OpUConvert:
+ // Look for any 8/16-bit storage capabilities. If there are none, assume that
+ // the convert instruction requires the Float16/Int8/16 capability.
+ if (containsType(typeId, OpTypeFloat, 16) || containsType(typeId, OpTypeInt, 16)) {
+ bool foundStorage = false;
+ for (auto it = capabilities.begin(); it != capabilities.end(); ++it) {
+ spv::Capability cap = *it;
+ if (cap == spv::CapabilityStorageInputOutput16 ||
+ cap == spv::CapabilityStoragePushConstant16 ||
+ cap == spv::CapabilityStorageUniformBufferBlock16 ||
+ cap == spv::CapabilityStorageUniform16) {
+ foundStorage = true;
+ break;
+ }
+ }
+ if (!foundStorage) {
+ if (containsType(typeId, OpTypeFloat, 16))
+ addCapability(CapabilityFloat16);
+ if (containsType(typeId, OpTypeInt, 16))
+ addCapability(CapabilityInt16);
+ }
+ }
+ if (containsType(typeId, OpTypeInt, 8)) {
+ bool foundStorage = false;
+ for (auto it = capabilities.begin(); it != capabilities.end(); ++it) {
+ spv::Capability cap = *it;
+ if (cap == spv::CapabilityStoragePushConstant8 ||
+ cap == spv::CapabilityUniformAndStorageBuffer8BitAccess ||
+ cap == spv::CapabilityStorageBuffer8BitAccess) {
+ foundStorage = true;
+ break;
+ }
+ }
+ if (!foundStorage) {
+ addCapability(CapabilityInt8);
+ }
+ }
break;
case OpExtInst:
#if AMD_EXTENSIONS
// Add per-instruction capabilities, extensions, etc.,
+ // Look for any 8/16 bit type in physical storage buffer class, and set the
+ // appropriate capability. This happens in createSpvVariable for other storage
+ // classes, but there isn't always a variable for physical storage buffer.
+ for (int t = 0; t < (int)groupedTypes[OpTypePointer].size(); ++t) {
+ Instruction* type = groupedTypes[OpTypePointer][t];
+ if (type->getImmediateOperand(0) == (unsigned)StorageClassPhysicalStorageBufferEXT) {
+ if (containsType(type->getIdOperand(1), OpTypeInt, 8)) {
+ addExtension(spv::E_SPV_KHR_8bit_storage);
+ addCapability(spv::CapabilityStorageBuffer8BitAccess);
+ }
+ if (containsType(type->getIdOperand(1), OpTypeInt, 16) ||
+ containsType(type->getIdOperand(1), OpTypeFloat, 16)) {
+ addExtension(spv::E_SPV_KHR_16bit_storage);
+ addCapability(spv::CapabilityStorageBuffer16BitAccess);
+ }
+ }
+ }
+
// process all reachable instructions...
for (auto bi = reachableBlocks.cbegin(); bi != reachableBlocks.cend(); ++bi) {
const Block* block = *bi;
}
}
}
-
- // Look for any 8/16 bit type in physical storage buffer class, and set the
- // appropriate capability. This happens in createSpvVariable for other storage
- // classes, but there isn't always a variable for physical storage buffer.
- for (int t = 0; t < (int)groupedTypes[OpTypePointer].size(); ++t) {
- Instruction* type = groupedTypes[OpTypePointer][t];
- if (type->getImmediateOperand(0) == (unsigned)StorageClassPhysicalStorageBufferEXT) {
- if (containsType(type->getIdOperand(1), OpTypeInt, 8)) {
- addExtension(spv::E_SPV_KHR_8bit_storage);
- addCapability(spv::CapabilityStorageBuffer8BitAccess);
- }
- if (containsType(type->getIdOperand(1), OpTypeInt, 16) ||
- containsType(type->getIdOperand(1), OpTypeFloat, 16)) {
- addExtension(spv::E_SPV_KHR_16bit_storage);
- addCapability(spv::CapabilityStorageBuffer16BitAccess);
- }
- }
- }
}
}; // end spv namespace
--- /dev/null
+spv.float16convertonlyarith.comp
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 22
+
+ Capability Shader
+ Capability Float16
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint GLCompute 4 "main"
+ ExecutionMode 4 LocalSize 16 16 1
+ Source GLSL 450
+ SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16"
+ Name 4 "main"
+ Name 9 "v"
+ Decorate 21 BuiltIn WorkgroupSize
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8: TypePointer Function 7(fvec4)
+ 10: 6(float) Constant 0
+ 11: 7(fvec4) ConstantComposite 10 10 10 10
+ 13: TypeFloat 16
+ 14: TypeVector 13(float16_t) 4
+ 17: TypeInt 32 0
+ 18: TypeVector 17(int) 3
+ 19: 17(int) Constant 16
+ 20: 17(int) Constant 1
+ 21: 18(ivec3) ConstantComposite 19 19 20
+ 4(main): 2 Function None 3
+ 5: Label
+ 9(v): 8(ptr) Variable Function
+ Store 9(v) 11
+ 12: 7(fvec4) Load 9(v)
+ 15: 14(f16vec4) FConvert 12
+ 16: 7(fvec4) FConvert 15
+ Return
+ FunctionEnd
--- /dev/null
+spv.float16convertonlystorage.comp
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 22
+
+ Capability Shader
+ Capability Float16
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint GLCompute 4 "main"
+ ExecutionMode 4 LocalSize 16 16 1
+ Source GLSL 450
+ SourceExtension "GL_EXT_shader_16bit_storage"
+ Name 4 "main"
+ Name 9 "v"
+ Decorate 21 BuiltIn WorkgroupSize
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8: TypePointer Function 7(fvec4)
+ 10: 6(float) Constant 0
+ 11: 7(fvec4) ConstantComposite 10 10 10 10
+ 13: TypeFloat 16
+ 14: TypeVector 13(float16_t) 4
+ 17: TypeInt 32 0
+ 18: TypeVector 17(int) 3
+ 19: 17(int) Constant 16
+ 20: 17(int) Constant 1
+ 21: 18(ivec3) ConstantComposite 19 19 20
+ 4(main): 2 Function None 3
+ 5: Label
+ 9(v): 8(ptr) Variable Function
+ Store 9(v) 11
+ 12: 7(fvec4) Load 9(v)
+ 15: 14(f16vec4) FConvert 12
+ 16: 7(fvec4) FConvert 15
+ Return
+ FunctionEnd