SPV: Emit extension for using StorageClassStorageBuffer.
This commit is contained in:
parent
43c72b0e01
commit
a5c5fb6118
@ -34,11 +34,12 @@ enum Capability;
|
|||||||
static const int GLSLextKHRVersion = 100;
|
static const int GLSLextKHRVersion = 100;
|
||||||
static const int GLSLextKHRRevision = 1;
|
static const int GLSLextKHRRevision = 1;
|
||||||
|
|
||||||
static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
|
static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
|
||||||
static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
|
static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
|
||||||
static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group";
|
static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group";
|
||||||
static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
|
static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
|
||||||
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
|
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
|
||||||
static const char* const E_SPV_KHR_16bit_storage = "SPV_KHR_16bit_storage";
|
static const char* const E_SPV_KHR_16bit_storage = "SPV_KHR_16bit_storage";
|
||||||
|
static const char* const E_SPV_KHR_storage_buffer_storage_class = "SPV_KHR_storage_buffer_storage_class";
|
||||||
|
|
||||||
#endif // #ifndef GLSLextKHR_H
|
#endif // #ifndef GLSLextKHR_H
|
||||||
|
@ -123,6 +123,7 @@ protected:
|
|||||||
spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable, bool memberDeclaration);
|
spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable, bool memberDeclaration);
|
||||||
spv::ImageFormat TranslateImageFormat(const glslang::TType& type);
|
spv::ImageFormat TranslateImageFormat(const glslang::TType& type);
|
||||||
spv::LoopControlMask TranslateLoopControl(glslang::TLoopControl) const;
|
spv::LoopControlMask TranslateLoopControl(glslang::TLoopControl) const;
|
||||||
|
spv::StorageClass TranslateStorageClass(const glslang::TType&);
|
||||||
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&);
|
||||||
@ -245,39 +246,6 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate glslang type to SPIR-V storage class.
|
|
||||||
spv::StorageClass TranslateStorageClass(const glslang::TType& type, bool useStorageBuffer)
|
|
||||||
{
|
|
||||||
if (type.getQualifier().isPipeInput())
|
|
||||||
return spv::StorageClassInput;
|
|
||||||
else if (type.getQualifier().isPipeOutput())
|
|
||||||
return spv::StorageClassOutput;
|
|
||||||
else if (type.getBasicType() == glslang::EbtAtomicUint)
|
|
||||||
return spv::StorageClassAtomicCounter;
|
|
||||||
else if (type.containsOpaque())
|
|
||||||
return spv::StorageClassUniformConstant;
|
|
||||||
else if (useStorageBuffer && type.getQualifier().storage == glslang::EvqBuffer)
|
|
||||||
return spv::StorageClassStorageBuffer;
|
|
||||||
else if (type.getQualifier().isUniformOrBuffer()) {
|
|
||||||
if (type.getQualifier().layoutPushConstant)
|
|
||||||
return spv::StorageClassPushConstant;
|
|
||||||
if (type.getBasicType() == glslang::EbtBlock)
|
|
||||||
return spv::StorageClassUniform;
|
|
||||||
else
|
|
||||||
return spv::StorageClassUniformConstant;
|
|
||||||
} else {
|
|
||||||
switch (type.getQualifier().storage) {
|
|
||||||
case glslang::EvqShared: return spv::StorageClassWorkgroup; break;
|
|
||||||
case glslang::EvqGlobal: return spv::StorageClassPrivate;
|
|
||||||
case glslang::EvqConstReadOnly: return spv::StorageClassFunction;
|
|
||||||
case glslang::EvqTemporary: return spv::StorageClassFunction;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
return spv::StorageClassFunction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Translate glslang sampler type to SPIR-V dimensionality.
|
// Translate glslang sampler type to SPIR-V dimensionality.
|
||||||
spv::Dim TranslateDimensionality(const glslang::TSampler& sampler)
|
spv::Dim TranslateDimensionality(const glslang::TSampler& sampler)
|
||||||
{
|
{
|
||||||
@ -780,6 +748,40 @@ spv::LoopControlMask TGlslangToSpvTraverser::TranslateLoopControl(glslang::TLoop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Translate glslang type to SPIR-V storage class.
|
||||||
|
spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::TType& type)
|
||||||
|
{
|
||||||
|
if (type.getQualifier().isPipeInput())
|
||||||
|
return spv::StorageClassInput;
|
||||||
|
else if (type.getQualifier().isPipeOutput())
|
||||||
|
return spv::StorageClassOutput;
|
||||||
|
else if (type.getBasicType() == glslang::EbtAtomicUint)
|
||||||
|
return spv::StorageClassAtomicCounter;
|
||||||
|
else if (type.containsOpaque())
|
||||||
|
return spv::StorageClassUniformConstant;
|
||||||
|
else if (glslangIntermediate->usingStorageBuffer() && type.getQualifier().storage == glslang::EvqBuffer) {
|
||||||
|
builder.addExtension(spv::E_SPV_KHR_storage_buffer_storage_class);
|
||||||
|
return spv::StorageClassStorageBuffer;
|
||||||
|
} else if (type.getQualifier().isUniformOrBuffer()) {
|
||||||
|
if (type.getQualifier().layoutPushConstant)
|
||||||
|
return spv::StorageClassPushConstant;
|
||||||
|
if (type.getBasicType() == glslang::EbtBlock)
|
||||||
|
return spv::StorageClassUniform;
|
||||||
|
else
|
||||||
|
return spv::StorageClassUniformConstant;
|
||||||
|
} else {
|
||||||
|
switch (type.getQualifier().storage) {
|
||||||
|
case glslang::EvqShared: return spv::StorageClassWorkgroup; break;
|
||||||
|
case glslang::EvqGlobal: return spv::StorageClassPrivate;
|
||||||
|
case glslang::EvqConstReadOnly: return spv::StorageClassFunction;
|
||||||
|
case glslang::EvqTemporary: return spv::StorageClassFunction;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
return spv::StorageClassFunction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
@ -2092,7 +2094,7 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now, handle actual variables
|
// Now, handle actual variables
|
||||||
spv::StorageClass storageClass = TranslateStorageClass(node->getType(), glslangIntermediate->usingStorageBuffer());
|
spv::StorageClass storageClass = TranslateStorageClass(node->getType());
|
||||||
spv::Id spvType = convertGlslangToSpvType(node->getType());
|
spv::Id spvType = convertGlslangToSpvType(node->getType());
|
||||||
|
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
@ -2855,7 +2857,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
|||||||
(paramType.getBasicType() == glslang::EbtBlock &&
|
(paramType.getBasicType() == glslang::EbtBlock &&
|
||||||
paramType.getQualifier().storage == glslang::EvqBuffer) || // SSBO
|
paramType.getQualifier().storage == glslang::EvqBuffer) || // SSBO
|
||||||
(p == 0 && implicitThis)) // implicit 'this'
|
(p == 0 && implicitThis)) // implicit 'this'
|
||||||
typeId = builder.makePointer(TranslateStorageClass(paramType, glslangIntermediate->usingStorageBuffer()), typeId);
|
typeId = builder.makePointer(TranslateStorageClass(paramType), typeId);
|
||||||
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
||||||
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
|
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
|
||||||
else
|
else
|
||||||
|
@ -6,6 +6,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
|
|||||||
// Id's are bound by 31
|
// Id's are bound by 31
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
|
Extension "SPV_KHR_storage_buffer_storage_class"
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Vertex 4 "main" 13
|
EntryPoint Vertex 4 "main" 13
|
||||||
|
Loading…
x
Reference in New Issue
Block a user