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
1e275c84
Commit
1e275c84
authored
Dec 14, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: More robust handling of bad shader input, catching a few more things.
parent
dca93d6b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
74 deletions
+82
-74
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+1
-0
hlsl.array.implicit-size.frag.out
Test/baseResults/hlsl.array.implicit-size.frag.out
+66
-66
hlsl.array.implicit-size.frag
Test/hlsl.array.implicit-size.frag
+1
-0
revision.h
glslang/Include/revision.h
+2
-2
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+11
-5
hlslParseHelper.h
hlsl/hlslParseHelper.h
+1
-1
No files found.
SPIRV/SpvBuilder.cpp
View file @
1e275c84
...
@@ -2144,6 +2144,7 @@ void Builder::accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizz
...
@@ -2144,6 +2144,7 @@ void Builder::accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizz
std
::
vector
<
unsigned
>
oldSwizzle
=
accessChain
.
swizzle
;
std
::
vector
<
unsigned
>
oldSwizzle
=
accessChain
.
swizzle
;
accessChain
.
swizzle
.
resize
(
0
);
accessChain
.
swizzle
.
resize
(
0
);
for
(
unsigned
int
i
=
0
;
i
<
swizzle
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
<
swizzle
.
size
();
++
i
)
{
assert
(
swizzle
[
i
]
<
oldSwizzle
.
size
());
accessChain
.
swizzle
.
push_back
(
oldSwizzle
[
swizzle
[
i
]]);
accessChain
.
swizzle
.
push_back
(
oldSwizzle
[
swizzle
[
i
]]);
}
}
}
else
}
else
...
...
Test/baseResults/hlsl.array.implicit-size.frag.out
View file @
1e275c84
...
@@ -41,38 +41,38 @@ gl_FragCoord origin is upper left
...
@@ -41,38 +41,38 @@ gl_FragCoord origin is upper left
0:28 1.000000
0:28 1.000000
0:28 2.000000
0:28 2.000000
0:28 3.000000
0:28 3.000000
0:3
0
move second child to first child (temp 4-component vector of float)
0:3
1
move second child to first child (temp 4-component vector of float)
0:3
0
color: direct index for structure (temp 4-component vector of float)
0:3
1
color: direct index for structure (temp 4-component vector of float)
0:3
0
'ps_output' (out structure{temp 4-component vector of float color})
0:3
1
'ps_output' (out structure{temp 4-component vector of float color})
0:3
0
Constant:
0:3
1
Constant:
0:3
0
0 (const int)
0:3
1
0 (const int)
0:3
0
Construct vec4 (temp 4-component vector of float)
0:3
1
Construct vec4 (temp 4-component vector of float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
direct index (temp float)
0:3
1
direct index (temp float)
0:3
0
'g_array' (global 5-element array of float)
0:3
1
'g_array' (global 5-element array of float)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
0 (const int)
0:3
1
0 (const int)
0:3
0
direct index (temp float)
0:3
1
direct index (temp float)
0:3
0
'g_array' (global 5-element array of float)
0:3
1
'g_array' (global 5-element array of float)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
4 (const int)
0:3
1
4 (const int)
0:3
0
direct index (temp float)
0:3
1
direct index (temp float)
0:3
0
'l_array' (temp 3-element array of float)
0:3
1
'l_array' (temp 3-element array of float)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
1 (const int)
0:3
1
1 (const int)
0:3
0
f: direct index for structure (temp float)
0:3
1
f: direct index for structure (temp float)
0:3
0
direct index (temp structure{temp int i, temp float f})
0:3
1
direct index (temp structure{temp int i, temp float f})
0:3
0
'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
0:3
1
'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
0:3
0
Constant:
0:3
1
Constant:
0:3
0
0 (const int)
0:3
1
0 (const int)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
1 (const int)
0:3
1
1 (const int)
0:3
0
indirect index (temp float)
0:3
1
indirect index (temp float)
0:3
0
'g_array' (global 5-element array of float)
0:3
1
'g_array' (global 5-element array of float)
0:3
0 'idx' (temp void
)
0:3
1 'idx' (temp int
)
0:? Linker Objects
0:? Linker Objects
0:? 'g_array' (global 5-element array of float)
0:? 'g_array' (global 5-element array of float)
0:? 'g_array_unused' (global 7-element array of float)
0:? 'g_array_unused' (global 7-element array of float)
...
@@ -125,38 +125,38 @@ gl_FragCoord origin is upper left
...
@@ -125,38 +125,38 @@ gl_FragCoord origin is upper left
0:28 1.000000
0:28 1.000000
0:28 2.000000
0:28 2.000000
0:28 3.000000
0:28 3.000000
0:3
0
move second child to first child (temp 4-component vector of float)
0:3
1
move second child to first child (temp 4-component vector of float)
0:3
0
color: direct index for structure (temp 4-component vector of float)
0:3
1
color: direct index for structure (temp 4-component vector of float)
0:3
0
'ps_output' (out structure{temp 4-component vector of float color})
0:3
1
'ps_output' (out structure{temp 4-component vector of float color})
0:3
0
Constant:
0:3
1
Constant:
0:3
0
0 (const int)
0:3
1
0 (const int)
0:3
0
Construct vec4 (temp 4-component vector of float)
0:3
1
Construct vec4 (temp 4-component vector of float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
add (temp float)
0:3
1
add (temp float)
0:3
0
direct index (temp float)
0:3
1
direct index (temp float)
0:3
0
'g_array' (global 5-element array of float)
0:3
1
'g_array' (global 5-element array of float)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
0 (const int)
0:3
1
0 (const int)
0:3
0
direct index (temp float)
0:3
1
direct index (temp float)
0:3
0
'g_array' (global 5-element array of float)
0:3
1
'g_array' (global 5-element array of float)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
4 (const int)
0:3
1
4 (const int)
0:3
0
direct index (temp float)
0:3
1
direct index (temp float)
0:3
0
'l_array' (temp 3-element array of float)
0:3
1
'l_array' (temp 3-element array of float)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
1 (const int)
0:3
1
1 (const int)
0:3
0
f: direct index for structure (temp float)
0:3
1
f: direct index for structure (temp float)
0:3
0
direct index (temp structure{temp int i, temp float f})
0:3
1
direct index (temp structure{temp int i, temp float f})
0:3
0
'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
0:3
1
'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
0:3
0
Constant:
0:3
1
Constant:
0:3
0
0 (const int)
0:3
1
0 (const int)
0:3
0
Constant:
0:3
1
Constant:
0:3
0
1 (const int)
0:3
1
1 (const int)
0:3
0
indirect index (temp float)
0:3
1
indirect index (temp float)
0:3
0
'g_array' (global 5-element array of float)
0:3
1
'g_array' (global 5-element array of float)
0:3
0 'idx' (temp void
)
0:3
1 'idx' (temp int
)
0:? Linker Objects
0:? Linker Objects
0:? 'g_array' (global 5-element array of float)
0:? 'g_array' (global 5-element array of float)
0:? 'g_array_unused' (global 7-element array of float)
0:? 'g_array_unused' (global 7-element array of float)
...
@@ -228,7 +228,7 @@ gl_FragCoord origin is upper left
...
@@ -228,7 +228,7 @@ gl_FragCoord origin is upper left
49: TypePointer Private 6(float)
49: TypePointer Private 6(float)
52: 32(int) Constant 4
52: 32(int) Constant 4
56: TypePointer Function 6(float)
56: TypePointer Function 6(float)
63: TypePointer Function
2
63: TypePointer Function
32(int)
70: TypePointer Function 7(fvec4)
70: TypePointer Function 7(fvec4)
4(PixelShaderFunction): 2 Function None 3
4(PixelShaderFunction): 2 Function None 3
5: Label
5: Label
...
@@ -254,7 +254,7 @@ gl_FragCoord origin is upper left
...
@@ -254,7 +254,7 @@ gl_FragCoord origin is upper left
60: 49(ptr) AccessChain 37(g_mystruct) 48 38
60: 49(ptr) AccessChain 37(g_mystruct) 48 38
61: 6(float) Load 60
61: 6(float) Load 60
62: 6(float) FAdd 59 61
62: 6(float) FAdd 59 61
65:
2
Load 64(idx)
65:
32(int)
Load 64(idx)
66: 49(ptr) AccessChain 18(g_array) 65
66: 49(ptr) AccessChain 18(g_array) 65
67: 6(float) Load 66
67: 6(float) Load 66
68: 6(float) FAdd 62 67
68: 6(float) FAdd 62 67
...
...
Test/hlsl.array.implicit-size.frag
View file @
1e275c84
...
@@ -26,6 +26,7 @@ void main(out PS_OUTPUT ps_output)
...
@@ -26,6 +26,7 @@ void main(out PS_OUTPUT ps_output)
{
{
// local array sized from initializers
// local array sized from initializers
float
l_array
[]
=
{
1
,
2
,
3
};
float
l_array
[]
=
{
1
,
2
,
3
};
int
idx
;
ps_output
.
color
=
g_array
[
0
]
+
g_array
[
4
]
+
l_array
[
1
]
+
g_mystruct
[
0
].
f
+
g_array
[
idx
];
ps_output
.
color
=
g_array
[
0
]
+
g_array
[
4
]
+
l_array
[
1
]
+
g_mystruct
[
0
].
f
+
g_array
[
idx
];
}
}
glslang/Include/revision.h
View file @
1e275c84
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// 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).
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.16
89
"
#define GLSLANG_REVISION "Overload400-PrecQual.16
94
"
#define GLSLANG_DATE "1
2
-Dec-2016"
#define GLSLANG_DATE "1
4
-Dec-2016"
hlsl/hlslParseHelper.cpp
View file @
1e275c84
...
@@ -579,8 +579,10 @@ TIntermTyped* HlslParseContext::handleVariable(const TSourceLoc& loc, TSymbol* s
...
@@ -579,8 +579,10 @@ TIntermTyped* HlslParseContext::handleVariable(const TSourceLoc& loc, TSymbol* s
}
}
// Recovery, if it wasn't found or was not a variable.
// Recovery, if it wasn't found or was not a variable.
if
(
!
variable
)
if
(
!
variable
)
{
error
(
loc
,
"unknown variable"
,
string
->
c_str
(),
""
);
variable
=
new
TVariable
(
string
,
TType
(
EbtVoid
));
variable
=
new
TVariable
(
string
,
TType
(
EbtVoid
));
}
if
(
variable
->
getType
().
getQualifier
().
isFrontEndConstant
())
if
(
variable
->
getType
().
getQualifier
().
isFrontEndConstant
())
node
=
intermediate
.
addConstantUnion
(
variable
->
getConstArray
(),
variable
->
getType
(),
loc
);
node
=
intermediate
.
addConstantUnion
(
variable
->
getConstArray
(),
variable
->
getType
(),
loc
);
...
@@ -2781,7 +2783,7 @@ TIntermTyped* HlslParseContext::handleLengthMethod(const TSourceLoc& loc, TFunct
...
@@ -2781,7 +2783,7 @@ TIntermTyped* HlslParseContext::handleLengthMethod(const TSourceLoc& loc, TFunct
//
//
// Add any needed implicit conversions for function-call arguments to input parameters.
// Add any needed implicit conversions for function-call arguments to input parameters.
//
//
void
HlslParseContext
::
addInputArgumentConversions
(
const
TFunction
&
function
,
TIntermNode
*&
arguments
)
const
void
HlslParseContext
::
addInputArgumentConversions
(
const
TFunction
&
function
,
TIntermNode
*&
arguments
)
{
{
TIntermAggregate
*
aggregate
=
arguments
->
getAsAggregate
();
TIntermAggregate
*
aggregate
=
arguments
->
getAsAggregate
();
const
auto
setArg
=
[
&
](
int
argNum
,
TIntermNode
*
arg
)
{
const
auto
setArg
=
[
&
](
int
argNum
,
TIntermNode
*
arg
)
{
...
@@ -2809,9 +2811,13 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
...
@@ -2809,9 +2811,13 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
if
(
*
function
[
i
].
type
!=
arg
->
getType
())
{
if
(
*
function
[
i
].
type
!=
arg
->
getType
())
{
// In-qualified arguments just need an extra node added above the argument to
// In-qualified arguments just need an extra node added above the argument to
// convert to the correct type.
// convert to the correct type.
arg
=
intermediate
.
addConversion
(
EOpFunctionCall
,
*
function
[
i
].
type
,
arg
);
TIntermTyped
*
convArg
=
intermediate
.
addConversion
(
EOpFunctionCall
,
*
function
[
i
].
type
,
arg
);
arg
=
intermediate
.
addShapeConversion
(
EOpFunctionCall
,
*
function
[
i
].
type
,
arg
);
if
(
convArg
!=
nullptr
)
setArg
(
i
,
arg
);
convArg
=
intermediate
.
addShapeConversion
(
EOpFunctionCall
,
*
function
[
i
].
type
,
convArg
);
if
(
convArg
!=
nullptr
)
setArg
(
i
,
convArg
);
else
error
(
arg
->
getLoc
(),
"cannot convert input argument, argument"
,
""
,
"%d"
,
i
);
}
else
{
}
else
{
if
(
wasFlattened
(
arg
))
{
if
(
wasFlattened
(
arg
))
{
// Will make a two-level subtree.
// Will make a two-level subtree.
...
...
hlsl/hlslParseHelper.h
View file @
1e275c84
...
@@ -84,7 +84,7 @@ public:
...
@@ -84,7 +84,7 @@ public:
void
decomposeSampleMethods
(
const
TSourceLoc
&
,
TIntermTyped
*&
node
,
TIntermNode
*
arguments
);
void
decomposeSampleMethods
(
const
TSourceLoc
&
,
TIntermTyped
*&
node
,
TIntermNode
*
arguments
);
void
decomposeGeometryMethods
(
const
TSourceLoc
&
,
TIntermTyped
*&
node
,
TIntermNode
*
arguments
);
void
decomposeGeometryMethods
(
const
TSourceLoc
&
,
TIntermTyped
*&
node
,
TIntermNode
*
arguments
);
TIntermTyped
*
handleLengthMethod
(
const
TSourceLoc
&
,
TFunction
*
,
TIntermNode
*
);
TIntermTyped
*
handleLengthMethod
(
const
TSourceLoc
&
,
TFunction
*
,
TIntermNode
*
);
void
addInputArgumentConversions
(
const
TFunction
&
,
TIntermNode
*&
)
const
;
void
addInputArgumentConversions
(
const
TFunction
&
,
TIntermNode
*&
);
TIntermTyped
*
addOutputArgumentConversions
(
const
TFunction
&
,
TIntermOperator
&
);
TIntermTyped
*
addOutputArgumentConversions
(
const
TFunction
&
,
TIntermOperator
&
);
void
builtInOpCheck
(
const
TSourceLoc
&
,
const
TFunction
&
,
TIntermOperator
&
);
void
builtInOpCheck
(
const
TSourceLoc
&
,
const
TFunction
&
,
TIntermOperator
&
);
TFunction
*
handleConstructorCall
(
const
TSourceLoc
&
,
const
TType
&
);
TFunction
*
handleConstructorCall
(
const
TSourceLoc
&
,
const
TType
&
);
...
...
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