Commit 097d3c0c by Jamie Madill Committed by Commit Bot

Make SamplerState a contained class.

This will more easily allow us to use a cached completeness comparison value. The cached value only gets updated on certain setters. Bug: angleproject:2763 Change-Id: Ib80db8517560617087ae8360f7af69d6c2392b76 Reviewed-on: https://chromium-review.googlesource.com/1171507Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent f0d258c3
......@@ -42,112 +42,112 @@ const std::string &Sampler::getLabel() const
void Sampler::setMinFilter(GLenum minFilter)
{
mState.minFilter = minFilter;
mState.setMinFilter(minFilter);
}
GLenum Sampler::getMinFilter() const
{
return mState.minFilter;
return mState.getMinFilter();
}
void Sampler::setMagFilter(GLenum magFilter)
{
mState.magFilter = magFilter;
mState.setMagFilter(magFilter);
}
GLenum Sampler::getMagFilter() const
{
return mState.magFilter;
return mState.getMagFilter();
}
void Sampler::setWrapS(GLenum wrapS)
{
mState.wrapS = wrapS;
mState.setWrapS(wrapS);
}
GLenum Sampler::getWrapS() const
{
return mState.wrapS;
return mState.getWrapS();
}
void Sampler::setWrapT(GLenum wrapT)
{
mState.wrapT = wrapT;
mState.setWrapT(wrapT);
}
GLenum Sampler::getWrapT() const
{
return mState.wrapT;
return mState.getWrapT();
}
void Sampler::setWrapR(GLenum wrapR)
{
mState.wrapR = wrapR;
mState.setWrapR(wrapR);
}
GLenum Sampler::getWrapR() const
{
return mState.wrapR;
return mState.getWrapR();
}
void Sampler::setMaxAnisotropy(float maxAnisotropy)
{
mState.maxAnisotropy = maxAnisotropy;
mState.setMaxAnisotropy(maxAnisotropy);
}
float Sampler::getMaxAnisotropy() const
{
return mState.maxAnisotropy;
return mState.getMaxAnisotropy();
}
void Sampler::setMinLod(GLfloat minLod)
{
mState.minLod = minLod;
mState.setMinLod(minLod);
}
GLfloat Sampler::getMinLod() const
{
return mState.minLod;
return mState.getMinLod();
}
void Sampler::setMaxLod(GLfloat maxLod)
{
mState.maxLod = maxLod;
mState.setMaxLod(maxLod);
}
GLfloat Sampler::getMaxLod() const
{
return mState.maxLod;
return mState.getMaxLod();
}
void Sampler::setCompareMode(GLenum compareMode)
{
mState.compareMode = compareMode;
mState.setCompareMode(compareMode);
}
GLenum Sampler::getCompareMode() const
{
return mState.compareMode;
return mState.getCompareMode();
}
void Sampler::setCompareFunc(GLenum compareFunc)
{
mState.compareFunc = compareFunc;
mState.setCompareFunc(compareFunc);
}
GLenum Sampler::getCompareFunc() const
{
return mState.compareFunc;
return mState.getCompareFunc();
}
void Sampler::setSRGBDecode(GLenum sRGBDecode)
{
mState.sRGBDecode = sRGBDecode;
mState.setSRGBDecode(sRGBDecode);
}
GLenum Sampler::getSRGBDecode() const
{
return mState.sRGBDecode;
return mState.getSRGBDecode();
}
const SamplerState &Sampler::getSamplerState() const
......
......@@ -26,9 +26,9 @@ namespace
{
bool IsPointSampled(const SamplerState &samplerState)
{
return (samplerState.magFilter == GL_NEAREST &&
(samplerState.minFilter == GL_NEAREST ||
samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST));
return (samplerState.getMagFilter() == GL_NEAREST &&
(samplerState.getMinFilter() == GL_NEAREST ||
samplerState.getMinFilter() == GL_NEAREST_MIPMAP_NEAREST));
}
size_t GetImageDescIndex(TextureTarget target, size_t level)
......@@ -53,7 +53,7 @@ InitState DetermineInitState(const Context *context, const uint8_t *pixels)
bool IsMipmapFiltered(const SamplerState &samplerState)
{
switch (samplerState.minFilter)
switch (samplerState.getMinFilter())
{
case GL_NEAREST:
case GL_LINEAR:
......@@ -280,8 +280,8 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
bool npotSupport = data.getExtensions().textureNPOT || data.getClientMajorVersion() >= 3;
if (!npotSupport)
{
if ((samplerState.wrapS != GL_CLAMP_TO_EDGE && !isPow2(baseImageDesc.size.width)) ||
(samplerState.wrapT != GL_CLAMP_TO_EDGE && !isPow2(baseImageDesc.size.height)))
if ((samplerState.getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(baseImageDesc.size.width)) ||
(samplerState.getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(baseImageDesc.size.height)))
{
return false;
}
......@@ -320,12 +320,13 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
// texture unit, such as TEXTURE_WRAP_R for an external texture, does not affect completeness.
if (mType == TextureType::External)
{
if (samplerState.wrapS != GL_CLAMP_TO_EDGE || samplerState.wrapT != GL_CLAMP_TO_EDGE)
if (samplerState.getWrapS() != GL_CLAMP_TO_EDGE ||
samplerState.getWrapT() != GL_CLAMP_TO_EDGE)
{
return false;
}
if (samplerState.minFilter != GL_LINEAR && samplerState.minFilter != GL_NEAREST)
if (samplerState.getMinFilter() != GL_LINEAR && samplerState.getMinFilter() != GL_NEAREST)
{
return false;
}
......@@ -343,11 +344,11 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
// extension, due to some underspecification problems, we must allow linear filtering
// for legacy compatibility with WebGL 1.
// See http://crbug.com/649200
if (samplerState.compareMode == GL_NONE && baseImageDesc.format.info->sized)
if (samplerState.getCompareMode() == GL_NONE && baseImageDesc.format.info->sized)
{
if ((samplerState.minFilter != GL_NEAREST &&
samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST) ||
samplerState.magFilter != GL_NEAREST)
if ((samplerState.getMinFilter() != GL_NEAREST &&
samplerState.getMinFilter() != GL_NEAREST_MIPMAP_NEAREST) ||
samplerState.getMagFilter() != GL_NEAREST)
{
return false;
}
......@@ -366,9 +367,9 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
if (!IsMultisampled(mType) && baseImageDesc.format.info->depthBits > 0 &&
mDepthStencilTextureMode == GL_STENCIL_INDEX)
{
if ((samplerState.minFilter != GL_NEAREST &&
samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST) ||
samplerState.magFilter != GL_NEAREST)
if ((samplerState.getMinFilter() != GL_NEAREST &&
samplerState.getMinFilter() != GL_NEAREST_MIPMAP_NEAREST) ||
samplerState.getMagFilter() != GL_NEAREST)
{
return false;
}
......@@ -678,123 +679,123 @@ GLenum Texture::getSwizzleAlpha() const
void Texture::setMinFilter(GLenum minFilter)
{
mState.mSamplerState.minFilter = minFilter;
mState.mSamplerState.setMinFilter(minFilter);
mDirtyBits.set(DIRTY_BIT_MIN_FILTER);
}
GLenum Texture::getMinFilter() const
{
return mState.mSamplerState.minFilter;
return mState.mSamplerState.getMinFilter();
}
void Texture::setMagFilter(GLenum magFilter)
{
mState.mSamplerState.magFilter = magFilter;
mState.mSamplerState.setMagFilter(magFilter);
mDirtyBits.set(DIRTY_BIT_MAG_FILTER);
}
GLenum Texture::getMagFilter() const
{
return mState.mSamplerState.magFilter;
return mState.mSamplerState.getMagFilter();
}
void Texture::setWrapS(GLenum wrapS)
{
mState.mSamplerState.wrapS = wrapS;
mState.mSamplerState.setWrapS(wrapS);
mDirtyBits.set(DIRTY_BIT_WRAP_S);
}
GLenum Texture::getWrapS() const
{
return mState.mSamplerState.wrapS;
return mState.mSamplerState.getWrapS();
}
void Texture::setWrapT(GLenum wrapT)
{
mState.mSamplerState.wrapT = wrapT;
mState.mSamplerState.setWrapT(wrapT);
mDirtyBits.set(DIRTY_BIT_WRAP_T);
}
GLenum Texture::getWrapT() const
{
return mState.mSamplerState.wrapT;
return mState.mSamplerState.getWrapT();
}
void Texture::setWrapR(GLenum wrapR)
{
mState.mSamplerState.wrapR = wrapR;
mState.mSamplerState.setWrapR(wrapR);
mDirtyBits.set(DIRTY_BIT_WRAP_R);
}
GLenum Texture::getWrapR() const
{
return mState.mSamplerState.wrapR;
return mState.mSamplerState.getWrapR();
}
void Texture::setMaxAnisotropy(float maxAnisotropy)
{
mState.mSamplerState.maxAnisotropy = maxAnisotropy;
mState.mSamplerState.setMaxAnisotropy(maxAnisotropy);
mDirtyBits.set(DIRTY_BIT_MAX_ANISOTROPY);
}
float Texture::getMaxAnisotropy() const
{
return mState.mSamplerState.maxAnisotropy;
return mState.mSamplerState.getMaxAnisotropy();
}
void Texture::setMinLod(GLfloat minLod)
{
mState.mSamplerState.minLod = minLod;
mState.mSamplerState.setMinLod(minLod);
mDirtyBits.set(DIRTY_BIT_MIN_LOD);
}
GLfloat Texture::getMinLod() const
{
return mState.mSamplerState.minLod;
return mState.mSamplerState.getMinLod();
}
void Texture::setMaxLod(GLfloat maxLod)
{
mState.mSamplerState.maxLod = maxLod;
mState.mSamplerState.setMaxLod(maxLod);
mDirtyBits.set(DIRTY_BIT_MAX_LOD);
}
GLfloat Texture::getMaxLod() const
{
return mState.mSamplerState.maxLod;
return mState.mSamplerState.getMaxLod();
}
void Texture::setCompareMode(GLenum compareMode)
{
mState.mSamplerState.compareMode = compareMode;
mState.mSamplerState.setCompareMode(compareMode);
mDirtyBits.set(DIRTY_BIT_COMPARE_MODE);
}
GLenum Texture::getCompareMode() const
{
return mState.mSamplerState.compareMode;
return mState.mSamplerState.getCompareMode();
}
void Texture::setCompareFunc(GLenum compareFunc)
{
mState.mSamplerState.compareFunc = compareFunc;
mState.mSamplerState.setCompareFunc(compareFunc);
mDirtyBits.set(DIRTY_BIT_COMPARE_FUNC);
}
GLenum Texture::getCompareFunc() const
{
return mState.mSamplerState.compareFunc;
return mState.mSamplerState.getCompareFunc();
}
void Texture::setSRGBDecode(GLenum sRGBDecode)
{
mState.mSamplerState.sRGBDecode = sRGBDecode;
mState.mSamplerState.setSRGBDecode(sRGBDecode);
mDirtyBits.set(DIRTY_BIT_SRGB_DECODE);
}
GLenum Texture::getSRGBDecode() const
{
return mState.mSamplerState.sRGBDecode;
return mState.mSamplerState.getSRGBDecode();
}
const SamplerState &Texture::getSamplerState() const
......
......@@ -110,17 +110,17 @@ SamplerState::SamplerState()
{
memset(this, 0, sizeof(SamplerState));
minFilter = GL_NEAREST_MIPMAP_LINEAR;
magFilter = GL_LINEAR;
wrapS = GL_REPEAT;
wrapT = GL_REPEAT;
wrapR = GL_REPEAT;
maxAnisotropy = 1.0f;
minLod = -1000.0f;
maxLod = 1000.0f;
compareMode = GL_NONE;
compareFunc = GL_LEQUAL;
sRGBDecode = GL_DECODE_EXT;
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
mWrapS = GL_REPEAT;
mWrapT = GL_REPEAT;
mWrapR = GL_REPEAT;
mMaxAnisotropy = 1.0f;
mMinLod = -1000.0f;
mMaxLod = 1000.0f;
mCompareMode = GL_NONE;
mCompareFunc = GL_LEQUAL;
mSRGBDecode = GL_DECODE_EXT;
}
SamplerState::SamplerState(const SamplerState &other) = default;
......@@ -134,14 +134,69 @@ SamplerState SamplerState::CreateDefaultForTarget(TextureType type)
// default min filter is GL_LINEAR and the default s and t wrap modes are GL_CLAMP_TO_EDGE.
if (type == TextureType::External || type == TextureType::Rectangle)
{
state.minFilter = GL_LINEAR;
state.wrapS = GL_CLAMP_TO_EDGE;
state.wrapT = GL_CLAMP_TO_EDGE;
state.mMinFilter = GL_LINEAR;
state.mWrapS = GL_CLAMP_TO_EDGE;
state.mWrapT = GL_CLAMP_TO_EDGE;
}
return state;
}
void SamplerState::setMinFilter(GLenum minFilter)
{
mMinFilter = minFilter;
}
void SamplerState::setMagFilter(GLenum magFilter)
{
mMagFilter = magFilter;
}
void SamplerState::setWrapS(GLenum wrapS)
{
mWrapS = wrapS;
}
void SamplerState::setWrapT(GLenum wrapT)
{
mWrapT = wrapT;
}
void SamplerState::setWrapR(GLenum wrapR)
{
mWrapR = wrapR;
}
void SamplerState::setMaxAnisotropy(float maxAnisotropy)
{
mMaxAnisotropy = maxAnisotropy;
}
void SamplerState::setMinLod(GLfloat minLod)
{
mMinLod = minLod;
}
void SamplerState::setMaxLod(GLfloat maxLod)
{
mMaxLod = maxLod;
}
void SamplerState::setCompareMode(GLenum compareMode)
{
mCompareMode = compareMode;
}
void SamplerState::setCompareFunc(GLenum compareFunc)
{
mCompareFunc = compareFunc;
}
void SamplerState::setSRGBDecode(GLenum sRGBDecode)
{
mSRGBDecode = sRGBDecode;
}
ImageUnit::ImageUnit()
: texture(), level(0), layered(false), layer(0), access(GL_READ_ONLY), format(GL_R32UI)
{
......
......@@ -196,31 +196,77 @@ bool operator==(const DepthStencilState &a, const DepthStencilState &b);
bool operator!=(const DepthStencilState &a, const DepthStencilState &b);
// State from Table 6.10 (state per sampler object)
struct SamplerState final
class SamplerState final
{
public:
// This will zero-initialize the struct, including padding.
SamplerState();
SamplerState(const SamplerState &other);
static SamplerState CreateDefaultForTarget(TextureType type);
GLenum minFilter;
GLenum magFilter;
GLenum getMinFilter() const { return mMinFilter; }
void setMinFilter(GLenum minFilter);
GLenum getMagFilter() const { return mMagFilter; }
void setMagFilter(GLenum magFilter);
GLenum getWrapS() const { return mWrapS; }
void setWrapS(GLenum wrapS);
GLenum getWrapT() const { return mWrapT; }
void setWrapT(GLenum wrapT);
GLenum getWrapR() const { return mWrapR; }
void setWrapR(GLenum wrapR);
float getMaxAnisotropy() const { return mMaxAnisotropy; }
void setMaxAnisotropy(float maxAnisotropy);
GLfloat getMinLod() const { return mMinLod; }
void setMinLod(GLfloat minLod);
GLfloat getMaxLod() const { return mMaxLod; }
void setMaxLod(GLfloat maxLod);
GLenum getCompareMode() const { return mCompareMode; }
void setCompareMode(GLenum compareMode);
GLenum getCompareFunc() const { return mCompareFunc; }
void setCompareFunc(GLenum compareFunc);
GLenum getSRGBDecode() const { return mSRGBDecode; }
void setSRGBDecode(GLenum sRGBDecode);
private:
GLenum mMinFilter;
GLenum mMagFilter;
GLenum wrapS;
GLenum wrapT;
GLenum wrapR;
GLenum mWrapS;
GLenum mWrapT;
GLenum mWrapR;
// From EXT_texture_filter_anisotropic
float maxAnisotropy;
float mMaxAnisotropy;
GLfloat minLod;
GLfloat maxLod;
GLfloat mMinLod;
GLfloat mMaxLod;
GLenum compareMode;
GLenum compareFunc;
GLenum mCompareMode;
GLenum mCompareFunc;
GLenum sRGBDecode;
GLenum mSRGBDecode;
};
bool operator==(const SamplerState &a, const SamplerState &b);
......
......@@ -170,10 +170,10 @@ void QueryTexParameterBase(const Texture *texture, GLenum pname, ParamType *para
*params = CastFromGLintStateValue<ParamType>(pname, texture->getMaxLevel());
break;
case GL_TEXTURE_MIN_LOD:
*params = CastFromStateValue<ParamType>(pname, texture->getSamplerState().minLod);
*params = CastFromStateValue<ParamType>(pname, texture->getMinLod());
break;
case GL_TEXTURE_MAX_LOD:
*params = CastFromStateValue<ParamType>(pname, texture->getSamplerState().maxLod);
*params = CastFromStateValue<ParamType>(pname, texture->getMaxLod());
break;
case GL_TEXTURE_COMPARE_MODE:
*params = CastFromGLintStateValue<ParamType>(pname, texture->getCompareMode());
......
......@@ -14,7 +14,7 @@
namespace gl
{
class Context;
struct SamplerState;
class SamplerState;
} // namespace gl
namespace rx
......
......@@ -241,28 +241,28 @@ angle::Result RenderStateCache::getSamplerState(const gl::Context *context,
D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter =
gl_d3d11::ConvertFilter(samplerState.minFilter, samplerState.magFilter,
samplerState.maxAnisotropy, samplerState.compareMode);
samplerDesc.AddressU = gl_d3d11::ConvertTextureWrap(samplerState.wrapS);
samplerDesc.AddressV = gl_d3d11::ConvertTextureWrap(samplerState.wrapT);
samplerDesc.AddressW = gl_d3d11::ConvertTextureWrap(samplerState.wrapR);
gl_d3d11::ConvertFilter(samplerState.getMinFilter(), samplerState.getMagFilter(),
samplerState.getMaxAnisotropy(), samplerState.getCompareMode());
samplerDesc.AddressU = gl_d3d11::ConvertTextureWrap(samplerState.getWrapS());
samplerDesc.AddressV = gl_d3d11::ConvertTextureWrap(samplerState.getWrapT());
samplerDesc.AddressW = gl_d3d11::ConvertTextureWrap(samplerState.getWrapR());
samplerDesc.MipLODBias = 0;
samplerDesc.MaxAnisotropy =
gl_d3d11::ConvertMaxAnisotropy(samplerState.maxAnisotropy, featureLevel);
samplerDesc.ComparisonFunc = gl_d3d11::ConvertComparison(samplerState.compareFunc);
gl_d3d11::ConvertMaxAnisotropy(samplerState.getMaxAnisotropy(), featureLevel);
samplerDesc.ComparisonFunc = gl_d3d11::ConvertComparison(samplerState.getCompareFunc());
samplerDesc.BorderColor[0] = 0.0f;
samplerDesc.BorderColor[1] = 0.0f;
samplerDesc.BorderColor[2] = 0.0f;
samplerDesc.BorderColor[3] = 0.0f;
samplerDesc.MinLOD = samplerState.minLod;
samplerDesc.MaxLOD = samplerState.maxLod;
samplerDesc.MinLOD = samplerState.getMinLod();
samplerDesc.MaxLOD = samplerState.getMaxLod();
if (featureLevel <= D3D_FEATURE_LEVEL_9_3)
{
// Check that maxLOD is nearly FLT_MAX (1000.0f is the default), since 9_3 doesn't support
// anything other than FLT_MAX. Note that Feature Level 9_* only supports GL ES 2.0, so the
// consumer of ANGLE can't modify the Max LOD themselves.
ASSERT(samplerState.maxLod >= 999.9f);
ASSERT(samplerState.getMaxLod() >= 999.9f);
// Now just set MaxLOD to FLT_MAX. Other parts of the renderer (e.g. the non-zero max LOD
// workaround) should take account of this.
......
......@@ -942,26 +942,26 @@ angle::Result Renderer9::setSamplerState(const gl::Context *context,
int d3dSampler = index + d3dSamplerOffset;
mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU,
gl_d3d9::ConvertTextureWrap(samplerState.wrapS));
gl_d3d9::ConvertTextureWrap(samplerState.getWrapS()));
mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSV,
gl_d3d9::ConvertTextureWrap(samplerState.wrapT));
gl_d3d9::ConvertTextureWrap(samplerState.getWrapT()));
mDevice->SetSamplerState(
d3dSampler, D3DSAMP_MAGFILTER,
gl_d3d9::ConvertMagFilter(samplerState.magFilter, samplerState.maxAnisotropy));
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAGFILTER,
gl_d3d9::ConvertMagFilter(samplerState.getMagFilter(),
samplerState.getMaxAnisotropy()));
D3DTEXTUREFILTERTYPE d3dMinFilter, d3dMipFilter;
float lodBias;
gl_d3d9::ConvertMinFilter(samplerState.minFilter, &d3dMinFilter, &d3dMipFilter, &lodBias,
samplerState.maxAnisotropy, baseLevel);
gl_d3d9::ConvertMinFilter(samplerState.getMinFilter(), &d3dMinFilter, &d3dMipFilter,
&lodBias, samplerState.getMaxAnisotropy(), baseLevel);
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MINFILTER, d3dMinFilter);
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXMIPLEVEL, baseLevel);
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPMAPLODBIAS, static_cast<DWORD>(lodBias));
if (getNativeExtensions().textureFilterAnisotropic)
{
DWORD maxAnisotropy =
std::min(mDeviceCaps.MaxAnisotropy, static_cast<DWORD>(samplerState.maxAnisotropy));
DWORD maxAnisotropy = std::min(mDeviceCaps.MaxAnisotropy,
static_cast<DWORD>(samplerState.getMaxAnisotropy()));
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MAXANISOTROPY, maxAnisotropy);
}
}
......
......@@ -14,18 +14,19 @@
namespace
{
template <typename T>
template <typename Getter, typename Setter>
static inline void SyncSamplerStateMember(const rx::FunctionsGL *functions,
GLuint sampler,
const gl::SamplerState &newState,
gl::SamplerState &curState,
GLenum name,
T(gl::SamplerState::*samplerMember))
Getter getter,
Setter setter)
{
if (curState.*samplerMember != newState.*samplerMember)
if ((curState.*getter)() != (newState.*getter)())
{
curState.*samplerMember = newState.*samplerMember;
functions->samplerParameterf(sampler, name, static_cast<GLfloat>(curState.*samplerMember));
(curState.*setter)((newState.*getter)());
functions->samplerParameterf(sampler, name, static_cast<GLfloat>((curState.*getter)()));
}
}
}
......@@ -54,17 +55,17 @@ SamplerGL::~SamplerGL()
void SamplerGL::syncState(const gl::Context *context)
{
// clang-format off
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_SRGB_DECODE_EXT, &gl::SamplerState::sRGBDecode);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::getMinFilter, &gl::SamplerState::setMinFilter);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::getMagFilter, &gl::SamplerState::setMagFilter);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_WRAP_S, &gl::SamplerState::getWrapS, &gl::SamplerState::setWrapS);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_WRAP_T, &gl::SamplerState::getWrapT, &gl::SamplerState::setWrapT);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_WRAP_R, &gl::SamplerState::getWrapR, &gl::SamplerState::setWrapR);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::getMaxAnisotropy, &gl::SamplerState::setMaxAnisotropy);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MIN_LOD, &gl::SamplerState::getMinLod, &gl::SamplerState::setMinLod);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_MAX_LOD, &gl::SamplerState::getMaxLod, &gl::SamplerState::setMaxLod);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::getCompareMode, &gl::SamplerState::setCompareMode);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::getCompareFunc, &gl::SamplerState::setCompareFunc);
SyncSamplerStateMember(mFunctions, mSamplerID, mState, mAppliedSamplerState, GL_TEXTURE_SRGB_DECODE_EXT, &gl::SamplerState::getSRGBDecode, &gl::SamplerState::setSRGBDecode);
// clang-format on
}
......
......@@ -1150,59 +1150,59 @@ gl::Error TextureGL::syncState(const gl::Context *context, const gl::Texture::Di
switch (dirtyBit)
{
case gl::Texture::DIRTY_BIT_MIN_FILTER:
mAppliedSampler.minFilter = mState.getSamplerState().minFilter;
mAppliedSampler.setMinFilter(mState.getSamplerState().getMinFilter());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_MIN_FILTER,
mAppliedSampler.minFilter);
mAppliedSampler.getMinFilter());
break;
case gl::Texture::DIRTY_BIT_MAG_FILTER:
mAppliedSampler.magFilter = mState.getSamplerState().magFilter;
mAppliedSampler.setMagFilter(mState.getSamplerState().getMagFilter());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_MAG_FILTER,
mAppliedSampler.magFilter);
mAppliedSampler.getMagFilter());
break;
case gl::Texture::DIRTY_BIT_WRAP_S:
mAppliedSampler.wrapS = mState.getSamplerState().wrapS;
mAppliedSampler.setWrapS(mState.getSamplerState().getWrapS());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_WRAP_S,
mAppliedSampler.wrapS);
mAppliedSampler.getWrapS());
break;
case gl::Texture::DIRTY_BIT_WRAP_T:
mAppliedSampler.wrapT = mState.getSamplerState().wrapT;
mAppliedSampler.setWrapT(mState.getSamplerState().getWrapT());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_WRAP_T,
mAppliedSampler.wrapT);
mAppliedSampler.getWrapT());
break;
case gl::Texture::DIRTY_BIT_WRAP_R:
mAppliedSampler.wrapR = mState.getSamplerState().wrapR;
mAppliedSampler.setWrapR(mState.getSamplerState().getWrapR());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_WRAP_R,
mAppliedSampler.wrapR);
mAppliedSampler.getWrapR());
break;
case gl::Texture::DIRTY_BIT_MAX_ANISOTROPY:
mAppliedSampler.maxAnisotropy = mState.getSamplerState().maxAnisotropy;
mAppliedSampler.setMaxAnisotropy(mState.getSamplerState().getMaxAnisotropy());
functions->texParameterf(ToGLenum(getType()), GL_TEXTURE_MAX_ANISOTROPY_EXT,
mAppliedSampler.maxAnisotropy);
mAppliedSampler.getMaxAnisotropy());
break;
case gl::Texture::DIRTY_BIT_MIN_LOD:
mAppliedSampler.minLod = mState.getSamplerState().minLod;
mAppliedSampler.setMinLod(mState.getSamplerState().getMinLod());
functions->texParameterf(ToGLenum(getType()), GL_TEXTURE_MIN_LOD,
mAppliedSampler.minLod);
mAppliedSampler.getMinLod());
break;
case gl::Texture::DIRTY_BIT_MAX_LOD:
mAppliedSampler.maxLod = mState.getSamplerState().maxLod;
mAppliedSampler.setMaxLod(mState.getSamplerState().getMaxLod());
functions->texParameterf(ToGLenum(getType()), GL_TEXTURE_MAX_LOD,
mAppliedSampler.maxLod);
mAppliedSampler.getMaxLod());
break;
case gl::Texture::DIRTY_BIT_COMPARE_MODE:
mAppliedSampler.compareMode = mState.getSamplerState().compareMode;
mAppliedSampler.setCompareMode(mState.getSamplerState().getCompareMode());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_COMPARE_MODE,
mAppliedSampler.compareMode);
mAppliedSampler.getCompareMode());
break;
case gl::Texture::DIRTY_BIT_COMPARE_FUNC:
mAppliedSampler.compareFunc = mState.getSamplerState().compareFunc;
mAppliedSampler.setCompareFunc(mState.getSamplerState().getCompareFunc());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_COMPARE_FUNC,
mAppliedSampler.compareFunc);
mAppliedSampler.getCompareFunc());
break;
case gl::Texture::DIRTY_BIT_SRGB_DECODE:
mAppliedSampler.sRGBDecode = mState.getSamplerState().sRGBDecode;
mAppliedSampler.setSRGBDecode(mState.getSamplerState().getSRGBDecode());
functions->texParameteri(ToGLenum(getType()), GL_TEXTURE_SRGB_DECODE_EXT,
mAppliedSampler.sRGBDecode);
mAppliedSampler.getSRGBDecode());
break;
// Texture state
......@@ -1280,12 +1280,12 @@ gl::Error TextureGL::setBaseLevel(const gl::Context *context, GLuint baseLevel)
void TextureGL::setMinFilter(const gl::Context *context, GLenum filter)
{
if (filter != mAppliedSampler.minFilter)
if (filter != mAppliedSampler.getMinFilter())
{
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
mAppliedSampler.minFilter = filter;
mAppliedSampler.setMinFilter(filter);
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MIN_FILTER);
stateManager->bindTexture(getType(), mTextureID);
......@@ -1294,12 +1294,12 @@ void TextureGL::setMinFilter(const gl::Context *context, GLenum filter)
}
void TextureGL::setMagFilter(const gl::Context *context, GLenum filter)
{
if (filter != mAppliedSampler.magFilter)
if (filter != mAppliedSampler.getMagFilter())
{
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
mAppliedSampler.magFilter = filter;
mAppliedSampler.setMagFilter(filter);
mLocalDirtyBits.set(gl::Texture::DIRTY_BIT_MAG_FILTER);
stateManager->bindTexture(getType(), mTextureID);
......
......@@ -1112,19 +1112,19 @@ gl::Error TextureVk::syncState(const gl::Context *context, const gl::Texture::Di
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
samplerInfo.pNext = nullptr;
samplerInfo.flags = 0;
samplerInfo.magFilter = gl_vk::GetFilter(samplerState.magFilter);
samplerInfo.minFilter = gl_vk::GetFilter(samplerState.minFilter);
samplerInfo.mipmapMode = gl_vk::GetSamplerMipmapMode(samplerState.minFilter);
samplerInfo.addressModeU = gl_vk::GetSamplerAddressMode(samplerState.wrapS);
samplerInfo.addressModeV = gl_vk::GetSamplerAddressMode(samplerState.wrapT);
samplerInfo.addressModeW = gl_vk::GetSamplerAddressMode(samplerState.wrapR);
samplerInfo.magFilter = gl_vk::GetFilter(samplerState.getMagFilter());
samplerInfo.minFilter = gl_vk::GetFilter(samplerState.getMinFilter());
samplerInfo.mipmapMode = gl_vk::GetSamplerMipmapMode(samplerState.getMinFilter());
samplerInfo.addressModeU = gl_vk::GetSamplerAddressMode(samplerState.getWrapS());
samplerInfo.addressModeV = gl_vk::GetSamplerAddressMode(samplerState.getWrapT());
samplerInfo.addressModeW = gl_vk::GetSamplerAddressMode(samplerState.getWrapR());
samplerInfo.mipLodBias = 0.0f;
samplerInfo.anisotropyEnable = VK_FALSE;
samplerInfo.maxAnisotropy = 1.0f;
samplerInfo.compareEnable = VK_FALSE;
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
samplerInfo.minLod = samplerState.minLod;
samplerInfo.maxLod = samplerState.maxLod;
samplerInfo.minLod = samplerState.getMinLod();
samplerInfo.maxLod = samplerState.getMaxLod();
samplerInfo.borderColor = VK_BORDER_COLOR_INT_TRANSPARENT_BLACK;
samplerInfo.unnormalizedCoordinates = VK_FALSE;
......@@ -1159,7 +1159,7 @@ const vk::ImageView &TextureVk::getImageView() const
{
ASSERT(mImage.valid());
const GLenum minFilter = mState.getSamplerState().minFilter;
const GLenum minFilter = mState.getSamplerState().getMinFilter();
if (minFilter == GL_LINEAR || minFilter == GL_NEAREST)
{
return mBaseLevelImageView;
......
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