Commit 51f40ecd by Jamie Madill Committed by Commit Bot

Make Framebuffer::checkStatus non-const.

BUG=angleproject:1388 Change-Id: Ia9befba0c915c087f2fe0557d91060256f6d4950 Reviewed-on: https://chromium-review.googlesource.com/348955Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent a9d60da8
......@@ -7,6 +7,8 @@
// Data.cpp: Container class for all GL relevant state, caps and objects
#include "libANGLE/ContextState.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/ResourceManager.h"
namespace gl
......
......@@ -388,7 +388,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const
return false;
}
GLenum Framebuffer::checkStatus(const ContextState &state) const
GLenum Framebuffer::checkStatus(const ContextState &state)
{
// The default framebuffer *must* always be complete, though it may not be
// subject to the same rules as application FBOs. ie, it could have 0x0 size.
......@@ -743,7 +743,7 @@ Error Framebuffer::blit(rx::ContextImpl *context,
return mImpl->blit(context, sourceArea, destArea, mask, filter);
}
int Framebuffer::getSamples(const ContextState &state) const
int Framebuffer::getSamples(const ContextState &state)
{
if (checkStatus(state) == GL_FRAMEBUFFER_COMPLETE)
{
......@@ -836,4 +836,18 @@ void Framebuffer::syncState() const
}
}
int Framebuffer::getCachedSamples(const ContextState &state) const
{
// TODO(jmadill): Framebuffer samples caching.
ASSERT(mDirtyBits.none());
return const_cast<Framebuffer *>(this)->getSamples(state);
}
GLenum Framebuffer::getCachedStatus(const ContextState &state) const
{
// TODO(jmadill): Framebuffer status caching.
ASSERT(mDirtyBits.none());
return const_cast<Framebuffer *>(this)->checkStatus(state);
}
} // namespace gl
......@@ -96,8 +96,7 @@ class Framebuffer final : public LabeledObject
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
const rx::FramebufferImpl *getImplementation() const { return mImpl; }
rx::FramebufferImpl *getImplementation() { return mImpl; }
rx::FramebufferImpl *getImplementation() const { return mImpl; }
GLuint id() const { return mId; }
......@@ -134,10 +133,18 @@ class Framebuffer final : public LabeledObject
size_t getNumColorBuffers() const;
bool hasDepth() const;
bool hasStencil() const;
int getSamples(const ContextState &state) const;
bool usingExtendedDrawBuffers() const;
GLenum checkStatus(const ContextState &state) const;
// This method calls checkStatus.
int getSamples(const ContextState &state);
GLenum checkStatus(const ContextState &state);
// These methods do not change any state.
// TODO(jmadill): Remove ContextState parameter when able.
int getCachedSamples(const ContextState &state) const;
GLenum getCachedStatus(const ContextState &state) const;
bool hasValidDepthStencil() const;
Error discard(size_t count, const GLenum *attachments);
......
......@@ -889,22 +889,12 @@ Framebuffer *State::getTargetFramebuffer(GLenum target) const
}
}
Framebuffer *State::getReadFramebuffer()
Framebuffer *State::getReadFramebuffer() const
{
return mReadFramebuffer;
}
Framebuffer *State::getDrawFramebuffer()
{
return mDrawFramebuffer;
}
const Framebuffer *State::getReadFramebuffer() const
{
return mReadFramebuffer;
}
const Framebuffer *State::getDrawFramebuffer() const
Framebuffer *State::getDrawFramebuffer() const
{
return mDrawFramebuffer;
}
......
......@@ -176,10 +176,8 @@ class State : angle::NonCopyable
void setReadFramebufferBinding(Framebuffer *framebuffer);
void setDrawFramebufferBinding(Framebuffer *framebuffer);
Framebuffer *getTargetFramebuffer(GLenum target) const;
Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer();
const Framebuffer *getReadFramebuffer() const;
const Framebuffer *getDrawFramebuffer() const;
Framebuffer *getReadFramebuffer() const;
Framebuffer *getDrawFramebuffer() const;
bool removeReadFramebufferBinding(GLuint framebuffer);
bool removeDrawFramebufferBinding(GLuint framebuffer);
......
......@@ -531,10 +531,9 @@ bool Framebuffer11::hasAnyInternalDirtyBit() const
return mInternalDirtyBits.any();
}
void Framebuffer11::syncInternalState() const
void Framebuffer11::syncInternalState()
{
// TODO(jmadill): Clean up this hack.
const_cast<Framebuffer11 *>(this)->syncState(gl::Framebuffer::DirtyBits());
syncState(gl::Framebuffer::DirtyBits());
}
} // namespace rx
......@@ -42,8 +42,7 @@ class Framebuffer11 : public FramebufferD3D, public angle::SignalReceiver
}
bool hasAnyInternalDirtyBit() const;
// TODO(jmadill): make this non-const
void syncInternalState() const;
void syncInternalState();
void signal(angle::SignalToken token) override;
......
......@@ -1498,8 +1498,9 @@ gl::Error Renderer11::updateState(const gl::ContextState &data, GLenum drawMode)
// Applies the render target surface, depth stencil surface, viewport rectangle and
// scissor rectangle to the renderer
const gl::Framebuffer *framebufferObject = glState.getDrawFramebuffer();
ASSERT(framebufferObject && framebufferObject->checkStatus(data) == GL_FRAMEBUFFER_COMPLETE);
gl::Framebuffer *framebufferObject = glState.getDrawFramebuffer();
ASSERT(framebufferObject &&
framebufferObject->getCachedStatus(data) == GL_FRAMEBUFFER_COMPLETE);
ANGLE_TRY(applyRenderTarget(framebufferObject));
// Set the present path state
......@@ -1516,7 +1517,7 @@ gl::Error Renderer11::updateState(const gl::ContextState &data, GLenum drawMode)
mStateManager.setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled());
// Applying rasterizer state to D3D11 device
int samples = framebufferObject->getSamples(data);
int samples = framebufferObject->getCachedSamples(data);
gl::RasterizerState rasterizer = glState.getRasterizerState();
rasterizer.pointDrawMode = (drawMode == GL_POINTS);
rasterizer.multiSample = (samples != 0);
......@@ -1572,7 +1573,7 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSi
return count >= minCount;
}
gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
gl::Error Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
{
return mStateManager.syncFramebuffer(framebuffer);
}
......
......@@ -136,7 +136,7 @@ class Renderer11 : public RendererD3D
gl::Error updateState(const gl::ContextState &data, GLenum drawMode);
bool applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize);
gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer);
gl::Error applyRenderTarget(gl::Framebuffer *frameBuffer);
gl::Error applyUniforms(const ProgramD3D &programD3D,
GLenum drawMode,
const std::vector<D3DUniform *> &uniformArray) override;
......
......@@ -981,9 +981,9 @@ void StateManager11::deinitialize()
mCurrentValueAttribs.clear();
}
gl::Error StateManager11::syncFramebuffer(const gl::Framebuffer *framebuffer)
gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer)
{
const Framebuffer11 *framebuffer11 = GetImplAs<Framebuffer11>(framebuffer);
Framebuffer11 *framebuffer11 = GetImplAs<Framebuffer11>(framebuffer);
gl::Error error = framebuffer11->invalidateSwizzles();
if (error.isError())
{
......
......@@ -77,7 +77,7 @@ class StateManager11 final : angle::NonCopyable
ID3D11ShaderResourceView *srv);
gl::Error clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd);
gl::Error syncFramebuffer(const gl::Framebuffer *framebuffer);
gl::Error syncFramebuffer(gl::Framebuffer *framebuffer);
void invalidateRenderTarget();
void invalidateBoundViews();
......
......@@ -894,7 +894,8 @@ gl::Error Renderer9::updateState(Context9 *context, GLenum drawMode)
// Applies the render target surface, depth stencil surface, viewport rectangle and
// scissor rectangle to the renderer
const gl::Framebuffer *framebufferObject = glState.getDrawFramebuffer();
ASSERT(framebufferObject && framebufferObject->checkStatus(data) == GL_FRAMEBUFFER_COMPLETE);
ASSERT(framebufferObject &&
framebufferObject->getCachedStatus(data) == GL_FRAMEBUFFER_COMPLETE);
ANGLE_TRY(applyRenderTarget(context, framebufferObject));
......@@ -906,7 +907,7 @@ gl::Error Renderer9::updateState(Context9 *context, GLenum drawMode)
setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled());
// Setting blend, depth stencil, and rasterizer states
int samples = framebufferObject->getSamples(data);
int samples = framebufferObject->getCachedSamples(data);
gl::RasterizerState rasterizer = glState.getRasterizerState();
rasterizer.pointDrawMode = (drawMode == GL_POINTS);
rasterizer.multiSample = (samples != 0);
......@@ -927,7 +928,7 @@ void Renderer9::setScissorRectangle(const gl::Rectangle &scissor, bool enabled)
gl::Error Renderer9::setBlendDepthRasterStates(const gl::ContextState &glData, GLenum drawMode)
{
const auto &glState = glData.getState();
int samples = glState.getDrawFramebuffer()->getSamples(glData);
int samples = glState.getDrawFramebuffer()->getCachedSamples(glData);
gl::RasterizerState rasterizer = glState.getRasterizerState();
rasterizer.pointDrawMode = (drawMode == GL_POINTS);
rasterizer.multiSample = (samples != 0);
......
......@@ -662,9 +662,9 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
return false;
}
const auto &glState = context->getGLState();
const gl::Framebuffer *readFramebuffer = glState.getReadFramebuffer();
const gl::Framebuffer *drawFramebuffer = glState.getDrawFramebuffer();
const auto &glState = context->getGLState();
gl::Framebuffer *readFramebuffer = glState.getReadFramebuffer();
gl::Framebuffer *drawFramebuffer = glState.getDrawFramebuffer();
if (!readFramebuffer || !drawFramebuffer)
{
......@@ -678,13 +678,13 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
return false;
}
if (!readFramebuffer->checkStatus(context->getContextState()))
if (readFramebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
}
if (!drawFramebuffer->checkStatus(context->getContextState()))
if (drawFramebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
......@@ -1085,22 +1085,22 @@ bool ValidateReadPixels(ValidationContext *context,
return false;
}
const Framebuffer *framebuffer = context->getGLState().getReadFramebuffer();
ASSERT(framebuffer);
auto readFramebuffer = context->getGLState().getReadFramebuffer();
if (framebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
if (readFramebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
}
if (context->getGLState().getReadFramebuffer()->id() != 0 &&
framebuffer->getSamples(context->getContextState()) != 0)
if (readFramebuffer->id() != 0 && readFramebuffer->getSamples(context->getContextState()) != 0)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
const Framebuffer *framebuffer = context->getGLState().getReadFramebuffer();
ASSERT(framebuffer);
const FramebufferAttachment *readBuffer = framebuffer->getReadColorbuffer();
if (!readBuffer)
{
......@@ -1587,14 +1587,15 @@ bool ValidateStateQuery(ValidationContext *context,
case GL_IMPLEMENTATION_COLOR_READ_TYPE:
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
{
const Framebuffer *framebuffer = context->getGLState().getReadFramebuffer();
ASSERT(framebuffer);
if (framebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
if (context->getGLState().getReadFramebuffer()->checkStatus(
context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
const Framebuffer *framebuffer = context->getGLState().getReadFramebuffer();
ASSERT(framebuffer);
const FramebufferAttachment *attachment = framebuffer->getReadColorbuffer();
if (!attachment)
{
......@@ -1656,16 +1657,15 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
return false;
}
const auto &state = context->getGLState();
const gl::Framebuffer *framebuffer = state.getReadFramebuffer();
if (framebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
const auto &state = context->getGLState();
auto readFramebuffer = state.getReadFramebuffer();
if (readFramebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
}
if (state.getReadFramebuffer()->id() != 0 &&
framebuffer->getSamples(context->getContextState()) != 0)
if (readFramebuffer->id() != 0 && readFramebuffer->getSamples(context->getContextState()) != 0)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
......@@ -1801,9 +1801,9 @@ static bool ValidateDrawBase(ValidationContext *context,
return false;
}
Framebuffer *framebuffer = state.getDrawFramebuffer();
if (context->getLimitations().noSeparateStencilRefsAndMasks)
{
const Framebuffer *framebuffer = state.getDrawFramebuffer();
const FramebufferAttachment *stencilBuffer = framebuffer->getStencilbuffer();
GLuint stencilBits = stencilBuffer ? stencilBuffer->getStencilSize() : 0;
GLuint minimumRequiredStencilMask = (1 << stencilBits) - 1;
......@@ -1824,8 +1824,7 @@ static bool ValidateDrawBase(ValidationContext *context,
}
}
const gl::Framebuffer *fbo = state.getDrawFramebuffer();
if (!fbo || fbo->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
if (framebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
......
......@@ -1632,8 +1632,8 @@ bool ValidateBlitFramebufferANGLE(Context *context,
return false;
}
const Framebuffer *readFramebuffer = context->getGLState().getReadFramebuffer();
const Framebuffer *drawFramebuffer = context->getGLState().getDrawFramebuffer();
Framebuffer *readFramebuffer = context->getGLState().getReadFramebuffer();
Framebuffer *drawFramebuffer = context->getGLState().getDrawFramebuffer();
if (mask & GL_COLOR_BUFFER_BIT)
{
......@@ -1676,9 +1676,7 @@ bool ValidateBlitFramebufferANGLE(Context *context,
}
}
int readSamples = readFramebuffer->getSamples(context->getContextState());
if (readSamples != 0 &&
if (readFramebuffer->getSamples(context->getContextState()) != 0 &&
IsPartialBlit(context, readColorAttachment, drawColorAttachment, srcX0, srcY0,
srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
{
......@@ -1727,10 +1725,8 @@ bool ValidateBlitFramebufferANGLE(Context *context,
bool ValidateClear(ValidationContext *context, GLbitfield mask)
{
const Framebuffer *framebufferObject = context->getGLState().getDrawFramebuffer();
ASSERT(framebufferObject);
if (framebufferObject->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
auto fbo = context->getGLState().getDrawFramebuffer();
if (fbo->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
......
......@@ -891,9 +891,9 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context,
return false;
}
const auto &state = context->getGLState();
const gl::Framebuffer *framebuffer = state.getReadFramebuffer();
GLuint readFramebufferID = framebuffer->id();
const auto &state = context->getGLState();
gl::Framebuffer *framebuffer = state.getReadFramebuffer();
GLuint readFramebufferID = framebuffer->id();
if (framebuffer->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
{
......@@ -1414,8 +1414,8 @@ bool ValidateClearBuffer(ValidationContext *context)
return false;
}
const gl::Framebuffer *fbo = context->getGLState().getDrawFramebuffer();
if (!fbo || fbo->checkStatus(context->getContextState()) != GL_FRAMEBUFFER_COMPLETE)
if (context->getGLState().getDrawFramebuffer()->checkStatus(context->getContextState()) !=
GL_FRAMEBUFFER_COMPLETE)
{
context->handleError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false;
......
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