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
6042eb47
Commit
6042eb47
authored
Aug 02, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Non-functional: HLSL: Simplify I/O logic for splitting.
parent
4cf52660
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
55 deletions
+36
-55
Types.h
glslang/Include/Types.h
+7
-19
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+29
-36
No files found.
glslang/Include/Types.h
View file @
6042eb47
...
@@ -1370,15 +1370,12 @@ public:
...
@@ -1370,15 +1370,12 @@ public:
virtual
bool
isImage
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isImage
();
}
virtual
bool
isImage
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isImage
();
}
virtual
bool
isSubpass
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isSubpass
();
}
virtual
bool
isSubpass
()
const
{
return
basicType
==
EbtSampler
&&
getSampler
().
isSubpass
();
}
virtual
bool
isBuiltInInterstageIO
(
EShLanguage
language
)
const
virtual
bool
isBuiltIn
()
const
{
return
getQualifier
().
builtIn
!=
EbvNone
;
}
{
return
isPerVertexAndBuiltIn
(
language
)
||
isLooseAndBuiltIn
(
language
);
}
// Return true if this is a
n interstage IO built
in
// Return true if this is a
per-vertex built-
in
virtual
bool
isPerVertex
And
BuiltIn
(
EShLanguage
language
)
const
virtual
bool
isPerVertexBuiltIn
(
EShLanguage
language
)
const
{
{
if
(
language
==
EShLangFragment
)
if
(
getQualifier
().
builtIn
==
EbvNone
||
language
==
EShLangFragment
)
return
false
;
return
false
;
// Any non-fragment stage
// Any non-fragment stage
...
@@ -1401,15 +1398,6 @@ public:
...
@@ -1401,15 +1398,6 @@ public:
}
}
}
}
// Return true if this is a loose builtin
virtual
bool
isLooseAndBuiltIn
(
EShLanguage
language
)
const
{
if
(
getQualifier
().
builtIn
==
EbvNone
)
return
false
;
return
!
isPerVertexAndBuiltIn
(
language
);
}
// return true if this type contains any subtype which satisfies the given predicate.
// return true if this type contains any subtype which satisfies the given predicate.
template
<
typename
P
>
template
<
typename
P
>
bool
contains
(
P
predicate
)
const
bool
contains
(
P
predicate
)
const
...
@@ -1451,10 +1439,10 @@ public:
...
@@ -1451,10 +1439,10 @@ public:
return
contains
([](
const
TType
*
t
)
{
return
t
->
isOpaque
();
}
);
return
contains
([](
const
TType
*
t
)
{
return
t
->
isOpaque
();
}
);
}
}
// Recursively checks if the type contains a
n interstage IO builtin
// Recursively checks if the type contains a
built-in variable
virtual
bool
containsBuiltIn
InterstageIO
(
EShLanguage
language
)
const
virtual
bool
containsBuiltIn
(
)
const
{
{
return
contains
([
language
](
const
TType
*
t
)
{
return
t
->
isBuiltInInterstageIO
(
language
);
}
);
return
contains
([
](
const
TType
*
t
)
{
return
t
->
isBuiltIn
(
);
}
);
}
}
virtual
bool
containsNonOpaque
()
const
virtual
bool
containsNonOpaque
()
const
...
...
hlsl/hlslParseHelper.cpp
View file @
6042eb47
...
@@ -1126,39 +1126,32 @@ TType& HlslParseContext::split(TType& type, TString name, const TType* outerStru
...
@@ -1126,39 +1126,32 @@ TType& HlslParseContext::split(TType& type, TString name, const TType* outerStru
// We can ignore arrayness: it's uninvolved.
// We can ignore arrayness: it's uninvolved.
if
(
type
.
isStruct
())
{
if
(
type
.
isStruct
())
{
TTypeList
*
userStructure
=
type
.
getWritableStruct
();
TTypeList
*
userStructure
=
type
.
getWritableStruct
();
for
(
auto
ioType
=
userStructure
->
begin
();
ioType
!=
userStructure
->
end
();
)
{
if
(
ioType
->
type
->
getQualifier
().
builtIn
!=
EbvNone
)
{
// split out built-in interstage IO
const
TType
&
memberType
=
*
ioType
->
type
;
TVariable
*
ioVar
=
makeInternalVariable
(
name
+
(
name
.
empty
()
?
""
:
"_"
)
+
memberType
.
getFieldName
(),
memberType
);
// Get iterator to (now at end) set of built-in interstage IO members
if
(
arraySizes
)
const
auto
firstIo
=
std
::
stable_partition
(
userStructure
->
begin
(),
userStructure
->
end
(),
ioVar
->
getWritableType
().
newArraySizes
(
*
arraySizes
);
[
this
](
const
TTypeLoc
&
t
)
{
return
!
t
.
type
->
isBuiltInInterstageIO
(
language
);
});
// Move those to the built-in IO. However, we also propagate arrayness (just one level is handled
fixBuiltInIoType
(
ioVar
->
getWritableType
());
// now) to this variable.
for
(
auto
ioType
=
firstIo
;
ioType
!=
userStructure
->
end
();
++
ioType
)
{
const
TType
&
memberType
=
*
ioType
->
type
;
TVariable
*
ioVar
=
makeInternalVariable
(
name
+
(
name
.
empty
()
?
""
:
"_"
)
+
memberType
.
getFieldName
(),
memberType
);
if
(
arraySizes
)
interstageBuiltInIo
[
tInterstageIoData
(
memberType
,
*
outerStructType
)]
=
ioVar
;
ioVar
->
getWritableType
().
newArraySizes
(
*
arraySizes
);
fixBuiltInIoType
(
ioVar
->
getWritableType
());
// Merge qualifier from the user structure
mergeQualifiers
(
ioVar
->
getWritableType
().
getQualifier
(),
outerStructType
->
getQualifier
());
interstageBuiltInIo
[
tInterstageIoData
(
memberType
,
*
outerStructType
)]
=
ioVar
;
// Erase the IO vars from the user structure.
ioType
=
userStructure
->
erase
(
ioType
);
// Merge qualifier from the user structure
}
else
{
mergeQualifiers
(
ioVar
->
getWritableType
().
getQualifier
(),
outerStructType
->
getQualifier
());
split
(
*
ioType
->
type
,
name
+
(
name
.
empty
()
?
""
:
"_"
)
+
ioType
->
type
->
getFieldName
(),
outerStructType
);
++
ioType
;
}
}
}
// Erase the IO vars from the user structure.
userStructure
->
erase
(
firstIo
,
userStructure
->
end
());
// Recurse further into the members.
for
(
unsigned
int
i
=
0
;
i
<
userStructure
->
size
();
++
i
)
split
(
*
(
*
userStructure
)[
i
].
type
,
name
+
(
name
.
empty
()
?
""
:
"_"
)
+
(
*
userStructure
)[
i
].
type
->
getFieldName
(),
outerStructType
);
}
}
return
type
;
return
type
;
...
@@ -1556,7 +1549,7 @@ void HlslParseContext::addInterstageIoToLinkage()
...
@@ -1556,7 +1549,7 @@ void HlslParseContext::addInterstageIoToLinkage()
TVariable
*
var
=
interstageBuiltInIo
[
io
[
idx
]];
TVariable
*
var
=
interstageBuiltInIo
[
io
[
idx
]];
// Add the loose interstage IO to the linkage
// Add the loose interstage IO to the linkage
if
(
var
->
getType
().
isLooseAnd
BuiltIn
(
language
))
if
(
!
var
->
getType
().
isPerVertex
BuiltIn
(
language
))
trackLinkage
(
*
var
);
trackLinkage
(
*
var
);
}
}
}
}
...
@@ -1906,8 +1899,8 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
...
@@ -1906,8 +1899,8 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
if
((
language
==
EShLangVertex
&&
qualifier
==
EvqVaryingIn
)
||
if
((
language
==
EShLangVertex
&&
qualifier
==
EvqVaryingIn
)
||
(
language
==
EShLangFragment
&&
qualifier
==
EvqVaryingOut
))
(
language
==
EShLangFragment
&&
qualifier
==
EvqVaryingOut
))
flatten
(
variable
);
flatten
(
variable
);
// Structs contain
interstage IO
must be split
// Structs contain
ing built-ins
must be split
else
if
(
variable
.
getType
().
containsBuiltIn
InterstageIO
(
language
))
else
if
(
variable
.
getType
().
containsBuiltIn
(
))
split
(
variable
);
split
(
variable
);
}
}
...
@@ -2530,7 +2523,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
...
@@ -2530,7 +2523,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
TIntermTyped
*
subTree
;
TIntermTyped
*
subTree
;
const
TType
derefType
(
node
->
getType
(),
member
);
const
TType
derefType
(
node
->
getType
(),
member
);
if
(
split
&&
derefType
.
isBuiltIn
InterstageIO
(
language
))
{
if
(
split
&&
derefType
.
isBuiltIn
(
))
{
// copy from interstage IO built-in if needed
// copy from interstage IO built-in if needed
const
TIntermTyped
*
outer
=
isLeft
?
outerLeft
:
outerRight
;
const
TIntermTyped
*
outer
=
isLeft
?
outerLeft
:
outerRight
;
subTree
=
intermediate
.
addSymbol
(
*
interstageBuiltInIo
.
find
(
subTree
=
intermediate
.
addSymbol
(
*
interstageBuiltInIo
.
find
(
...
@@ -2644,8 +2637,8 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
...
@@ -2644,8 +2637,8 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
assignList
=
intermediate
.
growAggregate
(
assignList
,
clipCullAssign
,
loc
);
assignList
=
intermediate
.
growAggregate
(
assignList
,
clipCullAssign
,
loc
);
}
else
if
(
!
isFlattenLeft
&&
!
isFlattenRight
&&
}
else
if
(
!
isFlattenLeft
&&
!
isFlattenRight
&&
!
typeL
.
containsBuiltIn
InterstageIO
(
language
)
&&
!
typeL
.
containsBuiltIn
(
)
&&
!
typeR
.
containsBuiltIn
InterstageIO
(
language
))
{
!
typeR
.
containsBuiltIn
(
))
{
// If this is the final flattening (no nested types below to flatten)
// If this is the final flattening (no nested types below to flatten)
// we'll copy the member, else recurse into the type hierarchy.
// we'll copy the member, else recurse into the type hierarchy.
// However, if splitting the struct, that means we can copy a whole
// However, if splitting the struct, that means we can copy a whole
...
@@ -2661,8 +2654,8 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
...
@@ -2661,8 +2654,8 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
traverse
(
subLeft
,
subRight
,
subSplitLeft
,
subSplitRight
);
traverse
(
subLeft
,
subRight
,
subSplitLeft
,
subSplitRight
);
}
}
memberL
+=
(
typeL
.
isBuiltIn
InterstageIO
(
language
)
?
0
:
1
);
memberL
+=
(
typeL
.
isBuiltIn
(
)
?
0
:
1
);
memberR
+=
(
typeR
.
isBuiltIn
InterstageIO
(
language
)
?
0
:
1
);
memberR
+=
(
typeR
.
isBuiltIn
(
)
?
0
:
1
);
}
}
}
else
{
}
else
{
// Member copy
// Member copy
...
@@ -9197,7 +9190,7 @@ void HlslParseContext::addPatchConstantInvocation()
...
@@ -9197,7 +9190,7 @@ void HlslParseContext::addPatchConstantInvocation()
TVariable
*
pcfOutput
=
makeInternalVariable
(
"@patchConstantOutput"
,
outType
);
TVariable
*
pcfOutput
=
makeInternalVariable
(
"@patchConstantOutput"
,
outType
);
pcfOutput
->
getWritableType
().
getQualifier
().
storage
=
EvqVaryingOut
;
pcfOutput
->
getWritableType
().
getQualifier
().
storage
=
EvqVaryingOut
;
if
(
pcfOutput
->
getType
().
containsBuiltIn
InterstageIO
(
language
))
if
(
pcfOutput
->
getType
().
containsBuiltIn
(
))
split
(
*
pcfOutput
);
split
(
*
pcfOutput
);
assignToInterface
(
*
pcfOutput
);
assignToInterface
(
*
pcfOutput
);
...
...
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