From 339ed0984d4f54fca91235a1df2ce3a850f6123f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fredrik=20H=C3=B6glund?= Date: Sun, 10 May 2015 20:46:36 +0200 Subject: [PATCH] mesa: Add ARB_direct_state_access checks in buffer object functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Höglund Reviewed-by: Adam Jackson --- src/mesa/main/bufferobj.c | 105 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 66dee680258..660bc94892e 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1303,6 +1303,12 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa) const char *func = dsa ? "glCreateBuffers" : "glGenBuffers"; + if (dsa && !ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(GL_ARB_direct_state_access is not supported)", func); + return; + } + if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s(%d)\n", func, n); @@ -1477,6 +1483,13 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glNamedBufferStorage(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferStorage"); if (!bufObj) return; @@ -1603,6 +1616,13 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glNamedBufferData(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData"); if (!bufObj) return; @@ -1673,6 +1693,13 @@ _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glNamedBufferSubData(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData"); if (!bufObj) return; @@ -1710,6 +1737,13 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetNamedBufferSubData(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glGetNamedBufferSubData"); if (!bufObj) @@ -1805,6 +1839,13 @@ _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glClearNamedBufferData(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferData"); if (!bufObj) return; @@ -1842,6 +1883,13 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glClearNamedBufferSubData(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferSubData"); if (!bufObj) @@ -1930,6 +1978,13 @@ _mesa_UnmapNamedBuffer(GLuint buffer) GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUnmapNamedBuffer(GL_ARB_direct_state_access " + "is not supported)"); + return GL_FALSE; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer"); if (!bufObj) return GL_FALSE; @@ -2039,6 +2094,13 @@ _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params) struct gl_buffer_object *bufObj; GLint64 parameter; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetNamedBufferParameteriv(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glGetNamedBufferParameteriv"); if (!bufObj) @@ -2059,6 +2121,13 @@ _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname, struct gl_buffer_object *bufObj; GLint64 parameter; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetNamedBufferParameteri64v(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glGetNamedBufferParameteri64v"); if (!bufObj) @@ -2098,6 +2167,13 @@ _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params) GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetNamedBufferPointerv(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + if (pname != GL_BUFFER_MAP_POINTER) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetNamedBufferPointerv(pname != " "GL_BUFFER_MAP_POINTER)"); @@ -2212,6 +2288,13 @@ _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *src, *dst; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyNamedBufferSubData(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + src = _mesa_lookup_bufferobj_err(ctx, readBuffer, "glCopyNamedBufferSubData"); if (!src) @@ -2430,6 +2513,13 @@ _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapNamedBufferRange(GL_ARB_direct_state_access " + "is not supported)"); + return NULL; + } + if (!ctx->Extensions.ARB_map_buffer_range) { _mesa_error(ctx, GL_INVALID_OPERATION, "glMapNamedBufferRange(" @@ -2497,6 +2587,13 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access) struct gl_buffer_object *bufObj; GLbitfield accessFlags; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapNamedBuffer(GL_ARB_direct_state_access " + "is not supported)"); + return NULL; + } + if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) { _mesa_error(ctx, GL_INVALID_ENUM, "glMapNamedBuffer(invalid access)"); return NULL; @@ -2587,6 +2684,14 @@ _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset, GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + if (!ctx->Extensions.ARB_direct_state_access) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFlushMappedNamedBufferRange(GL_ARB_direct_state_access " + "is not supported)"); + return; + } + + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glFlushMappedNamedBufferRange"); if (!bufObj) -- 2.30.2