Commit 79d0e565 by Nicolas Capens Committed by Nicolas Capens

Fix textureSize for non-uniform samplers.

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/22910Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 3b003a51
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment