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
f97f2ce6
Commit
f97f2ce6
authored
Nov 27, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Support the constructor idiom "(struct type)0".
This highly leverages the previous commit to handle partial initializers.
parent
98ad4853
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
6 deletions
+31
-6
hlsl.partialInit.frag.out
Test/baseResults/hlsl.partialInit.frag.out
+0
-0
hlsl.partialInit.frag
Test/hlsl.partialInit.frag
+10
-2
revision.h
glslang/Include/revision.h
+1
-1
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+19
-3
hlslParseHelper.h
hlsl/hlslParseHelper.h
+1
-0
No files found.
Test/baseResults/hlsl.partialInit.frag.out
View file @
f97f2ce6
This diff is collapsed.
Click to expand it.
Test/hlsl.partialInit.frag
View file @
f97f2ce6
...
...
@@ -8,15 +8,22 @@ struct outs {
static
float4
gv
=
{
0
,
0
,
1
};
static
float
gfa
[
3
]
=
{
0
,
0
};
struct
Nest
{
float4x3
m
;
outs
os
;
bool
b
;
};
outs
PixelShaderFunction
(
float4
input
)
:
COLOR0
{
outs
o2
=
{
3
};
outs
o4
;
o4
.
v
=
gv
*
gfa
[
2
];
outs
o1
=
{
};
//
outs o3 = (outs)0;
//
o4 = (outs)0;
outs
o3
=
(
outs
)
0
;
o4
=
(
outs
)
0
;
o4
.
c
=
o1
.
c
;
Nest
nest
=
(
Nest
)
0
;
return
o4
;
}
\ No newline at end of file
glslang/Include/revision.h
View file @
f97f2ce6
...
...
@@ -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.166
5
"
#define GLSLANG_REVISION "Overload400-PrecQual.166
6
"
#define GLSLANG_DATE "27-Nov-2016"
hlsl/hlslParseHelper.cpp
View file @
f97f2ce6
...
...
@@ -3285,7 +3285,7 @@ bool HlslParseContext::builtInName(const TString& /*identifier*/)
//
// Returns true if there was an error in construction.
//
bool
HlslParseContext
::
constructorError
(
const
TSourceLoc
&
loc
,
TIntermNode
*
/*node*/
,
TFunction
&
function
,
bool
HlslParseContext
::
constructorError
(
const
TSourceLoc
&
loc
,
TIntermNode
*
node
,
TFunction
&
function
,
TOperator
op
,
TType
&
type
)
{
type
.
shallowCopy
(
function
.
getType
());
...
...
@@ -3411,6 +3411,9 @@ bool HlslParseContext::constructorError(const TSourceLoc& loc, TIntermNode* /*no
return
true
;
}
if
(
op
==
EOpConstructStruct
&&
!
type
.
isArray
()
&&
isZeroConstructor
(
node
))
return
false
;
if
(
op
==
EOpConstructStruct
&&
!
type
.
isArray
()
&&
(
int
)
type
.
getStruct
()
->
size
()
!=
function
.
getParamCount
())
{
error
(
loc
,
"Number of constructor parameters does not match the number of structure fields"
,
"constructor"
,
""
);
return
true
;
...
...
@@ -3422,11 +3425,15 @@ bool HlslParseContext::constructorError(const TSourceLoc& loc, TIntermNode* /*no
return
true
;
}
// TIntermTyped* typed = node->getAsTyped();
return
false
;
}
bool
HlslParseContext
::
isZeroConstructor
(
const
TIntermNode
*
node
)
{
return
node
->
getAsTyped
()
->
isScalar
()
&&
node
->
getAsConstantUnion
()
&&
node
->
getAsConstantUnion
()
->
getConstArray
()[
0
].
getIConst
()
==
0
;
}
// Verify all the correct semantics for constructing a combined texture/sampler.
// Return true if the semantics are incorrect.
bool
HlslParseContext
::
constructorTextureSamplerError
(
const
TSourceLoc
&
loc
,
const
TFunction
&
function
)
...
...
@@ -4672,6 +4679,11 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm
// creating a constructor-style initializer, ensuring we get the
// same form.
//
// Returns a node representing an expression for the initializer list expressed
// as the correct type.
//
// Returns nullptr if there is an error.
//
TIntermTyped
*
HlslParseContext
::
convertInitializerList
(
const
TSourceLoc
&
loc
,
const
TType
&
type
,
TIntermTyped
*
initializer
)
{
// Will operate recursively. Once a subtree is found that is constructor style,
...
...
@@ -4808,6 +4820,10 @@ TIntermTyped* HlslParseContext::addConstructor(const TSourceLoc& loc, TIntermNod
if
(
node
==
nullptr
||
node
->
getAsTyped
()
==
nullptr
)
return
nullptr
;
// Handle the idiom "(struct type)0"
if
(
type
.
isStruct
()
&&
isZeroConstructor
(
node
))
return
convertInitializerList
(
loc
,
type
,
intermediate
.
makeAggregate
(
loc
));
TIntermAggregate
*
aggrNode
=
node
->
getAsAggregate
();
TOperator
op
=
intermediate
.
mapTypeToConstructorOp
(
type
);
...
...
hlsl/hlslParseHelper.h
View file @
f97f2ce6
...
...
@@ -172,6 +172,7 @@ protected:
void
declareArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
const
TType
&
,
TSymbol
*&
,
bool
track
);
TIntermNode
*
executeInitializer
(
const
TSourceLoc
&
,
TIntermTyped
*
initializer
,
TVariable
*
variable
);
TIntermTyped
*
convertInitializerList
(
const
TSourceLoc
&
,
const
TType
&
,
TIntermTyped
*
initializer
);
bool
HlslParseContext
::
isZeroConstructor
(
const
TIntermNode
*
);
TOperator
mapAtomicOp
(
const
TSourceLoc
&
loc
,
TOperator
op
,
bool
isImage
);
// Return true if this node requires L-value conversion (e.g, to an imageStore).
...
...
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