Commit 496c02df by Geoff Lang Committed by Commit Bot

Implement robust the GetBufferPointerv entry point.

BUG=angleproject:1354 Change-Id: Id7dd8438224adb1e2729bcdc18a306e5dfc83a3b Reviewed-on: https://chromium-review.googlesource.com/401399 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 0a9661f2
...@@ -3033,19 +3033,12 @@ void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId) ...@@ -3033,19 +3033,12 @@ void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId)
handleError(destTexture->copyCompressedTexture(sourceTexture)); handleError(destTexture->copyCompressedTexture(sourceTexture));
} }
void Context::getBufferPointerv(GLenum target, GLenum /*pname*/, void **params) void Context::getBufferPointerv(GLenum target, GLenum pname, void **params)
{ {
Buffer *buffer = mGLState.getTargetBuffer(target); Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer); ASSERT(buffer);
if (!buffer->isMapped()) QueryBufferPointerv(buffer, pname, params);
{
*params = nullptr;
}
else
{
*params = buffer->getMapPointer();
}
} }
GLvoid *Context::mapBuffer(GLenum target, GLenum access) GLvoid *Context::mapBuffer(GLenum target, GLenum access)
......
...@@ -438,6 +438,20 @@ void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *param ...@@ -438,6 +438,20 @@ void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *param
QueryBufferParameterBase(buffer, pname, params); QueryBufferParameterBase(buffer, pname, params);
} }
void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params)
{
switch (pname)
{
case GL_BUFFER_MAP_POINTER:
*params = buffer->getMapPointer();
break;
default:
UNREACHABLE();
break;
}
}
void QueryProgramiv(const Program *program, GLenum pname, GLint *params) void QueryProgramiv(const Program *program, GLenum pname, GLint *params)
{ {
ASSERT(program != nullptr); ASSERT(program != nullptr);
......
...@@ -32,6 +32,7 @@ void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer, ...@@ -32,6 +32,7 @@ void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer,
GLint *params); GLint *params);
void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *params); void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *params);
void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *params); void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *params);
void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params);
void QueryProgramiv(const Program *program, GLenum pname, GLint *params); void QueryProgramiv(const Program *program, GLenum pname, GLint *params);
void QueryRenderbufferiv(const Renderbuffer *renderbuffer, GLenum pname, GLint *params); void QueryRenderbufferiv(const Renderbuffer *renderbuffer, GLenum pname, GLint *params);
void QueryShaderiv(const Shader *shader, GLenum pname, GLint *params); void QueryShaderiv(const Shader *shader, GLenum pname, GLint *params);
......
...@@ -3921,32 +3921,56 @@ bool ValidateCopyTexSubImage2D(Context *context, ...@@ -3921,32 +3921,56 @@ bool ValidateCopyTexSubImage2D(Context *context,
yoffset, 0, x, y, width, height, 0); yoffset, 0, x, y, width, height, 0);
} }
bool ValidateGetBufferPointervBase(Context *context, GLenum target, GLenum pname, void **params) bool ValidateGetBufferPointervBase(Context *context,
GLenum target,
GLenum pname,
GLsizei *length,
void **params)
{ {
if (!ValidBufferTarget(context, target)) if (length)
{ {
context->handleError(Error(GL_INVALID_ENUM, "Buffer target not valid: 0x%X", target)); *length = 0;
}
if (context->getClientMajorVersion() < 3 && !context->getExtensions().mapBuffer)
{
context->handleError(
Error(GL_INVALID_OPERATION,
"Context does not support OpenGL ES 3.0 or GL_OES_map_buffer is not enabled."));
return false; return false;
} }
if (pname != GL_BUFFER_MAP_POINTER) if (!ValidBufferTarget(context, target))
{ {
context->handleError(Error(GL_INVALID_ENUM, "pname not valid: 0x%X", pname)); context->handleError(Error(GL_INVALID_ENUM, "Buffer target not valid: 0x%X", target));
return false; return false;
} }
Buffer *buffer = context->getGLState().getTargetBuffer(target); switch (pname)
{
case GL_BUFFER_MAP_POINTER:
break;
default:
context->handleError(Error(GL_INVALID_ENUM, "Unknown pname."));
return false;
}
// GLES 3.0 section 2.10.1: "Attempts to attempts to modify or query buffer object state for a // GLES 3.0 section 2.10.1: "Attempts to attempts to modify or query buffer object state for a
// target bound to zero generate an INVALID_OPERATION error." // target bound to zero generate an INVALID_OPERATION error."
// GLES 3.1 section 6.6 explicitly specifies this error. // GLES 3.1 section 6.6 explicitly specifies this error.
if (!buffer) if (context->getGLState().getTargetBuffer(target) == nullptr)
{ {
context->handleError( context->handleError(
Error(GL_INVALID_OPERATION, "Can not get pointer for reserved buffer name zero.")); Error(GL_INVALID_OPERATION, "Can not get pointer for reserved buffer name zero."));
return false; return false;
} }
if (length)
{
*length = 1;
}
return true; return true;
} }
......
...@@ -325,7 +325,11 @@ bool ValidateCopyTexSubImage2D(Context *context, ...@@ -325,7 +325,11 @@ bool ValidateCopyTexSubImage2D(Context *context,
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
bool ValidateGetBufferPointervBase(Context *context, GLenum target, GLenum pname, void **params); bool ValidateGetBufferPointervBase(Context *context,
GLenum target,
GLenum pname,
GLsizei *length,
void **params);
bool ValidateUnmapBufferBase(Context *context, GLenum target); bool ValidateUnmapBufferBase(Context *context, GLenum target);
bool ValidateMapBufferRangeBase(Context *context, bool ValidateMapBufferRangeBase(Context *context,
GLenum target, GLenum target,
......
...@@ -2170,13 +2170,7 @@ bool ValidateCompressedTexSubImage2D(Context *context, ...@@ -2170,13 +2170,7 @@ bool ValidateCompressedTexSubImage2D(Context *context,
bool ValidateGetBufferPointervOES(Context *context, GLenum target, GLenum pname, void **params) bool ValidateGetBufferPointervOES(Context *context, GLenum target, GLenum pname, void **params)
{ {
if (!context->getExtensions().mapBuffer) return ValidateGetBufferPointervBase(context, target, pname, nullptr, params);
{
context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available."));
return false;
}
return ValidateGetBufferPointervBase(context, target, pname, params);
} }
bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access) bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access)
......
...@@ -1791,13 +1791,32 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) ...@@ -1791,13 +1791,32 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode)
bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params) bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params)
{ {
if (context->getClientMajorVersion() < 3) return ValidateGetBufferPointervBase(context, target, pname, nullptr, params);
}
bool ValidateGetBufferPointervRobustANGLE(Context *context,
GLenum target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLvoid **params)
{
if (!ValidateRobustEntryPoint(context, bufSize))
{
return false;
}
if (!ValidateGetBufferPointervBase(context, target, pname, length, params))
{
return false;
}
if (!ValidateRobustBufferSize(context, bufSize, *length))
{ {
context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
return false; return false;
} }
return ValidateGetBufferPointervBase(context, target, pname, params); return true;
} }
bool ValidateUnmapBuffer(Context *context, GLenum target) bool ValidateUnmapBuffer(Context *context, GLenum target)
......
...@@ -318,6 +318,12 @@ bool ValidateGenOrDeleteCountES3(Context *context, GLint count); ...@@ -318,6 +318,12 @@ bool ValidateGenOrDeleteCountES3(Context *context, GLint count);
bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode); bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode);
bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params); bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params);
bool ValidateGetBufferPointervRobustANGLE(Context *context,
GLenum target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLvoid **params);
bool ValidateUnmapBuffer(Context *context, GLenum target); bool ValidateUnmapBuffer(Context *context, GLenum target);
bool ValidateMapBufferRange(Context *context, bool ValidateMapBufferRange(Context *context,
GLenum target, GLenum target,
......
...@@ -2658,6 +2658,20 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferPointervRobustANGLE(GLenum target, ...@@ -2658,6 +2658,20 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferPointervRobustANGLE(GLenum target,
"(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = " "(GLenum target = 0x%X, GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = "
"0x%0.8p, GLvoid** params = 0x%0.8p)", "0x%0.8p, GLvoid** params = 0x%0.8p)",
target, pname, bufSize, length, params); target, pname, bufSize, length, params);
Context *context = GetValidGlobalContext();
if (context)
{
GLsizei numParams = 0;
if (!ValidateGetBufferPointervRobustANGLE(context, target, pname, bufSize, &numParams,
params))
{
return;
}
context->getBufferPointerv(target, pname, params);
SetRobustLengthParam(length, numParams);
}
} }
ANGLE_EXPORT void GL_APIENTRY ANGLE_EXPORT void GL_APIENTRY
......
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