Commit bc0b1d47 by Geoff Lang

Track local dirty state in StateManagerGL.

Make the state setting functions of StateManagerGL public. BUG=angleproject:1113 Change-Id: Ic435c06ece24064a2f2403119fa30309aba37608 Reviewed-on: https://chromium-review.googlesource.com/295240Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c349ec03
...@@ -89,7 +89,8 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren ...@@ -89,7 +89,8 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren
mPrimitiveRestartEnabled(false), mPrimitiveRestartEnabled(false),
mClearColor(0.0f, 0.0f, 0.0f, 0.0f), mClearColor(0.0f, 0.0f, 0.0f, 0.0f),
mClearDepth(1.0f), mClearDepth(1.0f),
mClearStencil(0) mClearStencil(0),
mLocalDirtyBits()
{ {
ASSERT(mFunctions); ASSERT(mFunctions);
...@@ -262,43 +263,59 @@ void StateManagerGL::setPixelUnpackState(const gl::PixelUnpackState &unpack) ...@@ -262,43 +263,59 @@ void StateManagerGL::setPixelUnpackState(const gl::PixelUnpackState &unpack)
unpack.imageHeight, unpack.skipImages); unpack.imageHeight, unpack.skipImages);
} }
void StateManagerGL::setPixelUnpackState(GLint alignment, GLint rowLength, GLint skipRows, GLint skipPixels, void StateManagerGL::setPixelUnpackState(GLint alignment,
GLint imageHeight, GLint skipImages) GLint rowLength,
GLint skipRows,
GLint skipPixels,
GLint imageHeight,
GLint skipImages)
{ {
if (mUnpackAlignment != alignment) if (mUnpackAlignment != alignment)
{ {
mUnpackAlignment = alignment; mUnpackAlignment = alignment;
mFunctions->pixelStorei(GL_UNPACK_ALIGNMENT, mUnpackAlignment); mFunctions->pixelStorei(GL_UNPACK_ALIGNMENT, mUnpackAlignment);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_UNPACK_ALIGNMENT);
} }
if (mUnpackRowLength != rowLength) if (mUnpackRowLength != rowLength)
{ {
mUnpackRowLength = rowLength; mUnpackRowLength = rowLength;
mFunctions->pixelStorei(GL_UNPACK_ROW_LENGTH, mUnpackRowLength); mFunctions->pixelStorei(GL_UNPACK_ROW_LENGTH, mUnpackRowLength);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_UNPACK_ROW_LENGTH);
} }
if (mUnpackSkipRows != skipRows) if (mUnpackSkipRows != skipRows)
{ {
mUnpackSkipRows = rowLength; mUnpackSkipRows = rowLength;
mFunctions->pixelStorei(GL_UNPACK_SKIP_ROWS, mUnpackSkipRows); mFunctions->pixelStorei(GL_UNPACK_SKIP_ROWS, mUnpackSkipRows);
// TODO: set dirty bit once one exists
} }
if (mUnpackSkipPixels != skipPixels) if (mUnpackSkipPixels != skipPixels)
{ {
mUnpackSkipPixels = skipPixels; mUnpackSkipPixels = skipPixels;
mFunctions->pixelStorei(GL_UNPACK_SKIP_PIXELS, mUnpackSkipPixels); mFunctions->pixelStorei(GL_UNPACK_SKIP_PIXELS, mUnpackSkipPixels);
// TODO: set dirty bit once one exists
} }
if (mUnpackImageHeight != imageHeight) if (mUnpackImageHeight != imageHeight)
{ {
mUnpackImageHeight = imageHeight; mUnpackImageHeight = imageHeight;
mFunctions->pixelStorei(GL_UNPACK_IMAGE_HEIGHT, mUnpackImageHeight); mFunctions->pixelStorei(GL_UNPACK_IMAGE_HEIGHT, mUnpackImageHeight);
// TODO: set dirty bit once one exists
} }
if (mUnpackSkipImages != skipImages) if (mUnpackSkipImages != skipImages)
{ {
mUnpackSkipImages = skipImages; mUnpackSkipImages = skipImages;
mFunctions->pixelStorei(GL_UNPACK_SKIP_IMAGES, mUnpackSkipImages); mFunctions->pixelStorei(GL_UNPACK_SKIP_IMAGES, mUnpackSkipImages);
// TODO: set dirty bit once one exists
} }
} }
...@@ -312,30 +329,41 @@ void StateManagerGL::setPixelPackState(const gl::PixelPackState &pack) ...@@ -312,30 +329,41 @@ void StateManagerGL::setPixelPackState(const gl::PixelPackState &pack)
setPixelPackState(pack.alignment, pack.rowLength, pack.skipRows, pack.skipPixels); setPixelPackState(pack.alignment, pack.rowLength, pack.skipRows, pack.skipPixels);
} }
void StateManagerGL::setPixelPackState(GLint alignment, GLint rowLength, GLint skipRows, GLint skipPixels) void StateManagerGL::setPixelPackState(GLint alignment,
GLint rowLength,
GLint skipRows,
GLint skipPixels)
{ {
if (mPackAlignment != alignment) if (mPackAlignment != alignment)
{ {
mPackAlignment = alignment; mPackAlignment = alignment;
mFunctions->pixelStorei(GL_PACK_ALIGNMENT, mPackAlignment); mFunctions->pixelStorei(GL_PACK_ALIGNMENT, mPackAlignment);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_PACK_ALIGNMENT);
} }
if (mPackRowLength != rowLength) if (mPackRowLength != rowLength)
{ {
mPackRowLength = rowLength; mPackRowLength = rowLength;
mFunctions->pixelStorei(GL_PACK_ROW_LENGTH, mPackRowLength); mFunctions->pixelStorei(GL_PACK_ROW_LENGTH, mPackRowLength);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_UNPACK_ROW_LENGTH);
} }
if (mPackSkipRows != skipRows) if (mPackSkipRows != skipRows)
{ {
mPackSkipRows = rowLength; mPackSkipRows = rowLength;
mFunctions->pixelStorei(GL_PACK_SKIP_ROWS, mPackSkipRows); mFunctions->pixelStorei(GL_PACK_SKIP_ROWS, mPackSkipRows);
// TODO: set dirty bit once one exists
} }
if (mPackSkipPixels != skipPixels) if (mPackSkipPixels != skipPixels)
{ {
mPackSkipPixels = skipPixels; mPackSkipPixels = skipPixels;
mFunctions->pixelStorei(GL_PACK_SKIP_PIXELS, mPackSkipPixels); mFunctions->pixelStorei(GL_PACK_SKIP_PIXELS, mPackSkipPixels);
// TODO: set dirty bit once one exists
} }
} }
...@@ -465,7 +493,8 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data) ...@@ -465,7 +493,8 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data)
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void StateManagerGL::setAttributeCurrentData(size_t index, const gl::VertexAttribCurrentValueData &data) void StateManagerGL::setAttributeCurrentData(size_t index,
const gl::VertexAttribCurrentValueData &data)
{ {
if (mVertexAttribCurrentValues[index] != data) if (mVertexAttribCurrentValues[index] != data)
{ {
...@@ -486,6 +515,8 @@ void StateManagerGL::setAttributeCurrentData(size_t index, const gl::VertexAttri ...@@ -486,6 +515,8 @@ void StateManagerGL::setAttributeCurrentData(size_t index, const gl::VertexAttri
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_CURRENT_VALUE_0 + index);
} }
} }
...@@ -502,6 +533,8 @@ void StateManagerGL::setScissorTestEnabled(bool enabled) ...@@ -502,6 +533,8 @@ void StateManagerGL::setScissorTestEnabled(bool enabled)
{ {
mFunctions->disable(GL_SCISSOR_TEST); mFunctions->disable(GL_SCISSOR_TEST);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_SCISSOR_TEST_ENABLED);
} }
} }
...@@ -511,6 +544,8 @@ void StateManagerGL::setScissor(const gl::Rectangle &scissor) ...@@ -511,6 +544,8 @@ void StateManagerGL::setScissor(const gl::Rectangle &scissor)
{ {
mScissor = scissor; mScissor = scissor;
mFunctions->scissor(mScissor.x, mScissor.y, mScissor.width, mScissor.height); mFunctions->scissor(mScissor.x, mScissor.y, mScissor.width, mScissor.height);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_SCISSOR);
} }
} }
...@@ -520,6 +555,8 @@ void StateManagerGL::setViewport(const gl::Rectangle &viewport) ...@@ -520,6 +555,8 @@ void StateManagerGL::setViewport(const gl::Rectangle &viewport)
{ {
mViewport = viewport; mViewport = viewport;
mFunctions->viewport(mViewport.x, mViewport.y, mViewport.width, mViewport.height); mFunctions->viewport(mViewport.x, mViewport.y, mViewport.width, mViewport.height);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_VIEWPORT);
} }
} }
...@@ -530,6 +567,8 @@ void StateManagerGL::setDepthRange(float near, float far) ...@@ -530,6 +567,8 @@ void StateManagerGL::setDepthRange(float near, float far)
mNear = near; mNear = near;
mFar = far; mFar = far;
mFunctions->depthRange(mNear, mFar); mFunctions->depthRange(mNear, mFar);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_RANGE);
} }
} }
...@@ -546,6 +585,8 @@ void StateManagerGL::setBlendEnabled(bool enabled) ...@@ -546,6 +585,8 @@ void StateManagerGL::setBlendEnabled(bool enabled)
{ {
mFunctions->disable(GL_BLEND); mFunctions->disable(GL_BLEND);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_BLEND_ENABLED);
} }
} }
...@@ -555,10 +596,14 @@ void StateManagerGL::setBlendColor(const gl::ColorF &blendColor) ...@@ -555,10 +596,14 @@ void StateManagerGL::setBlendColor(const gl::ColorF &blendColor)
{ {
mBlendColor = blendColor; mBlendColor = blendColor;
mFunctions->blendColor(mBlendColor.red, mBlendColor.green, mBlendColor.blue, mBlendColor.alpha); mFunctions->blendColor(mBlendColor.red, mBlendColor.green, mBlendColor.blue, mBlendColor.alpha);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_BLEND_COLOR);
} }
} }
void StateManagerGL::setBlendFuncs(GLenum sourceBlendRGB, GLenum destBlendRGB, GLenum sourceBlendAlpha, void StateManagerGL::setBlendFuncs(GLenum sourceBlendRGB,
GLenum destBlendRGB,
GLenum sourceBlendAlpha,
GLenum destBlendAlpha) GLenum destBlendAlpha)
{ {
if (mSourceBlendRGB != sourceBlendRGB || mDestBlendRGB != destBlendRGB || if (mSourceBlendRGB != sourceBlendRGB || mDestBlendRGB != destBlendRGB ||
...@@ -570,6 +615,8 @@ void StateManagerGL::setBlendFuncs(GLenum sourceBlendRGB, GLenum destBlendRGB, G ...@@ -570,6 +615,8 @@ void StateManagerGL::setBlendFuncs(GLenum sourceBlendRGB, GLenum destBlendRGB, G
mDestBlendAlpha = destBlendAlpha; mDestBlendAlpha = destBlendAlpha;
mFunctions->blendFuncSeparate(mSourceBlendRGB, mDestBlendRGB, mSourceBlendAlpha, mDestBlendAlpha); mFunctions->blendFuncSeparate(mSourceBlendRGB, mDestBlendRGB, mSourceBlendAlpha, mDestBlendAlpha);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_BLEND_FUNCS);
} }
} }
...@@ -581,6 +628,8 @@ void StateManagerGL::setBlendEquations(GLenum blendEquationRGB, GLenum blendEqua ...@@ -581,6 +628,8 @@ void StateManagerGL::setBlendEquations(GLenum blendEquationRGB, GLenum blendEqua
mBlendEquationAlpha = blendEquationAlpha; mBlendEquationAlpha = blendEquationAlpha;
mFunctions->blendEquationSeparate(mBlendEquationRGB, mBlendEquationAlpha); mFunctions->blendEquationSeparate(mBlendEquationRGB, mBlendEquationAlpha);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_BLEND_EQUATIONS);
} }
} }
...@@ -593,6 +642,8 @@ void StateManagerGL::setColorMask(bool red, bool green, bool blue, bool alpha) ...@@ -593,6 +642,8 @@ void StateManagerGL::setColorMask(bool red, bool green, bool blue, bool alpha)
mColorMaskBlue = blue; mColorMaskBlue = blue;
mColorMaskAlpha = alpha; mColorMaskAlpha = alpha;
mFunctions->colorMask(mColorMaskRed, mColorMaskGreen, mColorMaskBlue, mColorMaskAlpha); mFunctions->colorMask(mColorMaskRed, mColorMaskGreen, mColorMaskBlue, mColorMaskAlpha);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_COLOR_MASK);
} }
} }
...@@ -609,6 +660,8 @@ void StateManagerGL::setSampleAlphaToCoverageEnabled(bool enabled) ...@@ -609,6 +660,8 @@ void StateManagerGL::setSampleAlphaToCoverageEnabled(bool enabled)
{ {
mFunctions->disable(GL_SAMPLE_ALPHA_TO_COVERAGE); mFunctions->disable(GL_SAMPLE_ALPHA_TO_COVERAGE);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED);
} }
} }
...@@ -625,6 +678,8 @@ void StateManagerGL::setSampleCoverageEnabled(bool enabled) ...@@ -625,6 +678,8 @@ void StateManagerGL::setSampleCoverageEnabled(bool enabled)
{ {
mFunctions->disable(GL_SAMPLE_COVERAGE); mFunctions->disable(GL_SAMPLE_COVERAGE);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_SAMPLE_COVERAGE_ENABLED);
} }
} }
...@@ -635,6 +690,8 @@ void StateManagerGL::setSampleCoverage(float value, bool invert) ...@@ -635,6 +690,8 @@ void StateManagerGL::setSampleCoverage(float value, bool invert)
mSampleCoverageValue = value; mSampleCoverageValue = value;
mSampleCoverageInvert = invert; mSampleCoverageInvert = invert;
mFunctions->sampleCoverage(mSampleCoverageValue, mSampleCoverageInvert); mFunctions->sampleCoverage(mSampleCoverageValue, mSampleCoverageInvert);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_SAMPLE_COVERAGE);
} }
} }
...@@ -651,6 +708,8 @@ void StateManagerGL::setDepthTestEnabled(bool enabled) ...@@ -651,6 +708,8 @@ void StateManagerGL::setDepthTestEnabled(bool enabled)
{ {
mFunctions->disable(GL_DEPTH_TEST); mFunctions->disable(GL_DEPTH_TEST);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED);
} }
} }
...@@ -660,6 +719,8 @@ void StateManagerGL::setDepthFunc(GLenum depthFunc) ...@@ -660,6 +719,8 @@ void StateManagerGL::setDepthFunc(GLenum depthFunc)
{ {
mDepthFunc = depthFunc; mDepthFunc = depthFunc;
mFunctions->depthFunc(mDepthFunc); mFunctions->depthFunc(mDepthFunc);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_FUNC);
} }
} }
...@@ -669,6 +730,8 @@ void StateManagerGL::setDepthMask(bool mask) ...@@ -669,6 +730,8 @@ void StateManagerGL::setDepthMask(bool mask)
{ {
mDepthMask = mask; mDepthMask = mask;
mFunctions->depthMask(mDepthMask); mFunctions->depthMask(mDepthMask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_MASK);
} }
} }
...@@ -685,6 +748,8 @@ void StateManagerGL::setStencilTestEnabled(bool enabled) ...@@ -685,6 +748,8 @@ void StateManagerGL::setStencilTestEnabled(bool enabled)
{ {
mFunctions->disable(GL_STENCIL_TEST); mFunctions->disable(GL_STENCIL_TEST);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED);
} }
} }
...@@ -694,6 +759,8 @@ void StateManagerGL::setStencilFrontWritemask(GLuint mask) ...@@ -694,6 +759,8 @@ void StateManagerGL::setStencilFrontWritemask(GLuint mask)
{ {
mStencilFrontWritemask = mask; mStencilFrontWritemask = mask;
mFunctions->stencilMaskSeparate(GL_FRONT, mStencilFrontWritemask); mFunctions->stencilMaskSeparate(GL_FRONT, mStencilFrontWritemask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT);
} }
} }
...@@ -703,6 +770,8 @@ void StateManagerGL::setStencilBackWritemask(GLuint mask) ...@@ -703,6 +770,8 @@ void StateManagerGL::setStencilBackWritemask(GLuint mask)
{ {
mStencilBackWritemask = mask; mStencilBackWritemask = mask;
mFunctions->stencilMaskSeparate(GL_BACK, mStencilBackWritemask); mFunctions->stencilMaskSeparate(GL_BACK, mStencilBackWritemask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK);
} }
} }
...@@ -714,6 +783,8 @@ void StateManagerGL::setStencilFrontFuncs(GLenum func, GLint ref, GLuint mask) ...@@ -714,6 +783,8 @@ void StateManagerGL::setStencilFrontFuncs(GLenum func, GLint ref, GLuint mask)
mStencilFrontRef = ref; mStencilFrontRef = ref;
mStencilFrontValueMask = mask; mStencilFrontValueMask = mask;
mFunctions->stencilFuncSeparate(GL_FRONT, mStencilFrontFunc, mStencilFrontRef, mStencilFrontValueMask); mFunctions->stencilFuncSeparate(GL_FRONT, mStencilFrontFunc, mStencilFrontRef, mStencilFrontValueMask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT);
} }
} }
...@@ -725,6 +796,8 @@ void StateManagerGL::setStencilBackFuncs(GLenum func, GLint ref, GLuint mask) ...@@ -725,6 +796,8 @@ void StateManagerGL::setStencilBackFuncs(GLenum func, GLint ref, GLuint mask)
mStencilBackRef = ref; mStencilBackRef = ref;
mStencilBackValueMask = mask; mStencilBackValueMask = mask;
mFunctions->stencilFuncSeparate(GL_BACK, mStencilBackFunc, mStencilBackRef, mStencilBackValueMask); mFunctions->stencilFuncSeparate(GL_BACK, mStencilBackFunc, mStencilBackRef, mStencilBackValueMask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK);
} }
} }
...@@ -736,6 +809,8 @@ void StateManagerGL::setStencilFrontOps(GLenum sfail, GLenum dpfail, GLenum dppa ...@@ -736,6 +809,8 @@ void StateManagerGL::setStencilFrontOps(GLenum sfail, GLenum dpfail, GLenum dppa
mStencilFrontStencilPassDepthFailOp = dpfail; mStencilFrontStencilPassDepthFailOp = dpfail;
mStencilFrontStencilPassDepthPassOp = dppass; mStencilFrontStencilPassDepthPassOp = dppass;
mFunctions->stencilOpSeparate(GL_FRONT, mStencilFrontStencilFailOp, mStencilFrontStencilPassDepthFailOp, mStencilFrontStencilPassDepthPassOp); mFunctions->stencilOpSeparate(GL_FRONT, mStencilFrontStencilFailOp, mStencilFrontStencilPassDepthFailOp, mStencilFrontStencilPassDepthPassOp);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_OPS_FRONT);
} }
} }
...@@ -747,6 +822,8 @@ void StateManagerGL::setStencilBackOps(GLenum sfail, GLenum dpfail, GLenum dppas ...@@ -747,6 +822,8 @@ void StateManagerGL::setStencilBackOps(GLenum sfail, GLenum dpfail, GLenum dppas
mStencilBackStencilPassDepthFailOp = dpfail; mStencilBackStencilPassDepthFailOp = dpfail;
mStencilBackStencilPassDepthPassOp = dppass; mStencilBackStencilPassDepthPassOp = dppass;
mFunctions->stencilOpSeparate(GL_BACK, mStencilBackStencilFailOp, mStencilBackStencilPassDepthFailOp, mStencilBackStencilPassDepthPassOp); mFunctions->stencilOpSeparate(GL_BACK, mStencilBackStencilFailOp, mStencilBackStencilPassDepthFailOp, mStencilBackStencilPassDepthPassOp);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_OPS_BACK);
} }
} }
...@@ -763,6 +840,8 @@ void StateManagerGL::setCullFaceEnabled(bool enabled) ...@@ -763,6 +840,8 @@ void StateManagerGL::setCullFaceEnabled(bool enabled)
{ {
mFunctions->disable(GL_CULL_FACE); mFunctions->disable(GL_CULL_FACE);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_CULL_FACE_ENABLED);
} }
} }
...@@ -772,6 +851,8 @@ void StateManagerGL::setCullFace(GLenum cullFace) ...@@ -772,6 +851,8 @@ void StateManagerGL::setCullFace(GLenum cullFace)
{ {
mCullFace = cullFace; mCullFace = cullFace;
mFunctions->cullFace(mCullFace); mFunctions->cullFace(mCullFace);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_CULL_FACE);
} }
} }
...@@ -781,6 +862,8 @@ void StateManagerGL::setFrontFace(GLenum frontFace) ...@@ -781,6 +862,8 @@ void StateManagerGL::setFrontFace(GLenum frontFace)
{ {
mFrontFace = frontFace; mFrontFace = frontFace;
mFunctions->frontFace(mFrontFace); mFunctions->frontFace(mFrontFace);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_FRONT_FACE);
} }
} }
...@@ -797,6 +880,8 @@ void StateManagerGL::setPolygonOffsetFillEnabled(bool enabled) ...@@ -797,6 +880,8 @@ void StateManagerGL::setPolygonOffsetFillEnabled(bool enabled)
{ {
mFunctions->disable(GL_POLYGON_OFFSET_FILL); mFunctions->disable(GL_POLYGON_OFFSET_FILL);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_POLYGON_OFFSET_FILL_ENABLED);
} }
} }
...@@ -807,6 +892,8 @@ void StateManagerGL::setPolygonOffset(float factor, float units) ...@@ -807,6 +892,8 @@ void StateManagerGL::setPolygonOffset(float factor, float units)
mPolygonOffsetFactor = factor; mPolygonOffsetFactor = factor;
mPolygonOffsetUnits = units; mPolygonOffsetUnits = units;
mFunctions->polygonOffset(mPolygonOffsetFactor, mPolygonOffsetUnits); mFunctions->polygonOffset(mPolygonOffsetFactor, mPolygonOffsetUnits);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_POLYGON_OFFSET);
} }
} }
...@@ -823,6 +910,8 @@ void StateManagerGL::setMultisampleEnabled(bool enabled) ...@@ -823,6 +910,8 @@ void StateManagerGL::setMultisampleEnabled(bool enabled)
{ {
mFunctions->disable(GL_MULTISAMPLE); mFunctions->disable(GL_MULTISAMPLE);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_MULTISAMPLE_ENABLED);
} }
} }
...@@ -839,6 +928,8 @@ void StateManagerGL::setRasterizerDiscardEnabled(bool enabled) ...@@ -839,6 +928,8 @@ void StateManagerGL::setRasterizerDiscardEnabled(bool enabled)
{ {
mFunctions->disable(GL_RASTERIZER_DISCARD); mFunctions->disable(GL_RASTERIZER_DISCARD);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED);
} }
} }
...@@ -848,6 +939,8 @@ void StateManagerGL::setLineWidth(float width) ...@@ -848,6 +939,8 @@ void StateManagerGL::setLineWidth(float width)
{ {
mLineWidth = width; mLineWidth = width;
mFunctions->lineWidth(mLineWidth); mFunctions->lineWidth(mLineWidth);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_LINE_WIDTH);
} }
} }
...@@ -865,6 +958,8 @@ void StateManagerGL::setPrimitiveRestartEnabled(bool enabled) ...@@ -865,6 +958,8 @@ void StateManagerGL::setPrimitiveRestartEnabled(bool enabled)
{ {
mFunctions->disable(GL_PRIMITIVE_RESTART_FIXED_INDEX); mFunctions->disable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_PRIMITIVE_RESTART_ENABLED);
} }
} }
...@@ -874,6 +969,8 @@ void StateManagerGL::setClearDepth(float clearDepth) ...@@ -874,6 +969,8 @@ void StateManagerGL::setClearDepth(float clearDepth)
{ {
mClearDepth = clearDepth; mClearDepth = clearDepth;
mFunctions->clearDepth(mClearDepth); mFunctions->clearDepth(mClearDepth);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_CLEAR_DEPTH);
} }
} }
...@@ -883,6 +980,8 @@ void StateManagerGL::setClearColor(const gl::ColorF &clearColor) ...@@ -883,6 +980,8 @@ void StateManagerGL::setClearColor(const gl::ColorF &clearColor)
{ {
mClearColor = clearColor; mClearColor = clearColor;
mFunctions->clearColor(mClearColor.red, mClearColor.green, mClearColor.blue, mClearColor.alpha); mFunctions->clearColor(mClearColor.red, mClearColor.green, mClearColor.blue, mClearColor.alpha);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_CLEAR_COLOR);
} }
} }
...@@ -892,13 +991,15 @@ void StateManagerGL::setClearStencil(GLint clearStencil) ...@@ -892,13 +991,15 @@ void StateManagerGL::setClearStencil(GLint clearStencil)
{ {
mClearStencil = clearStencil; mClearStencil = clearStencil;
mFunctions->clearStencil(mClearStencil); mFunctions->clearStencil(mClearStencil);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_CLEAR_STENCIL);
} }
} }
void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits)
{ {
// TODO(jmadill): Investigate only syncing vertex state for active attributes // TODO(jmadill): Investigate only syncing vertex state for active attributes
for (unsigned int dirtyBit : angle::IterateBitSet(dirtyBits)) for (unsigned int dirtyBit : angle::IterateBitSet(dirtyBits | mLocalDirtyBits))
{ {
switch (dirtyBit) switch (dirtyBit)
{ {
...@@ -1100,6 +1201,8 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit ...@@ -1100,6 +1201,8 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit
break; break;
} }
} }
mLocalDirtyBits.reset();
} }
} }
} }
...@@ -49,15 +49,6 @@ class StateManagerGL final : angle::NonCopyable ...@@ -49,15 +49,6 @@ class StateManagerGL final : angle::NonCopyable
void bindFramebuffer(GLenum type, GLuint framebuffer); void bindFramebuffer(GLenum type, GLuint framebuffer);
void bindRenderbuffer(GLenum type, GLuint renderbuffer); void bindRenderbuffer(GLenum type, GLuint renderbuffer);
gl::Error setDrawArraysState(const gl::Data &data, GLint first, GLsizei count);
gl::Error setDrawElementsState(const gl::Data &data, GLsizei count, GLenum type, const GLvoid *indices,
const GLvoid **outIndices);
void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits);
private:
gl::Error setGenericDrawState(const gl::Data &data);
void setAttributeCurrentData(size_t index, const gl::VertexAttribCurrentValueData &data); void setAttributeCurrentData(size_t index, const gl::VertexAttribCurrentValueData &data);
void setScissorTestEnabled(bool enabled); void setScissorTestEnabled(bool enabled);
...@@ -68,7 +59,10 @@ class StateManagerGL final : angle::NonCopyable ...@@ -68,7 +59,10 @@ class StateManagerGL final : angle::NonCopyable
void setBlendEnabled(bool enabled); void setBlendEnabled(bool enabled);
void setBlendColor(const gl::ColorF &blendColor); void setBlendColor(const gl::ColorF &blendColor);
void setBlendFuncs(GLenum sourceBlendRGB, GLenum destBlendRGB, GLenum sourceBlendAlpha, GLenum destBlendAlpha); void setBlendFuncs(GLenum sourceBlendRGB,
GLenum destBlendRGB,
GLenum sourceBlendAlpha,
GLenum destBlendAlpha);
void setBlendEquations(GLenum blendEquationRGB, GLenum blendEquationAlpha); void setBlendEquations(GLenum blendEquationRGB, GLenum blendEquationAlpha);
void setColorMask(bool red, bool green, bool blue, bool alpha); void setColorMask(bool red, bool green, bool blue, bool alpha);
void setSampleAlphaToCoverageEnabled(bool enabled); void setSampleAlphaToCoverageEnabled(bool enabled);
...@@ -111,6 +105,15 @@ class StateManagerGL final : angle::NonCopyable ...@@ -111,6 +105,15 @@ class StateManagerGL final : angle::NonCopyable
void setPixelPackState(const gl::PixelPackState &pack); void setPixelPackState(const gl::PixelPackState &pack);
void setPixelPackState(GLint alignment, GLint rowLength, GLint skipRows, GLint skipPixels); void setPixelPackState(GLint alignment, GLint rowLength, GLint skipRows, GLint skipPixels);
gl::Error setDrawArraysState(const gl::Data &data, GLint first, GLsizei count);
gl::Error setDrawElementsState(const gl::Data &data, GLsizei count, GLenum type, const GLvoid *indices,
const GLvoid **outIndices);
void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits);
private:
gl::Error setGenericDrawState(const gl::Data &data);
const FunctionsGL *mFunctions; const FunctionsGL *mFunctions;
GLuint mProgram; GLuint mProgram;
...@@ -197,6 +200,8 @@ class StateManagerGL final : angle::NonCopyable ...@@ -197,6 +200,8 @@ class StateManagerGL final : angle::NonCopyable
gl::ColorF mClearColor; gl::ColorF mClearColor;
float mClearDepth; float mClearDepth;
GLint mClearStencil; GLint mClearStencil;
gl::State::DirtyBits mLocalDirtyBits;
}; };
} }
......
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