diff options
author | Michel Dänzer <[email protected]> | 2009-02-18 18:13:44 +0100 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2009-02-18 18:13:44 +0100 |
commit | c738edcc68905fb251cf9edc0529e2e1c778fdee (patch) | |
tree | 56c903e98a82dc0abc01e1874d190a8f12a3dbf0 /src/gallium | |
parent | aba88b7ed7a1346adada9532aed9633617eb3b6d (diff) |
gallium: Fix up trace driver for introduction of struct pipe_transfer.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/trace/tr_screen.c | 131 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_state.c | 29 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_state.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_texture.c | 40 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_texture.h | 27 |
5 files changed, 200 insertions, 29 deletions
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 8789f86b1a8..164c6bbc4d6 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -315,26 +315,101 @@ trace_screen_tex_surface_release(struct pipe_screen *_screen, } +static struct pipe_transfer * +trace_screen_get_tex_transfer(struct pipe_screen *_screen, + struct pipe_texture *texture, + unsigned face, unsigned level, + unsigned zslice, + enum pipe_transfer_usage usage, + unsigned x, unsigned y, unsigned w, unsigned h) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + struct trace_texture *tr_tex; + struct pipe_transfer *result; + + assert(texture); + tr_tex = trace_texture(tr_scr, texture); + texture = tr_tex->texture; + assert(texture->screen == screen); + + trace_dump_call_begin("pipe_screen", "get_tex_transfer"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, texture); + trace_dump_arg(uint, face); + trace_dump_arg(uint, level); + trace_dump_arg(uint, zslice); + trace_dump_arg(uint, usage); + + result = screen->get_tex_transfer(screen, texture, face, level, zslice, usage, + x, y, w, h); + + trace_dump_ret(ptr, result); + + trace_dump_call_end(); + + result = trace_transfer_create(tr_tex, result); + + return result; +} + + +static void +trace_screen_tex_transfer_release(struct pipe_screen *_screen, + struct pipe_transfer **ptransfer) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + struct trace_texture *tr_tex; + struct trace_transfer *tr_trans; + struct pipe_transfer *transfer; + + assert(ptransfer); + if(*ptransfer) { + tr_tex = trace_texture(tr_scr, (*ptransfer)->texture); + tr_trans = trace_transfer(tr_tex, *ptransfer); + transfer = tr_trans->transfer; + } + else + transfer = NULL; + + if (*ptransfer) { + if (!--(*ptransfer)->refcount) { + trace_dump_call_begin("pipe_screen", "tex_transfer_destroy"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, transfer); + + trace_transfer_destroy(tr_tex, *ptransfer); + + trace_dump_call_end(); + } + + *ptransfer = NULL; + } +} + + static void * -trace_screen_surface_map(struct pipe_screen *_screen, - struct pipe_surface *surface, - unsigned flags) +trace_screen_transfer_map(struct pipe_screen *_screen, + struct pipe_transfer *transfer) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; struct trace_texture *tr_tex; - struct trace_surface *tr_surf; + struct trace_transfer *tr_trans; void *map; - tr_tex = trace_texture(tr_scr, surface->texture); - tr_surf = trace_surface(tr_tex, surface); - surface = tr_surf->surface; + tr_tex = trace_texture(tr_scr, transfer->texture); + tr_trans = trace_transfer(tr_tex, transfer); + transfer = tr_trans->transfer; - map = screen->surface_map(screen, surface, flags); + map = screen->transfer_map(screen, transfer); if(map) { - if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) { - assert(!tr_surf->map); - tr_surf->map = map; + if(transfer->usage != PIPE_TRANSFER_READ) { + assert(!tr_trans->map); + tr_trans->map = map; } } @@ -343,33 +418,33 @@ trace_screen_surface_map(struct pipe_screen *_screen, static void -trace_screen_surface_unmap(struct pipe_screen *_screen, - struct pipe_surface *surface) +trace_screen_transfer_unmap(struct pipe_screen *_screen, + struct pipe_transfer *transfer) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; struct trace_texture *tr_tex; - struct trace_surface *tr_surf; + struct trace_transfer *tr_trans; - tr_tex = trace_texture(tr_scr, surface->texture); - tr_surf = trace_surface(tr_tex, surface); - surface = tr_surf->surface; + tr_tex = trace_texture(tr_scr, transfer->texture); + tr_trans = trace_transfer(tr_tex, transfer); + transfer = tr_trans->transfer; - if(tr_surf->map) { - size_t size = surface->nblocksy * surface->stride; + if(tr_trans->map) { + size_t size = transfer->nblocksy * transfer->stride; - trace_dump_call_begin("pipe_winsys", "surface_write"); + trace_dump_call_begin("pipe_winsys", "transfer_write"); trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, surface); + trace_dump_arg(ptr, transfer); trace_dump_arg_begin("data"); - trace_dump_bytes(tr_surf->map, size); + trace_dump_bytes(tr_trans->map, size); trace_dump_arg_end(); trace_dump_arg_begin("stride"); - trace_dump_uint(surface->stride); + trace_dump_uint(transfer->stride); trace_dump_arg_end(); trace_dump_arg_begin("size"); @@ -378,10 +453,10 @@ trace_screen_surface_unmap(struct pipe_screen *_screen, trace_dump_call_end(); - tr_surf->map = NULL; + tr_trans->map = NULL; } - screen->surface_unmap(screen, surface); + screen->transfer_unmap(screen, transfer); } @@ -437,8 +512,10 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.texture_release = trace_screen_texture_release; tr_scr->base.get_tex_surface = trace_screen_get_tex_surface; tr_scr->base.tex_surface_release = trace_screen_tex_surface_release; - tr_scr->base.surface_map = trace_screen_surface_map; - tr_scr->base.surface_unmap = trace_screen_surface_unmap; + tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer; + tr_scr->base.tex_transfer_release = trace_screen_tex_transfer_release; + tr_scr->base.transfer_map = trace_screen_transfer_map; + tr_scr->base.transfer_unmap = trace_screen_transfer_unmap; tr_scr->screen = screen; diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c index 524f2d61948..81a9e2376e0 100644 --- a/src/gallium/drivers/trace/tr_state.c +++ b/src/gallium/drivers/trace/tr_state.c @@ -403,6 +403,33 @@ void trace_dump_surface(const struct pipe_surface *state) trace_dump_member(uint, state, width); trace_dump_member(uint, state, height); + trace_dump_member(uint, state, layout); + trace_dump_member(uint, state, offset); + trace_dump_member(uint, state, refcount); + trace_dump_member(uint, state, usage); + + trace_dump_member(ptr, state, texture); + trace_dump_member(uint, state, face); + trace_dump_member(uint, state, level); + trace_dump_member(uint, state, zslice); + + trace_dump_struct_end(); +} + + +void trace_dump_transfer(const struct pipe_transfer *state) +{ + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_transfer"); + + trace_dump_member(format, state, format); + trace_dump_member(uint, state, width); + trace_dump_member(uint, state, height); + trace_dump_member_begin("block"); trace_dump_block(&state->block); trace_dump_member_end(); @@ -410,8 +437,6 @@ void trace_dump_surface(const struct pipe_surface *state) trace_dump_member(uint, state, nblocksx); trace_dump_member(uint, state, nblocksy); trace_dump_member(uint, state, stride); - trace_dump_member(uint, state, layout); - trace_dump_member(uint, state, offset); trace_dump_member(uint, state, refcount); trace_dump_member(uint, state, usage); diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h index 5ae533dc664..513ed0ac98d 100644 --- a/src/gallium/drivers/trace/tr_state.h +++ b/src/gallium/drivers/trace/tr_state.h @@ -68,6 +68,8 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state); void trace_dump_surface(const struct pipe_surface *state); +void trace_dump_transfer(const struct pipe_transfer *state); + void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state); void trace_dump_vertex_element(const struct pipe_vertex_element *state); diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c index 1cc4f0bd436..120ba0dd317 100644 --- a/src/gallium/drivers/trace/tr_texture.c +++ b/src/gallium/drivers/trace/tr_texture.c @@ -109,3 +109,43 @@ trace_surface_destroy(struct trace_texture *tr_tex, FREE(tr_surf); } + +struct pipe_transfer * +trace_transfer_create(struct trace_texture *tr_tex, + struct pipe_transfer *transfer) +{ + struct trace_transfer *tr_trans; + + if(!transfer) + goto error; + + assert(transfer->texture == tr_tex->texture); + + tr_trans = CALLOC_STRUCT(trace_transfer); + if(!tr_trans) + goto error; + + memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer)); + + tr_trans->base.texture = NULL; + pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base); + tr_trans->transfer = transfer; + + return &tr_trans->base; + +error: + pipe_transfer_reference(&transfer, NULL); + return NULL; +} + + +void +trace_transfer_destroy(struct trace_texture *tr_tex, + struct pipe_transfer *transfer) +{ + struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer); + pipe_texture_reference(&tr_trans->base.texture, NULL); + pipe_transfer_reference(&tr_trans->transfer, NULL); + FREE(tr_trans); +} + diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h index 9e72edb8a3c..168cefd53d6 100644 --- a/src/gallium/drivers/trace/tr_texture.h +++ b/src/gallium/drivers/trace/tr_texture.h @@ -48,6 +48,14 @@ struct trace_surface struct pipe_surface base; struct pipe_surface *surface; +}; + + +struct trace_transfer +{ + struct pipe_transfer base; + + struct pipe_transfer *transfer; void *map; }; @@ -75,6 +83,17 @@ trace_surface(struct trace_texture *tr_tex, } +static INLINE struct trace_transfer * +trace_transfer(struct trace_texture *tr_tex, + struct pipe_transfer *transfer) +{ + if(!transfer) + return NULL; + assert(transfer->texture == &tr_tex->base); + return (struct trace_transfer *)transfer; +} + + struct pipe_texture * trace_texture_create(struct trace_screen *tr_scr, struct pipe_texture *texture); @@ -91,5 +110,13 @@ void trace_surface_destroy(struct trace_texture *tr_tex, struct pipe_surface *surface); +struct pipe_transfer * +trace_transfer_create(struct trace_texture *tr_tex, + struct pipe_transfer *transfer); + +void +trace_transfer_destroy(struct trace_texture *tr_tex, + struct pipe_transfer *transfer); + #endif /* TR_TEXTURE_H_ */ |