diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2022-09-29 23:00:28 -0400 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-10-01 03:17:33 +0000 |
commit | 4b0f28d7067bb85a8077dd56d78d0ba41af95377 (patch) | |
tree | 890ff1bfd38fb4cbeefcef1d5477a1a255061838 | |
parent | 8cc766d8f7eac26b7c029a2fac1bdfdba4776c29 (diff) |
delete rbug
These seem abandoned and they make interfaces changes less easy.
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18705>
26 files changed, 0 insertions, 7041 deletions
diff --git a/src/gallium/auxiliary/driver_rbug/README b/src/gallium/auxiliary/driver_rbug/README deleted file mode 100644 index 6db94810fc7..00000000000 --- a/src/gallium/auxiliary/driver_rbug/README +++ /dev/null @@ -1,44 +0,0 @@ - RBUG PIPE DRIVER - - -= About = - -This directory contains a Gallium3D remote debugger pipe driver. -It provides remote debugging functionality. - - -= Usage = - -Do - - 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. Also for a gui see: - - http://cgit.freedesktop.org/mesa/rbug-gui - - -= Integrating = - -You can integrate the rbug pipe driver either inside the gallium frontend or the -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(...); - -The rbug screen is then created by doing - - rbug_screen = rbug_screen_create(real_screen); - -You can then simply use rbug_screen instead of real_screen. - -You can create as many contexts you wish from rbug_screen::context_create they -are automatically wrapped by rbug_screen. - - --- -Jose Fonseca <jfonseca@vmware.com> -Jakob Bornecrantz <jakob@vmware.com> diff --git a/src/gallium/auxiliary/driver_rbug/rbug_context.c b/src/gallium/auxiliary/driver_rbug/rbug_context.c deleted file mode 100644 index 46d78ad729e..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_context.c +++ /dev/null @@ -1,1374 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 "pipe/p_context.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" - -#include "rbug/rbug_context.h" - -#include "rbug_context.h" -#include "rbug_objects.h" - - -static void -rbug_destroy(struct pipe_context *_pipe) -{ - struct rbug_screen *rb_screen = rbug_screen(_pipe->screen); - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - rbug_screen_remove_from_list(rb_screen, contexts, rb_pipe); - - mtx_lock(&rb_pipe->call_mutex); - pipe->destroy(pipe); - rb_pipe->pipe = NULL; - mtx_unlock(&rb_pipe->call_mutex); - - FREE(rb_pipe); -} - -static void -rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag) -{ - - if (rb_pipe->draw_blocker & flag) { - rb_pipe->draw_blocked |= flag; - } else if ((rb_pipe->draw_rule.blocker & flag) && - (rb_pipe->draw_blocker & RBUG_BLOCK_RULE)) { - unsigned k; - bool block = false; - unsigned sh; - - debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__, - (void *) rb_pipe->draw_rule.shader[PIPE_SHADER_FRAGMENT], - (void *) rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT], - (void *) rb_pipe->draw_rule.shader[PIPE_SHADER_VERTEX], - (void *) rb_pipe->curr.shader[PIPE_SHADER_VERTEX], - (void *) rb_pipe->draw_rule.surf, 0, - (void *) rb_pipe->draw_rule.texture, 0); - for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { - if (rb_pipe->draw_rule.shader[sh] && - rb_pipe->draw_rule.shader[sh] == rb_pipe->curr.shader[sh]) - block = true; - } - - if (rb_pipe->draw_rule.surf && - rb_pipe->draw_rule.surf == rb_pipe->curr.zsbuf) - block = true; - if (rb_pipe->draw_rule.surf) - for (k = 0; k < rb_pipe->curr.nr_cbufs; k++) - if (rb_pipe->draw_rule.surf == rb_pipe->curr.cbufs[k]) - block = true; - if (rb_pipe->draw_rule.texture) { - for (sh = 0; sh < ARRAY_SIZE(rb_pipe->curr.num_views); sh++) { - for (k = 0; k < rb_pipe->curr.num_views[sh]; k++) { - if (rb_pipe->draw_rule.texture == rb_pipe->curr.texs[sh][k]) { - block = true; - sh = PIPE_SHADER_TYPES; /* to break out of both loops */ - break; - } - } - } - } - - if (block) - rb_pipe->draw_blocked |= (flag | RBUG_BLOCK_RULE); - } - - if (rb_pipe->draw_blocked) - rbug_notify_draw_blocked(rb_pipe); - - /* wait for rbug to clear the blocked flag */ - while (rb_pipe->draw_blocked & flag) { - rb_pipe->draw_blocked |= flag; - cnd_wait(&rb_pipe->draw_cond, &rb_pipe->draw_mutex); - } - -} - -static void -rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *_info, - unsigned _drawid_offset, - const struct pipe_draw_indirect_info *_indirect, - const struct pipe_draw_start_count_bias *draws, - unsigned num_draws) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_draw_info info; - - info = *_info; - if(_info->index_size && !_info->has_user_indices) - info.index.resource = rbug_resource_unwrap(_info->index.resource); - - mtx_lock(&rb_pipe->draw_mutex); - rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE); - - mtx_lock(&rb_pipe->call_mutex); - /* XXX loop over PIPE_SHADER_x here */ - if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) && - !(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) && - !(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled)) - pipe->draw_vbo(pipe, &info, _drawid_offset, _indirect, draws, num_draws); - mtx_unlock(&rb_pipe->call_mutex); - - rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER); - mtx_unlock(&rb_pipe->draw_mutex); -} - -static struct pipe_query * -rbug_create_query(struct pipe_context *_pipe, - unsigned query_type, - unsigned index) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_query *query; - - mtx_lock(&rb_pipe->call_mutex); - query = pipe->create_query(pipe, - query_type, - index); - mtx_unlock(&rb_pipe->call_mutex); - return query; -} - -static void -rbug_destroy_query(struct pipe_context *_pipe, - struct pipe_query *query) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->destroy_query(pipe, - query); - mtx_unlock(&rb_pipe->call_mutex); -} - -static bool -rbug_begin_query(struct pipe_context *_pipe, - struct pipe_query *query) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - bool ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->begin_query(pipe, query); - mtx_unlock(&rb_pipe->call_mutex); - return ret; -} - -static bool -rbug_end_query(struct pipe_context *_pipe, - struct pipe_query *query) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - bool ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->end_query(pipe, - query); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static bool -rbug_get_query_result(struct pipe_context *_pipe, - struct pipe_query *query, - bool wait, - union pipe_query_result *result) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - bool ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->get_query_result(pipe, - query, - wait, - result); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static void -rbug_set_active_query_state(struct pipe_context *_pipe, bool enable) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_active_query_state(pipe, enable); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_blend_state(struct pipe_context *_pipe, - const struct pipe_blend_state *blend) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->create_blend_state(pipe, - blend); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static void -rbug_bind_blend_state(struct pipe_context *_pipe, - void *blend) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->bind_blend_state(pipe, - blend); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_blend_state(struct pipe_context *_pipe, - void *blend) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->delete_blend_state(pipe, - blend); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_sampler_state(struct pipe_context *_pipe, - const struct pipe_sampler_state *sampler) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->create_sampler_state(pipe, - sampler); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static void -rbug_bind_sampler_states(struct pipe_context *_pipe, - enum pipe_shader_type shader, - unsigned start, unsigned count, - void **samplers) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->bind_sampler_states(pipe, shader, start, count, samplers); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_sampler_state(struct pipe_context *_pipe, - void *sampler) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->delete_sampler_state(pipe, - sampler); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_rasterizer_state(struct pipe_context *_pipe, - const struct pipe_rasterizer_state *rasterizer) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->create_rasterizer_state(pipe, - rasterizer); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static void -rbug_bind_rasterizer_state(struct pipe_context *_pipe, - void *rasterizer) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->bind_rasterizer_state(pipe, - rasterizer); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_rasterizer_state(struct pipe_context *_pipe, - void *rasterizer) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->delete_rasterizer_state(pipe, - rasterizer); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_depth_stencil_alpha_state(struct pipe_context *_pipe, - const struct pipe_depth_stencil_alpha_state *depth_stencil_alpha) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->create_depth_stencil_alpha_state(pipe, - depth_stencil_alpha); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static void -rbug_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, - void *depth_stencil_alpha) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->bind_depth_stencil_alpha_state(pipe, - depth_stencil_alpha); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_depth_stencil_alpha_state(struct pipe_context *_pipe, - void *depth_stencil_alpha) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->delete_depth_stencil_alpha_state(pipe, - depth_stencil_alpha); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_fs_state(struct pipe_context *_pipe, - const struct pipe_shader_state *state) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *result; - - mtx_lock(&rb_pipe->call_mutex); - result = pipe->create_fs_state(pipe, state); - mtx_unlock(&rb_pipe->call_mutex); - - if (!result) - return NULL; - - return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_FRAGMENT); -} - -static void -rbug_bind_fs_state(struct pipe_context *_pipe, - void *_fs) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *fs; - - mtx_lock(&rb_pipe->call_mutex); - - fs = rbug_shader_unwrap(_fs); - rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] = rbug_shader(_fs); - pipe->bind_fs_state(pipe, - fs); - - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_fs_state(struct pipe_context *_pipe, - void *_fs) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_shader *rb_shader = rbug_shader(_fs); - - mtx_lock(&rb_pipe->call_mutex); - rbug_shader_destroy(rb_pipe, rb_shader); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_vs_state(struct pipe_context *_pipe, - const struct pipe_shader_state *state) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *result; - - mtx_lock(&rb_pipe->call_mutex); - result = pipe->create_vs_state(pipe, state); - mtx_unlock(&rb_pipe->call_mutex); - - if (!result) - return NULL; - - return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_VERTEX); -} - -static void -rbug_bind_vs_state(struct pipe_context *_pipe, - void *_vs) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *vs; - - mtx_lock(&rb_pipe->call_mutex); - - vs = rbug_shader_unwrap(_vs); - rb_pipe->curr.shader[PIPE_SHADER_VERTEX] = rbug_shader(_vs); - pipe->bind_vs_state(pipe, - vs); - - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_vs_state(struct pipe_context *_pipe, - void *_vs) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_shader *rb_shader = rbug_shader(_vs); - - mtx_lock(&rb_pipe->call_mutex); - rbug_shader_destroy(rb_pipe, rb_shader); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_gs_state(struct pipe_context *_pipe, - const struct pipe_shader_state *state) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *result; - - mtx_lock(&rb_pipe->call_mutex); - result = pipe->create_gs_state(pipe, state); - mtx_unlock(&rb_pipe->call_mutex); - - if (!result) - return NULL; - - return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_GEOM); -} - -static void -rbug_bind_gs_state(struct pipe_context *_pipe, - void *_gs) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *gs; - - mtx_lock(&rb_pipe->call_mutex); - - gs = rbug_shader_unwrap(_gs); - rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] = rbug_shader(_gs); - pipe->bind_gs_state(pipe, - gs); - - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_gs_state(struct pipe_context *_pipe, - void *_gs) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_shader *rb_shader = rbug_shader(_gs); - - mtx_lock(&rb_pipe->call_mutex); - rbug_shader_destroy(rb_pipe, rb_shader); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void * -rbug_create_vertex_elements_state(struct pipe_context *_pipe, - unsigned num_elements, - const struct pipe_vertex_element *vertex_elements) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - void *ret; - - mtx_lock(&rb_pipe->call_mutex); - ret = pipe->create_vertex_elements_state(pipe, - num_elements, - vertex_elements); - mtx_unlock(&rb_pipe->call_mutex); - - return ret; -} - -static void -rbug_bind_vertex_elements_state(struct pipe_context *_pipe, - void *velems) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->bind_vertex_elements_state(pipe, - velems); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_delete_vertex_elements_state(struct pipe_context *_pipe, - void *velems) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->delete_vertex_elements_state(pipe, - velems); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_blend_color(struct pipe_context *_pipe, - const struct pipe_blend_color *blend_color) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_blend_color(pipe, - blend_color); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_stencil_ref(struct pipe_context *_pipe, - const struct pipe_stencil_ref stencil_ref) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_stencil_ref(pipe, - stencil_ref); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_clip_state(struct pipe_context *_pipe, - const struct pipe_clip_state *clip) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_clip_state(pipe, - clip); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_constant_buffer(struct pipe_context *_pipe, - enum pipe_shader_type shader, - uint index, bool take_ownership, - const struct pipe_constant_buffer *_cb) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_constant_buffer cb; - - /* XXX hmm? unwrap the input state */ - if (_cb) { - cb = *_cb; - cb.buffer = rbug_resource_unwrap(_cb->buffer); - } - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_constant_buffer(pipe, - shader, - index, take_ownership, - _cb ? &cb : NULL); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_framebuffer_state(struct pipe_context *_pipe, - const struct pipe_framebuffer_state *_state) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_framebuffer_state unwrapped_state; - struct pipe_framebuffer_state *state = NULL; - unsigned i; - - /* must protect curr status */ - mtx_lock(&rb_pipe->call_mutex); - - rb_pipe->curr.nr_cbufs = 0; - memset(rb_pipe->curr.cbufs, 0, sizeof(rb_pipe->curr.cbufs)); - rb_pipe->curr.zsbuf = NULL; - - /* unwrap the input state */ - if (_state) { - memcpy(&unwrapped_state, _state, sizeof(unwrapped_state)); - - rb_pipe->curr.nr_cbufs = _state->nr_cbufs; - for(i = 0; i < _state->nr_cbufs; i++) { - unwrapped_state.cbufs[i] = rbug_surface_unwrap(_state->cbufs[i]); - if (_state->cbufs[i]) - rb_pipe->curr.cbufs[i] = rbug_resource(_state->cbufs[i]->texture); - } - unwrapped_state.zsbuf = rbug_surface_unwrap(_state->zsbuf); - if (_state->zsbuf) - rb_pipe->curr.zsbuf = rbug_resource(_state->zsbuf->texture); - state = &unwrapped_state; - } - - pipe->set_framebuffer_state(pipe, - state); - - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_polygon_stipple(struct pipe_context *_pipe, - const struct pipe_poly_stipple *poly_stipple) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_polygon_stipple(pipe, - poly_stipple); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_scissor_states(struct pipe_context *_pipe, - unsigned start_slot, - unsigned num_scissors, - const struct pipe_scissor_state *scissor) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_scissor_states(pipe, start_slot, num_scissors, scissor); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_viewport_states(struct pipe_context *_pipe, - unsigned start_slot, - unsigned num_viewports, - const struct pipe_viewport_state *viewport) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_viewport_states(pipe, start_slot, num_viewports, viewport); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_sampler_views(struct pipe_context *_pipe, - enum pipe_shader_type shader, - unsigned start, - unsigned num, - unsigned unbind_num_trailing_slots, - bool take_ownership, - struct pipe_sampler_view **_views) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - struct pipe_sampler_view **views = NULL; - unsigned i; - - assert(start == 0); /* XXX fix */ - - /* must protect curr status */ - mtx_lock(&rb_pipe->call_mutex); - - rb_pipe->curr.num_views[shader] = 0; - memset(rb_pipe->curr.views[shader], 0, sizeof(rb_pipe->curr.views[shader])); - memset(rb_pipe->curr.texs[shader], 0, sizeof(rb_pipe->curr.texs[shader])); - memset(unwrapped_views, 0, sizeof(unwrapped_views)); - - if (_views) { - rb_pipe->curr.num_views[shader] = num; - for (i = 0; i < num; i++) { - rb_pipe->curr.views[shader][i] = rbug_sampler_view(_views[i]); - rb_pipe->curr.texs[shader][i] = rbug_resource(_views[i] ? _views[i]->texture : NULL); - unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]); - } - views = unwrapped_views; - } - - pipe->set_sampler_views(pipe, shader, start, num, - unbind_num_trailing_slots, take_ownership, views); - - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_vertex_buffers(struct pipe_context *_pipe, - unsigned start_slot, unsigned num_buffers, - unsigned unbind_num_trailing_slots, - bool take_ownership, - const struct pipe_vertex_buffer *_buffers) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_vertex_buffer unwrapped_buffers[PIPE_MAX_SHADER_INPUTS]; - struct pipe_vertex_buffer *buffers = NULL; - unsigned i; - - mtx_lock(&rb_pipe->call_mutex); - - if (num_buffers && _buffers) { - memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers)); - for (i = 0; i < num_buffers; i++) { - if (!_buffers[i].is_user_buffer) - unwrapped_buffers[i].buffer.resource = - rbug_resource_unwrap(_buffers[i].buffer.resource); - } - buffers = unwrapped_buffers; - } - - pipe->set_vertex_buffers(pipe, start_slot, - num_buffers, unbind_num_trailing_slots, - take_ownership, buffers); - - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_sample_mask(struct pipe_context *_pipe, - unsigned sample_mask) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_sample_mask(pipe, sample_mask); - mtx_unlock(&rb_pipe->call_mutex); -} - -static struct pipe_stream_output_target * -rbug_create_stream_output_target(struct pipe_context *_pipe, - struct pipe_resource *_res, - unsigned buffer_offset, unsigned buffer_size) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_resource *res = rbug_resource_unwrap(_res); - struct pipe_stream_output_target *target; - - mtx_lock(&rb_pipe->call_mutex); - target = pipe->create_stream_output_target(pipe, res, buffer_offset, - buffer_size); - mtx_unlock(&rb_pipe->call_mutex); - return target; -} - -static void -rbug_stream_output_target_destroy(struct pipe_context *_pipe, - struct pipe_stream_output_target *target) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->stream_output_target_destroy(pipe, target); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_set_stream_output_targets(struct pipe_context *_pipe, - unsigned num_targets, - struct pipe_stream_output_target **targets, - const unsigned *offsets) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->set_stream_output_targets(pipe, num_targets, targets, offsets); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_resource_copy_region(struct pipe_context *_pipe, - struct pipe_resource *_dst, - unsigned dst_level, - unsigned dstx, - unsigned dsty, - unsigned dstz, - struct pipe_resource *_src, - unsigned src_level, - const struct pipe_box *src_box) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource_dst = rbug_resource(_dst); - struct rbug_resource *rb_resource_src = rbug_resource(_src); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_resource *dst = rb_resource_dst->resource; - struct pipe_resource *src = rb_resource_src->resource; - - mtx_lock(&rb_pipe->call_mutex); - pipe->resource_copy_region(pipe, - dst, - dst_level, - dstx, - dsty, - dstz, - src, - src_level, - src_box); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_blit(struct pipe_context *_pipe, const struct pipe_blit_info *_blit_info) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource_dst = rbug_resource(_blit_info->dst.resource); - struct rbug_resource *rb_resource_src = rbug_resource(_blit_info->src.resource); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_resource *dst = rb_resource_dst->resource; - struct pipe_resource *src = rb_resource_src->resource; - struct pipe_blit_info blit_info; - - blit_info = *_blit_info; - blit_info.dst.resource = dst; - blit_info.src.resource = src; - - mtx_lock(&rb_pipe->call_mutex); - pipe->blit(pipe, &blit_info); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_flush_resource(struct pipe_context *_pipe, - struct pipe_resource *_res) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource_res = rbug_resource(_res); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_resource *res = rb_resource_res->resource; - - mtx_lock(&rb_pipe->call_mutex); - pipe->flush_resource(pipe, res); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_clear(struct pipe_context *_pipe, - unsigned buffers, - const struct pipe_scissor_state *scissor_state, - const union pipe_color_union *color, - double depth, - unsigned stencil) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->clear(pipe, - buffers, - scissor_state, - color, - depth, - stencil); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_clear_render_target(struct pipe_context *_pipe, - struct pipe_surface *_dst, - const union pipe_color_union *color, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - bool render_condition_enabled) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_surface *rb_surface_dst = rbug_surface(_dst); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_surface *dst = rb_surface_dst->surface; - - mtx_lock(&rb_pipe->call_mutex); - pipe->clear_render_target(pipe, - dst, - color, - dstx, - dsty, - width, - height, - render_condition_enabled); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_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, - bool render_condition_enabled) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_surface *rb_surface_dst = rbug_surface(_dst); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_surface *dst = rb_surface_dst->surface; - - mtx_lock(&rb_pipe->call_mutex); - pipe->clear_depth_stencil(pipe, - dst, - clear_flags, - depth, - stencil, - dstx, - dsty, - width, - height, - render_condition_enabled); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_flush(struct pipe_context *_pipe, - struct pipe_fence_handle **fence, - unsigned flags) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->flush(pipe, fence, flags); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_create_fence_fd(struct pipe_context *_pipe, - struct pipe_fence_handle **fence, int fd, - enum pipe_fd_type type) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->create_fence_fd(pipe, fence, fd, type); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_fence_server_sync(struct pipe_context *_pipe, - struct pipe_fence_handle *fence) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct pipe_context *pipe = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - pipe->fence_server_sync(pipe, fence); - mtx_unlock(&rb_pipe->call_mutex); -} - -static struct pipe_sampler_view * -rbug_context_create_sampler_view(struct pipe_context *_pipe, - struct pipe_resource *_resource, - const struct pipe_sampler_view *templ) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_resource *resource = rb_resource->resource; - struct pipe_sampler_view *result; - - mtx_lock(&rb_pipe->call_mutex); - result = pipe->create_sampler_view(pipe, - resource, - templ); - mtx_unlock(&rb_pipe->call_mutex); - - if (result) - return rbug_sampler_view_create(rb_pipe, rb_resource, result); - return NULL; -} - -static void -rbug_context_sampler_view_destroy(struct pipe_context *_pipe, - struct pipe_sampler_view *_view) -{ - rbug_sampler_view_destroy(rbug_context(_pipe), - rbug_sampler_view(_view)); -} - -static struct pipe_surface * -rbug_context_create_surface(struct pipe_context *_pipe, - struct pipe_resource *_resource, - const struct pipe_surface *surf_tmpl) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_context *pipe = rb_pipe->pipe; - struct pipe_resource *resource = rb_resource->resource; - struct pipe_surface *result; - - mtx_lock(&rb_pipe->call_mutex); - result = pipe->create_surface(pipe, - resource, - surf_tmpl); - mtx_unlock(&rb_pipe->call_mutex); - - if (result) - return rbug_surface_create(rb_pipe, rb_resource, result); - return NULL; -} - -static void -rbug_context_surface_destroy(struct pipe_context *_pipe, - struct pipe_surface *_surface) -{ - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_surface *rb_surface = rbug_surface(_surface); - - mtx_lock(&rb_pipe->call_mutex); - rbug_surface_destroy(rb_pipe, - rb_surface); - mtx_unlock(&rb_pipe->call_mutex); -} - - - -static void * -rbug_context_buffer_map(struct pipe_context *_context, - struct pipe_resource *_resource, - unsigned level, - unsigned usage, - const struct pipe_box *box, - struct pipe_transfer **transfer) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_resource *resource = rb_resource->resource; - struct pipe_transfer *result; - void *map; - - mtx_lock(&rb_pipe->call_mutex); - map = context->buffer_map(context, - resource, - level, - usage, - box, &result); - mtx_unlock(&rb_pipe->call_mutex); - - *transfer = rbug_transfer_create(rb_pipe, rb_resource, result); - return *transfer ? map : NULL; -} - -static void * -rbug_context_texture_map(struct pipe_context *_context, - struct pipe_resource *_resource, - unsigned level, - unsigned usage, - const struct pipe_box *box, - struct pipe_transfer **transfer) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_resource *resource = rb_resource->resource; - struct pipe_transfer *result; - void *map; - - mtx_lock(&rb_pipe->call_mutex); - map = context->texture_map(context, - resource, - level, - usage, - box, &result); - mtx_unlock(&rb_pipe->call_mutex); - - *transfer = rbug_transfer_create(rb_pipe, rb_resource, result); - return *transfer ? map : NULL; -} - -static void -rbug_context_transfer_flush_region(struct pipe_context *_context, - struct pipe_transfer *_transfer, - const struct pipe_box *box) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_transfer *transfer = rb_transfer->transfer; - - mtx_lock(&rb_pipe->call_mutex); - context->transfer_flush_region(context, - transfer, - box); - mtx_unlock(&rb_pipe->call_mutex); -} - - -static void -rbug_context_buffer_unmap(struct pipe_context *_context, - struct pipe_transfer *_transfer) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_transfer *transfer = rb_transfer->transfer; - - mtx_lock(&rb_pipe->call_mutex); - context->buffer_unmap(context, - transfer); - rbug_transfer_destroy(rb_pipe, - rb_transfer); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_context_texture_unmap(struct pipe_context *_context, - struct pipe_transfer *_transfer) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_transfer *transfer = rb_transfer->transfer; - - mtx_lock(&rb_pipe->call_mutex); - context->texture_unmap(context, - transfer); - rbug_transfer_destroy(rb_pipe, - rb_transfer); - mtx_unlock(&rb_pipe->call_mutex); -} - - -static void -rbug_context_buffer_subdata(struct pipe_context *_context, - struct pipe_resource *_resource, - unsigned usage, unsigned offset, - unsigned size, const void *data) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_resource *resource = rb_resource->resource; - - mtx_lock(&rb_pipe->call_mutex); - context->buffer_subdata(context, resource, usage, offset, size, data); - mtx_unlock(&rb_pipe->call_mutex); -} - - -static void -rbug_context_texture_subdata(struct pipe_context *_context, - struct pipe_resource *_resource, - unsigned level, - unsigned usage, - const struct pipe_box *box, - const void *data, - unsigned stride, - unsigned layer_stride) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_context *context = rb_pipe->pipe; - struct pipe_resource *resource = rb_resource->resource; - - mtx_lock(&rb_pipe->call_mutex); - context->texture_subdata(context, - resource, - level, - usage, - box, - data, - stride, - layer_stride); - mtx_unlock(&rb_pipe->call_mutex); -} - -static void -rbug_context_texture_barrier(struct pipe_context *_context, unsigned flags) -{ - struct rbug_context *rb_pipe = rbug_context(_context); - struct pipe_context *context = rb_pipe->pipe; - - mtx_lock(&rb_pipe->call_mutex); - context->texture_barrier(context, - flags); - mtx_unlock(&rb_pipe->call_mutex); -} - -struct pipe_context * -rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) -{ - struct rbug_context *rb_pipe; - struct rbug_screen *rb_screen = rbug_screen(_screen); - - if (!rb_screen) - return NULL; - - rb_pipe = CALLOC_STRUCT(rbug_context); - if (!rb_pipe) - return NULL; - - (void) mtx_init(&rb_pipe->draw_mutex, mtx_plain); - cnd_init(&rb_pipe->draw_cond); - (void) mtx_init(&rb_pipe->call_mutex, mtx_plain); - (void) mtx_init(&rb_pipe->list_mutex, mtx_plain); - list_inithead(&rb_pipe->shaders); - - rb_pipe->base.screen = _screen; - rb_pipe->base.priv = pipe->priv; /* expose wrapped data */ - rb_pipe->base.draw = NULL; - rb_pipe->base.stream_uploader = pipe->stream_uploader; - rb_pipe->base.const_uploader = pipe->const_uploader; - - rb_pipe->base.destroy = rbug_destroy; - rb_pipe->base.draw_vbo = rbug_draw_vbo; - rb_pipe->base.create_query = rbug_create_query; - rb_pipe->base.destroy_query = rbug_destroy_query; - rb_pipe->base.begin_query = rbug_begin_query; - rb_pipe->base.end_query = rbug_end_query; - rb_pipe->base.get_query_result = rbug_get_query_result; - rb_pipe->base.set_active_query_state = rbug_set_active_query_state; - rb_pipe->base.create_blend_state = rbug_create_blend_state; - rb_pipe->base.bind_blend_state = rbug_bind_blend_state; - rb_pipe->base.delete_blend_state = rbug_delete_blend_state; - rb_pipe->base.create_sampler_state = rbug_create_sampler_state; - rb_pipe->base.bind_sampler_states = rbug_bind_sampler_states; - rb_pipe->base.delete_sampler_state = rbug_delete_sampler_state; - rb_pipe->base.create_rasterizer_state = rbug_create_rasterizer_state; - rb_pipe->base.bind_rasterizer_state = rbug_bind_rasterizer_state; - rb_pipe->base.delete_rasterizer_state = rbug_delete_rasterizer_state; - rb_pipe->base.create_depth_stencil_alpha_state = rbug_create_depth_stencil_alpha_state; - rb_pipe->base.bind_depth_stencil_alpha_state = rbug_bind_depth_stencil_alpha_state; - rb_pipe->base.delete_depth_stencil_alpha_state = rbug_delete_depth_stencil_alpha_state; - rb_pipe->base.create_fs_state = rbug_create_fs_state; - rb_pipe->base.bind_fs_state = rbug_bind_fs_state; - rb_pipe->base.delete_fs_state = rbug_delete_fs_state; - rb_pipe->base.create_vs_state = rbug_create_vs_state; - rb_pipe->base.bind_vs_state = rbug_bind_vs_state; - rb_pipe->base.delete_vs_state = rbug_delete_vs_state; - rb_pipe->base.create_gs_state = rbug_create_gs_state; - rb_pipe->base.bind_gs_state = rbug_bind_gs_state; - rb_pipe->base.delete_gs_state = rbug_delete_gs_state; - rb_pipe->base.create_vertex_elements_state = rbug_create_vertex_elements_state; - rb_pipe->base.bind_vertex_elements_state = rbug_bind_vertex_elements_state; - rb_pipe->base.delete_vertex_elements_state = rbug_delete_vertex_elements_state; - rb_pipe->base.set_blend_color = rbug_set_blend_color; - rb_pipe->base.set_stencil_ref = rbug_set_stencil_ref; - rb_pipe->base.set_clip_state = rbug_set_clip_state; - rb_pipe->base.set_constant_buffer = rbug_set_constant_buffer; - rb_pipe->base.set_framebuffer_state = rbug_set_framebuffer_state; - rb_pipe->base.set_polygon_stipple = rbug_set_polygon_stipple; - rb_pipe->base.set_scissor_states = rbug_set_scissor_states; - rb_pipe->base.set_viewport_states = rbug_set_viewport_states; - rb_pipe->base.set_sampler_views = rbug_set_sampler_views; - rb_pipe->base.set_vertex_buffers = rbug_set_vertex_buffers; - rb_pipe->base.set_sample_mask = rbug_set_sample_mask; - rb_pipe->base.create_stream_output_target = rbug_create_stream_output_target; - rb_pipe->base.stream_output_target_destroy = rbug_stream_output_target_destroy; - rb_pipe->base.set_stream_output_targets = rbug_set_stream_output_targets; - rb_pipe->base.resource_copy_region = rbug_resource_copy_region; - rb_pipe->base.blit = rbug_blit; - rb_pipe->base.clear = rbug_clear; - rb_pipe->base.clear_render_target = rbug_clear_render_target; - rb_pipe->base.clear_depth_stencil = rbug_clear_depth_stencil; - rb_pipe->base.flush = rbug_flush; - rb_pipe->base.create_fence_fd = rbug_create_fence_fd; - rb_pipe->base.fence_server_sync = rbug_fence_server_sync; - rb_pipe->base.create_sampler_view = rbug_context_create_sampler_view; - rb_pipe->base.sampler_view_destroy = rbug_context_sampler_view_destroy; - rb_pipe->base.create_surface = rbug_context_create_surface; - rb_pipe->base.surface_destroy = rbug_context_surface_destroy; - rb_pipe->base.buffer_map = rbug_context_buffer_map; - rb_pipe->base.buffer_unmap = rbug_context_buffer_unmap; - rb_pipe->base.texture_map = rbug_context_texture_map; - rb_pipe->base.texture_unmap = rbug_context_texture_unmap; - rb_pipe->base.transfer_flush_region = rbug_context_transfer_flush_region; - rb_pipe->base.buffer_subdata = rbug_context_buffer_subdata; - rb_pipe->base.texture_subdata = rbug_context_texture_subdata; - rb_pipe->base.texture_barrier = rbug_context_texture_barrier; - rb_pipe->base.flush_resource = rbug_flush_resource; - - rb_pipe->pipe = pipe; - - rbug_screen_add_to_list(rb_screen, contexts, rb_pipe); - - if (debug_get_bool_option("GALLIUM_RBUG_START_BLOCKED", false)) { - rb_pipe->draw_blocked = RBUG_BLOCK_BEFORE; - } - - return &rb_pipe->base; -} diff --git a/src/gallium/auxiliary/driver_rbug/rbug_context.h b/src/gallium/auxiliary/driver_rbug/rbug_context.h deleted file mode 100644 index 0ec556bd050..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_context.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 RBUG_CONTEXT_H -#define RBUG_CONTEXT_H - -#include "pipe/p_state.h" -#include "pipe/p_context.h" - -#include "rbug_screen.h" - - -struct rbug_context { - struct pipe_context base; /**< base class */ - - struct pipe_context *pipe; - - struct list_head list; - - /* call locking */ - mtx_t call_mutex; - - /* current state */ - struct { - struct rbug_shader *shader[PIPE_SHADER_TYPES]; - - struct rbug_sampler_view *views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS]; - struct rbug_resource *texs[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS]; - unsigned num_views[PIPE_SHADER_TYPES]; - - unsigned nr_cbufs; - struct rbug_resource *cbufs[PIPE_MAX_COLOR_BUFS]; - struct rbug_resource *zsbuf; - } curr; - - /* draw locking */ - mtx_t draw_mutex; - cnd_t draw_cond; - unsigned draw_num_rules; - int draw_blocker; - int draw_blocked; - - struct { - struct rbug_shader *shader[PIPE_SHADER_TYPES]; - - struct rbug_resource *texture; - struct rbug_resource *surf; - - int blocker; - } draw_rule; - - /* list of state objects */ - mtx_t list_mutex; - unsigned num_shaders; - struct list_head shaders; -}; - -static inline struct rbug_context * -rbug_context(struct pipe_context *pipe) -{ - return (struct rbug_context *)pipe; -} - - -/********************************************************** - * rbug_context.c - */ - -struct pipe_context * -rbug_context_create(struct pipe_screen *screen, struct pipe_context *pipe); - - -/********************************************************** - * rbug_core.c - */ - -void rbug_notify_draw_blocked(struct rbug_context *rb_context); - - -#endif /* RBUG_CONTEXT_H */ diff --git a/src/gallium/auxiliary/driver_rbug/rbug_core.c b/src/gallium/auxiliary/driver_rbug/rbug_core.c deleted file mode 100644 index a74d20a987b..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_core.c +++ /dev/null @@ -1,875 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 "os/os_thread.h" -#include "util/format/u_format.h" -#include "util/u_string.h" -#include "util/u_inlines.h" -#include "util/u_memory.h" -#include "util/u_network.h" -#include "util/os_time.h" - -#include "tgsi/tgsi_parse.h" - -#include "rbug_context.h" -#include "rbug_objects.h" - -#include "rbug/rbug.h" - -#include <errno.h> - -#define U642VOID(x) ((void *)(uintptr_t)(x)) -#define VOID2U64(x) ((uint64_t)(uintptr_t)(x)) - -struct rbug_rbug -{ - struct rbug_screen *rb_screen; - struct rbug_connection *con; - thrd_t thread; - bool running; -}; - -int -rbug_thread(void *void_rbug); - - -/********************************************************** - * Helper functions - */ - - -static struct rbug_context * -rbug_get_context_locked(struct rbug_screen *rb_screen, rbug_context_t ctx) -{ - struct rbug_context *rb_context; - - LIST_FOR_EACH_ENTRY(rb_context, &rb_screen->contexts, list) { - if (ctx == VOID2U64(rb_context)) - break; - rb_context = NULL; - } - - return rb_context; -} - -static struct rbug_shader * -rbug_get_shader_locked(struct rbug_context *rb_context, rbug_shader_t shdr) -{ - struct rbug_shader *tr_shdr; - - LIST_FOR_EACH_ENTRY(tr_shdr, &rb_context->shaders, list) { - if (shdr == VOID2U64(tr_shdr)) - break; - tr_shdr = NULL; - } - - return tr_shdr; -} - -static void * -rbug_shader_create_locked(struct pipe_context *pipe, - struct rbug_shader *rb_shader, - struct tgsi_token *tokens) -{ - void *state = NULL; - struct pipe_shader_state pss; - memset(&pss, 0, sizeof(pss)); - pss.tokens = tokens; - - switch(rb_shader->type) { - case RBUG_SHADER_FRAGMENT: - state = pipe->create_fs_state(pipe, &pss); - break; - case RBUG_SHADER_VERTEX: - state = pipe->create_vs_state(pipe, &pss); - break; - case RBUG_SHADER_GEOM: - state = pipe->create_gs_state(pipe, &pss); - break; - default: - assert(0); - break; - } - - return state; -} - -static void -rbug_shader_bind_locked(struct pipe_context *pipe, - struct rbug_shader *rb_shader, - void *state) -{ - switch(rb_shader->type) { - case RBUG_SHADER_FRAGMENT: - pipe->bind_fs_state(pipe, state); - break; - case RBUG_SHADER_VERTEX: - pipe->bind_vs_state(pipe, state); - break; - case RBUG_SHADER_GEOM: - pipe->bind_gs_state(pipe, state); - break; - default: - assert(0); - break; - } -} - -static void -rbug_shader_delete_locked(struct pipe_context *pipe, - struct rbug_shader *rb_shader, - void *state) -{ - switch(rb_shader->type) { - case RBUG_SHADER_FRAGMENT: - pipe->delete_fs_state(pipe, state); - break; - case RBUG_SHADER_VERTEX: - pipe->delete_vs_state(pipe, state); - break; - case RBUG_SHADER_GEOM: - pipe->delete_gs_state(pipe, state); - break; - default: - assert(0); - break; - } -} - -/************************************************ - * Request handler functions - */ - - -static int -rbug_texture_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_resource *tr_tex; - rbug_texture_t *texs; - int i = 0; - - mtx_lock(&rb_screen->list_mutex); - texs = MALLOC(rb_screen->num_resources * sizeof(rbug_texture_t)); - LIST_FOR_EACH_ENTRY(tr_tex, &rb_screen->resources, list) { - texs[i++] = VOID2U64(tr_tex); - } - mtx_unlock(&rb_screen->list_mutex); - - rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL); - FREE(texs); - - return 0; -} - -static int -rbug_texture_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_resource *tr_tex; - struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header; - struct pipe_resource *t; - uint16_t num_layers; - - mtx_lock(&rb_screen->list_mutex); - LIST_FOR_EACH_ENTRY(tr_tex, &rb_screen->resources, list) { - if (gpti->texture == VOID2U64(tr_tex)) - break; - tr_tex = NULL; - } - - if (!tr_tex) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - t = tr_tex->resource; - num_layers = util_num_layers(t, 0); - - rbug_send_texture_info_reply(tr_rbug->con, serial, - t->target, t->format, - &t->width0, 1, - &t->height0, 1, - &num_layers, 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); - - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_resource *tr_tex; - - struct pipe_context *context = rb_screen->private_context; - struct pipe_resource *tex; - struct pipe_transfer *t; - - void *map; - - mtx_lock(&rb_screen->list_mutex); - LIST_FOR_EACH_ENTRY(tr_tex, &rb_screen->resources, list) { - if (gptr->texture == VOID2U64(tr_tex)) - break; - tr_tex = NULL; - } - - if (!tr_tex) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - tex = tr_tex->resource; - map = pipe_texture_map(context, tex, - gptr->level, gptr->face + gptr->zslice, - PIPE_MAP_READ, - gptr->x, gptr->y, gptr->w, gptr->h, &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->texture_unmap(context, t); - - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_context_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context, *next; - rbug_context_t *ctxs; - int i = 0; - - mtx_lock(&rb_screen->list_mutex); - ctxs = MALLOC(rb_screen->num_contexts * sizeof(rbug_context_t)); - LIST_FOR_EACH_ENTRY_SAFE(rb_context, next, &rb_screen->contexts, list) { - ctxs[i++] = VOID2U64(rb_context); - } - mtx_unlock(&rb_screen->list_mutex); - - rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL); - FREE(ctxs); - - return 0; -} - -static int -rbug_context_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_info *info = (struct rbug_proto_context_info *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - rbug_texture_t cbufs[PIPE_MAX_COLOR_BUFS]; - rbug_texture_t texs[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - unsigned i; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, info->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - mtx_lock(&rb_context->draw_mutex); - mtx_lock(&rb_context->call_mutex); - - for (i = 0; i < rb_context->curr.nr_cbufs; i++) - cbufs[i] = VOID2U64(rb_context->curr.cbufs[i]); - - /* XXX what about vertex/geometry shader texture views? */ - for (i = 0; i < rb_context->curr.num_views[PIPE_SHADER_FRAGMENT]; i++) - texs[i] = VOID2U64(rb_context->curr.texs[PIPE_SHADER_FRAGMENT][i]); - - rbug_send_context_info_reply(tr_rbug->con, serial, - VOID2U64(rb_context->curr.shader[PIPE_SHADER_VERTEX]), VOID2U64(rb_context->curr.shader[PIPE_SHADER_FRAGMENT]), - texs, rb_context->curr.num_views[PIPE_SHADER_FRAGMENT], - cbufs, rb_context->curr.nr_cbufs, - VOID2U64(rb_context->curr.zsbuf), - rb_context->draw_blocker, rb_context->draw_blocked, NULL); - - mtx_unlock(&rb_context->call_mutex); - mtx_unlock(&rb_context->draw_mutex); - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_context_draw_block(struct rbug_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 rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, block->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->draw_mutex); - rb_context->draw_blocker |= block->block; - mtx_unlock(&rb_context->draw_mutex); - - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_context_draw_step(struct rbug_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 rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, step->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->draw_mutex); - if (rb_context->draw_blocked & RBUG_BLOCK_RULE) { - if (step->step & RBUG_BLOCK_RULE) - rb_context->draw_blocked &= ~RBUG_BLOCK_MASK; - } else { - rb_context->draw_blocked &= ~step->step; - } - mtx_unlock(&rb_context->draw_mutex); - - cnd_broadcast(&rb_context->draw_cond); - - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_context_draw_unblock(struct rbug_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 rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, unblock->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->draw_mutex); - if (rb_context->draw_blocked & RBUG_BLOCK_RULE) { - if (unblock->unblock & RBUG_BLOCK_RULE) - rb_context->draw_blocked &= ~RBUG_BLOCK_MASK; - } else { - rb_context->draw_blocked &= ~unblock->unblock; - } - rb_context->draw_blocker &= ~unblock->unblock; - mtx_unlock(&rb_context->draw_mutex); - - cnd_broadcast(&rb_context->draw_cond); - - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_context_draw_rule(struct rbug_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 rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, rule->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->draw_mutex); - rb_context->draw_rule.shader[PIPE_SHADER_VERTEX] = U642VOID(rule->vertex); - rb_context->draw_rule.shader[PIPE_SHADER_FRAGMENT] = U642VOID(rule->fragment); - rb_context->draw_rule.texture = U642VOID(rule->texture); - rb_context->draw_rule.surf = U642VOID(rule->surface); - rb_context->draw_rule.blocker = rule->block; - rb_context->draw_blocker |= RBUG_BLOCK_RULE; - mtx_unlock(&rb_context->draw_mutex); - - cnd_broadcast(&rb_context->draw_cond); - - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_context_flush(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_flush *flush = (struct rbug_proto_context_flush *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, flush->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - mtx_lock(&rb_context->call_mutex); - - rb_context->pipe->flush(rb_context->pipe, NULL, 0); - - mtx_unlock(&rb_context->call_mutex); - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_shader_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - struct rbug_shader *tr_shdr, *next; - rbug_shader_t *shdrs; - int i = 0; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, list->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->list_mutex); - shdrs = MALLOC(rb_context->num_shaders * sizeof(rbug_shader_t)); - LIST_FOR_EACH_ENTRY_SAFE(tr_shdr, next, &rb_context->shaders, list) { - shdrs[i++] = VOID2U64(tr_shdr); - } - - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - - rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL); - FREE(shdrs); - - return 0; -} - -static int -rbug_shader_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - struct rbug_shader *tr_shdr = NULL; - unsigned original_len; - unsigned replaced_len; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, info->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->list_mutex); - - tr_shdr = rbug_get_shader_locked(rb_context, info->shader); - - if (!tr_shdr) { - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - /* just in case */ - assert(sizeof(struct tgsi_token) == 4); - - if (tr_shdr->tokens) { - 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); - } - - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_shader_disable(struct rbug_rbug *tr_rbug, struct rbug_header *header) -{ - struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - struct rbug_shader *tr_shdr = NULL; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, dis->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->list_mutex); - - tr_shdr = rbug_get_shader_locked(rb_context, dis->shader); - - if (!tr_shdr) { - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - tr_shdr->disabled = dis->disable; - - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - - return 0; -} - -static int -rbug_shader_replace(struct rbug_rbug *tr_rbug, struct rbug_header *header) -{ - struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header; - - struct rbug_screen *rb_screen = tr_rbug->rb_screen; - struct rbug_context *rb_context = NULL; - struct rbug_shader *tr_shdr = NULL; - struct pipe_context *pipe = NULL; - void *state; - - mtx_lock(&rb_screen->list_mutex); - rb_context = rbug_get_context_locked(rb_screen, rep->context); - - if (!rb_context) { - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - mtx_lock(&rb_context->list_mutex); - - tr_shdr = rbug_get_shader_locked(rb_context, rep->shader); - - if (!tr_shdr) { - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - mtx_lock(&rb_context->call_mutex); - - pipe = rb_context->pipe; - - /* remove old replaced shader */ - if (tr_shdr->replaced_shader) { - /* if this shader is bound rebind the original shader */ - if (rb_context->curr.shader[PIPE_SHADER_FRAGMENT] == tr_shdr || rb_context->curr.shader[PIPE_SHADER_VERTEX] == tr_shdr) - rbug_shader_bind_locked(pipe, tr_shdr, tr_shdr->shader); - - FREE(tr_shdr->replaced_tokens); - rbug_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced_shader); - tr_shdr->replaced_shader = 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 = rbug_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 (rb_context->curr.shader[PIPE_SHADER_FRAGMENT] == tr_shdr || rb_context->curr.shader[PIPE_SHADER_VERTEX] == tr_shdr) - rbug_shader_bind_locked(pipe, tr_shdr, state); - - /* save state */ - tr_shdr->replaced_shader = state; - -out: - mtx_unlock(&rb_context->call_mutex); - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - - return 0; - -err: - FREE(tr_shdr->replaced_tokens); - tr_shdr->replaced_shader = NULL; - tr_shdr->replaced_tokens = NULL; - - mtx_unlock(&rb_context->call_mutex); - mtx_unlock(&rb_context->list_mutex); - mtx_unlock(&rb_screen->list_mutex); - return -EINVAL; -} - -static bool -rbug_header(struct rbug_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 = rbug_texture_list(tr_rbug, header, serial); - break; - case RBUG_OP_TEXTURE_INFO: - ret = rbug_texture_info(tr_rbug, header, serial); - break; - case RBUG_OP_TEXTURE_READ: - ret = rbug_texture_read(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_LIST: - ret = rbug_context_list(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_INFO: - ret = rbug_context_info(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_BLOCK: - ret = rbug_context_draw_block(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_STEP: - ret = rbug_context_draw_step(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_UNBLOCK: - ret = rbug_context_draw_unblock(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_RULE: - ret = rbug_context_draw_rule(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_FLUSH: - ret = rbug_context_flush(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_LIST: - ret = rbug_shader_list(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_INFO: - ret = rbug_shader_info(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_DISABLE: - ret = rbug_shader_disable(tr_rbug, header); - break; - case RBUG_OP_SHADER_REPLACE: - ret = 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 -rbug_con(struct rbug_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 (!rbug_header(tr_rbug, header, serial)) - break; - } - - debug_printf("%s - connection closed\n", __FUNCTION__); - - rbug_disconnect(tr_rbug->con); - tr_rbug->con = NULL; -} - -int -rbug_thread(void *void_tr_rbug) -{ - struct rbug_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("rbug_rbug - failed to listen\n"); - return 0; - } - - u_socket_block(s, false); - - debug_printf("rbug_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); - - rbug_con(tr_rbug); - - u_socket_close(c); - } - - u_socket_close(s); - - u_socket_stop(); - - return 0; -} - -/********************************************************** - * - */ - -struct rbug_rbug * -rbug_start(struct rbug_screen *rb_screen) -{ - struct rbug_rbug *tr_rbug = CALLOC_STRUCT(rbug_rbug); - if (!tr_rbug) - return NULL; - - tr_rbug->rb_screen = rb_screen; - tr_rbug->running = true; - if (thrd_success != u_thread_create(&tr_rbug->thread, rbug_thread, tr_rbug)) { - FREE(tr_rbug); - return NULL; - } - - return tr_rbug; -} - -void -rbug_stop(struct rbug_rbug *tr_rbug) -{ - if (!tr_rbug) - return; - - tr_rbug->running = false; - thrd_join(tr_rbug->thread, NULL); - - FREE(tr_rbug); - - return; -} - -void -rbug_notify_draw_blocked(struct rbug_context *rb_context) -{ - struct rbug_screen *rb_screen = rbug_screen(rb_context->base.screen); - struct rbug_rbug *tr_rbug = rb_screen->rbug; - - if (tr_rbug && tr_rbug->con) - rbug_send_context_draw_blocked(tr_rbug->con, - VOID2U64(rb_context), rb_context->draw_blocked, NULL); -} diff --git a/src/gallium/auxiliary/driver_rbug/rbug_objects.c b/src/gallium/auxiliary/driver_rbug/rbug_objects.c deleted file mode 100644 index 8d1bf86a8f9..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_objects.c +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 "util/u_inlines.h" -#include "util/u_memory.h" - -#include "tgsi/tgsi_parse.h" - -#include "rbug_screen.h" -#include "rbug_objects.h" -#include "rbug_context.h" - - - -struct pipe_resource * -rbug_resource_create(struct rbug_screen *rb_screen, - struct pipe_resource *resource) -{ - struct rbug_resource *rb_resource; - - if (!resource) - goto error; - - assert(resource->screen == rb_screen->screen); - - rb_resource = CALLOC_STRUCT(rbug_resource); - if (!rb_resource) - goto error; - - memcpy(&rb_resource->base, resource, sizeof(struct pipe_resource)); - - pipe_reference_init(&rb_resource->base.reference, 1); - rb_resource->base.screen = &rb_screen->base; - rb_resource->resource = resource; - - if (resource->target != PIPE_BUFFER) - rbug_screen_add_to_list(rb_screen, resources, rb_resource); - - return &rb_resource->base; - -error: - pipe_resource_reference(&resource, NULL); - return NULL; -} - -void -rbug_resource_destroy(struct rbug_resource *rb_resource) -{ - struct rbug_screen *rb_screen = rbug_screen(rb_resource->base.screen); - - if (rb_resource->base.target != PIPE_BUFFER) - rbug_screen_remove_from_list(rb_screen, resources, rb_resource); - - pipe_resource_reference(&rb_resource->resource, NULL); - FREE(rb_resource); -} - - -struct pipe_surface * -rbug_surface_create(struct rbug_context *rb_context, - struct rbug_resource *rb_resource, - struct pipe_surface *surface) -{ - struct rbug_surface *rb_surface; - - if (!surface) - goto error; - - assert(surface->texture == rb_resource->resource); - - rb_surface = CALLOC_STRUCT(rbug_surface); - if (!rb_surface) - goto error; - - memcpy(&rb_surface->base, surface, sizeof(struct pipe_surface)); - - pipe_reference_init(&rb_surface->base.reference, 1); - rb_surface->base.texture = NULL; - rb_surface->base.context = &rb_context->base; - rb_surface->surface = surface; /* we own the surface already */ - pipe_resource_reference(&rb_surface->base.texture, &rb_resource->base); - - return &rb_surface->base; - -error: - pipe_surface_reference(&surface, NULL); - return NULL; -} - -void -rbug_surface_destroy(struct rbug_context *rb_context, - struct rbug_surface *rb_surface) -{ - pipe_resource_reference(&rb_surface->base.texture, NULL); - pipe_surface_reference(&rb_surface->surface, NULL); - FREE(rb_surface); -} - - -struct pipe_sampler_view * -rbug_sampler_view_create(struct rbug_context *rb_context, - struct rbug_resource *rb_resource, - struct pipe_sampler_view *view) -{ - struct rbug_sampler_view *rb_view; - - if (!view) - goto error; - - assert(view->texture == rb_resource->resource); - - rb_view = MALLOC(sizeof(struct rbug_sampler_view)); - - rb_view->base = *view; - rb_view->base.reference.count = 1; - rb_view->base.texture = NULL; - pipe_resource_reference(&rb_view->base.texture, &rb_resource->base); - rb_view->base.context = &rb_context->base; - rb_view->sampler_view = view; - - return &rb_view->base; -error: - return NULL; -} - -void -rbug_sampler_view_destroy(struct rbug_context *rb_context, - struct rbug_sampler_view *rb_view) -{ - pipe_resource_reference(&rb_view->base.texture, NULL); - pipe_sampler_view_reference(&rb_view->sampler_view, NULL); - FREE(rb_view); -} - - -struct pipe_transfer * -rbug_transfer_create(struct rbug_context *rb_context, - struct rbug_resource *rb_resource, - struct pipe_transfer *transfer) -{ - struct rbug_transfer *rb_transfer; - - if (!transfer) - goto error; - - assert(transfer->resource == rb_resource->resource); - - rb_transfer = CALLOC_STRUCT(rbug_transfer); - if (!rb_transfer) - goto error; - - memcpy(&rb_transfer->base, transfer, sizeof(struct pipe_transfer)); - - rb_transfer->base.resource = NULL; - rb_transfer->transfer = transfer; - rb_transfer->pipe = rb_context->pipe; - - pipe_resource_reference(&rb_transfer->base.resource, &rb_resource->base); - assert(rb_transfer->base.resource == &rb_resource->base); - - return &rb_transfer->base; - -error: - if (rb_resource->base.target == PIPE_BUFFER) - rb_context->pipe->buffer_unmap(rb_context->pipe, transfer); - else - rb_context->pipe->texture_unmap(rb_context->pipe, transfer); - return NULL; -} - -void -rbug_transfer_destroy(struct rbug_context *rb_context, - struct rbug_transfer *rb_transfer) -{ - pipe_resource_reference(&rb_transfer->base.resource, NULL); - FREE(rb_transfer); -} - -void * -rbug_shader_create(struct rbug_context *rb_context, - const struct pipe_shader_state *state, - void *result, enum rbug_shader_type type) -{ - struct rbug_shader *rb_shader = CALLOC_STRUCT(rbug_shader); - - rb_shader->type = type; - rb_shader->shader = result; - if (state->tokens) - rb_shader->tokens = tgsi_dup_tokens(state->tokens); - - /* works on context as well since its just a macro */ - rbug_screen_add_to_list(rb_context, shaders, rb_shader); - - return rb_shader; -} - -void -rbug_shader_destroy(struct rbug_context *rb_context, - struct rbug_shader *rb_shader) -{ - struct pipe_context *pipe = rb_context->pipe; - - /* works on context as well since its just a macro */ - rbug_screen_remove_from_list(rb_context, shaders, rb_shader); - - switch(rb_shader->type) { - case RBUG_SHADER_FRAGMENT: - if (rb_shader->replaced_shader) - pipe->delete_fs_state(pipe, rb_shader->replaced_shader); - pipe->delete_fs_state(pipe, rb_shader->shader); - break; - case RBUG_SHADER_VERTEX: - if (rb_shader->replaced_shader) - pipe->delete_vs_state(pipe, rb_shader->replaced_shader); - pipe->delete_vs_state(pipe, rb_shader->shader); - break; - case RBUG_SHADER_GEOM: - if (rb_shader->replaced_shader) - pipe->delete_gs_state(pipe, rb_shader->replaced_shader); - pipe->delete_gs_state(pipe, rb_shader->shader); - break; - default: - assert(0); - } - - FREE(rb_shader->replaced_tokens); - FREE(rb_shader->tokens); - FREE(rb_shader); -} diff --git a/src/gallium/auxiliary/driver_rbug/rbug_objects.h b/src/gallium/auxiliary/driver_rbug/rbug_objects.h deleted file mode 100644 index 32375a0b6a0..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_objects.h +++ /dev/null @@ -1,228 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 RBUG_OBJECTS_H -#define RBUG_OBJECTS_H - - -#include "pipe/p_compiler.h" -#include "pipe/p_state.h" - -#include "rbug_screen.h" - -struct rbug_context; - - -struct rbug_resource -{ - struct pipe_resource base; - - struct pipe_resource *resource; - - struct list_head list; -}; - - -enum rbug_shader_type -{ - RBUG_SHADER_GEOM, - RBUG_SHADER_VERTEX, - RBUG_SHADER_FRAGMENT, -}; - -struct rbug_shader -{ - struct list_head list; - - void *shader; - void *tokens; - void *replaced_shader; - void *replaced_tokens; - - enum rbug_shader_type type; - bool disabled; -}; - - -struct rbug_sampler_view -{ - struct pipe_sampler_view base; - - struct pipe_sampler_view *sampler_view; -}; - - -struct rbug_surface -{ - struct pipe_surface base; - - struct pipe_surface *surface; -}; - - -struct rbug_transfer -{ - struct pipe_transfer base; - - struct pipe_context *pipe; - struct pipe_transfer *transfer; -}; - - -static inline struct rbug_resource * -rbug_resource(struct pipe_resource *_resource) -{ - if (!_resource) - return NULL; - (void)rbug_screen(_resource->screen); - return (struct rbug_resource *)_resource; -} - -static inline struct rbug_sampler_view * -rbug_sampler_view(struct pipe_sampler_view *_sampler_view) -{ - if (!_sampler_view) - return NULL; - (void)rbug_resource(_sampler_view->texture); - return (struct rbug_sampler_view *)_sampler_view; -} - -static inline struct rbug_surface * -rbug_surface(struct pipe_surface *_surface) -{ - if (!_surface) - return NULL; - (void)rbug_resource(_surface->texture); - return (struct rbug_surface *)_surface; -} - -static inline struct rbug_transfer * -rbug_transfer(struct pipe_transfer *_transfer) -{ - if (!_transfer) - return NULL; - (void)rbug_resource(_transfer->resource); - return (struct rbug_transfer *)_transfer; -} - -static inline struct rbug_shader * -rbug_shader(void *_state) -{ - if (!_state) - return NULL; - return (struct rbug_shader *)_state; -} - -static inline struct pipe_resource * -rbug_resource_unwrap(struct pipe_resource *_resource) -{ - if (!_resource) - return NULL; - return rbug_resource(_resource)->resource; -} - -static inline struct pipe_sampler_view * -rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view) -{ - if (!_sampler_view) - return NULL; - return rbug_sampler_view(_sampler_view)->sampler_view; -} - -static inline struct pipe_surface * -rbug_surface_unwrap(struct pipe_surface *_surface) -{ - if (!_surface) - return NULL; - return rbug_surface(_surface)->surface; -} - -static inline struct pipe_transfer * -rbug_transfer_unwrap(struct pipe_transfer *_transfer) -{ - if (!_transfer) - return NULL; - return rbug_transfer(_transfer)->transfer; -} - -static inline void * -rbug_shader_unwrap(void *_state) -{ - struct rbug_shader *shader; - if (!_state) - return NULL; - - shader = rbug_shader(_state); - return shader->replaced_shader ? shader->replaced_shader : shader->shader; -} - - -struct pipe_resource * -rbug_resource_create(struct rbug_screen *rb_screen, - struct pipe_resource *resource); - -void -rbug_resource_destroy(struct rbug_resource *rb_resource); - -struct pipe_surface * -rbug_surface_create(struct rbug_context *rb_context, - struct rbug_resource *rb_resource, - struct pipe_surface *surface); - -void -rbug_surface_destroy(struct rbug_context *rb_context, - struct rbug_surface *rb_surface); - -struct pipe_sampler_view * -rbug_sampler_view_create(struct rbug_context *rb_context, - struct rbug_resource *rb_resource, - struct pipe_sampler_view *view); - -void -rbug_sampler_view_destroy(struct rbug_context *rb_context, - struct rbug_sampler_view *rb_sampler_view); - -struct pipe_transfer * -rbug_transfer_create(struct rbug_context *rb_context, - struct rbug_resource *rb_resource, - struct pipe_transfer *transfer); - -void -rbug_transfer_destroy(struct rbug_context *rb_context, - struct rbug_transfer *rb_transfer); - -void * -rbug_shader_create(struct rbug_context *rb_context, - const struct pipe_shader_state *state, - void *result, enum rbug_shader_type type); - -void -rbug_shader_destroy(struct rbug_context *rb_context, - struct rbug_shader *rb_shader); - - -#endif /* RBUG_OBJECTS_H */ diff --git a/src/gallium/auxiliary/driver_rbug/rbug_public.h b/src/gallium/auxiliary/driver_rbug/rbug_public.h deleted file mode 100644 index d17cf98b807..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_public.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 RBUG_PUBLIC_H -#define RBUG_PUBLIC_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct pipe_screen; -struct pipe_context; - -struct pipe_screen * -rbug_screen_create(struct pipe_screen *screen); - -bool -rbug_enabled(void); - -#ifdef __cplusplus -} -#endif - -#endif /* RBUG_PUBLIC_H */ diff --git a/src/gallium/auxiliary/driver_rbug/rbug_screen.c b/src/gallium/auxiliary/driver_rbug/rbug_screen.c deleted file mode 100644 index 3c78e6c3c8d..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_screen.c +++ /dev/null @@ -1,511 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 "pipe/p_screen.h" -#include "pipe/p_state.h" -#include "util/u_memory.h" -#include "util/u_debug.h" - -#include "rbug_public.h" -#include "rbug_screen.h" -#include "rbug_context.h" -#include "rbug_objects.h" - -DEBUG_GET_ONCE_BOOL_OPTION(rbug, "GALLIUM_RBUG", false) - -static void -rbug_screen_destroy(struct pipe_screen *_screen) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - screen->destroy(screen); - - FREE(rb_screen); -} - -static const char * -rbug_screen_get_name(struct pipe_screen *_screen) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_name(screen); -} - -static const char * -rbug_screen_get_vendor(struct pipe_screen *_screen) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_vendor(screen); -} - -static const char * -rbug_screen_get_device_vendor(struct pipe_screen *_screen) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_device_vendor(screen); -} - -static const void * -rbug_screen_get_compiler_options(struct pipe_screen *_screen, - enum pipe_shader_ir ir, - enum pipe_shader_type shader) -{ - struct pipe_screen *screen = rbug_screen(_screen)->screen; - - return screen->get_compiler_options(screen, ir, shader); -} - -static struct disk_cache * -rbug_screen_get_disk_shader_cache(struct pipe_screen *_screen) -{ - struct pipe_screen *screen = rbug_screen(_screen)->screen; - - return screen->get_disk_shader_cache(screen); -} - -static int -rbug_screen_get_param(struct pipe_screen *_screen, - enum pipe_cap param) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_param(screen, - param); -} - -static int -rbug_screen_get_shader_param(struct pipe_screen *_screen, - enum pipe_shader_type shader, - enum pipe_shader_cap param) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_shader_param(screen, shader, - param); -} - -static float -rbug_screen_get_paramf(struct pipe_screen *_screen, - enum pipe_capf param) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_paramf(screen, - param); -} - -static bool -rbug_screen_is_format_supported(struct pipe_screen *_screen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned sample_count, - unsigned storage_sample_count, - unsigned tex_usage) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->is_format_supported(screen, - format, - target, - sample_count, - storage_sample_count, - tex_usage); -} - -static void -rbug_screen_query_dmabuf_modifiers(struct pipe_screen *_screen, - enum pipe_format format, int max, - uint64_t *modifiers, - unsigned int *external_only, int *count) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - screen->query_dmabuf_modifiers(screen, - format, - max, - modifiers, - external_only, - count); -} - -static bool -rbug_screen_is_dmabuf_modifier_supported(struct pipe_screen *_screen, - uint64_t modifier, - enum pipe_format format, - bool *external_only) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->is_dmabuf_modifier_supported(screen, - modifier, - format, - external_only); -} - -static unsigned int -rbug_screen_get_dmabuf_modifier_planes(struct pipe_screen *_screen, - uint64_t modifier, - enum pipe_format format) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_dmabuf_modifier_planes(screen, modifier, format); -} - -static int -rbug_screen_get_sparse_texture_virtual_page_size(struct pipe_screen *_screen, - enum pipe_texture_target target, - bool multi_sample, - enum pipe_format format, - unsigned offset, unsigned size, - int *x, int *y, int *z) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->get_sparse_texture_virtual_page_size(screen, target, multi_sample, - format, offset, size, x, y, z); -} - -static struct pipe_context * -rbug_screen_context_create(struct pipe_screen *_screen, - void *priv, unsigned flags) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_context *result; - - result = screen->context_create(screen, priv, flags); - if (result) - return rbug_context_create(_screen, result); - return NULL; -} - -static bool -rbug_screen_can_create_resource(struct pipe_screen *_screen, - const struct pipe_resource *templat) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->can_create_resource(screen, - templat); -} - -static struct pipe_resource * -rbug_screen_resource_create(struct pipe_screen *_screen, - const struct pipe_resource *templat) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *result; - - result = screen->resource_create(screen, - templat); - - if (result) - return rbug_resource_create(rb_screen, result); - return NULL; -} - -static struct pipe_resource * -rbug_screen_resource_create_with_modifiers(struct pipe_screen *_screen, - const struct pipe_resource *templat, - const uint64_t *modifiers, int count) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *result; - - result = screen->resource_create_with_modifiers(screen, - templat, - modifiers, - count); - - if (result) - return rbug_resource_create(rb_screen, result); - return NULL; -} - -static struct pipe_resource * -rbug_screen_resource_from_handle(struct pipe_screen *_screen, - const struct pipe_resource *templ, - struct winsys_handle *handle, - unsigned usage) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *result; - - result = screen->resource_from_handle(screen, templ, handle, usage); - - result = rbug_resource_create(rbug_screen(_screen), result); - - return result; -} - -static bool -rbug_screen_check_resource_capability(struct pipe_screen *_screen, - struct pipe_resource *_resource, - unsigned bind) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *resource = rb_resource->resource; - - return screen->check_resource_capability(screen, resource, bind); -} - -static bool -rbug_screen_resource_get_handle(struct pipe_screen *_screen, - struct pipe_context *_pipe, - struct pipe_resource *_resource, - struct winsys_handle *handle, - unsigned usage) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *resource = rb_resource->resource; - - return screen->resource_get_handle(screen, rb_pipe ? rb_pipe->pipe : NULL, - resource, handle, usage); -} - -static bool -rbug_screen_resource_get_param(struct pipe_screen *_screen, - struct pipe_context *_pipe, - struct pipe_resource *_resource, - unsigned plane, - unsigned layer, - unsigned level, - enum pipe_resource_param param, - unsigned handle_usage, - uint64_t *value) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct rbug_context *rb_pipe = rbug_context(_pipe); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *resource = rb_resource->resource; - - return screen->resource_get_param(screen, rb_pipe ? rb_pipe->pipe : NULL, - resource, plane, layer, level, param, - handle_usage, value); -} - - -static void -rbug_screen_resource_get_info(struct pipe_screen *_screen, - struct pipe_resource *_resource, - unsigned *stride, - unsigned *offset) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *resource = rb_resource->resource; - - screen->resource_get_info(screen, resource, stride, offset); -} - -static void -rbug_screen_resource_changed(struct pipe_screen *_screen, - struct pipe_resource *_resource) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *resource = rb_resource->resource; - - screen->resource_changed(screen, resource); -} - -static void -rbug_screen_resource_destroy(struct pipe_screen *screen, - struct pipe_resource *_resource) -{ - rbug_resource_destroy(rbug_resource(_resource)); -} - -static void -rbug_screen_flush_frontbuffer(struct pipe_screen *_screen, - struct pipe_context *_ctx, - struct pipe_resource *_resource, - unsigned level, unsigned layer, - void *context_private, struct pipe_box *sub_box) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct rbug_resource *rb_resource = rbug_resource(_resource); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_resource *resource = rb_resource->resource; - struct pipe_context *ctx = _ctx ? rbug_context(_ctx)->pipe : NULL; - - screen->flush_frontbuffer(screen, - ctx, - resource, - level, layer, - context_private, sub_box); -} - -static void -rbug_screen_fence_reference(struct pipe_screen *_screen, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - screen->fence_reference(screen, - ptr, - fence); -} - -static bool -rbug_screen_fence_finish(struct pipe_screen *_screen, - struct pipe_context *_ctx, - struct pipe_fence_handle *fence, - uint64_t timeout) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - struct pipe_context *ctx = _ctx ? rbug_context(_ctx)->pipe : NULL; - - return screen->fence_finish(screen, ctx, fence, timeout); -} - -static int -rbug_screen_fence_get_fd(struct pipe_screen *_screen, - struct pipe_fence_handle *fence) -{ - struct rbug_screen *rb_screen = rbug_screen(_screen); - struct pipe_screen *screen = rb_screen->screen; - - return screen->fence_get_fd(screen, fence); -} - -static char * -rbug_screen_finalize_nir(struct pipe_screen *_screen, void *nir) -{ - struct pipe_screen *screen = rbug_screen(_screen)->screen; - - return screen->finalize_nir(screen, nir); -} - -bool -rbug_enabled() -{ - return debug_get_option_rbug(); -} - -struct pipe_screen * -rbug_screen_create(struct pipe_screen *screen) -{ - struct rbug_screen *rb_screen; - - if (!debug_get_option_rbug()) - return screen; - - rb_screen = CALLOC_STRUCT(rbug_screen); - if (!rb_screen) - return screen; - - (void) mtx_init(&rb_screen->list_mutex, mtx_plain); - list_inithead(&rb_screen->contexts); - list_inithead(&rb_screen->resources); - list_inithead(&rb_screen->surfaces); - list_inithead(&rb_screen->transfers); - -#define SCR_INIT(_member) \ - rb_screen->base._member = screen->_member ? rbug_screen_##_member : NULL - - rb_screen->base.destroy = rbug_screen_destroy; - rb_screen->base.get_name = rbug_screen_get_name; - rb_screen->base.get_vendor = rbug_screen_get_vendor; - SCR_INIT(get_compiler_options); - SCR_INIT(get_disk_shader_cache); - rb_screen->base.get_device_vendor = rbug_screen_get_device_vendor; - rb_screen->base.get_param = rbug_screen_get_param; - rb_screen->base.get_shader_param = rbug_screen_get_shader_param; - rb_screen->base.get_paramf = rbug_screen_get_paramf; - rb_screen->base.is_format_supported = rbug_screen_is_format_supported; - SCR_INIT(query_dmabuf_modifiers); - SCR_INIT(is_dmabuf_modifier_supported); - SCR_INIT(get_dmabuf_modifier_planes); - rb_screen->base.context_create = rbug_screen_context_create; - SCR_INIT(can_create_resource); - rb_screen->base.resource_create = rbug_screen_resource_create; - SCR_INIT(resource_create_with_modifiers); - rb_screen->base.resource_from_handle = rbug_screen_resource_from_handle; - SCR_INIT(check_resource_capability); - rb_screen->base.resource_get_handle = rbug_screen_resource_get_handle; - SCR_INIT(resource_get_param); - SCR_INIT(resource_get_info); - SCR_INIT(resource_changed); - rb_screen->base.resource_destroy = rbug_screen_resource_destroy; - rb_screen->base.flush_frontbuffer = rbug_screen_flush_frontbuffer; - rb_screen->base.fence_reference = rbug_screen_fence_reference; - rb_screen->base.fence_finish = rbug_screen_fence_finish; - rb_screen->base.fence_get_fd = rbug_screen_fence_get_fd; - SCR_INIT(finalize_nir); - SCR_INIT(get_sparse_texture_virtual_page_size); - - rb_screen->screen = screen; - - rb_screen->private_context = screen->context_create(screen, NULL, 0); - if (!rb_screen->private_context) - goto err_free; - - rb_screen->rbug = rbug_start(rb_screen); - - if (!rb_screen->rbug) - goto err_context; - - return &rb_screen->base; - -err_context: - rb_screen->private_context->destroy(rb_screen->private_context); -err_free: - FREE(rb_screen); - return screen; -} diff --git a/src/gallium/auxiliary/driver_rbug/rbug_screen.h b/src/gallium/auxiliary/driver_rbug/rbug_screen.h deleted file mode 100644 index bfa0e7704e6..00000000000 --- a/src/gallium/auxiliary/driver_rbug/rbug_screen.h +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 RBUG_SCREEN_H -#define RBUG_SCREEN_H - -#include "pipe/p_screen.h" -#include "pipe/p_defines.h" -#include "util/list.h" - -#include "os/os_thread.h" - - -struct rbug_screen -{ - struct pipe_screen base; - - struct pipe_screen *screen; - struct pipe_context *private_context; - - /* remote debugger */ - struct rbug_rbug *rbug; - - mtx_t list_mutex; - int num_contexts; - int num_resources; - int num_surfaces; - int num_transfers; - struct list_head contexts; - struct list_head resources; - struct list_head surfaces; - struct list_head transfers; -}; - -static inline struct rbug_screen * -rbug_screen(struct pipe_screen *screen) -{ - return (struct rbug_screen *)screen; -} - -#define rbug_screen_add_to_list(scr, name, obj) \ - do { \ - mtx_lock(&scr->list_mutex); \ - list_add(&scr->name, &obj->list); \ - scr->num_##name++; \ - mtx_unlock(&scr->list_mutex); \ - } while (0) - -#define rbug_screen_remove_from_list(scr, name, obj) \ - do { \ - mtx_lock(&scr->list_mutex); \ - list_del(&obj->list); \ - scr->num_##name--; \ - mtx_unlock(&scr->list_mutex); \ - } while (0) - - - -/********************************************************** - * rbug_core.c - */ - -struct rbug_rbug; - -struct rbug_rbug * -rbug_start(struct rbug_screen *rb_screen); - -void -rbug_stop(struct rbug_rbug *rbug); - - -#endif /* RBUG_SCREEN_H */ diff --git a/src/gallium/auxiliary/meson.build b/src/gallium/auxiliary/meson.build index a22717869d0..80052535183 100644 --- a/src/gallium/auxiliary/meson.build +++ b/src/gallium/auxiliary/meson.build @@ -88,14 +88,6 @@ files_libgallium = files( 'driver_noop/noop_pipe.c', 'driver_noop/noop_public.h', 'driver_noop/noop_state.c', - 'driver_rbug/rbug_context.c', - 'driver_rbug/rbug_context.h', - 'driver_rbug/rbug_core.c', - 'driver_rbug/rbug_objects.c', - 'driver_rbug/rbug_objects.h', - 'driver_rbug/rbug_public.h', - 'driver_rbug/rbug_screen.c', - 'driver_rbug/rbug_screen.h', 'driver_trace/tr_context.c', 'driver_trace/tr_context.h', 'driver_trace/tr_dump.c', @@ -152,20 +144,6 @@ files_libgallium = files( 'postprocess/pp_private.h', 'postprocess/pp_program.c', 'postprocess/pp_run.c', - 'rbug/rbug_connection.c', - 'rbug/rbug_connection.h', - 'rbug/rbug_context.c', - 'rbug/rbug_context.h', - 'rbug/rbug_core.c', - 'rbug/rbug_core.h', - 'rbug/rbug_demarshal.c', - 'rbug/rbug.h', - 'rbug/rbug_internal.h', - 'rbug/rbug_proto.h', - 'rbug/rbug_shader.c', - 'rbug/rbug_shader.h', - 'rbug/rbug_texture.c', - 'rbug/rbug_texture.h', 'rtasm/rtasm_execmem.c', 'rtasm/rtasm_execmem.h', 'rtasm/rtasm_x86sse.c', diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README deleted file mode 100644 index 0c41c8c3fa1..00000000000 --- a/src/gallium/auxiliary/rbug/README +++ /dev/null @@ -1,25 +0,0 @@ - GALLIUM REMOTE DEBUGGING COMMON CODE - -= About = - -This directory contains the common code for the Gallium 3D remote debugging -driver and clients. The code is two parts the connection managment code and -the (de)marsheller. - -The code currently uses tcp and ip4v for connections. - -Information about driver integration can be found in: - -src/gallium/auxiliary/driver_rbug/README - -for information about applications look in: - -progs/rbug/README - -for a GUI see: - - http://cgit.freedesktop.org/mesa/rbug-gui - - --- -Jakob Bornecrantz <jakob@vmware.com> diff --git a/src/gallium/auxiliary/rbug/rbug.h b/src/gallium/auxiliary/rbug/rbug.h deleted file mode 100644 index 6b03ddebc87..00000000000 --- a/src/gallium/auxiliary/rbug/rbug.h +++ /dev/null @@ -1,33 +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 all for users the remote debugger protocol code. - */ - -#include "rbug_core.h" -#include "rbug_shader.h" -#include "rbug_context.h" -#include "rbug_texture.h" -#include "rbug_connection.h" diff --git a/src/gallium/auxiliary/rbug/rbug_connection.c b/src/gallium/auxiliary/rbug/rbug_connection.c deleted file mode 100644 index 152226f84e2..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_connection.c +++ /dev/null @@ -1,168 +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 "rbug.h" -#include "rbug_internal.h" - -#include "util/u_network.h" - -struct rbug_connection -{ - int socket; - uint32_t send_serial; - uint32_t recv_serial; - enum rbug_opcode opcode; -}; - -/** - * Create a rbug connection from a socket created with u_socket. - * - * Result: - * A new allocated connection using socket as communication path - */ -struct rbug_connection * -rbug_from_socket(int socket) -{ - struct rbug_connection *c = CALLOC_STRUCT(rbug_connection); - c->socket = socket; - return c; -} - -/** - * Free a connection, also closes socket. - */ -void -rbug_disconnect(struct rbug_connection *c) -{ - u_socket_close(c->socket); - FREE(c); -} - -/** - * Waits for a message to be fully received. - * Also returns the serial for the message, serial is not touched for replys. - * - * Result: - * demarshaled message on success, NULL on connection error - */ -struct rbug_header * -rbug_get_message(struct rbug_connection *c, uint32_t *serial) -{ - struct rbug_proto_header header; - struct rbug_header *out; - struct rbug_proto_header *data; - size_t length = 0; - size_t read = 0; - int ret; - - - ret = u_socket_peek(c->socket, &header, sizeof(header)); - if (ret <= 0) { - return NULL; - } - - length = (size_t)header.length * 4; - data = MALLOC(length); - if (!data) { - return NULL; - } - data->opcode = 0; - - do { - uint8_t *ptr = ((uint8_t*)data) + read; - ret = u_socket_recv(c->socket, ptr, length - read); - - if (ret <= 0) { - FREE(data); - return NULL; - } - - read += ret; - } while(read < length); - - out = rbug_demarshal(data); - if (!out) - FREE(data); - else if (serial) - *serial = c->recv_serial++; - else - c->recv_serial++; - - return out; -} - -/** - * Frees a message and associated data. - */ -void -rbug_free_header(struct rbug_header *header) -{ - if (!header) - return; - - FREE(header->__message); - FREE(header); -} - -/** - * Internal function used by rbug_send_* functions. - * - * Start sending a message. - */ -int -rbug_connection_send_start(struct rbug_connection *c, enum rbug_opcode opcode, uint32_t length) -{ - c->opcode = opcode; - return 0; -} - -/** - * Internal function used by rbug_send_* functions. - * - * Write data to the socket. - */ -int -rbug_connection_write(struct rbug_connection *c, void *to, uint32_t size) -{ - int ret = u_socket_send(c->socket, to, size); - return ret; -} - -/** - * Internal function used by rbug_send_* functions. - * - * Finish writing data to the socket. - * Ups the send_serial and sets the serial argument if supplied. - */ -int rbug_connection_send_finish(struct rbug_connection *c, uint32_t *serial) -{ - if (c->opcode < 0) - return 0; - else if (serial) - *serial = c->send_serial++; - else - c->send_serial++; - - return 0; -} diff --git a/src/gallium/auxiliary/rbug/rbug_connection.h b/src/gallium/auxiliary/rbug/rbug_connection.h deleted file mode 100644 index ea0ff14a625..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_connection.h +++ /dev/null @@ -1,45 +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. - */ - -/* - * This file contains the function defentions for connection see c file for - * more comments covering function use. - */ - -#ifndef _RBUG_CONNECTION_H_ -#define _RBUG_CONNECTION_H_ - -#include "rbug_proto.h" - -struct rbug_connection * rbug_from_socket(int socket); - -void rbug_disconnect(struct rbug_connection *c); - -struct rbug_header * rbug_get_message(struct rbug_connection *c, uint32_t *serial); - -void rbug_free_header(struct rbug_header *header); - -struct rbug_header * rbug_demarshal(struct rbug_proto_header *header); - -#endif diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c deleted file mode 100644 index cff5cfdaca9..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_context.c +++ /dev/null @@ -1,748 +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. - */ - -/* - * This file holds the function implementation for one of the rbug extensions. - * Prototypes and declerations of functions and structs is in the same folder - * in the header file matching this file's name. - * - * The functions starting rbug_send_* encodes a call to the write format and - * sends that to the supplied connection, while functions starting with - * rbug_demarshal_* demarshal data in the wire protocol. - * - * Functions ending with _reply are replies to requests. - */ - -#include "rbug_internal.h" -#include "rbug_context.h" - -int rbug_send_context_list(struct rbug_connection *__con, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_info(struct rbug_connection *__con, - rbug_context_t context, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_draw_block(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t block, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(4); /* block */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(4, rbug_block_t, block); /* block */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCK, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_draw_step(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t step, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(4); /* step */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_STEP)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(4, rbug_block_t, step); /* step */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_STEP, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_draw_unblock(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t unblock, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(4); /* unblock */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(4, rbug_block_t, unblock); /* unblock */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_UNBLOCK, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_draw_rule(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t vertex, - rbug_shader_t fragment, - rbug_texture_t texture, - rbug_texture_t surface, - rbug_block_t block, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(8); /* vertex */ - LEN(8); /* fragment */ - LEN(8); /* texture */ - LEN(8); /* surface */ - LEN(4); /* block */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_RULE)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(8, rbug_shader_t, vertex); /* vertex */ - WRITE(8, rbug_shader_t, fragment); /* fragment */ - WRITE(8, rbug_texture_t, texture); /* texture */ - WRITE(8, rbug_texture_t, surface); /* surface */ - WRITE(4, rbug_block_t, block); /* block */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_RULE, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_flush(struct rbug_connection *__con, - rbug_context_t context, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_FLUSH, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_list_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_context_t *contexts, - uint32_t contexts_len, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN_ARRAY(8, contexts); /* contexts */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE_ARRAY(8, rbug_context_t, contexts); /* contexts */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_info_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_shader_t vertex, - rbug_shader_t fragment, - rbug_texture_t *texs, - uint32_t texs_len, - rbug_texture_t *cbufs, - uint32_t cbufs_len, - rbug_texture_t zsbuf, - rbug_block_t blocker, - rbug_block_t blocked, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN(8); /* vertex */ - LEN(8); /* fragment */ - LEN_ARRAY(8, texs); /* texs */ - LEN_ARRAY(8, cbufs); /* cbufs */ - LEN(8); /* zsbuf */ - LEN(4); /* blocker */ - LEN(4); /* blocked */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE(8, rbug_shader_t, vertex); /* vertex */ - WRITE(8, rbug_shader_t, fragment); /* fragment */ - WRITE_ARRAY(8, rbug_texture_t, texs); /* texs */ - WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ - WRITE(8, rbug_texture_t, zsbuf); /* zsbuf */ - WRITE(4, rbug_block_t, blocker); /* blocker */ - WRITE(4, rbug_block_t, blocked); /* blocked */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_context_draw_blocked(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t block, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(4); /* block */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(4, rbug_block_t, block); /* block */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCKED, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header) -{ - struct rbug_proto_context_list *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST) - return NULL; - - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - return ret; -} - -struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_info *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - - return ret; -} - -struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_draw_block *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(4, rbug_block_t, block); /* block */ - - return ret; -} - -struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_draw_step *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_STEP) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(4, rbug_block_t, step); /* step */ - - return ret; -} - -struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_draw_unblock *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(4, rbug_block_t, unblock); /* unblock */ - - return ret; -} - -struct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_draw_rule *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_RULE) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(8, rbug_shader_t, vertex); /* vertex */ - READ(8, rbug_shader_t, fragment); /* fragment */ - READ(8, rbug_texture_t, texture); /* texture */ - READ(8, rbug_texture_t, surface); /* surface */ - READ(4, rbug_block_t, block); /* block */ - - return ret; -} - -struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_flush *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_FLUSH) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - - return ret; -} - -struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_list_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ_ARRAY(8, rbug_context_t, contexts); /* contexts */ - - return ret; -} - -struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_info_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ(8, rbug_shader_t, vertex); /* vertex */ - READ(8, rbug_shader_t, fragment); /* fragment */ - READ_ARRAY(8, rbug_texture_t, texs); /* texs */ - READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ - READ(8, rbug_texture_t, zsbuf); /* zsbuf */ - READ(4, rbug_block_t, blocker); /* blocker */ - READ(4, rbug_block_t, blocked); /* blocked */ - - return ret; -} - -struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_draw_blocked *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(4, rbug_block_t, block); /* block */ - - return ret; -} diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h deleted file mode 100644 index 573507804fa..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_context.h +++ /dev/null @@ -1,210 +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. - */ - -/* - * This file holds structs decelerations and function prototypes for one of - * the rbug extensions. Implementation of the functions is in the same folder - * in the c file matching this file's name. - * - * The structs what is returned from the demarshal functions. The functions - * starting rbug_send_* encodes a call to the write format and sends that to - * the supplied connection, while functions starting with rbug_demarshal_* - * demarshal data from the wire protocol. - * - * Structs and functions ending with _reply are replies to requests. - */ - -#ifndef _RBUG_PROTO_CONTEXT_H_ -#define _RBUG_PROTO_CONTEXT_H_ - -#include "rbug_proto.h" -#include "rbug_core.h" - -typedef enum -{ - RBUG_BLOCK_BEFORE = 1, - RBUG_BLOCK_AFTER = 2, - RBUG_BLOCK_RULE = 4, - RBUG_BLOCK_MASK = 7 -} rbug_block_t; - -struct rbug_proto_context_list -{ - struct rbug_header header; -}; - -struct rbug_proto_context_info -{ - struct rbug_header header; - rbug_context_t context; -}; - -struct rbug_proto_context_draw_block -{ - struct rbug_header header; - rbug_context_t context; - rbug_block_t block; -}; - -struct rbug_proto_context_draw_step -{ - struct rbug_header header; - rbug_context_t context; - rbug_block_t step; -}; - -struct rbug_proto_context_draw_unblock -{ - struct rbug_header header; - rbug_context_t context; - rbug_block_t unblock; -}; - -struct rbug_proto_context_draw_rule -{ - struct rbug_header header; - rbug_context_t context; - rbug_shader_t vertex; - rbug_shader_t fragment; - rbug_texture_t texture; - rbug_texture_t surface; - rbug_block_t block; -}; - -struct rbug_proto_context_flush -{ - struct rbug_header header; - rbug_context_t context; -}; - -struct rbug_proto_context_list_reply -{ - struct rbug_header header; - uint32_t serial; - rbug_context_t *contexts; - uint32_t contexts_len; -}; - -struct rbug_proto_context_info_reply -{ - struct rbug_header header; - uint32_t serial; - rbug_shader_t vertex; - rbug_shader_t fragment; - rbug_texture_t *texs; - uint32_t texs_len; - rbug_texture_t *cbufs; - uint32_t cbufs_len; - rbug_texture_t zsbuf; - rbug_block_t blocker; - rbug_block_t blocked; -}; - -struct rbug_proto_context_draw_blocked -{ - struct rbug_header header; - rbug_context_t context; - rbug_block_t block; -}; - -int rbug_send_context_list(struct rbug_connection *__con, - uint32_t *__serial); - -int rbug_send_context_info(struct rbug_connection *__con, - rbug_context_t context, - uint32_t *__serial); - -int rbug_send_context_draw_block(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t block, - uint32_t *__serial); - -int rbug_send_context_draw_step(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t step, - uint32_t *__serial); - -int rbug_send_context_draw_unblock(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t unblock, - uint32_t *__serial); - -int rbug_send_context_draw_rule(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t vertex, - rbug_shader_t fragment, - rbug_texture_t texture, - rbug_texture_t surface, - rbug_block_t block, - uint32_t *__serial); - -int rbug_send_context_flush(struct rbug_connection *__con, - rbug_context_t context, - uint32_t *__serial); - -int rbug_send_context_list_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_context_t *contexts, - uint32_t contexts_len, - uint32_t *__serial); - -int rbug_send_context_info_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_shader_t vertex, - rbug_shader_t fragment, - rbug_texture_t *texs, - uint32_t texs_len, - rbug_texture_t *cbufs, - uint32_t cbufs_len, - rbug_texture_t zsbuf, - rbug_block_t blocker, - rbug_block_t blocked, - uint32_t *__serial); - -int rbug_send_context_draw_blocked(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_t block, - uint32_t *__serial); - -struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header); - -struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header); - -struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header); - -struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header); - -struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header); - -struct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rbug_proto_header *header); - -struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header); - -struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header); - -struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header); - -struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header); - -#endif diff --git a/src/gallium/auxiliary/rbug/rbug_core.c b/src/gallium/auxiliary/rbug/rbug_core.c deleted file mode 100644 index 767dd38ee86..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_core.c +++ /dev/null @@ -1,345 +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. - */ - -/* - * This file holds the function implementation for one of the rbug extensions. - * Prototypes and declerations of functions and structs is in the same folder - * in the header file matching this file's name. - * - * The functions starting rbug_send_* encodes a call to the write format and - * sends that to the supplied connection, while functions starting with - * rbug_demarshal_* demarshal data in the wire protocol. - * - * Functions ending with _reply are replies to requests. - */ - -#include "rbug_internal.h" -#include "rbug_core.h" - -int rbug_send_noop(struct rbug_connection *__con, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_NOOP)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_NOOP, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_ping(struct rbug_connection *__con, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_PING)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_PING, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_error(struct rbug_connection *__con, - uint32_t error, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* error */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, error); /* error */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_ERROR, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_ping_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_PING_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_PING_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_error_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t error, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN(4); /* error */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE(4, uint32_t, error); /* error */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_ERROR_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header) -{ - struct rbug_proto_noop *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_NOOP) - return NULL; - - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - return ret; -} - -struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header) -{ - struct rbug_proto_ping *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_PING) - return NULL; - - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - return ret; -} - -struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_error *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_ERROR) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, error); /* error */ - - return ret; -} - -struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_ping_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_PING_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - - return ret; -} - -struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_error_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_ERROR_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ(4, uint32_t, error); /* error */ - - return ret; -} diff --git a/src/gallium/auxiliary/rbug/rbug_core.h b/src/gallium/auxiliary/rbug/rbug_core.h deleted file mode 100644 index 7cd36e4f87f..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_core.h +++ /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 - * 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. - */ - -/* - * This file holds structs decelerations and function prototypes for one of - * the rbug extensions. Implementation of the functions is in the same folder - * in the c file matching this file's name. - * - * The structs what is returned from the demarshal functions. The functions - * starting rbug_send_* encodes a call to the write format and sends that to - * the supplied connection, while functions starting with rbug_demarshal_* - * demarshal data from the wire protocol. - * - * Structs and functions ending with _reply are replies to requests. - */ - -#ifndef _RBUG_PROTO_CORE_H_ -#define _RBUG_PROTO_CORE_H_ - -#include "rbug_proto.h" - -typedef uint64_t rbug_shader_t; -typedef uint64_t rbug_context_t; -typedef uint64_t rbug_texture_t; - -struct rbug_proto_noop -{ - struct rbug_header header; -}; - -struct rbug_proto_ping -{ - struct rbug_header header; -}; - -struct rbug_proto_error -{ - struct rbug_header header; - uint32_t error; -}; - -struct rbug_proto_ping_reply -{ - struct rbug_header header; - uint32_t serial; -}; - -struct rbug_proto_error_reply -{ - struct rbug_header header; - uint32_t serial; - uint32_t error; -}; - -int rbug_send_noop(struct rbug_connection *__con, - uint32_t *__serial); - -int rbug_send_ping(struct rbug_connection *__con, - uint32_t *__serial); - -int rbug_send_error(struct rbug_connection *__con, - uint32_t error, - uint32_t *__serial); - -int rbug_send_ping_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t *__serial); - -int rbug_send_error_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t error, - uint32_t *__serial); - -struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header); - -struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header); - -struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header); - -struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header); - -struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header); - -#endif diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c deleted file mode 100644 index 06caa45469d..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_demarshal.c +++ /dev/null @@ -1,157 +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 "rbug.h" - -/** - * Small function that looks at the proto_header and selects the correct - * demarshal functions and return the result. - */ -struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) -{ - switch(header->opcode) { - case RBUG_OP_NOOP: - return (struct rbug_header *)rbug_demarshal_noop(header); - case RBUG_OP_PING: - return (struct rbug_header *)rbug_demarshal_ping(header); - case RBUG_OP_ERROR: - return (struct rbug_header *)rbug_demarshal_error(header); - case RBUG_OP_PING_REPLY: - return (struct rbug_header *)rbug_demarshal_ping_reply(header); - case RBUG_OP_ERROR_REPLY: - return (struct rbug_header *)rbug_demarshal_error_reply(header); - case RBUG_OP_TEXTURE_LIST: - return (struct rbug_header *)rbug_demarshal_texture_list(header); - case RBUG_OP_TEXTURE_INFO: - return (struct rbug_header *)rbug_demarshal_texture_info(header); - case RBUG_OP_TEXTURE_WRITE: - return (struct rbug_header *)rbug_demarshal_texture_write(header); - case RBUG_OP_TEXTURE_READ: - return (struct rbug_header *)rbug_demarshal_texture_read(header); - case RBUG_OP_TEXTURE_LIST_REPLY: - return (struct rbug_header *)rbug_demarshal_texture_list_reply(header); - case RBUG_OP_TEXTURE_INFO_REPLY: - return (struct rbug_header *)rbug_demarshal_texture_info_reply(header); - case RBUG_OP_TEXTURE_READ_REPLY: - return (struct rbug_header *)rbug_demarshal_texture_read_reply(header); - case RBUG_OP_CONTEXT_LIST: - return (struct rbug_header *)rbug_demarshal_context_list(header); - case RBUG_OP_CONTEXT_INFO: - return (struct rbug_header *)rbug_demarshal_context_info(header); - case RBUG_OP_CONTEXT_DRAW_BLOCK: - return (struct rbug_header *)rbug_demarshal_context_draw_block(header); - case RBUG_OP_CONTEXT_DRAW_STEP: - return (struct rbug_header *)rbug_demarshal_context_draw_step(header); - case RBUG_OP_CONTEXT_DRAW_UNBLOCK: - return (struct rbug_header *)rbug_demarshal_context_draw_unblock(header); - case RBUG_OP_CONTEXT_DRAW_RULE: - return (struct rbug_header *)rbug_demarshal_context_draw_rule(header); - case RBUG_OP_CONTEXT_FLUSH: - return (struct rbug_header *)rbug_demarshal_context_flush(header); - case RBUG_OP_CONTEXT_LIST_REPLY: - return (struct rbug_header *)rbug_demarshal_context_list_reply(header); - case RBUG_OP_CONTEXT_INFO_REPLY: - return (struct rbug_header *)rbug_demarshal_context_info_reply(header); - case RBUG_OP_CONTEXT_DRAW_BLOCKED: - return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header); - case RBUG_OP_SHADER_LIST: - return (struct rbug_header *)rbug_demarshal_shader_list(header); - case RBUG_OP_SHADER_INFO: - return (struct rbug_header *)rbug_demarshal_shader_info(header); - case RBUG_OP_SHADER_DISABLE: - return (struct rbug_header *)rbug_demarshal_shader_disable(header); - case RBUG_OP_SHADER_REPLACE: - return (struct rbug_header *)rbug_demarshal_shader_replace(header); - case RBUG_OP_SHADER_LIST_REPLY: - return (struct rbug_header *)rbug_demarshal_shader_list_reply(header); - case RBUG_OP_SHADER_INFO_REPLY: - return (struct rbug_header *)rbug_demarshal_shader_info_reply(header); - default: - return NULL; - } -} - -const char* rbug_proto_get_name(enum rbug_opcode opcode) -{ - switch(opcode) { - case RBUG_OP_NOOP: - return "RBUG_OP_NOOP"; - case RBUG_OP_PING: - return "RBUG_OP_PING"; - case RBUG_OP_ERROR: - return "RBUG_OP_ERROR"; - case RBUG_OP_PING_REPLY: - return "RBUG_OP_PING_REPLY"; - case RBUG_OP_ERROR_REPLY: - return "RBUG_OP_ERROR_REPLY"; - case RBUG_OP_TEXTURE_LIST: - return "RBUG_OP_TEXTURE_LIST"; - case RBUG_OP_TEXTURE_INFO: - return "RBUG_OP_TEXTURE_INFO"; - case RBUG_OP_TEXTURE_WRITE: - return "RBUG_OP_TEXTURE_WRITE"; - case RBUG_OP_TEXTURE_READ: - return "RBUG_OP_TEXTURE_READ"; - case RBUG_OP_TEXTURE_LIST_REPLY: - return "RBUG_OP_TEXTURE_LIST_REPLY"; - case RBUG_OP_TEXTURE_INFO_REPLY: - return "RBUG_OP_TEXTURE_INFO_REPLY"; - case RBUG_OP_TEXTURE_READ_REPLY: - return "RBUG_OP_TEXTURE_READ_REPLY"; - case RBUG_OP_CONTEXT_LIST: - return "RBUG_OP_CONTEXT_LIST"; - case RBUG_OP_CONTEXT_INFO: - return "RBUG_OP_CONTEXT_INFO"; - case RBUG_OP_CONTEXT_DRAW_BLOCK: - return "RBUG_OP_CONTEXT_DRAW_BLOCK"; - case RBUG_OP_CONTEXT_DRAW_STEP: - return "RBUG_OP_CONTEXT_DRAW_STEP"; - case RBUG_OP_CONTEXT_DRAW_UNBLOCK: - return "RBUG_OP_CONTEXT_DRAW_UNBLOCK"; - case RBUG_OP_CONTEXT_DRAW_RULE: - return "RBUG_OP_CONTEXT_DRAW_RULE"; - case RBUG_OP_CONTEXT_FLUSH: - return "RBUG_OP_CONTEXT_FLUSH"; - case RBUG_OP_CONTEXT_LIST_REPLY: - return "RBUG_OP_CONTEXT_LIST_REPLY"; - case RBUG_OP_CONTEXT_INFO_REPLY: - return "RBUG_OP_CONTEXT_INFO_REPLY"; - case RBUG_OP_CONTEXT_DRAW_BLOCKED: - return "RBUG_OP_CONTEXT_DRAW_BLOCKED"; - case RBUG_OP_SHADER_LIST: - return "RBUG_OP_SHADER_LIST"; - case RBUG_OP_SHADER_INFO: - return "RBUG_OP_SHADER_INFO"; - case RBUG_OP_SHADER_DISABLE: - return "RBUG_OP_SHADER_DISABLE"; - case RBUG_OP_SHADER_REPLACE: - return "RBUG_OP_SHADER_REPLACE"; - case RBUG_OP_SHADER_LIST_REPLY: - return "RBUG_OP_SHADER_LIST_REPLY"; - case RBUG_OP_SHADER_INFO_REPLY: - return "RBUG_OP_SHADER_INFO_REPLY"; - default: - return NULL; - } -} diff --git a/src/gallium/auxiliary/rbug/rbug_internal.h b/src/gallium/auxiliary/rbug/rbug_internal.h deleted file mode 100644 index 3a4cbc19240..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_internal.h +++ /dev/null @@ -1,100 +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. - */ - -/* - * This file is internal to the rbug protocol code, and contains asorted - * features needed by the code. - */ - -#ifndef _RBUG_INTERNAL_H_ -#define _RBUG_INTERNAL_H_ - -#include "rbug_proto.h" - -#include "util/u_memory.h" -#include "util/u_debug.h" -#include <errno.h> - -int rbug_connection_send_start(struct rbug_connection *con, enum rbug_opcode opcode, uint32_t length); -int rbug_connection_write(struct rbug_connection *con, void *data, uint32_t size); -int rbug_connection_send_finish(struct rbug_connection *con, uint32_t *c); - -/** - * Only works with multiples of 2 - */ -#define PAD(from, to) \ -do { \ - from = (from + to - 1) & ~(to - 1); \ -} while(0) - -#define LEN(size) \ -do { \ - PAD(__len, size); \ - __len += size; \ -} while(0) - -#define LEN_ARRAY(size, name) \ -do { \ - LEN(4); \ - PAD(__len, size); \ - __len += size * name##_len; \ -} while(0) - -#define WRITE(size, type, name) \ -do { \ - PAD(__pos, size); \ - *((type *)(&__data[__pos])) = name; \ - __pos += size; \ -} while(0) - -#define WRITE_ARRAY(size, type, name) \ -do { \ - WRITE(4, uint32_t, name##_len); \ - PAD(__pos, size); \ - memcpy(&__data[__pos], name, size * name##_len); \ - __pos += size * name##_len; \ -} while(0) - -#define READ(size, type, name) \ -do { \ - PAD(pos, size); \ - pos += size; \ - if (pos > len) \ - break; \ - ret->name = *((type *)(&data[pos - size])); \ -} while(0) - -#define READ_ARRAY(size, type, name) \ -do { \ - READ(4, uint32_t, name##_len); \ - if (pos > len) \ - break; \ - PAD(pos, size); \ - pos += size * ret->name##_len; \ - if (pos > len) \ - break; \ - ret->name = (type *)&data[pos - size * ret->name##_len]; \ -} while(0) - -#endif diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h deleted file mode 100644 index 2fce725bc9e..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_proto.h +++ /dev/null @@ -1,99 +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. - */ - -/* - * This file holds common definitions of the gallium remote debugging protocol. - */ - -#ifndef _RBUG_PROTO_H_ -#define _RBUG_PROTO_H_ - -#include "pipe/p_compiler.h" - -/** - * Uniqe indentifier for each command. - * - * Replys are designated by negative. - */ -enum rbug_opcode -{ - RBUG_OP_NOOP = 0, - RBUG_OP_PING = 1, - RBUG_OP_ERROR = 2, - RBUG_OP_PING_REPLY = -1, - RBUG_OP_ERROR_REPLY = -2, - RBUG_OP_TEXTURE_LIST = 256, - RBUG_OP_TEXTURE_INFO = 257, - RBUG_OP_TEXTURE_WRITE = 258, - RBUG_OP_TEXTURE_READ = 259, - RBUG_OP_TEXTURE_LIST_REPLY = -256, - RBUG_OP_TEXTURE_INFO_REPLY = -257, - RBUG_OP_TEXTURE_READ_REPLY = -259, - RBUG_OP_CONTEXT_LIST = 512, - RBUG_OP_CONTEXT_INFO = 513, - RBUG_OP_CONTEXT_DRAW_BLOCK = 514, - RBUG_OP_CONTEXT_DRAW_STEP = 515, - RBUG_OP_CONTEXT_DRAW_UNBLOCK = 516, - RBUG_OP_CONTEXT_DRAW_RULE = 518, - RBUG_OP_CONTEXT_FLUSH = 519, - RBUG_OP_CONTEXT_LIST_REPLY = -512, - RBUG_OP_CONTEXT_INFO_REPLY = -513, - RBUG_OP_CONTEXT_DRAW_BLOCKED = 517, - RBUG_OP_SHADER_LIST = 768, - RBUG_OP_SHADER_INFO = 769, - RBUG_OP_SHADER_DISABLE = 770, - RBUG_OP_SHADER_REPLACE = 771, - RBUG_OP_SHADER_LIST_REPLY = -768, - RBUG_OP_SHADER_INFO_REPLY = -769 -}; - -/** - * Header for demarshaled message. - */ -struct rbug_header -{ - enum rbug_opcode opcode; - void *__message; -}; - -/** - * Header for a message in wire format. - */ -struct rbug_proto_header -{ - int32_t opcode; - uint32_t length; -}; - -/** - * Forward declare connection here, as this file is included by all users. - */ -struct rbug_connection; - -/** - * Get printable string for opcode. - */ -const char* rbug_proto_get_name(enum rbug_opcode opcode); - -#endif diff --git a/src/gallium/auxiliary/rbug/rbug_shader.c b/src/gallium/auxiliary/rbug/rbug_shader.c deleted file mode 100644 index 7765f761461..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_shader.c +++ /dev/null @@ -1,468 +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. - */ - -/* - * This file holds the function implementation for one of the rbug extensions. - * Prototypes and declerations of functions and structs is in the same folder - * in the header file matching this file's name. - * - * The functions starting rbug_send_* encodes a call to the write format and - * sends that to the supplied connection, while functions starting with - * rbug_demarshal_* demarshal data in the wire protocol. - * - * Functions ending with _reply are replies to requests. - */ - -#include "rbug_internal.h" -#include "rbug_shader.h" - -int rbug_send_shader_list(struct rbug_connection *__con, - rbug_context_t context, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_shader_info(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t shader, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(8); /* shader */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(8, rbug_shader_t, shader); /* shader */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_shader_disable(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t shader, - uint8_t disable, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(8); /* shader */ - LEN(1); /* disable */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_DISABLE)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(8, rbug_shader_t, shader); /* shader */ - WRITE(1, uint8_t, disable); /* disable */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_SHADER_DISABLE, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_shader_replace(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t shader, - uint32_t *tokens, - uint32_t tokens_len, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* context */ - LEN(8); /* shader */ - LEN_ARRAY(4, tokens); /* tokens */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_REPLACE)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_context_t, context); /* context */ - WRITE(8, rbug_shader_t, shader); /* shader */ - WRITE_ARRAY(4, uint32_t, tokens); /* tokens */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_SHADER_REPLACE, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_shader_list_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_shader_t *shaders, - uint32_t shaders_len, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN_ARRAY(8, shaders); /* shaders */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE_ARRAY(8, rbug_shader_t, shaders); /* shaders */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_shader_info_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t *original, - uint32_t original_len, - uint32_t *replaced, - uint32_t replaced_len, - uint8_t disabled, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN_ARRAY(4, original); /* original */ - LEN_ARRAY(4, replaced); /* replaced */ - LEN(1); /* disabled */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE_ARRAY(4, uint32_t, original); /* original */ - WRITE_ARRAY(4, uint32_t, replaced); /* replaced */ - WRITE(1, uint8_t, disabled); /* disabled */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_shader_list *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_SHADER_LIST) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - - return ret; -} - -struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_shader_info *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_SHADER_INFO) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(8, rbug_shader_t, shader); /* shader */ - - return ret; -} - -struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_shader_disable *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_SHADER_DISABLE) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(8, rbug_shader_t, shader); /* shader */ - READ(1, uint8_t, disable); /* disable */ - - return ret; -} - -struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_shader_replace *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_SHADER_REPLACE) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_context_t, context); /* context */ - READ(8, rbug_shader_t, shader); /* shader */ - READ_ARRAY(4, uint32_t, tokens); /* tokens */ - - return ret; -} - -struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_shader_list_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_SHADER_LIST_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ_ARRAY(8, rbug_shader_t, shaders); /* shaders */ - - return ret; -} - -struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_shader_info_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_SHADER_INFO_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ_ARRAY(4, uint32_t, original); /* original */ - READ_ARRAY(4, uint32_t, replaced); /* replaced */ - READ(1, uint8_t, disabled); /* disabled */ - - return ret; -} diff --git a/src/gallium/auxiliary/rbug/rbug_shader.h b/src/gallium/auxiliary/rbug/rbug_shader.h deleted file mode 100644 index 9352e0cac7f..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_shader.h +++ /dev/null @@ -1,142 +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. - */ - -/* - * This file holds structs decelerations and function prototypes for one of - * the rbug extensions. Implementation of the functions is in the same folder - * in the c file matching this file's name. - * - * The structs what is returned from the demarshal functions. The functions - * starting rbug_send_* encodes a call to the write format and sends that to - * the supplied connection, while functions starting with rbug_demarshal_* - * demarshal data from the wire protocol. - * - * Structs and functions ending with _reply are replies to requests. - */ - -#ifndef _RBUG_PROTO_SHADER_H_ -#define _RBUG_PROTO_SHADER_H_ - -#include "rbug_proto.h" -#include "rbug_core.h" - -struct rbug_proto_shader_list -{ - struct rbug_header header; - rbug_context_t context; -}; - -struct rbug_proto_shader_info -{ - struct rbug_header header; - rbug_context_t context; - rbug_shader_t shader; -}; - -struct rbug_proto_shader_disable -{ - struct rbug_header header; - rbug_context_t context; - rbug_shader_t shader; - uint8_t disable; -}; - -struct rbug_proto_shader_replace -{ - struct rbug_header header; - rbug_context_t context; - rbug_shader_t shader; - uint32_t *tokens; - uint32_t tokens_len; -}; - -struct rbug_proto_shader_list_reply -{ - struct rbug_header header; - uint32_t serial; - rbug_shader_t *shaders; - uint32_t shaders_len; -}; - -struct rbug_proto_shader_info_reply -{ - struct rbug_header header; - uint32_t serial; - uint32_t *original; - uint32_t original_len; - uint32_t *replaced; - uint32_t replaced_len; - uint8_t disabled; -}; - -int rbug_send_shader_list(struct rbug_connection *__con, - rbug_context_t context, - uint32_t *__serial); - -int rbug_send_shader_info(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t shader, - uint32_t *__serial); - -int rbug_send_shader_disable(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t shader, - uint8_t disable, - uint32_t *__serial); - -int rbug_send_shader_replace(struct rbug_connection *__con, - rbug_context_t context, - rbug_shader_t shader, - uint32_t *tokens, - uint32_t tokens_len, - uint32_t *__serial); - -int rbug_send_shader_list_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_shader_t *shaders, - uint32_t shaders_len, - uint32_t *__serial); - -int rbug_send_shader_info_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t *original, - uint32_t original_len, - uint32_t *replaced, - uint32_t replaced_len, - uint8_t disabled, - uint32_t *__serial); - -struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header); - -struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header); - -struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header); - -struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header); - -struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header); - -struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header); - -#endif diff --git a/src/gallium/auxiliary/rbug/rbug_texture.c b/src/gallium/auxiliary/rbug/rbug_texture.c deleted file mode 100644 index b0d8c60d46d..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_texture.c +++ /dev/null @@ -1,633 +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. - */ - -/* - * This file holds the function implementation for one of the rbug extensions. - * Prototypes and declerations of functions and structs is in the same folder - * in the header file matching this file's name. - * - * The functions starting rbug_send_* encodes a call to the write format and - * sends that to the supplied connection, while functions starting with - * rbug_demarshal_* demarshal data in the wire protocol. - * - * Functions ending with _reply are replies to requests. - */ - -#include "c99_alloca.h" - -#include "rbug_internal.h" -#include "rbug_texture.h" - -int rbug_send_texture_list(struct rbug_connection *__con, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_texture_info(struct rbug_connection *__con, - rbug_texture_t texture, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* texture */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_texture_t, texture); /* texture */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_texture_write(struct rbug_connection *__con, - rbug_texture_t texture, - uint32_t face, - uint32_t level, - uint32_t zslice, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h, - uint8_t *data, - uint32_t data_len, - uint32_t stride, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* texture */ - LEN(4); /* face */ - LEN(4); /* level */ - LEN(4); /* zslice */ - LEN(4); /* x */ - LEN(4); /* y */ - LEN(4); /* w */ - LEN(4); /* h */ - LEN_ARRAY(1, data); /* data */ - LEN(4); /* stride */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_WRITE)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_texture_t, texture); /* texture */ - WRITE(4, uint32_t, face); /* face */ - WRITE(4, uint32_t, level); /* level */ - WRITE(4, uint32_t, zslice); /* zslice */ - WRITE(4, uint32_t, x); /* x */ - WRITE(4, uint32_t, y); /* y */ - WRITE(4, uint32_t, w); /* w */ - WRITE(4, uint32_t, h); /* h */ - WRITE_ARRAY(1, uint8_t, data); /* data */ - WRITE(4, uint32_t, stride); /* stride */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_WRITE, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_texture_read(struct rbug_connection *__con, - rbug_texture_t texture, - uint32_t face, - uint32_t level, - uint32_t zslice, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(8); /* texture */ - LEN(4); /* face */ - LEN(4); /* level */ - LEN(4); /* zslice */ - LEN(4); /* x */ - LEN(4); /* y */ - LEN(4); /* w */ - LEN(4); /* h */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(8, rbug_texture_t, texture); /* texture */ - WRITE(4, uint32_t, face); /* face */ - WRITE(4, uint32_t, level); /* level */ - WRITE(4, uint32_t, zslice); /* zslice */ - WRITE(4, uint32_t, x); /* x */ - WRITE(4, uint32_t, y); /* y */ - WRITE(4, uint32_t, w); /* w */ - WRITE(4, uint32_t, h); /* h */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_texture_list_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_texture_t *textures, - uint32_t textures_len, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN_ARRAY(8, textures); /* textures */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE_ARRAY(8, rbug_texture_t, textures); /* textures */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_texture_info_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t target, - uint32_t format, - uint32_t *width, - uint32_t width_len, - uint16_t *h16, - uint32_t height_len, - uint16_t *d16, - uint32_t depth_len, - uint32_t blockw, - uint32_t blockh, - uint32_t blocksize, - uint32_t last_level, - uint32_t nr_samples, - uint32_t tex_usage, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - uint32_t *height = alloca(sizeof(uint32_t) * height_len); - uint32_t *depth = alloca(sizeof(uint32_t) * height_len); - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN(4); /* target */ - LEN(4); /* format */ - LEN_ARRAY(4, width); /* width */ - LEN_ARRAY(4, height); /* height */ - LEN_ARRAY(4, depth); /* depth */ - LEN(4); /* blockw */ - LEN(4); /* blockh */ - LEN(4); /* blocksize */ - LEN(4); /* last_level */ - LEN(4); /* nr_samples */ - LEN(4); /* tex_usage */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - for (int i = 0; i < height_len; i++) - height[i] = h16[i]; - for (int i = 0; i < depth_len; i++) - depth[i] = d16[i]; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE(4, uint32_t, target); /* target */ - WRITE(4, uint32_t, format); /* format */ - WRITE_ARRAY(4, uint32_t, width); /* width */ - WRITE_ARRAY(4, uint32_t, height); /* height */ - WRITE_ARRAY(4, uint32_t, depth); /* depth */ - WRITE(4, uint32_t, blockw); /* blockw */ - WRITE(4, uint32_t, blockh); /* blockh */ - WRITE(4, uint32_t, blocksize); /* blocksize */ - WRITE(4, uint32_t, last_level); /* last_level */ - WRITE(4, uint32_t, nr_samples); /* nr_samples */ - WRITE(4, uint32_t, tex_usage); /* tex_usage */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -int rbug_send_texture_read_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t format, - uint32_t blockw, - uint32_t blockh, - uint32_t blocksize, - uint8_t *data, - uint32_t data_len, - uint32_t stride, - uint32_t *__serial) -{ - uint32_t __len = 0; - uint32_t __pos = 0; - uint8_t *__data = NULL; - int __ret = 0; - - LEN(8); /* header */ - LEN(4); /* serial */ - LEN(4); /* format */ - LEN(4); /* blockw */ - LEN(4); /* blockh */ - LEN(4); /* blocksize */ - LEN_ARRAY(1, data); /* data */ - LEN(4); /* stride */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE(4, uint32_t, format); /* format */ - WRITE(4, uint32_t, blockw); /* blockw */ - WRITE(4, uint32_t, blockh); /* blockh */ - WRITE(4, uint32_t, blocksize); /* blocksize */ - WRITE_ARRAY(1, uint8_t, data); /* data */ - WRITE(4, uint32_t, stride); /* stride */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ_REPLY, __len); - rbug_connection_write(__con, __data, __len); - __ret = rbug_connection_send_finish(__con, __serial); - } - - FREE(__data); - return __ret; -} - -struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header) -{ - struct rbug_proto_texture_list *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_LIST) - return NULL; - - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - return ret; -} - -struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_texture_info *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_INFO) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_texture_t, texture); /* texture */ - - return ret; -} - -struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_texture_write *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_WRITE) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_texture_t, texture); /* texture */ - READ(4, uint32_t, face); /* face */ - READ(4, uint32_t, level); /* level */ - READ(4, uint32_t, zslice); /* zslice */ - READ(4, uint32_t, x); /* x */ - READ(4, uint32_t, y); /* y */ - READ(4, uint32_t, w); /* w */ - READ(4, uint32_t, h); /* h */ - READ_ARRAY(1, uint8_t, data); /* data */ - READ(4, uint32_t, stride); /* stride */ - - return ret; -} - -struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_texture_read *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_READ) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(8, rbug_texture_t, texture); /* texture */ - READ(4, uint32_t, face); /* face */ - READ(4, uint32_t, level); /* level */ - READ(4, uint32_t, zslice); /* zslice */ - READ(4, uint32_t, x); /* x */ - READ(4, uint32_t, y); /* y */ - READ(4, uint32_t, w); /* w */ - READ(4, uint32_t, h); /* h */ - - return ret; -} - -struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_texture_list_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_LIST_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ_ARRAY(8, rbug_texture_t, textures); /* textures */ - - return ret; -} - -struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_texture_info_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_INFO_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ(4, uint32_t, target); /* target */ - READ(4, uint32_t, format); /* format */ - READ_ARRAY(4, uint32_t, width); /* width */ - READ_ARRAY(4, uint32_t, height); /* height */ - READ_ARRAY(4, uint32_t, depth); /* depth */ - READ(4, uint32_t, blockw); /* blockw */ - READ(4, uint32_t, blockh); /* blockh */ - READ(4, uint32_t, blocksize); /* blocksize */ - READ(4, uint32_t, last_level); /* last_level */ - READ(4, uint32_t, nr_samples); /* nr_samples */ - READ(4, uint32_t, tex_usage); /* tex_usage */ - - return ret; -} - -struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_texture_read_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int32_t)RBUG_OP_TEXTURE_READ_REPLY) - return NULL; - - pos = 0; - len = header->length * 4; - data = (uint8_t*)&header[1]; - ret = MALLOC(sizeof(*ret)); - if (!ret) - return NULL; - - ret->header.__message = header; - ret->header.opcode = header->opcode; - - READ(4, uint32_t, serial); /* serial */ - READ(4, uint32_t, format); /* format */ - READ(4, uint32_t, blockw); /* blockw */ - READ(4, uint32_t, blockh); /* blockh */ - READ(4, uint32_t, blocksize); /* blocksize */ - READ_ARRAY(1, uint8_t, data); /* data */ - READ(4, uint32_t, stride); /* stride */ - - return ret; -} diff --git a/src/gallium/auxiliary/rbug/rbug_texture.h b/src/gallium/auxiliary/rbug/rbug_texture.h deleted file mode 100644 index 269e5961148..00000000000 --- a/src/gallium/auxiliary/rbug/rbug_texture.h +++ /dev/null @@ -1,206 +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. - */ - -/* - * This file holds structs decelerations and function prototypes for one of - * the rbug extensions. Implementation of the functions is in the same folder - * in the c file matching this file's name. - * - * The structs what is returned from the demarshal functions. The functions - * starting rbug_send_* encodes a call to the write format and sends that to - * the supplied connection, while functions starting with rbug_demarshal_* - * demarshal data from the wire protocol. - * - * Structs and functions ending with _reply are replies to requests. - */ - -#ifndef _RBUG_PROTO_TEXTURE_H_ -#define _RBUG_PROTO_TEXTURE_H_ - -#include "rbug_proto.h" -#include "rbug_core.h" - -struct rbug_proto_texture_list -{ - struct rbug_header header; -}; - -struct rbug_proto_texture_info -{ - struct rbug_header header; - rbug_texture_t texture; -}; - -struct rbug_proto_texture_write -{ - struct rbug_header header; - rbug_texture_t texture; - uint32_t face; - uint32_t level; - uint32_t zslice; - uint32_t x; - uint32_t y; - uint32_t w; - uint32_t h; - uint8_t *data; - uint32_t data_len; - uint32_t stride; -}; - -struct rbug_proto_texture_read -{ - struct rbug_header header; - rbug_texture_t texture; - uint32_t face; - uint32_t level; - uint32_t zslice; - uint32_t x; - uint32_t y; - uint32_t w; - uint32_t h; -}; - -struct rbug_proto_texture_list_reply -{ - struct rbug_header header; - uint32_t serial; - rbug_texture_t *textures; - uint32_t textures_len; -}; - -struct rbug_proto_texture_info_reply -{ - struct rbug_header header; - uint32_t serial; - uint32_t target; - uint32_t format; - uint32_t *width; - uint32_t width_len; - uint32_t *height; - uint32_t height_len; - uint32_t *depth; - uint32_t depth_len; - uint32_t blockw; - uint32_t blockh; - uint32_t blocksize; - uint32_t last_level; - uint32_t nr_samples; - uint32_t tex_usage; -}; - -struct rbug_proto_texture_read_reply -{ - struct rbug_header header; - uint32_t serial; - uint32_t format; - uint32_t blockw; - uint32_t blockh; - uint32_t blocksize; - uint8_t *data; - uint32_t data_len; - uint32_t stride; -}; - -int rbug_send_texture_list(struct rbug_connection *__con, - uint32_t *__serial); - -int rbug_send_texture_info(struct rbug_connection *__con, - rbug_texture_t texture, - uint32_t *__serial); - -int rbug_send_texture_write(struct rbug_connection *__con, - rbug_texture_t texture, - uint32_t face, - uint32_t level, - uint32_t zslice, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h, - uint8_t *data, - uint32_t data_len, - uint32_t stride, - uint32_t *__serial); - -int rbug_send_texture_read(struct rbug_connection *__con, - rbug_texture_t texture, - uint32_t face, - uint32_t level, - uint32_t zslice, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h, - uint32_t *__serial); - -int rbug_send_texture_list_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_texture_t *textures, - uint32_t textures_len, - uint32_t *__serial); - -int rbug_send_texture_info_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t target, - uint32_t format, - uint32_t *width, - uint32_t width_len, - uint16_t *height, - uint32_t height_len, - uint16_t *depth, - uint32_t depth_len, - uint32_t blockw, - uint32_t blockh, - uint32_t blocksize, - uint32_t last_level, - uint32_t nr_samples, - uint32_t tex_usage, - uint32_t *__serial); - -int rbug_send_texture_read_reply(struct rbug_connection *__con, - uint32_t serial, - uint32_t format, - uint32_t blockw, - uint32_t blockh, - uint32_t blocksize, - uint8_t *data, - uint32_t data_len, - uint32_t stride, - uint32_t *__serial); - -struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header); - -struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header); - -struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header); - -struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header); - -struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header); - -struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header); - -struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header); - -#endif diff --git a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h index 08aea330710..0f999bf71ef 100644 --- a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h +++ b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h @@ -13,7 +13,6 @@ #include "driver_ddebug/dd_public.h" #include "driver_trace/tr_public.h" -#include "driver_rbug/rbug_public.h" #include "driver_noop/noop_public.h" #ifdef __cplusplus @@ -28,7 +27,6 @@ static inline struct pipe_screen * debug_screen_wrap(struct pipe_screen *screen) { screen = ddebug_screen_create(screen); - screen = rbug_screen_create(screen); screen = trace_screen_create(screen); screen = noop_screen_create(screen); |