Commit 9f7d5621 by Alexis Hetu Committed by Alexis Hétu

Texture size fix

I looked into the texture size issue and I removed the " + Int(1)" used on the LOD and replaced it with "baseLevel", which I think makes more sense. Without the "+1", some tests using baseLevel==1 fail, but all tests pass when I use "+baseLevel". I'm not 100% sure why the "+1" wasn't making tests that were using baseLevel==0 fail. Note that, for now, the new Sampler::State "baseLevel" member will always be 0, as the code to set it hasn't landed yet and will be in another cl. Change-Id: I8532bb7009abcc15e03416489f1d25027e336457 Reviewed-on: https://swiftshader-review.googlesource.com/5471Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 1f2003a2
...@@ -145,13 +145,15 @@ namespace sw ...@@ -145,13 +145,15 @@ namespace sw
AddressingMode addressingModeV : BITS(ADDRESSING_LAST); AddressingMode addressingModeV : BITS(ADDRESSING_LAST);
AddressingMode addressingModeW : BITS(ADDRESSING_LAST); AddressingMode addressingModeW : BITS(ADDRESSING_LAST);
MipmapType mipmapFilter : BITS(FILTER_LAST); MipmapType mipmapFilter : BITS(FILTER_LAST);
bool hasNPOTTexture : 1; bool hasNPOTTexture : 1;
bool sRGB : 1; bool sRGB : 1;
SwizzleType swizzleR : BITS(SWIZZLE_LAST); SwizzleType swizzleR : BITS(SWIZZLE_LAST);
SwizzleType swizzleG : BITS(SWIZZLE_LAST); SwizzleType swizzleG : BITS(SWIZZLE_LAST);
SwizzleType swizzleB : BITS(SWIZZLE_LAST); SwizzleType swizzleB : BITS(SWIZZLE_LAST);
SwizzleType swizzleA : BITS(SWIZZLE_LAST); SwizzleType swizzleA : BITS(SWIZZLE_LAST);
int baseLevel;
#if PERF_PROFILE #if PERF_PROFILE
bool compressedFormat : 1; bool compressedFormat : 1;
#endif #endif
......
...@@ -1153,13 +1153,7 @@ namespace sw ...@@ -1153,13 +1153,7 @@ namespace sw
void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
{ {
Pointer<Byte> textureMipmap = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture) + OFFSET(Texture, mipmap); Pointer<Byte> textureMipmap = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture) + OFFSET(Texture, mipmap);
for(int i = 0; i < 4; ++i) sampler[src1.index]->textureSize(textureMipmap, dst, lod);
{
Pointer<Byte> mipmap = textureMipmap + (As<Int>(Extract(lod, i)) + Int(1)) * sizeof(Mipmap);
dst.x = Insert(dst.x, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, width)))), i);
dst.y = Insert(dst.y, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, height)))), i);
dst.z = Insert(dst.z, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, depth)))), i);
}
} }
void PixelProgram::TEXKILL(Int cMask[4], Vector4f &src, unsigned char mask) void PixelProgram::TEXKILL(Int cMask[4], Vector4f &src, unsigned char mask)
......
...@@ -549,6 +549,17 @@ namespace sw ...@@ -549,6 +549,17 @@ namespace sw
} }
} }
void SamplerCore::textureSize(Pointer<Byte> &textureMipmap, 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);
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);
}
}
void SamplerCore::border(Short4 &mask, Float4 &coordinates) void SamplerCore::border(Short4 &mask, Float4 &coordinates)
{ {
Int4 border = As<Int4>(CmpLT(Abs(coordinates - Float4(0.5f)), Float4(0.5f))); Int4 border = As<Int4>(CmpLT(Abs(coordinates - Float4(0.5f)), Float4(0.5f)));
......
...@@ -35,6 +35,7 @@ namespace sw ...@@ -35,6 +35,7 @@ namespace sw
void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, SamplerMethod method = Implicit); void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, SamplerMethod method = Implicit);
void sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method = Implicit, bool hasOffset = false); void sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, SamplerMethod method = Implicit, bool hasOffset = false);
void textureSize(Pointer<Byte> &mipmap, Vector4f &size, Float4 &lod);
private: private:
void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, bool hasOffset, SamplerMethod method, bool fixed12); void sampleTexture(Pointer<Byte> &texture, Vector4s &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, Vector4f &offset, bool hasOffset, SamplerMethod method, bool fixed12);
......
...@@ -1578,13 +1578,7 @@ namespace sw ...@@ -1578,13 +1578,7 @@ namespace sw
void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) 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); Pointer<Byte> textureMipmap = data + OFFSET(DrawData, mipmap[16]) + src1.index * sizeof(Texture) + OFFSET(Texture, mipmap);
for(int i = 0; i < 4; ++i) sampler[src1.index]->textureSize(textureMipmap, dst, lod);
{
Pointer<Byte> mipmap = textureMipmap + (As<Int>(Extract(lod, i)) + Int(1)) * sizeof(Mipmap);
dst.x = Insert(dst.x, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, width)))), i);
dst.y = Insert(dst.y, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, height)))), i);
dst.z = Insert(dst.z, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, depth)))), i);
}
} }
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) 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)
......
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