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 ...@@ -264,10 +264,10 @@ bool IsClearBufferEnabled(const FramebufferState &mState, GLenum buffer, GLint d
return buffer != GL_COLOR || mState.getEnabledDrawBuffers()[drawbuffer]; 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 && ASSERT(static_cast<size_t>(drawbuffer) < blendStateExt.mMaxDrawBuffers);
!blend.colorMaskAlpha); return blendStateExt.getColorMaskIndexed(static_cast<size_t>(drawbuffer)) == 0;
} }
} // anonymous namespace } // anonymous namespace
...@@ -3816,8 +3816,7 @@ bool Context::isClearBufferMaskedOut(GLenum buffer, GLint drawbuffer) const ...@@ -3816,8 +3816,7 @@ bool Context::isClearBufferMaskedOut(GLenum buffer, GLint drawbuffer) const
switch (buffer) switch (buffer)
{ {
case GL_COLOR: case GL_COLOR:
ASSERT(static_cast<size_t>(drawbuffer) < mState.getBlendStateArray().size()); return IsColorMaskedOut(mState.getBlendStateExt(), drawbuffer);
return IsColorMaskedOut(mState.getBlendStateArray()[drawbuffer]);
case GL_DEPTH: case GL_DEPTH:
return mState.getDepthStencilState().isDepthMaskedOut(); return mState.getDepthStencilState().isDepthMaskedOut();
case GL_STENCIL: case GL_STENCIL:
......
...@@ -134,8 +134,8 @@ class State : angle::NonCopyable ...@@ -134,8 +134,8 @@ class State : angle::NonCopyable
bool allActiveDrawBufferChannelsMasked() const; bool allActiveDrawBufferChannelsMasked() const;
bool anyActiveDrawBufferChannelMasked() const; bool anyActiveDrawBufferChannelMasked() const;
const RasterizerState &getRasterizerState() const; const RasterizerState &getRasterizerState() const;
const BlendState &getBlendState() const { return mBlendStateArray[0]; } const BlendState &getBlendState() const { return mBlendState; }
const BlendStateArray &getBlendStateArray() const { return mBlendStateArray; } const BlendStateExt &getBlendStateExt() const { return mBlendStateExt; }
const DepthStencilState &getDepthStencilState() const; const DepthStencilState &getDepthStencilState() const;
// Clear behavior setters & state parameter block generation function // Clear behavior setters & state parameter block generation function
...@@ -176,11 +176,11 @@ class State : angle::NonCopyable ...@@ -176,11 +176,11 @@ class State : angle::NonCopyable
float getFarPlane() const { return mFarZ; } float getFarPlane() const { return mFarZ; }
// Blend state manipulation // Blend state manipulation
bool isBlendEnabled() const { return mBlendStateArray[0].blend; } bool isBlendEnabled() const { return mBlendStateExt.mEnabledMask.test(0); }
bool isBlendEnabledIndexed(GLuint index) const bool isBlendEnabledIndexed(GLuint index) const
{ {
ASSERT(index < mBlendStateArray.size()); ASSERT(static_cast<size_t>(index) < mBlendStateExt.mMaxDrawBuffers);
return mBlendStateArray[index].blend; return mBlendStateExt.mEnabledMask.test(index);
} }
DrawBufferMask getBlendEnabledDrawBufferMask() const { return mBlendStateExt.mEnabledMask; } DrawBufferMask getBlendEnabledDrawBufferMask() const { return mBlendStateExt.mEnabledMask; }
void setBlend(bool enabled); void setBlend(bool enabled);
...@@ -858,8 +858,6 @@ class State : angle::NonCopyable ...@@ -858,8 +858,6 @@ class State : angle::NonCopyable
const std::vector<ImageUnit> getImageUnits() const { return mImageUnits; } const std::vector<ImageUnit> getImageUnits() const { return mImageUnits; }
const BlendStateExt &getBlendStateExt() const { return mBlendStateExt; }
private: private:
friend class Context; friend class Context;
...@@ -957,7 +955,7 @@ class State : angle::NonCopyable ...@@ -957,7 +955,7 @@ class State : angle::NonCopyable
bool mScissorTest; bool mScissorTest;
Rectangle mScissor; Rectangle mScissor;
BlendStateArray mBlendStateArray; BlendState mBlendState; // Buffer zero blend state legacy struct
BlendStateExt mBlendStateExt; BlendStateExt mBlendStateExt;
ColorF mBlendColor; ColorF mBlendColor;
bool mSampleAlphaToCoverage; bool mSampleAlphaToCoverage;
......
...@@ -189,8 +189,6 @@ struct BlendState final ...@@ -189,8 +189,6 @@ struct BlendState final
bool operator==(const BlendState &a, const BlendState &b); bool operator==(const BlendState &a, const BlendState &b);
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 struct DepthStencilState final
{ {
// This will zero-initialize the struct, including padding. // This will zero-initialize the struct, including padding.
......
...@@ -235,19 +235,16 @@ void SerializeRectangle(gl::BinaryOutputStream *bos, const gl::Rectangle &rectan ...@@ -235,19 +235,16 @@ void SerializeRectangle(gl::BinaryOutputStream *bos, const gl::Rectangle &rectan
bos->writeInt(rectangle.height); 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(blendStateExt.mEnabledMask.bits());
bos->writeInt(blendState.sourceBlendRGB); bos->writeInt(blendStateExt.mDstColor);
bos->writeInt(blendState.destBlendRGB); bos->writeInt(blendStateExt.mDstAlpha);
bos->writeInt(blendState.sourceBlendAlpha); bos->writeInt(blendStateExt.mSrcColor);
bos->writeInt(blendState.destBlendAlpha); bos->writeInt(blendStateExt.mSrcAlpha);
bos->writeInt(blendState.blendEquationRGB); bos->writeInt(blendStateExt.mEquationColor);
bos->writeInt(blendState.blendEquationAlpha); bos->writeInt(blendStateExt.mEquationAlpha);
bos->writeInt(blendState.colorMaskRed); bos->writeInt(blendStateExt.mColorMask);
bos->writeInt(blendState.colorMaskGreen);
bos->writeInt(blendState.colorMaskBlue);
bos->writeInt(blendState.colorMaskAlpha);
} }
void SerializeDepthStencilState(gl::BinaryOutputStream *bos, void SerializeDepthStencilState(gl::BinaryOutputStream *bos,
...@@ -346,11 +343,7 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat ...@@ -346,11 +343,7 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat
SerializeRasterizerState(bos, state.getRasterizerState()); SerializeRasterizerState(bos, state.getRasterizerState());
bos->writeInt(state.isScissorTestEnabled()); bos->writeInt(state.isScissorTestEnabled());
SerializeRectangle(bos, state.getScissor()); SerializeRectangle(bos, state.getScissor());
const gl::BlendStateArray &blendStateArray = state.getBlendStateArray(); SerializeBlendStateExt(bos, state.getBlendStateExt());
for (size_t i = 0; i < blendStateArray.size(); i++)
{
SerializeBlendState(bos, blendStateArray[i]);
}
SerializeColor(bos, state.getBlendColor()); SerializeColor(bos, state.getBlendColor());
bos->writeInt(state.isSampleAlphaToCoverageEnabled()); bos->writeInt(state.isSampleAlphaToCoverageEnabled());
bos->writeInt(state.isSampleCoverageEnabled()); 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