OSDN Git Service

Fix for 3D texture sampling
authorAlexis Hetu <sugoi@google.com>
Tue, 3 Oct 2017 17:56:07 +0000 (13:56 -0400)
committerAlexis Hétu <sugoi@google.com>
Tue, 3 Oct 2017 20:04:31 +0000 (20:04 +0000)
3D texture sampling did not support width*height > MAX_USHORT(65535).
Changed for 32 bit integer computation for that multiplication to
solve this issue.

Verified with 3D texture related dEQP tests.

Bug b/26105892 chromium:763382

Change-Id: Ifd07278f6263d000620a0b525c07ed4fcbdcf2e7
Reviewed-on: https://swiftshader-review.googlesource.com/12988
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
src/Shader/SamplerCore.cpp

index 290f402..cf02699 100644 (file)
@@ -1695,19 +1695,20 @@ namespace sw
                                        wwww = applyOffset(wwww, offset.z, Int4(*Pointer<UShort4>(mipmap + OFFSET(Mipmap, depth))), texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeW);
                                }
                        }
-                       Short4 www2 = wwww;
-                       wwww = As<Short4>(UnpackLow(wwww, Short4(0x0000)));
-                       www2 = As<Short4>(UnpackHigh(www2, Short4(0x0000)));
-                       wwww = As<Short4>(MulAdd(wwww, *Pointer<Short4>(mipmap + OFFSET(Mipmap,sliceP))));
-                       www2 = As<Short4>(MulAdd(www2, *Pointer<Short4>(mipmap + OFFSET(Mipmap,sliceP))));
-                       uuuu = As<Short4>(As<Int2>(uuuu) + As<Int2>(wwww));
-                       uuu2 = As<Short4>(As<Int2>(uuu2) + As<Int2>(www2));
-               }
-
-               index[0] = Extract(As<Int2>(uuuu), 0);
-               index[1] = Extract(As<Int2>(uuuu), 1);
-               index[2] = Extract(As<Int2>(uuu2), 0);
-               index[3] = Extract(As<Int2>(uuu2), 1);
+                       UInt4 uv(As<UInt2>(uuuu), As<UInt2>(uuu2));
+                       uv += As<UInt4>(Int4(As<UShort4>(wwww))) * *Pointer<UInt4>(mipmap + OFFSET(Mipmap, sliceP));
+                       index[0] = Extract(As<Int4>(uv), 0);
+                       index[1] = Extract(As<Int4>(uv), 1);
+                       index[2] = Extract(As<Int4>(uv), 2);
+                       index[3] = Extract(As<Int4>(uv), 3);
+               }
+               else
+               {
+                       index[0] = Extract(As<Int2>(uuuu), 0);
+                       index[1] = Extract(As<Int2>(uuuu), 1);
+                       index[2] = Extract(As<Int2>(uuu2), 0);
+                       index[3] = Extract(As<Int2>(uuu2), 1);
+               }
 
                if(texelFetch)
                {