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
d8fe2ca8
Commit
d8fe2ca8
authored
Oct 01, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Handle flattened I/O structs passed to function *out* parameters.
parent
c86d38bb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
33 deletions
+37
-33
hlsl.entry-out.frag.out
Test/baseResults/hlsl.entry-out.frag.out
+0
-0
hlsl.entry-out.frag
Test/hlsl.entry-out.frag
+7
-1
revision.h
glslang/Include/revision.h
+1
-1
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+29
-31
No files found.
Test/baseResults/hlsl.entry-out.frag.out
View file @
d8fe2ca8
This diff is collapsed.
Click to expand it.
Test/hlsl.entry-out.frag
View file @
d8fe2ca8
...
...
@@ -3,6 +3,12 @@ struct OutParam {
int2
i
;
};
void
fun
(
out
OutParam
op
)
{
op
.
v
=
float2
(
0
.
4
);
op
.
i
=
int2
(
7
);
}
float4
PixelShaderFunction
(
float4
input
,
out
float4
out1
,
out
OutParam
out2
,
out
OutParam
out3
)
:
COLOR0
{
out1
=
input
;
...
...
@@ -11,7 +17,7 @@ float4 PixelShaderFunction(float4 input, out float4 out1, out OutParam out2, out
OutParam
local
;
local
.
v
=
12
.
0
;
local
.
i
=
13
;
out3
=
local
;
fun
(
out3
)
;
return
out1
;
}
glslang/Include/revision.h
View file @
d8fe2ca8
...
...
@@ -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 "Overload400-PrecQual.154
3
"
#define GLSLANG_REVISION "Overload400-PrecQual.154
4
"
#define GLSLANG_DATE "01-Oct-2016"
hlsl/hlslParseHelper.cpp
View file @
d8fe2ca8
...
...
@@ -2246,21 +2246,9 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
if
(
builtIn
&&
fnCandidate
->
getNumExtensions
())
requireExtensions
(
loc
,
fnCandidate
->
getNumExtensions
(),
fnCandidate
->
getExtensions
(),
fnCandidate
->
getName
().
c_str
());
if
(
arguments
)
{
// Make sure qualifications work for these arguments.
//TIntermAggregate* aggregate = arguments->getAsAggregate();
//for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
// // At this early point there is a slight ambiguity between whether an aggregate 'arguments'
// // is the single argument itself or its children are the arguments. Only one argument
// // means take 'arguments' itself as the one argument.
// TIntermNode* arg = fnCandidate->getParamCount() == 1 ? arguments : (aggregate ? aggregate->getSequence()[i] : arguments);
// TQualifier& formalQualifier = (*fnCandidate)[i].type->getQualifier();
// TQualifier& argQualifier = arg->getAsTyped()->getQualifier();
//}
// Convert 'in' arguments
addInputArgumentConversions
(
*
fnCandidate
,
arguments
);
// arguments may be modified if it's just a single argument node
}
// Convert 'in' arguments
if
(
arguments
)
addInputArgumentConversions
(
*
fnCandidate
,
arguments
);
op
=
fnCandidate
->
getBuiltInOp
();
if
(
builtIn
&&
op
!=
EOpNull
)
{
...
...
@@ -2390,7 +2378,9 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
// At this early point there is a slight ambiguity between whether an aggregate 'arguments'
// is the single argument itself or its children are the arguments. Only one argument
// means take 'arguments' itself as the one argument.
TIntermTyped
*
arg
=
function
.
getParamCount
()
==
1
?
arguments
->
getAsTyped
()
:
(
aggregate
?
aggregate
->
getSequence
()[
i
]
->
getAsTyped
()
:
arguments
->
getAsTyped
());
TIntermTyped
*
arg
=
function
.
getParamCount
()
==
1
?
arguments
->
getAsTyped
()
:
(
aggregate
?
aggregate
->
getSequence
()[
i
]
->
getAsTyped
()
:
arguments
->
getAsTyped
());
if
(
*
function
[
i
].
type
!=
arg
->
getType
())
{
// In-qualified arguments just need an extra node added above the argument to
// convert to the correct type.
...
...
@@ -2401,9 +2391,9 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
if
(
shouldFlatten
(
arg
->
getType
()))
{
// Will make a two-level subtree.
// The deepest will copy member-by-member to build the structure to pass.
// The level above that will be a
n
two-operand EOpComma sequence that follows the copy by the
// The level above that will be a two-operand EOpComma sequence that follows the copy by the
// object itself.
TSourceLoc
dummyLoc
;
TSourceLoc
dummyLoc
;
// ?? fix these everywhere to be arguments[i]->getLoc()?
dummyLoc
.
init
();
TVariable
*
internalAggregate
=
makeInternalVariable
(
"aggShadow"
,
*
function
[
i
].
type
);
internalAggregate
->
getWritableType
().
getQualifier
().
makeTemporary
();
...
...
@@ -2433,11 +2423,16 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
TIntermTyped
*
HlslParseContext
::
addOutputArgumentConversions
(
const
TFunction
&
function
,
TIntermAggregate
&
intermNode
)
const
{
TIntermSequence
&
arguments
=
intermNode
.
getSequence
();
const
auto
needsConversion
=
[
&
](
int
argNum
)
{
return
function
[
argNum
].
type
->
getQualifier
().
isParamOutput
()
&&
(
*
function
[
argNum
].
type
!=
arguments
[
argNum
]
->
getAsTyped
()
->
getType
()
||
shouldFlatten
(
arguments
[
argNum
]
->
getAsTyped
()
->
getType
()));
};
// Will there be any output conversions?
bool
outputConversions
=
false
;
for
(
int
i
=
0
;
i
<
function
.
getParamCount
();
++
i
)
{
if
(
*
function
[
i
].
type
!=
arguments
[
i
]
->
getAsTyped
()
->
getType
()
&&
function
[
i
].
type
->
getQualifier
().
isParamOutput
(
))
{
if
(
needsConversion
(
i
))
{
outputConversions
=
true
;
break
;
}
...
...
@@ -2468,18 +2463,21 @@ TIntermTyped* HlslParseContext::addOutputArgumentConversions(const TFunction& fu
// Process each argument's conversion
for
(
int
i
=
0
;
i
<
function
.
getParamCount
();
++
i
)
{
if
(
*
function
[
i
].
type
!=
arguments
[
i
]
->
getAsTyped
()
->
getType
())
{
if
(
function
[
i
].
type
->
getQualifier
().
isParamOutput
())
{
// Out-qualified arguments need to use the topology set up above.
// do the " ...(tempArg, ...), arg = tempArg" bit from above
TVariable
*
tempArg
=
makeInternalVariable
(
"tempArg"
,
*
function
[
i
].
type
);
tempArg
->
getWritableType
().
getQualifier
().
makeTemporary
();
TIntermSymbol
*
tempArgNode
=
intermediate
.
addSymbol
(
*
tempArg
,
intermNode
.
getLoc
());
TIntermTyped
*
tempAssign
=
intermediate
.
addAssign
(
EOpAssign
,
arguments
[
i
]
->
getAsTyped
(),
tempArgNode
,
arguments
[
i
]
->
getLoc
());
conversionTree
=
intermediate
.
growAggregate
(
conversionTree
,
tempAssign
,
arguments
[
i
]
->
getLoc
());
// replace the argument with another node for the same tempArg variable
arguments
[
i
]
=
intermediate
.
addSymbol
(
*
tempArg
,
intermNode
.
getLoc
());
}
if
(
needsConversion
(
i
))
{
// Out-qualified arguments needing conversion need to use the topology setup above.
// Do the " ...(tempArg, ...), arg = tempArg" bit from above.
// Make a temporary for what the function expects the argument to look like.
TVariable
*
tempArg
=
makeInternalVariable
(
"tempArg"
,
*
function
[
i
].
type
);
tempArg
->
getWritableType
().
getQualifier
().
makeTemporary
();
TIntermSymbol
*
tempArgNode
=
intermediate
.
addSymbol
(
*
tempArg
,
intermNode
.
getLoc
());
// This makes the deepest level, the member-wise copy
TIntermTyped
*
tempAssign
=
handleAssign
(
arguments
[
i
]
->
getLoc
(),
EOpAssign
,
arguments
[
i
]
->
getAsTyped
(),
tempArgNode
)
->
getAsAggregate
();
conversionTree
=
intermediate
.
growAggregate
(
conversionTree
,
tempAssign
,
arguments
[
i
]
->
getLoc
());
// replace the argument with another node for the same tempArg variable
arguments
[
i
]
=
intermediate
.
addSymbol
(
*
tempArg
,
intermNode
.
getLoc
());
}
}
...
...
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