[Mesa-dev] [PATCH 1/5] trace: remove pipe_resource wrapping
Marek Olšák
maraeo at gmail.com
Thu Feb 23 00:07:47 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
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.
---
src/gallium/drivers/trace/tr_context.c | 156 +++---------------------------
src/gallium/drivers/trace/tr_dump.c | 14 ---
src/gallium/drivers/trace/tr_dump.h | 1 -
src/gallium/drivers/trace/tr_dump_state.c | 12 +--
src/gallium/drivers/trace/tr_screen.c | 30 ++----
src/gallium/drivers/trace/tr_texture.c | 52 ++--------
src/gallium/drivers/trace/tr_texture.h | 35 +------
7 files changed, 40 insertions(+), 260 deletions(-)
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index f5939b1..4024ddd 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -60,84 +60,55 @@ static inline struct pipe_query *
trace_query_unwrap(struct pipe_query *query)
{
if (query) {
return trace_query(query)->query;
} else {
return NULL;
}
}
-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)
return NULL;
assert(surface->texture);
if (!surface->texture)
return surface;
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;
}
static void
trace_context_draw_vbo(struct pipe_context *_pipe,
const struct pipe_draw_info *info)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "draw_vbo");
trace_dump_arg(ptr, pipe);
trace_dump_arg(draw_info, info);
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();
}
static struct pipe_query *
trace_context_create_query(struct pipe_context *_pipe,
unsigned query_type,
unsigned index)
{
@@ -769,27 +740,20 @@ trace_context_set_sample_mask(struct pipe_context *_pipe,
trace_dump_call_end();
}
static void
trace_context_set_constant_buffer(struct pipe_context *_pipe,
uint shader, uint index,
const struct pipe_constant_buffer *constant_buffer)
{
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");
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, shader);
trace_dump_arg(uint, index);
trace_dump_arg(constant_buffer, constant_buffer);
pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
@@ -884,27 +848,25 @@ trace_context_set_viewport_states(struct pipe_context *_pipe,
trace_dump_arg(viewport_state, states);
pipe->set_viewport_states(pipe, start_slot, num_viewports, states);
trace_dump_call_end();
}
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;
trace_dump_call_begin("pipe_context", "create_sampler_view");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, resource);
trace_dump_arg_begin("templ");
trace_dump_sampler_view_template(templ, resource->target);
@@ -916,21 +878,21 @@ trace_context_create_sampler_view(struct pipe_context *_pipe,
trace_dump_call_end();
/*
* Wrap pipe_sampler_view
*/
tr_view = CALLOC_STRUCT(trace_sampler_view);
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;
return result;
}
static void
trace_context_sampler_view_destroy(struct pipe_context *_pipe,
@@ -956,46 +918,44 @@ trace_context_sampler_view_destroy(struct pipe_context *_pipe,
FREE(_view);
}
/********************************************************************
* surface
*/
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");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, resource);
trace_dump_arg_begin("surf_tmpl");
trace_dump_surface_template(surf_tmpl, resource->target);
trace_dump_arg_end();
result = pipe->create_surface(pipe, resource, surf_tmpl);
trace_dump_ret(ptr, result);
trace_dump_call_end();
- result = trace_surf_create(tr_ctx, tr_res, result);
+ result = trace_surf_create(tr_ctx, resource, result);
return result;
}
static void
trace_context_surface_destroy(struct pipe_context *_pipe,
struct pipe_surface *_surface)
{
struct trace_context *tr_ctx = trace_context(_pipe);
@@ -1050,84 +1010,65 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
}
static void
trace_context_set_vertex_buffers(struct pipe_context *_pipe,
unsigned start_slot, unsigned num_buffers,
const struct pipe_vertex_buffer *buffers)
{
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");
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, start_slot);
trace_dump_arg(uint, num_buffers);
trace_dump_arg_begin("buffers");
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();
}
static void
trace_context_set_index_buffer(struct pipe_context *_pipe,
const struct pipe_index_buffer *ib)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "set_index_buffer");
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();
}
static struct pipe_stream_output_target *
trace_context_create_stream_output_target(struct pipe_context *_pipe,
struct pipe_resource *res,
unsigned buffer_offset,
unsigned buffer_size)
{
struct trace_context *tr_ctx = trace_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);
trace_dump_arg(ptr, res);
trace_dump_arg(uint, buffer_offset);
trace_dump_arg(uint, buffer_size);
result = pipe->create_stream_output_target(pipe,
res, buffer_offset, buffer_size);
@@ -1185,23 +1126,20 @@ trace_context_resource_copy_region(struct pipe_context *_pipe,
struct pipe_resource *dst,
unsigned dst_level,
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned src_level,
const struct pipe_box *src_box)
{
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);
trace_dump_arg(ptr, dst);
trace_dump_arg(uint, dst_level);
trace_dump_arg(uint, dstx);
trace_dump_arg(uint, dsty);
trace_dump_arg(uint, dstz);
trace_dump_arg(ptr, src);
trace_dump_arg(uint, src_level);
@@ -1216,43 +1154,38 @@ trace_context_resource_copy_region(struct pipe_context *_pipe,
static void
trace_context_blit(struct pipe_context *_pipe,
const struct pipe_blit_info *_info)
{
struct trace_context *tr_ctx = trace_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);
trace_dump_arg(blit_info, _info);
pipe->blit(pipe, &info);
trace_dump_call_end();
}
static void
trace_context_flush_resource(struct pipe_context *_pipe,
struct pipe_resource *resource)
{
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);
trace_dump_arg(ptr, resource);
pipe->flush_resource(pipe, resource);
trace_dump_call_end();
}
@@ -1354,21 +1287,20 @@ trace_context_clear_depth_stencil(struct pipe_context *_pipe,
static inline void
trace_context_clear_texture(struct pipe_context *_pipe,
struct pipe_resource *res,
unsigned level,
const struct pipe_box *box,
const void *data)
{
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");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, res);
trace_dump_arg(uint, level);
trace_dump_arg_begin("box");
trace_dump_box(box);
trace_dump_arg_end();
trace_dump_arg(ptr, data);
@@ -1406,22 +1338,20 @@ trace_context_generate_mipmap(struct pipe_context *_pipe,
enum pipe_format format,
unsigned base_level,
unsigned last_level,
unsigned first_layer,
unsigned last_layer)
{
struct trace_context *tr_ctx = trace_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);
trace_dump_arg(ptr, res);
trace_dump_arg(format, format);
trace_dump_arg(uint, base_level);
trace_dump_arg(uint, last_level);
trace_dump_arg(uint, first_layer);
trace_dump_arg(uint, last_layer);
@@ -1452,45 +1382,41 @@ trace_context_destroy(struct pipe_context *_pipe)
}
/********************************************************************
* transfer
*/
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) {
trace_transfer(*transfer)->map = map;
}
}
return *transfer ? map : NULL;
}
@@ -1555,28 +1481,26 @@ trace_context_transfer_unmap(struct pipe_context *_context,
tr_trans->map = NULL;
}
context->transfer_unmap(context, transfer);
trace_transfer_destroy(tr_ctx, tr_trans);
}
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);
trace_dump_call_begin("pipe_context", "buffer_subdata");
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, resource);
trace_dump_arg(uint, usage);
trace_dump_arg(uint, offset);
@@ -1588,32 +1512,30 @@ trace_context_buffer_subdata(struct pipe_context *_context,
trace_dump_arg_end();
trace_dump_call_end();
context->buffer_subdata(context, resource, usage, offset, size, data);
}
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,
const void *data,
unsigned stride,
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);
trace_dump_call_begin("pipe_context", "texture_subdata");
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, resource);
trace_dump_arg(uint, level);
trace_dump_arg(uint, usage);
trace_dump_arg(box, box);
@@ -1630,26 +1552,24 @@ trace_context_texture_subdata(struct pipe_context *_context,
trace_dump_arg(uint, layer_stride);
trace_dump_call_end();
context->texture_subdata(context, resource, level, usage, box,
data, stride, layer_stride);
}
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);
trace_dump_call_begin("pipe_context", "invalidate_resource");
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, resource);
trace_dump_call_end();
@@ -1731,111 +1651,67 @@ trace_context_set_tess_state(struct pipe_context *_context,
}
static void trace_context_set_shader_buffers(struct pipe_context *_context,
enum pipe_shader_type shader,
unsigned start, unsigned nr,
const struct pipe_shader_buffer *buffers)
{
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);
trace_dump_arg(uint, shader);
trace_dump_arg(uint, start);
trace_dump_arg_begin("buffers");
trace_dump_struct_array(shader_buffer, buffers, nr);
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,
enum pipe_shader_type shader,
unsigned start, unsigned nr,
const struct pipe_image_view *images)
{
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);
trace_dump_arg(uint, shader);
trace_dump_arg(uint, start);
trace_dump_arg_begin("images");
trace_dump_struct_array(image_view, images, nr);
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,
const struct pipe_grid_info *info)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "launch_grid");
trace_dump_arg(ptr, pipe);
trace_dump_arg(grid_info, info);
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();
}
struct pipe_context *
trace_context_create(struct trace_screen *tr_scr,
struct pipe_context *pipe)
{
struct trace_context *tr_ctx;
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index b173b8a..112a69e 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -618,34 +618,20 @@ void trace_dump_ptr(const void *value)
{
if (!dumping)
return;
if(value)
trace_dump_writef("<ptr>0x%08lx</ptr>", (unsigned long)(uintptr_t)value);
else
trace_dump_null();
}
-
-void trace_dump_resource_ptr(struct pipe_resource *_resource)
-{
- if (!dumping)
- return;
-
- if (_resource) {
- struct trace_resource *tr_resource = trace_resource(_resource);
- trace_dump_ptr(tr_resource->resource);
- } else {
- trace_dump_null();
- }
-}
-
void trace_dump_surface_ptr(struct pipe_surface *_surface)
{
if (!dumping)
return;
if (_surface) {
struct trace_surface *tr_surf = trace_surface(_surface);
trace_dump_ptr(tr_surf->surface);
} else {
trace_dump_null();
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index c03660a..7a268e3 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -98,21 +98,20 @@ void trace_dump_array_begin(void);
void trace_dump_array_end(void);
void trace_dump_elem_begin(void);
void trace_dump_elem_end(void);
void trace_dump_struct_begin(const char *name);
void trace_dump_struct_end(void);
void trace_dump_member_begin(const char *name);
void trace_dump_member_end(void);
void trace_dump_null(void);
void trace_dump_ptr(const void *value);
/* will turn a wrapped object into the real one and dump ptr */
-void trace_dump_resource_ptr(struct pipe_resource *_texture);
void trace_dump_surface_ptr(struct pipe_surface *_surface);
void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
/*
* Code saving macros.
*/
#define trace_dump_arg(_type, _arg) \
do { \
trace_dump_arg_begin(#_arg); \
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index c5740d0..4c6f6d6 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -647,42 +647,42 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
if (!state) {
trace_dump_null();
return;
}
trace_dump_struct_begin("pipe_vertex_buffer");
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, buffer_offset);
- trace_dump_member(resource_ptr, state, buffer);
+ trace_dump_member(ptr, state, buffer);
trace_dump_member(ptr, state, user_buffer);
trace_dump_struct_end();
}
void trace_dump_index_buffer(const struct pipe_index_buffer *state)
{
if (!trace_dumping_enabled_locked())
return;
if (!state) {
trace_dump_null();
return;
}
trace_dump_struct_begin("pipe_index_buffer");
trace_dump_member(uint, state, index_size);
trace_dump_member(uint, state, offset);
- trace_dump_member(resource_ptr, state, buffer);
+ trace_dump_member(ptr, state, buffer);
trace_dump_member(ptr, state, user_buffer);
trace_dump_struct_end();
}
void trace_dump_vertex_element(const struct pipe_vertex_element *state)
{
if (!trace_dumping_enabled_locked())
return;
@@ -726,39 +726,39 @@ void trace_dump_shader_buffer(const struct pipe_shader_buffer *state)
{
if (!trace_dumping_enabled_locked())
return;
if(!state) {
trace_dump_null();
return;
}
trace_dump_struct_begin("pipe_shader_buffer");
- trace_dump_member(resource_ptr, state, buffer);
+ trace_dump_member(ptr, state, buffer);
trace_dump_member(uint, state, buffer_offset);
trace_dump_member(uint, state, buffer_size);
trace_dump_struct_end();
}
void trace_dump_image_view(const struct pipe_image_view *state)
{
if (!trace_dumping_enabled_locked())
return;
if(!state) {
trace_dump_null();
return;
}
trace_dump_struct_begin("pipe_image_view");
- trace_dump_member(resource_ptr, state, resource);
+ trace_dump_member(ptr, state, resource);
trace_dump_member(uint, state, format);
trace_dump_member(uint, state, access);
trace_dump_member_begin("u");
trace_dump_struct_begin(""); /* anonymous */
if (state->resource->target == PIPE_BUFFER) {
trace_dump_member_begin("buf");
trace_dump_struct_begin(""); /* anonymous */
trace_dump_member(uint, &state->u.buf, offset);
trace_dump_member(uint, &state->u.buf, size);
@@ -827,32 +827,32 @@ void trace_dump_blit_info(const struct pipe_blit_info *info)
if (!info) {
trace_dump_null();
return;
}
trace_dump_struct_begin("pipe_blit_info");
trace_dump_member_begin("dst");
trace_dump_struct_begin("dst");
- trace_dump_member(resource_ptr, &info->dst, resource);
+ trace_dump_member(ptr, &info->dst, resource);
trace_dump_member(uint, &info->dst, level);
trace_dump_member(format, &info->dst, format);
trace_dump_member_begin("box");
trace_dump_box(&info->dst.box);
trace_dump_member_end();
trace_dump_struct_end();
trace_dump_member_end();
trace_dump_member_begin("src");
trace_dump_struct_begin("src");
- trace_dump_member(resource_ptr, &info->src, resource);
+ trace_dump_member(ptr, &info->src, resource);
trace_dump_member(uint, &info->src, level);
trace_dump_member(format, &info->src, format);
trace_dump_member_begin("box");
trace_dump_box(&info->src.box);
trace_dump_member_end();
trace_dump_struct_end();
trace_dump_member_end();
mask[0] = (info->mask & PIPE_MASK_R) ? 'R' : '-';
mask[1] = (info->mask & PIPE_MASK_G) ? 'G' : '-';
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 13505af..a444068 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -270,29 +270,27 @@ trace_screen_context_create(struct pipe_screen *_screen, void *priv,
trace_dump_call_end();
result = trace_context_create(tr_scr, result);
return result;
}
static void
trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
- struct pipe_resource *_resource,
+ struct pipe_resource *resource,
unsigned level, unsigned layer,
void *context_private,
struct pipe_box *sub_box)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_resource *tr_res = trace_resource(_resource);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_resource *resource = tr_res->resource;
trace_dump_call_begin("pipe_screen", "flush_frontbuffer");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, resource);
trace_dump_arg(uint, level);
trace_dump_arg(uint, layer);
/* XXX: hide, as there is nothing we can do with this
trace_dump_arg(ptr, context_private);
*/
@@ -320,103 +318,93 @@ trace_screen_resource_create(struct pipe_screen *_screen,
trace_dump_arg(ptr, screen);
trace_dump_arg(resource_template, templat);
result = screen->resource_create(screen, templat);
trace_dump_ret(ptr, result);
trace_dump_call_end();
- result = trace_resource_create(tr_scr, result);
-
+ if (result)
+ result->screen = _screen;
return result;
}
static struct pipe_resource *
trace_screen_resource_from_handle(struct pipe_screen *_screen,
const struct pipe_resource *templ,
struct winsys_handle *handle,
unsigned usage)
{
struct trace_screen *tr_screen = trace_screen(_screen);
struct pipe_screen *screen = tr_screen->screen;
struct pipe_resource *result;
/* TODO trace call */
result = screen->resource_from_handle(screen, templ, handle, usage);
- result = trace_resource_create(trace_screen(_screen), result);
-
+ if (result)
+ result->screen = _screen;
return result;
}
static boolean
trace_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_context *_pipe,
- struct pipe_resource *_resource,
+ struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
{
struct trace_screen *tr_screen = trace_screen(_screen);
struct trace_context *tr_pipe = _pipe ? trace_context(_pipe) : NULL;
- struct trace_resource *tr_resource = trace_resource(_resource);
struct pipe_screen *screen = tr_screen->screen;
- struct pipe_resource *resource = tr_resource->resource;
/* TODO trace call */
return screen->resource_get_handle(screen, tr_pipe ? tr_pipe->pipe : NULL,
resource, handle, usage);
}
static void
trace_screen_resource_changed(struct pipe_screen *_screen,
- struct pipe_resource *_resource)
+ struct pipe_resource *resource)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_resource *tr_res = trace_resource(_resource);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_resource *resource = tr_res->resource;
-
- assert(resource->screen == screen);
trace_dump_call_begin("pipe_screen", "resource_changed");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, resource);
screen->resource_changed(screen, resource);
trace_dump_call_end();
}
static void
trace_screen_resource_destroy(struct pipe_screen *_screen,
- struct pipe_resource *_resource)
+ struct pipe_resource *resource)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_resource *tr_res = trace_resource(_resource);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_resource *resource = tr_res->resource;
-
- assert(resource->screen == screen);
trace_dump_call_begin("pipe_screen", "resource_destroy");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, resource);
trace_dump_call_end();
- trace_resource_destroy(tr_scr, tr_res);
+ screen->resource_destroy(screen, resource);
}
/********************************************************************
* fence
*/
static void
trace_screen_fence_reference(struct pipe_screen *_screen,
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index 47845a3..fe0c7b5 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -28,80 +28,42 @@
#include "util/u_inlines.h"
#include "util/u_hash_table.h"
#include "util/u_memory.h"
#include "util/simple_list.h"
#include "tr_screen.h"
#include "tr_context.h"
#include "tr_texture.h"
-struct pipe_resource *
-trace_resource_create(struct trace_screen *tr_scr,
- struct pipe_resource *texture)
-{
- struct trace_resource *tr_res;
-
- if (!texture)
- goto error;
-
- assert(texture->screen == tr_scr->screen);
-
- tr_res = CALLOC_STRUCT(trace_resource);
- if (!tr_res)
- goto error;
-
- memcpy(&tr_res->base, texture, sizeof(struct pipe_resource));
-
- pipe_reference_init(&tr_res->base.reference, 1);
- tr_res->base.screen = &tr_scr->base;
- tr_res->resource = texture;
-
- return &tr_res->base;
-
-error:
- pipe_resource_reference(&texture, NULL);
- return NULL;
-}
-
-
-void
-trace_resource_destroy(struct trace_screen *tr_scr,
- struct trace_resource *tr_res)
-{
- pipe_resource_reference(&tr_res->resource, NULL);
- FREE(tr_res);
-}
-
-
struct pipe_surface *
trace_surf_create(struct trace_context *tr_ctx,
- struct trace_resource *tr_res,
+ struct pipe_resource *res,
struct pipe_surface *surface)
{
struct trace_surface *tr_surf;
if (!surface)
goto error;
- assert(surface->texture == tr_res->resource);
+ assert(surface->texture == res);
tr_surf = CALLOC_STRUCT(trace_surface);
if (!tr_surf)
goto error;
memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
tr_surf->base.context = &tr_ctx->base;
pipe_reference_init(&tr_surf->base.reference, 1);
tr_surf->base.texture = NULL;
- pipe_resource_reference(&tr_surf->base.texture, &tr_res->base);
+ pipe_resource_reference(&tr_surf->base.texture, res);
tr_surf->surface = surface;
return &tr_surf->base;
error:
pipe_surface_reference(&surface, NULL);
return NULL;
}
@@ -110,41 +72,41 @@ trace_surf_destroy(struct trace_surface *tr_surf)
{
trace_context_check(tr_surf->base.context);
pipe_resource_reference(&tr_surf->base.texture, NULL);
pipe_surface_reference(&tr_surf->surface, NULL);
FREE(tr_surf);
}
struct pipe_transfer *
trace_transfer_create(struct trace_context *tr_ctx,
- struct trace_resource *tr_res,
+ struct pipe_resource *res,
struct pipe_transfer *transfer)
{
struct trace_transfer *tr_trans;
if (!transfer)
goto error;
- assert(transfer->resource == tr_res->resource);
+ assert(transfer->resource == res);
tr_trans = CALLOC_STRUCT(trace_transfer);
if (!tr_trans)
goto error;
memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer));
tr_trans->base.resource = NULL;
tr_trans->transfer = transfer;
- pipe_resource_reference(&tr_trans->base.resource, &tr_res->base);
- assert(tr_trans->base.resource == &tr_res->base);
+ pipe_resource_reference(&tr_trans->base.resource, res);
+ assert(tr_trans->base.resource == res);
return &tr_trans->base;
error:
tr_ctx->pipe->transfer_unmap(tr_ctx->pipe, transfer);
return NULL;
}
void
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
index af50851..e5dfc53 100644
--- a/src/gallium/drivers/trace/tr_texture.h
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -36,31 +36,20 @@
struct trace_context;
struct tr_list
{
struct tr_list *next;
struct tr_list *prev;
};
-
-struct trace_resource
-{
- struct pipe_resource base;
-
- struct pipe_resource *resource;
-
- struct tr_list list;
-};
-
-
struct trace_surface
{
struct pipe_surface base;
struct pipe_surface *surface;
struct tr_list list;
};
@@ -78,76 +67,56 @@ struct trace_transfer
struct pipe_transfer *transfer;
struct pipe_context *pipe;
struct tr_list list;
void *map;
};
-static inline struct trace_resource *
-trace_resource(struct pipe_resource *texture)
-{
- if (!texture)
- return NULL;
- (void)trace_screen(texture->screen);
- return (struct trace_resource *)texture;
-}
-
-
static inline struct trace_surface *
trace_surface(struct pipe_surface *surface)
{
if (!surface)
return NULL;
- (void)trace_resource(surface->texture);
return (struct trace_surface *)surface;
}
static inline struct trace_sampler_view *
trace_sampler_view(struct pipe_sampler_view *sampler_view)
{
if (!sampler_view)
return NULL;
return (struct trace_sampler_view *)sampler_view;
}
static inline struct trace_transfer *
trace_transfer(struct pipe_transfer *transfer)
{
if (!transfer)
return NULL;
- (void)trace_resource(transfer->resource);
return (struct trace_transfer *)transfer;
}
-struct pipe_resource *
-trace_resource_create(struct trace_screen *tr_scr,
- struct pipe_resource *texture);
-
-void
-trace_resource_destroy(struct trace_screen *tr_scr,
- struct trace_resource *tr_res);
-
struct pipe_surface *
trace_surf_create(struct trace_context *tr_ctx,
- struct trace_resource *tr_res,
+ struct pipe_resource *tr_res,
struct pipe_surface *surface);
void
trace_surf_destroy(struct trace_surface *tr_surf);
struct pipe_transfer *
trace_transfer_create(struct trace_context *tr_ctx,
- struct trace_resource *tr_res,
+ struct pipe_resource *tr_res,
struct pipe_transfer *transfer);
void
trace_transfer_destroy(struct trace_context *tr_ctx,
struct trace_transfer *tr_trans);
#endif /* TR_TEXTURE_H_ */
--
2.7.4
More information about the mesa-dev
mailing list