<div dir="ltr">Actually, I can just set only batch->used to 0, but it seems to error prone. When someone adds some fields to batch struct, it will be easy to miss that it should be initialized in glthread_unmarshal_batch.<div><br></div><div>Anyway I can change it if you want to.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 3, 2017 at 8:42 PM, Nicolai Hähnle <span dir="ltr"><<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</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 03.04.2017 20:38, Bartosz Tomczyk wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
src/mesa/main/glthread.c | 15 +++++++++------<br>
1 file changed, 9 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c<br>
index 3f07c420d4..aa14292e59 100644<br>
--- a/src/mesa/main/glthread.c<br>
+++ b/src/mesa/main/glthread.c<br>
@@ -53,7 +53,8 @@ glthread_allocate_batch(struct gl_context *ctx)<br>
}<br>
<br>
static void<br>
-glthread_unmarshal_batch(stru<wbr>ct gl_context *ctx, struct glthread_batch *batch)<br>
+glthread_unmarshal_batch(stru<wbr>ct gl_context *ctx, struct glthread_batch *batch,<br>
+ const bool release_batch)<br>
{<br>
size_t pos = 0;<br>
<br>
@@ -64,7 +65,10 @@ glthread_unmarshal_batch(struc<wbr>t gl_context *ctx, struct glthread_batch *batch)<br>
<br>
assert(pos == batch->used);<br>
<br>
- free(batch);<br>
+ if (release_batch)<br>
+ free(batch);<br>
+ else<br>
+ memset(batch, 0, offsetof(struct glthread_batch, buffer));<br>
</blockquote>
<br></span>
Hmm. Why do we memset the batch? Seems like a trivial optimization to just not do that...<br>
<br>
Apart from that, the patch looks good to me.<br>
<br>
Cheers,<br>
Nicolai<div><div class="h5"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
static void *<br>
@@ -103,7 +107,7 @@ glthread_worker(void *data)<br>
glthread->busy = true;<br>
pthread_mutex_unlock(&glthrea<wbr>d->mutex);<br>
<br>
- glthread_unmarshal_batch(ctx, batch);<br>
+ glthread_unmarshal_batch(ctx, batch, true);<br>
<br>
pthread_mutex_lock(&glthread-<wbr>>mutex);<br>
glthread->busy = false;<br>
@@ -214,7 +218,7 @@ _mesa_glthread_flush_batch_loc<wbr>ked(struct gl_context *ctx)<br>
* need to restore it when it returns.<br>
*/<br>
if (false) {<br>
- glthread_unmarshal_batch(ctx, batch);<br>
+ glthread_unmarshal_batch(ctx, batch, true);<br>
_glapi_set_dispatch(ctx->Curr<wbr>entClientDispatch);<br>
return;<br>
}<br>
@@ -269,9 +273,8 @@ _mesa_glthread_finish(struct gl_context *ctx)<br>
if (!(glthread->batch_queue || glthread->busy)) {<br>
if (glthread->batch && glthread->batch->used) {<br>
struct _glapi_table *dispatch = _glapi_get_dispatch();<br>
- glthread_unmarshal_batch(ctx, glthread->batch);<br>
+ glthread_unmarshal_batch(ctx, glthread->batch, false);<br>
_glapi_set_dispatch(dispatch);<br>
- glthread_allocate_batch(ctx);<br>
}<br>
} else {<br>
_mesa_glthread_flush_batch_lo<wbr>cked(ctx);<br>
<br>
</blockquote>
<br>
<br>
-- <br></div></div>
Lerne, wie die Welt wirklich ist,<br>
Aber vergiss niemals, wie sie sein sollte.<br>
</blockquote></div><br></div>