Commit 007530ea by Jamie Madill Committed by Commit Bot

Entry Points: Refactor Extensions Part 2.

This moves the validation and entry point files to use a consistent syntax. This will facilitate auto-generation. Bug: angleproject:2263 Change-Id: If5d06e97db66783d7b3d7fb1d6365f8218d956ae Reviewed-on: https://chromium-review.googlesource.com/846022 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent f095799b
......@@ -741,9 +741,9 @@ void Context::setPathCommands(GLuint path,
handleError(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords));
}
void Context::setPathParameterf(GLuint path, GLenum pname, GLfloat value)
void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value)
{
auto *pathObj = mState.mPaths->getPath(path);
Path *pathObj = mState.mPaths->getPath(path);
switch (pname)
{
......@@ -768,9 +768,15 @@ void Context::setPathParameterf(GLuint path, GLenum pname, GLfloat value)
}
}
void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) const
void Context::pathParameteri(GLuint path, GLenum pname, GLint value)
{
const auto *pathObj = mState.mPaths->getPath(path);
// TODO(jmadill): Should use proper clamping/casting.
pathParameterf(path, pname, static_cast<GLfloat>(value));
}
void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value)
{
const Path *pathObj = mState.mPaths->getPath(path);
switch (pname)
{
......@@ -795,6 +801,14 @@ void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) cons
}
}
void Context::getPathParameteriv(GLuint path, GLenum pname, GLint *value)
{
GLfloat val = 0.0f;
getPathParameterfv(path, pname, value != nullptr ? &val : nullptr);
if (value)
*value = static_cast<GLint>(val);
}
void Context::setPathStencilFunc(GLenum func, GLint ref, GLuint mask)
{
mGLState.setPathStencilFunc(func, ref, mask);
......@@ -1840,7 +1854,17 @@ void Context::insertEventMarker(GLsizei length, const char *marker)
void Context::pushGroupMarker(GLsizei length, const char *marker)
{
ASSERT(mImplementation);
mImplementation->pushGroupMarker(length, marker);
if (marker == nullptr)
{
// From the EXT_debug_marker spec,
// "If <marker> is null then an empty string is pushed on the stack."
mImplementation->pushGroupMarker(length, "");
}
else
{
mImplementation->pushGroupMarker(length, marker);
}
}
void Context::popGroupMarker()
......@@ -3424,16 +3448,16 @@ void Context::generateMipmap(GLenum target)
handleError(texture->generateMipmap(this));
}
void Context::copyTextureCHROMIUM(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint internalFormat,
GLenum destType,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha)
void Context::copyTexture(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint internalFormat,
GLenum destType,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha)
{
syncStateForTexImage();
......@@ -3445,20 +3469,20 @@ void Context::copyTextureCHROMIUM(GLuint sourceId,
ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
}
void Context::copySubTextureCHROMIUM(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha)
void Context::copySubTexture(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha)
{
// Zero sized copies are valid but no-ops
if (width == 0 || height == 0)
......@@ -3478,7 +3502,7 @@ void Context::copySubTextureCHROMIUM(GLuint sourceId,
ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
}
void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId)
void Context::compressedCopyTexture(GLuint sourceId, GLuint destId)
{
syncStateForTexImage();
......@@ -5748,4 +5772,45 @@ void Context::readnPixels(GLint x,
return readPixels(x, y, width, height, format, type, data);
}
void Context::setFenceNV(GLuint fence, GLenum condition)
{
ASSERT(condition == GL_ALL_COMPLETED_NV);
FenceNV *fenceObject = getFenceNV(fence);
ASSERT(fenceObject != nullptr);
handleError(fenceObject->set(condition));
}
GLboolean Context::testFenceNV(GLuint fence)
{
FenceNV *fenceObject = getFenceNV(fence);
ASSERT(fenceObject != nullptr);
ASSERT(fenceObject->isSet() == GL_TRUE);
GLboolean result = GL_TRUE;
Error error = fenceObject->test(&result);
if (error.isError())
{
handleError(error);
return GL_TRUE;
}
return result;
}
void Context::eGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
Texture *texture = getTargetTexture(target);
egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
handleError(texture->setEGLImageTarget(this, target, imageObject));
}
void Context::eGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
{
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
handleError(renderbuffer->setStorageEGLImageTarget(this, imageObject));
}
} // namespace gl
......@@ -106,8 +106,10 @@ class Context final : public ValidationContext
GLsizei numCoords,
GLenum coordType,
const void *coords);
void setPathParameterf(GLuint path, GLenum pname, GLfloat value);
void getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) const;
void pathParameterf(GLuint path, GLenum pname, GLfloat value);
void pathParameteri(GLuint path, GLenum pname, GLint value);
void getPathParameterfv(GLuint path, GLenum pname, GLfloat *value);
void getPathParameteriv(GLuint path, GLenum pname, GLint *value);
void setPathStencilFunc(GLenum func, GLint ref, GLuint mask);
// Framebuffers are owned by the Context, so these methods do not pass through
......@@ -120,6 +122,8 @@ class Context final : public ValidationContext
void finishFenceNV(GLuint fence);
void getFenceivNV(GLuint fence, GLenum pname, GLint *params);
GLboolean isFenceNV(GLuint fence);
void setFenceNV(GLuint fence, GLenum condition);
GLboolean testFenceNV(GLuint fence);
void bindTexture(GLenum target, GLuint handle);
void bindReadFramebuffer(GLuint framebufferHandle);
......@@ -527,31 +531,31 @@ class Context final : public ValidationContext
GLenum format,
GLsizei imageSize,
const void *data);
void copyTextureCHROMIUM(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint internalFormat,
GLenum destType,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha);
void copySubTextureCHROMIUM(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha);
void compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId);
void copyTexture(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint internalFormat,
GLenum destType,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha);
void copySubTexture(GLuint sourceId,
GLint sourceLevel,
GLenum destTarget,
GLuint destId,
GLint destLevel,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLboolean unpackFlipY,
GLboolean unpackPremultiplyAlpha,
GLboolean unpackUnmultiplyAlpha);
void compressedCopyTexture(GLuint sourceId, GLuint destId);
void generateMipmap(GLenum target);
......@@ -979,6 +983,8 @@ class Context final : public ValidationContext
GLenum type,
GLsizei bufSize,
void *data);
void eGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
void eGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
// Consumes the error.
void handleError(const Error &error) override;
......
......@@ -3167,8 +3167,15 @@ bool ValidateDiscardFramebufferBase(Context *context,
bool ValidateInsertEventMarkerEXT(Context *context, GLsizei length, const char *marker)
{
// Note that debug marker calls must not set error state
if (!context->getExtensions().debugMarker)
{
// The debug marker calls should not set error state
// However, it seems reasonable to set an error state if the extension is not enabled
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false;
}
// Note that debug marker calls must not set error state
if (length < 0)
{
return false;
......@@ -3184,8 +3191,15 @@ bool ValidateInsertEventMarkerEXT(Context *context, GLsizei length, const char *
bool ValidatePushGroupMarkerEXT(Context *context, GLsizei length, const char *marker)
{
// Note that debug marker calls must not set error state
if (!context->getExtensions().debugMarker)
{
// The debug marker calls should not set error state
// However, it seems reasonable to set an error state if the extension is not enabled
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExtensionNotEnabled);
return false;
}
// Note that debug marker calls must not set error state
if (length < 0)
{
return false;
......@@ -3199,9 +3213,7 @@ bool ValidatePushGroupMarkerEXT(Context *context, GLsizei length, const char *ma
return true;
}
bool ValidateEGLImageTargetTexture2DOES(Context *context,
GLenum target,
egl::Image *image)
bool ValidateEGLImageTargetTexture2DOES(Context *context, GLenum target, GLeglImageOES image)
{
if (!context->getExtensions().eglImage && !context->getExtensions().eglImageExternal)
{
......@@ -3232,14 +3244,16 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context,
return false;
}
egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
ASSERT(context->getCurrentDisplay());
if (!context->getCurrentDisplay()->isValidImage(image))
if (!context->getCurrentDisplay()->isValidImage(imageObject))
{
context->handleError(InvalidValue() << "EGL image is not valid.");
return false;
}
if (image->getSamples() > 0)
if (imageObject->getSamples() > 0)
{
context->handleError(InvalidOperation()
<< "cannot create a 2D texture from a multisampled EGL image.");
......@@ -3247,7 +3261,7 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context,
}
const TextureCaps &textureCaps =
context->getTextureCaps().get(image->getFormat().info->sizedInternalFormat);
context->getTextureCaps().get(imageObject->getFormat().info->sizedInternalFormat);
if (!textureCaps.texturable)
{
context->handleError(InvalidOperation()
......@@ -3260,7 +3274,7 @@ bool ValidateEGLImageTargetTexture2DOES(Context *context,
bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context,
GLenum target,
egl::Image *image)
GLeglImageOES image)
{
if (!context->getExtensions().eglImage)
{
......@@ -3278,15 +3292,17 @@ bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context,
return false;
}
egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
ASSERT(context->getCurrentDisplay());
if (!context->getCurrentDisplay()->isValidImage(image))
if (!context->getCurrentDisplay()->isValidImage(imageObject))
{
context->handleError(InvalidValue() << "EGL image is not valid.");
return false;
}
const TextureCaps &textureCaps =
context->getTextureCaps().get(image->getFormat().info->sizedInternalFormat);
context->getTextureCaps().get(imageObject->getFormat().info->sizedInternalFormat);
if (!textureCaps.renderable)
{
context->handleError(InvalidOperation()
......
......@@ -39,7 +39,6 @@ bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum ta
bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target);
bool ValidTexLevelDestinationTarget(const ValidationContext *context, GLenum target);
bool ValidFramebufferTarget(const ValidationContext *context, GLenum target);
bool ValidBufferParameter(const ValidationContext *context, GLenum pname, GLsizei *numParams);
bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level);
bool ValidImageSizeParameters(ValidationContext *context,
GLenum target,
......@@ -337,12 +336,10 @@ bool ValidateDiscardFramebufferBase(Context *context,
bool ValidateInsertEventMarkerEXT(Context *context, GLsizei length, const char *marker);
bool ValidatePushGroupMarkerEXT(Context *context, GLsizei length, const char *marker);
bool ValidateEGLImageTargetTexture2DOES(Context *context,
GLenum target,
egl::Image *image);
bool ValidateEGLImageTargetTexture2DOES(Context *context, GLenum target, GLeglImageOES image);
bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context,
GLenum target,
egl::Image *image);
GLeglImageOES image);
bool ValidateBindVertexArrayBase(Context *context, GLuint array);
......
......@@ -218,8 +218,8 @@ ANGLE_EXPORT void GL_APIENTRY PathCommandsCHROMIUM(GLuint path,
const void *coords);
ANGLE_EXPORT void GL_APIENTRY PathParameterfCHROMIUM(GLuint path, GLenum pname, GLfloat value);
ANGLE_EXPORT void GL_APIENTRY PathParameteriCHROMIUM(GLuint path, GLenum pname, GLint value);
ANGLE_EXPORT void GL_APIENTRY GetPathParameterfCHROMIUM(GLuint path, GLenum pname, GLfloat *value);
ANGLE_EXPORT void GL_APIENTRY GetPathParameteriCHROMIUM(GLuint path, GLenum pname, GLint *value);
ANGLE_EXPORT void GL_APIENTRY GetPathParameterfvCHROMIUM(GLuint path, GLenum pname, GLfloat *value);
ANGLE_EXPORT void GL_APIENTRY GetPathParameterivCHROMIUM(GLuint path, GLenum pname, GLint *value);
ANGLE_EXPORT void GL_APIENTRY PathStencilFuncCHROMIUM(GLenum func, GLint ref, GLuint mask);
ANGLE_EXPORT void GL_APIENTRY StencilFillPathCHROMIUM(GLuint path, GLenum fillMode, GLuint mask);
ANGLE_EXPORT void GL_APIENTRY StencilStrokePathCHROMIUM(GLuint path, GLint reference, GLuint mask);
......
......@@ -1938,12 +1938,12 @@ void GL_APIENTRY glPathParameteriCHROMIUM(GLuint path, GLenum pname, GLint value
void GL_APIENTRY glGetPathParameterfvCHROMIUM(GLuint path, GLenum pname, GLfloat *value)
{
gl::GetPathParameterfCHROMIUM(path, pname, value);
gl::GetPathParameterfvCHROMIUM(path, pname, value);
}
void GL_APIENTRY glGetPathParameterivCHROMIUM(GLuint path, GLenum pname, GLint *value)
{
gl::GetPathParameteriCHROMIUM(path, pname, value);
gl::GetPathParameterivCHROMIUM(path, pname, value);
}
void GL_APIENTRY glPathStencilFuncCHROMIUM(GLenum func, GLint ref, GLuint mask)
......
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