mirror of
https://github.com/KhronosGroup/glslang
synced 2024-09-19 12:19:53 +00:00
HLSL: More robust handling of bad shader input, catching a few more things.
This commit is contained in:
parent
dca93d6baa
commit
1e275c8486
@ -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
|
||||||
|
@ -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:30 move second child to first child (temp 4-component vector of float)
|
0:31 move second child to first child (temp 4-component vector of float)
|
||||||
0:30 color: direct index for structure (temp 4-component vector of float)
|
0:31 color: direct index for structure (temp 4-component vector of float)
|
||||||
0:30 'ps_output' (out structure{temp 4-component vector of float color})
|
0:31 'ps_output' (out structure{temp 4-component vector of float color})
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 0 (const int)
|
0:31 0 (const int)
|
||||||
0:30 Construct vec4 (temp 4-component vector of float)
|
0:31 Construct vec4 (temp 4-component vector of float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 direct index (temp float)
|
0:31 direct index (temp float)
|
||||||
0:30 'g_array' (global 5-element array of float)
|
0:31 'g_array' (global 5-element array of float)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 0 (const int)
|
0:31 0 (const int)
|
||||||
0:30 direct index (temp float)
|
0:31 direct index (temp float)
|
||||||
0:30 'g_array' (global 5-element array of float)
|
0:31 'g_array' (global 5-element array of float)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 4 (const int)
|
0:31 4 (const int)
|
||||||
0:30 direct index (temp float)
|
0:31 direct index (temp float)
|
||||||
0:30 'l_array' (temp 3-element array of float)
|
0:31 'l_array' (temp 3-element array of float)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 1 (const int)
|
0:31 1 (const int)
|
||||||
0:30 f: direct index for structure (temp float)
|
0:31 f: direct index for structure (temp float)
|
||||||
0:30 direct index (temp structure{temp int i, temp float f})
|
0:31 direct index (temp structure{temp int i, temp float f})
|
||||||
0:30 'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
|
0:31 'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 0 (const int)
|
0:31 0 (const int)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 1 (const int)
|
0:31 1 (const int)
|
||||||
0:30 indirect index (temp float)
|
0:31 indirect index (temp float)
|
||||||
0:30 'g_array' (global 5-element array of float)
|
0:31 'g_array' (global 5-element array of float)
|
||||||
0:30 'idx' (temp void)
|
0:31 '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
|
|||||||
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:30 move second child to first child (temp 4-component vector of float)
|
0:31 move second child to first child (temp 4-component vector of float)
|
||||||
0:30 color: direct index for structure (temp 4-component vector of float)
|
0:31 color: direct index for structure (temp 4-component vector of float)
|
||||||
0:30 'ps_output' (out structure{temp 4-component vector of float color})
|
0:31 'ps_output' (out structure{temp 4-component vector of float color})
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 0 (const int)
|
0:31 0 (const int)
|
||||||
0:30 Construct vec4 (temp 4-component vector of float)
|
0:31 Construct vec4 (temp 4-component vector of float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 add (temp float)
|
0:31 add (temp float)
|
||||||
0:30 direct index (temp float)
|
0:31 direct index (temp float)
|
||||||
0:30 'g_array' (global 5-element array of float)
|
0:31 'g_array' (global 5-element array of float)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 0 (const int)
|
0:31 0 (const int)
|
||||||
0:30 direct index (temp float)
|
0:31 direct index (temp float)
|
||||||
0:30 'g_array' (global 5-element array of float)
|
0:31 'g_array' (global 5-element array of float)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 4 (const int)
|
0:31 4 (const int)
|
||||||
0:30 direct index (temp float)
|
0:31 direct index (temp float)
|
||||||
0:30 'l_array' (temp 3-element array of float)
|
0:31 'l_array' (temp 3-element array of float)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 1 (const int)
|
0:31 1 (const int)
|
||||||
0:30 f: direct index for structure (temp float)
|
0:31 f: direct index for structure (temp float)
|
||||||
0:30 direct index (temp structure{temp int i, temp float f})
|
0:31 direct index (temp structure{temp int i, temp float f})
|
||||||
0:30 'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
|
0:31 'g_mystruct' (global 2-element array of structure{temp int i, temp float f})
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 0 (const int)
|
0:31 0 (const int)
|
||||||
0:30 Constant:
|
0:31 Constant:
|
||||||
0:30 1 (const int)
|
0:31 1 (const int)
|
||||||
0:30 indirect index (temp float)
|
0:31 indirect index (temp float)
|
||||||
0:30 'g_array' (global 5-element array of float)
|
0:31 'g_array' (global 5-element array of float)
|
||||||
0:30 'idx' (temp void)
|
0:31 '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
|
|||||||
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
|
|||||||
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
|
||||||
|
@ -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];
|
||||||
}
|
}
|
||||||
|
@ -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.1689"
|
#define GLSLANG_REVISION "Overload400-PrecQual.1694"
|
||||||
#define GLSLANG_DATE "12-Dec-2016"
|
#define GLSLANG_DATE "14-Dec-2016"
|
||||||
|
@ -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
|
|||||||
//
|
//
|
||||||
// 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
|
|||||||
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.
|
||||||
|
@ -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&);
|
||||||
|
Loading…
Reference in New Issue
Block a user