summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp')
-rw-r--r--src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp81
1 files changed, 55 insertions, 26 deletions
diff --git a/src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp b/src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp
index 80471ca..832ee3e 100644
--- a/src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp
+++ b/src/3rdparty/glslang/SPIRV/SpvPostProcess.cpp
@@ -51,12 +51,8 @@ namespace spv {
#include "GLSL.std.450.h"
#include "GLSL.ext.KHR.h"
#include "GLSL.ext.EXT.h"
-#ifdef AMD_EXTENSIONS
#include "GLSL.ext.AMD.h"
-#endif
-#ifdef NV_EXTENSIONS
#include "GLSL.ext.NV.h"
-#endif
}
namespace spv {
@@ -118,12 +114,48 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
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
switch (inst.getImmediateOperand(1)) {
case GLSLstd450Frexp:
case GLSLstd450FrexpStruct:
@@ -139,7 +171,6 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
default:
break;
}
-#endif
break;
default:
if (basicTypeOp == OpTypeFloat && width == 16)
@@ -185,12 +216,10 @@ void Builder::postProcess(Instruction& inst)
addCapability(CapabilityImageQuery);
break;
-#ifdef NV_EXTENSIONS
case OpGroupNonUniformPartitionNV:
addExtension(E_SPV_NV_shader_subgroup_partitioned);
addCapability(CapabilityGroupNonUniformPartitionedNV);
break;
-#endif
case OpLoad:
case OpStore:
@@ -327,6 +356,24 @@ void Builder::postProcess()
// 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)) {
+ addIncorporatedExtension(spv::E_SPV_KHR_8bit_storage, spv::Spv_1_5);
+ addCapability(spv::CapabilityStorageBuffer8BitAccess);
+ }
+ if (containsType(type->getIdOperand(1), OpTypeInt, 16) ||
+ containsType(type->getIdOperand(1), OpTypeFloat, 16)) {
+ addIncorporatedExtension(spv::E_SPV_KHR_16bit_storage, spv::Spv_1_3);
+ addCapability(spv::CapabilityStorageBuffer16BitAccess);
+ }
+ }
+ }
+
// process all reachable instructions...
for (auto bi = reachableBlocks.cbegin(); bi != reachableBlocks.cend(); ++bi) {
const Block* block = *bi;
@@ -366,24 +413,6 @@ void Builder::postProcess()
}
}
}
-
- // 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