diff options
author | Thomas Balling Sørensen <tball@tball-laptop.(none)> | 2010-10-05 12:04:08 +0200 |
---|---|---|
committer | Thomas Balling Sørensen <tball@tball-laptop.(none)> | 2010-10-05 12:04:08 +0200 |
commit | 1218430e1200a08cd64b6555d3fd1fd0274ad9e5 (patch) | |
tree | e060fb27b8388a4bd237ca39fc20f1675c5e367c /src/gallium/drivers/trace | |
parent | 63b1525cf0a50e3d31328c3b56355a86056e4c05 (diff) | |
parent | bf21b7006c63c3dc47045c22d4f372dfe6c7ce67 (diff) |
Merge branch 'master' into pipe-video
Conflicts:
configs/linux-dri
configure.ac
src/gallium/drivers/nvfx/Makefile
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/state_tracker/dri1_api.h
src/gallium/include/state_tracker/drm_api.h
src/gallium/tests/python/samples/tri.py
src/gallium/tests/trivial/Makefile
src/gallium/tests/unit/Makefile
src/gallium/tests/unit/SConscript
src/gallium/tests/unit/u_format_test.c
src/gallium/winsys/nouveau/drm/nouveau_drm_api.c
Diffstat (limited to 'src/gallium/drivers/trace')
-rw-r--r-- | src/gallium/drivers/trace/Makefile | 3 | ||||
-rw-r--r-- | src/gallium/drivers/trace/README | 37 | ||||
-rw-r--r-- | src/gallium/drivers/trace/SConscript | 3 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 401 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_context.h | 42 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_drm.c | 105 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_drm.h | 35 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump_state.c | 62 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump_state.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_public.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_rbug.c | 864 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_screen.c | 58 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_screen.h | 50 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_state.c | 66 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_state.h | 68 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_texture.c | 17 |
17 files changed, 243 insertions, 1576 deletions
diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 78f6347dc72..99e5fb81c22 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -8,9 +8,6 @@ C_SOURCES = \ tr_dump.c \ tr_dump_state.c \ tr_screen.c \ - tr_state.c \ - tr_rbug.c \ - tr_drm.c \ tr_texture.c include ../../Makefile.template diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index 203c3851bc3..cdcd8d2b4be 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -3,15 +3,15 @@ = About = -This directory contains a Gallium3D debugger pipe driver. -It can traces all incoming calls and/or provide remote debugging functionality. +This directory contains a Gallium3D trace debugger pipe driver. +It can traces all incoming calls. = Build Instructions = To build, invoke scons on the top dir as - scons dri=no statetrackers=mesa drivers=softpipe,i965simple,trace winsys=xlib + scons dri=no statetrackers=mesa winsys=xlib = Usage = @@ -36,40 +36,27 @@ Firefox or Internet Explorer. == Remote debugging == -For remote debugging +For remote debugging see: - export XMESA_TRACE=y - GALLIUM_RBUG=true progs/trivial/tri - -which should open gallium remote debugging session. While the program is running -you can launch the small remote debugging application from progs/rbug. More -information is in that directory. + src/gallium/drivers/rbug/README = Integrating = You can integrate the trace pipe driver either inside the state tracker or the -winsys. The procedure on both cases is the same. Let's assume you have a -pipe_screen and a pipe_context pair obtained by the usual means (variable and -function names are just for illustration purposes): +target. The procedure on both cases is the same. Let's assume you have a +pipe_screen obtained by the usual means (variable and function names are just +for illustration purposes): real_screen = real_screen_create(...); - real_context = real_context_create(...); - -The trace screen and pipe_context is then created by doing +The trace screen is then created by doing trace_screen = trace_screen_create(real_screen); - - trace_context = trace_context_create(trace_screen, real_context); - -You can then simply use trace_screen and trace_context instead of real_screen -and real_context. -Do not call trace_winsys_create. Simply pass trace_screen->winsys or -trace_context->winsys in places you would pass winsys. +You can then simply use trace_screen instead of real_screen. -You can create as many contexts you wish. Just ensure that you don't mistake -trace_screen with real_screen when creating them. +You can create as many contexts you wish from trace_screen::context_create they +are automatically wrapped by trace_screen. -- diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 5f1fb17966a..06b0c4863a4 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -6,12 +6,9 @@ trace = env.ConvenienceLibrary( target = 'trace', source = [ 'tr_context.c', - 'tr_drm.c', 'tr_dump.c', 'tr_dump_state.c', 'tr_screen.c', - 'tr_state.c', - 'tr_rbug.c', 'tr_texture.c', ]) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 71ba1e909df..04f30f82c3d 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -28,16 +28,16 @@ #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_simple_list.h" -#include "util/u_format.h" #include "pipe/p_format.h" #include "pipe/p_screen.h" #include "tr_dump.h" #include "tr_dump_state.h" -#include "tr_state.h" +#include "tr_public.h" #include "tr_screen.h" #include "tr_texture.h" +#include "tr_context.h" @@ -83,173 +83,20 @@ trace_surface_unwrap(struct trace_context *tr_ctx, static INLINE void -trace_context_draw_block(struct trace_context *tr_ctx, int flag) -{ - int k; - - pipe_mutex_lock(tr_ctx->draw_mutex); - - if (tr_ctx->draw_blocker & flag) { - tr_ctx->draw_blocked |= flag; - } else if ((tr_ctx->draw_rule.blocker & flag) && - (tr_ctx->draw_blocker & 4)) { - boolean block = FALSE; - debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__, - (void *) tr_ctx->draw_rule.fs, (void *) tr_ctx->curr.fs, - (void *) tr_ctx->draw_rule.vs, (void *) tr_ctx->curr.vs, - (void *) tr_ctx->draw_rule.surf, 0, - (void *) tr_ctx->draw_rule.sampler_view, 0); - if (tr_ctx->draw_rule.fs && - tr_ctx->draw_rule.fs == tr_ctx->curr.fs) - block = TRUE; - if (tr_ctx->draw_rule.vs && - tr_ctx->draw_rule.vs == tr_ctx->curr.vs) - block = TRUE; - if (tr_ctx->draw_rule.surf && - tr_ctx->draw_rule.surf == tr_ctx->curr.zsbuf) - block = TRUE; - if (tr_ctx->draw_rule.surf) - for (k = 0; k < tr_ctx->curr.nr_cbufs; k++) - if (tr_ctx->draw_rule.surf == tr_ctx->curr.cbufs[k]) - block = TRUE; - if (tr_ctx->draw_rule.sampler_view) { - for (k = 0; k < tr_ctx->curr.num_sampler_views; k++) - if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.sampler_views[k]) - block = TRUE; - for (k = 0; k < tr_ctx->curr.num_vert_sampler_views; k++) { - if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.vert_sampler_views[k]) { - block = TRUE; - } - } - } - - if (block) - tr_ctx->draw_blocked |= (flag | 4); - } - - if (tr_ctx->draw_blocked) - trace_rbug_notify_draw_blocked(tr_ctx); - - /* wait for rbug to clear the blocked flag */ - while (tr_ctx->draw_blocked & flag) { - tr_ctx->draw_blocked |= flag; -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_wait(tr_ctx->draw_cond, tr_ctx->draw_mutex); -#else - pipe_mutex_unlock(tr_ctx->draw_mutex); -#ifdef PIPE_SUBSYSTEM_WINDOWS_USER - Sleep(1); -#endif - pipe_mutex_lock(tr_ctx->draw_mutex); -#endif - } - - pipe_mutex_unlock(tr_ctx->draw_mutex); -} - -static INLINE void -trace_context_draw_arrays(struct pipe_context *_pipe, - unsigned mode, unsigned start, unsigned count) +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; - if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) - return; - - trace_context_draw_block(tr_ctx, 1); - - trace_dump_call_begin("pipe_context", "draw_arrays"); + trace_dump_call_begin("pipe_context", "draw_vbo"); - trace_dump_arg(ptr, pipe); - trace_dump_arg(uint, mode); - trace_dump_arg(uint, start); - trace_dump_arg(uint, count); + trace_dump_arg(ptr, pipe); + trace_dump_arg(draw_info, info); - pipe->draw_arrays(pipe, mode, start, count); + pipe->draw_vbo(pipe, info); trace_dump_call_end(); - - trace_context_draw_block(tr_ctx, 2); -} - - -static INLINE void -trace_context_draw_elements(struct pipe_context *_pipe, - struct pipe_resource *_indexBuffer, - unsigned indexSize, int indexBias, - unsigned mode, unsigned start, unsigned count) -{ - struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_resource *tr_buf = trace_resource(_indexBuffer); - struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_resource *indexBuffer = tr_buf->resource; - - if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) - return; - - trace_context_draw_block(tr_ctx, 1); - - trace_dump_call_begin("pipe_context", "draw_elements"); - - trace_dump_arg(ptr, pipe); - trace_dump_arg(ptr, indexBuffer); - trace_dump_arg(uint, indexSize); - trace_dump_arg(int, indexBias); - trace_dump_arg(uint, mode); - trace_dump_arg(uint, start); - trace_dump_arg(uint, count); - - pipe->draw_elements(pipe, indexBuffer, indexSize, indexBias, - mode, start, count); - - trace_dump_call_end(); - - trace_context_draw_block(tr_ctx, 2); -} - - -static INLINE void -trace_context_draw_range_elements(struct pipe_context *_pipe, - struct pipe_resource *_indexBuffer, - unsigned indexSize, - int indexBias, - unsigned minIndex, - unsigned maxIndex, - unsigned mode, - unsigned start, - unsigned count) -{ - struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_resource *tr_buf = trace_resource(_indexBuffer); - struct pipe_context *pipe = tr_ctx->pipe; - struct pipe_resource *indexBuffer = tr_buf->resource; - - if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) - return; - - trace_context_draw_block(tr_ctx, 1); - - trace_dump_call_begin("pipe_context", "draw_range_elements"); - - trace_dump_arg(ptr, pipe); - trace_dump_arg(ptr, indexBuffer); - trace_dump_arg(uint, indexSize); - trace_dump_arg(int, indexBias); - trace_dump_arg(uint, minIndex); - trace_dump_arg(uint, maxIndex); - trace_dump_arg(uint, mode); - trace_dump_arg(uint, start); - trace_dump_arg(uint, count); - - pipe->draw_range_elements(pipe, - indexBuffer, indexSize, indexBias, - minIndex, maxIndex, - mode, start, count); - - trace_dump_call_end(); - - trace_context_draw_block(tr_ctx, 2); } @@ -334,7 +181,7 @@ static INLINE boolean trace_context_get_query_result(struct pipe_context *_pipe, struct pipe_query *query, boolean wait, - uint64_t *presult) + void *presult) { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; @@ -346,7 +193,7 @@ trace_context_get_query_result(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); _result = pipe->get_query_result(pipe, query, wait, presult); - result = *presult; + result = *((uint64_t*)presult); trace_dump_arg(uint, result); trace_dump_ret(bool, _result); @@ -634,31 +481,22 @@ trace_context_create_fs_state(struct pipe_context *_pipe, trace_dump_call_end(); - result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_FRAGMENT); - return result; } static INLINE void trace_context_bind_fs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr ? tr_shdr->state : NULL; trace_dump_call_begin("pipe_context", "bind_fs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); - tr_ctx->curr.fs = tr_shdr; - - if (tr_shdr && tr_shdr->replaced) - state = tr_shdr->replaced; - pipe->bind_fs_state(pipe, state); trace_dump_call_end(); @@ -667,12 +505,10 @@ trace_context_bind_fs_state(struct pipe_context *_pipe, static INLINE void trace_context_delete_fs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr->state; trace_dump_call_begin("pipe_context", "delete_fs_state"); @@ -682,8 +518,6 @@ trace_context_delete_fs_state(struct pipe_context *_pipe, pipe->delete_fs_state(pipe, state); trace_dump_call_end(); - - trace_shader_destroy(tr_ctx, tr_shdr); } @@ -706,31 +540,22 @@ trace_context_create_vs_state(struct pipe_context *_pipe, trace_dump_call_end(); - result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_VERTEX); - return result; } static INLINE void trace_context_bind_vs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr ? tr_shdr->state : NULL; trace_dump_call_begin("pipe_context", "bind_vs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); - tr_ctx->curr.vs = tr_shdr; - - if (tr_shdr && tr_shdr->replaced) - state = tr_shdr->replaced; - pipe->bind_vs_state(pipe, state); trace_dump_call_end(); @@ -739,12 +564,10 @@ trace_context_bind_vs_state(struct pipe_context *_pipe, static INLINE void trace_context_delete_vs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr->state; trace_dump_call_begin("pipe_context", "delete_vs_state"); @@ -754,8 +577,6 @@ trace_context_delete_vs_state(struct pipe_context *_pipe, pipe->delete_vs_state(pipe, state); trace_dump_call_end(); - - trace_shader_destroy(tr_ctx, tr_shdr); } @@ -812,7 +633,7 @@ trace_context_delete_vertex_elements_state(struct pipe_context *_pipe, struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - trace_dump_call_begin("pipe_context", "delete_verte_elements_state"); + trace_dump_call_begin("pipe_context", "delete_vertex_elements_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); @@ -876,6 +697,22 @@ trace_context_set_clip_state(struct pipe_context *_pipe, trace_dump_call_end(); } +static INLINE void +trace_context_set_sample_mask(struct pipe_context *_pipe, + unsigned sample_mask) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + trace_dump_call_begin("pipe_context", "set_sample_mask"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(uint, sample_mask); + + pipe->set_sample_mask(pipe, sample_mask); + + trace_dump_call_end(); +} static INLINE void trace_context_set_constant_buffer(struct pipe_context *_pipe, @@ -911,18 +748,6 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe, struct pipe_framebuffer_state unwrapped_state; unsigned i; - { - tr_ctx->curr.nr_cbufs = state->nr_cbufs; - for (i = 0; i < state->nr_cbufs; i++) - if (state->cbufs[i]) - tr_ctx->curr.cbufs[i] = trace_resource(state->cbufs[i]->texture); - else - tr_ctx->curr.cbufs[i] = NULL; - if (state->zsbuf) - tr_ctx->curr.zsbuf = trace_resource(state->zsbuf->texture); - else - tr_ctx->curr.zsbuf = NULL; - } /* Unwrap the input state */ memcpy(&unwrapped_state, state, sizeof(unwrapped_state)); @@ -1052,7 +877,7 @@ trace_sampler_view_destroy(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, view); - pipe->sampler_view_destroy(pipe, view); + pipe_sampler_view_reference(&tr_view->sampler_view, NULL); trace_dump_call_end(); @@ -1072,10 +897,8 @@ trace_context_set_fragment_sampler_views(struct pipe_context *_pipe, struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS]; unsigned i; - tr_ctx->curr.num_sampler_views = num; for(i = 0; i < num; ++i) { tr_view = trace_sampler_view(views[i]); - tr_ctx->curr.sampler_views[i] = tr_view; unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } views = unwrapped_views; @@ -1103,10 +926,8 @@ trace_context_set_vertex_sampler_views(struct pipe_context *_pipe, struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS]; unsigned i; - tr_ctx->curr.num_vert_sampler_views = num; for(i = 0; i < num; ++i) { tr_view = trace_sampler_view(views[i]); - tr_ctx->curr.vert_sampler_views[i] = tr_view; unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } views = unwrapped_views; @@ -1157,61 +978,64 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, static INLINE void -trace_context_surface_copy(struct pipe_context *_pipe, - struct pipe_surface *dest, - unsigned destx, unsigned desty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, - unsigned width, unsigned height) +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; - dest = trace_surface_unwrap(tr_ctx, dest); - src = trace_surface_unwrap(tr_ctx, src); - - trace_dump_call_begin("pipe_context", "surface_copy"); + trace_dump_call_begin("pipe_context", "set_index_buffer"); trace_dump_arg(ptr, pipe); - trace_dump_arg(ptr, dest); - trace_dump_arg(uint, destx); - trace_dump_arg(uint, desty); - trace_dump_arg(ptr, src); - trace_dump_arg(uint, srcx); - trace_dump_arg(uint, srcy); - trace_dump_arg(uint, width); - trace_dump_arg(uint, height); + trace_dump_arg(index_buffer, ib); - pipe->surface_copy(pipe, - dest, destx, desty, - src, srcx, srcy, width, height); + 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); + } trace_dump_call_end(); } - static INLINE void -trace_context_surface_fill(struct pipe_context *_pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - unsigned value) +trace_context_resource_copy_region(struct pipe_context *_pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height) { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - dst = trace_surface_unwrap(tr_ctx, dst); + dst = trace_resource_unwrap(tr_ctx, dst); + src = trace_resource_unwrap(tr_ctx, src); - trace_dump_call_begin("pipe_context", "surface_fill"); + trace_dump_call_begin("pipe_context", "resource_copy_region"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, dst); + trace_dump_arg_struct(subresource, subdst); trace_dump_arg(uint, dstx); trace_dump_arg(uint, dsty); + trace_dump_arg(uint, dstz); + trace_dump_arg(ptr, src); + trace_dump_arg_struct(subresource, subsrc); + trace_dump_arg(uint, srcx); + trace_dump_arg(uint, srcy); + trace_dump_arg(uint, srcz); trace_dump_arg(uint, width); trace_dump_arg(uint, height); - pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value); + pipe->resource_copy_region(pipe, + dst, subdst, dstx, dsty, dstz, + src, subsrc, srcx, srcy, srcz, width, height); trace_dump_call_end(); } @@ -1231,7 +1055,10 @@ trace_context_clear(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(uint, buffers); - trace_dump_arg_array(float, rgba, 4); + if (rgba) + trace_dump_arg_array(float, rgba, 4); + else + trace_dump_null(); trace_dump_arg(float, depth); trace_dump_arg(uint, stencil); @@ -1242,6 +1069,65 @@ trace_context_clear(struct pipe_context *_pipe, static INLINE void +trace_context_clear_render_target(struct pipe_context *_pipe, + struct pipe_surface *dst, + const float *rgba, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + dst = trace_surface_unwrap(tr_ctx, dst); + + trace_dump_call_begin("pipe_context", "clear_render_target"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, dst); + trace_dump_arg_array(float, rgba, 4); + trace_dump_arg(uint, dstx); + trace_dump_arg(uint, dsty); + trace_dump_arg(uint, width); + trace_dump_arg(uint, height); + + pipe->clear_render_target(pipe, dst, rgba, dstx, dsty, width, height); + + trace_dump_call_end(); +} + +static INLINE void +trace_context_clear_depth_stencil(struct pipe_context *_pipe, + struct pipe_surface *dst, + unsigned clear_flags, + double depth, + unsigned stencil, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + dst = trace_surface_unwrap(tr_ctx, dst); + + trace_dump_call_begin("pipe_context", "clear_depth_stencil"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, dst); + trace_dump_arg(uint, clear_flags); + trace_dump_arg(float, depth); + trace_dump_arg(uint, stencil); + trace_dump_arg(uint, dstx); + trace_dump_arg(uint, dsty); + trace_dump_arg(uint, width); + trace_dump_arg(uint, height); + + pipe->clear_depth_stencil(pipe, dst, clear_flags, depth, stencil, + dstx, dsty, width, height); + + trace_dump_call_end(); +} + +static INLINE void trace_context_flush(struct pipe_context *_pipe, unsigned flags, struct pipe_fence_handle **fence) @@ -1266,7 +1152,6 @@ trace_context_flush(struct pipe_context *_pipe, static INLINE void trace_context_destroy(struct pipe_context *_pipe) { - struct trace_screen *tr_scr = trace_screen(_pipe->screen); struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; @@ -1274,8 +1159,6 @@ trace_context_destroy(struct pipe_context *_pipe) trace_dump_arg(ptr, pipe); trace_dump_call_end(); - trace_screen_remove_from_list(tr_scr, contexts, tr_ctx); - pipe->destroy(pipe); FREE(tr_ctx); @@ -1484,9 +1367,9 @@ trace_context_transfer_inline_write(struct pipe_context *_context, static const struct debug_named_value rbug_blocker_flags[] = { - {"before", 1}, - {"after", 2}, - {NULL, 0}, + {"before", 1, NULL}, + {"after", 2, NULL}, + DEBUG_NAMED_VALUE_END }; struct pipe_context * @@ -1508,18 +1391,9 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.winsys = NULL; tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */ tr_ctx->base.screen = &tr_scr->base; - tr_ctx->draw_blocker = debug_get_flags_option("RBUG_BLOCK", - rbug_blocker_flags, - 0); - pipe_mutex_init(tr_ctx->draw_mutex); - pipe_condvar_init(tr_ctx->draw_cond); - pipe_mutex_init(tr_ctx->list_mutex); - make_empty_list(&tr_ctx->shaders); tr_ctx->base.destroy = trace_context_destroy; - tr_ctx->base.draw_arrays = trace_context_draw_arrays; - tr_ctx->base.draw_elements = trace_context_draw_elements; - tr_ctx->base.draw_range_elements = trace_context_draw_range_elements; + tr_ctx->base.draw_vbo = trace_context_draw_vbo; tr_ctx->base.create_query = trace_context_create_query; tr_ctx->base.destroy_query = trace_context_destroy_query; tr_ctx->base.begin_query = trace_context_begin_query; @@ -1550,6 +1424,7 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.set_blend_color = trace_context_set_blend_color; tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref; tr_ctx->base.set_clip_state = trace_context_set_clip_state; + tr_ctx->base.set_sample_mask = trace_context_set_sample_mask; tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer; tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state; tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple; @@ -1560,11 +1435,11 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.create_sampler_view = trace_create_sampler_view; tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy; tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers; - if (pipe->surface_copy) - tr_ctx->base.surface_copy = trace_context_surface_copy; - if (pipe->surface_fill) - tr_ctx->base.surface_fill = trace_context_surface_fill; + tr_ctx->base.set_index_buffer = trace_context_set_index_buffer; + tr_ctx->base.resource_copy_region = trace_context_resource_copy_region; tr_ctx->base.clear = trace_context_clear; + tr_ctx->base.clear_render_target = trace_context_clear_render_target; + tr_ctx->base.clear_depth_stencil = trace_context_clear_depth_stencil; tr_ctx->base.flush = trace_context_flush; tr_ctx->base.is_resource_referenced = trace_is_resource_referenced; @@ -1577,8 +1452,6 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->pipe = pipe; - trace_screen_add_to_list(tr_scr, contexts, tr_ctx); - return &tr_ctx->base; error1: diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 1b4121d80a9..dadbe561180 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -47,45 +47,6 @@ struct trace_context struct pipe_context base; struct pipe_context *pipe; - - /* current state */ - struct { - struct trace_shader *fs; - struct trace_shader *vs; - - struct trace_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; - unsigned num_sampler_views; - - struct trace_sampler_view *vert_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; - unsigned num_vert_sampler_views; - - unsigned nr_cbufs; - struct trace_resource *cbufs[PIPE_MAX_COLOR_BUFS]; - struct trace_resource *zsbuf; - } curr; - - struct { - struct trace_shader *fs; - struct trace_shader *vs; - - struct trace_sampler_view *sampler_view; - struct trace_resource *surf; - - int blocker; - } draw_rule; - unsigned draw_num_rules; - pipe_condvar draw_cond; - pipe_mutex draw_mutex; - int draw_blocker; - int draw_blocked; - - /* for list on screen */ - struct tr_list list; - - /* list of state objects */ - pipe_mutex list_mutex; - unsigned num_shaders; - struct tr_list shaders; }; @@ -101,9 +62,6 @@ struct pipe_context * trace_context_create(struct trace_screen *tr_scr, struct pipe_context *pipe); -void -trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx); - #ifdef __cplusplus } diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c deleted file mode 100644 index 0dc8cca2648..00000000000 --- a/src/gallium/drivers/trace/tr_drm.c +++ /dev/null @@ -1,105 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "state_tracker/drm_api.h" - -#include "util/u_memory.h" -#include "tr_drm.h" -#include "tr_screen.h" -#include "tr_public.h" - -struct trace_drm_api -{ - struct drm_api base; - - struct drm_api *api; -}; - -static INLINE struct trace_drm_api * -trace_drm_api(struct drm_api *_api) -{ - return (struct trace_drm_api *)_api; -} - -static struct pipe_screen * -trace_drm_create_screen(struct drm_api *_api, int fd, - struct drm_create_screen_arg *arg) -{ - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct drm_api *api = tr_api->api; - struct pipe_screen *screen; - - /* TODO trace call */ - - if (arg && arg->mode != DRM_CREATE_NORMAL) - return NULL; - - screen = api->create_screen(api, fd, arg); - - - return trace_screen_create(screen); -} - -static void -trace_drm_destroy(struct drm_api *_api) -{ - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct drm_api *api = tr_api->api; - - if (api->destroy) - api->destroy(api); - - FREE(tr_api); -} - -struct drm_api * -trace_drm_create(struct drm_api *api) -{ - struct trace_drm_api *tr_api; - - if (!api) - goto error; - - if (!trace_enabled()) - goto error; - - tr_api = CALLOC_STRUCT(trace_drm_api); - - if (!tr_api) - goto error; - - tr_api->base.name = api->name; - tr_api->base.driver_name = api->driver_name; - tr_api->base.create_screen = trace_drm_create_screen; - tr_api->base.destroy = trace_drm_destroy; - tr_api->api = api; - - return &tr_api->base; - -error: - return api; -} diff --git a/src/gallium/drivers/trace/tr_drm.h b/src/gallium/drivers/trace/tr_drm.h deleted file mode 100644 index 845c66a32aa..00000000000 --- a/src/gallium/drivers/trace/tr_drm.h +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef TR_DRM_H -#define TR_DRM_H - -struct drm_api; - -struct drm_api* trace_drm_create(struct drm_api *api); - -#endif /* ID_DRM_H */ diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h index f21f72b0c79..74c5e83e9e1 100644 --- a/src/gallium/drivers/trace/tr_dump.h +++ b/src/gallium/drivers/trace/tr_dump.h @@ -37,7 +37,6 @@ #include "pipe/p_compiler.h" #include "pipe/p_format.h" -struct pipe_buffer; struct pipe_resource; struct pipe_surface; struct pipe_transfer; diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index f148a859ff3..8f816060324 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -136,12 +136,13 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) trace_dump_member(bool, state, flatshade); trace_dump_member(bool, state, light_twoside); - trace_dump_member(uint, state, front_winding); - trace_dump_member(uint, state, cull_mode); - trace_dump_member(uint, state, fill_cw); - trace_dump_member(uint, state, fill_ccw); - trace_dump_member(bool, state, offset_cw); - trace_dump_member(bool, state, offset_ccw); + trace_dump_member(uint, state, front_ccw); + trace_dump_member(uint, state, cull_face); + trace_dump_member(uint, state, fill_front); + trace_dump_member(uint, state, fill_back); + trace_dump_member(bool, state, offset_point); + trace_dump_member(bool, state, offset_line); + trace_dump_member(bool, state, offset_tri); trace_dump_member(bool, state, scissor); trace_dump_member(bool, state, poly_smooth); trace_dump_member(bool, state, poly_stipple_enable); @@ -532,6 +533,26 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) } +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_struct_end(); +} + + void trace_dump_vertex_element(const struct pipe_vertex_element *state) { if (!trace_dumping_enabled_locked()) @@ -552,3 +573,32 @@ void trace_dump_vertex_element(const struct pipe_vertex_element *state) trace_dump_struct_end(); } + + +void trace_dump_draw_info(const struct pipe_draw_info *state) +{ + if (!trace_dumping_enabled_locked()) + return; + + if(!state) { + trace_dump_null(); + return; + } + + trace_dump_struct_begin("pipe_draw_info"); + + trace_dump_member(bool, state, indexed); + + trace_dump_member(uint, state, mode); + trace_dump_member(uint, state, start); + trace_dump_member(uint, state, count); + + trace_dump_member(uint, state, start_instance); + trace_dump_member(uint, state, instance_count); + + trace_dump_member(int, state, index_bias); + trace_dump_member(uint, state, min_index); + trace_dump_member(uint, state, max_index); + + trace_dump_struct_end(); +} diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h index e614e8355e3..078d2086109 100644 --- a/src/gallium/drivers/trace/tr_dump_state.h +++ b/src/gallium/drivers/trace/tr_dump_state.h @@ -75,7 +75,11 @@ void trace_dump_transfer(const struct pipe_transfer *state); void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state); +void trace_dump_index_buffer(const struct pipe_index_buffer *state); + void trace_dump_vertex_element(const struct pipe_vertex_element *state); +void trace_dump_draw_info(const struct pipe_draw_info *state); + #endif /* TR_STATE_H */ diff --git a/src/gallium/drivers/trace/tr_public.h b/src/gallium/drivers/trace/tr_public.h index 62e217097d0..aee4937dd4f 100644 --- a/src/gallium/drivers/trace/tr_public.h +++ b/src/gallium/drivers/trace/tr_public.h @@ -38,6 +38,9 @@ struct pipe_context; struct pipe_screen * trace_screen_create(struct pipe_screen *screen); +boolean +trace_enabled(void); + #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c deleted file mode 100644 index 3ce1b85854b..00000000000 --- a/src/gallium/drivers/trace/tr_rbug.c +++ /dev/null @@ -1,864 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#include "os/os_thread.h" -#include "util/u_format.h" -#include "util/u_string.h" -#include "util/u_inlines.h" -#include "util/u_memory.h" -#include "util/u_simple_list.h" -#include "util/u_network.h" -#include "os/os_time.h" - -#include "tgsi/tgsi_parse.h" - -#include "tr_dump.h" -#include "tr_state.h" -#include "tr_texture.h" - -#include "rbug/rbug.h" - -#include <errno.h> - -#define U642VOID(x) ((void *)(unsigned long)(x)) -#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) - -struct trace_rbug -{ - struct trace_screen *tr_scr; - struct rbug_connection *con; - pipe_thread thread; - boolean running; -}; - -PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug); - - -/********************************************************** - * Helper functions - */ - - -static struct trace_context * -trace_rbug_get_context_locked(struct trace_screen *tr_scr, rbug_context_t ctx) -{ - struct trace_context *tr_ctx = NULL; - struct tr_list *ptr; - - foreach(ptr, &tr_scr->contexts) { - tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); - if (ctx == VOID2U64(tr_ctx)) - break; - tr_ctx = NULL; - } - - return tr_ctx; -} - -static struct trace_shader * -trace_rbug_get_shader_locked(struct trace_context *tr_ctx, rbug_shader_t shdr) -{ - struct trace_shader *tr_shdr = NULL; - struct tr_list *ptr; - - foreach(ptr, &tr_ctx->shaders) { - tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); - if (shdr == VOID2U64(tr_shdr)) - break; - tr_shdr = NULL; - } - - return tr_shdr; -} - -static void * -trace_shader_create_locked(struct pipe_context *pipe, - struct trace_shader *tr_shdr, - struct tgsi_token *tokens) -{ - void *state = NULL; - struct pipe_shader_state pss = { 0 }; - pss.tokens = tokens; - - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { - state = pipe->create_fs_state(pipe, &pss); - } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { - state = pipe->create_vs_state(pipe, &pss); - } else - assert(0); - - return state; -} - -static void -trace_shader_bind_locked(struct pipe_context *pipe, - struct trace_shader *tr_shdr, - void *state) -{ - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { - pipe->bind_fs_state(pipe, state); - } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { - pipe->bind_vs_state(pipe, state); - } else - assert(0); -} - -static void -trace_shader_delete_locked(struct pipe_context *pipe, - struct trace_shader *tr_shdr, - void *state) -{ - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { - pipe->delete_fs_state(pipe, state); - } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { - pipe->delete_vs_state(pipe, state); - } else - assert(0); -} - -/************************************************ - * Request handler functions - */ - - -static int -trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_resource *tr_tex = NULL; - struct tr_list *ptr; - rbug_texture_t *texs; - int i = 0; - - pipe_mutex_lock(tr_scr->list_mutex); - texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t)); - foreach(ptr, &tr_scr->textures) { - tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list)); - texs[i++] = VOID2U64(tr_tex); - } - pipe_mutex_unlock(tr_scr->list_mutex); - - rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL); - FREE(texs); - - return 0; -} - -static int -trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_resource *tr_tex = NULL; - struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header; - struct tr_list *ptr; - struct pipe_resource *t; - - pipe_mutex_lock(tr_scr->list_mutex); - foreach(ptr, &tr_scr->textures) { - tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list)); - if (gpti->texture == VOID2U64(tr_tex)) - break; - tr_tex = NULL; - } - - if (!tr_tex) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - t = tr_tex->resource; - rbug_send_texture_info_reply(tr_rbug->con, serial, - t->target, t->format, - &t->width0, 1, - &t->height0, 1, - &t->depth0, 1, - util_format_get_blockwidth(t->format), - util_format_get_blockheight(t->format), - util_format_get_blocksize(t->format), - t->last_level, - t->nr_samples, - t->bind, - NULL); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_resource *tr_tex = NULL; - struct tr_list *ptr; - - struct pipe_context *context = tr_scr->private_context; - struct pipe_resource *tex; - struct pipe_transfer *t; - - void *map; - - pipe_mutex_lock(tr_scr->list_mutex); - foreach(ptr, &tr_scr->textures) { - tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list)); - if (gptr->texture == VOID2U64(tr_tex)) - break; - tr_tex = NULL; - } - - if (!tr_tex) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - tex = tr_tex->resource; - t = pipe_get_transfer(context, tex, - gptr->face, gptr->level, gptr->zslice, - PIPE_TRANSFER_READ, - gptr->x, gptr->y, gptr->w, gptr->h); - - map = context->transfer_map(context, t); - - rbug_send_texture_read_reply(tr_rbug->con, serial, - t->resource->format, - util_format_get_blockwidth(t->resource->format), - util_format_get_blockheight(t->resource->format), - util_format_get_blocksize(t->resource->format), - (uint8_t*)map, - t->stride * util_format_get_nblocksy(t->resource->format, - t->box.height), - t->stride, - NULL); - - context->transfer_unmap(context, t); - context->transfer_destroy(context, t); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct tr_list *ptr; - struct trace_context *tr_ctx = NULL; - rbug_context_t *ctxs; - int i = 0; - - pipe_mutex_lock(tr_scr->list_mutex); - ctxs = MALLOC(tr_scr->num_contexts * sizeof(rbug_context_t)); - foreach(ptr, &tr_scr->contexts) { - tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); - ctxs[i++] = VOID2U64(tr_ctx); - } - pipe_mutex_unlock(tr_scr->list_mutex); - - rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL); - FREE(ctxs); - - return 0; -} - -static int -trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_info *info = (struct rbug_proto_context_info *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - rbug_texture_t cbufs[PIPE_MAX_COLOR_BUFS]; - rbug_texture_t texs[PIPE_MAX_SAMPLERS]; - int i; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - pipe_mutex_lock(tr_ctx->draw_mutex); - trace_dump_call_lock(); - - for (i = 0; i < tr_ctx->curr.nr_cbufs; i++) - cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]); - - for (i = 0; i < tr_ctx->curr.num_sampler_views; i++) - texs[i] = VOID2U64(tr_ctx->curr.sampler_views[i]); - - rbug_send_context_info_reply(tr_rbug->con, serial, - VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs), - texs, tr_ctx->curr.num_sampler_views, - cbufs, tr_ctx->curr.nr_cbufs, - VOID2U64(tr_ctx->curr.zsbuf), - tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL); - - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_ctx->draw_mutex); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_block(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_block *block = (struct rbug_proto_context_draw_block *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, block->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - tr_ctx->draw_blocker |= block->block; - pipe_mutex_unlock(tr_ctx->draw_mutex); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_step(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_step *step = (struct rbug_proto_context_draw_step *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, step->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - if (tr_ctx->draw_blocked & RBUG_BLOCK_RULE) { - if (step->step & RBUG_BLOCK_RULE) - tr_ctx->draw_blocked &= ~RBUG_BLOCK_MASK; - } else { - tr_ctx->draw_blocked &= ~step->step; - } - pipe_mutex_unlock(tr_ctx->draw_mutex); - -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_broadcast(tr_ctx->draw_cond); -#endif - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_unblock(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_unblock *unblock = (struct rbug_proto_context_draw_unblock *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, unblock->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - if (tr_ctx->draw_blocked & RBUG_BLOCK_RULE) { - if (unblock->unblock & RBUG_BLOCK_RULE) - tr_ctx->draw_blocked &= ~RBUG_BLOCK_MASK; - } else { - tr_ctx->draw_blocked &= ~unblock->unblock; - } - tr_ctx->draw_blocker &= ~unblock->unblock; - pipe_mutex_unlock(tr_ctx->draw_mutex); - -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_broadcast(tr_ctx->draw_cond); -#endif - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_rule(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_rule *rule = (struct rbug_proto_context_draw_rule *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, rule->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - tr_ctx->draw_rule.vs = U642VOID(rule->vertex); - tr_ctx->draw_rule.fs = U642VOID(rule->fragment); - tr_ctx->draw_rule.sampler_view = U642VOID(rule->texture); - tr_ctx->draw_rule.surf = U642VOID(rule->surface); - tr_ctx->draw_rule.blocker = rule->block; - tr_ctx->draw_blocker |= RBUG_BLOCK_RULE; - pipe_mutex_unlock(tr_ctx->draw_mutex); - -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_broadcast(tr_ctx->draw_cond); -#endif - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_flush(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_flush *flush = (struct rbug_proto_context_flush *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, flush->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - trace_dump_call_lock(); - - tr_ctx->pipe->flush(tr_ctx->pipe, flush->flags, NULL); - - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_shader_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - struct tr_list *ptr; - rbug_shader_t *shdrs; - int i = 0; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, list->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - shdrs = MALLOC(tr_ctx->num_shaders * sizeof(rbug_shader_t)); - foreach(ptr, &tr_ctx->shaders) { - tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); - shdrs[i++] = VOID2U64(tr_shdr); - } - - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL); - FREE(shdrs); - - return 0; -} - -static int -trace_rbug_shader_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - unsigned original_len; - unsigned replaced_len; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - - tr_shdr = trace_rbug_get_shader_locked(tr_ctx, info->shader); - - if (!tr_shdr) { - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* just in case */ - assert(sizeof(struct tgsi_token) == 4); - - original_len = tgsi_num_tokens(tr_shdr->tokens); - if (tr_shdr->replaced_tokens) - replaced_len = tgsi_num_tokens(tr_shdr->replaced_tokens); - else - replaced_len = 0; - - rbug_send_shader_info_reply(tr_rbug->con, serial, - (uint32_t*)tr_shdr->tokens, original_len, - (uint32_t*)tr_shdr->replaced_tokens, replaced_len, - tr_shdr->disabled, - NULL); - - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_shader_disable(struct trace_rbug *tr_rbug, struct rbug_header *header) -{ - struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, dis->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - - tr_shdr = trace_rbug_get_shader_locked(tr_ctx, dis->shader); - - if (!tr_shdr) { - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - tr_shdr->disabled = dis->disable; - - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_shader_replace(struct trace_rbug *tr_rbug, struct rbug_header *header) -{ - struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - struct pipe_context *pipe = NULL; - void *state; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, rep->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - - tr_shdr = trace_rbug_get_shader_locked(tr_ctx, rep->shader); - - if (!tr_shdr) { - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - trace_dump_call_lock(); - - pipe = tr_ctx->pipe; - - /* remove old replaced shader */ - if (tr_shdr->replaced) { - if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) - trace_shader_bind_locked(pipe, tr_shdr, tr_shdr->state); - - FREE(tr_shdr->replaced_tokens); - trace_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced); - tr_shdr->replaced = NULL; - tr_shdr->replaced_tokens = NULL; - } - - /* empty inputs means restore old which we did above */ - if (rep->tokens_len == 0) - goto out; - - tr_shdr->replaced_tokens = tgsi_dup_tokens((struct tgsi_token *)rep->tokens); - if (!tr_shdr->replaced_tokens) - goto err; - - state = trace_shader_create_locked(pipe, tr_shdr, tr_shdr->replaced_tokens); - if (!state) - goto err; - - /* bind new shader if the shader is currently a bound */ - if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) - trace_shader_bind_locked(pipe, tr_shdr, state); - - /* save state */ - tr_shdr->replaced = state; - -out: - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; - -err: - FREE(tr_shdr->replaced_tokens); - tr_shdr->replaced = NULL; - tr_shdr->replaced_tokens = NULL; - - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -EINVAL; -} - -static boolean -trace_rbug_header(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - int ret = 0; - - switch(header->opcode) { - case RBUG_OP_PING: - rbug_send_ping_reply(tr_rbug->con, serial, NULL); - break; - case RBUG_OP_TEXTURE_LIST: - ret = trace_rbug_texture_list(tr_rbug, header, serial); - break; - case RBUG_OP_TEXTURE_INFO: - ret = trace_rbug_texture_info(tr_rbug, header, serial); - break; - case RBUG_OP_TEXTURE_READ: - ret = trace_rbug_texture_read(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_LIST: - ret = trace_rbug_context_list(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_INFO: - ret = trace_rbug_context_info(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_BLOCK: - ret = trace_rbug_context_draw_block(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_STEP: - ret = trace_rbug_context_draw_step(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_UNBLOCK: - ret = trace_rbug_context_draw_unblock(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_RULE: - ret = trace_rbug_context_draw_rule(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_FLUSH: - ret = trace_rbug_context_flush(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_LIST: - ret = trace_rbug_shader_list(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_INFO: - ret = trace_rbug_shader_info(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_DISABLE: - ret = trace_rbug_shader_disable(tr_rbug, header); - break; - case RBUG_OP_SHADER_REPLACE: - ret = trace_rbug_shader_replace(tr_rbug, header); - break; - default: - debug_printf("%s - unsupported opcode %u\n", __FUNCTION__, header->opcode); - ret = -ENOSYS; - break; - } - rbug_free_header(header); - - if (ret) - rbug_send_error_reply(tr_rbug->con, serial, ret, NULL); - - return TRUE; -} - -static void -trace_rbug_con(struct trace_rbug *tr_rbug) -{ - struct rbug_header *header; - uint32_t serial; - - debug_printf("%s - connection received\n", __FUNCTION__); - - while(tr_rbug->running) { - header = rbug_get_message(tr_rbug->con, &serial); - if (!header) - break; - - if (!trace_rbug_header(tr_rbug, header, serial)) - break; - } - - debug_printf("%s - connection closed\n", __FUNCTION__); - - rbug_disconnect(tr_rbug->con); - tr_rbug->con = NULL; -} - -PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug) -{ - struct trace_rbug *tr_rbug = void_tr_rbug; - uint16_t port = 13370; - int s = -1; - int c; - - u_socket_init(); - - for (;port <= 13379 && s < 0; port++) - s = u_socket_listen_on_port(port); - - if (s < 0) { - debug_printf("trace_rbug - failed to listen\n"); - return NULL; - } - - u_socket_block(s, false); - - debug_printf("trace_rbug - remote debugging listening on port %u\n", --port); - - while(tr_rbug->running) { - os_time_sleep(1); - - c = u_socket_accept(s); - if (c < 0) - continue; - - u_socket_block(c, true); - tr_rbug->con = rbug_from_socket(c); - - trace_rbug_con(tr_rbug); - - u_socket_close(c); - } - - u_socket_close(s); - - u_socket_stop(); - - return NULL; -} - -/********************************************************** - * - */ - -struct trace_rbug * -trace_rbug_start(struct trace_screen *tr_scr) -{ - struct trace_rbug *tr_rbug = CALLOC_STRUCT(trace_rbug); - if (!tr_rbug) - return NULL; - - tr_rbug->tr_scr = tr_scr; - tr_rbug->running = TRUE; - tr_rbug->thread = pipe_thread_create(trace_rbug_thread, tr_rbug); - - return tr_rbug; -} - -void -trace_rbug_stop(struct trace_rbug *tr_rbug) -{ - if (!tr_rbug) - return; - - tr_rbug->running = false; - pipe_thread_wait(tr_rbug->thread); - - FREE(tr_rbug); - - return; -} - -void -trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx) -{ - struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); - struct trace_rbug *tr_rbug = tr_scr->rbug; - - if (tr_rbug && tr_rbug->con) - rbug_send_context_draw_blocked(tr_rbug->con, - VOID2U64(tr_ctx), tr_ctx->draw_blocked, NULL); -} diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 63a45d7e512..935831071e6 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -40,7 +40,6 @@ static boolean trace = FALSE; -static boolean rbug = FALSE; static const char * trace_screen_get_name(struct pipe_screen *_screen) @@ -86,7 +85,7 @@ trace_screen_get_vendor(struct pipe_screen *_screen) static int trace_screen_get_param(struct pipe_screen *_screen, - int param) + enum pipe_cap param) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; @@ -107,9 +106,33 @@ trace_screen_get_param(struct pipe_screen *_screen, } +static int +trace_screen_get_shader_param(struct pipe_screen *_screen, unsigned shader, + enum pipe_shader_cap param) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + int result; + + trace_dump_call_begin("pipe_screen", "get_shader_param"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(int, shader); + trace_dump_arg(int, param); + + result = screen->get_shader_param(screen, shader, param); + + trace_dump_ret(int, result); + + trace_dump_call_end(); + + return result; +} + + static float trace_screen_get_paramf(struct pipe_screen *_screen, - int param) + enum pipe_cap param) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; @@ -134,6 +157,7 @@ static boolean trace_screen_is_format_supported(struct pipe_screen *_screen, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned tex_usage, unsigned geom_flags) { @@ -146,10 +170,12 @@ trace_screen_is_format_supported(struct pipe_screen *_screen, trace_dump_arg(ptr, screen); trace_dump_arg(format, format); trace_dump_arg(int, target); + trace_dump_arg(uint, sample_count); trace_dump_arg(uint, tex_usage); trace_dump_arg(uint, geom_flags); - result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags); + result = screen->is_format_supported(screen, format, target, sample_count, + tex_usage, geom_flags); trace_dump_ret(bool, result); @@ -491,9 +517,6 @@ trace_screen_destroy(struct pipe_screen *_screen) trace_dump_call_end(); trace_dump_trace_end(); - if (tr_scr->rbug) - trace_rbug_stop(tr_scr->rbug); - screen->destroy(screen); FREE(tr_scr); @@ -515,11 +538,6 @@ trace_enabled(void) trace = TRUE; } - if (debug_get_bool_option("GALLIUM_RBUG", FALSE)) { - trace = TRUE; - rbug = TRUE; - } - return trace; } @@ -548,18 +566,12 @@ trace_screen_create(struct pipe_screen *screen) #else winsys = screen->winsys; #endif - pipe_mutex_init(tr_scr->list_mutex); - make_empty_list(&tr_scr->buffers); - make_empty_list(&tr_scr->contexts); - make_empty_list(&tr_scr->textures); - make_empty_list(&tr_scr->surfaces); - make_empty_list(&tr_scr->transfers); - tr_scr->base.winsys = winsys; tr_scr->base.destroy = trace_screen_destroy; tr_scr->base.get_name = trace_screen_get_name; tr_scr->base.get_vendor = trace_screen_get_vendor; tr_scr->base.get_param = trace_screen_get_param; + tr_scr->base.get_shader_param = trace_screen_get_shader_param; tr_scr->base.get_paramf = trace_screen_get_paramf; tr_scr->base.is_format_supported = trace_screen_is_format_supported; assert(screen->context_create); @@ -577,20 +589,12 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer; tr_scr->screen = screen; - tr_scr->private_context = screen->context_create(screen, NULL); - if (tr_scr->private_context == NULL) - goto error3; trace_dump_ret(ptr, screen); trace_dump_call_end(); - if (rbug) - tr_scr->rbug = trace_rbug_start(tr_scr); - return &tr_scr->base; -error3: - FREE(tr_scr); error2: trace_dump_ret(ptr, screen); trace_dump_call_end(); diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 05ff9ef61f1..3598ceaa20f 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -56,67 +56,17 @@ struct trace_screen struct pipe_screen base; struct pipe_screen *screen; - struct pipe_context *private_context; - - /* remote debugger */ - struct trace_rbug *rbug; - - pipe_mutex list_mutex; - int num_buffers; - int num_contexts; - int num_textures; - int num_surfaces; - int num_transfers; - struct tr_list buffers; - struct tr_list contexts; - struct tr_list textures; - struct tr_list surfaces; - struct tr_list transfers; }; /* - * tr_rbug.c - */ - - -struct trace_rbug; - -struct trace_rbug * -trace_rbug_start(struct trace_screen *tr_scr); - -void -trace_rbug_stop(struct trace_rbug *tr_rbug); - - -/* * tr_screen.c */ -boolean -trace_enabled(void); - struct trace_screen * trace_screen(struct pipe_screen *screen); -#define trace_screen_add_to_list(tr_scr, name, obj) \ - do { \ - pipe_mutex_lock(tr_scr->list_mutex); \ - insert_at_head(&tr_scr->name, &obj->list); \ - tr_scr->num_##name++; \ - pipe_mutex_unlock(tr_scr->list_mutex); \ - } while (0) - -#define trace_screen_remove_from_list(tr_scr, name, obj) \ - do { \ - pipe_mutex_lock(tr_scr->list_mutex); \ - remove_from_list(&obj->list); \ - tr_scr->num_##name--; \ - pipe_mutex_unlock(tr_scr->list_mutex); \ - } while (0) - - #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c deleted file mode 100644 index d8c11640bf3..00000000000 --- a/src/gallium/drivers/trace/tr_state.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "tr_state.h" - -#include "util/u_memory.h" -#include "util/u_simple_list.h" - -#include "tgsi/tgsi_parse.h" - -struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, - const struct pipe_shader_state *state, - void *result, - enum trace_shader_type type) -{ - struct trace_shader *tr_shdr = CALLOC_STRUCT(trace_shader); - - tr_shdr->state = result; - tr_shdr->type = type; - tr_shdr->tokens = tgsi_dup_tokens(state->tokens); - - /* works on context as well */ - trace_screen_add_to_list(tr_ctx, shaders, tr_shdr); - - return tr_shdr; -} - -void trace_shader_destroy(struct trace_context *tr_ctx, - struct trace_shader *tr_shdr) -{ - trace_screen_remove_from_list(tr_ctx, shaders, tr_shdr); - - if (tr_shdr->replaced) { - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) - tr_ctx->pipe->delete_fs_state(tr_ctx->pipe, tr_shdr->replaced); - else if (tr_shdr->type == TRACE_SHADER_VERTEX) - tr_ctx->pipe->delete_vs_state(tr_ctx->pipe, tr_shdr->replaced); - else - assert(0); - } - - FREE(tr_shdr->replaced_tokens); - FREE(tr_shdr->tokens); - FREE(tr_shdr); -} diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h deleted file mode 100644 index e2f981d0513..00000000000 --- a/src/gallium/drivers/trace/tr_state.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef TR_STATE_H_ -#define TR_STATE_H_ - -#include "tr_context.h" - -struct tgsi_token; - -enum trace_shader_type { - TRACE_SHADER_FRAGMENT = 0, - TRACE_SHADER_VERTEX = 1, - TRACE_SHADER_GEOMETRY = 2 -}; - -struct trace_shader -{ - struct tr_list list; - - enum trace_shader_type type; - - void *state; - void *replaced; - - struct tgsi_token *tokens; - struct tgsi_token *replaced_tokens; - - boolean disabled; -}; - - -static INLINE struct trace_shader * -trace_shader(void *state) -{ - return (struct trace_shader *)state; -} - -struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, - const struct pipe_shader_state *state, - void *result, - enum trace_shader_type type); - -void trace_shader_destroy(struct trace_context *tr_ctx, - struct trace_shader *tr_shdr); - -#endif diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c index 1132dc92724..9914b98b39c 100644 --- a/src/gallium/drivers/trace/tr_texture.c +++ b/src/gallium/drivers/trace/tr_texture.c @@ -56,8 +56,6 @@ trace_resource_create(struct trace_screen *tr_scr, tr_tex->base.screen = &tr_scr->base; tr_tex->resource = texture; - trace_screen_add_to_list(tr_scr, textures, tr_tex); - return &tr_tex->base; error: @@ -70,8 +68,6 @@ void trace_resource_destroy(struct trace_screen *tr_scr, struct trace_resource *tr_tex) { - trace_screen_remove_from_list(tr_scr, textures, tr_tex); - pipe_resource_reference(&tr_tex->resource, NULL); FREE(tr_tex); } @@ -81,7 +77,6 @@ struct pipe_surface * trace_surface_create(struct trace_resource *tr_tex, struct pipe_surface *surface) { - struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen); struct trace_surface *tr_surf; if(!surface) @@ -100,8 +95,6 @@ trace_surface_create(struct trace_resource *tr_tex, pipe_resource_reference(&tr_surf->base.texture, &tr_tex->base); tr_surf->surface = surface; - trace_screen_add_to_list(tr_scr, surfaces, tr_surf); - return &tr_surf->base; error: @@ -113,10 +106,6 @@ error: void trace_surface_destroy(struct trace_surface *tr_surf) { - struct trace_screen *tr_scr = trace_screen(tr_surf->base.texture->screen); - - trace_screen_remove_from_list(tr_scr, surfaces, tr_surf); - pipe_resource_reference(&tr_surf->base.texture, NULL); pipe_surface_reference(&tr_surf->surface, NULL); FREE(tr_surf); @@ -128,7 +117,6 @@ trace_transfer_create(struct trace_context *tr_ctx, struct trace_resource *tr_tex, struct pipe_transfer *transfer) { - struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen); struct trace_transfer *tr_trans; if(!transfer) @@ -148,8 +136,6 @@ trace_transfer_create(struct trace_context *tr_ctx, pipe_resource_reference(&tr_trans->base.resource, &tr_tex->base); assert(tr_trans->base.resource == &tr_tex->base); - trace_screen_add_to_list(tr_scr, transfers, tr_trans); - return &tr_trans->base; error: @@ -162,12 +148,9 @@ void trace_transfer_destroy(struct trace_context *tr_context, struct trace_transfer *tr_trans) { - struct trace_screen *tr_scr = trace_screen(tr_context->base.screen); struct pipe_context *context = tr_context->pipe; struct pipe_transfer *transfer = tr_trans->transfer; - trace_screen_remove_from_list(tr_scr, transfers, tr_trans); - pipe_resource_reference(&tr_trans->base.resource, NULL); context->transfer_destroy(context, transfer); FREE(tr_trans); |