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
aa6d5629
Commit
aa6d5629
authored
Dec 30, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Handle const with no initializer. Fixes issue #651.
parent
53864846
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
3 deletions
+50
-3
hlsl.partialInit.frag.out
Test/baseResults/hlsl.partialInit.frag.out
+24
-1
hlsl.partialInit.frag
Test/hlsl.partialInit.frag
+3
-0
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+2
-2
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+20
-0
hlslParseHelper.h
hlsl/hlslParseHelper.h
+1
-0
No files found.
Test/baseResults/hlsl.partialInit.frag.out
View file @
aa6d5629
hlsl.partialInit.frag
hlsl.partialInit.frag
WARNING: 0:35: 'cgf2a' : variable with qualifier 'const' not initialized; zero initializing
WARNING: 0:36: 'ci' : variable with qualifier 'const' not initialized; zero initializing
Shader version: 450
Shader version: 450
gl_FragCoord origin is upper left
gl_FragCoord origin is upper left
0:? Sequence
0:? Sequence
...
@@ -175,6 +178,15 @@ gl_FragCoord origin is upper left
...
@@ -175,6 +178,15 @@ gl_FragCoord origin is upper left
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
0:? 'gfa' (global 3-element array of float)
0:? 'cgf2a' (const 3-element array of 2-component vector of float)
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 'ci' (const int)
0:? 0 (const int)
Linked fragment stage:
Linked fragment stage:
...
@@ -356,10 +368,19 @@ gl_FragCoord origin is upper left
...
@@ -356,10 +368,19 @@ gl_FragCoord origin is upper left
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
0:? 'gfa' (global 3-element array of float)
0:? 'cgf2a' (const 3-element array of 2-component vector of float)
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 'ci' (const int)
0:? 0 (const int)
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by 9
0
// Id's are bound by 9
2
Capability Shader
Capability Shader
1: ExtInstImport "GLSL.std.450"
1: ExtInstImport "GLSL.std.450"
...
@@ -451,6 +472,8 @@ gl_FragCoord origin is upper left
...
@@ -451,6 +472,8 @@ gl_FragCoord origin is upper left
84(v): 83(ptr) Variable Output
84(v): 83(ptr) Variable Output
88: TypePointer Input 7(fvec4)
88: TypePointer Input 7(fvec4)
89(input): 88(ptr) Variable Input
89(input): 88(ptr) Variable Input
90: TypeArray 53(fvec2) 14
91: 90 ConstantComposite 58 58 58
4(PixelShaderFunction): 2 Function None 3
4(PixelShaderFunction): 2 Function None 3
5: Label
5: Label
23(o2): 22(ptr) Variable Function
23(o2): 22(ptr) Variable Function
...
...
Test/hlsl.partialInit.frag
View file @
aa6d5629
...
@@ -31,3 +31,6 @@ outs PixelShaderFunction(float4 input) : COLOR0
...
@@ -31,3 +31,6 @@ outs PixelShaderFunction(float4 input) : COLOR0
return
o4
;
return
o4
;
}
}
static
const
float2
cgf2a
[
3
];
static
const
int
ci
;
glslang/MachineIndependent/ParseHelper.cpp
View file @
aa6d5629
...
@@ -3255,7 +3255,7 @@ bool TParseContext::lineDirectiveShouldSetNextLine() const
...
@@ -3255,7 +3255,7 @@ bool TParseContext::lineDirectiveShouldSetNextLine() const
void
TParseContext
::
nonInitConstCheck
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
TType
&
type
)
void
TParseContext
::
nonInitConstCheck
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
TType
&
type
)
{
{
//
//
// Make the qualifier make sense, given that there is an initializer.
// Make the qualifier make sense, given that there is
not
an initializer.
//
//
if
(
type
.
getQualifier
().
storage
==
EvqConst
||
if
(
type
.
getQualifier
().
storage
==
EvqConst
||
type
.
getQualifier
().
storage
==
EvqConstReadOnly
)
{
type
.
getQualifier
().
storage
==
EvqConstReadOnly
)
{
...
@@ -5007,7 +5007,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
...
@@ -5007,7 +5007,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
if
(
voidErrorCheck
(
loc
,
identifier
,
type
.
getBasicType
()))
if
(
voidErrorCheck
(
loc
,
identifier
,
type
.
getBasicType
()))
return
nullptr
;
return
nullptr
;
if
(
initializer
)
if
(
initializer
)
rValueErrorCheck
(
loc
,
"initializer"
,
initializer
);
rValueErrorCheck
(
loc
,
"initializer"
,
initializer
);
else
else
nonInitConstCheck
(
loc
,
identifier
,
type
);
nonInitConstCheck
(
loc
,
identifier
,
type
);
...
...
hlsl/hlslParseHelper.cpp
View file @
aa6d5629
...
@@ -3893,6 +3893,23 @@ void HlslParseContext::updateImplicitArraySize(const TSourceLoc& loc, TIntermNod
...
@@ -3893,6 +3893,23 @@ void HlslParseContext::updateImplicitArraySize(const TSourceLoc& loc, TIntermNod
}
}
//
//
// Enforce non-initializer type/qualifier rules.
//
void
HlslParseContext
::
fixConstInit
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
TType
&
type
,
TIntermTyped
*&
initializer
)
{
//
// Make the qualifier make sense, given that there is an initializer.
//
if
(
initializer
==
nullptr
)
{
if
(
type
.
getQualifier
().
storage
==
EvqConst
||
type
.
getQualifier
().
storage
==
EvqConstReadOnly
)
{
initializer
=
intermediate
.
makeAggregate
(
loc
);
warn
(
loc
,
"variable with qualifier 'const' not initialized; zero initializing"
,
identifier
.
c_str
(),
""
);
}
}
}
//
// See if the identifier is a built-in symbol that can be redeclared, and if so,
// See if the identifier is a built-in symbol that can be redeclared, and if so,
// copy the symbol table's read-only built-in variable to the current
// copy the symbol table's read-only built-in variable to the current
// global level, where it can be modified based on the passed in type.
// global level, where it can be modified based on the passed in type.
...
@@ -4736,6 +4753,9 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
...
@@ -4736,6 +4753,9 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
if
(
voidErrorCheck
(
loc
,
identifier
,
type
.
getBasicType
()))
if
(
voidErrorCheck
(
loc
,
identifier
,
type
.
getBasicType
()))
return
nullptr
;
return
nullptr
;
// make const and initialization consistent
fixConstInit
(
loc
,
identifier
,
type
,
initializer
);
// Check for redeclaration of built-ins and/or attempting to declare a reserved name
// Check for redeclaration of built-ins and/or attempting to declare a reserved name
TSymbol
*
symbol
=
nullptr
;
TSymbol
*
symbol
=
nullptr
;
...
...
hlsl/hlslParseHelper.h
View file @
aa6d5629
...
@@ -183,6 +183,7 @@ protected:
...
@@ -183,6 +183,7 @@ protected:
int
nextBinding
;
// next binding to use.
int
nextBinding
;
// next binding to use.
};
};
void
fixConstInit
(
const
TSourceLoc
&
,
TString
&
identifier
,
TType
&
type
,
TIntermTyped
*&
initializer
);
void
inheritGlobalDefaults
(
TQualifier
&
dst
)
const
;
void
inheritGlobalDefaults
(
TQualifier
&
dst
)
const
;
TVariable
*
makeInternalVariable
(
const
char
*
name
,
const
TType
&
)
const
;
TVariable
*
makeInternalVariable
(
const
char
*
name
,
const
TType
&
)
const
;
TVariable
*
declareNonArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
TType
&
,
bool
track
);
TVariable
*
declareNonArray
(
const
TSourceLoc
&
,
TString
&
identifier
,
TType
&
,
bool
track
);
...
...
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