[Mesa-dev] [PATCH] mesa: simplify code around 'variable_data' in marshal.c
Brian Paul
brianp at vmware.com
Fri Mar 24 15:50:43 UTC 2017
Remove needless pointer increments, unneeded vars, etc. Untested.
Plus, fix a couple comments.
---
src/mesa/main/marshal.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c
index cdc7fed..783ca0a 100644
--- a/src/mesa/main/marshal.c
+++ b/src/mesa/main/marshal.c
@@ -267,7 +267,7 @@ struct marshal_cmd_BufferData
GLsizeiptr size;
GLenum usage;
bool data_null; /* If set, no data follows for "data" */
- /* Next size bytes are GLvoid data[size] */
+ /* Next size bytes are GLubyte data[size] */
};
void
@@ -277,13 +277,12 @@ _mesa_unmarshal_BufferData(struct gl_context *ctx,
const GLenum target = cmd->target;
const GLsizeiptr size = cmd->size;
const GLenum usage = cmd->usage;
- const char *variable_data = (const char *) (cmd + 1);
- const GLvoid *data = (const GLvoid *) variable_data;
+ const void *data;
if (cmd->data_null)
data = NULL;
else
- variable_data += size;
+ data = (const void *) (cmd + 1);
CALL_BufferData(ctx->CurrentServerDispatch, (target, size, data, usage));
}
@@ -312,11 +311,10 @@ _mesa_marshal_BufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
cmd->target = target;
cmd->size = size;
cmd->usage = usage;
- char *variable_data = (char *) (cmd + 1);
cmd->data_null = !data;
- if (!cmd->data_null) {
+ if (data) {
+ char *variable_data = (char *) (cmd + 1);
memcpy(variable_data, data, size);
- variable_data += size;
}
_mesa_post_marshal_hook(ctx);
} else {
@@ -333,7 +331,7 @@ struct marshal_cmd_BufferSubData
GLenum target;
GLintptr offset;
GLsizeiptr size;
- /* Next size bytes are GLvoid data[size] */
+ /* Next size bytes are GLubyte data[size] */
};
void
@@ -343,10 +341,8 @@ _mesa_unmarshal_BufferSubData(struct gl_context *ctx,
const GLenum target = cmd->target;
const GLintptr offset = cmd->offset;
const GLsizeiptr size = cmd->size;
- const char *variable_data = (const char *) (cmd + 1);
- const GLvoid *data = (const GLvoid *) variable_data;
+ const void *data = (const void *) (cmd + 1);
- variable_data += size;
CALL_BufferSubData(ctx->CurrentServerDispatch,
(target, offset, size, data));
}
@@ -375,7 +371,6 @@ _mesa_marshal_BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
cmd->size = size;
char *variable_data = (char *) (cmd + 1);
memcpy(variable_data, data, size);
- variable_data += size;
_mesa_post_marshal_hook(ctx);
} else {
_mesa_glthread_finish(ctx);
--
1.9.1
More information about the mesa-dev
mailing list