trace: fix a segfault when tracing indirect draw calls
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 24 Jan 2016 16:50:46 +0000 (17:50 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 24 Jan 2016 18:53:53 +0000 (19:53 +0100)
Like other resources, the indirect draw buffer must be unwrapped.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/trace/tr_context.c

index b5ab92498351d29ccea9a3435a4b112f51621153..6e703f76499fc0dd82a253ded28e79bf9b6b6110 100644 (file)
@@ -119,7 +119,22 @@ trace_context_draw_vbo(struct pipe_context *_pipe,
 
    trace_dump_trace_flush();
 
-   pipe->draw_vbo(pipe, info);
+   if (info->indirect) {
+      struct pipe_draw_info *_info = NULL;
+
+      _info = MALLOC(sizeof(*_info));
+      if (!_info)
+         return;
+
+      memcpy(_info, info, sizeof(*_info));
+      _info->indirect = trace_resource_unwrap(tr_ctx, _info->indirect);
+      _info->indirect_params = trace_resource_unwrap(tr_ctx,
+                                                     _info->indirect_params);
+      pipe->draw_vbo(pipe, _info);
+      FREE(_info);
+   } else {
+      pipe->draw_vbo(pipe, info);
+   }
 
    trace_dump_call_end();
 }