LOD Base level and Max level to sampler state Plumbing to send the LOD base level and max level from the Sampler object in the Context to the Renderer's texture's state. Change-Id: I5a9571f58a0cbaea8cedfb98da159672673eed94 Reviewed-on: https://swiftshader-review.googlesource.com/5501 Tested-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/PixelProgram.cpp b/src/Shader/PixelProgram.cpp index 662b834..af9fca0 100644 --- a/src/Shader/PixelProgram.cpp +++ b/src/Shader/PixelProgram.cpp
@@ -1152,8 +1152,8 @@ void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) { - Pointer<Byte> textureMipmap = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture) + OFFSET(Texture, mipmap); - sampler[src1.index]->textureSize(textureMipmap, dst, lod); + Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture); + sampler[src1.index]->textureSize(texture, dst, lod); } void PixelProgram::TEXKILL(Int cMask[4], Vector4f &src, unsigned char mask)
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp index 264f35d..9e2179b 100644 --- a/src/Shader/SamplerCore.cpp +++ b/src/Shader/SamplerCore.cpp
@@ -549,11 +549,12 @@ } } - void SamplerCore::textureSize(Pointer<Byte> &textureMipmap, Vector4f &size, Float4 &lod) + void SamplerCore::textureSize(Pointer<Byte> &texture, Vector4f &size, Float4 &lod) { for(int i = 0; i < 4; ++i) { - Pointer<Byte> mipmap = textureMipmap + (As<Int>(Extract(lod, i)) + Int(state.baseLevel)) * sizeof(Mipmap); + Int baseLevel = *Pointer<Int>(texture + OFFSET(Texture, baseLevel)); + Pointer<Byte> mipmap = texture + OFFSET(Texture, mipmap) + (As<Int>(Extract(lod, i)) + baseLevel) * sizeof(Mipmap); size.x = Insert(size.x, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, width)))), i); size.y = Insert(size.y, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, height)))), i); size.z = Insert(size.z, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, depth)))), i);
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp index 7868074..b986122 100644 --- a/src/Shader/VertexProgram.cpp +++ b/src/Shader/VertexProgram.cpp
@@ -1577,8 +1577,8 @@ void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) { - Pointer<Byte> textureMipmap = data + OFFSET(DrawData, mipmap[16]) + src1.index * sizeof(Texture) + OFFSET(Texture, mipmap); - sampler[src1.index]->textureSize(textureMipmap, dst, lod); + Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[16]) + src1.index * sizeof(Texture); + sampler[src1.index]->textureSize(texture, dst, lod); } void VertexProgram::sampleTexture(Vector4f &c, const Src &s, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method, bool hasOffset)