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
......@@ -2748,4 +2748,375 @@ void Context::syncStateForBlit()
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
......@@ -188,6 +188,82 @@ class Context final : public ValidationContext
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);
......
......@@ -49,7 +49,7 @@ void GL_APIENTRY ActiveTexture(GLenum texture)
return;
}
context->getState().setActiveSampler(texture - GL_TEXTURE0);
context->activeTexture(texture);
}
}
......@@ -223,7 +223,7 @@ void GL_APIENTRY BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclamp
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 @@ void GL_APIENTRY BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
return;
}
context->getState().setBlendEquation(modeRGB, modeAlpha);
context->blendEquationSeparate(modeRGB, modeAlpha);
}
}
......@@ -415,7 +415,7 @@ void GL_APIENTRY BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha
}
}
context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
}
......@@ -590,7 +590,7 @@ void GL_APIENTRY ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclamp
Context *context = GetValidGlobalContext();
if (context)
{
context->getState().setColorClearValue(red, green, blue, alpha);
context->clearColor(red, green, blue, alpha);
}
}
......@@ -601,7 +601,7 @@ void GL_APIENTRY ClearDepthf(GLclampf depth)
Context *context = GetValidGlobalContext();
if (context)
{
context->getState().setDepthClearValue(depth);
context->clearDepthf(depth);
}
}
......@@ -612,7 +612,7 @@ void GL_APIENTRY ClearStencil(GLint s)
Context *context = GetValidGlobalContext();
if (context)
{
context->getState().setStencilClearValue(s);
context->clearStencil(s);
}
}
......@@ -624,7 +624,7 @@ void GL_APIENTRY ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboo
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 @@ void GL_APIENTRY CullFace(GLenum mode)
return;
}
context->getState().setCullMode(mode);
context->cullFace(mode);
}
}
......@@ -945,13 +945,14 @@ void GL_APIENTRY DepthFunc(GLenum func)
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 @@ void GL_APIENTRY DepthMask(GLboolean flag)
Context *context = GetValidGlobalContext();
if (context)
{
context->getState().setDepthMask(flag != GL_FALSE);
context->depthMask(flag);
}
}
......@@ -973,7 +974,7 @@ void GL_APIENTRY DepthRangef(GLclampf zNear, GLclampf zFar)
Context *context = GetValidGlobalContext();
if (context)
{
context->getState().setDepthRange(zNear, zFar);
context->depthRangef(zNear, zFar);
}
}
......@@ -1017,7 +1018,7 @@ void GL_APIENTRY Disable(GLenum cap)
return;
}
context->getState().setEnableFeature(cap, false);
context->disable(cap);
}
}
......@@ -1034,7 +1035,7 @@ void GL_APIENTRY DisableVertexAttribArray(GLuint index)
return;
}
context->getState().setEnableVertexAttribArray(index, false);
context->disableVertexAttribArray(index);
}
}
......@@ -1109,7 +1110,7 @@ void GL_APIENTRY Enable(GLenum cap)
}
}
context->getState().setEnableFeature(cap, true);
context->enable(cap);
}
}
......@@ -1126,7 +1127,7 @@ void GL_APIENTRY EnableVertexAttribArray(GLuint index)
return;
}
context->getState().setEnableVertexAttribArray(index, true);
context->enableVertexAttribArray(index);
}
}
......@@ -1210,12 +1211,13 @@ void GL_APIENTRY FrontFace(GLenum mode)
{
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 @@ void GL_APIENTRY GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint*
return;
}
Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
Renderbuffer *renderbuffer =
context->getRenderbuffer(context->getState().getRenderbufferId());
switch (pname)
{
......@@ -2612,7 +2615,8 @@ void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
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)
{
params[i] = currentValueData.FloatValues[i];
......@@ -2620,7 +2624,8 @@ void GL_APIENTRY GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
}
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 @@ void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
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)
{
float currentValue = currentValueData.FloatValues[i];
......@@ -2655,7 +2661,8 @@ void GL_APIENTRY GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
}
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 @@ void GL_APIENTRY GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** po
return;
}
*pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
*pointer = const_cast<GLvoid *>(context->getState().getVertexAttribPointer(index));
}
}
......@@ -2706,17 +2713,15 @@ void GL_APIENTRY Hint(GLenum target, GLenum mode)
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 @@ void GL_APIENTRY LineWidth(GLfloat width)
return;
}
context->getState().setLineWidth(width);
context->lineWidth(width);
}
}
......@@ -2936,8 +2941,6 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param)
return;
}
State &state = context->getState();
switch (pname)
{
case GL_UNPACK_ALIGNMENT:
......@@ -2946,8 +2949,6 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param)
context->handleError(Error(GL_INVALID_VALUE));
return;
}
state.setUnpackAlignment(param);
break;
case GL_PACK_ALIGNMENT:
......@@ -2956,58 +2957,25 @@ void GL_APIENTRY PixelStorei(GLenum pname, GLint param)
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 @@ void GL_APIENTRY PolygonOffset(GLfloat factor, GLfloat units)
Context *context = GetValidGlobalContext();
if (context)
{
context->getState().setPolygonOffsetParams(factor, units);
context->polygonOffset(factor, units);
}
}
......@@ -3092,7 +3060,7 @@ void GL_APIENTRY SampleCoverage(GLclampf value, GLboolean invert)
if (context)
{
context->getState().setSampleCoverageParams(clamp01(value), invert == GL_TRUE);
context->sampleCoverage(value, invert);
}
}
......@@ -3109,7 +3077,7 @@ void GL_APIENTRY Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
return;
}
context->getState().setScissorParams(x, y, width, height);
context->scissor(x, y, width, height);
}
}
......@@ -3198,15 +3166,7 @@ void GL_APIENTRY StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint
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 @@ void GL_APIENTRY StencilMaskSeparate(GLenum face, GLuint mask)
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 @@ void GL_APIENTRY StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu
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 @@ void GL_APIENTRY VertexAttrib1f(GLuint index, GLfloat x)
return;
}
GLfloat vals[4] = { x, 0, 0, 1 };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib1f(index, x);
}
}
......@@ -3800,8 +3743,7 @@ void GL_APIENTRY VertexAttrib1fv(GLuint index, const GLfloat* values)
return;
}
GLfloat vals[4] = { values[0], 0, 0, 1 };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib1fv(index, values);
}
}
......@@ -3818,8 +3760,7 @@ void GL_APIENTRY VertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
return;
}
GLfloat vals[4] = { x, y, 0, 1 };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib2f(index, x, y);
}
}
......@@ -3836,8 +3777,7 @@ void GL_APIENTRY VertexAttrib2fv(GLuint index, const GLfloat* values)
return;
}
GLfloat vals[4] = { values[0], values[1], 0, 1 };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib2fv(index, values);
}
}
......@@ -3854,8 +3794,7 @@ void GL_APIENTRY VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
return;
}
GLfloat vals[4] = { x, y, z, 1 };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib3f(index, x, y, z);
}
}
......@@ -3872,8 +3811,7 @@ void GL_APIENTRY VertexAttrib3fv(GLuint index, const GLfloat* values)
return;
}
GLfloat vals[4] = { values[0], values[1], values[2], 1 };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib3fv(index, values);
}
}
......@@ -3890,8 +3828,7 @@ void GL_APIENTRY VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, G
return;
}
GLfloat vals[4] = { x, y, z, w };
context->getState().setVertexAttribf(index, vals);
context->vertexAttrib4f(index, x, y, z, w);
}
}
......@@ -3908,7 +3845,7 @@ void GL_APIENTRY VertexAttrib4fv(GLuint index, const GLfloat* values)
return;
}
context->getState().setVertexAttribf(index, values);
context->vertexAttrib4fv(index, values);
}
}
......@@ -3976,14 +3913,14 @@ void GL_APIENTRY VertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo
// 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 @@ void GL_APIENTRY Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
return;
}
context->getState().setViewportParams(x, y, width, height);
context->viewport(x, y, width, height);
}
}
}
} // namespace gl
......@@ -1139,9 +1139,7 @@ void GL_APIENTRY DebugMessageControlKHR(GLenum source,
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 @@ void GL_APIENTRY DebugMessageInsertKHR(GLenum source,
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 @@ void GL_APIENTRY DebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void *us
return;
}
context->getState().getDebug().setCallback(callback, userParam);
context->debugMessageCallback(callback, userParam);
}
}
......@@ -1211,8 +1208,8 @@ GLuint GL_APIENTRY GetDebugMessageLogKHR(GLuint count,
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 @@ void GL_APIENTRY PushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, con
}
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)
return;
}
context->getState().getDebug().popGroup();
context->popDebugGroup();
}
}
......
......@@ -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)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive())
{
context->handleError(Error(GL_INVALID_OPERATION));
......@@ -910,7 +911,8 @@ void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint 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)
TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
TransformFeedback *curTransformFeedback =
context->getState().getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive())
{
context->handleError(Error(GL_INVALID_OPERATION));
......@@ -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
// 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 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
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)
{
params[i] = currentValueData.IntValues[i];
......@@ -1121,7 +1124,8 @@ void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
}
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 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
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)
{
params[i] = currentValueData.UnsignedIntValues[i];
......@@ -1162,7 +1167,8 @@ void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
}
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 @@ void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint
return;
}
GLint vals[4] = { x, y, z, w };
context->getState().setVertexAttribi(index, vals);
context->vertexAttribI4i(index, x, y, z, w);
}
}
......@@ -1213,8 +1218,7 @@ void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL
return;
}
GLuint vals[4] = { x, y, z, w };
context->getState().setVertexAttribu(index, vals);
context->vertexAttribI4ui(index, x, y, z, w);
}
}
......@@ -1237,7 +1241,7 @@ void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v)
return;
}
context->getState().setVertexAttribi(index, v);
context->vertexAttribI4iv(index, v);
}
}
......@@ -1260,7 +1264,7 @@ void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v)
return;
}
context->getState().setVertexAttribu(index, v);
context->vertexAttribI4uiv(index, v);
}
}
......@@ -1536,7 +1540,7 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintp
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 @@ void GL_APIENTRY BindTransformFeedback(GLenum target, GLuint id)
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));
......
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