Commit caf7becc by Alexey Knyazev Committed by Commit Bot

Move dither from blend state to rasterizer state

Dither is technically not a part of blend state so it was removed from there as a first step towards exposing OES_draw_buffers_indexed (that defines independent blend state for each draw buffer). Rasterizer state seems to be the closest (although also not accurate) place for it to keep code changes to a minimum. ANGLE's D3D11, Vulkan, and Metal renderers ignore dithering altogether. Bug: angleproject:4394 Change-Id: Ib138624b9218851d18cd63e2033e8e8ac8ca71d9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2050464Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 92b00ca8
...@@ -898,7 +898,7 @@ void State::setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height) ...@@ -898,7 +898,7 @@ void State::setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height)
void State::setDither(bool enabled) void State::setDither(bool enabled)
{ {
mBlend.dither = enabled; mRasterizer.dither = enabled;
mDirtyBits.set(DIRTY_BIT_DITHER_ENABLED); mDirtyBits.set(DIRTY_BIT_DITHER_ENABLED);
} }
...@@ -1906,7 +1906,7 @@ void State::getBooleanv(GLenum pname, GLboolean *params) ...@@ -1906,7 +1906,7 @@ void State::getBooleanv(GLenum pname, GLboolean *params)
*params = mBlend.blend; *params = mBlend.blend;
break; break;
case GL_DITHER: case GL_DITHER:
*params = mBlend.dither; *params = mRasterizer.dither;
break; break;
case GL_TRANSFORM_FEEDBACK_ACTIVE: case GL_TRANSFORM_FEEDBACK_ACTIVE:
*params = getCurrentTransformFeedback()->isActive() ? GL_TRUE : GL_FALSE; *params = getCurrentTransformFeedback()->isActive() ? GL_TRUE : GL_FALSE;
......
...@@ -207,7 +207,7 @@ class State : angle::NonCopyable ...@@ -207,7 +207,7 @@ class State : angle::NonCopyable
const Rectangle &getScissor() const { return mScissor; } const Rectangle &getScissor() const { return mScissor; }
// Dither state toggle & query // Dither state toggle & query
bool isDitherEnabled() const { return mBlend.dither; } bool isDitherEnabled() const { return mRasterizer.dither; }
void setDither(bool enabled); void setDither(bool enabled);
// Generic state toggle & query // Generic state toggle & query
......
...@@ -27,6 +27,12 @@ RasterizerState::RasterizerState() ...@@ -27,6 +27,12 @@ RasterizerState::RasterizerState()
polygonOffsetUnits = 0.0f; polygonOffsetUnits = 0.0f;
pointDrawMode = false; pointDrawMode = false;
multiSample = false; multiSample = false;
dither = true;
}
RasterizerState::RasterizerState(const RasterizerState &other)
{
memcpy(this, &other, sizeof(RasterizerState));
} }
bool operator==(const RasterizerState &a, const RasterizerState &b) bool operator==(const RasterizerState &a, const RasterizerState &b)
...@@ -51,7 +57,6 @@ BlendState::BlendState() ...@@ -51,7 +57,6 @@ BlendState::BlendState()
blendEquationRGB = GL_FUNC_ADD; blendEquationRGB = GL_FUNC_ADD;
blendEquationAlpha = GL_FUNC_ADD; blendEquationAlpha = GL_FUNC_ADD;
sampleAlphaToCoverage = false; sampleAlphaToCoverage = false;
dither = true;
colorMaskRed = true; colorMaskRed = true;
colorMaskGreen = true; colorMaskGreen = true;
colorMaskBlue = true; colorMaskBlue = true;
......
...@@ -127,6 +127,7 @@ struct RasterizerState final ...@@ -127,6 +127,7 @@ struct RasterizerState final
{ {
// This will zero-initialize the struct, including padding. // This will zero-initialize the struct, including padding.
RasterizerState(); RasterizerState();
RasterizerState(const RasterizerState &other);
bool cullFace; bool cullFace;
CullFaceMode cullMode; CullFaceMode cullMode;
...@@ -140,6 +141,8 @@ struct RasterizerState final ...@@ -140,6 +141,8 @@ struct RasterizerState final
bool multiSample; bool multiSample;
bool rasterizerDiscard; bool rasterizerDiscard;
bool dither;
}; };
bool operator==(const RasterizerState &a, const RasterizerState &b); bool operator==(const RasterizerState &a, const RasterizerState &b);
...@@ -167,8 +170,6 @@ struct BlendState final ...@@ -167,8 +170,6 @@ struct BlendState final
bool colorMaskAlpha; bool colorMaskAlpha;
bool sampleAlphaToCoverage; bool sampleAlphaToCoverage;
bool dither;
}; };
bool operator==(const BlendState &a, const BlendState &b); bool operator==(const BlendState &a, const BlendState &b);
......
...@@ -295,7 +295,6 @@ angle::Result Clear11::ensureResourcesInitialized(const gl::Context *context) ...@@ -295,7 +295,6 @@ angle::Result Clear11::ensureResourcesInitialized(const gl::Context *context)
mBlendStateKey.blendState.blendEquationRGB = GL_FUNC_ADD; mBlendStateKey.blendState.blendEquationRGB = GL_FUNC_ADD;
mBlendStateKey.blendState.blendEquationAlpha = GL_FUNC_ADD; mBlendStateKey.blendState.blendEquationAlpha = GL_FUNC_ADD;
mBlendStateKey.blendState.sampleAlphaToCoverage = false; mBlendStateKey.blendState.sampleAlphaToCoverage = false;
mBlendStateKey.blendState.dither = true;
mResourcesInitialized = true; mResourcesInitialized = true;
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -711,7 +711,6 @@ StateManager11::StateManager11(Renderer11 *renderer) ...@@ -711,7 +711,6 @@ StateManager11::StateManager11(Renderer11 *renderer)
mCurBlendState.colorMaskGreen = true; mCurBlendState.colorMaskGreen = true;
mCurBlendState.colorMaskAlpha = true; mCurBlendState.colorMaskAlpha = true;
mCurBlendState.sampleAlphaToCoverage = false; mCurBlendState.sampleAlphaToCoverage = false;
mCurBlendState.dither = false;
mCurDepthStencilState.depthTest = false; mCurDepthStencilState.depthTest = false;
mCurDepthStencilState.depthFunc = GL_LESS; mCurDepthStencilState.depthFunc = GL_LESS;
...@@ -738,6 +737,7 @@ StateManager11::StateManager11(Renderer11 *renderer) ...@@ -738,6 +737,7 @@ StateManager11::StateManager11(Renderer11 *renderer)
mCurRasterState.polygonOffsetUnits = 0.0f; mCurRasterState.polygonOffsetUnits = 0.0f;
mCurRasterState.pointDrawMode = false; mCurRasterState.pointDrawMode = false;
mCurRasterState.multiSample = false; mCurRasterState.multiSample = false;
mCurRasterState.dither = false;
// Start with all internal dirty bits set except DIRTY_BIT_COMPUTE_SRVUAV_STATE and // Start with all internal dirty bits set except DIRTY_BIT_COMPUTE_SRVUAV_STATE and
// DIRTY_BIT_GRAPHICS_SRVUAV_STATE. // DIRTY_BIT_GRAPHICS_SRVUAV_STATE.
...@@ -993,9 +993,9 @@ void StateManager11::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -993,9 +993,9 @@ void StateManager11::syncState(const gl::Context *context, const gl::State::Dirt
} }
break; break;
case gl::State::DIRTY_BIT_DITHER_ENABLED: case gl::State::DIRTY_BIT_DITHER_ENABLED:
if (state.getBlendState().dither != mCurBlendState.dither) if (state.getRasterizerState().dither != mCurRasterState.dither)
{ {
mInternalDirtyBits.set(DIRTY_BIT_BLEND_STATE); mInternalDirtyBits.set(DIRTY_BIT_RASTERIZER_STATE);
} }
break; break;
case gl::State::DIRTY_BIT_COLOR_MASK: case gl::State::DIRTY_BIT_COLOR_MASK:
......
...@@ -201,7 +201,7 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits ...@@ -201,7 +201,7 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits
break; break;
} }
case gl::State::DIRTY_BIT_DITHER_ENABLED: case gl::State::DIRTY_BIT_DITHER_ENABLED:
if (state.getBlendState().dither != mCurBlendState.dither) if (state.getRasterizerState().dither != mCurRasterState.dither)
{ {
mDirtyBits.set(DIRTY_BIT_DITHER); mDirtyBits.set(DIRTY_BIT_DITHER);
} }
...@@ -361,7 +361,7 @@ void StateManager9::setBlendDepthRasterStates(const gl::State &glState, unsigned ...@@ -361,7 +361,7 @@ void StateManager9::setBlendDepthRasterStates(const gl::State &glState, unsigned
blendState.colorMaskGreen, blendState.colorMaskAlpha); blendState.colorMaskGreen, blendState.colorMaskAlpha);
break; break;
case DIRTY_BIT_DITHER: case DIRTY_BIT_DITHER:
setDither(blendState.dither); setDither(rasterState.dither);
break; break;
case DIRTY_BIT_CULL_MODE: case DIRTY_BIT_CULL_MODE:
setCullMode(rasterState.cullFace, rasterState.cullMode, rasterState.frontFace); setCullMode(rasterState.cullFace, rasterState.cullMode, rasterState.frontFace);
...@@ -763,7 +763,7 @@ void StateManager9::setBlendEnabled(bool enabled) ...@@ -763,7 +763,7 @@ void StateManager9::setBlendEnabled(bool enabled)
void StateManager9::setDither(bool dither) void StateManager9::setDither(bool dither)
{ {
mRenderer9->getDevice()->SetRenderState(D3DRS_DITHERENABLE, dither ? TRUE : FALSE); mRenderer9->getDevice()->SetRenderState(D3DRS_DITHERENABLE, dither ? TRUE : FALSE);
mCurBlendState.dither = dither; mCurRasterState.dither = dither;
} }
// TODO(dianx) one bit for color mask // TODO(dianx) one bit for color mask
......
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