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
d347794e
Commit
d347794e
authored
Nov 22, 2016
by
John Kessenich
Committed by
GitHub
Nov 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #597 from steve-lunarg/sample-keyword-fix
HLSL: allow "sample" as a valid identifier.
parents
fabe7d6a
75fd223f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
0 deletions
+135
-0
hlsl.identifier.sample.frag.out
Test/baseResults/hlsl.identifier.sample.frag.out
+103
-0
hlsl.identifier.sample.frag
Test/hlsl.identifier.sample.frag
+18
-0
Hlsl.FromFile.cpp
gtests/Hlsl.FromFile.cpp
+1
-0
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+13
-0
No files found.
Test/baseResults/hlsl.identifier.sample.frag.out
0 → 100644
View file @
d347794e
hlsl.identifier.sample.frag
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:9 Function Definition: sample(i1; (temp int)
0:9 Function Parameters:
0:9 'x' (in int)
0:? Sequence
0:9 Branch: Return with expression
0:9 'x' (in int)
0:12 Function Definition: main( (temp 4-component vector of float)
0:12 Function Parameters:
0:? Sequence
0:15 Sequence
0:15 move second child to first child (temp int)
0:15 'sample' (temp int)
0:15 Constant:
0:15 3 (const int)
0:17 Sequence
0:17 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:17 Branch: Return
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:9 Function Definition: sample(i1; (temp int)
0:9 Function Parameters:
0:9 'x' (in int)
0:? Sequence
0:9 Branch: Return with expression
0:9 'x' (in int)
0:12 Function Definition: main( (temp 4-component vector of float)
0:12 Function Parameters:
0:? Sequence
0:15 Sequence
0:15 move second child to first child (temp int)
0:15 'sample' (temp int)
0:15 Constant:
0:15 3 (const int)
0:17 Sequence
0:17 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:17 Branch: Return
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 24
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 20
ExecutionMode 4 OriginUpperLeft
Name 4 "main"
Name 10 "sample(i1;"
Name 9 "x"
Name 15 "sample"
Name 20 "@entryPointOutput"
Decorate 20(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
8: TypeFunction 6(int) 7(ptr)
16: 6(int) Constant 3
17: TypeFloat 32
18: TypeVector 17(float) 4
19: TypePointer Output 18(fvec4)
20(@entryPointOutput): 19(ptr) Variable Output
21: 17(float) Constant 0
22: 18(fvec4) ConstantComposite 21 21 21 21
4(main): 2 Function None 3
5: Label
15(sample): 7(ptr) Variable Function
Store 15(sample) 16
Store 20(@entryPointOutput) 22
Return
FunctionEnd
10(sample(i1;): 6(int) Function None 8
9(x): 7(ptr) FunctionParameter
11: Label
12: 6(int) Load 9(x)
ReturnValue 12
FunctionEnd
Test/hlsl.identifier.sample.frag
0 → 100644
View file @
d347794e
struct
MyStruct
{
sample
float
a
;
noperspective
float
b
;
linear
float
c
;
centroid
float
d
;
};
int
sample
(
int
x
)
{
return
x
;
}
// HLSL allows this as an identifier as well.
float4
main
()
:
SV_Target0
{
// HLSL allows this as an identifier as well.
// However, this is not true of other qualifier keywords such as "linear".
int
sample
=
3
;
return
float4
(
0
,
0
,
0
,
0
);
}
gtests/Hlsl.FromFile.cpp
View file @
d347794e
...
...
@@ -118,6 +118,7 @@ INSTANTIATE_TEST_CASE_P(
{
"hlsl.getdimensions.rw.dx10.frag"
,
"main"
},
{
"hlsl.getdimensions.dx10.vert"
,
"main"
},
{
"hlsl.getsampleposition.dx10.frag"
,
"main"
},
{
"hlsl.identifier.sample.frag"
,
"main"
},
{
"hlsl.if.frag"
,
"PixelShaderFunction"
},
{
"hlsl.inoutquals.frag"
,
"main"
},
{
"hlsl.init.frag"
,
"ShaderFunction"
},
...
...
hlsl/hlslGrammar.cpp
View file @
d347794e
...
...
@@ -85,6 +85,19 @@ bool HlslGrammar::acceptIdentifier(HlslToken& idToken)
return
true
;
}
// Even though "sample" is a keyword (for interpolation modifiers), it IS still accepted as
// an identifier. This appears to be a solitary exception: other interp modifier keywords such
// as "linear" or "centroid" NOT valid identifiers. This code special cases "sample",
// so e.g, "int sample;" is accepted.
if
(
peekTokenClass
(
EHTokSample
))
{
idToken
.
string
=
NewPoolTString
(
"sample"
);
idToken
.
tokenClass
=
EHTokIdentifier
;
idToken
.
symbol
=
nullptr
;
idToken
.
loc
=
token
.
loc
;
advanceToken
();
return
true
;
}
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