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
4e13c909
Commit
4e13c909
authored
Jul 13, 2020
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #2329: don't use invalid initializers.
parent
20688694
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
2 deletions
+176
-2
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+1
-1
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+1
-1
SpvBuilder.h
SPIRV/SpvBuilder.h
+7
-0
spv.ext.World3x4.rahit.out
Test/baseResults/spv.ext.World3x4.rahit.out
+145
-0
spv.ext.World3x4.rahit
Test/spv.ext.World3x4.rahit
+21
-0
Spv.FromFile.cpp
gtests/Spv.FromFile.cpp
+1
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
4e13c909
...
@@ -1724,7 +1724,7 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
...
@@ -1724,7 +1724,7 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
spv
::
StorageClass
sc
=
builder
.
getStorageClass
(
id
);
spv
::
StorageClass
sc
=
builder
.
getStorageClass
(
id
);
// Before SPIR-V 1.4, we only want to include Input and Output.
// Before SPIR-V 1.4, we only want to include Input and Output.
// Starting with SPIR-V 1.4, we want all globals.
// Starting with SPIR-V 1.4, we want all globals.
if
((
glslangIntermediate
->
getSpv
().
spv
>=
glslang
::
EShTargetSpv_1_4
&&
sc
!=
spv
::
StorageClassFunction
)
||
if
((
glslangIntermediate
->
getSpv
().
spv
>=
glslang
::
EShTargetSpv_1_4
&&
builder
.
isGlobalStorage
(
id
)
)
||
(
sc
==
spv
::
StorageClassInput
||
sc
==
spv
::
StorageClassOutput
))
{
(
sc
==
spv
::
StorageClassInput
||
sc
==
spv
::
StorageClassOutput
))
{
iOSet
.
insert
(
id
);
iOSet
.
insert
(
id
);
}
}
...
...
SPIRV/SpvBuilder.cpp
View file @
4e13c909
...
@@ -2722,7 +2722,7 @@ Id Builder::accessChainLoad(Decoration precision, Decoration nonUniform, Id resu
...
@@ -2722,7 +2722,7 @@ Id Builder::accessChainLoad(Decoration precision, Decoration nonUniform, Id resu
setPrecision
(
id
,
precision
);
setPrecision
(
id
,
precision
);
}
else
{
}
else
{
Id
lValue
=
NoResult
;
Id
lValue
=
NoResult
;
if
(
spvVersion
>=
Spv_1_4
)
{
if
(
spvVersion
>=
Spv_1_4
&&
isValidInitializer
(
accessChain
.
base
)
)
{
// make a new function variable for this r-value, using an initializer,
// make a new function variable for this r-value, using an initializer,
// and mark it as NonWritable so that downstream it can be detected as a lookup
// and mark it as NonWritable so that downstream it can be detected as a lookup
// table
// table
...
...
SPIRV/SpvBuilder.h
View file @
4e13c909
...
@@ -248,6 +248,13 @@ public:
...
@@ -248,6 +248,13 @@ public:
{
return
module
.
getInstruction
(
resultId
)
->
getImmediateOperand
(
0
);
}
{
return
module
.
getInstruction
(
resultId
)
->
getImmediateOperand
(
0
);
}
StorageClass
getStorageClass
(
Id
resultId
)
const
{
return
getTypeStorageClass
(
getTypeId
(
resultId
));
}
StorageClass
getStorageClass
(
Id
resultId
)
const
{
return
getTypeStorageClass
(
getTypeId
(
resultId
));
}
bool
isVariableOpCode
(
Op
opcode
)
const
{
return
opcode
==
OpVariable
;
}
bool
isVariable
(
Id
resultId
)
const
{
return
isVariableOpCode
(
getOpCode
(
resultId
));
}
bool
isGlobalStorage
(
Id
resultId
)
const
{
return
getStorageClass
(
resultId
)
!=
StorageClassFunction
;
}
bool
isGlobalVariable
(
Id
resultId
)
const
{
return
isVariable
(
resultId
)
&&
isGlobalStorage
(
resultId
);
}
// See if a resultId is valid for use as an initializer.
bool
isValidInitializer
(
Id
resultId
)
const
{
return
isConstant
(
resultId
)
||
isGlobalVariable
(
resultId
);
}
int
getScalarTypeWidth
(
Id
typeId
)
const
int
getScalarTypeWidth
(
Id
typeId
)
const
{
{
Id
scalarTypeId
=
getScalarTypeId
(
typeId
);
Id
scalarTypeId
=
getScalarTypeId
(
typeId
);
...
...
Test/baseResults/spv.ext.World3x4.rahit.out
0 → 100755
View file @
4e13c909
spv.ext.World3x4.rahit
// Module Version 10400
// Generated by (magic number): 8000a
// Id's are bound by 90
Capability RayTracingProvisionalKHR
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint AnyHitKHR 4 "main" 43 60 78 87 89
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"
Name 8 "k"
Name 12 "ndx"
Name 14 "col"
Name 25 "row"
Name 39 "p"
Name 43 "gl_LaunchIDEXT"
Name 53 "r"
Name 60 "gl_WorldToObject3x4EXT"
Name 66 "indexable"
Name 72 "c"
Name 78 "result"
Name 87 "attribs"
Name 89 "hitValue"
Decorate 43(gl_LaunchIDEXT) BuiltIn LaunchIdKHR
Decorate 60(gl_WorldToObject3x4EXT) BuiltIn WorldToObjectKHR
Decorate 78(result) DescriptorSet 0
Decorate 78(result) Binding 0
Decorate 89(hitValue) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Function 6(float)
9: 6(float) Constant 1233125376
10: TypeInt 32 1
11: TypePointer Function 10(int)
13: 10(int) Constant 4294967295
15: 10(int) Constant 0
22: 10(int) Constant 3
23: TypeBool
32: 10(int) Constant 4
35: 10(int) Constant 1
37: TypeVector 10(int) 3
38: TypePointer Function 37(ivec3)
40: TypeInt 32 0
41: TypeVector 40(int) 3
42: TypePointer Input 41(ivec3)
43(gl_LaunchIDEXT): 42(ptr) Variable Input
44: TypeVector 40(int) 2
47: TypeVector 10(int) 2
55: TypeVector 6(float) 4
56: TypeMatrix 55(fvec4) 3
57: TypeVector 6(float) 3
58: TypeMatrix 57(fvec3) 4
59: TypePointer Input 58
60(gl_WorldToObject3x4EXT): 59(ptr) Variable Input
65: TypePointer Function 56
70: TypeVector 10(int) 4
71: TypePointer Function 70(ivec4)
76: TypeImage 10(int) 3D nonsampled format:R32i
77: TypePointer UniformConstant 76
78(result): 77(ptr) Variable UniformConstant
86: TypePointer HitAttributeKHR 57(fvec3)
87(attribs): 86(ptr) Variable HitAttributeKHR
88: TypePointer IncomingRayPayloadKHR 57(fvec3)
89(hitValue): 88(ptr) Variable IncomingRayPayloadKHR
4(main): 2 Function None 3
5: Label
8(k): 7(ptr) Variable Function
12(ndx): 11(ptr) Variable Function
14(col): 11(ptr) Variable Function
25(row): 11(ptr) Variable Function
39(p): 38(ptr) Variable Function
53(r): 7(ptr) Variable Function
66(indexable): 65(ptr) Variable Function
72(c): 71(ptr) Variable Function
Store 8(k) 9
Store 12(ndx) 13
Store 14(col) 15
Branch 16
16: Label
LoopMerge 18 19 None
Branch 20
20: Label
21: 10(int) Load 14(col)
24: 23(bool) SLessThan 21 22
BranchConditional 24 17 18
17: Label
Store 25(row) 15
Branch 26
26: Label
LoopMerge 28 29 None
Branch 30
30: Label
31: 10(int) Load 25(row)
33: 23(bool) SLessThan 31 32
BranchConditional 33 27 28
27: Label
34: 10(int) Load 12(ndx)
36: 10(int) IAdd 34 35
Store 12(ndx) 36
45: 41(ivec3) Load 43(gl_LaunchIDEXT)
46: 44(ivec2) VectorShuffle 45 45 0 1
48: 47(ivec2) Bitcast 46
49: 10(int) Load 12(ndx)
50: 10(int) CompositeExtract 48 0
51: 10(int) CompositeExtract 48 1
52: 37(ivec3) CompositeConstruct 50 51 49
Store 39(p) 52
54: 6(float) Load 8(k)
61: 58 Load 60(gl_WorldToObject3x4EXT)
62: 56 Transpose 61
63: 10(int) Load 14(col)
64: 10(int) Load 25(row)
Store 66(indexable) 62
67: 7(ptr) AccessChain 66(indexable) 63 64
68: 6(float) Load 67
69: 6(float) FMul 54 68
Store 53(r) 69
73: 6(float) Load 53(r)
74: 10(int) ConvertFToS 73
75: 70(ivec4) CompositeConstruct 74 15 15 35
Store 72(c) 75
79: 76 Load 78(result)
80: 37(ivec3) Load 39(p)
81: 70(ivec4) Load 72(c)
ImageWrite 79 80 81 SignExtend
Branch 29
29: Label
82: 10(int) Load 25(row)
83: 10(int) IAdd 82 35
Store 25(row) 83
Branch 26
28: Label
Branch 19
19: Label
84: 10(int) Load 14(col)
85: 10(int) IAdd 84 35
Store 14(col) 85
Branch 16
18: Label
Return
FunctionEnd
Test/spv.ext.World3x4.rahit
0 → 100644
View file @
4e13c909
#version 460
#extension GL_EXT_ray_tracing : enable
hitAttributeEXT vec3 attribs;
layout(location = 0) rayPayloadInEXT vec3 hitValue;
layout(set = 0, binding = 0, r32i) uniform iimage3D result;
void main()
{
float k = 1048576.0f;
int ndx = -1;
for (int col = 0; col < 3; col++)
for (int row = 0; row < 4; row++)
{
ndx++;
ivec3 p = ivec3(gl_LaunchIDEXT.xy, ndx);
float r = k * gl_WorldToObject3x4EXT[col][row];
ivec4 c = ivec4(int(r),0,0,1);
imageStore(result, p, c);
}
}
gtests/Spv.FromFile.cpp
View file @
4e13c909
...
@@ -560,6 +560,7 @@ INSTANTIATE_TEST_CASE_P(
...
@@ -560,6 +560,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.ext.RayGenShader.rgen"
,
"spv.ext.RayGenShader.rgen"
,
"spv.ext.RayGenShader11.rgen"
,
"spv.ext.RayGenShader11.rgen"
,
"spv.ext.RayGenShaderArray.rgen"
,
"spv.ext.RayGenShaderArray.rgen"
,
"spv.ext.World3x4.rahit"
,
})),
})),
FileNameAsCustomTestSuffix
FileNameAsCustomTestSuffix
);
);
...
...
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