main: Add entry point for CreateBuffers.
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
This commit is contained in:
parent
44ecf0793d
commit
2cf48c37c1
|
@ -7,6 +7,13 @@
|
|||
<enum name="QUERY_TARGET" value="0x82EA"/>
|
||||
<enum name="TEXTURE_BINDING" value="0x82EB"/>
|
||||
|
||||
<!-- Buffer object functions -->
|
||||
|
||||
<function name="CreateBuffers" offset="assign">
|
||||
<param name="n" type="GLsizei" />
|
||||
<param name="buffers" type="GLuint *" />
|
||||
</function>
|
||||
|
||||
<!-- Texture object functions -->
|
||||
|
||||
<function name="CreateTextures" offset="assign">
|
||||
|
|
|
@ -1292,27 +1292,29 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
|
|||
|
||||
|
||||
/**
|
||||
* Generate a set of unique buffer object IDs and store them in \c buffer.
|
||||
*
|
||||
* \param n Number of IDs to generate.
|
||||
* \param buffer Array of \c n locations to store the IDs.
|
||||
* This is the implementation for glGenBuffers and glCreateBuffers. It is not
|
||||
* exposed to the rest of Mesa to encourage the use of nameless buffers in
|
||||
* driver internals.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_GenBuffers(GLsizei n, GLuint *buffer)
|
||||
static void
|
||||
create_buffers(GLsizei n, GLuint *buffers, bool dsa)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLuint first;
|
||||
GLint i;
|
||||
struct gl_buffer_object *buf;
|
||||
|
||||
const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
|
||||
|
||||
if (MESA_VERBOSE & VERBOSE_API)
|
||||
_mesa_debug(ctx, "glGenBuffers(%d)\n", n);
|
||||
_mesa_debug(ctx, "%s(%d)\n", func, n);
|
||||
|
||||
if (n < 0) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB");
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!buffer) {
|
||||
if (!buffers) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1323,16 +1325,53 @@ _mesa_GenBuffers(GLsizei n, GLuint *buffer)
|
|||
|
||||
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n);
|
||||
|
||||
/* Insert the ID and pointer to dummy buffer object into hash table */
|
||||
/* Insert the ID and pointer into the hash table. If non-DSA, insert a
|
||||
* DummyBufferObject. Otherwise, create a new buffer object and insert
|
||||
* it.
|
||||
*/
|
||||
for (i = 0; i < n; i++) {
|
||||
_mesa_HashInsert(ctx->Shared->BufferObjects, first + i,
|
||||
&DummyBufferObject);
|
||||
buffer[i] = first + i;
|
||||
buffers[i] = first + i;
|
||||
if (dsa) {
|
||||
assert(ctx->Driver.NewBufferObject);
|
||||
buf = ctx->Driver.NewBufferObject(ctx, buffers[i]);
|
||||
if (!buf) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
buf = &DummyBufferObject;
|
||||
|
||||
_mesa_HashInsert(ctx->Shared->BufferObjects, buffers[i], buf);
|
||||
}
|
||||
|
||||
mtx_unlock(&ctx->Shared->Mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(GLsizei n, GLuint *buffers)
|
||||
{
|
||||
create_buffers(n, buffers, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a set of buffer objects and store their unique IDs in \c buffers.
|
||||
*
|
||||
* \param n Number of IDs to generate.
|
||||
* \param buffers Array of \c n locations to store the IDs.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_CreateBuffers(GLsizei n, GLuint *buffers)
|
||||
{
|
||||
create_buffers(n, buffers, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if ID is the name of a buffer object.
|
||||
|
|
|
@ -150,7 +150,10 @@ void GLAPIENTRY
|
|||
_mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GenBuffers(GLsizei n, GLuint * buffer);
|
||||
_mesa_GenBuffers(GLsizei n, GLuint *buffers);
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_CreateBuffers(GLsizei n, GLuint *buffers);
|
||||
|
||||
GLboolean GLAPIENTRY
|
||||
_mesa_IsBuffer(GLuint buffer);
|
||||
|
|
|
@ -953,6 +953,7 @@ const struct function gl_core_functions_possible[] = {
|
|||
{ "glClipControl", 45, -1 },
|
||||
|
||||
/* GL_ARB_direct_state_access */
|
||||
{ "glCreateBuffers", 45, -1 },
|
||||
{ "glCreateTextures", 45, -1 },
|
||||
{ "glTextureStorage1D", 45, -1 },
|
||||
{ "glTextureStorage2D", 45, -1 },
|
||||
|
|
Loading…
Reference in New Issue