Commit 72b68950 by Courtney Goeltzenleuchter Committed by Commit Bot

Ignore redundant Texture state changes

Dirtying the state unnecessarily was causing Vulkan backend to create new framebuffer objects when it didn't need to. Bug: b/174700581 Change-Id: I74e0ed51a2c6598ab3dca9a955c247ec97b6856f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2570201 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 173f1c94
...@@ -813,8 +813,10 @@ GLenum Texture::getSwizzleAlpha() const ...@@ -813,8 +813,10 @@ GLenum Texture::getSwizzleAlpha() const
void Texture::setMinFilter(const Context *context, GLenum minFilter) void Texture::setMinFilter(const Context *context, GLenum minFilter)
{ {
mState.mSamplerState.setMinFilter(minFilter); if (mState.mSamplerState.setMinFilter(minFilter))
signalDirtyState(DIRTY_BIT_MIN_FILTER); {
signalDirtyState(DIRTY_BIT_MIN_FILTER);
}
} }
GLenum Texture::getMinFilter() const GLenum Texture::getMinFilter() const
...@@ -824,8 +826,10 @@ GLenum Texture::getMinFilter() const ...@@ -824,8 +826,10 @@ GLenum Texture::getMinFilter() const
void Texture::setMagFilter(const Context *context, GLenum magFilter) void Texture::setMagFilter(const Context *context, GLenum magFilter)
{ {
mState.mSamplerState.setMagFilter(magFilter); if (mState.mSamplerState.setMagFilter(magFilter))
signalDirtyState(DIRTY_BIT_MAG_FILTER); {
signalDirtyState(DIRTY_BIT_MAG_FILTER);
}
} }
GLenum Texture::getMagFilter() const GLenum Texture::getMagFilter() const
...@@ -835,8 +839,10 @@ GLenum Texture::getMagFilter() const ...@@ -835,8 +839,10 @@ GLenum Texture::getMagFilter() const
void Texture::setWrapS(const Context *context, GLenum wrapS) void Texture::setWrapS(const Context *context, GLenum wrapS)
{ {
mState.mSamplerState.setWrapS(wrapS); if (mState.mSamplerState.setWrapS(wrapS))
signalDirtyState(DIRTY_BIT_WRAP_S); {
signalDirtyState(DIRTY_BIT_WRAP_S);
}
} }
GLenum Texture::getWrapS() const GLenum Texture::getWrapS() const
...@@ -846,8 +852,12 @@ GLenum Texture::getWrapS() const ...@@ -846,8 +852,12 @@ GLenum Texture::getWrapS() const
void Texture::setWrapT(const Context *context, GLenum wrapT) void Texture::setWrapT(const Context *context, GLenum wrapT)
{ {
mState.mSamplerState.setWrapT(wrapT); if (mState.mSamplerState.getWrapT() == wrapT)
signalDirtyState(DIRTY_BIT_WRAP_T); return;
if (mState.mSamplerState.setWrapT(wrapT))
{
signalDirtyState(DIRTY_BIT_WRAP_T);
}
} }
GLenum Texture::getWrapT() const GLenum Texture::getWrapT() const
...@@ -857,8 +867,10 @@ GLenum Texture::getWrapT() const ...@@ -857,8 +867,10 @@ GLenum Texture::getWrapT() const
void Texture::setWrapR(const Context *context, GLenum wrapR) void Texture::setWrapR(const Context *context, GLenum wrapR)
{ {
mState.mSamplerState.setWrapR(wrapR); if (mState.mSamplerState.setWrapR(wrapR))
signalDirtyState(DIRTY_BIT_WRAP_R); {
signalDirtyState(DIRTY_BIT_WRAP_R);
}
} }
GLenum Texture::getWrapR() const GLenum Texture::getWrapR() const
...@@ -868,8 +880,10 @@ GLenum Texture::getWrapR() const ...@@ -868,8 +880,10 @@ GLenum Texture::getWrapR() const
void Texture::setMaxAnisotropy(const Context *context, float maxAnisotropy) void Texture::setMaxAnisotropy(const Context *context, float maxAnisotropy)
{ {
mState.mSamplerState.setMaxAnisotropy(maxAnisotropy); if (mState.mSamplerState.setMaxAnisotropy(maxAnisotropy))
signalDirtyState(DIRTY_BIT_MAX_ANISOTROPY); {
signalDirtyState(DIRTY_BIT_MAX_ANISOTROPY);
}
} }
float Texture::getMaxAnisotropy() const float Texture::getMaxAnisotropy() const
...@@ -879,8 +893,10 @@ float Texture::getMaxAnisotropy() const ...@@ -879,8 +893,10 @@ float Texture::getMaxAnisotropy() const
void Texture::setMinLod(const Context *context, GLfloat minLod) void Texture::setMinLod(const Context *context, GLfloat minLod)
{ {
mState.mSamplerState.setMinLod(minLod); if (mState.mSamplerState.setMinLod(minLod))
signalDirtyState(DIRTY_BIT_MIN_LOD); {
signalDirtyState(DIRTY_BIT_MIN_LOD);
}
} }
GLfloat Texture::getMinLod() const GLfloat Texture::getMinLod() const
...@@ -890,8 +906,10 @@ GLfloat Texture::getMinLod() const ...@@ -890,8 +906,10 @@ GLfloat Texture::getMinLod() const
void Texture::setMaxLod(const Context *context, GLfloat maxLod) void Texture::setMaxLod(const Context *context, GLfloat maxLod)
{ {
mState.mSamplerState.setMaxLod(maxLod); if (mState.mSamplerState.setMaxLod(maxLod))
signalDirtyState(DIRTY_BIT_MAX_LOD); {
signalDirtyState(DIRTY_BIT_MAX_LOD);
}
} }
GLfloat Texture::getMaxLod() const GLfloat Texture::getMaxLod() const
...@@ -901,8 +919,10 @@ GLfloat Texture::getMaxLod() const ...@@ -901,8 +919,10 @@ GLfloat Texture::getMaxLod() const
void Texture::setCompareMode(const Context *context, GLenum compareMode) void Texture::setCompareMode(const Context *context, GLenum compareMode)
{ {
mState.mSamplerState.setCompareMode(compareMode); if (mState.mSamplerState.setCompareMode(compareMode))
signalDirtyState(DIRTY_BIT_COMPARE_MODE); {
signalDirtyState(DIRTY_BIT_COMPARE_MODE);
}
} }
GLenum Texture::getCompareMode() const GLenum Texture::getCompareMode() const
...@@ -912,8 +932,10 @@ GLenum Texture::getCompareMode() const ...@@ -912,8 +932,10 @@ GLenum Texture::getCompareMode() const
void Texture::setCompareFunc(const Context *context, GLenum compareFunc) void Texture::setCompareFunc(const Context *context, GLenum compareFunc)
{ {
mState.mSamplerState.setCompareFunc(compareFunc); if (mState.mSamplerState.setCompareFunc(compareFunc))
signalDirtyState(DIRTY_BIT_COMPARE_FUNC); {
signalDirtyState(DIRTY_BIT_COMPARE_FUNC);
}
} }
GLenum Texture::getCompareFunc() const GLenum Texture::getCompareFunc() const
...@@ -923,8 +945,10 @@ GLenum Texture::getCompareFunc() const ...@@ -923,8 +945,10 @@ GLenum Texture::getCompareFunc() const
void Texture::setSRGBDecode(const Context *context, GLenum sRGBDecode) void Texture::setSRGBDecode(const Context *context, GLenum sRGBDecode)
{ {
mState.mSamplerState.setSRGBDecode(sRGBDecode); if (mState.mSamplerState.setSRGBDecode(sRGBDecode))
signalDirtyState(DIRTY_BIT_SRGB_DECODE); {
signalDirtyState(DIRTY_BIT_SRGB_DECODE);
}
} }
GLenum Texture::getSRGBDecode() const GLenum Texture::getSRGBDecode() const
......
...@@ -198,69 +198,129 @@ SamplerState SamplerState::CreateDefaultForTarget(TextureType type) ...@@ -198,69 +198,129 @@ SamplerState SamplerState::CreateDefaultForTarget(TextureType type)
return state; return state;
} }
void SamplerState::setMinFilter(GLenum minFilter) bool SamplerState::setMinFilter(GLenum minFilter)
{ {
mMinFilter = minFilter; if (mMinFilter != minFilter)
mCompleteness.typed.minFilter = static_cast<uint8_t>(FromGLenum<FilterMode>(minFilter)); {
mMinFilter = minFilter;
mCompleteness.typed.minFilter = static_cast<uint8_t>(FromGLenum<FilterMode>(minFilter));
return true;
}
return false;
} }
void SamplerState::setMagFilter(GLenum magFilter) bool SamplerState::setMagFilter(GLenum magFilter)
{ {
mMagFilter = magFilter; if (mMagFilter != magFilter)
mCompleteness.typed.magFilter = static_cast<uint8_t>(FromGLenum<FilterMode>(magFilter)); {
mMagFilter = magFilter;
mCompleteness.typed.magFilter = static_cast<uint8_t>(FromGLenum<FilterMode>(magFilter));
return true;
}
return false;
} }
void SamplerState::setWrapS(GLenum wrapS) bool SamplerState::setWrapS(GLenum wrapS)
{ {
mWrapS = wrapS; if (mWrapS != wrapS)
mCompleteness.typed.wrapS = static_cast<uint8_t>(FromGLenum<WrapMode>(wrapS)); {
mWrapS = wrapS;
mCompleteness.typed.wrapS = static_cast<uint8_t>(FromGLenum<WrapMode>(wrapS));
return true;
}
return false;
} }
void SamplerState::setWrapT(GLenum wrapT) bool SamplerState::setWrapT(GLenum wrapT)
{ {
mWrapT = wrapT; if (mWrapT != wrapT)
updateWrapTCompareMode(); {
mWrapT = wrapT;
updateWrapTCompareMode();
return true;
}
return false;
} }
void SamplerState::setWrapR(GLenum wrapR) bool SamplerState::setWrapR(GLenum wrapR)
{ {
mWrapR = wrapR; if (mWrapR != wrapR)
{
mWrapR = wrapR;
return true;
}
return false;
} }
void SamplerState::setMaxAnisotropy(float maxAnisotropy) bool SamplerState::setMaxAnisotropy(float maxAnisotropy)
{ {
mMaxAnisotropy = maxAnisotropy; if (mMaxAnisotropy != maxAnisotropy)
{
mMaxAnisotropy = maxAnisotropy;
return true;
}
return false;
} }
void SamplerState::setMinLod(GLfloat minLod) bool SamplerState::setMinLod(GLfloat minLod)
{ {
mMinLod = minLod; if (mMinLod != minLod)
{
mMinLod = minLod;
return true;
}
return false;
} }
void SamplerState::setMaxLod(GLfloat maxLod) bool SamplerState::setMaxLod(GLfloat maxLod)
{ {
mMaxLod = maxLod; if (mMaxLod != maxLod)
{
mMaxLod = maxLod;
return true;
}
return false;
} }
void SamplerState::setCompareMode(GLenum compareMode) bool SamplerState::setCompareMode(GLenum compareMode)
{ {
mCompareMode = compareMode; if (mCompareMode != compareMode)
updateWrapTCompareMode(); {
mCompareMode = compareMode;
updateWrapTCompareMode();
return true;
}
return false;
} }
void SamplerState::setCompareFunc(GLenum compareFunc) bool SamplerState::setCompareFunc(GLenum compareFunc)
{ {
mCompareFunc = compareFunc; if (mCompareFunc != compareFunc)
{
mCompareFunc = compareFunc;
return true;
}
return false;
} }
void SamplerState::setSRGBDecode(GLenum sRGBDecode) bool SamplerState::setSRGBDecode(GLenum sRGBDecode)
{ {
mSRGBDecode = sRGBDecode; if (mSRGBDecode != sRGBDecode)
{
mSRGBDecode = sRGBDecode;
return true;
}
return false;
} }
void SamplerState::setBorderColor(const ColorGeneric &color) bool SamplerState::setBorderColor(const ColorGeneric &color)
{ {
mBorderColor = color; if (mBorderColor != color)
{
mBorderColor = color;
return true;
}
return false;
} }
void SamplerState::updateWrapTCompareMode() void SamplerState::updateWrapTCompareMode()
......
...@@ -287,49 +287,49 @@ class SamplerState final ...@@ -287,49 +287,49 @@ class SamplerState final
GLenum getMinFilter() const { return mMinFilter; } GLenum getMinFilter() const { return mMinFilter; }
void setMinFilter(GLenum minFilter); bool setMinFilter(GLenum minFilter);
GLenum getMagFilter() const { return mMagFilter; } GLenum getMagFilter() const { return mMagFilter; }
void setMagFilter(GLenum magFilter); bool setMagFilter(GLenum magFilter);
GLenum getWrapS() const { return mWrapS; } GLenum getWrapS() const { return mWrapS; }
void setWrapS(GLenum wrapS); bool setWrapS(GLenum wrapS);
GLenum getWrapT() const { return mWrapT; } GLenum getWrapT() const { return mWrapT; }
void setWrapT(GLenum wrapT); bool setWrapT(GLenum wrapT);
GLenum getWrapR() const { return mWrapR; } GLenum getWrapR() const { return mWrapR; }
void setWrapR(GLenum wrapR); bool setWrapR(GLenum wrapR);
float getMaxAnisotropy() const { return mMaxAnisotropy; } float getMaxAnisotropy() const { return mMaxAnisotropy; }
void setMaxAnisotropy(float maxAnisotropy); bool setMaxAnisotropy(float maxAnisotropy);
GLfloat getMinLod() const { return mMinLod; } GLfloat getMinLod() const { return mMinLod; }
void setMinLod(GLfloat minLod); bool setMinLod(GLfloat minLod);
GLfloat getMaxLod() const { return mMaxLod; } GLfloat getMaxLod() const { return mMaxLod; }
void setMaxLod(GLfloat maxLod); bool setMaxLod(GLfloat maxLod);
GLenum getCompareMode() const { return mCompareMode; } GLenum getCompareMode() const { return mCompareMode; }
void setCompareMode(GLenum compareMode); bool setCompareMode(GLenum compareMode);
GLenum getCompareFunc() const { return mCompareFunc; } GLenum getCompareFunc() const { return mCompareFunc; }
void setCompareFunc(GLenum compareFunc); bool setCompareFunc(GLenum compareFunc);
GLenum getSRGBDecode() const { return mSRGBDecode; } GLenum getSRGBDecode() const { return mSRGBDecode; }
void setSRGBDecode(GLenum sRGBDecode); bool setSRGBDecode(GLenum sRGBDecode);
void setBorderColor(const ColorGeneric &color); bool setBorderColor(const ColorGeneric &color);
const ColorGeneric &getBorderColor() const { return mBorderColor; } const ColorGeneric &getBorderColor() const { return mBorderColor; }
......
...@@ -1645,12 +1645,11 @@ angle::Result TextureGL::setMaxLevel(const gl::Context *context, GLuint maxLevel ...@@ -1645,12 +1645,11 @@ angle::Result TextureGL::setMaxLevel(const gl::Context *context, GLuint maxLevel
angle::Result TextureGL::setMinFilter(const gl::Context *context, GLenum filter) angle::Result TextureGL::setMinFilter(const gl::Context *context, GLenum filter)
{ {
if (filter != mAppliedSampler.getMinFilter()) if (mAppliedSampler.setMinFilter(filter))
{ {
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
mAppliedSampler.setMinFilter(filter);
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MIN_FILTER); mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MIN_FILTER);
// Signal to the GL layer that the Impl has dirty bits. // Signal to the GL layer that the Impl has dirty bits.
...@@ -1664,12 +1663,11 @@ angle::Result TextureGL::setMinFilter(const gl::Context *context, GLenum filter) ...@@ -1664,12 +1663,11 @@ angle::Result TextureGL::setMinFilter(const gl::Context *context, GLenum filter)
} }
angle::Result TextureGL::setMagFilter(const gl::Context *context, GLenum filter) angle::Result TextureGL::setMagFilter(const gl::Context *context, GLenum filter)
{ {
if (filter != mAppliedSampler.getMagFilter()) if (mAppliedSampler.setMagFilter(filter))
{ {
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
mAppliedSampler.setMagFilter(filter);
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MAG_FILTER); mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MAG_FILTER);
// Signal to the GL layer that the Impl has dirty bits. // Signal to the GL layer that the Impl has dirty bits.
......
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