<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 21, 2015 at 6:42 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On 01/21/2015 05:40 PM, Laura Ekstrand wrote:<br>
> ---<br>
> src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 ++<br>
> src/mesa/main/bufferobj.c | 150 ++++++++++++++++---------<br>
> src/mesa/main/bufferobj.h | 13 ++-<br>
> src/mesa/main/tests/dispatch_sanity.cpp | 1 +<br>
> 4 files changed, 113 insertions(+), 58 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 4b1ef6f..8a5cebb 100644<br>
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> @@ -28,6 +28,13 @@<br>
> <param name="usage" type="GLenum" /><br>
> </function><br>
><br>
> + <function name="NamedBufferSubData" offset="assign"><br>
> + <param name="buffer" type="GLuint" /><br>
> + <param name="offset" type="GLintptr" /><br>
> + <param name="size" type="GLsizeiptr" /><br>
> + <param name="data" type="const GLvoid *" /><br>
> + </function><br>
> +<br>
> <!-- Texture object functions --><br>
><br>
> <function name="CreateTextures" offset="assign"><br>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c<br>
> index c77029f..20c2cdc 100644<br>
> --- a/src/mesa/main/bufferobj.c<br>
> +++ b/src/mesa/main/bufferobj.c<br>
> @@ -227,67 +227,62 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,<br>
> * \c glClearBufferSubData.<br>
> *<br>
> * \param ctx GL context.<br>
> - * \param target Buffer object target on which to operate.<br>
> + * \param bufObj The buffer object.<br>
> * \param offset Offset of the first byte of the subdata range.<br>
> * \param size Size, in bytes, of the subdata range.<br>
> * \param mappedRange If true, checks if an overlapping range is mapped.<br>
> * If false, checks if buffer is mapped.<br>
> - * \param errorNoBuffer Error code if no buffer is bound to target.<br>
> - * \param caller Name of calling function for recording errors.<br>
> - * \return A pointer to the buffer object bound to \c target in the<br>
> - * specified context or \c NULL if any of the parameter or state<br>
> - * conditions are invalid.<br>
> + * \param func Name of calling function for recording errors.<br>
> + * \return false if error, true otherwise<br>
> *<br>
> * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData<br>
> */<br>
> -static struct gl_buffer_object *<br>
> -buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,<br>
> - GLintptrARB offset, GLsizeiptrARB size,<br>
> - bool mappedRange, GLenum errorNoBuffer,<br>
> - const char *caller)<br>
> +static bool<br>
> +buffer_object_subdata_range_good(struct gl_context *ctx,<br>
> + struct gl_buffer_object *bufObj,<br>
> + GLintptr offset, GLsizeiptr size,<br>
> + bool mappedRange, const char *func)<br>
<br>
</div></div>Many places in Mesa use 'caller'. This feels like a spurious change in<br>
this patch. If we want to unify on a single name, there should be a<br>
patch that changes all the occurrences of 'func', 'caller', and<br>
'function' to that single name.<br>
<div><div class="h5"><br>
> {<br>
> - struct gl_buffer_object *bufObj;<br>
> -<br>
> if (size < 0) {<br>
> - _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller);<br>
> - return NULL;<br>
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", func);<br>
> + return false;<br>
> }<br>
><br>
> if (offset < 0) {<br>
> - _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller);<br>
> - return NULL;<br>
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", func);<br>
> + return false;<br>
> }<br>
><br>
> - bufObj = get_buffer(ctx, caller, target, errorNoBuffer);<br>
> - if (!bufObj)<br>
> - return NULL;<br>
> -<br>
> if (offset + size > bufObj->Size) {<br>
> _mesa_error(ctx, GL_INVALID_VALUE,<br>
> - "%s(offset %lu + size %lu > buffer size %lu)", caller,<br>
> + "%s(offset %lu + size %lu > buffer size %lu)", func,<br>
> (unsigned long) offset,<br>
> (unsigned long) size,<br>
> (unsigned long) bufObj->Size);<br>
> - return NULL;<br>
> + return false;<br>
> }<br>
><br>
> if (bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_PERSISTENT_BIT)<br>
> - return bufObj;<br>
> + return true;<br>
><br>
> if (mappedRange) {<br>
> if (bufferobj_range_mapped(bufObj, offset, size)) {<br>
> - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);<br>
> - return NULL;<br>
> + _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> + "%s(range is mapped without GL_MAP_PERSISTENT_BIT)",<br>
<br>
</div></div>I don't understand why this error text was added here or below. If it<br>
is correct, it also seems like it should be a separate patch that<br>
includes justification in the commit message.<br></blockquote><div>In reviews for the ARB_direct_state_access texture functions, Brian Paul and Anuj Phogat recommended that error messages, if touched by a commit, should be more verbose.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> + func);<br>
> + return false;<br>
> }<br>
> }<br>
> else {<br>
> if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) {<br>
> - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);<br>
> - return NULL;<br>
> + _mesa_error(ctx, GL_INVALID_OPERATION,<br>
> + "%s(buffer is mapped without GL_MAP_PERSISTENT_BIT)",<br>
> + func);<br>
> + return false;<br>
> }<br>
> }<br>
><br>
> - return bufObj;<br>
> + return true;<br>
> }<br>
><br>
><br>
> @@ -602,9 +597,9 @@ _mesa_BufferData_sw(struct gl_context *ctx, GLenum target, GLsizeiptr size,<br>
> * \sa glBufferSubDataARB, dd_function_table::BufferSubData.<br>
> */<br>
> static void<br>
> -_mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset,<br>
> - GLsizeiptrARB size, const GLvoid * data,<br>
> - struct gl_buffer_object * bufObj )<br>
> +_mesa_BufferSubData_sw(struct gl_context *ctx, GLintptr offset,<br>
> + GLsizeiptr size, const GLvoid *data,<br>
> + struct gl_buffer_object *bufObj)<br>
> {<br>
> (void) ctx;<br>
><br>
> @@ -1113,7 +1108,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)<br>
> driver->NewBufferObject = _mesa_new_buffer_object;<br>
> driver->DeleteBuffer = _mesa_delete_buffer_object;<br>
> driver->BufferData = _mesa_BufferData_sw;<br>
> - driver->BufferSubData = _mesa_buffer_subdata;<br>
> + driver->BufferSubData = _mesa_BufferSubData_sw;<br>
> driver->GetBufferSubData = _mesa_buffer_get_subdata;<br>
> driver->UnmapBuffer = _mesa_buffer_unmap;<br>
><br>
> @@ -1580,24 +1575,33 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,<br>
> }<br>
><br>
><br>
> -void GLAPIENTRY<br>
> -_mesa_BufferSubData(GLenum target, GLintptrARB offset,<br>
> - GLsizeiptrARB size, const GLvoid * data)<br>
> +/**<br>
> + * Implementation for glBufferSubData and glNamedBufferSubData.<br>
> + *<br>
> + * \param ctx GL context.<br>
> + * \param bufObj The buffer object.<br>
> + * \param offset Offset of the first byte of the subdata range.<br>
> + * \param size Size, in bytes, of the subdata range.<br>
> + * \param data The data store.<br>
> + * \param mappedRange If true, checks if an overlapping range is mapped.<br>
> + * If false, checks if buffer is mapped.<br>
> + * \param func Name of calling function for recording errors.<br>
> + *<br>
> + */<br>
> +void<br>
> +_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,<br>
> + GLintptr offset, GLsizeiptr size, const GLvoid *data,<br>
> + bool mappedRange, const char *func)<br>
<br>
</div></div>mappedRange is always false. Is that intentional? I don't see this<br>
function used anywhere else in the series, so I think this parameter<br>
should be removed. It also looks like this function is only called from<br>
this file, so it should lose the _mesa_ and be static.<br></blockquote><div> mappedRange is true in _mesa_ClearBufferSubData.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Unless you have other code that will use it. In that case, there should<br>
be some explanation in the commit message.<br></blockquote><div>There will be meta code that uses this. Read patch 0 of ARB_dsa textures.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><br>
> {<br>
> - GET_CURRENT_CONTEXT(ctx);<br>
> - struct gl_buffer_object *bufObj;<br>
> -<br>
> - bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,<br>
> - false, GL_INVALID_OPERATION,<br>
> - "glBufferSubDataARB" );<br>
> - if (!bufObj) {<br>
> + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,<br>
> + mappedRange, func)) {<br>
> /* error already recorded */<br>
> return;<br>
> }<br>
><br>
> if (bufObj->Immutable &&<br>
> !(bufObj->StorageFlags & GL_DYNAMIC_STORAGE_BIT)) {<br>
> - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferSubData");<br>
> + _mesa_error(ctx, GL_INVALID_OPERATION, func);<br>
> return;<br>
> }<br>
><br>
> @@ -1607,22 +1611,54 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,<br>
> bufObj->Written = GL_TRUE;<br>
><br>
> ASSERT(ctx->Driver.BufferSubData);<br>
> - ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj );<br>
> + ctx->Driver.BufferSubData(ctx, offset, size, data, bufObj);<br>
<br>
</span>Spurious whitespace change. Drop this change.<br></blockquote><div>Again, in previous reviews, Brian Paul and Anuj Phogat were in favor of getting rid of this style: ( ctx, ..., bufObj ) whenever possible within a commit. Since I was in the neighborhood, I changed it. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> }<br>
><br>
> +void GLAPIENTRY<br>
> +_mesa_BufferSubData(GLenum target, GLintptr offset,<br>
> + GLsizeiptr size, const GLvoid *data)<br>
> +{<br>
> + GET_CURRENT_CONTEXT(ctx);<br>
> + struct gl_buffer_object *bufObj;<br>
> +<br>
> + bufObj = get_buffer(ctx, "glBufferSubData", target, GL_INVALID_OPERATION);<br>
> + if (!bufObj)<br>
> + return;<br>
> +<br>
> + _mesa_buffer_sub_data(ctx, bufObj, offset, size, data, false,<br>
> + "glBufferSubData");<br>
> +}<br>
><br>
> void GLAPIENTRY<br>
> -_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,<br>
> - GLsizeiptrARB size, void * data)<br>
> +_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,<br>
> + GLsizeiptr size, const GLvoid *data)<br>
> {<br>
> GET_CURRENT_CONTEXT(ctx);<br>
> struct gl_buffer_object *bufObj;<br>
><br>
> - bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,<br>
> - false, GL_INVALID_OPERATION,<br>
> - "glGetBufferSubDataARB");<br>
> - if (!bufObj) {<br>
> - /* error already recorded */<br>
> + bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData");<br>
> + if (!bufObj)<br>
> + return;<br>
> +<br>
> + _mesa_buffer_sub_data(ctx, bufObj, offset, size, data, false,<br>
> + "glNamedBufferSubData");<br>
> +}<br>
> +<br>
> +<br>
> +void GLAPIENTRY<br>
> +_mesa_GetBufferSubData(GLenum target, GLintptr offset,<br>
> + GLsizeiptr size, GLvoid *data)<br>
> +{<br>
> + GET_CURRENT_CONTEXT(ctx);<br>
> + struct gl_buffer_object *bufObj;<br>
> +<br>
> + bufObj = get_buffer(ctx, "glGetBufferSubData", target,<br>
> + GL_INVALID_OPERATION);<br>
> + if (!bufObj)<br>
> + return;<br>
> +<br>
> + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, false,<br>
> + "glGetBufferSubData")) {<br>
> return;<br>
> }<br>
><br>
> @@ -1696,10 +1732,12 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,<br>
> GLubyte clearValue[MAX_PIXEL_BYTES];<br>
> GLsizeiptr clearValueSize;<br>
><br>
> - bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,<br>
> - true, GL_INVALID_VALUE,<br>
> - "glClearBufferSubData");<br>
> - if (!bufObj) {<br>
> + bufObj = get_buffer(ctx, "glClearBufferSubData", target, GL_INVALID_VALUE);<br>
> + if (!bufObj)<br>
> + return;<br>
> +<br>
> + if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,<br>
> + true, "glClearBufferSubData")) {<br>
> return;<br>
> }<br>
><br>
> diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h<br>
> index 9801c87..72d3d82 100644<br>
> --- a/src/mesa/main/bufferobj.h<br>
> +++ b/src/mesa/main/bufferobj.h<br>
> @@ -140,6 +140,11 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,<br>
> GLenum usage, const char *func);<br>
><br>
> extern void<br>
> +_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,<br>
> + GLintptr offset, GLsizeiptr size, const GLvoid *data,<br>
> + bool mappedRange, 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>
> @@ -185,8 +190,12 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size,<br>
> const GLvoid *data, GLenum usage);<br>
><br>
> void GLAPIENTRY<br>
> -_mesa_BufferSubData(GLenum target, GLintptrARB offset,<br>
> - GLsizeiptrARB size, const GLvoid * data);<br>
> +_mesa_BufferSubData(GLenum target, GLintptr offset,<br>
> + GLsizeiptr size, const GLvoid *data);<br>
<br>
</div></div>As much as I hate the ARB suffixes, this is also a spurious change.<br></blockquote><div>Again, I wonder if other reviewers would agree with this.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><div class="h5"><br>
> +<br>
> +void GLAPIENTRY<br>
> +_mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,<br>
> + GLsizeiptr size, const GLvoid *data);<br>
><br>
> void GLAPIENTRY<br>
> _mesa_GetBufferSubData(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 3c87b5e..c639353 100644<br>
> --- a/src/mesa/main/tests/dispatch_sanity.cpp<br>
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp<br>
> @@ -958,6 +958,7 @@ const struct function gl_core_functions_possible[] = {<br>
> { "glCreateBuffers", 45, -1 },<br>
> { "glNamedBufferStorage", 45, -1 },<br>
> { "glNamedBufferData", 45, -1 },<br>
> + { "glNamedBufferSubData", 45, -1 },<br>
> { "glCreateTextures", 45, -1 },<br>
> { "glTextureStorage1D", 45, -1 },<br>
> { "glTextureStorage2D", 45, -1 },<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>