diff options
Diffstat (limited to 'src/gallium/drivers/trace/tr_context.c')
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 210 |
1 files changed, 124 insertions, 86 deletions
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index ec8be27077..c894972904 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -30,48 +30,66 @@ #include "tr_dump.h" #include "tr_state.h" +#include "tr_buffer.h" #include "tr_screen.h" #include "tr_texture.h" -#include "tr_winsys.h" #include "tr_context.h" -static INLINE struct pipe_texture * +static INLINE struct pipe_buffer * +trace_buffer_unwrap(struct trace_context *tr_ctx, + struct pipe_buffer *buffer) +{ + struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); + struct trace_buffer *tr_buf; + + if(!buffer) + return NULL; + + tr_buf = trace_buffer(tr_scr, buffer); + + assert(tr_buf->buffer); + assert(tr_buf->buffer->screen == tr_scr->screen); + return tr_buf->buffer; +} + + +static INLINE struct pipe_texture * trace_texture_unwrap(struct trace_context *tr_ctx, struct pipe_texture *texture) { - struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); + struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); struct trace_texture *tr_tex; - + if(!texture) return NULL; - + tr_tex = trace_texture(tr_scr, texture); - + assert(tr_tex->texture); assert(tr_tex->texture->screen == tr_scr->screen); return tr_tex->texture; } -static INLINE struct pipe_surface * +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_screen *tr_scr = trace_screen(tr_ctx->base.screen); struct trace_texture *tr_tex; struct trace_surface *tr_surf; - + if(!surface) return NULL; assert(surface->texture); if(!surface->texture) return surface; - + tr_tex = trace_texture(tr_scr, surface->texture); tr_surf = trace_surface(tr_tex, surface); - + assert(tr_surf->surface); assert(tr_surf->surface->texture->screen == tr_scr->screen); return tr_surf->surface; @@ -86,7 +104,7 @@ trace_context_set_edgeflags(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; trace_dump_call_begin("pipe_context", "set_edgeflags"); - + trace_dump_arg(ptr, pipe); /* FIXME: we don't know how big this array is */ trace_dump_arg(ptr, bitfield); @@ -115,24 +133,27 @@ trace_context_draw_arrays(struct pipe_context *_pipe, result = pipe->draw_arrays(pipe, mode, start, count);; trace_dump_ret(bool, result); - + trace_dump_call_end(); - + return result; } static INLINE boolean trace_context_draw_elements(struct pipe_context *_pipe, - struct pipe_buffer *indexBuffer, + struct pipe_buffer *_indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { + struct trace_screen *tr_scr = trace_screen(_pipe->screen); struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer); struct pipe_context *pipe = tr_ctx->pipe; + struct pipe_buffer *indexBuffer = tr_buf->buffer; boolean result; - trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer); + trace_screen_user_buffer_update(_pipe->screen, indexBuffer); trace_dump_call_begin("pipe_context", "draw_elements"); @@ -146,28 +167,31 @@ trace_context_draw_elements(struct pipe_context *_pipe, result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);; trace_dump_ret(bool, result); - + trace_dump_call_end(); - + return result; } static INLINE boolean trace_context_draw_range_elements(struct pipe_context *_pipe, - struct pipe_buffer *indexBuffer, + struct pipe_buffer *_indexBuffer, unsigned indexSize, unsigned minIndex, unsigned maxIndex, - unsigned mode, - unsigned start, + unsigned mode, + unsigned start, unsigned count) { + struct trace_screen *tr_scr = trace_screen(_pipe->screen); struct trace_context *tr_ctx = trace_context(_pipe); + struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer); struct pipe_context *pipe = tr_ctx->pipe; + struct pipe_buffer *indexBuffer = tr_buf->buffer; boolean result; - trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer); + trace_screen_user_buffer_update(_pipe->screen, indexBuffer); trace_dump_call_begin("pipe_context", "draw_range_elements"); @@ -180,15 +204,15 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, trace_dump_arg(uint, start); trace_dump_arg(uint, count); - result = pipe->draw_range_elements(pipe, - indexBuffer, - indexSize, minIndex, maxIndex, + result = pipe->draw_range_elements(pipe, + indexBuffer, + indexSize, minIndex, maxIndex, mode, start, count); - + trace_dump_ret(bool, result); - + trace_dump_call_end(); - + return result; } @@ -209,9 +233,9 @@ trace_context_create_query(struct pipe_context *_pipe, result = pipe->create_query(pipe, query_type);; trace_dump_ret(ptr, result); - + trace_dump_call_end(); - + return result; } @@ -235,7 +259,7 @@ trace_context_destroy_query(struct pipe_context *_pipe, static INLINE void -trace_context_begin_query(struct pipe_context *_pipe, +trace_context_begin_query(struct pipe_context *_pipe, struct pipe_query *query) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -253,7 +277,7 @@ trace_context_begin_query(struct pipe_context *_pipe, static INLINE void -trace_context_end_query(struct pipe_context *_pipe, +trace_context_end_query(struct pipe_context *_pipe, struct pipe_query *query) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -271,7 +295,7 @@ trace_context_end_query(struct pipe_context *_pipe, static INLINE boolean -trace_context_get_query_result(struct pipe_context *_pipe, +trace_context_get_query_result(struct pipe_context *_pipe, struct pipe_query *query, boolean wait, uint64_t *presult) @@ -290,9 +314,9 @@ trace_context_get_query_result(struct pipe_context *_pipe, trace_dump_arg(uint, result); trace_dump_ret(bool, _result); - + trace_dump_call_end(); - + return _result; } @@ -315,13 +339,13 @@ trace_context_create_blend_state(struct pipe_context *_pipe, trace_dump_ret(ptr, result); trace_dump_call_end(); - + return result; } static INLINE void -trace_context_bind_blend_state(struct pipe_context *_pipe, +trace_context_bind_blend_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -339,7 +363,7 @@ trace_context_bind_blend_state(struct pipe_context *_pipe, static INLINE void -trace_context_delete_blend_state(struct pipe_context *_pipe, +trace_context_delete_blend_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -372,15 +396,15 @@ trace_context_create_sampler_state(struct pipe_context *_pipe, result = pipe->create_sampler_state(pipe, state);; trace_dump_ret(ptr, result); - + trace_dump_call_end(); - + return result; } static INLINE void -trace_context_bind_sampler_states(struct pipe_context *_pipe, +trace_context_bind_sampler_states(struct pipe_context *_pipe, unsigned num_states, void **states) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -399,7 +423,7 @@ trace_context_bind_sampler_states(struct pipe_context *_pipe, static INLINE void -trace_context_delete_sampler_state(struct pipe_context *_pipe, +trace_context_delete_sampler_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -432,15 +456,15 @@ trace_context_create_rasterizer_state(struct pipe_context *_pipe, result = pipe->create_rasterizer_state(pipe, state);; trace_dump_ret(ptr, result); - + trace_dump_call_end(); - + return result; } static INLINE void -trace_context_bind_rasterizer_state(struct pipe_context *_pipe, +trace_context_bind_rasterizer_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -458,7 +482,7 @@ trace_context_bind_rasterizer_state(struct pipe_context *_pipe, static INLINE void -trace_context_delete_rasterizer_state(struct pipe_context *_pipe, +trace_context_delete_rasterizer_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -489,17 +513,17 @@ trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(depth_stencil_alpha_state, state); - + trace_dump_ret(ptr, result); trace_dump_call_end(); - + return result; } static INLINE void -trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, +trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -517,7 +541,7 @@ trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, static INLINE void -trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe, +trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -550,15 +574,15 @@ trace_context_create_fs_state(struct pipe_context *_pipe, result = pipe->create_fs_state(pipe, state);; trace_dump_ret(ptr, result); - + trace_dump_call_end(); - + return result; } static INLINE void -trace_context_bind_fs_state(struct pipe_context *_pipe, +trace_context_bind_fs_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -576,7 +600,7 @@ trace_context_bind_fs_state(struct pipe_context *_pipe, static INLINE void -trace_context_delete_fs_state(struct pipe_context *_pipe, +trace_context_delete_fs_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -609,15 +633,15 @@ trace_context_create_vs_state(struct pipe_context *_pipe, result = pipe->create_vs_state(pipe, state);; trace_dump_ret(ptr, result); - + trace_dump_call_end(); - + return result; } static INLINE void -trace_context_bind_vs_state(struct pipe_context *_pipe, +trace_context_bind_vs_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -635,7 +659,7 @@ trace_context_bind_vs_state(struct pipe_context *_pipe, static INLINE void -trace_context_delete_vs_state(struct pipe_context *_pipe, +trace_context_delete_vs_state(struct pipe_context *_pipe, void *state) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -696,8 +720,9 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer); - + if (buffer) + trace_screen_user_buffer_update(_pipe->screen, buffer->buffer); + trace_dump_call_begin("pipe_context", "set_constant_buffer"); trace_dump_arg(ptr, pipe); @@ -705,7 +730,13 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe, trace_dump_arg(uint, index); trace_dump_arg(constant_buffer, buffer); - pipe->set_constant_buffer(pipe, shader, index, buffer);; + if (buffer) { + struct pipe_constant_buffer _buffer; + _buffer.buffer = trace_buffer_unwrap(tr_ctx, buffer->buffer); + pipe->set_constant_buffer(pipe, shader, index, &_buffer); + } else { + pipe->set_constant_buffer(pipe, shader, index, buffer); + } trace_dump_call_end(); } @@ -719,7 +750,7 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; struct pipe_framebuffer_state unwrapped_state; unsigned i; - + /* Unwrap the input state */ memcpy(&unwrapped_state, state, sizeof(unwrapped_state)); for(i = 0; i < state->nr_cbufs; ++i) @@ -728,7 +759,7 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe, unwrapped_state.cbufs[i] = NULL; unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf); state = &unwrapped_state; - + trace_dump_call_begin("pipe_context", "set_framebuffer_state"); trace_dump_arg(ptr, pipe); @@ -803,7 +834,7 @@ trace_context_set_sampler_textures(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS]; unsigned i; - + for(i = 0; i < num_textures; ++i) unwrapped_textures[i] = trace_texture_unwrap(tr_ctx, textures[i]); textures = unwrapped_textures; @@ -830,18 +861,27 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, unsigned i; for(i = 0; i < num_buffers; ++i) - trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer); + trace_screen_user_buffer_update(_pipe->screen, buffers[i].buffer); trace_dump_call_begin("pipe_context", "set_vertex_buffers"); trace_dump_arg(ptr, pipe); trace_dump_arg(uint, num_buffers); - + trace_dump_arg_begin("buffers"); trace_dump_struct_array(vertex_buffer, buffers, num_buffers); trace_dump_arg_end(); - pipe->set_vertex_buffers(pipe, num_buffers, buffers);; + if (num_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_buffer_unwrap(tr_ctx, buffers[i].buffer); + pipe->set_vertex_buffers(pipe, num_buffers, _buffers); + free(_buffers); + } else { + pipe->set_vertex_buffers(pipe, num_buffers, NULL); + } trace_dump_call_end(); } @@ -872,7 +912,6 @@ trace_context_set_vertex_elements(struct pipe_context *_pipe, static INLINE void trace_context_surface_copy(struct pipe_context *_pipe, - boolean do_flip, struct pipe_surface *dest, unsigned destx, unsigned desty, struct pipe_surface *src, @@ -884,11 +923,10 @@ trace_context_surface_copy(struct pipe_context *_pipe, dest = trace_surface_unwrap(tr_ctx, dest); src = trace_surface_unwrap(tr_ctx, src); - + trace_dump_call_begin("pipe_context", "surface_copy"); trace_dump_arg(ptr, pipe); - trace_dump_arg(bool, do_flip); trace_dump_arg(ptr, dest); trace_dump_arg(uint, destx); trace_dump_arg(uint, desty); @@ -898,10 +936,10 @@ trace_context_surface_copy(struct pipe_context *_pipe, trace_dump_arg(uint, width); trace_dump_arg(uint, height); - pipe->surface_copy(pipe, do_flip, - dest, destx, desty, + pipe->surface_copy(pipe, + dest, destx, desty, src, srcx, srcy, width, height); - + trace_dump_call_end(); } @@ -934,7 +972,7 @@ trace_context_surface_fill(struct pipe_context *_pipe, static INLINE void -trace_context_clear(struct pipe_context *_pipe, +trace_context_clear(struct pipe_context *_pipe, struct pipe_surface *surface, unsigned clearValue) { @@ -988,7 +1026,7 @@ trace_context_destroy(struct pipe_context *_pipe) trace_dump_arg(ptr, pipe); pipe->destroy(pipe); - + trace_dump_call_end(); FREE(tr_ctx); @@ -996,23 +1034,25 @@ trace_context_destroy(struct pipe_context *_pipe) struct pipe_context * -trace_context_create(struct pipe_screen *screen, +trace_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) { + struct trace_screen *tr_scr = trace_screen(_screen); struct trace_context *tr_ctx; - + struct pipe_screen *screen = tr_scr->screen; + if(!pipe) goto error1; - + if(!trace_dump_enabled()) goto error1; - + tr_ctx = CALLOC_STRUCT(trace_context); if(!tr_ctx) goto error1; - tr_ctx->base.winsys = screen->winsys; - tr_ctx->base.screen = screen; + tr_ctx->base.winsys = _screen->winsys; + tr_ctx->base.screen = _screen; tr_ctx->base.destroy = trace_context_destroy; tr_ctx->base.set_edgeflags = trace_context_set_edgeflags; tr_ctx->base.draw_arrays = trace_context_draw_arrays; @@ -1057,16 +1097,14 @@ trace_context_create(struct pipe_screen *screen, tr_ctx->base.flush = trace_context_flush; tr_ctx->pipe = pipe; - + trace_dump_call_begin("", "pipe_context_create"); - trace_dump_arg_begin("screen"); - trace_dump_ptr(pipe->screen); - trace_dump_arg_end(); + trace_dump_arg(ptr, screen); trace_dump_ret(ptr, pipe); trace_dump_call_end(); return &tr_ctx->base; - + error1: return pipe; } |