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/351171
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index d311e8a..933082f 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -2748,4 +2748,375 @@
syncRendererState(mBlitDirtyBits, mBlitDirtyObjects);
}
+void Context::activeTexture(GLenum texture)
+{
+ mState.setActiveSampler(texture - GL_TEXTURE0);
+}
+
+void Context::blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ mState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha));
+}
+
+void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+ mState.setBlendEquation(modeRGB, modeAlpha);
+}
+
+void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+ mState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+
+void Context::clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ mState.setColorClearValue(red, green, blue, alpha);
+}
+
+void Context::clearDepthf(GLclampf depth)
+{
+ mState.setDepthClearValue(depth);
+}
+
+void Context::clearStencil(GLint s)
+{
+ mState.setStencilClearValue(s);
+}
+
+void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+ mState.setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
+}
+
+void Context::cullFace(GLenum mode)
+{
+ mState.setCullMode(mode);
+}
+
+void Context::depthFunc(GLenum func)
+{
+ mState.setDepthFunc(func);
+}
+
+void Context::depthMask(GLboolean flag)
+{
+ mState.setDepthMask(flag != GL_FALSE);
+}
+
+void Context::depthRangef(GLclampf zNear, GLclampf zFar)
+{
+ mState.setDepthRange(zNear, zFar);
+}
+
+void Context::disable(GLenum cap)
+{
+ mState.setEnableFeature(cap, false);
+}
+
+void Context::disableVertexAttribArray(GLuint index)
+{
+ mState.setEnableVertexAttribArray(index, false);
+}
+
+void Context::enable(GLenum cap)
+{
+ mState.setEnableFeature(cap, true);
+}
+
+void Context::enableVertexAttribArray(GLuint index)
+{
+ mState.setEnableVertexAttribArray(index, true);
+}
+
+void Context::frontFace(GLenum mode)
+{
+ mState.setFrontFace(mode);
+}
+
+void Context::hint(GLenum target, GLenum mode)
+{
+ switch (target)
+ {
+ case GL_GENERATE_MIPMAP_HINT:
+ mState.setGenerateMipmapHint(mode);
+ break;
+
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
+ mState.setFragmentShaderDerivativeHint(mode);
+ break;
+
+ default:
+ UNREACHABLE();
+ return;
+ }
+}
+
+void Context::lineWidth(GLfloat width)
+{
+ mState.setLineWidth(width);
+}
+
+void Context::pixelStorei(GLenum pname, GLint param)
+{
+ switch (pname)
+ {
+ case GL_UNPACK_ALIGNMENT:
+ mState.setUnpackAlignment(param);
+ break;
+
+ case GL_PACK_ALIGNMENT:
+ mState.setPackAlignment(param);
+ break;
+
+ case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
+ mState.setPackReverseRowOrder(param != 0);
+ break;
+
+ case GL_UNPACK_ROW_LENGTH:
+ ASSERT((getClientVersion() >= 3) || getExtensions().unpackSubimage);
+ mState.setUnpackRowLength(param);
+ break;
+
+ case GL_UNPACK_IMAGE_HEIGHT:
+ ASSERT(getClientVersion() >= 3);
+ mState.setUnpackImageHeight(param);
+ break;
+
+ case GL_UNPACK_SKIP_IMAGES:
+ ASSERT(getClientVersion() >= 3);
+ mState.setUnpackSkipImages(param);
+ break;
+
+ case GL_UNPACK_SKIP_ROWS:
+ ASSERT((getClientVersion() >= 3) || getExtensions().unpackSubimage);
+ mState.setUnpackSkipRows(param);
+ break;
+
+ case GL_UNPACK_SKIP_PIXELS:
+ ASSERT((getClientVersion() >= 3) || getExtensions().unpackSubimage);
+ mState.setUnpackSkipPixels(param);
+ break;
+
+ case GL_PACK_ROW_LENGTH:
+ ASSERT((getClientVersion() >= 3) || getExtensions().packSubimage);
+ mState.setPackRowLength(param);
+ break;
+
+ case GL_PACK_SKIP_ROWS:
+ ASSERT((getClientVersion() >= 3) || getExtensions().packSubimage);
+ mState.setPackSkipRows(param);
+ break;
+
+ case GL_PACK_SKIP_PIXELS:
+ ASSERT((getClientVersion() >= 3) || getExtensions().packSubimage);
+ mState.setPackSkipPixels(param);
+ break;
+
+ default:
+ UNREACHABLE();
+ return;
+ }
+}
+
+void Context::polygonOffset(GLfloat factor, GLfloat units)
+{
+ mState.setPolygonOffsetParams(factor, units);
+}
+
+void Context::sampleCoverage(GLclampf value, GLboolean invert)
+{
+ mState.setSampleCoverageParams(clamp01(value), invert == GL_TRUE);
+}
+
+void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ mState.setScissorParams(x, y, width, height);
+}
+
+void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
+ {
+ mState.setStencilParams(func, ref, mask);
+ }
+
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK)
+ {
+ mState.setStencilBackParams(func, ref, mask);
+ }
+}
+
+void Context::stencilMaskSeparate(GLenum face, GLuint mask)
+{
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
+ {
+ mState.setStencilWritemask(mask);
+ }
+
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK)
+ {
+ mState.setStencilBackWritemask(mask);
+ }
+}
+
+void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
+ {
+ mState.setStencilOperations(fail, zfail, zpass);
+ }
+
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK)
+ {
+ mState.setStencilBackOperations(fail, zfail, zpass);
+ }
+}
+
+void Context::vertexAttrib1f(GLuint index, GLfloat x)
+{
+ GLfloat vals[4] = {x, 0, 0, 1};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib1fv(GLuint index, const GLfloat *values)
+{
+ GLfloat vals[4] = {values[0], 0, 0, 1};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
+{
+ GLfloat vals[4] = {x, y, 0, 1};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib2fv(GLuint index, const GLfloat *values)
+{
+ GLfloat vals[4] = {values[0], values[1], 0, 1};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+{
+ GLfloat vals[4] = {x, y, z, 1};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib3fv(GLuint index, const GLfloat *values)
+{
+ GLfloat vals[4] = {values[0], values[1], values[2], 1};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GLfloat vals[4] = {x, y, z, w};
+ mState.setVertexAttribf(index, vals);
+}
+
+void Context::vertexAttrib4fv(GLuint index, const GLfloat *values)
+{
+ mState.setVertexAttribf(index, values);
+}
+
+void Context::vertexAttribPointer(GLuint index,
+ GLint size,
+ GLenum type,
+ GLboolean normalized,
+ GLsizei stride,
+ const GLvoid *ptr)
+{
+ mState.setVertexAttribState(index, mState.getTargetBuffer(GL_ARRAY_BUFFER), size, type,
+ normalized == GL_TRUE, false, stride, ptr);
+}
+
+void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ mState.setViewportParams(x, y, width, height);
+}
+
+void Context::vertexAttribIPointer(GLuint index,
+ GLint size,
+ GLenum type,
+ GLsizei stride,
+ const GLvoid *pointer)
+{
+ mState.setVertexAttribState(index, mState.getTargetBuffer(GL_ARRAY_BUFFER), size, type, false,
+ true, stride, pointer);
+}
+
+void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
+{
+ GLint vals[4] = {x, y, z, w};
+ mState.setVertexAttribi(index, vals);
+}
+
+void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
+{
+ GLuint vals[4] = {x, y, z, w};
+ mState.setVertexAttribu(index, vals);
+}
+
+void Context::vertexAttribI4iv(GLuint index, const GLint *v)
+{
+ mState.setVertexAttribi(index, v);
+}
+
+void Context::vertexAttribI4uiv(GLuint index, const GLuint *v)
+{
+ mState.setVertexAttribu(index, v);
+}
+
+void Context::debugMessageControl(GLenum source,
+ GLenum type,
+ GLenum severity,
+ GLsizei count,
+ const GLuint *ids,
+ GLboolean enabled)
+{
+ std::vector<GLuint> idVector(ids, ids + count);
+ mState.getDebug().setMessageControl(source, type, severity, std::move(idVector),
+ (enabled != GL_FALSE));
+}
+
+void Context::debugMessageInsert(GLenum source,
+ GLenum type,
+ GLuint id,
+ GLenum severity,
+ GLsizei length,
+ const GLchar *buf)
+{
+ std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf));
+ mState.getDebug().insertMessage(source, type, id, severity, std::move(msg));
+}
+
+void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam)
+{
+ mState.getDebug().setCallback(callback, userParam);
+}
+
+GLuint Context::getDebugMessageLog(GLuint count,
+ GLsizei bufSize,
+ GLenum *sources,
+ GLenum *types,
+ GLuint *ids,
+ GLenum *severities,
+ GLsizei *lengths,
+ GLchar *messageLog)
+{
+ return static_cast<GLuint>(mState.getDebug().getMessages(count, bufSize, sources, types, ids,
+ severities, lengths, messageLog));
+}
+
+void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message)
+{
+ std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message));
+ mState.getDebug().pushGroup(source, id, std::move(msg));
+}
+
+void Context::popDebugGroup()
+{
+ mState.getDebug().popGroup();
+}
+
} // namespace gl
diff --git a/src/libANGLE/Context.h b/src/libANGLE/Context.h
index 668e01e..7ac9f0e 100644
--- a/src/libANGLE/Context.h
+++ b/src/libANGLE/Context.h
@@ -188,6 +188,82 @@
bool getQueryParameterInfo(GLenum pname, 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 clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values);
void clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values);
diff --git a/src/libGLESv2/entry_points_gles_2_0.cpp b/src/libGLESv2/entry_points_gles_2_0.cpp
index fe396ef..b1e9a96 100644
--- a/src/libGLESv2/entry_points_gles_2_0.cpp
+++ b/src/libGLESv2/entry_points_gles_2_0.cpp
@@ -49,7 +49,7 @@
return;
}
- context->getState().setActiveSampler(texture - GL_TEXTURE0);
+ context->activeTexture(texture);
}
}
@@ -223,7 +223,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha));
+ context->blendColor(red, green, blue, alpha);
}
}
@@ -267,7 +267,7 @@
return;
}
- context->getState().setBlendEquation(modeRGB, modeAlpha);
+ context->blendEquationSeparate(modeRGB, modeAlpha);
}
}
@@ -415,7 +415,7 @@
}
}
- context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
}
@@ -590,7 +590,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setColorClearValue(red, green, blue, alpha);
+ context->clearColor(red, green, blue, alpha);
}
}
@@ -601,7 +601,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setDepthClearValue(depth);
+ context->clearDepthf(depth);
}
}
@@ -612,7 +612,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setStencilClearValue(s);
+ context->clearStencil(s);
}
}
@@ -624,7 +624,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
+ context->colorMask(red, green, blue, alpha);
}
}
@@ -782,7 +782,7 @@
return;
}
- context->getState().setCullMode(mode);
+ context->cullFace(mode);
}
}
@@ -945,13 +945,14 @@
case GL_GREATER:
case GL_GEQUAL:
case GL_NOTEQUAL:
- context->getState().setDepthFunc(func);
- break;
+ break;
default:
context->handleError(Error(GL_INVALID_ENUM));
return;
}
+
+ context->depthFunc(func);
}
}
@@ -962,7 +963,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setDepthMask(flag != GL_FALSE);
+ context->depthMask(flag);
}
}
@@ -973,7 +974,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setDepthRange(zNear, zFar);
+ context->depthRangef(zNear, zFar);
}
}
@@ -1017,7 +1018,7 @@
return;
}
- context->getState().setEnableFeature(cap, false);
+ context->disable(cap);
}
}
@@ -1034,7 +1035,7 @@
return;
}
- context->getState().setEnableVertexAttribArray(index, false);
+ context->disableVertexAttribArray(index);
}
}
@@ -1109,7 +1110,7 @@
}
}
- context->getState().setEnableFeature(cap, true);
+ context->enable(cap);
}
}
@@ -1126,7 +1127,7 @@
return;
}
- context->getState().setEnableVertexAttribArray(index, true);
+ context->enableVertexAttribArray(index);
}
}
@@ -1210,12 +1211,13 @@
{
case GL_CW:
case GL_CCW:
- context->getState().setFrontFace(mode);
- break;
+ break;
default:
context->handleError(Error(GL_INVALID_ENUM));
return;
}
+
+ context->frontFace(mode);
}
}
@@ -1968,7 +1970,8 @@
return;
}
- Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
+ Renderbuffer *renderbuffer =
+ context->getRenderbuffer(context->getState().getRenderbufferId());
switch (pname)
{
@@ -2612,7 +2615,8 @@
if (pname == GL_CURRENT_VERTEX_ATTRIB)
{
- const VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index);
+ const VertexAttribCurrentValueData ¤tValueData =
+ context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i)
{
params[i] = currentValueData.FloatValues[i];
@@ -2620,7 +2624,8 @@
}
else
{
- const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ const VertexAttribute &attribState =
+ context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
}
}
@@ -2646,7 +2651,8 @@
if (pname == GL_CURRENT_VERTEX_ATTRIB)
{
- const VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index);
+ const VertexAttribCurrentValueData ¤tValueData =
+ context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i)
{
float currentValue = currentValueData.FloatValues[i];
@@ -2655,7 +2661,8 @@
}
else
{
- const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ const VertexAttribute &attribState =
+ context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
}
}
@@ -2680,7 +2687,7 @@
return;
}
- *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
+ *pointer = const_cast<GLvoid *>(context->getState().getVertexAttribPointer(index));
}
}
@@ -2706,17 +2713,15 @@
switch (target)
{
case GL_GENERATE_MIPMAP_HINT:
- context->getState().setGenerateMipmapHint(mode);
- break;
-
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
- context->getState().setFragmentShaderDerivativeHint(mode);
- break;
+ break;
default:
context->handleError(Error(GL_INVALID_ENUM));
return;
}
+
+ context->hint(target, mode);
}
}
@@ -2860,7 +2865,7 @@
return;
}
- context->getState().setLineWidth(width);
+ context->lineWidth(width);
}
}
@@ -2936,8 +2941,6 @@
return;
}
- State &state = context->getState();
-
switch (pname)
{
case GL_UNPACK_ALIGNMENT:
@@ -2946,8 +2949,6 @@
context->handleError(Error(GL_INVALID_VALUE));
return;
}
-
- state.setUnpackAlignment(param);
break;
case GL_PACK_ALIGNMENT:
@@ -2956,58 +2957,25 @@
context->handleError(Error(GL_INVALID_VALUE));
return;
}
-
- state.setPackAlignment(param);
break;
case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
- state.setPackReverseRowOrder(param != 0);
- break;
-
case GL_UNPACK_ROW_LENGTH:
- ASSERT((context->getClientVersion() >= 3) || context->getExtensions().unpackSubimage);
- state.setUnpackRowLength(param);
- break;
-
case GL_UNPACK_IMAGE_HEIGHT:
- ASSERT(context->getClientVersion() >= 3);
- state.setUnpackImageHeight(param);
- break;
-
case GL_UNPACK_SKIP_IMAGES:
- ASSERT(context->getClientVersion() >= 3);
- state.setUnpackSkipImages(param);
- break;
-
case GL_UNPACK_SKIP_ROWS:
- ASSERT((context->getClientVersion() >= 3) || context->getExtensions().unpackSubimage);
- state.setUnpackSkipRows(param);
- break;
-
case GL_UNPACK_SKIP_PIXELS:
- ASSERT((context->getClientVersion() >= 3) || context->getExtensions().unpackSubimage);
- state.setUnpackSkipPixels(param);
- break;
-
case GL_PACK_ROW_LENGTH:
- ASSERT((context->getClientVersion() >= 3) || context->getExtensions().packSubimage);
- state.setPackRowLength(param);
- break;
-
case GL_PACK_SKIP_ROWS:
- ASSERT((context->getClientVersion() >= 3) || context->getExtensions().packSubimage);
- state.setPackSkipRows(param);
- break;
-
case GL_PACK_SKIP_PIXELS:
- ASSERT((context->getClientVersion() >= 3) || context->getExtensions().packSubimage);
- state.setPackSkipPixels(param);
break;
default:
context->handleError(Error(GL_INVALID_ENUM));
return;
}
+
+ context->pixelStorei(pname, param);
}
}
@@ -3018,7 +2986,7 @@
Context *context = GetValidGlobalContext();
if (context)
{
- context->getState().setPolygonOffsetParams(factor, units);
+ context->polygonOffset(factor, units);
}
}
@@ -3092,7 +3060,7 @@
if (context)
{
- context->getState().setSampleCoverageParams(clamp01(value), invert == GL_TRUE);
+ context->sampleCoverage(value, invert);
}
}
@@ -3109,7 +3077,7 @@
return;
}
- context->getState().setScissorParams(x, y, width, height);
+ context->scissor(x, y, width, height);
}
}
@@ -3198,15 +3166,7 @@
return;
}
- if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilParams(func, ref, mask);
- }
-
- if (face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilBackParams(func, ref, mask);
- }
+ context->stencilFuncSeparate(face, func, ref, mask);
}
}
@@ -3234,15 +3194,7 @@
return;
}
- if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilWritemask(mask);
- }
-
- if (face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilBackWritemask(mask);
- }
+ context->stencilMaskSeparate(face, mask);
}
}
@@ -3322,15 +3274,7 @@
return;
}
- if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilOperations(fail, zfail, zpass);
- }
-
- if (face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->getState().setStencilBackOperations(fail, zfail, zpass);
- }
+ context->stencilOpSeparate(face, fail, zfail, zpass);
}
}
@@ -3782,8 +3726,7 @@
return;
}
- GLfloat vals[4] = { x, 0, 0, 1 };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib1f(index, x);
}
}
@@ -3800,8 +3743,7 @@
return;
}
- GLfloat vals[4] = { values[0], 0, 0, 1 };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib1fv(index, values);
}
}
@@ -3818,8 +3760,7 @@
return;
}
- GLfloat vals[4] = { x, y, 0, 1 };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib2f(index, x, y);
}
}
@@ -3836,8 +3777,7 @@
return;
}
- GLfloat vals[4] = { values[0], values[1], 0, 1 };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib2fv(index, values);
}
}
@@ -3854,8 +3794,7 @@
return;
}
- GLfloat vals[4] = { x, y, z, 1 };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib3f(index, x, y, z);
}
}
@@ -3872,8 +3811,7 @@
return;
}
- GLfloat vals[4] = { values[0], values[1], values[2], 1 };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib3fv(index, values);
}
}
@@ -3890,8 +3828,7 @@
return;
}
- GLfloat vals[4] = { x, y, z, w };
- context->getState().setVertexAttribf(index, vals);
+ context->vertexAttrib4f(index, x, y, z, w);
}
}
@@ -3908,7 +3845,7 @@
return;
}
- context->getState().setVertexAttribf(index, values);
+ context->vertexAttrib4fv(index, values);
}
}
@@ -3976,14 +3913,14 @@
// 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,
// and the pointer argument is not NULL.
- if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
+ if (context->getState().getVertexArray()->id() != 0 &&
+ context->getState().getArrayBufferId() == 0 && ptr != NULL)
{
context->handleError(Error(GL_INVALID_OPERATION));
return;
}
- context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
- normalized == GL_TRUE, false, stride, ptr);
+ context->vertexAttribPointer(index, size, type, normalized, stride, ptr);
}
}
@@ -4000,8 +3937,8 @@
return;
}
- context->getState().setViewportParams(x, y, width, height);
+ context->viewport(x, y, width, height);
}
}
-}
+} // namespace gl
diff --git a/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/src/libGLESv2/entry_points_gles_2_0_ext.cpp
index b436b3a..6cf0e4b 100644
--- a/src/libGLESv2/entry_points_gles_2_0_ext.cpp
+++ b/src/libGLESv2/entry_points_gles_2_0_ext.cpp
@@ -1139,9 +1139,7 @@
return;
}
- std::vector<GLuint> idVector(ids, ids + count);
- context->getState().getDebug().setMessageControl(
- source, type, severity, std::move(idVector), (enabled != GL_FALSE));
+ context->debugMessageControl(source, type, severity, count, ids, enabled);
}
}
@@ -1165,8 +1163,7 @@
return;
}
- std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf));
- context->getState().getDebug().insertMessage(source, type, id, severity, std::move(msg));
+ context->debugMessageInsert(source, type, id, severity, length, buf);
}
}
@@ -1183,7 +1180,7 @@
return;
}
- context->getState().getDebug().setCallback(callback, userParam);
+ context->debugMessageCallback(callback, userParam);
}
}
@@ -1211,8 +1208,8 @@
return 0;
}
- return static_cast<GLuint>(context->getState().getDebug().getMessages(
- count, bufSize, sources, types, ids, severities, lengths, messageLog));
+ return context->getDebugMessageLog(count, bufSize, sources, types, ids, severities, lengths,
+ messageLog);
}
return 0;
@@ -1234,7 +1231,7 @@
}
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 @@
return;
}
- context->getState().getDebug().popGroup();
+ context->popDebugGroup();
}
}
diff --git a/src/libGLESv2/entry_points_gles_3_0.cpp b/src/libGLESv2/entry_points_gles_3_0.cpp
index e9e1eea..7de8d5d 100644
--- a/src/libGLESv2/entry_points_gles_3_0.cpp
+++ b/src/libGLESv2/entry_points_gles_3_0.cpp
@@ -836,7 +836,8 @@
}
// 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())
{
context->handleError(Error(GL_INVALID_OPERATION));
@@ -910,7 +911,8 @@
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)
- TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
+ TransformFeedback *curTransformFeedback =
+ context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive())
{
context->handleError(Error(GL_INVALID_OPERATION));
@@ -1075,14 +1077,14 @@
// 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,
// 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));
return;
}
- context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
- stride, pointer);
+ context->vertexAttribIPointer(index, size, type, stride, pointer);
}
}
@@ -1113,7 +1115,8 @@
if (pname == GL_CURRENT_VERTEX_ATTRIB)
{
- const VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index);
+ const VertexAttribCurrentValueData ¤tValueData =
+ context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i)
{
params[i] = currentValueData.IntValues[i];
@@ -1121,7 +1124,8 @@
}
else
{
- const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ const VertexAttribute &attribState =
+ context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
}
}
@@ -1154,7 +1158,8 @@
if (pname == GL_CURRENT_VERTEX_ATTRIB)
{
- const VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index);
+ const VertexAttribCurrentValueData ¤tValueData =
+ context->getState().getVertexAttribCurrentValue(index);
for (int i = 0; i < 4; ++i)
{
params[i] = currentValueData.UnsignedIntValues[i];
@@ -1162,7 +1167,8 @@
}
else
{
- const VertexAttribute &attribState = context->getState().getVertexArray()->getVertexAttribute(index);
+ const VertexAttribute &attribState =
+ context->getState().getVertexArray()->getVertexAttribute(index);
*params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
}
}
@@ -1188,8 +1194,7 @@
return;
}
- GLint vals[4] = { x, y, z, w };
- context->getState().setVertexAttribi(index, vals);
+ context->vertexAttribI4i(index, x, y, z, w);
}
}
@@ -1213,8 +1218,7 @@
return;
}
- GLuint vals[4] = { x, y, z, w };
- context->getState().setVertexAttribu(index, vals);
+ context->vertexAttribI4ui(index, x, y, z, w);
}
}
@@ -1237,7 +1241,7 @@
return;
}
- context->getState().setVertexAttribi(index, v);
+ context->vertexAttribI4iv(index, v);
}
}
@@ -1260,7 +1264,7 @@
return;
}
- context->getState().setVertexAttribu(index, v);
+ context->vertexAttribI4uiv(index, v);
}
}
@@ -1536,7 +1540,7 @@
return;
}
- Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
+ Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
if (!readBuffer || !writeBuffer)
@@ -2507,7 +2511,8 @@
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)
- TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
+ TransformFeedback *curTransformFeedback =
+ context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused())
{
context->handleError(Error(GL_INVALID_OPERATION));