OSDN Git Service

Fix textureSize for non-uniform samplers.
authorNicolas Capens <capn@google.com>
Tue, 27 Nov 2018 22:07:49 +0000 (17:07 -0500)
committerNicolas Capens <nicolascapens@google.com>
Wed, 28 Nov 2018 17:32:41 +0000 (17:32 +0000)
GLSL textureSize() calls that use a sampler that is not a uniform,
should not use the index of the register as the texture unit index.
Instead the index is the value stored in the register itself.

Bug chromium:904265

Change-Id: Iee1058e789daae15248ae5ffa940a0155dca61b5
Reviewed-on: https://swiftshader-review.googlesource.com/c/22910
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
src/Pipeline/PixelProgram.cpp
src/Pipeline/VertexProgram.cpp
src/Shader/PixelProgram.cpp
src/Shader/VertexProgram.cpp

index df99196..5b5df45 100644 (file)
@@ -1254,7 +1254,10 @@ namespace sw
 
        void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
        {
-               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture);
+               bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
+               Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x));
+               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + index * sizeof(Texture);
+
                dst = SamplerCore::textureSize(texture, lod);
        }
 
index 816af77..3ad2156 100644 (file)
@@ -1524,7 +1524,10 @@ namespace sw
 
        void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
        {
-               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + src1.index * sizeof(Texture);
+               bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
+               Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x));
+               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + index * sizeof(Texture);
+
                dst = SamplerCore::textureSize(texture, lod);
        }
 
index 7dff00b..06ece40 100644 (file)
@@ -1279,7 +1279,10 @@ namespace sw
 
        void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
        {
-               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture);
+               bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
+               Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x));
+               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + index * sizeof(Texture);
+
                dst = SamplerCore::textureSize(texture, lod);
        }
 
index 55cc8c8..a74a37f 100644 (file)
@@ -1608,7 +1608,10 @@ namespace sw
 
        void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
        {
-               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + src1.index * sizeof(Texture);
+               bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
+               Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x));
+               Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + index * sizeof(Texture);
+
                dst = SamplerCore::textureSize(texture, lod);
        }