HLSL: Fix unary and binary operator type conversion issues
This fixes defects as follows: 1. handleLvalue could be called on a non-L-value, and it shouldn't be. 2. HLSL allows unary negation on non-bool values. TUnaryOperator::promote can now promote other types (e.g, int, float) to bool for this op. 3. HLSL allows binary logical operations (&&, ||) on arbitrary types, similar (2). 4. HLSL allows mod operation on arbitrary types, which will be promoted. E.g, int % float -> float % float.
This commit is contained in:
@@ -1935,7 +1935,10 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node)
|
||||
return true;
|
||||
|
||||
node = intermediate.addUnaryMath(unaryOp, node, loc);
|
||||
node = parseContext.handleLvalue(loc, "unary operator", node);
|
||||
|
||||
// These unary ops require lvalues
|
||||
if (unaryOp == EOpPreIncrement || unaryOp == EOpPreDecrement)
|
||||
node = parseContext.handleLvalue(loc, "unary operator", node);
|
||||
|
||||
return node != nullptr;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,6 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
|
||||
char order = *argOrder;
|
||||
|
||||
if (UseHlslTypes) {
|
||||
// TODO: handle sub-vec4 returns
|
||||
switch (type) {
|
||||
case '-': s += "void"; break;
|
||||
case 'F': s += "float"; break;
|
||||
@@ -832,8 +831,6 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
||||
{ "GatherCmpAlpha", /* O-4 */ "V4", nullptr, "%@,S,V,S,V,,,", "FIU,s,F,,I,,,", EShLangAll },
|
||||
{ "GatherCmpAlpha", /* O-4, status */"V4", nullptr, "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll },
|
||||
|
||||
// TODO: Cmp forms
|
||||
|
||||
// Mark end of list, since we want to avoid a range-based for, as some compilers don't handle it yet.
|
||||
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user