<div dir="ltr">This naming convention tries to match the corresponding DD table entry.<br><br>There's a thread discussing the naming convention for external software fallback functions. Feel free to add your input to the discussion there :)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 20, 2015 at 6:18 AM, Martin Peres <span dir="ltr"><<a href="mailto:martin.peres@free.fr" target="_blank">martin.peres@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 12/02/2015 04:05, Laura Ekstrand wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
v2: review by Jason Ekstrand<br>
- Split refactor of clear buffer sub data from addition of DSA entry<br>
points.<br>
---<br>
src/mesa/main/bufferobj.c | 125 ++++++++++++---------------<br>
src/mesa/main/bufferobj.h | 19 ++--<br>
src/mesa/state_tracker/st_cb_<u></u>bufferobjects.c | 4 +-<br>
3 files changed, 69 insertions(+), 79 deletions(-)<br>
<br>
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c<br>
index 7225b64..b8fa917 100644<br>
--- a/src/mesa/main/bufferobj.c<br>
+++ b/src/mesa/main/bufferobj.c<br>
@@ -660,11 +660,11 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset,<br>
* dd_function_table::<u></u>ClearBufferSubData.<br>
*/<br>
void<br>
-_mesa_buffer_clear_subdata(<u></u>struct gl_context *ctx,<br>
- GLintptr offset, GLsizeiptr size,<br>
- const GLvoid *clearValue,<br>
- GLsizeiptr clearValueSize,<br>
- struct gl_buffer_object *bufObj)<br>
+_mesa_ClearBufferSubData_sw(<u></u>struct gl_context *ctx,<br>
</blockquote>
<br></span>
Interesting choice of naming the function as a mix of camel case and underscores.<br>
<br>
Since it is an internal function, shouldn't it only have underscores?<br>
<br>
Other than that:<br>
<br>
Reviewed-by: Martin Peres <<a href="mailto:martin.peres@linux.intel.com" target="_blank">martin.peres@linux.intel.com</a>><div class="HOEnZb"><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ GLintptr offset, GLsizeiptr size,<br>
+ const GLvoid *clearValue,<br>
+ GLsizeiptr clearValueSize,<br>
+ struct gl_buffer_object *bufObj)<br>
{<br>
GLsizeiptr i;<br>
GLubyte *dest;<br>
@@ -1113,7 +1113,7 @@ _mesa_init_buffer_object_<u></u>functions(struct dd_function_table *driver)<br>
driver->UnmapBuffer = _mesa_buffer_unmap;<br>
/* GL_ARB_clear_buffer_object */<br>
- driver->ClearBufferSubData = _mesa_buffer_clear_subdata;<br>
+ driver->ClearBufferSubData = _mesa_ClearBufferSubData_sw;<br>
/* GL_ARB_map_buffer_range */<br>
driver->MapBufferRange = _mesa_buffer_map_range;<br>
@@ -1671,57 +1671,77 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset,<br>
ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj );<br>
}<br>
-<br>
-void GLAPIENTRY<br>
-_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,<br>
- GLenum type, const GLvoid* data)<br>
+/**<br>
+ * \param subdata true if caller is *SubData, false if *Data<br>
+ */<br>
+void<br>
+_mesa_clear_buffer_sub_data(<u></u>struct gl_context *ctx,<br>
+ struct gl_buffer_object *bufObj,<br>
+ GLenum internalformat,<br>
+ GLintptr offset, GLsizeiptr size,<br>
+ GLenum format, GLenum type,<br>
+ const GLvoid *data,<br>
+ const char *func, bool subdata)<br>
{<br>
- GET_CURRENT_CONTEXT(ctx);<br>
- struct gl_buffer_object* bufObj;<br>
mesa_format mesaFormat;<br>
GLubyte clearValue[MAX_PIXEL_BYTES];<br>
GLsizeiptr clearValueSize;<br>
- bufObj = get_buffer(ctx, "glClearBufferData", target, GL_INVALID_VALUE);<br>
- if (!bufObj) {<br>
- return;<br>
- }<br>
-<br>
- if (_mesa_check_disallowed_<u></u>mapping(bufObj)) {<br>
- _mesa_error(ctx, GL_INVALID_OPERATION,<br>
- "glClearBufferData(buffer currently mapped)");<br>
+ /* This checks for disallowed mappings. */<br>
+ if (!buffer_object_subdata_range_<u></u>good(ctx, bufObj, offset, size,<br>
+ subdata, func)) {<br>
return;<br>
}<br>
mesaFormat = validate_clear_buffer_format(<u></u>ctx, internalformat,<br>
- format, type,<br>
- "glClearBufferData");<br>
+ format, type, func);<br>
+<br>
if (mesaFormat == MESA_FORMAT_NONE) {<br>
return;<br>
}<br>
clearValueSize = _mesa_get_format_bytes(<u></u>mesaFormat);<br>
- if (bufObj->Size % clearValueSize != 0) {<br>
+ if (offset % clearValueSize != 0 || size % clearValueSize != 0) {<br>
_mesa_error(ctx, GL_INVALID_VALUE,<br>
- "glClearBufferData(size is not a multiple of "<br>
- "internalformat size)");<br>
+ "%s(offset or size is not a multiple of "<br>
+ "internalformat size)", func);<br>
return;<br>
}<br>
if (data == NULL) {<br>
/* clear to zeros, per the spec */<br>
- ctx->Driver.<u></u>ClearBufferSubData(ctx, 0, bufObj->Size,<br>
- NULL, clearValueSize, bufObj);<br>
+ if (size > 0) {<br>
+ ctx->Driver.<u></u>ClearBufferSubData(ctx, offset, size,<br>
+ NULL, clearValueSize, bufObj);<br>
+ }<br>
return;<br>
}<br>
if (!convert_clear_buffer_data(<u></u>ctx, mesaFormat, clearValue,<br>
- format, type, data, "glClearBufferData")) {<br>
+ format, type, data, func)) {<br>
return;<br>
}<br>
- ctx->Driver.<u></u>ClearBufferSubData(ctx, 0, bufObj->Size,<br>
- clearValue, clearValueSize, bufObj);<br>
+ if (size > 0) {<br>
+ ctx->Driver.<u></u>ClearBufferSubData(ctx, offset, size,<br>
+ clearValue, clearValueSize, bufObj);<br>
+ }<br>
+}<br>
+<br>
+void GLAPIENTRY<br>
+_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,<br>
+ GLenum type, const GLvoid *data)<br>
+{<br>
+ GET_CURRENT_CONTEXT(ctx);<br>
+ struct gl_buffer_object *bufObj;<br>
+<br>
+ bufObj = get_buffer(ctx, "glClearBufferData", target, GL_INVALID_VALUE);<br>
+ if (!bufObj)<br>
+ return;<br>
+<br>
+ _mesa_clear_buffer_sub_data(<u></u>ctx, bufObj, internalformat, 0, bufObj->Size,<br>
+ format, type, data,<br>
+ "glClearBufferData", false);<br>
}<br>
@@ -1733,53 +1753,14 @@ _mesa_ClearBufferSubData(<u></u>GLenum target, GLenum internalformat,<br>
{<br>
GET_CURRENT_CONTEXT(ctx);<br>
struct gl_buffer_object* bufObj;<br>
- mesa_format mesaFormat;<br>
- GLubyte clearValue[MAX_PIXEL_BYTES];<br>
- GLsizeiptr clearValueSize;<br>
bufObj = get_buffer(ctx, "glClearBufferSubData", target, GL_INVALID_VALUE);<br>
if (!bufObj)<br>
return;<br>
- if (!buffer_object_subdata_range_<u></u>good(ctx, bufObj, offset, size,<br>
- true, "glClearBufferSubData")) {<br>
- return;<br>
- }<br>
-<br>
- mesaFormat = validate_clear_buffer_format(<u></u>ctx, internalformat,<br>
- format, type,<br>
- "glClearBufferSubData");<br>
- if (mesaFormat == MESA_FORMAT_NONE) {<br>
- return;<br>
- }<br>
-<br>
- clearValueSize = _mesa_get_format_bytes(<u></u>mesaFormat);<br>
- if (offset % clearValueSize != 0 || size % clearValueSize != 0) {<br>
- _mesa_error(ctx, GL_INVALID_VALUE,<br>
- "glClearBufferSubData(offset or size is not a multiple of "<br>
- "internalformat size)");<br>
- return;<br>
- }<br>
-<br>
- if (data == NULL) {<br>
- /* clear to zeros, per the spec */<br>
- if (size > 0) {<br>
- ctx->Driver.<u></u>ClearBufferSubData(ctx, offset, size,<br>
- NULL, clearValueSize, bufObj);<br>
- }<br>
- return;<br>
- }<br>
-<br>
- if (!convert_clear_buffer_data(<u></u>ctx, mesaFormat, clearValue,<br>
- format, type, data,<br>
- "glClearBufferSubData")) {<br>
- return;<br>
- }<br>
-<br>
- if (size > 0) {<br>
- ctx->Driver.<u></u>ClearBufferSubData(ctx, offset, size,<br>
- clearValue, clearValueSize, bufObj);<br>
- }<br>
+ _mesa_clear_buffer_sub_data(<u></u>ctx, bufObj, internalformat, offset, size,<br>
+ format, type, data,<br>
+ "glClearBufferSubData", true);<br>
}<br>
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h<br>
index 7db5c98..5911270 100644<br>
--- a/src/mesa/main/bufferobj.h<br>
+++ b/src/mesa/main/bufferobj.h<br>
@@ -156,11 +156,20 @@ _mesa_copy_buffer_sub_data(<u></u>struct gl_context *ctx,<br>
GLsizeiptr size, const char *func);<br>
extern void<br>
-_mesa_buffer_clear_subdata(<u></u>struct gl_context *ctx,<br>
- GLintptr offset, GLsizeiptr size,<br>
- const GLvoid *clearValue,<br>
- GLsizeiptr clearValueSize,<br>
- struct gl_buffer_object *bufObj);<br>
+_mesa_ClearBufferSubData_sw(<u></u>struct gl_context *ctx,<br>
+ GLintptr offset, GLsizeiptr size,<br>
+ const GLvoid *clearValue,<br>
+ GLsizeiptr clearValueSize,<br>
+ struct gl_buffer_object *bufObj);<br>
+<br>
+extern void<br>
+_mesa_clear_buffer_sub_data(<u></u>struct gl_context *ctx,<br>
+ struct gl_buffer_object *bufObj,<br>
+ GLenum internalformat,<br>
+ GLintptr offset, GLsizeiptr size,<br>
+ GLenum format, GLenum type,<br>
+ const GLvoid *data,<br>
+ const char *func, bool subdata);<br>
/*<br>
* API functions<br>
diff --git a/src/mesa/state_tracker/st_<u></u>cb_bufferobjects.c b/src/mesa/state_tracker/st_<u></u>cb_bufferobjects.c<br>
index 90f786c..b7096f7 100644<br>
--- a/src/mesa/state_tracker/st_<u></u>cb_bufferobjects.c<br>
+++ b/src/mesa/state_tracker/st_<u></u>cb_bufferobjects.c<br>
@@ -477,8 +477,8 @@ st_clear_buffer_subdata(struct gl_context *ctx,<br>
static const char zeros[16] = {0};<br>
if (!pipe->clear_buffer) {<br>
- _mesa_buffer_clear_subdata(<u></u>ctx, offset, size,<br>
- clearValue, clearValueSize, bufObj);<br>
+ _mesa_ClearBufferSubData_sw(<u></u>ctx, offset, size,<br>
+ clearValue, clearValueSize, bufObj);<br>
return;<br>
}<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>