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
1b46f137
Commit
1b46f137
authored
Oct 19, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Fix #1106. Support shader setting of binding/set for $Global.
parent
fe4e572c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
141 additions
and
2 deletions
+141
-2
hlsl.attributeGlobalBuffer.frag.out
Test/baseResults/hlsl.attributeGlobalBuffer.frag.out
+109
-0
hlsl.attributeGlobalBuffer.frag
Test/hlsl.attributeGlobalBuffer.frag
+9
-0
ParseContextBase.cpp
glslang/MachineIndependent/ParseContextBase.cpp
+4
-0
ParseHelper.h
glslang/MachineIndependent/ParseHelper.h
+5
-1
Hlsl.FromFile.cpp
gtests/Hlsl.FromFile.cpp
+1
-0
hlslAttributes.cpp
hlsl/hlslAttributes.cpp
+2
-0
hlslAttributes.h
hlsl/hlslAttributes.h
+1
-0
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+8
-0
hlslParseHelper.h
hlsl/hlslParseHelper.h
+2
-1
No files found.
Test/baseResults/hlsl.attributeGlobalBuffer.frag.out
0 → 100755
View file @
1b46f137
hlsl.attributeGlobalBuffer.frag
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
0:6 Function Definition: @main( ( temp 4-component vector of float)
0:6 Function Parameters:
0:? Sequence
0:7 Branch: Return with expression
0:7 add ( temp 4-component vector of float)
0:7 u1: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 0 (const uint)
0:7 u2: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 1 (const uint)
0:6 Function Definition: main( ( temp void)
0:6 Function Parameters:
0:? Sequence
0:6 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:6 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
Linked fragment stage:
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
0:6 Function Definition: @main( ( temp 4-component vector of float)
0:6 Function Parameters:
0:? Sequence
0:7 Branch: Return with expression
0:7 add ( temp 4-component vector of float)
0:7 u1: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 0 (const uint)
0:7 u2: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 1 (const uint)
0:6 Function Definition: main( ( temp void)
0:6 Function Parameters:
0:? Sequence
0:6 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:6 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 28
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 26
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
Name 9 "@main("
Name 11 "$Global"
MemberName 11($Global) 0 "u1"
MemberName 11($Global) 1 "u2"
Name 13 ""
Name 26 "@entryPointOutput"
MemberDecorate 11($Global) 0 Offset 0
MemberDecorate 11($Global) 1 Offset 16
Decorate 11($Global) Block
Decorate 13 DescriptorSet 2
Decorate 13 Binding 5
Decorate 26(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeFunction 7(fvec4)
11($Global): TypeStruct 7(fvec4) 7(fvec4)
12: TypePointer Uniform 11($Global)
13: 12(ptr) Variable Uniform
14: TypeInt 32 1
15: 14(int) Constant 0
16: TypePointer Uniform 7(fvec4)
19: 14(int) Constant 1
25: TypePointer Output 7(fvec4)
26(@entryPointOutput): 25(ptr) Variable Output
4(main): 2 Function None 3
5: Label
27: 7(fvec4) FunctionCall 9(@main()
Store 26(@entryPointOutput) 27
Return
FunctionEnd
9(@main(): 7(fvec4) Function None 8
10: Label
17: 16(ptr) AccessChain 13 15
18: 7(fvec4) Load 17
20: 16(ptr) AccessChain 13 19
21: 7(fvec4) Load 20
22: 7(fvec4) FAdd 18 21
ReturnValue 22
FunctionEnd
Test/hlsl.attributeGlobalBuffer.frag
0 → 100644
View file @
1b46f137
[[
vk
::
global_cbuffer_binding
(
5
,
2
)]]
float4
u1
;
float4
u2
;
float4
main
()
:
SV_Target0
{
return
u1
+
u2
;
}
\ No newline at end of file
glslang/MachineIndependent/ParseContextBase.cpp
View file @
1b46f137
...
...
@@ -569,6 +569,10 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem
firstNewMember
=
0
;
}
// Update with binding and set
globalUniformBlock
->
getWritableType
().
getQualifier
().
layoutBinding
=
globalUniformBinding
;
globalUniformBlock
->
getWritableType
().
getQualifier
().
layoutSet
=
globalUniformSet
;
// Add the requested member as a member to the global block.
TType
*
type
=
new
TType
;
type
->
shallowCopy
(
memberType
);
...
...
glslang/MachineIndependent/ParseHelper.h
View file @
1b46f137
...
...
@@ -84,7 +84,9 @@ public:
contextPragma
(
true
,
false
),
parsingBuiltins
(
parsingBuiltins
),
scanContext
(
nullptr
),
ppContext
(
nullptr
),
limits
(
resources
.
limits
),
globalUniformBlock
(
nullptr
)
globalUniformBlock
(
nullptr
),
globalUniformBinding
(
TQualifier
::
layoutBindingEnd
),
globalUniformSet
(
TQualifier
::
layoutSetEnd
)
{
if
(
entryPoint
!=
nullptr
)
sourceEntryPointName
=
*
entryPoint
;
...
...
@@ -209,6 +211,8 @@ protected:
// Manage the global uniform block (default uniforms in GLSL, $Global in HLSL)
TVariable
*
globalUniformBlock
;
// the actual block, inserted into the symbol table
unsigned
int
globalUniformBinding
;
unsigned
int
globalUniformSet
;
int
firstNewMember
;
// the index of the first member not yet inserted into the symbol table
// override this to set the language-specific name
virtual
const
char
*
getGlobalUniformBlockName
()
const
{
return
""
;
}
...
...
gtests/Hlsl.FromFile.cpp
View file @
1b46f137
...
...
@@ -100,6 +100,7 @@ INSTANTIATE_TEST_CASE_P(
{
"hlsl.attribute.frag"
,
"PixelShaderFunction"
},
{
"hlsl.attribute.expression.comp"
,
"main"
},
{
"hlsl.attributeC11.frag"
,
"main"
},
{
"hlsl.attributeGlobalBuffer.frag"
,
"main"
},
{
"hlsl.basic.comp"
,
"main"
},
{
"hlsl.basic.geom"
,
"main"
},
{
"hlsl.boolConv.vert"
,
"main"
},
...
...
hlsl/hlslAttributes.cpp
View file @
1b46f137
...
...
@@ -58,6 +58,8 @@ namespace glslang {
return
EatLocation
;
else
if
(
lowername
==
"binding"
)
return
EatBinding
;
else
if
(
lowername
==
"global_cbuffer_binding"
)
return
EatGlobalBinding
;
}
else
if
(
lowernameSpace
.
size
()
>
0
)
return
EatNone
;
...
...
hlsl/hlslAttributes.h
View file @
1b46f137
...
...
@@ -64,6 +64,7 @@ namespace glslang {
EatUnroll
,
EatLoop
,
EatBinding
,
EatGlobalBinding
,
EatLocation
,
EatInputAttachment
};
...
...
hlsl/hlslParseHelper.cpp
View file @
1b46f137
...
...
@@ -1869,6 +1869,14 @@ void HlslParseContext::transferTypeAttributes(const TAttributeMap& attributes, T
if
(
attributes
.
getInt
(
EatBinding
,
value
,
1
))
type
.
getQualifier
().
layoutSet
=
value
;
// global cbuffer binding
if
(
attributes
.
getInt
(
EatGlobalBinding
,
value
))
globalUniformBinding
=
value
;
// global cbuffer binding
if
(
attributes
.
getInt
(
EatGlobalBinding
,
value
,
1
))
globalUniformSet
=
value
;
// input attachment
if
(
attributes
.
getInt
(
EatInputAttachment
,
value
))
type
.
getQualifier
().
layoutAttachment
=
value
;
...
...
hlsl/hlslParseHelper.h
View file @
1b46f137
...
...
@@ -187,7 +187,8 @@ public:
void
pushSwitchSequence
(
TIntermSequence
*
sequence
)
{
switchSequenceStack
.
push_back
(
sequence
);
}
void
popSwitchSequence
()
{
switchSequenceStack
.
pop_back
();
}
virtual
void
growGlobalUniformBlock
(
const
TSourceLoc
&
,
TType
&
,
const
TString
&
memberName
,
TTypeList
*
typeList
=
nullptr
)
override
;
virtual
void
growGlobalUniformBlock
(
const
TSourceLoc
&
,
TType
&
,
const
TString
&
memberName
,
TTypeList
*
typeList
=
nullptr
)
override
;
// Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore.
TIntermTyped
*
handleLvalue
(
const
TSourceLoc
&
,
const
char
*
op
,
TIntermTyped
*&
node
);
...
...
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