Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
417a4d82
Commit
417a4d82
authored
Mar 30, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nonuniform: emit the 10 indexing capabilities
parent
94f0b1b9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
1 deletion
+51
-1
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+39
-0
spv.nonuniform.frag.out
Test/baseResults/spv.nonuniform.frag.out
+10
-0
Types.h
glslang/Include/Types.h
+2
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
417a4d82
...
...
@@ -144,6 +144,7 @@ protected:
spv
::
SelectionControlMask
TranslateSwitchControl
(
const
glslang
::
TIntermSwitch
&
)
const
;
spv
::
LoopControlMask
TranslateLoopControl
(
const
glslang
::
TIntermLoop
&
,
unsigned
int
&
dependencyLength
)
const
;
spv
::
StorageClass
TranslateStorageClass
(
const
glslang
::
TType
&
);
void
addIndirectionIndexCapabilities
(
const
glslang
::
TType
&
baseType
,
const
glslang
::
TType
&
indexType
);
spv
::
Id
createSpvVariable
(
const
glslang
::
TIntermSymbol
*
);
spv
::
Id
getSampledType
(
const
glslang
::
TSampler
&
);
spv
::
Id
getInvertedSwizzleType
(
const
glslang
::
TIntermTyped
&
);
...
...
@@ -902,6 +903,42 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
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
// descriptor set.
bool
IsDescriptorResource
(
const
glslang
::
TType
&
type
)
...
...
@@ -1376,6 +1413,8 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
node
->
getRight
()
->
traverse
(
this
);
spv
::
Id
index
=
accessChainLoad
(
node
->
getRight
()
->
getType
());
addIndirectionIndexCapabilities
(
node
->
getLeft
()
->
getType
(),
node
->
getRight
()
->
getType
());
// restore the saved access chain
builder
.
setAccessChain
(
partial
);
...
...
Test/baseResults/spv.nonuniform.frag.out
View file @
417a4d82
...
...
@@ -9,6 +9,16 @@ spv.nonuniform.frag
Capability ImageBuffer
Capability CapabilityShaderNonUniformEXT
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"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
...
...
glslang/Include/Types.h
View file @
417a4d82
...
...
@@ -1390,8 +1390,9 @@ public:
virtual
bool
isBuiltIn
()
const
{
return
getQualifier
().
builtIn
!=
EbvNone
;
}
// "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
isTexture
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isTexture
();
}
// return true if this type contains any subtype which satisfies the given predicate.
template
<
typename
P
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment