Commit 417a4d82 by John Kessenich

nonuniform: emit the 10 indexing capabilities

parent 94f0b1b9
...@@ -144,6 +144,7 @@ protected: ...@@ -144,6 +144,7 @@ protected:
spv::SelectionControlMask TranslateSwitchControl(const glslang::TIntermSwitch&) const; spv::SelectionControlMask TranslateSwitchControl(const glslang::TIntermSwitch&) const;
spv::LoopControlMask TranslateLoopControl(const glslang::TIntermLoop&, unsigned int& dependencyLength) const; spv::LoopControlMask TranslateLoopControl(const glslang::TIntermLoop&, unsigned int& dependencyLength) const;
spv::StorageClass TranslateStorageClass(const glslang::TType&); spv::StorageClass TranslateStorageClass(const glslang::TType&);
void addIndirectionIndexCapabilities(const glslang::TType& baseType, const glslang::TType& indexType);
spv::Id createSpvVariable(const glslang::TIntermSymbol*); spv::Id createSpvVariable(const glslang::TIntermSymbol*);
spv::Id getSampledType(const glslang::TSampler&); spv::Id getSampledType(const glslang::TSampler&);
spv::Id getInvertedSwizzleType(const glslang::TIntermTyped&); spv::Id getInvertedSwizzleType(const glslang::TIntermTyped&);
...@@ -902,6 +903,42 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T ...@@ -902,6 +903,42 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
return spv::StorageClassFunction; return spv::StorageClassFunction;
} }
// Add capabilities pertaining to how an array is indexed.
void TGlslangToSpvTraverser::addIndirectionIndexCapabilities(const glslang::TType& baseType,
const glslang::TType& indexType)
{
if (indexType.getQualifier().isNonUniform()) {
// deal with an asserted non-uniform index
if (baseType.getBasicType() == glslang::EbtSampler) {
if (baseType.getQualifier().hasAttachment())
builder.addCapability(spv::CapabilityInputAttachmentArrayNonUniformIndexingEXT);
else if (baseType.isImage() && baseType.getSampler().dim == glslang::EsdBuffer)
builder.addCapability(spv::CapabilityStorageTexelBufferArrayNonUniformIndexingEXT);
else if (baseType.isTexture() && baseType.getSampler().dim == glslang::EsdBuffer)
builder.addCapability(spv::CapabilityUniformTexelBufferArrayNonUniformIndexingEXT);
else if (baseType.isImage())
builder.addCapability(spv::CapabilityStorageImageArrayNonUniformIndexingEXT);
else if (baseType.isTexture())
builder.addCapability(spv::CapabilitySampledImageArrayNonUniformIndexingEXT);
} else if (baseType.getBasicType() == glslang::EbtBlock) {
if (baseType.getQualifier().storage == glslang::EvqBuffer)
builder.addCapability(spv::CapabilityStorageBufferArrayNonUniformIndexingEXT);
else if (baseType.getQualifier().storage == glslang::EvqUniform)
builder.addCapability(spv::CapabilityUniformBufferArrayNonUniformIndexingEXT);
}
} else {
// assume a dynamically uniform index
if (baseType.getBasicType() == glslang::EbtSampler) {
if (baseType.getQualifier().hasAttachment())
builder.addCapability(spv::CapabilityInputAttachmentArrayDynamicIndexingEXT);
else if (baseType.isImage() && baseType.getSampler().dim == glslang::EsdBuffer)
builder.addCapability(spv::CapabilityStorageTexelBufferArrayDynamicIndexingEXT);
else if (baseType.isTexture() && baseType.getSampler().dim == glslang::EsdBuffer)
builder.addCapability(spv::CapabilityUniformTexelBufferArrayDynamicIndexingEXT);
}
}
}
// Return whether or not the given type is something that should be tied to a // Return whether or not the given type is something that should be tied to a
// descriptor set. // descriptor set.
bool IsDescriptorResource(const glslang::TType& type) bool IsDescriptorResource(const glslang::TType& type)
...@@ -1376,6 +1413,8 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T ...@@ -1376,6 +1413,8 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
node->getRight()->traverse(this); node->getRight()->traverse(this);
spv::Id index = accessChainLoad(node->getRight()->getType()); spv::Id index = accessChainLoad(node->getRight()->getType());
addIndirectionIndexCapabilities(node->getLeft()->getType(), node->getRight()->getType());
// restore the saved access chain // restore the saved access chain
builder.setAccessChain(partial); builder.setAccessChain(partial);
......
...@@ -9,6 +9,16 @@ spv.nonuniform.frag ...@@ -9,6 +9,16 @@ spv.nonuniform.frag
Capability ImageBuffer Capability ImageBuffer
Capability CapabilityShaderNonUniformEXT Capability CapabilityShaderNonUniformEXT
Capability CapabilityRuntimeDescriptorArrayEXT Capability CapabilityRuntimeDescriptorArrayEXT
Capability CapabilityInputAttachmentArrayDynamicIndexingEXT
Capability CapabilityUniformTexelBufferArrayDynamicIndexingEXT
Capability CapabilityStorageTexelBufferArrayDynamicIndexingEXT
Capability CapabilityUniformBufferArrayNonUniformIndexingEXT
Capability CapabilitySampledImageArrayNonUniformIndexingEXT
Capability CapabilityStorageBufferArrayNonUniformIndexingEXT
Capability CapabilityStorageImageArrayNonUniformIndexingEXT
Capability CapabilityInputAttachmentArrayNonUniformIndexingEXT
Capability CapabilityUniformTexelBufferArrayNonUniformIndexingEXT
Capability CapabilityStorageTexelBufferArrayNonUniformIndexingEXT
Extension "SPV_EXT_descriptor_indexing" Extension "SPV_EXT_descriptor_indexing"
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
......
...@@ -1392,6 +1392,7 @@ public: ...@@ -1392,6 +1392,7 @@ public:
// "Image" is a superset of "Subpass" // "Image" is a superset of "Subpass"
virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); } virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); }
virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); } virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
virtual bool isTexture() const { return basicType == EbtSampler && getSampler().isTexture(); }
// return true if this type contains any subtype which satisfies the given predicate. // return true if this type contains any subtype which satisfies the given predicate.
template <typename P> template <typename P>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment