Commit d9ba4f73 by Jamie Madill

Move implementation of hasMappedBuffer to State.

Refactoring patch only. BUG=angle:571 Change-Id: Ib9f3145eaa457d94e488fd42eb4c4b9133768996 Reviewed-on: https://chromium-review.googlesource.com/210643Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent baadf23a
......@@ -2453,33 +2453,6 @@ void Context::invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const
}
}
bool Context::hasMappedBuffer(GLenum target) const
{
if (target == GL_ARRAY_BUFFER)
{
for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++)
{
const gl::VertexAttribute &vertexAttrib = mState.getVertexAttribState(attribIndex);
gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
{
return true;
}
}
}
else if (target == GL_ELEMENT_ARRAY_BUFFER)
{
Buffer *elementBuffer = mState.getTargetBuffer(target);
return (elementBuffer && elementBuffer->isMapped());
}
else if (target == GL_TRANSFORM_FEEDBACK_BUFFER)
{
UNIMPLEMENTED();
}
else UNREACHABLE();
return false;
}
void Context::initCaps(GLuint clientVersion)
{
mCaps = mRenderer->getRendererCaps();
......
......@@ -230,8 +230,6 @@ class Context
void invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments,
GLint x, GLint y, GLsizei width, GLsizei height);
bool hasMappedBuffer(GLenum target) const;
rx::Renderer *getRenderer() { return mRenderer; }
State &getState() { return mState; }
......
......@@ -1412,4 +1412,27 @@ bool State::getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data)
return true;
}
bool State::hasMappedBuffer(GLenum target) const
{
if (target == GL_ARRAY_BUFFER)
{
for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++)
{
const gl::VertexAttribute &vertexAttrib = getVertexAttribState(attribIndex);
gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
{
return true;
}
}
return false;
}
else
{
Buffer *buffer = getTargetBuffer(target);
return (buffer && buffer->isMapped());
}
}
}
......@@ -238,6 +238,8 @@ class State
bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
bool hasMappedBuffer(GLenum target) const;
private:
DISALLOW_COPY_AND_ASSIGN(State);
......
......@@ -1301,7 +1301,7 @@ bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLi
return true;
}
static bool ValidateDrawBase(const gl::Context *context, GLenum mode, GLsizei count)
static bool ValidateDrawBase(const gl::State &state, GLenum mode, GLsizei count)
{
switch (mode)
{
......@@ -1323,14 +1323,14 @@ static bool ValidateDrawBase(const gl::Context *context, GLenum mode, GLsizei co
}
// Check for mapped buffers
if (context->hasMappedBuffer(GL_ARRAY_BUFFER))
if (state.hasMappedBuffer(GL_ARRAY_BUFFER))
{
return gl::error(GL_INVALID_OPERATION, false);
}
const gl::DepthStencilState &depthStencilState = context->getState().getDepthStencilState();
const gl::DepthStencilState &depthStencilState = state.getDepthStencilState();
if (depthStencilState.stencilWritemask != depthStencilState.stencilBackWritemask ||
context->getState().getStencilRef() != context->getState().getStencilBackRef() ||
state.getStencilRef() != state.getStencilBackRef() ||
depthStencilState.stencilMask != depthStencilState.stencilBackMask)
{
// Note: these separate values are not supported in WebGL, due to D3D's limitations.
......@@ -1340,18 +1340,18 @@ static bool ValidateDrawBase(const gl::Context *context, GLenum mode, GLsizei co
return gl::error(GL_INVALID_OPERATION, false);
}
const gl::Framebuffer *fbo = context->getState().getDrawFramebuffer();
const gl::Framebuffer *fbo = state.getDrawFramebuffer();
if (!fbo || fbo->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
}
if (context->getState().getCurrentProgramId() == 0)
if (state.getCurrentProgramId() == 0)
{
return gl::error(GL_INVALID_OPERATION, false);
}
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
gl::ProgramBinary *programBinary = state.getCurrentProgramBinary();
if (!programBinary->validateSamplers(NULL))
{
return gl::error(GL_INVALID_OPERATION, false);
......@@ -1368,7 +1368,8 @@ bool ValidateDrawArrays(const gl::Context *context, GLenum mode, GLint first, GL
return gl::error(GL_INVALID_VALUE, false);
}
gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
const State &state = context->getState();
gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused() &&
curTransformFeedback->getDrawMode() != mode)
{
......@@ -1378,7 +1379,7 @@ bool ValidateDrawArrays(const gl::Context *context, GLenum mode, GLint first, GL
return gl::error(GL_INVALID_OPERATION, false);
}
if (!ValidateDrawBase(context, mode, count))
if (!ValidateDrawBase(state, mode, count))
{
return false;
}
......@@ -1419,7 +1420,9 @@ bool ValidateDrawElements(const gl::Context *context, GLenum mode, GLsizei count
return gl::error(GL_INVALID_ENUM, false);
}
gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
const State &state = context->getState();
gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
{
// It is an invalid operation to call DrawElements, DrawRangeElements or DrawElementsInstanced
......@@ -1428,18 +1431,18 @@ bool ValidateDrawElements(const gl::Context *context, GLenum mode, GLsizei count
}
// Check for mapped buffers
if (context->hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER))
if (state.hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER))
{
return gl::error(GL_INVALID_OPERATION, false);
}
gl::VertexArray *vao = context->getState().getVertexArray();
gl::VertexArray *vao = state.getVertexArray();
if (!indices && !vao->getElementArrayBuffer())
{
return gl::error(GL_INVALID_OPERATION, false);
}
if (!ValidateDrawBase(context, mode, count))
if (!ValidateDrawBase(state, mode, count))
{
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