Commit 95ac1874 by Alexis Hetu Committed by Alexis Hétu

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/5501Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 9f7d5621
...@@ -3060,6 +3060,8 @@ void Context::applyTextures(sw::SamplerType samplerType) ...@@ -3060,6 +3060,8 @@ void Context::applyTextures(sw::SamplerType samplerType)
} }
GLfloat maxAnisotropy = texture->getMaxAnisotropy(); GLfloat maxAnisotropy = texture->getMaxAnisotropy();
GLint baseLevel = texture->getBaseLevel();
GLint maxLevel = texture->getMaxLevel();
GLenum swizzleR = texture->getSwizzleR(); GLenum swizzleR = texture->getSwizzleR();
GLenum swizzleG = texture->getSwizzleG(); GLenum swizzleG = texture->getSwizzleG();
GLenum swizzleB = texture->getSwizzleB(); GLenum swizzleB = texture->getSwizzleB();
...@@ -3072,6 +3074,8 @@ void Context::applyTextures(sw::SamplerType samplerType) ...@@ -3072,6 +3074,8 @@ void Context::applyTextures(sw::SamplerType samplerType)
device->setSwizzleG(samplerType, samplerIndex, es2sw::ConvertSwizzleType(swizzleG)); device->setSwizzleG(samplerType, samplerIndex, es2sw::ConvertSwizzleType(swizzleG));
device->setSwizzleB(samplerType, samplerIndex, es2sw::ConvertSwizzleType(swizzleB)); device->setSwizzleB(samplerType, samplerIndex, es2sw::ConvertSwizzleType(swizzleB));
device->setSwizzleA(samplerType, samplerIndex, es2sw::ConvertSwizzleType(swizzleA)); device->setSwizzleA(samplerType, samplerIndex, es2sw::ConvertSwizzleType(swizzleA));
device->setBaseLevel(samplerType, samplerIndex, baseLevel);
device->setMaxLevel(samplerType, samplerIndex, maxLevel);
device->setTextureFilter(samplerType, samplerIndex, es2sw::ConvertTextureFilter(minFilter, magFilter, maxAnisotropy)); device->setTextureFilter(samplerType, samplerIndex, es2sw::ConvertTextureFilter(minFilter, magFilter, maxAnisotropy));
device->setMipmapFilter(samplerType, samplerIndex, es2sw::ConvertMipMapFilter(minFilter)); device->setMipmapFilter(samplerType, samplerIndex, es2sw::ConvertMipMapFilter(minFilter));
......
...@@ -480,6 +480,24 @@ namespace sw ...@@ -480,6 +480,24 @@ namespace sw
else ASSERT(false); else ASSERT(false);
} }
void PixelProcessor::setBaseLevel(unsigned int sampler, int baseLevel)
{
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setBaseLevel(baseLevel);
}
else ASSERT(false);
}
void PixelProcessor::setMaxLevel(unsigned int sampler, int maxLevel)
{
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setMaxLevel(maxLevel);
}
else ASSERT(false);
}
void PixelProcessor::setWriteSRGB(bool sRGB) void PixelProcessor::setWriteSRGB(bool sRGB)
{ {
context->setWriteSRGB(sRGB); context->setWriteSRGB(sRGB);
......
...@@ -235,6 +235,8 @@ namespace sw ...@@ -235,6 +235,8 @@ namespace sw
virtual void setSwizzleG(unsigned int sampler, SwizzleType swizzleG); virtual void setSwizzleG(unsigned int sampler, SwizzleType swizzleG);
virtual void setSwizzleB(unsigned int sampler, SwizzleType swizzleB); virtual void setSwizzleB(unsigned int sampler, SwizzleType swizzleB);
virtual void setSwizzleA(unsigned int sampler, SwizzleType swizzleA); virtual void setSwizzleA(unsigned int sampler, SwizzleType swizzleA);
virtual void setBaseLevel(unsigned int sampler, int baseLevel);
virtual void setMaxLevel(unsigned int sampler, int maxLevel);
virtual void setWriteSRGB(bool sRGB); virtual void setWriteSRGB(bool sRGB);
virtual void setDepthBufferEnable(bool depthBufferEnable); virtual void setDepthBufferEnable(bool depthBufferEnable);
......
...@@ -2347,6 +2347,30 @@ namespace sw ...@@ -2347,6 +2347,30 @@ namespace sw
} }
} }
void Renderer::setBaseLevel(SamplerType type, int sampler, int baseLevel)
{
if(type == SAMPLER_PIXEL)
{
PixelProcessor::setBaseLevel(sampler, baseLevel);
}
else
{
VertexProcessor::setBaseLevel(sampler, baseLevel);
}
}
void Renderer::setMaxLevel(SamplerType type, int sampler, int maxLevel)
{
if(type == SAMPLER_PIXEL)
{
PixelProcessor::setMaxLevel(sampler, maxLevel);
}
else
{
VertexProcessor::setMaxLevel(sampler, maxLevel);
}
}
void Renderer::setPointSpriteEnable(bool pointSpriteEnable) void Renderer::setPointSpriteEnable(bool pointSpriteEnable)
{ {
context->setPointSpriteEnable(pointSpriteEnable); context->setPointSpriteEnable(pointSpriteEnable);
......
...@@ -345,6 +345,8 @@ namespace sw ...@@ -345,6 +345,8 @@ namespace sw
virtual void setSwizzleG(SamplerType type, int sampler, SwizzleType swizzleG); virtual void setSwizzleG(SamplerType type, int sampler, SwizzleType swizzleG);
virtual void setSwizzleB(SamplerType type, int sampler, SwizzleType swizzleB); virtual void setSwizzleB(SamplerType type, int sampler, SwizzleType swizzleB);
virtual void setSwizzleA(SamplerType type, int sampler, SwizzleType swizzleA); virtual void setSwizzleA(SamplerType type, int sampler, SwizzleType swizzleA);
virtual void setBaseLevel(SamplerType type, int sampler, int baseLevel);
virtual void setMaxLevel(SamplerType type, int sampler, int maxLevel);
virtual void setPointSpriteEnable(bool pointSpriteEnable); virtual void setPointSpriteEnable(bool pointSpriteEnable);
virtual void setPointScaleEnable(bool pointScaleEnable); virtual void setPointScaleEnable(bool pointScaleEnable);
......
...@@ -334,6 +334,16 @@ namespace sw ...@@ -334,6 +334,16 @@ namespace sw
this->swizzleA = swizzleA; this->swizzleA = swizzleA;
} }
void Sampler::setBaseLevel(int baseLevel)
{
texture.baseLevel = baseLevel;
}
void Sampler::setMaxLevel(int maxLevel)
{
texture.maxLevel = maxLevel;
}
void Sampler::setFilterQuality(FilterType maximumFilterQuality) void Sampler::setFilterQuality(FilterType maximumFilterQuality)
{ {
Sampler::maximumTextureFilterQuality = maximumFilterQuality; Sampler::maximumTextureFilterQuality = maximumFilterQuality;
......
...@@ -67,6 +67,8 @@ namespace sw ...@@ -67,6 +67,8 @@ namespace sw
word4 borderColor4[4]; word4 borderColor4[4];
float4 borderColorF[4]; float4 borderColorF[4];
float maxAnisotropy; float maxAnisotropy;
int baseLevel;
int maxLevel;
}; };
enum SamplerType enum SamplerType
...@@ -152,8 +154,6 @@ namespace sw ...@@ -152,8 +154,6 @@ namespace sw
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
...@@ -180,6 +180,8 @@ namespace sw ...@@ -180,6 +180,8 @@ namespace sw
void setSwizzleG(SwizzleType swizzleG); void setSwizzleG(SwizzleType swizzleG);
void setSwizzleB(SwizzleType swizzleB); void setSwizzleB(SwizzleType swizzleB);
void setSwizzleA(SwizzleType swizzleA); void setSwizzleA(SwizzleType swizzleA);
void setBaseLevel(int baseLevel);
void setMaxLevel(int maxLevel);
static void setFilterQuality(FilterType maximumFilterQuality); static void setFilterQuality(FilterType maximumFilterQuality);
static void setMipmapQuality(MipmapType maximumFilterQuality); static void setMipmapQuality(MipmapType maximumFilterQuality);
......
...@@ -638,6 +638,24 @@ namespace sw ...@@ -638,6 +638,24 @@ namespace sw
else ASSERT(false); else ASSERT(false);
} }
void VertexProcessor::setBaseLevel(unsigned int sampler, int baseLevel)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setBaseLevel(baseLevel);
}
else ASSERT(false);
}
void VertexProcessor::setMaxLevel(unsigned int sampler, int maxLevel)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxLevel(maxLevel);
}
else ASSERT(false);
}
void VertexProcessor::setPointSize(float pointSize) void VertexProcessor::setPointSize(float pointSize)
{ {
point.pointSize = replicate(pointSize); point.pointSize = replicate(pointSize);
......
...@@ -260,6 +260,8 @@ namespace sw ...@@ -260,6 +260,8 @@ namespace sw
virtual void setSwizzleG(unsigned int sampler, SwizzleType swizzleG); virtual void setSwizzleG(unsigned int sampler, SwizzleType swizzleG);
virtual void setSwizzleB(unsigned int sampler, SwizzleType swizzleB); virtual void setSwizzleB(unsigned int sampler, SwizzleType swizzleB);
virtual void setSwizzleA(unsigned int sampler, SwizzleType swizzleA); virtual void setSwizzleA(unsigned int sampler, SwizzleType swizzleA);
virtual void setBaseLevel(unsigned int sampler, int baseLevel);
virtual void setMaxLevel(unsigned int sampler, int maxLevel);
virtual void setPointSize(float pointSize); virtual void setPointSize(float pointSize);
virtual void setPointSizeMin(float pointSizeMin); virtual void setPointSizeMin(float pointSizeMin);
......
...@@ -1152,8 +1152,8 @@ namespace sw ...@@ -1152,8 +1152,8 @@ 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> texture = data + OFFSET(DrawData, mipmap) + src1.index * sizeof(Texture);
sampler[src1.index]->textureSize(textureMipmap, dst, lod); sampler[src1.index]->textureSize(texture, dst, lod);
} }
void PixelProgram::TEXKILL(Int cMask[4], Vector4f &src, unsigned char mask) void PixelProgram::TEXKILL(Int cMask[4], Vector4f &src, unsigned char mask)
......
...@@ -549,11 +549,12 @@ namespace sw ...@@ -549,11 +549,12 @@ namespace sw
} }
} }
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) 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.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.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); size.z = Insert(size.z, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, depth)))), i);
......
...@@ -1577,8 +1577,8 @@ namespace sw ...@@ -1577,8 +1577,8 @@ 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> texture = data + OFFSET(DrawData, mipmap[16]) + src1.index * sizeof(Texture);
sampler[src1.index]->textureSize(textureMipmap, dst, lod); 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) 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