Commit c20ab279 by Jamie Madill Committed by Commit Bot

Refactor more GL entrypoints.

In the next CL, the Context is going to remove the mutable getter for the gl::State. This means we can only mutate the state inside Context. So, we need to move all the state mutating GL command implementations to gl::Context. BUG=angleproject:747 BUG=angleproject:1388 Change-Id: I9ed351d08611934bf708781c6af3948396921593 Reviewed-on: https://chromium-review.googlesource.com/351171Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 5034c971
...@@ -188,6 +188,82 @@ class Context final : public ValidationContext ...@@ -188,6 +188,82 @@ class Context final : public ValidationContext
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams); bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams); bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
void activeTexture(GLenum texture);
void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void clearDepthf(GLclampf depth);
void clearStencil(GLint s);
void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void cullFace(GLenum mode);
void depthFunc(GLenum func);
void depthMask(GLboolean flag);
void depthRangef(GLclampf zNear, GLclampf zFar);
void disable(GLenum cap);
void disableVertexAttribArray(GLuint index);
void enable(GLenum cap);
void enableVertexAttribArray(GLuint index);
void frontFace(GLenum mode);
void hint(GLenum target, GLenum mode);
void lineWidth(GLfloat width);
void pixelStorei(GLenum pname, GLint param);
void polygonOffset(GLfloat factor, GLfloat units);
void sampleCoverage(GLclampf value, GLboolean invert);
void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
void stencilMaskSeparate(GLenum face, GLuint mask);
void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
void vertexAttrib1f(GLuint index, GLfloat x);
void vertexAttrib1fv(GLuint index, const GLfloat *values);
void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y);
void vertexAttrib2fv(GLuint index, const GLfloat *values);
void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);
void vertexAttrib3fv(GLuint index, const GLfloat *values);
void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void vertexAttrib4fv(GLuint index, const GLfloat *values);
void vertexAttribPointer(GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid *ptr);
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
void vertexAttribIPointer(GLuint index,
GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer);
void vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
void vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
void vertexAttribI4iv(GLuint index, const GLint *v);
void vertexAttribI4uiv(GLuint index, const GLuint *v);
void debugMessageControl(GLenum source,
GLenum type,
GLenum severity,
GLsizei count,
const GLuint *ids,
GLboolean enabled);
void debugMessageInsert(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar *buf);
void debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam);
GLuint getDebugMessageLog(GLuint count,
GLsizei bufSize,
GLenum *sources,
GLenum *types,
GLuint *ids,
GLenum *severities,
GLsizei *lengths,
GLchar *messageLog);
void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message);
void popDebugGroup();
void clear(GLbitfield mask); void clear(GLbitfield mask);
void clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values); void clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values);
void clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values); void clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values);
......
...@@ -1139,9 +1139,7 @@ void GL_APIENTRY DebugMessageControlKHR(GLenum source, ...@@ -1139,9 +1139,7 @@ void GL_APIENTRY DebugMessageControlKHR(GLenum source,
return; return;
} }
std::vector<GLuint> idVector(ids, ids + count); context->debugMessageControl(source, type, severity, count, ids, enabled);
context->getState().getDebug().setMessageControl(
source, type, severity, std::move(idVector), (enabled != GL_FALSE));
} }
} }
...@@ -1165,8 +1163,7 @@ void GL_APIENTRY DebugMessageInsertKHR(GLenum source, ...@@ -1165,8 +1163,7 @@ void GL_APIENTRY DebugMessageInsertKHR(GLenum source,
return; return;
} }
std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf)); context->debugMessageInsert(source, type, id, severity, length, buf);
context->getState().getDebug().insertMessage(source, type, id, severity, std::move(msg));
} }
} }
...@@ -1183,7 +1180,7 @@ void GL_APIENTRY DebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void *us ...@@ -1183,7 +1180,7 @@ void GL_APIENTRY DebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void *us
return; return;
} }
context->getState().getDebug().setCallback(callback, userParam); context->debugMessageCallback(callback, userParam);
} }
} }
...@@ -1211,8 +1208,8 @@ GLuint GL_APIENTRY GetDebugMessageLogKHR(GLuint count, ...@@ -1211,8 +1208,8 @@ GLuint GL_APIENTRY GetDebugMessageLogKHR(GLuint count,
return 0; return 0;
} }
return static_cast<GLuint>(context->getState().getDebug().getMessages( return context->getDebugMessageLog(count, bufSize, sources, types, ids, severities, lengths,
count, bufSize, sources, types, ids, severities, lengths, messageLog)); messageLog);
} }
return 0; return 0;
...@@ -1234,7 +1231,7 @@ void GL_APIENTRY PushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, con ...@@ -1234,7 +1231,7 @@ void GL_APIENTRY PushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, con
} }
std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message)); std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message));
context->getState().getDebug().pushGroup(source, id, std::move(msg)); context->pushDebugGroup(source, id, length, message);
} }
} }
...@@ -1250,7 +1247,7 @@ void GL_APIENTRY PopDebugGroupKHR(void) ...@@ -1250,7 +1247,7 @@ void GL_APIENTRY PopDebugGroupKHR(void)
return; return;
} }
context->getState().getDebug().popGroup(); context->popDebugGroup();
} }
} }
......
...@@ -836,7 +836,8 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi ...@@ -836,7 +836,8 @@ void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLi
} }
// Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2) // Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive()) if (curTransformFeedback && curTransformFeedback->isActive())
{ {
context->handleError(Error(GL_INVALID_OPERATION)); context->handleError(Error(GL_INVALID_OPERATION));
...@@ -910,7 +911,8 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer) ...@@ -910,7 +911,8 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer)
case GL_TRANSFORM_FEEDBACK_BUFFER: case GL_TRANSFORM_FEEDBACK_BUFFER:
{ {
// Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2) // Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive()) if (curTransformFeedback && curTransformFeedback->isActive())
{ {
context->handleError(Error(GL_INVALID_OPERATION)); context->handleError(Error(GL_INVALID_OPERATION));
...@@ -1075,14 +1077,14 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs ...@@ -1075,14 +1077,14 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs
// An INVALID_OPERATION error is generated when a non-zero vertex array object // An INVALID_OPERATION error is generated when a non-zero vertex array object
// is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
// and the pointer argument is not NULL. // and the pointer argument is not NULL.
if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL) if (context->getState().getVertexArray()->id() != 0 &&
context->getState().getArrayBufferId() == 0 && pointer != NULL)
{ {
context->handleError(Error(GL_INVALID_OPERATION)); context->handleError(Error(GL_INVALID_OPERATION));
return; return;
} }
context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true, context->vertexAttribIPointer(index, size, type, stride, pointer);
stride, pointer);
} }
} }
...@@ -1113,7 +1115,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) ...@@ -1113,7 +1115,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
if (pname == GL_CURRENT_VERTEX_ATTRIB) if (pname == GL_CURRENT_VERTEX_ATTRIB)
{ {
const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index); const VertexAttribCurrentValueData &currentValueData =
context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
params[i] = currentValueData.IntValues[i]; params[i] = currentValueData.IntValues[i];
...@@ -1121,7 +1124,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) ...@@ -1121,7 +1124,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
} }
else else
{ {
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index); const VertexAttribute &attribState =
context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname); *params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
} }
} }
...@@ -1154,7 +1158,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) ...@@ -1154,7 +1158,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
if (pname == GL_CURRENT_VERTEX_ATTRIB) if (pname == GL_CURRENT_VERTEX_ATTRIB)
{ {
const VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index); const VertexAttribCurrentValueData &currentValueData =
context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
params[i] = currentValueData.UnsignedIntValues[i]; params[i] = currentValueData.UnsignedIntValues[i];
...@@ -1162,7 +1167,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) ...@@ -1162,7 +1167,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
} }
else else
{ {
const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index); const VertexAttribute &attribState =
context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname); *params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
} }
} }
...@@ -1188,8 +1194,7 @@ void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint ...@@ -1188,8 +1194,7 @@ void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint
return; return;
} }
GLint vals[4] = { x, y, z, w }; context->vertexAttribI4i(index, x, y, z, w);
context->getState().setVertexAttribi(index, vals);
} }
} }
...@@ -1213,8 +1218,7 @@ void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL ...@@ -1213,8 +1218,7 @@ void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL
return; return;
} }
GLuint vals[4] = { x, y, z, w }; context->vertexAttribI4ui(index, x, y, z, w);
context->getState().setVertexAttribu(index, vals);
} }
} }
...@@ -1237,7 +1241,7 @@ void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v) ...@@ -1237,7 +1241,7 @@ void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v)
return; return;
} }
context->getState().setVertexAttribi(index, v); context->vertexAttribI4iv(index, v);
} }
} }
...@@ -1260,7 +1264,7 @@ void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v) ...@@ -1260,7 +1264,7 @@ void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v)
return; return;
} }
context->getState().setVertexAttribu(index, v); context->vertexAttribI4uiv(index, v);
} }
} }
...@@ -1536,7 +1540,7 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp ...@@ -1536,7 +1540,7 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp
return; return;
} }
Buffer *readBuffer = context->getState().getTargetBuffer(readTarget); Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget); Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
if (!readBuffer || !writeBuffer) if (!readBuffer || !writeBuffer)
...@@ -2507,7 +2511,8 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id) ...@@ -2507,7 +2511,8 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id)
case GL_TRANSFORM_FEEDBACK: case GL_TRANSFORM_FEEDBACK:
{ {
// Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1) // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused()) if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused())
{ {
context->handleError(Error(GL_INVALID_OPERATION)); context->handleError(Error(GL_INVALID_OPERATION));
......
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