mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-08 19:40:06 +00:00
SPV Capabilities: SampleRateShading, SparseResidency, MinLod, and ImageQuery.
This commit is contained in:
parent
b0364dcc3e
commit
5e80113939
@ -88,6 +88,7 @@ public:
|
||||
void dumpSpv(std::vector<unsigned int>& out);
|
||||
|
||||
protected:
|
||||
spv::Decoration TranslateInterpolationDecoration(const glslang::TQualifier& qualifier);
|
||||
spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable);
|
||||
spv::Id createSpvVariable(const glslang::TIntermSymbol*);
|
||||
spv::Id getSampledType(const glslang::TSampler&);
|
||||
@ -301,7 +302,7 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type, glslang::T
|
||||
// Translate glslang type to SPIR-V interpolation decorations.
|
||||
// Returns spv::Decoration(spv::BadValue) when no decoration
|
||||
// should be applied.
|
||||
spv::Decoration TranslateInterpolationDecoration(const glslang::TQualifier& qualifier)
|
||||
spv::Decoration TGlslangToSpvTraverser::TranslateInterpolationDecoration(const glslang::TQualifier& qualifier)
|
||||
{
|
||||
if (qualifier.smooth) {
|
||||
// Smooth decoration doesn't exist in SPIR-V 1.0
|
||||
@ -315,9 +316,10 @@ spv::Decoration TranslateInterpolationDecoration(const glslang::TQualifier& qual
|
||||
return spv::DecorationFlat;
|
||||
else if (qualifier.centroid)
|
||||
return spv::DecorationCentroid;
|
||||
else if (qualifier.sample)
|
||||
else if (qualifier.sample) {
|
||||
builder.addCapability(spv::CapabilitySampleRateShading);
|
||||
return spv::DecorationSample;
|
||||
else
|
||||
} else
|
||||
return (spv::Decoration)spv::BadValue;
|
||||
}
|
||||
|
||||
@ -358,6 +360,18 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
// TODO: builder.addCapability(spv::CapabilityMultiViewport);
|
||||
return spv::BuiltInViewportIndex;
|
||||
|
||||
case glslang::EbvSampleId:
|
||||
builder.addCapability(spv::CapabilitySampleRateShading);
|
||||
return spv::BuiltInSampleId;
|
||||
|
||||
case glslang::EbvSamplePosition:
|
||||
builder.addCapability(spv::CapabilitySampleRateShading);
|
||||
return spv::BuiltInSamplePosition;
|
||||
|
||||
case glslang::EbvSampleMask:
|
||||
builder.addCapability(spv::CapabilitySampleRateShading);
|
||||
return spv::BuiltInSampleMask;
|
||||
|
||||
case glslang::EbvPosition: return spv::BuiltInPosition;
|
||||
case glslang::EbvVertexId: return spv::BuiltInVertexId;
|
||||
case glslang::EbvInstanceId: return spv::BuiltInInstanceId;
|
||||
@ -377,9 +391,6 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
case glslang::EbvFragCoord: return spv::BuiltInFragCoord;
|
||||
case glslang::EbvPointCoord: return spv::BuiltInPointCoord;
|
||||
case glslang::EbvFace: return spv::BuiltInFrontFacing;
|
||||
case glslang::EbvSampleId: return spv::BuiltInSampleId;
|
||||
case glslang::EbvSamplePosition: return spv::BuiltInSamplePosition;
|
||||
case glslang::EbvSampleMask: return spv::BuiltInSampleMask;
|
||||
case glslang::EbvFragDepth: return spv::BuiltInFragDepth;
|
||||
case glslang::EbvHelperInvocation: return spv::BuiltInHelperInvocation;
|
||||
case glslang::EbvNumWorkGroups: return spv::BuiltInNumWorkgroups;
|
||||
|
@ -1340,6 +1340,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
|
||||
texArgs[numArgs++] = parameters.sample;
|
||||
}
|
||||
if (parameters.lodClamp) {
|
||||
// capability if this bit is used
|
||||
addCapability(CapabilityMinLod);
|
||||
|
||||
mask = (ImageOperandsMask)(mask | ImageOperandsMinLodMask);
|
||||
texArgs[numArgs++] = parameters.lodClamp;
|
||||
}
|
||||
@ -1459,6 +1462,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
|
||||
Id resultId = textureInst->getResultId();
|
||||
|
||||
if (sparse) {
|
||||
// set capability
|
||||
addCapability(CapabilitySparseResidency);
|
||||
|
||||
// Decode the return type that was a special structure
|
||||
createStore(createCompositeExtract(resultId, typeId1, 1), parameters.texelOut);
|
||||
resultId = createCompositeExtract(resultId, typeId0, 0);
|
||||
@ -1476,6 +1482,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
|
||||
// Comments in header
|
||||
Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameters)
|
||||
{
|
||||
// All these need a capability
|
||||
addCapability(CapabilityImageQuery);
|
||||
|
||||
// Figure out the result type
|
||||
Id resultType = 0;
|
||||
switch (opCode) {
|
||||
|
@ -14,6 +14,7 @@ Linked fragment stage:
|
||||
Capability SampledRect
|
||||
Capability Sampled1D
|
||||
Capability SampledCubeArray
|
||||
Capability ImageQuery
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 17 68 79 99 173 184 185 186
|
||||
|
@ -11,6 +11,7 @@ Linked fragment stage:
|
||||
Capability ClipDistance
|
||||
Capability SampledRect
|
||||
Capability SampledBuffer
|
||||
Capability ImageQuery
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 16 28 33 43
|
||||
|
@ -15,6 +15,7 @@ Linked fragment stage:
|
||||
Capability SampledCubeArray
|
||||
Capability SampledBuffer
|
||||
Capability ImageMSArray
|
||||
Capability ImageQuery
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 356
|
||||
|
@ -12,6 +12,7 @@ Linked fragment stage:
|
||||
Capability Shader
|
||||
Capability SampledRect
|
||||
Capability SampledCubeArray
|
||||
Capability ImageQuery
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 17 26 29 55 81 84 91 247 277
|
||||
|
@ -14,6 +14,7 @@ Linked fragment stage:
|
||||
Capability Sampled1D
|
||||
Capability SampledCubeArray
|
||||
Capability SampledBuffer
|
||||
Capability ImageQuery
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main"
|
||||
|
@ -11,6 +11,7 @@ Linked fragment stage:
|
||||
|
||||
Capability Shader
|
||||
Capability SampledRect
|
||||
Capability SparseResidency
|
||||
Capability SampledCubeArray
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
|
@ -11,6 +11,8 @@ Linked fragment stage:
|
||||
|
||||
Capability Shader
|
||||
Capability SampledRect
|
||||
Capability SparseResidency
|
||||
Capability MinLod
|
||||
Capability SampledCubeArray
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
|
Loading…
Reference in New Issue
Block a user