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
4a57dced
Commit
4a57dced
authored
Feb 24, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Handle nested opaque types as function parameters.
parent
74912347
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
8 deletions
+101
-8
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+5
-6
spv.functionNestedOpaque.vert.out
Test/baseResults/spv.functionNestedOpaque.vert.out
+67
-0
spv.functionNestedOpaque.vert
Test/spv.functionNestedOpaque.vert
+26
-0
revision.h
glslang/Include/revision.h
+2
-2
Spv.FromFile.cpp
gtests/Spv.FromFile.cpp
+1
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
4a57dced
...
...
@@ -251,10 +251,10 @@ 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
.
containsOpaque
())
return
spv
::
StorageClassUniformConstant
;
else
if
(
type
.
getQualifier
().
isUniformOrBuffer
())
{
if
(
type
.
getQualifier
().
layoutPushConstant
)
return
spv
::
StorageClassPushConstant
;
...
...
@@ -262,7 +262,6 @@ spv::StorageClass TranslateStorageClass(const glslang::TType& type)
return
spv
::
StorageClassUniform
;
else
return
spv
::
StorageClassUniformConstant
;
// TODO: how are we distinguishing between default and non-default non-writable uniforms? Do default uniforms even exist?
}
else
{
switch
(
type
.
getQualifier
().
storage
)
{
case
glslang
:
:
EvqShared
:
return
spv
::
StorageClassWorkgroup
;
break
;
...
...
@@ -2731,7 +2730,7 @@ 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
.
i
sOpaque
())
if
(
paramType
.
contain
sOpaque
())
typeId
=
builder
.
makePointer
(
TranslateStorageClass
(
paramType
),
typeId
);
else
if
(
paramType
.
getQualifier
().
storage
!=
glslang
::
EvqConstReadOnly
)
typeId
=
builder
.
makePointer
(
spv
::
StorageClassFunction
,
typeId
);
...
...
@@ -3192,7 +3191,7 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
glslangArgs
[
a
]
->
traverse
(
this
);
argTypes
.
push_back
(
&
paramType
);
// keep outputs and opaque objects as l-values, evaluate input-only as r-values
if
(
qualifiers
[
a
]
!=
glslang
::
EvqConstReadOnly
||
paramType
.
i
sOpaque
())
{
if
(
qualifiers
[
a
]
!=
glslang
::
EvqConstReadOnly
||
paramType
.
contain
sOpaque
())
{
// save l-value
lValues
.
push_back
(
builder
.
getAccessChain
());
}
else
{
...
...
@@ -3211,7 +3210,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
.
i
sOpaque
())
{
if
(
paramType
.
contain
sOpaque
())
{
builder
.
setAccessChain
(
lValues
[
lValueCount
]);
arg
=
builder
.
accessChainGetLValue
();
++
lValueCount
;
...
...
Test/baseResults/spv.functionNestedOpaque.vert.out
0 → 100644
View file @
4a57dced
spv.functionNestedOpaque.vert
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 39
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main"
Source GLSL 450
Name 4 "main"
Name 12 "foo(s21;"
Name 11 "t"
Name 14 "S"
MemberName 14(S) 0 "s"
Name 18 "barc(struct-S-s211;"
Name 17 "p"
Name 21 "bar(struct-S-s211;"
Name 20 "p"
Name 36 "si"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeImage 6(float) 2D sampled format:Unknown
8: TypeSampledImage 7
9: TypePointer UniformConstant 8
10: TypeFunction 2 9(ptr)
14(S): TypeStruct 8
15: TypePointer UniformConstant 14(S)
16: TypeFunction 2 15(ptr)
24: TypeVector 6(float) 2
25: 6(float) Constant 1056964608
26: 24(fvec2) ConstantComposite 25 25
27: TypeVector 6(float) 4
28: 6(float) Constant 0
30: TypeInt 32 1
31: 30(int) Constant 0
36(si): 15(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
37: 2 FunctionCall 18(barc(struct-S-s211;) 36(si)
38: 2 FunctionCall 21(bar(struct-S-s211;) 36(si)
Return
FunctionEnd
12(foo(s21;): 2 Function None 10
11(t): 9(ptr) FunctionParameter
13: Label
23: 8 Load 11(t)
29: 27(fvec4) ImageSampleExplicitLod 23 26 Lod 28
Return
FunctionEnd
18(barc(struct-S-s211;): 2 Function None 16
17(p): 15(ptr) FunctionParameter
19: Label
32: 9(ptr) AccessChain 17(p) 31
33: 2 FunctionCall 12(foo(s21;) 32
Return
FunctionEnd
21(bar(struct-S-s211;): 2 Function None 16
20(p): 15(ptr) FunctionParameter
22: Label
34: 9(ptr) AccessChain 20(p) 31
35: 2 FunctionCall 12(foo(s21;) 34
Return
FunctionEnd
Test/spv.functionNestedOpaque.vert
0 → 100755
View file @
4a57dced
#version 450
uniform
struct
S
{
sampler2D
s
;
}
si
;
void
foo
(
sampler2D
t
)
{
texture
(
t
,
vec2
(
0
.
5
));
}
void
barc
(
const
S
p
)
{
foo
(
p
.
s
);
}
void
bar
(
S
p
)
{
foo
(
p
.
s
);
}
void
main
()
{
barc
(
si
);
bar
(
si
);
}
glslang/Include/revision.h
View file @
4a57dced
...
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.184
3
"
#define GLSLANG_DATE "
18
-Feb-2017"
#define GLSLANG_REVISION "Overload400-PrecQual.184
5
"
#define GLSLANG_DATE "
24
-Feb-2017"
gtests/Spv.FromFile.cpp
View file @
4a57dced
...
...
@@ -232,6 +232,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.forLoop.frag"
,
"spv.forwardFun.frag"
,
"spv.functionCall.frag"
,
"spv.functionNestedOpaque.vert"
,
"spv.functionSemantics.frag"
,
"spv.interpOps.frag"
,
"spv.int64.frag"
,
...
...
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