diff options
author | Marek Olšák <[email protected]> | 2017-02-22 23:40:53 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-02-25 00:03:09 +0100 |
commit | d17b8d08a3e51df7ff218adf54600b34fa015a4f (patch) | |
tree | 6c5af2d90f06ede498c6982ad5ec4dacadd03667 /src/gallium/drivers/trace/tr_context.c | |
parent | 4a883966c1f74f43afc145d2c3d27af7b8c5e01a (diff) |
trace: remove pipe_resource wrapping
Not needed. ddebug does the same thing. The limitation is that drivers
can only use pipe_resource::screen through pipe_resource_reference.
This unbreaks trace, because pipe_context uploaders aren't wrapped,
so trace doesn't understand buffers returned by them.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers/trace/tr_context.c')
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 156 |
1 files changed, 16 insertions, 140 deletions
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index f5939b1126c..4024dddde89 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -67,27 +67,10 @@ trace_query_unwrap(struct pipe_query *query) } -static inline struct pipe_resource * -trace_resource_unwrap(struct trace_context *tr_ctx, - struct pipe_resource *resource) -{ - struct trace_resource *tr_res; - - if (!resource) - return NULL; - - tr_res = trace_resource(resource); - - assert(tr_res->resource); - return tr_res->resource; -} - - static inline struct pipe_surface * trace_surface_unwrap(struct trace_context *tr_ctx, struct pipe_surface *surface) { - struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); struct trace_surface *tr_surf; if (!surface) @@ -100,8 +83,6 @@ trace_surface_unwrap(struct trace_context *tr_ctx, tr_surf = trace_surface(surface); assert(tr_surf->surface); - assert(tr_surf->surface->texture->screen == tr_scr->screen); - (void) tr_scr; return tr_surf->surface; } @@ -120,17 +101,7 @@ trace_context_draw_vbo(struct pipe_context *_pipe, trace_dump_trace_flush(); - if (info->indirect) { - struct pipe_draw_info _info; - - 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); - } else { - pipe->draw_vbo(pipe, info); - } + pipe->draw_vbo(pipe, info); trace_dump_call_end(); } @@ -776,13 +747,6 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe, { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_constant_buffer cb; - - if (constant_buffer) { - cb = *constant_buffer; - cb.buffer = trace_resource_unwrap(tr_ctx, constant_buffer->buffer); - constant_buffer = &cb; - } trace_dump_call_begin("pipe_context", "set_constant_buffer"); @@ -891,13 +855,11 @@ trace_context_set_viewport_states(struct pipe_context *_pipe, static struct pipe_sampler_view * trace_context_create_sampler_view(struct pipe_context *_pipe, - struct pipe_resource *_resource, + struct pipe_resource *resource, const struct pipe_sampler_view *templ) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_resource *resource = tr_res->resource; struct pipe_sampler_view *result; struct trace_sampler_view *tr_view; @@ -923,7 +885,7 @@ trace_context_create_sampler_view(struct pipe_context *_pipe, tr_view->base = *templ; tr_view->base.reference.count = 1; tr_view->base.texture = NULL; - pipe_resource_reference(&tr_view->base.texture, _resource); + pipe_resource_reference(&tr_view->base.texture, resource); tr_view->base.context = _pipe; tr_view->sampler_view = result; result = &tr_view->base; @@ -963,13 +925,11 @@ trace_context_sampler_view_destroy(struct pipe_context *_pipe, static struct pipe_surface * trace_context_create_surface(struct pipe_context *_pipe, - struct pipe_resource *_resource, + struct pipe_resource *resource, const struct pipe_surface *surf_tmpl) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_resource *resource = tr_res->resource; struct pipe_surface *result = NULL; trace_dump_call_begin("pipe_context", "create_surface"); @@ -988,7 +948,7 @@ trace_context_create_surface(struct pipe_context *_pipe, trace_dump_call_end(); - result = trace_surf_create(tr_ctx, tr_res, result); + result = trace_surf_create(tr_ctx, resource, result); return result; } @@ -1057,7 +1017,6 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - unsigned i; trace_dump_call_begin("pipe_context", "set_vertex_buffers"); @@ -1069,16 +1028,7 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, trace_dump_struct_array(vertex_buffer, buffers, num_buffers); trace_dump_arg_end(); - if (buffers) { - struct pipe_vertex_buffer *_buffers = MALLOC(num_buffers * sizeof(*_buffers)); - memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers)); - for (i = 0; i < num_buffers; i++) - _buffers[i].buffer = trace_resource_unwrap(tr_ctx, buffers[i].buffer); - pipe->set_vertex_buffers(pipe, start_slot, num_buffers, _buffers); - FREE(_buffers); - } else { - pipe->set_vertex_buffers(pipe, start_slot, num_buffers, NULL); - } + pipe->set_vertex_buffers(pipe, start_slot, num_buffers, buffers); trace_dump_call_end(); } @@ -1096,14 +1046,7 @@ trace_context_set_index_buffer(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(index_buffer, ib); - if (ib) { - struct pipe_index_buffer _ib; - _ib = *ib; - _ib.buffer = trace_resource_unwrap(tr_ctx, ib->buffer); - pipe->set_index_buffer(pipe, &_ib); - } else { - pipe->set_index_buffer(pipe, NULL); - } + pipe->set_index_buffer(pipe, ib); trace_dump_call_end(); } @@ -1119,8 +1062,6 @@ trace_context_create_stream_output_target(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; struct pipe_stream_output_target *result; - res = trace_resource_unwrap(tr_ctx, res); - trace_dump_call_begin("pipe_context", "create_stream_output_target"); trace_dump_arg(ptr, pipe); @@ -1192,9 +1133,6 @@ trace_context_resource_copy_region(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - dst = trace_resource_unwrap(tr_ctx, dst); - src = trace_resource_unwrap(tr_ctx, src); - trace_dump_call_begin("pipe_context", "resource_copy_region"); trace_dump_arg(ptr, pipe); @@ -1223,9 +1161,6 @@ trace_context_blit(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; struct pipe_blit_info info = *_info; - info.dst.resource = trace_resource_unwrap(tr_ctx, info.dst.resource); - info.src.resource = trace_resource_unwrap(tr_ctx, info.src.resource); - trace_dump_call_begin("pipe_context", "blit"); trace_dump_arg(ptr, pipe); @@ -1244,8 +1179,6 @@ trace_context_flush_resource(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - resource = trace_resource_unwrap(tr_ctx, resource); - trace_dump_call_begin("pipe_context", "flush_resource"); trace_dump_arg(ptr, pipe); @@ -1361,7 +1294,6 @@ trace_context_clear_texture(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - res = trace_resource_unwrap(tr_ctx, res); trace_dump_call_begin("pipe_context", "clear_texture"); @@ -1413,8 +1345,6 @@ trace_context_generate_mipmap(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; boolean ret; - res = trace_resource_unwrap(tr_ctx, res); - trace_dump_call_begin("pipe_context", "generate_mipmap"); trace_dump_arg(ptr, pipe); @@ -1459,31 +1389,27 @@ trace_context_destroy(struct pipe_context *_pipe) static void * trace_context_transfer_map(struct pipe_context *_context, - struct pipe_resource *_resource, + struct pipe_resource *resource, unsigned level, unsigned usage, const struct pipe_box *box, struct pipe_transfer **transfer) { struct trace_context *tr_context = trace_context(_context); - struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *context = tr_context->pipe; - struct pipe_resource *texture = tr_res->resource; struct pipe_transfer *result = NULL; void *map; - assert(texture->screen == context->screen); - /* * Map and transfers can't be serialized so we convert all write transfers * to texture/buffer_subdata and ignore read transfers. */ - map = context->transfer_map(context, texture, level, usage, box, &result); + map = context->transfer_map(context, resource, level, usage, box, &result); if (!map) return NULL; - *transfer = trace_transfer_create(tr_context, tr_res, result); + *transfer = trace_transfer_create(tr_context, resource, result); if (map) { if (usage & PIPE_TRANSFER_WRITE) { @@ -1562,14 +1488,12 @@ trace_context_transfer_unmap(struct pipe_context *_context, static void trace_context_buffer_subdata(struct pipe_context *_context, - struct pipe_resource *_resource, + struct pipe_resource *resource, unsigned usage, unsigned offset, unsigned size, const void *data) { struct trace_context *tr_context = trace_context(_context); - struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *context = tr_context->pipe; - struct pipe_resource *resource = tr_res->resource; struct pipe_box box; assert(resource->screen == context->screen); @@ -1595,7 +1519,7 @@ trace_context_buffer_subdata(struct pipe_context *_context, static void trace_context_texture_subdata(struct pipe_context *_context, - struct pipe_resource *_resource, + struct pipe_resource *resource, unsigned level, unsigned usage, const struct pipe_box *box, @@ -1604,9 +1528,7 @@ trace_context_texture_subdata(struct pipe_context *_context, unsigned layer_stride) { struct trace_context *tr_context = trace_context(_context); - struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *context = tr_context->pipe; - struct pipe_resource *resource = tr_res->resource; assert(resource->screen == context->screen); @@ -1637,12 +1559,10 @@ trace_context_texture_subdata(struct pipe_context *_context, static void trace_context_invalidate_resource(struct pipe_context *_context, - struct pipe_resource *_resource) + struct pipe_resource *resource) { struct trace_context *tr_context = trace_context(_context); - struct trace_resource *tr_res = trace_resource(_resource); struct pipe_context *context = tr_context->pipe; - struct pipe_resource *resource = tr_res->resource; assert(resource->screen == context->screen); @@ -1738,7 +1658,6 @@ static void trace_context_set_shader_buffers(struct pipe_context *_context, { struct trace_context *tr_context = trace_context(_context); struct pipe_context *context = tr_context->pipe; - struct pipe_shader_buffer *_buffers = NULL; trace_dump_call_begin("pipe_context", "set_shader_buffers"); trace_dump_arg(ptr, context); @@ -1749,24 +1668,7 @@ static void trace_context_set_shader_buffers(struct pipe_context *_context, trace_dump_arg_end(); trace_dump_call_end(); - if (buffers) { - int i; - - _buffers = MALLOC(nr * sizeof(struct pipe_shader_buffer)); - if (!_buffers) - return; - - for (i = 0; i < nr; i++) { - _buffers[i] = buffers[i]; - _buffers[i].buffer = trace_resource_unwrap( - tr_context, _buffers[i].buffer); - } - } - - context->set_shader_buffers(context, shader, start, nr, _buffers); - - if (_buffers) - FREE(_buffers); + context->set_shader_buffers(context, shader, start, nr, buffers); } static void trace_context_set_shader_images(struct pipe_context *_context, @@ -1776,7 +1678,6 @@ static void trace_context_set_shader_images(struct pipe_context *_context, { struct trace_context *tr_context = trace_context(_context); struct pipe_context *context = tr_context->pipe; - struct pipe_image_view *_images = NULL; trace_dump_call_begin("pipe_context", "set_shader_images"); trace_dump_arg(ptr, context); @@ -1787,24 +1688,7 @@ static void trace_context_set_shader_images(struct pipe_context *_context, trace_dump_arg_end(); trace_dump_call_end(); - if (images) { - int i; - - _images = MALLOC(nr * sizeof(struct pipe_image_view)); - if (!_images) - return; - - for (i = 0; i < nr; i++) { - _images[i] = images[i]; - _images[i].resource = trace_resource_unwrap(tr_context, - _images[i].resource); - } - } - - context->set_shader_images(context, shader, start, nr, _images); - - if (_images) - FREE(_images); + context->set_shader_images(context, shader, start, nr, images); } static void trace_context_launch_grid(struct pipe_context *_pipe, @@ -1820,15 +1704,7 @@ static void trace_context_launch_grid(struct pipe_context *_pipe, trace_dump_trace_flush(); - if (info->indirect) { - struct pipe_grid_info _info; - - memcpy(&_info, info, sizeof(_info)); - _info.indirect = trace_resource_unwrap(tr_ctx, _info.indirect); - pipe->launch_grid(pipe, &_info); - } else { - pipe->launch_grid(pipe, info); - } + pipe->launch_grid(pipe, info); trace_dump_call_end(); } |