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
41ebc429
Commit
41ebc429
authored
Jun 09, 2016
by
John Kessenich
Committed by
GitHub
Jun 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #335 from jekstrand/sampler-params
SPV: Fix pointer address spaces for sampler function parameters
parents
077e052a
ed15ef1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
46 deletions
+51
-46
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+10
-6
spv.subpass.frag.out
Test/baseResults/spv.subpass.frag.out
+38
-39
Types.h
glslang/Include/Types.h
+3
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
41ebc429
...
...
@@ -227,13 +227,15 @@ spv::StorageClass TranslateStorageClass(const glslang::TType& type)
return
spv
::
StorageClassInput
;
else
if
(
type
.
getQualifier
().
isPipeOutput
())
return
spv
::
StorageClassOutput
;
else
if
(
type
.
getBasicType
()
==
glslang
::
EbtSampler
)
return
spv
::
StorageClassUniformConstant
;
else
if
(
type
.
getBasicType
()
==
glslang
::
EbtAtomicUint
)
return
spv
::
StorageClassAtomicCounter
;
else
if
(
type
.
getQualifier
().
isUniformOrBuffer
())
{
if
(
type
.
getQualifier
().
layoutPushConstant
)
return
spv
::
StorageClassPushConstant
;
if
(
type
.
getBasicType
()
==
glslang
::
EbtBlock
)
return
spv
::
StorageClassUniform
;
else
if
(
type
.
getBasicType
()
==
glslang
::
EbtAtomicUint
)
return
spv
::
StorageClassAtomicCounter
;
else
return
spv
::
StorageClassUniformConstant
;
// TODO: how are we distuingishing between default and non-default non-writable uniforms? Do default uniforms even exist?
...
...
@@ -2270,7 +2272,9 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
for
(
int
p
=
0
;
p
<
(
int
)
parameters
.
size
();
++
p
)
{
const
glslang
::
TType
&
paramType
=
parameters
[
p
]
->
getAsTyped
()
->
getType
();
spv
::
Id
typeId
=
convertGlslangToSpvType
(
paramType
);
if
(
paramType
.
getQualifier
().
storage
!=
glslang
::
EvqConstReadOnly
)
if
(
paramType
.
isOpaque
())
typeId
=
builder
.
makePointer
(
TranslateStorageClass
(
paramType
),
typeId
);
else
if
(
paramType
.
getQualifier
().
storage
!=
glslang
::
EvqConstReadOnly
)
typeId
=
builder
.
makePointer
(
spv
::
StorageClassFunction
,
typeId
);
else
constReadOnlyParameters
.
insert
(
parameters
[
p
]
->
getAsSymbolNode
()
->
getId
());
...
...
@@ -2686,8 +2690,8 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
builder
.
clearAccessChain
();
glslangArgs
[
a
]
->
traverse
(
this
);
argTypes
.
push_back
(
&
paramType
);
// keep outputs as and
sampler
s l-values, evaluate input-only as r-values
if
(
qualifiers
[
a
]
!=
glslang
::
EvqConstReadOnly
||
paramType
.
getBasicType
()
==
glslang
::
EbtSampler
)
{
// keep outputs as and
opaque object
s l-values, evaluate input-only as r-values
if
(
qualifiers
[
a
]
!=
glslang
::
EvqConstReadOnly
||
paramType
.
isOpaque
()
)
{
// save l-value
lValues
.
push_back
(
builder
.
getAccessChain
());
}
else
{
...
...
@@ -2706,7 +2710,7 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
for
(
int
a
=
0
;
a
<
(
int
)
glslangArgs
.
size
();
++
a
)
{
const
glslang
::
TType
&
paramType
=
glslangArgs
[
a
]
->
getAsTyped
()
->
getType
();
spv
::
Id
arg
;
if
(
paramType
.
getBasicType
()
==
glslang
::
EbtSampler
)
{
if
(
paramType
.
isOpaque
()
)
{
builder
.
setAccessChain
(
lValues
[
lValueCount
]);
arg
=
builder
.
accessChainGetLValue
();
++
lValueCount
;
...
...
Test/baseResults/spv.subpass.frag.out
View file @
41ebc429
...
...
@@ -7,13 +7,13 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 6
8
// Id's are bound by 6
7
Capability Shader
Capability InputAttachment
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 15 27 5
4
EntryPoint Fragment 4 "main" 15 27 5
3
ExecutionMode 4 OriginUpperLeft
Source GLSL 400
Name 4 "main"
...
...
@@ -24,27 +24,27 @@ Linked fragment stage:
Name 30 "sub"
Name 35 "subMS"
Name 42 "isub"
Name 4
6
"isubMS"
Name 5
4
"ucolor"
Name 5
7
"usub"
Name 6
2
"usubMS"
Name 4
5
"isubMS"
Name 5
3
"ucolor"
Name 5
6
"usub"
Name 6
1
"usubMS"
Decorate 30(sub) DescriptorSet 0
Decorate 30(sub) InputAttachmentIndex 1
Decorate 35(subMS) DescriptorSet 0
Decorate 35(subMS) InputAttachmentIndex 2
Decorate 42(isub) DescriptorSet 0
Decorate 42(isub) InputAttachmentIndex 3
Decorate 4
6
(isubMS) DescriptorSet 0
Decorate 4
6
(isubMS) InputAttachmentIndex 4
Decorate 5
7
(usub) DescriptorSet 0
Decorate 5
7
(usub) InputAttachmentIndex 5
Decorate 6
2
(usubMS) DescriptorSet 0
Decorate 6
2
(usubMS) InputAttachmentIndex 6
Decorate 4
5
(isubMS) DescriptorSet 0
Decorate 4
5
(isubMS) InputAttachmentIndex 4
Decorate 5
6
(usub) DescriptorSet 0
Decorate 5
6
(usub) InputAttachmentIndex 5
Decorate 6
1
(usubMS) DescriptorSet 0
Decorate 6
1
(usubMS) InputAttachmentIndex 6
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypeImage 6(int) SubpassData multi-sampled nonsampled format:Unknown
8: TypePointer
Function
7
8: TypePointer
UniformConstant
7
9: TypeFunction 2 8(ptr)
13: TypeVector 6(int) 4
14: TypePointer Output 13(ivec4)
...
...
@@ -66,18 +66,17 @@ Linked fragment stage:
40: TypeImage 6(int) SubpassData nonsampled format:Unknown
41: TypePointer UniformConstant 40
42(isub): 41(ptr) Variable UniformConstant
45: TypePointer UniformConstant 7
46(isubMS): 45(ptr) Variable UniformConstant
51: TypeInt 32 0
52: TypeVector 51(int) 4
53: TypePointer Output 52(ivec4)
54(ucolor): 53(ptr) Variable Output
55: TypeImage 51(int) SubpassData nonsampled format:Unknown
56: TypePointer UniformConstant 55
57(usub): 56(ptr) Variable UniformConstant
60: TypeImage 51(int) SubpassData multi-sampled nonsampled format:Unknown
61: TypePointer UniformConstant 60
62(usubMS): 61(ptr) Variable UniformConstant
45(isubMS): 8(ptr) Variable UniformConstant
50: TypeInt 32 0
51: TypeVector 50(int) 4
52: TypePointer Output 51(ivec4)
53(ucolor): 52(ptr) Variable Output
54: TypeImage 50(int) SubpassData nonsampled format:Unknown
55: TypePointer UniformConstant 54
56(usub): 55(ptr) Variable UniformConstant
59: TypeImage 50(int) SubpassData multi-sampled nonsampled format:Unknown
60: TypePointer UniformConstant 59
61(usubMS): 60(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
31: 28 Load 30(sub)
...
...
@@ -91,20 +90,20 @@ Linked fragment stage:
43: 40 Load 42(isub)
44: 13(ivec4) ImageRead 43 20
Store 15(icolor) 44
4
7: 7 Load 46
(isubMS)
4
8: 13(ivec4) ImageRead 47
20 Sample 17
4
9
: 13(ivec4) Load 15(icolor)
50: 13(ivec4) IAdd 49 48
Store 15(icolor)
50
5
8: 55 Load 57
(usub)
5
9: 52(ivec4) ImageRead 58
20
Store 5
4(ucolor) 59
6
3: 60 Load 62
(usubMS)
6
4: 52(ivec4) ImageRead 63
20 Sample 17
6
5: 52(ivec4) Load 54
(ucolor)
6
6: 52(ivec4) IAdd 65 64
Store 5
4(ucolor) 66
6
7: 2 FunctionCall 11(foo(iIPM1;) 46
(isubMS)
4
6: 7 Load 45
(isubMS)
4
7: 13(ivec4) ImageRead 46
20 Sample 17
4
8
: 13(ivec4) Load 15(icolor)
49: 13(ivec4) IAdd 48 47
Store 15(icolor)
49
5
7: 54 Load 56
(usub)
5
8: 51(ivec4) ImageRead 57
20
Store 5
3(ucolor) 58
6
2: 59 Load 61
(usubMS)
6
3: 51(ivec4) ImageRead 62
20 Sample 17
6
4: 51(ivec4) Load 53
(ucolor)
6
5: 51(ivec4) IAdd 64 63
Store 5
3(ucolor) 65
6
6: 2 FunctionCall 11(foo(iIPM1;) 45
(isubMS)
Return
FunctionEnd
11(foo(iIPM1;): 2 Function None 9
...
...
glslang/Include/Types.h
View file @
41ebc429
...
...
@@ -1255,6 +1255,8 @@ public:
virtual
bool
isStruct
()
const
{
return
structure
!=
nullptr
;
}
virtual
bool
isFloatingDomain
()
const
{
return
basicType
==
EbtFloat
||
basicType
==
EbtDouble
;
}
virtual
bool
isOpaque
()
const
{
return
basicType
==
EbtSampler
||
basicType
==
EbtAtomicUint
;
}
// "Image" is a superset of "Subpass"
virtual
bool
isImage
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isImage
();
}
virtual
bool
isSubpass
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isSubpass
();
}
...
...
@@ -1315,7 +1317,7 @@ public:
virtual
bool
containsOpaque
()
const
{
if
(
basicType
==
EbtSampler
||
basicType
==
EbtAtomicUint
)
if
(
isOpaque
()
)
return
true
;
if
(
!
structure
)
return
false
;
...
...
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