mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 22:13:25 -10:00
Implement robust the GetBufferPointerv entry point.
BUG=angleproject:1354 Change-Id: Id7dd8438224adb1e2729bcdc18a306e5dfc83a3b Reviewed-on: https://chromium-review.googlesource.com/401399 Commit-Queue: Geoff Lang <[email protected]> Reviewed-by: Corentin Wallez <[email protected]>
This commit is contained in:
1 parent
0a9661f2b4
commit
496c02dfcb
9 files changed
+96
-27
No files matched your search
@@ -3033,19 +3033,12 @@ void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId)
|
||||
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);
|
||||
ASSERT(buffer);
|
||||
|
||||
if (!buffer->isMapped())
|
||||
{
|
||||
*params = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
*params = buffer->getMapPointer();
|
||||
}
|
||||
QueryBufferPointerv(buffer, pname, params);
|
||||
}
|
||||
|
||||
GLvoid *Context::mapBuffer(GLenum target, GLenum access)
|
||||
|
||||
@@ -438,6 +438,20 @@ void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *param
|
||||
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)
|
||||
{
|
||||
ASSERT(program != nullptr);
|
||||
|
||||
@@ -32,6 +32,7 @@ void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer,
|
||||
GLint *params);
|
||||
void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *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 QueryRenderbufferiv(const Renderbuffer *renderbuffer, GLenum pname, GLint *params);
|
||||
void QueryShaderiv(const Shader *shader, GLenum pname, GLint *params);
|
||||
|
||||
@@ -3921,32 +3921,56 @@ bool ValidateCopyTexSubImage2D(Context *context,
|
||||
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 (length)
|
||||
{
|
||||
*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;
|
||||
}
|
||||
|
||||
if (!ValidBufferTarget(context, target))
|
||||
{
|
||||
context->handleError(Error(GL_INVALID_ENUM, "Buffer target not valid: 0x%X", target));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pname != GL_BUFFER_MAP_POINTER)
|
||||
switch (pname)
|
||||
{
|
||||
context->handleError(Error(GL_INVALID_ENUM, "pname not valid: 0x%X", pname));
|
||||
return false;
|
||||
}
|
||||
case GL_BUFFER_MAP_POINTER:
|
||||
break;
|
||||
|
||||
Buffer *buffer = context->getGLState().getTargetBuffer(target);
|
||||
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
|
||||
// target bound to zero generate an INVALID_OPERATION error."
|
||||
// GLES 3.1 section 6.6 explicitly specifies this error.
|
||||
if (!buffer)
|
||||
if (context->getGLState().getTargetBuffer(target) == nullptr)
|
||||
{
|
||||
context->handleError(
|
||||
Error(GL_INVALID_OPERATION, "Can not get pointer for reserved buffer name zero."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (length)
|
||||
{
|
||||
*length = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -325,7 +325,11 @@ bool ValidateCopyTexSubImage2D(Context *context,
|
||||
GLsizei width,
|
||||
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 ValidateMapBufferRangeBase(Context *context,
|
||||
GLenum target,
|
||||
|
||||
@@ -2170,13 +2170,7 @@ bool ValidateCompressedTexSubImage2D(Context *context,
|
||||
|
||||
bool ValidateGetBufferPointervOES(Context *context, GLenum target, GLenum pname, void **params)
|
||||
{
|
||||
if (!context->getExtensions().mapBuffer)
|
||||
{
|
||||
context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return ValidateGetBufferPointervBase(context, target, pname, params);
|
||||
return ValidateGetBufferPointervBase(context, target, pname, nullptr, params);
|
||||
}
|
||||
|
||||
bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access)
|
||||
|
||||
@@ -1791,13 +1791,32 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode)
|
||||
|
||||
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))
|
||||
{
|
||||
context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return ValidateGetBufferPointervBase(context, target, pname, params);
|
||||
if (!ValidateGetBufferPointervBase(context, target, pname, length, params))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ValidateRobustBufferSize(context, bufSize, *length))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateUnmapBuffer(Context *context, GLenum target)
|
||||
|
||||
@@ -318,6 +318,12 @@ bool ValidateGenOrDeleteCountES3(Context *context, GLint count);
|
||||
bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode);
|
||||
|
||||
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 ValidateMapBufferRange(Context *context,
|
||||
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 = "
|
||||
"0x%0.8p, GLvoid** params = 0x%0.8p)",
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user