Implement seamless cubemap sampling.
The addressing is offset by 1 to account for the border. Note that this
could be avoided by locking at (0, 0) instead of (-1, -1) instead, but
then negative address offsets have to be allowed and this complicates
the subsequent calculations and only unsigned extension from 32-bit to
64-bit is typically for free during memory accesses.
Change-Id: I5fb843401d440a9d77d141782124a9c260765830
Reviewed-on: https://swiftshader-review.googlesource.com/13289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Renderer/Sampler.cpp b/src/Renderer/Sampler.cpp
index 71a6eaf..5862996 100644
--- a/src/Renderer/Sampler.cpp
+++ b/src/Renderer/Sampler.cpp
@@ -61,6 +61,7 @@
sRGB = false;
gather = false;
highPrecisionFiltering = false;
+ border = 0;
swizzleR = SWIZZLE_RED;
swizzleG = SWIZZLE_GREEN;
@@ -117,7 +118,8 @@
{
Mipmap &mipmap = texture.mipmap[level];
- mipmap.buffer[face] = surface->lockInternal(0, 0, 0, LOCK_UNLOCKED, PRIVATE);
+ border = surface->getBorder();
+ mipmap.buffer[face] = surface->lockInternal(-border, -border, 0, LOCK_UNLOCKED, PRIVATE);
if(face == 0)
{
@@ -456,7 +458,7 @@
{
if(textureType == TEXTURE_CUBE)
{
- return ADDRESSING_CLAMP;
+ return border ? ADDRESSING_SEAMLESS : ADDRESSING_CLAMP;
}
return addressingModeU;
@@ -466,7 +468,7 @@
{
if(textureType == TEXTURE_CUBE)
{
- return ADDRESSING_CLAMP;
+ return border ? ADDRESSING_SEAMLESS : ADDRESSING_CLAMP;
}
return addressingModeV;