Skip to content

Commit 167e982

Browse files
committed
Fix pow domain on some drivers
1 parent 4a4e420 commit 167e982

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

vendor/hlslparser/src/GLSLGenerator.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,25 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType*
986986
m_writer.Write("))/log(10.0))");
987987
handled = true;
988988
}
989+
else if (String_Equal(functionName, "pow"))
990+
{
991+
HLSLExpression* argument[2];
992+
if (GetFunctionArguments(functionCall, argument, 2) != 2)
993+
{
994+
Error("%s expects 2 arguments", functionName);
995+
return;
996+
}
997+
/* See rsqrt above regarding abs(). Note that this behaves
998+
* as expected on some drivers but not others, so we add
999+
* the abs() call for compatibility across drivers.
1000+
*/
1001+
m_writer.Write("pow(abs(");
1002+
OutputExpression(argument[0]);
1003+
m_writer.Write("),");
1004+
OutputExpression(argument[1]);
1005+
m_writer.Write(")");
1006+
handled = true;
1007+
}
9891008

9901009
if (!handled)
9911010
{

0 commit comments

Comments
 (0)