Reactor: Add UInt4 constructors taking UInt
Odd that these don't exist already.
Change-Id: I018dc4eb5144cb4c359c790aadabc35516bdd745
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31430
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 171f9b1..7df7d8a 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -2964,6 +2964,18 @@
storeValue((~(As<Int4>(cast) >> 31) & uiValue).value);
}
+ UInt4::UInt4(RValue<UInt> rhs) : XYZW(this)
+ {
+ RR_DEBUG_INFO_UPDATE_LOC();
+ Value *vector = loadValue();
+ Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
+
+ int swizzle[4] = {0, 0, 0, 0};
+ Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle);
+
+ storeValue(replicate);
+ }
+
RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs)
{
RR_DEBUG_INFO_UPDATE_LOC();
diff --git a/src/Reactor/Reactor.cpp b/src/Reactor/Reactor.cpp
index 518c646..516f752 100644
--- a/src/Reactor/Reactor.cpp
+++ b/src/Reactor/Reactor.cpp
@@ -3500,6 +3500,16 @@
storeValue(packed);
}
+ UInt4::UInt4(const UInt &rhs) : XYZW(this)
+ {
+ *this = RValue<UInt>(rhs.loadValue());
+ }
+
+ UInt4::UInt4(const Reference<UInt> &rhs) : XYZW(this)
+ {
+ *this = RValue<UInt>(rhs.loadValue());
+ }
+
RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs)
{
storeValue(rhs.value);
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index 1a8b86b..7aed561 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -1966,6 +1966,9 @@
UInt4(const Int4 &rhs);
UInt4(const Reference<Int4> &rhs);
UInt4(RValue<UInt2> lo, RValue<UInt2> hi);
+ UInt4(RValue<UInt> rhs);
+ UInt4(const UInt &rhs);
+ UInt4(const Reference<UInt> &rhs);
RValue<UInt4> operator=(RValue<UInt4> rhs);
RValue<UInt4> operator=(const UInt4 &rhs);
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 5ee2f79..93bc879 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -3007,6 +3007,16 @@
storeValue((~(As<Int4>(cast) >> 31) & uiValue).value);
}
+ UInt4::UInt4(RValue<UInt> rhs) : XYZW(this)
+ {
+ Value *vector = Nucleus::createBitCast(rhs.value, UInt4::getType());
+
+ int swizzle[4] = {0, 0, 0, 0};
+ Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
+
+ storeValue(replicate);
+ }
+
RValue<UInt4> operator<<(RValue<UInt4> lhs, unsigned char rhs)
{
if(emulateIntrinsics)
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index 67307ef..b3f81a0 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -92,7 +92,7 @@
{
if(state.textureSampling)
{
- vertexID = Int4(index);
+ vertexID = Int4(Int(index));
}
else
{