Commit 0f55e3e5 by Alexey Knyazev Committed by Commit Bot

Reland "Remove redundant BlendStateArray tracking"

Rebase the original CL and update capture/replay state serialization Original CL reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2169093 Bug: angleproject:4394 Bug: chromium:1085996 Bug: chromium:1086582 Bug: chromium:1086585 Bug: chromium:1086586 Change-Id: If0fba8b6e185540aed57d22eaf0ff79ec142209e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2404442 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 30d067cf
......@@ -264,10 +264,10 @@ bool IsClearBufferEnabled(const FramebufferState &mState, GLenum buffer, GLint d
return buffer != GL_COLOR || mState.getEnabledDrawBuffers()[drawbuffer];
}
bool IsColorMaskedOut(const BlendState &blend)
bool IsColorMaskedOut(const BlendStateExt &blendStateExt, const GLint drawbuffer)
{
return (!blend.colorMaskRed && !blend.colorMaskGreen && !blend.colorMaskBlue &&
!blend.colorMaskAlpha);
ASSERT(static_cast<size_t>(drawbuffer) < blendStateExt.mMaxDrawBuffers);
return blendStateExt.getColorMaskIndexed(static_cast<size_t>(drawbuffer)) == 0;
}
} // anonymous namespace
......@@ -3816,8 +3816,7 @@ bool Context::isClearBufferMaskedOut(GLenum buffer, GLint drawbuffer) const
switch (buffer)
{
case GL_COLOR:
ASSERT(static_cast<size_t>(drawbuffer) < mState.getBlendStateArray().size());
return IsColorMaskedOut(mState.getBlendStateArray()[drawbuffer]);
return IsColorMaskedOut(mState.getBlendStateExt(), drawbuffer);
case GL_DEPTH:
return mState.getDepthStencilState().isDepthMaskedOut();
case GL_STENCIL:
......
......@@ -134,8 +134,8 @@ class State : angle::NonCopyable
bool allActiveDrawBufferChannelsMasked() const;
bool anyActiveDrawBufferChannelMasked() const;
const RasterizerState &getRasterizerState() const;
const BlendState &getBlendState() const { return mBlendStateArray[0]; }
const BlendStateArray &getBlendStateArray() const { return mBlendStateArray; }
const BlendState &getBlendState() const { return mBlendState; }
const BlendStateExt &getBlendStateExt() const { return mBlendStateExt; }
const DepthStencilState &getDepthStencilState() const;
// Clear behavior setters & state parameter block generation function
......@@ -176,11 +176,11 @@ class State : angle::NonCopyable
float getFarPlane() const { return mFarZ; }
// Blend state manipulation
bool isBlendEnabled() const { return mBlendStateArray[0].blend; }
bool isBlendEnabled() const { return mBlendStateExt.mEnabledMask.test(0); }
bool isBlendEnabledIndexed(GLuint index) const
{
ASSERT(index < mBlendStateArray.size());
return mBlendStateArray[index].blend;
ASSERT(static_cast<size_t>(index) < mBlendStateExt.mMaxDrawBuffers);
return mBlendStateExt.mEnabledMask.test(index);
}
DrawBufferMask getBlendEnabledDrawBufferMask() const { return mBlendStateExt.mEnabledMask; }
void setBlend(bool enabled);
......@@ -858,8 +858,6 @@ class State : angle::NonCopyable
const std::vector<ImageUnit> getImageUnits() const { return mImageUnits; }
const BlendStateExt &getBlendStateExt() const { return mBlendStateExt; }
private:
friend class Context;
......@@ -957,7 +955,7 @@ class State : angle::NonCopyable
bool mScissorTest;
Rectangle mScissor;
BlendStateArray mBlendStateArray;
BlendState mBlendState; // Buffer zero blend state legacy struct
BlendStateExt mBlendStateExt;
ColorF mBlendColor;
bool mSampleAlphaToCoverage;
......
......@@ -189,8 +189,6 @@ struct BlendState final
bool operator==(const BlendState &a, const BlendState &b);
bool operator!=(const BlendState &a, const BlendState &b);
using BlendStateArray = std::array<BlendState, IMPLEMENTATION_MAX_DRAW_BUFFERS>;
struct DepthStencilState final
{
// This will zero-initialize the struct, including padding.
......
......@@ -235,19 +235,16 @@ void SerializeRectangle(gl::BinaryOutputStream *bos, const gl::Rectangle &rectan
bos->writeInt(rectangle.height);
}
void SerializeBlendState(gl::BinaryOutputStream *bos, const gl::BlendState &blendState)
void SerializeBlendStateExt(gl::BinaryOutputStream *bos, const gl::BlendStateExt &blendStateExt)
{
bos->writeInt(blendState.blend);
bos->writeInt(blendState.sourceBlendRGB);
bos->writeInt(blendState.destBlendRGB);
bos->writeInt(blendState.sourceBlendAlpha);
bos->writeInt(blendState.destBlendAlpha);
bos->writeInt(blendState.blendEquationRGB);
bos->writeInt(blendState.blendEquationAlpha);
bos->writeInt(blendState.colorMaskRed);
bos->writeInt(blendState.colorMaskGreen);
bos->writeInt(blendState.colorMaskBlue);
bos->writeInt(blendState.colorMaskAlpha);
bos->writeInt(blendStateExt.mEnabledMask.bits());
bos->writeInt(blendStateExt.mDstColor);
bos->writeInt(blendStateExt.mDstAlpha);
bos->writeInt(blendStateExt.mSrcColor);
bos->writeInt(blendStateExt.mSrcAlpha);
bos->writeInt(blendStateExt.mEquationColor);
bos->writeInt(blendStateExt.mEquationAlpha);
bos->writeInt(blendStateExt.mColorMask);
}
void SerializeDepthStencilState(gl::BinaryOutputStream *bos,
......@@ -346,11 +343,7 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat
SerializeRasterizerState(bos, state.getRasterizerState());
bos->writeInt(state.isScissorTestEnabled());
SerializeRectangle(bos, state.getScissor());
const gl::BlendStateArray &blendStateArray = state.getBlendStateArray();
for (size_t i = 0; i < blendStateArray.size(); i++)
{
SerializeBlendState(bos, blendStateArray[i]);
}
SerializeBlendStateExt(bos, state.getBlendStateExt());
SerializeColor(bos, state.getBlendColor());
bos->writeInt(state.isSampleAlphaToCoverageEnabled());
bos->writeInt(state.isSampleCoverageEnabled());
......
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