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
e00e72de
Commit
e00e72de
authored
Dec 08, 2015
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Protect getStorageClass() with a test that the thing is pointer.
parent
33661450
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
5 deletions
+128
-5
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+5
-3
spvIR.h
SPIRV/spvIR.h
+6
-1
spv.bool.vert.out
Test/baseResults/spv.bool.vert.out
+98
-0
spv.bool.vert
Test/spv.bool.vert
+17
-0
test-spirv-list
Test/test-spirv-list
+1
-0
revision.h
glslang/Include/revision.h
+1
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
e00e72de
...
...
@@ -599,9 +599,11 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
builder
.
setAccessChainLValue
(
id
);
}
else
{
// finish off the entry-point SPV instruction by adding the Input/Output <id>
spv
::
StorageClass
sc
=
builder
.
getStorageClass
(
id
);
if
(
sc
==
spv
::
StorageClassInput
||
sc
==
spv
::
StorageClassOutput
)
entryPoint
->
addIdOperand
(
id
);
if
(
builder
.
isPointer
(
id
))
{
spv
::
StorageClass
sc
=
builder
.
getStorageClass
(
id
);
if
(
sc
==
spv
::
StorageClassInput
||
sc
==
spv
::
StorageClassOutput
)
entryPoint
->
addIdOperand
(
id
);
}
}
}
...
...
SPIRV/spvIR.h
View file @
e00e72de
...
...
@@ -293,7 +293,12 @@ public:
Instruction
*
getInstruction
(
Id
id
)
const
{
return
idToInstruction
[
id
];
}
spv
::
Id
getTypeId
(
Id
resultId
)
const
{
return
idToInstruction
[
resultId
]
->
getTypeId
();
}
StorageClass
getStorageClass
(
Id
typeId
)
const
{
return
(
StorageClass
)
idToInstruction
[
typeId
]
->
getImmediateOperand
(
0
);
}
StorageClass
getStorageClass
(
Id
typeId
)
const
{
assert
(
idToInstruction
[
typeId
]
->
getOpCode
()
==
spv
::
OpTypePointer
);
return
(
StorageClass
)
idToInstruction
[
typeId
]
->
getImmediateOperand
(
0
);
}
void
dump
(
std
::
vector
<
unsigned
int
>&
out
)
const
{
for
(
int
f
=
0
;
f
<
(
int
)
functions
.
size
();
++
f
)
...
...
Test/baseResults/spv.bool.vert.out
0 → 100644
View file @
e00e72de
spv.bool.vert
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked vertex stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 49
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 23 47 48
Source GLSL 450
Name 4 "main"
Name 10 "foo(b1;"
Name 9 "b"
Name 21 "gl_PerVertex"
MemberName 21(gl_PerVertex) 0 "gl_Position"
MemberName 21(gl_PerVertex) 1 "gl_PointSize"
MemberName 21(gl_PerVertex) 2 "gl_ClipDistance"
MemberName 21(gl_PerVertex) 3 "gl_CullDistance"
Name 23 ""
Name 28 "ubname"
MemberName 28(ubname) 0 "b"
Name 30 "ubinst"
Name 31 "param"
Name 47 "gl_VertexID"
Name 48 "gl_InstanceID"
MemberDecorate 21(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 21(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 21(gl_PerVertex) 2 BuiltIn ClipDistance
MemberDecorate 21(gl_PerVertex) 3 BuiltIn CullDistance
Decorate 21(gl_PerVertex) Block
Decorate 28(ubname) GLSLShared
Decorate 28(ubname) Block
Decorate 47(gl_VertexID) BuiltIn VertexId
Decorate 48(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid
3: TypeFunction 2
6: TypeBool
7: TypePointer Function 6(bool)
8: TypeFunction 6(bool) 7(ptr)
13: 6(bool) ConstantFalse
16: TypeFloat 32
17: TypeVector 16(float) 4
18: TypeInt 32 0
19: 18(int) Constant 1
20: TypeArray 16(float) 19
21(gl_PerVertex): TypeStruct 17(fvec4) 16(float) 20 20
22: TypePointer Output 21(gl_PerVertex)
23: 22(ptr) Variable Output
24: TypeInt 32 1
25: 24(int) Constant 0
26: TypePointer Function 17(fvec4)
28(ubname): TypeStruct 6(bool)
29: TypePointer Uniform 28(ubname)
30(ubinst): 29(ptr) Variable Uniform
32: TypePointer Uniform 6(bool)
38: 16(float) Constant 0
39: 17(fvec4) ConstantComposite 38 38 38 38
41: 16(float) Constant 1065353216
42: 17(fvec4) ConstantComposite 41 41 41 41
44: TypePointer Output 17(fvec4)
46: TypePointer Input 24(int)
47(gl_VertexID): 46(ptr) Variable Input
48(gl_InstanceID): 46(ptr) Variable Input
4(main): 2 Function None 3
5: Label
27: 26(ptr) Variable Function
31(param): 7(ptr) Variable Function
33: 32(ptr) AccessChain 30(ubinst) 25
34: 6(bool) Load 33
Store 31(param) 34
35: 6(bool) FunctionCall 10(foo(b1;) 31(param)
SelectionMerge 37 None
BranchConditional 35 36 40
36: Label
Store 27 39
Branch 37
40: Label
Store 27 42
Branch 37
37: Label
43: 17(fvec4) Load 27
45: 44(ptr) AccessChain 23 25
Store 45 43
Return
FunctionEnd
10(foo(b1;): 6(bool) Function None 8
9(b): 7(ptr) FunctionParameter
11: Label
12: 6(bool) Load 9(b)
14: 6(bool) INotEqual 12 13
ReturnValue 14
FunctionEnd
Test/spv.bool.vert
0 → 100644
View file @
e00e72de
#version 450
const
bool
condition
=
false
;
uniform
ubname
{
bool
b
;
}
ubinst
;
bool
foo
(
bool
b
)
{
return
b
!=
condition
;
}
void
main
()
{
gl_Position
=
foo
(
ubinst
.
b
)
?
vec4
(
0
.
0
)
:
vec4
(
1
.
0
);
}
Test/test-spirv-list
View file @
e00e72de
...
...
@@ -30,6 +30,7 @@ spv.accessChain.frag
spv.aggOps.frag
spv.always-discard.frag
spv.always-discard2.frag
spv.bool.vert
spv.conditionalDiscard.frag
spv.conversion.frag
spv.dataOut.frag
...
...
glslang/Include/revision.h
View file @
e00e72de
...
...
@@ -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 "SPIRV99.83
0
"
#define GLSLANG_REVISION "SPIRV99.83
1
"
#define GLSLANG_DATE "08-Dec-2015"
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