Simplify int4 and float4 types.
Change-Id: Id0d55c1364fc3db05821eb6ef666aed8c5713e31
Reviewed-on: https://swiftshader-review.googlesource.com/3503
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Common/Types.hpp b/src/Common/Types.hpp
index 44989d4..1337f4d 100644
--- a/src/Common/Types.hpp
+++ b/src/Common/Types.hpp
@@ -58,15 +58,12 @@
ALIGN(16, struct int4
{
- struct
- {
- int x;
- int y;
- int z;
- int w;
- };
+ int x;
+ int y;
+ int z;
+ int w;
- int &operator[](int i)
+ int &operator[](int i)
{
return (&x)[i];
}
@@ -76,12 +73,12 @@
return (&x)[i];
}
- bool operator!=(int4 &rhs)
+ bool operator!=(const int4 &rhs)
{
return x != rhs.x || y != rhs.y || z != rhs.z || w != rhs.w;
}
- bool operator==(int4 &rhs)
+ bool operator==(const int4 &rhs)
{
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
}
@@ -89,26 +86,12 @@
ALIGN(16, struct float4
{
- union
- {
- struct
- {
- float x;
- float y;
- float z;
- float w;
- };
+ float x;
+ float y;
+ float z;
+ float w;
- struct
- {
- float r;
- float g;
- float b;
- float a;
- };
- };
-
- float &operator[](int i)
+ float &operator[](int i)
{
return (&x)[i];
}
@@ -118,12 +101,12 @@
return (&x)[i];
}
- bool operator!=(float4 &rhs)
+ bool operator!=(const float4 &rhs)
{
return x != rhs.x || y != rhs.y || z != rhs.z || w != rhs.w;
}
- bool operator==(float4 &rhs)
+ bool operator==(const float4 &rhs)
{
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
}
diff --git a/src/OpenGL/libGL/Context.cpp b/src/OpenGL/libGL/Context.cpp
index 1a7bdfb..635e8ab 100644
--- a/src/OpenGL/libGL/Context.cpp
+++ b/src/OpenGL/libGL/Context.cpp
@@ -3482,10 +3482,10 @@
v.P.y = y;
v.P.z = z;
v.P.w = w;
- v.C.r = mState.vertexAttribute[sw::Color0].mCurrentValue[0];
- v.C.g = mState.vertexAttribute[sw::Color0].mCurrentValue[1];
- v.C.b = mState.vertexAttribute[sw::Color0].mCurrentValue[2];
- v.C.a = mState.vertexAttribute[sw::Color0].mCurrentValue[3];
+ v.C.x = mState.vertexAttribute[sw::Color0].mCurrentValue[0];
+ v.C.y = mState.vertexAttribute[sw::Color0].mCurrentValue[1];
+ v.C.z = mState.vertexAttribute[sw::Color0].mCurrentValue[2];
+ v.C.w = mState.vertexAttribute[sw::Color0].mCurrentValue[3];
v.N.x = mState.vertexAttribute[sw::Normal].mCurrentValue[0];
v.N.y = mState.vertexAttribute[sw::Normal].mCurrentValue[1];
v.N.z = mState.vertexAttribute[sw::Normal].mCurrentValue[2];