<div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Laura Ekstrand</b> <span dir="ltr"><<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>></span><br>Date: Fri, Jan 30, 2015 at 3:42 PM<br>Subject: Re: [Mesa-dev] [PATCH 06/21] main: Add entry point for NamedBufferData.<br>To: Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>><br><br><br><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Jan 21, 2015 at 6:28 PM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 01/21/2015 05:40 PM, Laura Ekstrand wrote:<br>
> ---<br>
> src/mapi/glapi/gen/ARB_direct_state_access.xml | 9 ++-<br>
> src/mesa/main/bufferobj.c | 77 ++++++++++++++++----------<br>
> src/mesa/main/bufferobj.h | 13 ++++-<br>
> src/mesa/main/tests/dispatch_sanity.cpp | 1 +<br>
> 4 files changed, 69 insertions(+), 31 deletions(-)<br>
><br>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> index ff81c21..4b1ef6f 100644<br>
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> @@ -21,7 +21,14 @@<br>
> <param name="flags" type="GLbitfield" /><br>
> </function><br>
><br>
> - <!-- Texture object functions --><br>
> + <function name="NamedBufferData" offset="assign"><br>
> + <param name="buffer" type="GLuint" /><br>
> + <param name="size" type="GLsizeiptr" /><br>
> + <param name="data" type="const GLvoid *" /><br>
> + <param name="usage" type="GLenum" /><br>
> + </function><br>
> +<br>
> + <!-- Texture object functions --><br>
<br>
</span>I think you accidentally deleted a space before this comment.<br>
<span><br>
><br>
> <function name="CreateTextures" offset="assign"><br>
> <param name="target" type="GLenum" /><br>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c<br>
> index 0977459..c77029f 100644<br>
> --- a/src/mesa/main/bufferobj.c<br>
> +++ b/src/mesa/main/bufferobj.c<br>
> @@ -556,9 +556,9 @@ _mesa_total_buffer_object_memory(struct gl_context *ctx)<br>
> * \sa glBufferDataARB, dd_function_table::BufferData.<br>
> */<br>
> static GLboolean<br>
> -_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,<br>
> - const GLvoid * data, GLenum usage, GLenum storageFlags,<br>
> - struct gl_buffer_object * bufObj )<br>
> +_mesa_BufferData_sw(struct gl_context *ctx, GLenum target, GLsizeiptr size,<br>
> + const GLvoid *data, GLenum usage, GLenum storageFlags,<br>
> + struct gl_buffer_object *bufObj)<br>
<br></span></blockquote></div></div><div>You are confused here. This function has nothing to do with swrast. It is a fallback for a DD-table entry. <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
</span>We should pick a different name for this. Names with this pattern are<br>
(almost exclusively) direct API entry points. Maybe _swrast_buffer_data?<br>
<br>
Alternately, if the "new" _mesa_buffer_data will only ever be called<br>
from the same file, we could just call that buffer_data and make it static.<br>
<div><div><br>
> {<br>
> void * new_data;<br>
><br>
> @@ -1112,7 +1112,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)<br>
> /* GL_ARB_vertex/pixel_buffer_object */<br>
> driver->NewBufferObject = _mesa_new_buffer_object;<br>
> driver->DeleteBuffer = _mesa_delete_buffer_object;<br>
> - driver->BufferData = _mesa_buffer_data;<br>
> + driver->BufferData = _mesa_BufferData_sw;<br>
> driver->BufferSubData = _mesa_buffer_subdata;<br>
> driver->GetBufferSubData = _mesa_buffer_get_subdata;<br>
> driver->UnmapBuffer = _mesa_buffer_unmap;<br>
> @@ -1474,23 +1474,22 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,<br>
> }<br>
><br>
><br>
> -<br>
> -void GLAPIENTRY<br>
> -_mesa_BufferData(GLenum target, GLsizeiptrARB size,<br>
> - const GLvoid * data, GLenum usage)<br>
> +void<br>
> +_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,<br>
> + GLenum target, GLsizeiptr size, const GLvoid *data,<br>
> + GLenum usage, const char *func)<br>
> {<br>
> - GET_CURRENT_CONTEXT(ctx);<br>
> - struct gl_buffer_object *bufObj;<br>
> bool valid_usage;<br>
><br>
> if (MESA_VERBOSE & VERBOSE_API)<br>
> - _mesa_debug(ctx, "glBufferData(%s, %ld, %p, %s)\n",<br>
> + _mesa_debug(ctx, "%s(%s, %ld, %p, %s)\n",<br>
> + func,<br>
> _mesa_lookup_enum_by_nr(target),<br>
> (long int) size, data,<br>
> _mesa_lookup_enum_by_nr(usage));<br>
><br>
> if (size < 0) {<br>
> - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)");<br>
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", func);<br>
> return;<br>
> }<br>
><br>
> @@ -1519,16 +1518,13 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,<br>
> }<br>
><br>
> if (!valid_usage) {<br>
> - _mesa_error(ctx, GL_INVALID_ENUM, "glBufferData(usage)");<br>
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid usage: %s)", func,<br>
> + _mesa_lookup_enum_by_nr(usage));<br>
> return;<br>
> }<br>
><br>
> - bufObj = get_buffer(ctx, "glBufferDataARB", target, GL_INVALID_OPERATION);<br>
> - if (!bufObj)<br>
> - return;<br>
> -<br>
> if (bufObj->Immutable) {<br>
> - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferData(immutable)");<br>
> + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);<br>
> return;<br>
> }<br>
><br>
> @@ -1539,25 +1535,50 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,<br>
><br>
> bufObj->Written = GL_TRUE;<br>
><br>
> -#ifdef VBO_DEBUG<br>
> - printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n",<br>
> - bufObj->Name, size, data, usage);<br>
> -#endif<br>
> -<br>
> -#ifdef BOUNDS_CHECK<br>
> - size += 100;<br>
> -#endif<br>
> -<br>
<br></div></div></blockquote></div></div><div>I believe what you meant to say is that this deletion should be in a separate commit so we can revert it later if we want to? <br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
</div></div>This change by itself is not okay. If someone builds with BOUNDS_CHECK<br>
defined, the code in _mesa_MapBuffer and _mesa_UnmapBuffer will explode.<br>
I don't know how much utility there is to BOUNDS_CHECK or VBO_DEBUG.<br>
I'd be inclined to send separate patches that completely remove each of<br>
those.<br>
<br>
It looks like BOUNDS_CHECK was added by Brian Paul in commit 4a7fd632.<br>
Maybe he has an opinion...<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><br>
> ASSERT(ctx->Driver.BufferData);<br>
> if (!ctx->Driver.BufferData(ctx, target, size, data, usage,<br>
> GL_MAP_READ_BIT |<br>
> GL_MAP_WRITE_BIT |<br>
> GL_DYNAMIC_STORAGE_BIT,<br>
> bufObj)) {<br>
> - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB()");<br>
> + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);<br>
> }<br>
> }<br>
><br>
> +void GLAPIENTRY<br>
> +_mesa_BufferData(GLenum target, GLsizeiptr size,<br>
> + const GLvoid *data, GLenum usage)<br>
> +{<br>
> + GET_CURRENT_CONTEXT(ctx);<br>
> + struct gl_buffer_object *bufObj;<br>
> +<br>
> + bufObj = get_buffer(ctx, "glBufferData", target, GL_INVALID_OPERATION);<br>
> + if (!bufObj)<br>
> + return;<br>
> +<br>
> + _mesa_buffer_data(ctx, bufObj, target, size, data, usage,<br>
> + "glBufferData");<br>
> +}<br>
> +<br>
> +void GLAPIENTRY<br>
> +_mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,<br>
> + GLenum usage)<br>
> +{<br>
> + GET_CURRENT_CONTEXT(ctx);<br>
> + struct gl_buffer_object *bufObj;<br>
> +<br>
> + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData");<br>
> + if (!bufObj)<br>
> + return;<br>
> +<br>
> + /*<br>
> + * In direct state access, buffer objects have an unspecified target since<br>
> + * they are not required to be bound.<br>
> + */<br>
<br>
</div></div>Tiny nit... the opening /* should go on the same like with the start of<br>
the comment text. It's probably not worth going through the series to<br>
change the existing occurrences, but new code should use that style.<br>
<div><div><br>
> + _mesa_buffer_data(ctx, bufObj, GL_NONE, size, data, usage,<br>
> + "glNamedBufferData");<br>
> +}<br>
> +<br>
><br>
> void GLAPIENTRY<br>
> _mesa_BufferSubData(GLenum target, GLintptrARB offset,<br>
> diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h<br>
> index 0537bd4..9801c87 100644<br>
> --- a/src/mesa/main/bufferobj.h<br>
> +++ b/src/mesa/main/bufferobj.h<br>
> @@ -135,6 +135,11 @@ _mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,<br>
> GLbitfield flags, const char *func);<br>
><br>
> extern void<br>
> +_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,<br>
> + GLenum target, GLsizeiptr size, const GLvoid *data,<br>
> + GLenum usage, const char *func);<br>
> +<br>
> +extern void<br>
> _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,<br>
> struct gl_buffer_object *bufObj);<br>
><br>
> @@ -172,8 +177,12 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,<br>
> GLbitfield flags);<br>
><br>
> void GLAPIENTRY<br>
> -_mesa_BufferData(GLenum target, GLsizeiptrARB size,<br>
> - const GLvoid * data, GLenum usage);<br>
> +_mesa_BufferData(GLenum target, GLsizeiptr size,<br>
> + const GLvoid *data, GLenum usage);<br>
> +<br>
> +void GLAPIENTRY<br>
> +_mesa_NamedBufferData(GLuint buffer, GLsizeiptr size,<br>
> + const GLvoid *data, GLenum usage);<br>
><br>
> void GLAPIENTRY<br>
> _mesa_BufferSubData(GLenum target, GLintptrARB offset,<br>
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp<br>
> index 131d15e..3c87b5e 100644<br>
> --- a/src/mesa/main/tests/dispatch_sanity.cpp<br>
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp<br>
> @@ -957,6 +957,7 @@ const struct function gl_core_functions_possible[] = {<br>
> /* GL_ARB_direct_state_access */<br>
> { "glCreateBuffers", 45, -1 },<br>
> { "glNamedBufferStorage", 45, -1 },<br>
> + { "glNamedBufferData", 45, -1 },<br>
> { "glCreateTextures", 45, -1 },<br>
> { "glTextureStorage1D", 45, -1 },<br>
> { "glTextureStorage2D", 45, -1 },<br>
><br>
<br>
</div></div></blockquote></div></div></div><br></div></div>
</div><br></div>