X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fbufferobj.c;h=419972e37127137eec4f09f72debf640ed744de2;hb=9853ca6037b92d176ea35dc0d213b66c25392dc0;hp=e66a3a566889f3ee6cf9da5be2abe15298b65e94;hpb=c231590f8d1e474c2c8e5bcf7a3956903b2b8ccc;p=mesa.git diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index e66a3a56688..419972e3712 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1416,25 +1416,13 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids) * driver internals. */ static void -create_buffers(GLsizei n, GLuint *buffers, bool dsa) +create_buffers(struct gl_context *ctx, GLsizei n, GLuint *buffers, bool dsa) { - GET_CURRENT_CONTEXT(ctx); GLuint first; struct gl_buffer_object *buf; - const char *func = dsa ? "glCreateBuffers" : "glGenBuffers"; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "%s(%d)\n", func, n); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n); - return; - } - - if (!buffers) { + if (!buffers) return; - } /* * This must be atomic (generation and allocation of buffer object IDs) @@ -1453,7 +1441,7 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa) assert(ctx->Driver.NewBufferObject); buf = ctx->Driver.NewBufferObject(ctx, buffers[i]); if (!buf) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCreateBuffers"); _mesa_HashUnlockMutex(ctx->Shared->BufferObjects); return; } @@ -1467,16 +1455,42 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa) _mesa_HashUnlockMutex(ctx->Shared->BufferObjects); } + +static void +create_buffers_err(struct gl_context *ctx, GLsizei n, GLuint *buffers, bool dsa) +{ + const char *func = dsa ? "glCreateBuffers" : "glGenBuffers"; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "%s(%d)\n", func, n); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n); + return; + } + + create_buffers(ctx, n, buffers, dsa); +} + /** * Generate a set of unique buffer object IDs and store them in \c buffers. * * \param n Number of IDs to generate. * \param buffers Array of \c n locations to store the IDs. */ +void GLAPIENTRY +_mesa_GenBuffers_no_error(GLsizei n, GLuint *buffers) +{ + GET_CURRENT_CONTEXT(ctx); + create_buffers(ctx, n, buffers, false); +} + + void GLAPIENTRY _mesa_GenBuffers(GLsizei n, GLuint *buffers) { - create_buffers(n, buffers, false); + GET_CURRENT_CONTEXT(ctx); + create_buffers_err(ctx, n, buffers, false); } /** @@ -1485,10 +1499,19 @@ _mesa_GenBuffers(GLsizei n, GLuint *buffers) * \param n Number of IDs to generate. * \param buffers Array of \c n locations to store the IDs. */ +void GLAPIENTRY +_mesa_CreateBuffers_no_error(GLsizei n, GLuint *buffers) +{ + GET_CURRENT_CONTEXT(ctx); + create_buffers(ctx, n, buffers, true); +} + + void GLAPIENTRY _mesa_CreateBuffers(GLsizei n, GLuint *buffers) { - create_buffers(n, buffers, true); + GET_CURRENT_CONTEXT(ctx); + create_buffers_err(ctx, n, buffers, true); } @@ -1562,7 +1585,7 @@ validate_buffer_storage(struct gl_context *ctx, return false; } - if (bufObj->Immutable) { + if (bufObj->Immutable || bufObj->HandleAllocated) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func); return false; } @@ -1579,7 +1602,7 @@ buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj, /* Unmap the existing buffer. We'll replace it now. Not an error. */ _mesa_buffer_unmap_all_mappings(ctx, bufObj); - FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT); + FLUSH_VERTICES(ctx, 0); bufObj->Written = GL_TRUE; bufObj->Immutable = GL_TRUE; @@ -1726,7 +1749,7 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, return; } - if (bufObj->Immutable) { + if (bufObj->Immutable || bufObj->HandleAllocated) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func); return; } @@ -1734,7 +1757,7 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, /* Unmap the existing buffer. We'll replace it now. Not an error. */ _mesa_buffer_unmap_all_mappings(ctx, bufObj); - FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT); + FLUSH_VERTICES(ctx, 0); bufObj->Written = GL_TRUE; bufObj->MinMaxCacheDirty = true;