Commit 38bb9fdf by Corentin Wallez Committed by Commit Bot

Revert "Move sampleAlphaToCoverage out of blendState"

This reverts commit f6e73131. Reason for revert: Crashes on Win10 FYI x64 Debug (NVIDIA) and Win7 FYI Debug (AMD) in the webgl CTS Original change's description: > Move sampleAlphaToCoverage out of blendState > > This is the second step towards exposing OES_draw_buffers_indexed (that defines independent blend state for each draw buffer). This flag is global in all graphics APIs, however D3D11 technically puts it in the blend state. > > D3D11: BlendStateKey was extended to keep existing D3D11 state caching semantics. > > D3D9: a comment was added explaining why this feature was never implemented there. > > Bug: angleproject:4394 > Change-Id: Ie6a294eeb6fcf4c868a1f1001c4f7efd61692ccd > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057063 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Geoff Lang <geofflang@chromium.org> TBR=geofflang@chromium.org,jmadill@chromium.org,lexa.knyazev@gmail.com Change-Id: I650624b5dfb7f2777c316906b9145a411243f42f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:4394 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2062605Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 90c9f66c
......@@ -293,7 +293,6 @@ State::State(ContextID contextIn,
mDepthClearValue(0),
mStencilClearValue(0),
mScissorTest(false),
mSampleAlphaToCoverage(false),
mSampleCoverage(false),
mSampleCoverageValue(0),
mSampleCoverageInvert(false),
......@@ -839,7 +838,7 @@ void State::setPolygonOffsetParams(GLfloat factor, GLfloat units)
void State::setSampleAlphaToCoverage(bool enabled)
{
mSampleAlphaToCoverage = enabled;
mBlend.sampleAlphaToCoverage = enabled;
mDirtyBits.set(DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED);
}
......@@ -1886,7 +1885,7 @@ void State::getBooleanv(GLenum pname, GLboolean *params)
*params = mRasterizer.polygonOffsetFill;
break;
case GL_SAMPLE_ALPHA_TO_COVERAGE:
*params = mSampleAlphaToCoverage;
*params = mBlend.sampleAlphaToCoverage;
break;
case GL_SAMPLE_COVERAGE:
*params = mSampleCoverage;
......
......@@ -175,7 +175,7 @@ class State : angle::NonCopyable
void setPolygonOffsetParams(GLfloat factor, GLfloat units);
// Multisample coverage state manipulation
bool isSampleAlphaToCoverageEnabled() const { return mSampleAlphaToCoverage; }
bool isSampleAlphaToCoverageEnabled() const { return mBlend.sampleAlphaToCoverage; }
void setSampleAlphaToCoverage(bool enabled);
bool isSampleCoverageEnabled() const { return mSampleCoverage; }
void setSampleCoverage(bool enabled);
......@@ -808,7 +808,6 @@ class State : angle::NonCopyable
BlendState mBlend;
ColorF mBlendColor;
bool mSampleAlphaToCoverage;
bool mSampleCoverage;
GLfloat mSampleCoverageValue;
bool mSampleCoverageInvert;
......
......@@ -49,17 +49,18 @@ BlendState::BlendState()
{
memset(this, 0, sizeof(BlendState));
blend = false;
sourceBlendRGB = GL_ONE;
sourceBlendAlpha = GL_ONE;
destBlendRGB = GL_ZERO;
destBlendAlpha = GL_ZERO;
blendEquationRGB = GL_FUNC_ADD;
blendEquationAlpha = GL_FUNC_ADD;
colorMaskRed = true;
colorMaskGreen = true;
colorMaskBlue = true;
colorMaskAlpha = true;
blend = false;
sourceBlendRGB = GL_ONE;
sourceBlendAlpha = GL_ONE;
destBlendRGB = GL_ZERO;
destBlendAlpha = GL_ZERO;
blendEquationRGB = GL_FUNC_ADD;
blendEquationAlpha = GL_FUNC_ADD;
sampleAlphaToCoverage = false;
colorMaskRed = true;
colorMaskGreen = true;
colorMaskBlue = true;
colorMaskAlpha = true;
}
BlendState::BlendState(const BlendState &other)
......
......@@ -168,6 +168,8 @@ struct BlendState final
bool colorMaskGreen;
bool colorMaskBlue;
bool colorMaskAlpha;
bool sampleAlphaToCoverage;
};
bool operator==(const BlendState &a, const BlendState &b);
......
......@@ -287,13 +287,14 @@ angle::Result Clear11::ensureResourcesInitialized(const gl::Context *context)
mDepthStencilStateKey.stencilBackFunc = GL_ALWAYS;
// Initialize BlendStateKey with defaults
mBlendStateKey.blendState.blend = false;
mBlendStateKey.blendState.sourceBlendRGB = GL_ONE;
mBlendStateKey.blendState.sourceBlendAlpha = GL_ONE;
mBlendStateKey.blendState.destBlendRGB = GL_ZERO;
mBlendStateKey.blendState.destBlendAlpha = GL_ZERO;
mBlendStateKey.blendState.blendEquationRGB = GL_FUNC_ADD;
mBlendStateKey.blendState.blendEquationAlpha = GL_FUNC_ADD;
mBlendStateKey.blendState.blend = false;
mBlendStateKey.blendState.sourceBlendRGB = GL_ONE;
mBlendStateKey.blendState.sourceBlendAlpha = GL_ONE;
mBlendStateKey.blendState.destBlendRGB = GL_ZERO;
mBlendStateKey.blendState.destBlendAlpha = GL_ZERO;
mBlendStateKey.blendState.blendEquationRGB = GL_FUNC_ADD;
mBlendStateKey.blendState.blendEquationAlpha = GL_FUNC_ADD;
mBlendStateKey.blendState.sampleAlphaToCoverage = false;
mResourcesInitialized = true;
return angle::Result::Continue;
......@@ -645,7 +646,7 @@ angle::Result Clear11::clearFramebuffer(const gl::Context *context,
mBlendStateKey.blendState.colorMaskGreen = clearParams.colorMaskGreen;
mBlendStateKey.blendState.colorMaskBlue = clearParams.colorMaskBlue;
mBlendStateKey.blendState.colorMaskAlpha = clearParams.colorMaskAlpha;
mBlendStateKey.rtvMax = static_cast<uint8_t>(numRtvs);
mBlendStateKey.rtvMax = numRtvs;
memcpy(mBlendStateKey.rtvMasks, &rtvMasks[0], sizeof(mBlendStateKey.rtvMasks));
// Get BlendState
......
......@@ -45,8 +45,7 @@ void RenderStateCache::clear()
// static
d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *context,
Framebuffer11 *framebuffer11,
const gl::BlendState &blendState,
bool sampleAlphaToCoverage)
const gl::BlendState &blendState)
{
d3d11::BlendStateKey key;
const gl::AttachmentList &colorbuffers = framebuffer11->getColorAttachmentsForRender(context);
......@@ -54,8 +53,7 @@ d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *conte
gl_d3d11::ConvertColorMask(blendState.colorMaskRed, blendState.colorMaskGreen,
blendState.colorMaskBlue, blendState.colorMaskAlpha);
key.blendState = blendState;
key.sampleAlphaToCoverage = sampleAlphaToCoverage;
key.blendState = blendState;
for (size_t i = 0; i < colorbuffers.size(); i++)
{
......@@ -63,7 +61,7 @@ d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *conte
if (attachment)
{
key.rtvMax = static_cast<uint8_t>(i) + 1;
key.rtvMax = static_cast<uint32_t>(i) + 1;
key.rtvMasks[i] =
(gl_d3d11::GetColorMask(*attachment->getFormat().info)) & blendStateMask;
}
......@@ -91,7 +89,7 @@ angle::Result RenderStateCache::getBlendState(const gl::Context *context,
D3D11_RENDER_TARGET_BLEND_DESC &rtDesc0 = blendDesc.RenderTarget[0];
const gl::BlendState &blendState = key.blendState;
blendDesc.AlphaToCoverageEnable = key.sampleAlphaToCoverage;
blendDesc.AlphaToCoverageEnable = blendState.sampleAlphaToCoverage;
blendDesc.IndependentBlendEnable = key.rtvMax > 1 ? TRUE : FALSE;
rtDesc0 = {};
......
......@@ -69,8 +69,7 @@ class RenderStateCache : angle::NonCopyable
static d3d11::BlendStateKey GetBlendStateKey(const gl::Context *context,
Framebuffer11 *framebuffer11,
const gl::BlendState &blendState,
bool sampleAlphaToCoverage);
const gl::BlendState &blendState);
angle::Result getBlendState(const gl::Context *context,
Renderer11 *renderer,
const d3d11::BlendStateKey &key,
......
......@@ -665,7 +665,6 @@ angle::Result ShaderConstants11::updateBuffer(const gl::Context *context,
StateManager11::StateManager11(Renderer11 *renderer)
: mRenderer(renderer),
mInternalDirtyBits(),
mCurSampleAlphaToCoverage(false),
mCurBlendColor(0, 0, 0, 0),
mCurSampleMask(0),
mCurStencilRef(0),
......@@ -700,17 +699,18 @@ StateManager11::StateManager11(Renderer11 *renderer)
mVertexArray11(nullptr),
mFramebuffer11(nullptr)
{
mCurBlendState.blend = false;
mCurBlendState.sourceBlendRGB = GL_ONE;
mCurBlendState.destBlendRGB = GL_ZERO;
mCurBlendState.sourceBlendAlpha = GL_ONE;
mCurBlendState.destBlendAlpha = GL_ZERO;
mCurBlendState.blendEquationRGB = GL_FUNC_ADD;
mCurBlendState.blendEquationAlpha = GL_FUNC_ADD;
mCurBlendState.colorMaskRed = true;
mCurBlendState.colorMaskBlue = true;
mCurBlendState.colorMaskGreen = true;
mCurBlendState.colorMaskAlpha = true;
mCurBlendState.blend = false;
mCurBlendState.sourceBlendRGB = GL_ONE;
mCurBlendState.destBlendRGB = GL_ZERO;
mCurBlendState.sourceBlendAlpha = GL_ONE;
mCurBlendState.destBlendAlpha = GL_ZERO;
mCurBlendState.blendEquationRGB = GL_FUNC_ADD;
mCurBlendState.blendEquationAlpha = GL_FUNC_ADD;
mCurBlendState.colorMaskRed = true;
mCurBlendState.colorMaskBlue = true;
mCurBlendState.colorMaskGreen = true;
mCurBlendState.colorMaskAlpha = true;
mCurBlendState.sampleAlphaToCoverage = false;
mCurDepthStencilState.depthTest = false;
mCurDepthStencilState.depthFunc = GL_LESS;
......@@ -986,7 +986,8 @@ void StateManager11::syncState(const gl::Context *context, const gl::State::Dirt
}
break;
case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED:
if (state.isSampleAlphaToCoverageEnabled() != mCurSampleAlphaToCoverage)
if (state.getBlendState().sampleAlphaToCoverage !=
mCurBlendState.sampleAlphaToCoverage)
{
mInternalDirtyBits.set(DIRTY_BIT_BLEND_STATE);
}
......@@ -1231,12 +1232,11 @@ void StateManager11::handleMultiviewDrawFramebufferChange(const gl::Context *con
angle::Result StateManager11::syncBlendState(const gl::Context *context,
const gl::BlendState &blendState,
const gl::ColorF &blendColor,
unsigned int sampleMask,
bool sampleAlphaToCoverage)
unsigned int sampleMask)
{
const d3d11::BlendState *dxBlendState = nullptr;
const d3d11::BlendStateKey &key = RenderStateCache::GetBlendStateKey(
context, mFramebuffer11, blendState, sampleAlphaToCoverage);
const d3d11::BlendStateKey &key =
RenderStateCache::GetBlendStateKey(context, mFramebuffer11, blendState);
ANGLE_TRY(mRenderer->getBlendState(context, key, &dxBlendState));
......@@ -1263,10 +1263,9 @@ angle::Result StateManager11::syncBlendState(const gl::Context *context,
mRenderer->getDeviceContext()->OMSetBlendState(dxBlendState->get(), blendColors, sampleMask);
mCurBlendState = blendState;
mCurBlendColor = blendColor;
mCurSampleMask = sampleMask;
mCurSampleAlphaToCoverage = sampleAlphaToCoverage;
mCurBlendState = blendState;
mCurBlendColor = blendColor;
mCurSampleMask = sampleMask;
return angle::Result::Continue;
}
......@@ -2249,7 +2248,7 @@ angle::Result StateManager11::updateState(const gl::Context *context,
break;
case DIRTY_BIT_BLEND_STATE:
ANGLE_TRY(syncBlendState(context, glState.getBlendState(), glState.getBlendColor(),
sampleMask, glState.isSampleAlphaToCoverageEnabled()));
sampleMask));
break;
case DIRTY_BIT_DEPTH_STENCIL_STATE:
ANGLE_TRY(syncDepthStencilState(context));
......
......@@ -315,8 +315,7 @@ class StateManager11 final : angle::NonCopyable
angle::Result syncBlendState(const gl::Context *context,
const gl::BlendState &blendState,
const gl::ColorF &blendColor,
unsigned int sampleMask,
bool sampleAlphaToCoverage);
unsigned int sampleMask);
angle::Result syncDepthStencilState(const gl::Context *context);
......@@ -462,8 +461,6 @@ class StateManager11 final : angle::NonCopyable
DirtyBits mGraphicsDirtyBitsMask;
DirtyBits mComputeDirtyBitsMask;
bool mCurSampleAlphaToCoverage;
// Blend State
gl::BlendState mCurBlendState;
gl::ColorF mCurBlendColor;
......
......@@ -149,11 +149,10 @@ struct BlendStateKey final
gl::BlendState blendState;
uint8_t rtvMasks[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
// An int so struct size rounds nicely.
uint32_t rtvMax;
// Keep two 1-byte values at the end, so struct size rounds nicely.
uint8_t rtvMax;
bool sampleAlphaToCoverage;
uint8_t rtvMasks[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
};
bool operator==(const BlendStateKey &a, const BlendStateKey &b);
......
......@@ -19,7 +19,6 @@ namespace rx
StateManager9::StateManager9(Renderer9 *renderer9)
: mUsingZeroColorMaskWorkaround(false),
mCurSampleAlphaToCoverage(false),
mCurBlendState(),
mCurBlendColor(0, 0, 0, 0),
mCurSampleMask(0),
......@@ -175,7 +174,8 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits
break;
}
case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED:
if (state.isSampleAlphaToCoverageEnabled() != mCurSampleAlphaToCoverage)
if (state.getBlendState().sampleAlphaToCoverage !=
mCurBlendState.sampleAlphaToCoverage)
{
mDirtyBits.set(DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE);
}
......@@ -354,7 +354,7 @@ void StateManager9::setBlendDepthRasterStates(const gl::State &glState, unsigned
setBlendFuncsEquations(blendState);
break;
case DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE:
setSampleAlphaToCoverage(glState.isSampleAlphaToCoverageEnabled());
setSampleAlphaToCoverage(blendState.sampleAlphaToCoverage);
break;
case DIRTY_BIT_COLOR_MASK:
setColorMask(framebuffer, blendState.colorMaskRed, blendState.colorMaskBlue,
......@@ -692,8 +692,7 @@ void StateManager9::setSampleAlphaToCoverage(bool enabled)
{
if (enabled)
{
// D3D9 support for alpha-to-coverage is vendor-specific.
UNIMPLEMENTED();
UNREACHABLE();
}
}
......
......@@ -159,8 +159,6 @@ class StateManager9 final : angle::NonCopyable
bool mUsingZeroColorMaskWorkaround;
bool mCurSampleAlphaToCoverage;
// Currently applied blend state
gl::BlendState mCurBlendState;
gl::ColorF mCurBlendColor;
......
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