Work around Visual Studio bug causing access violation.
The Reactor Value resulting from loading the value from the
dereferenced Pointer does not get passed to the Int4 cast constructor
correctly. This happens in 32-bit builds on Visual Studio
2017 (15.3.5), but not in 64-bit builds.
Change-Id: I68e1639ada436c65bb4f3bf9b3ac88d503f10e30
Reviewed-on: https://swiftshader-review.googlesource.com/13554
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp
index 79e97fd..194e35a 100644
--- a/src/Shader/SamplerCore.cpp
+++ b/src/Shader/SamplerCore.cpp
@@ -1715,8 +1715,10 @@
if(hasOffset)
{
- uuuu = applyOffset(uuuu, offset.x, Int4(*Pointer<UShort4>(mipmap + OFFSET(Mipmap, width))), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeU);
- vvvv = applyOffset(vvvv, offset.y, Int4(*Pointer<UShort4>(mipmap + OFFSET(Mipmap, height))), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeV);
+ UShort4 w = *Pointer<UShort4>(mipmap + OFFSET(Mipmap, width));
+ uuuu = applyOffset(uuuu, offset.x, Int4(w), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeU);
+ UShort4 h = *Pointer<UShort4>(mipmap + OFFSET(Mipmap, height));
+ vvvv = applyOffset(vvvv, offset.y, Int4(h), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeV);
}
Short4 uuu2 = uuuu;
@@ -1736,7 +1738,8 @@
if(hasOffset)
{
- wwww = applyOffset(wwww, offset.z, Int4(*Pointer<UShort4>(mipmap + OFFSET(Mipmap, depth))), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeW);
+ UShort4 d = *Pointer<UShort4>(mipmap + OFFSET(Mipmap, depth));
+ wwww = applyOffset(wwww, offset.z, Int4(d), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeW);
}
}