Fix HLSL translation for mod(vec2,vec2)

ANGLEBUG=258 Signed-off-by: Daniel Koch Signed-off-by: Nicolas Capens Author: Sam Hocevar git-svn-id: https://angleproject.googlecode.com/svn/trunk@890 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 56d46abe
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 889 #define BUILD_REVISION 890
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -45,9 +45,12 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr ...@@ -45,9 +45,12 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr
mUsesPointSize = false; mUsesPointSize = false;
mUsesXor = false; mUsesXor = false;
mUsesMod1 = false; mUsesMod1 = false;
mUsesMod2 = false; mUsesMod2v = false;
mUsesMod3 = false; mUsesMod2f = false;
mUsesMod4 = false; mUsesMod3v = false;
mUsesMod3f = false;
mUsesMod4v = false;
mUsesMod4f = false;
mUsesFaceforward1 = false; mUsesFaceforward1 = false;
mUsesFaceforward2 = false; mUsesFaceforward2 = false;
mUsesFaceforward3 = false; mUsesFaceforward3 = false;
...@@ -480,7 +483,16 @@ void OutputHLSL::header() ...@@ -480,7 +483,16 @@ void OutputHLSL::header()
"\n"; "\n";
} }
if (mUsesMod2) if (mUsesMod2v)
{
out << "float2 mod(float2 x, float2 y)\n"
"{\n"
" return x - y * floor(x / y);\n"
"}\n"
"\n";
}
if (mUsesMod2f)
{ {
out << "float2 mod(float2 x, float y)\n" out << "float2 mod(float2 x, float y)\n"
"{\n" "{\n"
...@@ -489,7 +501,16 @@ void OutputHLSL::header() ...@@ -489,7 +501,16 @@ void OutputHLSL::header()
"\n"; "\n";
} }
if (mUsesMod3) if (mUsesMod3v)
{
out << "float3 mod(float3 x, float3 y)\n"
"{\n"
" return x - y * floor(x / y);\n"
"}\n"
"\n";
}
if (mUsesMod3f)
{ {
out << "float3 mod(float3 x, float y)\n" out << "float3 mod(float3 x, float y)\n"
"{\n" "{\n"
...@@ -498,7 +519,16 @@ void OutputHLSL::header() ...@@ -498,7 +519,16 @@ void OutputHLSL::header()
"\n"; "\n";
} }
if (mUsesMod4) if (mUsesMod4v)
{
out << "float4 mod(float4 x, float4 y)\n"
"{\n"
" return x - y * floor(x / y);\n"
"}\n"
"\n";
}
if (mUsesMod4f)
{ {
out << "float4 mod(float4 x, float y)\n" out << "float4 mod(float4 x, float y)\n"
"{\n" "{\n"
...@@ -1447,12 +1477,17 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1447,12 +1477,17 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpVectorNotEqual: outputTriplet(visit, "(", " != ", ")"); break; case EOpVectorNotEqual: outputTriplet(visit, "(", " != ", ")"); break;
case EOpMod: case EOpMod:
{ {
switch (node->getSequence()[0]->getAsTyped()->getNominalSize()) // Number of components in the first argument // We need to look at the number of components in both arguments
{ switch (node->getSequence()[0]->getAsTyped()->getNominalSize() * 10
case 1: mUsesMod1 = true; break; + node->getSequence()[1]->getAsTyped()->getNominalSize())
case 2: mUsesMod2 = true; break; {
case 3: mUsesMod3 = true; break; case 11: mUsesMod1 = true; break;
case 4: mUsesMod4 = true; break; case 22: mUsesMod2v = true; break;
case 21: mUsesMod2f = true; break;
case 33: mUsesMod3v = true; break;
case 31: mUsesMod3f = true; break;
case 44: mUsesMod4v = true; break;
case 41: mUsesMod4f = true; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
......
...@@ -91,9 +91,12 @@ class OutputHLSL : public TIntermTraverser ...@@ -91,9 +91,12 @@ class OutputHLSL : public TIntermTraverser
bool mUsesPointSize; bool mUsesPointSize;
bool mUsesXor; bool mUsesXor;
bool mUsesMod1; bool mUsesMod1;
bool mUsesMod2; bool mUsesMod2v;
bool mUsesMod3; bool mUsesMod2f;
bool mUsesMod4; bool mUsesMod3v;
bool mUsesMod3f;
bool mUsesMod4v;
bool mUsesMod4f;
bool mUsesFaceforward1; bool mUsesFaceforward1;
bool mUsesFaceforward2; bool mUsesFaceforward2;
bool mUsesFaceforward3; bool mUsesFaceforward3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment