summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2009-06-12 12:09:34 -0400
committerAlex Deucher <alexdeucher@gmail.com>2009-06-12 12:09:34 -0400
commit1036ef2bf468611d37b5df06fc4424f2002e3837 (patch)
treef0859a6d903c2570a0a00c918da88139f8f7d065 /src/gallium/auxiliary
parent917f8bc1a85e61311cef6478127b387df70fba14 (diff)
parent1cd0afffc9edbcac690f8ab436aecfced26b0aba (diff)
Merge master and fix conflicts
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c14
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c14
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_cull.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_flatshade.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_twoside.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_unfilled.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_validate.c11
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_point.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch.c10
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos_machine.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c6
-rw-r--r--src/gallium/auxiliary/gallivm/instructionssoa.cpp2
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.c160
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.py1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c19
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c102
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c2
-rw-r--r--src/gallium/auxiliary/rbug/Makefile14
-rw-r--r--src/gallium/auxiliary/rbug/README21
-rw-r--r--src/gallium/auxiliary/rbug/SConscript14
-rw-r--r--src/gallium/auxiliary/rbug/rbug.h33
-rw-r--r--src/gallium/auxiliary/rbug/rbug_connection.c167
-rw-r--r--src/gallium/auxiliary/rbug/rbug_connection.h45
-rw-r--r--src/gallium/auxiliary/rbug/rbug_context.c759
-rw-r--r--src/gallium/auxiliary/rbug/rbug_context.h212
-rw-r--r--src/gallium/auxiliary/rbug/rbug_core.c359
-rw-r--r--src/gallium/auxiliary/rbug/rbug_core.h105
-rw-r--r--src/gallium/auxiliary/rbug/rbug_demarshal.c93
-rw-r--r--src/gallium/auxiliary/rbug/rbug_internal.h100
-rw-r--r--src/gallium/auxiliary/rbug/rbug_proto.h94
-rw-r--r--src/gallium/auxiliary/rbug/rbug_shader.c468
-rw-r--r--src/gallium/auxiliary/rbug/rbug_shader.h142
-rw-r--r--src/gallium/auxiliary/rbug/rbug_texture.c631
-rw-r--r--src/gallium/auxiliary/rbug/rbug_texture.h206
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_cpu.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c62
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c133
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_transform.c27
-rw-r--r--src/gallium/auxiliary/trace/trace_drm.h165
-rw-r--r--src/gallium/auxiliary/util/Makefile2
-rw-r--r--src/gallium/auxiliary/util/SConscript2
-rw-r--r--src/gallium/auxiliary/util/u_blit.c5
-rw-r--r--src/gallium/auxiliary/util/u_debug.c58
-rw-r--r--src/gallium/auxiliary/util/u_debug.h21
-rw-r--r--src/gallium/auxiliary/util/u_debug_stack.c11
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c100
-rw-r--r--src/gallium/auxiliary/util/u_linear.c31
-rw-r--r--src/gallium/auxiliary/util/u_linear.h31
-rw-r--r--src/gallium/auxiliary/util/u_network.c188
-rw-r--r--src/gallium/auxiliary/util/u_network.h24
-rw-r--r--src/gallium/auxiliary/util/u_surface.c113
-rw-r--r--src/gallium/auxiliary/util/u_surface.h52
-rw-r--r--src/gallium/auxiliary/util/u_tile.c17
-rw-r--r--src/gallium/auxiliary/util/u_time.c5
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.c30
67 files changed, 4656 insertions, 262 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe.h b/src/gallium/auxiliary/draw/draw_pipe.h
index dbad8f98ac..479250729f 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.h
+++ b/src/gallium/auxiliary/draw/draw_pipe.h
@@ -57,6 +57,7 @@ struct draw_stage
struct draw_context *draw; /**< parent context */
struct draw_stage *next; /**< next stage in pipeline */
+ const char *name; /**< for debugging */
struct vertex_header **tmp; /**< temp vert storage, such as for clipping */
unsigned nr_tmps;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index ca69f0b95e..9f956715a2 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -60,8 +60,6 @@ struct aaline_fragment_shader
struct pipe_shader_state state;
void *driver_fs;
void *aaline_fs;
- void *aapoint_fs; /* not yet */
- void *sprite_fs; /* not yet */
uint sampler_unit;
int generic_attrib; /**< texcoord/generic used for texture */
};
@@ -373,10 +371,15 @@ generate_aaline_fs(struct aaline_stage *aaline)
aaline->fs->aaline_fs
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
if (aaline->fs->aaline_fs == NULL)
- return FALSE;
+ goto fail;
aaline->fs->generic_attrib = transform.maxGeneric + 1;
+ FREE((void *)aaline_fs.tokens);
return TRUE;
+
+fail:
+ FREE((void *)aaline_fs.tokens);
+ return FALSE;
}
@@ -746,6 +749,7 @@ draw_aaline_stage(struct draw_context *draw)
goto fail;
aaline->stage.draw = draw;
+ aaline->stage.name = "aaline";
aaline->stage.next = NULL;
aaline->stage.point = draw_pipe_passthrough_point;
aaline->stage.line = aaline_first_line;
@@ -815,6 +819,10 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
/* pass-through */
aaline->driver_delete_fs_state(aaline->pipe, aafs->driver_fs);
+
+ if (aafs->aaline_fs)
+ aaline->driver_delete_fs_state(aaline->pipe, aafs->aaline_fs);
+
FREE(aafs);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index 3133abe5dc..ae1712fe12 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -523,11 +523,15 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
aapoint->fs->aapoint_fs
= aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
if (aapoint->fs->aapoint_fs == NULL)
- return FALSE;
+ goto fail;
aapoint->fs->generic_attrib = transform.maxGeneric + 1;
-
+ FREE((void *)aapoint_fs.tokens);
return TRUE;
+
+fail:
+ FREE((void *)aapoint_fs.tokens);
+ return FALSE;
}
@@ -757,6 +761,7 @@ draw_aapoint_stage(struct draw_context *draw)
goto fail;
aapoint->stage.draw = draw;
+ aapoint->stage.name = "aapoint";
aapoint->stage.next = NULL;
aapoint->stage.point = aapoint_first_point;
aapoint->stage.line = draw_pipe_passthrough_line;
@@ -824,8 +829,13 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
{
struct aapoint_stage *aapoint = aapoint_stage_from_pipe(pipe);
struct aapoint_fragment_shader *aafs = (struct aapoint_fragment_shader *) fs;
+
/* pass-through */
aapoint->driver_delete_fs_state(aapoint->pipe, aafs->driver_fs);
+
+ if (aafs->aapoint_fs)
+ aapoint->driver_delete_fs_state(aapoint->pipe, aafs->aapoint_fs);
+
FREE(aafs);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 3265dcd154..0670268a19 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -496,6 +496,7 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw )
goto fail;
clipper->stage.draw = draw;
+ clipper->stage.name = "clipper";
clipper->stage.point = clip_point;
clipper->stage.line = clip_first_line;
clipper->stage.tri = clip_first_tri;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index 053be5f050..0a70483858 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -129,6 +129,7 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw )
goto fail;
cull->stage.draw = draw;
+ cull->stage.name = "cull";
cull->stage.next = NULL;
cull->stage.point = draw_pipe_passthrough_point;
cull->stage.line = draw_pipe_passthrough_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
index 43d1fecc4d..34afb1a0b6 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
@@ -261,6 +261,7 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
goto fail;
flatshade->stage.draw = draw;
+ flatshade->stage.name = "flatshade";
flatshade->stage.next = NULL;
flatshade->stage.point = draw_pipe_passthrough_point;
flatshade->stage.line = flatshade_first_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 62c31532d0..40798a5d6e 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -166,6 +166,7 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw )
draw_alloc_temp_verts( &offset->stage, 3 );
offset->stage.draw = draw;
+ offset->stage.name = "offset";
offset->stage.next = NULL;
offset->stage.point = draw_pipe_passthrough_point;
offset->stage.line = draw_pipe_passthrough_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 04e59152c5..30a6d2919d 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -358,6 +358,7 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
+ FREE((void *)pstip_fs.tokens);
return TRUE;
}
@@ -586,6 +587,7 @@ draw_pstip_stage(struct draw_context *draw)
draw_alloc_temp_verts( &pstip->stage, 8 );
pstip->stage.draw = draw;
+ pstip->stage.name = "pstip";
pstip->stage.next = NULL;
pstip->stage.point = draw_pipe_passthrough_point;
pstip->stage.line = draw_pipe_passthrough_line;
@@ -648,6 +650,10 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
struct pstip_fragment_shader *aafs = (struct pstip_fragment_shader *) fs;
/* pass-through */
pstip->driver_delete_fs_state(pstip->pipe, aafs->driver_fs);
+
+ if (aafs->pstip_fs)
+ pstip->driver_delete_fs_state(pstip->pipe, aafs->pstip_fs);
+
FREE(aafs);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index b65e2aa102..6e921bac27 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -238,6 +238,7 @@ struct draw_stage *draw_stipple_stage( struct draw_context *draw )
draw_alloc_temp_verts( &stipple->stage, 2 );
stipple->stage.draw = draw;
+ stipple->stage.name = "stipple";
stipple->stage.next = NULL;
stipple->stage.point = stipple_reset_point;
stipple->stage.line = stipple_first_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
index c329d92339..eef0238b15 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
@@ -181,6 +181,7 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw )
goto fail;
twoside->stage.draw = draw;
+ twoside->stage.name = "twoside";
twoside->stage.next = NULL;
twoside->stage.point = draw_pipe_passthrough_point;
twoside->stage.line = draw_pipe_passthrough_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
index 68835fd1a5..03bb842e20 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
@@ -184,6 +184,7 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
goto fail;
unfilled->stage.draw = draw;
+ unfilled->stage.name = "unfilled";
unfilled->stage.next = NULL;
unfilled->stage.tmp = NULL;
unfilled->stage.point = draw_pipe_passthrough_point;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c
index 03e842ce08..bea90e50d3 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_validate.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c
@@ -262,7 +262,15 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
draw->pipeline.first = next;
- return next;
+
+ if (0) {
+ debug_printf("draw pipeline:\n");
+ for (next = draw->pipeline.first; next ; next = next->next )
+ debug_printf(" %s\n", next->name);
+ debug_printf("\n");
+ }
+
+ return draw->pipeline.first;
}
static void validate_tri( struct draw_stage *stage,
@@ -318,6 +326,7 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw )
return NULL;
stage->draw = draw;
+ stage->name = "validate";
stage->next = NULL;
stage->point = validate_point;
stage->line = validate_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index 12325d30d6..a5d840b96e 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -446,6 +446,7 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
goto fail;
vbuf->stage.draw = draw;
+ vbuf->stage.name = "vbuf";
vbuf->stage.point = vbuf_first_point;
vbuf->stage.line = vbuf_first_line;
vbuf->stage.tri = vbuf_first_tri;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index 184e363594..f32cbef983 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -168,6 +168,7 @@ struct draw_stage *draw_wide_line_stage( struct draw_context *draw )
draw_alloc_temp_verts( &wide->stage, 4 );
wide->stage.draw = draw;
+ wide->stage.name = "wide-line";
wide->stage.next = NULL;
wide->stage.point = draw_pipe_passthrough_point;
wide->stage.line = wideline_line;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index e1af9e56a2..d84bab9eaa 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -253,6 +253,7 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags )
{
stage->point = widepoint_first_point;
stage->next->flush( stage->next, flags );
+ stage->draw->extra_vp_outputs.slot = 0;
}
@@ -279,6 +280,7 @@ struct draw_stage *draw_wide_point_stage( struct draw_context *draw )
goto fail;
wide->stage.draw = draw;
+ wide->stage.name = "wide-point";
wide->stage.next = NULL;
wide->stage.point = widepoint_first_point;
wide->stage.line = draw_pipe_passthrough_line;
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index 6f3e1e0289..8ef0ea8011 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -187,6 +187,7 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw );
struct pt_fetch;
void draw_pt_fetch_prepare( struct pt_fetch *fetch,
+ unsigned vertex_input_count,
unsigned vertex_size );
void draw_pt_fetch_run( struct pt_fetch *fetch,
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 058caf7dcc..65c3a34c34 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -26,6 +26,7 @@
**************************************************************************/
#include "util/u_memory.h"
+#include "util/u_math.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
@@ -56,9 +57,11 @@ struct pt_fetch {
*
*/
void draw_pt_fetch_prepare( struct pt_fetch *fetch,
+ unsigned vs_input_count,
unsigned vertex_size )
{
struct draw_context *draw = fetch->draw;
+ unsigned nr_inputs;
unsigned i, nr = 0;
unsigned dst_offset = 0;
struct translate_key key;
@@ -89,8 +92,11 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
dst_offset += 4 * sizeof(float);
}
+ assert( draw->pt.nr_vertex_elements >= vs_input_count );
- for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
+ nr_inputs = MIN2( vs_input_count, draw->pt.nr_vertex_elements );
+
+ for (i = 0; i < nr_inputs; i++) {
key.element[nr].input_format = draw->pt.vertex_element[i].src_format;
key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index;
key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset;
@@ -114,7 +120,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
fetch->translate = translate_cache_find(fetch->cache, &key);
{
- static struct vertex_header vh = { 0, 1, 0, 0xffff };
+ static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } };
fetch->translate->set_buffer(fetch->translate,
draw->pt.nr_vertex_buffers,
&vh,
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index 6b7d02a19b..e7fe6b3b76 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -130,6 +130,10 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
unsigned output_format;
switch (vinfo->attrib[i].emit) {
+ case EMIT_4UB:
+ output_format = PIPE_FORMAT_R8G8B8A8_UNORM;
+ emit_sz = 4 * sizeof(unsigned char);
+ break;
case EMIT_4F:
output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
emit_sz = 4 * sizeof(float);
@@ -153,6 +157,8 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
output_format = PIPE_FORMAT_R32_FLOAT;
emit_sz = 1 * sizeof(float);
break;
+ case EMIT_OMIT:
+ continue;
default:
assert(0);
output_format = PIPE_FORMAT_NONE;
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index 11ac90fc56..df6c265b7e 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -77,8 +77,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
draw_pt_fetch_prepare( fpme->fetch,
+ vs->info.num_inputs,
fpme->vertex_size );
-
/* XXX: it's not really gl rasterization rules we care about here,
* but gl vs dx9 clip spaces.
*/
diff --git a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
index 55a8e6521d..010c7a18a7 100644
--- a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
+++ b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h
@@ -9,7 +9,7 @@ static void FUNC(struct draw_pt_front_end *frontend,
unsigned count)
{
struct varray_frontend *varray = (struct varray_frontend *)frontend;
- unsigned start = (unsigned)elts;
+ unsigned start = (unsigned) ((char *) elts - (char *) NULL);
unsigned j;
unsigned first, incr;
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
index b358bd2df4..3240e3745d 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
@@ -74,7 +74,7 @@ void PIPE_CDECL aos_do_lit( struct aos_machine *machine,
{
result[0] = 1.0F;
result[1] = in[0];
- result[2] = 1.0;
+ result[2] = 0.0F;
result[3] = 1.0F;
}
else
@@ -108,7 +108,7 @@ static void PIPE_CDECL do_lit_lut( struct aos_machine *machine,
{
result[0] = 1.0F;
result[1] = in[0];
- result[2] = 1.0;
+ result[2] = 0.0F;
result[3] = 1.0F;
return;
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index dbbc33fffa..f2368dde5c 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -114,6 +114,12 @@ vs_exec_run_linear( struct draw_vertex_shader *shader,
#endif
for (slot = 0; slot < shader->info.num_inputs; slot++) {
+#if 0
+ assert(!util_is_inf_or_nan(input[slot][0]));
+ assert(!util_is_inf_or_nan(input[slot][1]));
+ assert(!util_is_inf_or_nan(input[slot][2]));
+ assert(!util_is_inf_or_nan(input[slot][3]));
+#endif
machine->Inputs[slot].xyzw[0].f[j] = input[slot][0];
machine->Inputs[slot].xyzw[1].f[j] = input[slot][1];
machine->Inputs[slot].xyzw[2].f[j] = input[slot][2];
diff --git a/src/gallium/auxiliary/gallivm/instructionssoa.cpp b/src/gallium/auxiliary/gallivm/instructionssoa.cpp
index 925e948763..2d2af3085e 100644
--- a/src/gallium/auxiliary/gallivm/instructionssoa.cpp
+++ b/src/gallium/auxiliary/gallivm/instructionssoa.cpp
@@ -24,6 +24,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
+
+#include <cstdio>
#include "instructionssoa.h"
#include "storagesoa.h"
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.c b/src/gallium/auxiliary/indices/u_unfilled_gen.c
index fd082ebbb3..93897c98de 100644
--- a/src/gallium/auxiliary/indices/u_unfilled_gen.c
+++ b/src/gallium/auxiliary/indices/u_unfilled_gen.c
@@ -71,13 +71,10 @@ static void generate_tris_ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (ushort)(i);
(out+j)[1] = (ushort)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(i);
}
@@ -90,13 +87,10 @@ static void generate_tristrip_ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (ushort)(i);
(out+j)[1] = (ushort)(i+1/*+(i&1)*/);
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (ushort)(i+1/*+(i&1)*/);
(out+j+2)[1] = (ushort)(i+2/*-(i&1)*/);
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (ushort)(i+2/*-(i&1)*/);
(out+j+4)[1] = (ushort)(i);
}
@@ -109,13 +103,10 @@ static void generate_trifan_ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)(0);
(out+j)[1] = (ushort)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(0);
}
@@ -128,16 +119,12 @@ static void generate_quads_ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (ushort)(i+0);
(out+j)[1] = (ushort)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(i+3);
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (ushort)(i+3);
(out+j+6)[1] = (ushort)(i+0);
}
@@ -150,16 +137,12 @@ static void generate_quadstrip_ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (ushort)(i+2);
(out+j)[1] = (ushort)(i+0);
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (ushort)(i+0);
(out+j+2)[1] = (ushort)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (ushort)(i+1);
(out+j+4)[1] = (ushort)(i+3);
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (ushort)(i+3);
(out+j+6)[1] = (ushort)(i+2);
}
@@ -172,13 +155,10 @@ static void generate_polygon_ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)(0);
(out+j)[1] = (ushort)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(0);
}
@@ -191,13 +171,10 @@ static void generate_tris_uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (uint)(i);
(out+j)[1] = (uint)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(i);
}
@@ -210,13 +187,10 @@ static void generate_tristrip_uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (uint)(i);
(out+j)[1] = (uint)(i+1/*+(i&1)*/);
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (uint)(i+1/*+(i&1)*/);
(out+j+2)[1] = (uint)(i+2/*-(i&1)*/);
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (uint)(i+2/*-(i&1)*/);
(out+j+4)[1] = (uint)(i);
}
@@ -229,13 +203,10 @@ static void generate_trifan_uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)(0);
(out+j)[1] = (uint)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(0);
}
@@ -248,16 +219,12 @@ static void generate_quads_uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (uint)(i+0);
(out+j)[1] = (uint)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(i+3);
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (uint)(i+3);
(out+j+6)[1] = (uint)(i+0);
}
@@ -270,16 +237,12 @@ static void generate_quadstrip_uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (uint)(i+2);
(out+j)[1] = (uint)(i+0);
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (uint)(i+0);
(out+j+2)[1] = (uint)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (uint)(i+1);
(out+j+4)[1] = (uint)(i+3);
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (uint)(i+3);
(out+j+6)[1] = (uint)(i+2);
}
@@ -292,13 +255,10 @@ static void generate_polygon_uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)(0);
(out+j)[1] = (uint)(i+1);
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(0);
}
@@ -313,13 +273,10 @@ static void translate_tris_ubyte2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i];
}
@@ -334,13 +291,10 @@ static void translate_tristrip_ubyte2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (ushort)in[i];
}
@@ -355,13 +309,10 @@ static void translate_trifan_ubyte2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
@@ -376,16 +327,12 @@ static void translate_quads_ubyte2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (ushort)in[i+0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+0];
}
@@ -400,16 +347,12 @@ static void translate_quadstrip_ubyte2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (ushort)in[i+2];
(out+j)[1] = (ushort)in[i+0];
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (ushort)in[i+0];
(out+j+2)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (ushort)in[i+1];
(out+j+4)[1] = (ushort)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+2];
}
@@ -424,13 +367,10 @@ static void translate_polygon_ubyte2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
@@ -445,13 +385,10 @@ static void translate_tris_ubyte2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i];
}
@@ -466,13 +403,10 @@ static void translate_tristrip_ubyte2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1/*+(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (uint)in[i];
}
@@ -487,13 +421,10 @@ static void translate_trifan_ubyte2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
@@ -508,16 +439,12 @@ static void translate_quads_ubyte2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (uint)in[i+0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+0];
}
@@ -532,16 +459,12 @@ static void translate_quadstrip_ubyte2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (uint)in[i+2];
(out+j)[1] = (uint)in[i+0];
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (uint)in[i+0];
(out+j+2)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (uint)in[i+1];
(out+j+4)[1] = (uint)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+2];
}
@@ -556,13 +479,10 @@ static void translate_polygon_ubyte2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
@@ -577,13 +497,10 @@ static void translate_tris_ushort2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i];
}
@@ -598,13 +515,10 @@ static void translate_tristrip_ushort2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (ushort)in[i];
}
@@ -619,13 +533,10 @@ static void translate_trifan_ushort2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
@@ -640,16 +551,12 @@ static void translate_quads_ushort2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (ushort)in[i+0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+0];
}
@@ -664,16 +571,12 @@ static void translate_quadstrip_ushort2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (ushort)in[i+2];
(out+j)[1] = (ushort)in[i+0];
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (ushort)in[i+0];
(out+j+2)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (ushort)in[i+1];
(out+j+4)[1] = (ushort)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+2];
}
@@ -688,13 +591,10 @@ static void translate_polygon_ushort2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
@@ -709,13 +609,10 @@ static void translate_tris_ushort2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i];
}
@@ -730,13 +627,10 @@ static void translate_tristrip_ushort2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1/*+(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (uint)in[i];
}
@@ -751,13 +645,10 @@ static void translate_trifan_ushort2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
@@ -772,16 +663,12 @@ static void translate_quads_ushort2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (uint)in[i+0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+0];
}
@@ -796,16 +683,12 @@ static void translate_quadstrip_ushort2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (uint)in[i+2];
(out+j)[1] = (uint)in[i+0];
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (uint)in[i+0];
(out+j+2)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (uint)in[i+1];
(out+j+4)[1] = (uint)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+2];
}
@@ -820,13 +703,10 @@ static void translate_polygon_ushort2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
@@ -841,13 +721,10 @@ static void translate_tris_uint2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i];
}
@@ -862,13 +739,10 @@ static void translate_tristrip_uint2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (ushort)in[i];
}
@@ -883,13 +757,10 @@ static void translate_trifan_uint2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
@@ -904,16 +775,12 @@ static void translate_quads_uint2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (ushort)in[i+0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+0];
}
@@ -928,16 +795,12 @@ static void translate_quadstrip_uint2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (ushort)in[i+2];
(out+j)[1] = (ushort)in[i+0];
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (ushort)in[i+0];
(out+j+2)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (ushort)in[i+1];
(out+j+4)[1] = (ushort)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+2];
}
@@ -952,13 +815,10 @@ static void translate_polygon_uint2ushort(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
@@ -973,13 +833,10 @@ static void translate_tris_uint2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1);
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i];
}
@@ -994,13 +851,10 @@ static void translate_tristrip_uint2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)i, (int)i+1/*+(i&1)*/);
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1/*+(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+1/*+(i&1)*/, (int)i+2/*-(i&1)*/);
(out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
- debug_printf(" line %d %d\n", (int)i+2/*-(i&1)*/, (int)i);
(out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (uint)in[i];
}
@@ -1015,13 +869,10 @@ static void translate_trifan_uint2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
@@ -1036,16 +887,12 @@ static void translate_quads_uint2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j)[0] = (uint)in[i+0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)i+3);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+0);
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+0];
}
@@ -1060,16 +907,12 @@ static void translate_quadstrip_uint2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
- debug_printf(" line %d %d\n", (int)i+2, (int)i+0);
(out+j)[0] = (uint)in[i+2];
(out+j)[1] = (uint)in[i+0];
- debug_printf(" line %d %d\n", (int)i+0, (int)i+1);
(out+j+2)[0] = (uint)in[i+0];
(out+j+2)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+3);
(out+j+4)[0] = (uint)in[i+1];
(out+j+4)[1] = (uint)in[i+3];
- debug_printf(" line %d %d\n", (int)i+3, (int)i+2);
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+2];
}
@@ -1084,13 +927,10 @@ static void translate_polygon_uint2uint(
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
- debug_printf(" line %d %d\n", (int)0, (int)i+1);
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
- debug_printf(" line %d %d\n", (int)i+1, (int)i+2);
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
- debug_printf(" line %d %d\n", (int)i+2, (int)0);
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py
index d0344fe313..36896ce605 100644
--- a/src/gallium/auxiliary/indices/u_unfilled_gen.py
+++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py
@@ -99,7 +99,6 @@ def vert( intype, outtype, v0 ):
return '(' + outtype + ')in[' + v0 + ']'
def line( intype, outtype, ptr, v0, v1 ):
- print ' debug_printf(" line %d %d\\n", (int)' + v0 + ', (int)' + v1 + ');'
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index 2cd0b8a8cd..4698efa69c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -365,21 +365,22 @@ fenced_buffer_validate(struct pb_buffer *buf,
if(fenced_buf->vl && fenced_buf->vl != vl)
return PIPE_ERROR_RETRY;
+#if 0
/* Do not validate if buffer is still mapped */
if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) {
/* TODO: wait for the thread that mapped the buffer to unmap it */
return PIPE_ERROR_RETRY;
}
+ /* Final sanity checking */
+ assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
+ assert(!fenced_buf->mapcount);
+#endif
if(fenced_buf->vl == vl &&
(fenced_buf->validation_flags & flags) == flags) {
/* Nothing to do -- buffer already validated */
return PIPE_OK;
}
-
- /* Final sanity checking */
- assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
- assert(!fenced_buf->mapcount);
ret = pb_validate(fenced_buf->buffer, vl, flags);
if (ret != PIPE_OK)
@@ -530,16 +531,17 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
pipe_mutex_lock(fenced_list->mutex);
- debug_printf("%10s %7s %10s %s\n",
- "buffer", "reference.count", "fence", "signalled");
+ debug_printf("%10s %7s %7s %10s %s\n",
+ "buffer", "size", "refcount", "fence", "signalled");
curr = fenced_list->unfenced.next;
next = curr->next;
while(curr != &fenced_list->unfenced) {
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
assert(!fenced_buf->fence);
- debug_printf("%10p %7u\n",
+ debug_printf("%10p %7u %7u\n",
fenced_buf,
+ fenced_buf->base.base.size,
fenced_buf->base.base.reference.count);
curr = next;
next = curr->next;
@@ -551,8 +553,9 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
int signaled;
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
- debug_printf("%10p %7u %10p %s\n",
+ debug_printf("%10p %7u %7u %10p %s\n",
fenced_buf,
+ fenced_buf->base.base.size,
fenced_buf->base.base.reference.count,
fenced_buf->fence,
signaled == 0 ? "y" : "n");
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index f1a05be46e..cedf745bda 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -40,6 +40,7 @@
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"
+#include "util/u_debug_stack.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
@@ -48,6 +49,10 @@
#ifdef DEBUG
+#define PB_DEBUG_CREATE_BACKTRACE 8
+#define PB_DEBUG_MAP_BACKTRACE 8
+
+
/**
* Convenience macro (type safe).
*/
@@ -69,6 +74,14 @@ struct pb_debug_buffer
size_t underflow_size;
size_t overflow_size;
+
+ struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE];
+
+ pipe_mutex mutex;
+ unsigned map_count;
+ struct debug_stack_frame map_backtrace[PB_DEBUG_MAP_BACKTRACE];
+
+ struct list_head head;
};
@@ -80,6 +93,9 @@ struct pb_debug_manager
size_t underflow_size;
size_t overflow_size;
+
+ pipe_mutex mutex;
+ struct list_head list;
};
@@ -189,6 +205,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
max_ofs == buf->overflow_size - 1 ? "+" : "");
}
+ if(underflow || overflow)
+ debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE);
+
debug_assert(!underflow && !overflow);
/* re-fill if not aborted */
@@ -207,11 +226,18 @@ static void
pb_debug_buffer_destroy(struct pb_buffer *_buf)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+ struct pb_debug_manager *mgr = buf->mgr;
assert(!pipe_is_referenced(&buf->base.base.reference));
pb_debug_buffer_check(buf);
+ pipe_mutex_lock(mgr->mutex);
+ LIST_DEL(&buf->head);
+ pipe_mutex_unlock(mgr->mutex);
+
+ pipe_mutex_destroy(buf->mutex);
+
pb_reference(&buf->buffer, NULL);
FREE(buf);
}
@@ -230,6 +256,13 @@ pb_debug_buffer_map(struct pb_buffer *_buf,
if(!map)
return NULL;
+ if(map) {
+ pipe_mutex_lock(buf->mutex);
+ ++buf->map_count;
+ debug_backtrace_capture(buf->map_backtrace, 1, PB_DEBUG_MAP_BACKTRACE);
+ pipe_mutex_unlock(buf->mutex);
+ }
+
return (uint8_t *)map + buf->underflow_size;
}
@@ -238,6 +271,13 @@ static void
pb_debug_buffer_unmap(struct pb_buffer *_buf)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+
+ pipe_mutex_lock(buf->mutex);
+ assert(buf->map_count);
+ if(buf->map_count)
+ --buf->map_count;
+ pipe_mutex_unlock(buf->mutex);
+
pb_unmap(buf->buffer);
pb_debug_buffer_check(buf);
@@ -262,6 +302,14 @@ pb_debug_buffer_validate(struct pb_buffer *_buf,
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+ pipe_mutex_lock(buf->mutex);
+ if(buf->map_count) {
+ debug_printf("%s: attempting to validate a mapped buffer\n", __FUNCTION__);
+ debug_printf("last map backtrace is\n");
+ debug_backtrace_dump(buf->map_backtrace, PB_DEBUG_MAP_BACKTRACE);
+ }
+ pipe_mutex_unlock(buf->mutex);
+
pb_debug_buffer_check(buf);
return pb_validate(buf->buffer, vl, flags);
@@ -288,6 +336,31 @@ pb_debug_buffer_vtbl = {
};
+static void
+pb_debug_manager_dump(struct pb_debug_manager *mgr)
+{
+ struct list_head *curr, *next;
+ struct pb_debug_buffer *buf;
+
+ pipe_mutex_lock(mgr->mutex);
+
+ curr = mgr->list.next;
+ next = curr->next;
+ while(curr != &mgr->list) {
+ buf = LIST_ENTRY(struct pb_debug_buffer, curr, head);
+
+ debug_printf("buffer = %p\n", buf);
+ debug_printf(" .size = %p\n", buf->base.base.size);
+ debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE);
+
+ curr = next;
+ next = curr->next;
+ }
+
+ pipe_mutex_unlock(mgr->mutex);
+}
+
+
static struct pb_buffer *
pb_debug_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
@@ -312,6 +385,13 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
&real_desc);
if(!buf->buffer) {
FREE(buf);
+#if 0
+ pipe_mutex_lock(mgr->mutex);
+ debug_printf("%s: failed to create buffer\n", __FUNCTION__);
+ if(!LIST_IS_EMPTY(&mgr->list))
+ pb_debug_manager_dump(mgr);
+ pipe_mutex_unlock(mgr->mutex);
+#endif
return NULL;
}
@@ -331,8 +411,16 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
buf->underflow_size = mgr->underflow_size;
buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size;
+ debug_backtrace_capture(buf->create_backtrace, 1, PB_DEBUG_CREATE_BACKTRACE);
+
pb_debug_buffer_fill(buf);
+ pipe_mutex_init(buf->mutex);
+
+ pipe_mutex_lock(mgr->mutex);
+ LIST_ADDTAIL(&buf->head, &mgr->list);
+ pipe_mutex_unlock(mgr->mutex);
+
return &buf->base;
}
@@ -351,6 +439,15 @@ static void
pb_debug_manager_destroy(struct pb_manager *_mgr)
{
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
+
+ pipe_mutex_lock(mgr->mutex);
+ if(!LIST_IS_EMPTY(&mgr->list)) {
+ debug_printf("%s: unfreed buffers\n", __FUNCTION__);
+ pb_debug_manager_dump(mgr);
+ }
+ pipe_mutex_unlock(mgr->mutex);
+
+ pipe_mutex_destroy(mgr->mutex);
mgr->provider->destroy(mgr->provider);
FREE(mgr);
}
@@ -375,7 +472,10 @@ pb_debug_manager_create(struct pb_manager *provider,
mgr->provider = provider;
mgr->underflow_size = underflow_size;
mgr->overflow_size = overflow_size;
-
+
+ pipe_mutex_init(mgr->mutex);
+ LIST_INITHEAD(&mgr->list);
+
return &mgr->base;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 5a342fbf3b..d8decba49d 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -200,8 +200,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
if(!mm_buf->block) {
- debug_printf("warning: heap full\n");
#if 0
+ debug_printf("warning: heap full\n");
mmDumpMemInfo(mm->heap);
#endif
FREE(mm_buf);
diff --git a/src/gallium/auxiliary/rbug/Makefile b/src/gallium/auxiliary/rbug/Makefile
new file mode 100644
index 0000000000..cd12e8468f
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/Makefile
@@ -0,0 +1,14 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = rbug
+
+C_SOURCES = \
+ rbug_connection.c \
+ rbug_core.c \
+ rbug_texture.c \
+ rbug_context.c \
+ rbug_shader.c \
+ rbug_demarshal.c
+
+include ../../Makefile.template
diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README
new file mode 100644
index 0000000000..33d76371de
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/README
@@ -0,0 +1,21 @@
+ 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/drivers/trace/README
+
+for information about applications look in:
+
+progs/rbug/README
+
+
+--
+Jakob Bornecrantz <jakob@vmware.com>
diff --git a/src/gallium/auxiliary/rbug/SConscript b/src/gallium/auxiliary/rbug/SConscript
new file mode 100644
index 0000000000..4a9afb45d3
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/SConscript
@@ -0,0 +1,14 @@
+Import('*')
+
+rbug = env.ConvenienceLibrary(
+ target = 'rbug',
+ source = [
+ 'rbug_core.c',
+ 'rbug_shader.c',
+ 'rbug_context.c',
+ 'rbug_texture.c',
+ 'rbug_demarshal.c',
+ 'rbug_connection.c',
+ ])
+
+auxiliaries.insert(0, rbug)
diff --git a/src/gallium/auxiliary/rbug/rbug.h b/src/gallium/auxiliary/rbug/rbug.h
new file mode 100644
index 0000000000..259bfc6c79
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug.h
@@ -0,0 +1,33 @@
+/*
+ * 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/rbug_core.h"
+#include "rbug/rbug_shader.h"
+#include "rbug/rbug_context.h"
+#include "rbug/rbug_texture.h"
+#include "rbug/rbug_connection.h"
diff --git a/src/gallium/auxiliary/rbug/rbug_connection.c b/src/gallium/auxiliary/rbug/rbug_connection.c
new file mode 100644
index 0000000000..52acb700af
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_connection.c
@@ -0,0 +1,167 @@
+/*
+ * 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/rbug.h"
+#include "rbug/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;
+ }
+
+ 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 writeing 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
new file mode 100644
index 0000000000..1f2c9ff347
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_connection.h
@@ -0,0 +1,45 @@
+/*
+ * 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/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
new file mode 100644
index 0000000000..1832425658
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_context.c
@@ -0,0 +1,759 @@
+/*
+ * 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/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,
+ int32_t flags,
+ 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); /* flags */
+
+ /* 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 */
+ WRITE(4, int32_t, flags); /* flags */
+
+ /* 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)
+{
+ uint32_t len = 0;
+ uint32_t pos = 0;
+ uint8_t *data = NULL;
+ struct rbug_proto_context_list *ret;
+
+ if (!header)
+ return NULL;
+ if (header->opcode != (int16_t)RBUG_OP_CONTEXT_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;
+
+
+ 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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 */
+ READ(4, int32_t, flags); /* flags */
+
+ 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 != (int16_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 != (int16_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 != (int16_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
new file mode 100644
index 0000000000..da61c2365b
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_context.h
@@ -0,0 +1,212 @@
+/*
+ * 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/rbug_proto.h"
+#include "rbug/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;
+ int32_t flags;
+};
+
+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,
+ int32_t flags,
+ 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
new file mode 100644
index 0000000000..876ae5a0ce
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_core.c
@@ -0,0 +1,359 @@
+/*
+ * 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/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)
+{
+ uint32_t len = 0;
+ uint32_t pos = 0;
+ uint8_t *data = NULL;
+ struct rbug_proto_noop *ret;
+
+ if (!header)
+ return NULL;
+ if (header->opcode != (int16_t)RBUG_OP_NOOP)
+ 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;
+
+
+ return ret;
+}
+
+struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header)
+{
+ uint32_t len = 0;
+ uint32_t pos = 0;
+ uint8_t *data = NULL;
+ struct rbug_proto_ping *ret;
+
+ if (!header)
+ return NULL;
+ if (header->opcode != (int16_t)RBUG_OP_PING)
+ 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;
+
+
+ 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 != (int16_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 != (int16_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 != (int16_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
new file mode 100644
index 0000000000..99a36a0163
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_core.h
@@ -0,0 +1,105 @@
+/*
+ * 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/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
new file mode 100644
index 0000000000..47390fbcee
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c
@@ -0,0 +1,93 @@
+/*
+ * 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;
+ }
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_internal.h b/src/gallium/auxiliary/rbug/rbug_internal.h
new file mode 100644
index 0000000000..4aba1a810f
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_internal.h
@@ -0,0 +1,100 @@
+/*
+ * 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/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
new file mode 100644
index 0000000000..d273be0166
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_proto.h
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+#endif
diff --git a/src/gallium/auxiliary/rbug/rbug_shader.c b/src/gallium/auxiliary/rbug/rbug_shader.c
new file mode 100644
index 0000000000..fccd2f55ef
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_shader.c
@@ -0,0 +1,468 @@
+/*
+ * 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/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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 != (int16_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
new file mode 100644
index 0000000000..b5d886781d
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_shader.h
@@ -0,0 +1,142 @@
+/*
+ * 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/rbug_proto.h"
+#include "rbug/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
new file mode 100644
index 0000000000..5a918fe6bc
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_texture.c
@@ -0,0 +1,631 @@
+/*
+ * 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/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,
+ 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,
+ 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); /* 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;
+
+ 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)
+{
+ uint32_t len = 0;
+ uint32_t pos = 0;
+ uint8_t *data = NULL;
+ struct rbug_proto_texture_list *ret;
+
+ if (!header)
+ return NULL;
+ if (header->opcode != (int16_t)RBUG_OP_TEXTURE_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;
+
+
+ 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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 != (int16_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 != (int16_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
new file mode 100644
index 0000000000..fbb247e1d4
--- /dev/null
+++ b/src/gallium/auxiliary/rbug/rbug_texture.h
@@ -0,0 +1,206 @@
+/*
+ * 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/rbug_proto.h"
+#include "rbug/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,
+ 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,
+ 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/rtasm/rtasm_cpu.c b/src/gallium/auxiliary/rtasm/rtasm_cpu.c
index 03bdd47238..2e15751e50 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_cpu.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_cpu.c
@@ -30,6 +30,7 @@
#include "rtasm_cpu.h"
+#if defined(PIPE_ARCH_X86)
static boolean rtasm_sse_enabled(void)
{
static boolean firsttime = 1;
@@ -43,6 +44,7 @@ static boolean rtasm_sse_enabled(void)
}
return enabled;
}
+#endif
int rtasm_cpu_has_sse(void)
{
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index e8bd7cda3b..aba7a3f937 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -53,6 +53,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
+#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi_exec.h"
@@ -169,6 +170,56 @@ print_temp(const struct tgsi_exec_machine *mach, uint index)
#endif
+/**
+ * Check if there's a potential src/dst register data dependency when
+ * using SOA execution.
+ * Example:
+ * MOV T, T.yxwz;
+ * This would expand into:
+ * MOV t0, t1;
+ * MOV t1, t0;
+ * MOV t2, t3;
+ * MOV t3, t2;
+ * The second instruction will have the wrong value for t0 if executed as-is.
+ */
+static boolean
+tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst)
+{
+ uint i, chan;
+
+ uint writemask = inst->FullDstRegisters[0].DstRegister.WriteMask;
+ if (writemask == TGSI_WRITEMASK_X ||
+ writemask == TGSI_WRITEMASK_Y ||
+ writemask == TGSI_WRITEMASK_Z ||
+ writemask == TGSI_WRITEMASK_W ||
+ writemask == TGSI_WRITEMASK_NONE) {
+ /* no chance of data dependency */
+ return FALSE;
+ }
+
+ /* loop over src regs */
+ for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
+ if ((inst->FullSrcRegisters[i].SrcRegister.File ==
+ inst->FullDstRegisters[0].DstRegister.File) &&
+ (inst->FullSrcRegisters[i].SrcRegister.Index ==
+ inst->FullDstRegisters[0].DstRegister.Index)) {
+ /* loop over dest channels */
+ uint channelsWritten = 0x0;
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan) {
+ /* check if we're reading a channel that's been written */
+ uint swizzle = tgsi_util_get_full_src_register_extswizzle(&inst->FullSrcRegisters[i], chan);
+ if (swizzle <= TGSI_SWIZZLE_W &&
+ (channelsWritten & (1 << swizzle))) {
+ return TRUE;
+ }
+
+ channelsWritten |= (1 << chan);
+ }
+ }
+ }
+ return FALSE;
+}
+
/**
* Initialize machine state by expanding tokens to full instructions,
@@ -280,6 +331,17 @@ tgsi_exec_machine_bind_shader(
memcpy(instructions + numInstructions,
&parse.FullToken.FullInstruction,
sizeof(instructions[0]));
+
+#if 0
+ if (tgsi_check_soa_dependencies(&parse.FullToken.FullInstruction)) {
+ debug_printf("SOA dependency in instruction:\n");
+ tgsi_dump_instruction(&parse.FullToken.FullInstruction,
+ numInstructions);
+ }
+#else
+ (void) tgsi_check_soa_dependencies;
+#endif
+
numInstructions++;
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index 0b4b2a6fb6..da22baad3e 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -34,7 +34,7 @@
extern "C" {
#endif
-#define MAX_LABELS 1024
+#define MAX_LABELS (4 * 1024) /**< basically, max instructions */
#define NUM_CHANNELS 4 /* R,G,B,A */
#define QUAD_SIZE 4 /* 4 pixel/quad */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index d70bcd03c5..ba2bfdef06 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -1466,6 +1466,31 @@ emit_cmp(
}
}
+
+/**
+ * Check if inst src/dest regs use indirect addressing into temporary
+ * register file.
+ */
+static boolean
+indirect_temp_reference(const struct tgsi_full_instruction *inst)
+{
+ uint i;
+ for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
+ const struct tgsi_full_src_register *reg = &inst->FullSrcRegisters[i];
+ if (reg->SrcRegister.File == TGSI_FILE_TEMPORARY &&
+ reg->SrcRegister.Indirect)
+ return TRUE;
+ }
+ for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
+ const struct tgsi_full_dst_register *reg = &inst->FullDstRegisters[i];
+ if (reg->DstRegister.File == TGSI_FILE_TEMPORARY &&
+ reg->DstRegister.Indirect)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
static int
emit_instruction(
struct x86_function *func,
@@ -1473,10 +1498,15 @@ emit_instruction(
{
unsigned chan_index;
+ /* we can't handle indirect addressing into temp register file yet */
+ if (indirect_temp_reference(inst))
+ return FALSE;
+
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( func, *inst, 0, 0, chan_index );
+ emit_flr(func, 0, 0);
emit_f2it( func, 0 );
STORE( func, *inst, 0, 0, chan_index );
}
@@ -1553,7 +1583,7 @@ emit_instruction(
func,
make_xmm( 2 ),
make_xmm( 0 ),
- cc_LessThanEqual );
+ cc_LessThan );
sse_andps(
func,
make_xmm( 2 ),
@@ -2177,32 +2207,83 @@ emit_instruction(
/* 3 or 4-component normalization */
{
uint dims = (inst->Instruction.Opcode == TGSI_OPCODE_NRM) ? 3 : 4;
- /* note: cannot use xmm regs 2/3 here (see emit_rsqrt() above) */
- FETCH( func, *inst, 4, 0, CHAN_X ); /* xmm4 = src[0].x */
- FETCH( func, *inst, 5, 0, CHAN_Y ); /* xmm5 = src[0].y */
- FETCH( func, *inst, 6, 0, CHAN_Z ); /* xmm6 = src[0].z */
- if (dims == 4) {
- FETCH( func, *inst, 7, 0, CHAN_W ); /* xmm7 = src[0].w */
- }
- emit_MOV( func, 0, 4 ); /* xmm0 = xmm3 */
- emit_mul( func, 0, 4 ); /* xmm0 *= xmm3 */
- emit_MOV( func, 1, 5 ); /* xmm1 = xmm4 */
- emit_mul( func, 1, 5 ); /* xmm1 *= xmm4 */
- emit_add( func, 0, 1 ); /* xmm0 += xmm1 */
- emit_MOV( func, 1, 6 ); /* xmm1 = xmm5 */
- emit_mul( func, 1, 6 ); /* xmm1 *= xmm5 */
- emit_add( func, 0, 1 ); /* xmm0 += xmm1 */
- if (dims == 4) {
- emit_MOV( func, 1, 7 ); /* xmm1 = xmm7 */
- emit_mul( func, 1, 7 ); /* xmm1 *= xmm7 */
- emit_add( func, 0, 0 ); /* xmm0 += xmm1 */
- }
- emit_rsqrt( func, 1, 0 ); /* xmm1 = 1/sqrt(xmm0) */
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- if (chan_index < dims) {
- emit_mul( func, 4+chan_index, 1); /* xmm[4+ch] *= xmm1 */
- STORE( func, *inst, 4+chan_index, 0, chan_index );
+
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X) ||
+ IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y) ||
+ IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z) ||
+ (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W) && dims == 4)) {
+
+ /* NOTE: Cannot use xmm regs 2/3 here (see emit_rsqrt() above). */
+
+ /* xmm4 = src.x */
+ /* xmm0 = src.x * src.x */
+ FETCH(func, *inst, 0, 0, CHAN_X);
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ emit_MOV(func, 4, 0);
+ }
+ emit_mul(func, 0, 0);
+
+ /* xmm5 = src.y */
+ /* xmm0 = xmm0 + src.y * src.y */
+ FETCH(func, *inst, 1, 0, CHAN_Y);
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ emit_MOV(func, 5, 1);
+ }
+ emit_mul(func, 1, 1);
+ emit_add(func, 0, 1);
+
+ /* xmm6 = src.z */
+ /* xmm0 = xmm0 + src.z * src.z */
+ FETCH(func, *inst, 1, 0, CHAN_Z);
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ emit_MOV(func, 6, 1);
+ }
+ emit_mul(func, 1, 1);
+ emit_add(func, 0, 1);
+
+ if (dims == 4) {
+ /* xmm7 = src.w */
+ /* xmm0 = xmm0 + src.w * src.w */
+ FETCH(func, *inst, 1, 0, CHAN_W);
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ emit_MOV(func, 7, 1);
+ }
+ emit_mul(func, 1, 1);
+ emit_add(func, 0, 1);
}
+
+ /* xmm1 = 1 / sqrt(xmm0) */
+ emit_rsqrt(func, 1, 0);
+
+ /* dst.x = xmm1 * src.x */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ emit_mul(func, 4, 1);
+ STORE(func, *inst, 4, 0, CHAN_X);
+ }
+
+ /* dst.y = xmm1 * src.y */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ emit_mul(func, 5, 1);
+ STORE(func, *inst, 5, 0, CHAN_Y);
+ }
+
+ /* dst.z = xmm1 * src.z */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ emit_mul(func, 6, 1);
+ STORE(func, *inst, 6, 0, CHAN_Z);
+ }
+
+ /* dst.w = xmm1 * src.w */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X) && dims == 4) {
+ emit_mul(func, 7, 1);
+ STORE(func, *inst, 7, 0, CHAN_W);
+ }
+ }
+
+ /* dst0.w = 1.0 */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W) && dims == 3) {
+ emit_tempf(func, 0, TEMP_ONE_I, TEMP_ONE_C);
+ STORE(func, *inst, 0, 0, CHAN_W);
}
}
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c
index 062c1be938..bc9c18fd4a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_transform.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_transform.c
@@ -198,3 +198,30 @@ tgsi_transform_shader(const struct tgsi_token *tokens_in,
return ctx->ti;
}
+
+
+#include "tgsi_text.h"
+
+extern int tgsi_transform_foo( struct tgsi_token *tokens_out,
+ uint max_tokens_out );
+
+/* This function exists only so that tgsi_text_translate() doesn't get
+ * magic-ed out of the libtgsi.a archive by the build system. Don't
+ * remove unless you know this has been fixed - check on mingw/scons
+ * builds as well.
+ */
+int
+tgsi_transform_foo( struct tgsi_token *tokens_out,
+ uint max_tokens_out )
+{
+ const char *text =
+ "FRAG1.1\n"
+ "DCL IN[0], COLOR, CONSTANT\n"
+ "DCL OUT[0], COLOR\n"
+ " 0: MOV OUT[0], IN[0]\n"
+ " 1: END";
+
+ return tgsi_text_translate( text,
+ tokens_out,
+ max_tokens_out );
+}
diff --git a/src/gallium/auxiliary/trace/trace_drm.h b/src/gallium/auxiliary/trace/trace_drm.h
new file mode 100644
index 0000000000..892bd9860c
--- /dev/null
+++ b/src/gallium/auxiliary/trace/trace_drm.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2009 Jakob Bornecrantz <jakob@vmware.com>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * 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
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef TRACE_DRM_H
+#define TRACE_DRM_H
+
+#include "state_tracker/drm_api.h"
+
+#include "trace/tr_buffer.h"
+#include "trace/tr_context.h"
+#include "trace/tr_screen.h"
+#include "trace/tr_texture.h"
+
+struct drm_api hooks;
+
+static struct pipe_screen *
+trace_drm_create_screen(int fd, struct drm_create_screen_arg *arg)
+{
+ struct pipe_screen *screen;
+
+ if (arg && arg->mode != DRM_CREATE_NORMAL)
+ return NULL;
+
+ screen = hooks.create_screen(fd, arg);
+
+ return trace_screen_create(screen);
+};
+
+static struct pipe_context *
+trace_drm_create_context(struct pipe_screen *_screen)
+{
+ struct pipe_screen *screen;
+ struct pipe_context *pipe;
+
+ if (trace_enabled())
+ screen = trace_screen(_screen)->screen;
+ else
+ screen = _screen;
+
+ pipe = hooks.create_context(screen);
+
+ if (trace_enabled())
+ pipe = trace_context_create(_screen, pipe);
+
+ return pipe;
+};
+
+static boolean
+trace_drm_buffer_from_texture(struct pipe_texture *_texture,
+ struct pipe_buffer **_buffer,
+ unsigned *stride)
+{
+ struct pipe_texture *texture;
+ struct pipe_buffer *buffer = NULL;
+ boolean result;
+
+ if (trace_enabled())
+ texture = trace_texture(_texture)->texture;
+ else
+ texture = _texture;
+
+ result = hooks.buffer_from_texture(texture, &buffer, stride);
+
+ if (result && _buffer)
+ buffer = trace_buffer_create(trace_screen(texture->screen), buffer);
+
+ if (_buffer)
+ *_buffer = buffer;
+ else
+ pipe_buffer_reference(&buffer, NULL);
+
+ return result;
+}
+
+static struct pipe_buffer *
+trace_drm_buffer_from_handle(struct pipe_screen *_screen,
+ const char *name,
+ unsigned handle)
+{
+ struct pipe_screen *screen;
+ struct pipe_buffer *result;
+
+ if (trace_enabled())
+ screen = trace_screen(_screen)->screen;
+ else
+ screen = _screen;
+
+ result = hooks.buffer_from_handle(screen, name, handle);
+
+ if (trace_enabled())
+ result = trace_buffer_create(trace_screen(_screen), result);
+
+ return result;
+}
+
+static boolean
+trace_drm_handle_from_buffer(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer,
+ unsigned *handle)
+{
+ struct pipe_screen *screen;
+ struct pipe_buffer *buffer;
+
+ if (trace_enabled()) {
+ screen = trace_screen(_screen)->screen;
+ buffer = trace_buffer(_buffer)->buffer;
+ } else {
+ screen = _screen;
+ buffer = _buffer;
+ }
+
+ return hooks.handle_from_buffer(screen, buffer, handle);
+}
+
+static boolean
+trace_drm_global_handle_from_buffer(struct pipe_screen *_screen,
+ struct pipe_buffer *_buffer,
+ unsigned *handle)
+{
+ struct pipe_screen *screen;
+ struct pipe_buffer *buffer;
+
+ if (trace_enabled()) {
+ screen = trace_screen(_screen)->screen;
+ buffer = trace_buffer(_buffer)->buffer;
+ } else {
+ screen = _screen;
+ buffer = _buffer;
+ }
+
+ return hooks.global_handle_from_buffer(screen, buffer, handle);
+}
+
+struct drm_api drm_api_hooks =
+{
+ .create_screen = trace_drm_create_screen,
+ .create_context = trace_drm_create_context,
+
+ .buffer_from_texture = trace_drm_buffer_from_texture,
+ .buffer_from_handle = trace_drm_buffer_from_handle,
+ .handle_from_buffer = trace_drm_handle_from_buffer,
+ .global_handle_from_buffer = trace_drm_global_handle_from_buffer,
+};
+
+#endif /* TRACE_DRM_H */
diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile
index 5035e9cc13..6a8eb73e84 100644
--- a/src/gallium/auxiliary/util/Makefile
+++ b/src/gallium/auxiliary/util/Makefile
@@ -16,6 +16,7 @@ C_SOURCES = \
u_hash.c \
u_keymap.c \
u_linear.c \
+ u_network.c \
u_math.c \
u_mm.c \
u_rect.c \
@@ -23,6 +24,7 @@ C_SOURCES = \
u_snprintf.c \
u_stream_stdc.c \
u_stream_wd.c \
+ u_surface.c \
u_tile.c \
u_time.c \
u_timed_winsys.c \
diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript
index 8317263bb8..fb142eebca 100644
--- a/src/gallium/auxiliary/util/SConscript
+++ b/src/gallium/auxiliary/util/SConscript
@@ -17,6 +17,7 @@ util = env.ConvenienceLibrary(
'u_hash.c',
'u_hash_table.c',
'u_keymap.c',
+ 'u_network.c',
'u_math.c',
'u_mm.c',
'u_rect.c',
@@ -24,6 +25,7 @@ util = env.ConvenienceLibrary(
'u_snprintf.c',
'u_stream_stdc.c',
'u_stream_wd.c',
+ 'u_surface.c',
'u_tile.c',
'u_time.c',
'u_timed_winsys.c',
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index deb68c43a6..414cf91025 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -89,10 +89,6 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
/* disabled blending/masking */
memset(&ctx->blend, 0, sizeof(ctx->blend));
- ctx->blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
- ctx->blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
- ctx->blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
- ctx->blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
ctx->blend.colormask = PIPE_MASK_RGBA;
/* no-op depth/stencil/alpha */
@@ -337,7 +333,6 @@ util_blit_pixels(struct blit_state *ctx,
texTemp.width[0] = srcW;
texTemp.height[0] = srcH;
texTemp.depth[0] = 1;
- texTemp.compressed = 0;
pf_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 96a2222f9b..18597ef839 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -109,6 +109,7 @@ void _debug_vprintf(const char *format, va_list ap)
}
if(GetConsoleWindow() && !IsDebuggerPresent()) {
+ fflush(stdout);
vfprintf(stderr, format, ap);
fflush(stderr);
}
@@ -145,6 +146,7 @@ void _debug_vprintf(const char *format, va_list ap)
/* TODO */
#else /* !PIPE_SUBSYSTEM_WINDOWS */
#ifdef DEBUG
+ fflush(stdout);
vfprintf(stderr, format, ap);
#endif
#endif
@@ -719,6 +721,7 @@ void
debug_dump_surface_bmp(const char *filename,
struct pipe_surface *surface)
{
+#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
struct pipe_transfer *transfer;
struct pipe_texture *texture = surface->texture;
struct pipe_screen *screen = texture->screen;
@@ -731,6 +734,7 @@ debug_dump_surface_bmp(const char *filename,
debug_dump_transfer_bmp(filename, transfer);
screen->tex_transfer_destroy(transfer);
+#endif
}
void
@@ -738,11 +742,7 @@ debug_dump_transfer_bmp(const char *filename,
struct pipe_transfer *transfer)
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
- struct util_stream *stream;
- struct bmp_file_header bmfh;
- struct bmp_info_header bmih;
float *rgba;
- unsigned x, y;
if (!transfer)
goto error1;
@@ -751,19 +751,47 @@ debug_dump_transfer_bmp(const char *filename,
if(!rgba)
goto error1;
+ pipe_get_tile_rgba(transfer, 0, 0,
+ transfer->width, transfer->height,
+ rgba);
+
+ debug_dump_float_rgba_bmp(filename,
+ transfer->width, transfer->height,
+ rgba, transfer->width);
+
+ FREE(rgba);
+error1:
+ ;
+#endif
+}
+
+void
+debug_dump_float_rgba_bmp(const char *filename,
+ unsigned width, unsigned height,
+ float *rgba, unsigned stride)
+{
+#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
+ struct util_stream *stream;
+ struct bmp_file_header bmfh;
+ struct bmp_info_header bmih;
+ unsigned x, y;
+
+ if(!rgba)
+ goto error1;
+
bmfh.bfType = 0x4d42;
- bmfh.bfSize = 14 + 40 + transfer->height*transfer->width*4;
+ bmfh.bfSize = 14 + 40 + height*width*4;
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfOffBits = 14 + 40;
bmih.biSize = 40;
- bmih.biWidth = transfer->width;
- bmih.biHeight = transfer->height;
+ bmih.biWidth = width;
+ bmih.biHeight = height;
bmih.biPlanes = 1;
bmih.biBitCount = 32;
bmih.biCompression = 0;
- bmih.biSizeImage = transfer->height*transfer->width*4;
+ bmih.biSizeImage = height*width*4;
bmih.biXPelsPerMeter = 0;
bmih.biYPelsPerMeter = 0;
bmih.biClrUsed = 0;
@@ -771,19 +799,15 @@ debug_dump_transfer_bmp(const char *filename,
stream = util_stream_create(filename, bmfh.bfSize);
if(!stream)
- goto error2;
+ goto error1;
util_stream_write(stream, &bmfh, 14);
util_stream_write(stream, &bmih, 40);
- pipe_get_tile_rgba(transfer, 0, 0,
- transfer->width, transfer->height,
- rgba);
-
- y = transfer->height;
+ y = height;
while(y--) {
- float *ptr = rgba + (transfer->width * y * 4);
- for(x = 0; x < transfer->width; ++x)
+ float *ptr = rgba + (stride * y * 4);
+ for(x = 0; x < width; ++x)
{
struct bmp_rgb_quad pixel;
pixel.rgbRed = float_to_ubyte(ptr[x*4 + 0]);
@@ -795,8 +819,6 @@ debug_dump_transfer_bmp(const char *filename,
}
util_stream_close(stream);
-error2:
- FREE(rgba);
error1:
;
#endif
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 8d703e47fc..d42b65ce28 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -102,6 +102,22 @@ debug_printf(const char *format, ...)
}
+/*
+ * ... isn't portable so we need to pass arguments in parentheses.
+ *
+ * usage:
+ * debug_printf_once(("awnser: %i\n", 42));
+ */
+#define debug_printf_once(args) \
+ do { \
+ static boolean once = TRUE; \
+ if (once) { \
+ once = FALSE; \
+ debug_printf args; \
+ } \
+ } while (0)
+
+
#ifdef DEBUG
#define debug_vprintf(_format, _ap) _debug_vprintf(_format, _ap)
#else
@@ -347,10 +363,15 @@ void debug_dump_surface_bmp(const char *filename,
struct pipe_surface *surface);
void debug_dump_transfer_bmp(const char *filename,
struct pipe_transfer *transfer);
+void debug_dump_float_rgba_bmp(const char *filename,
+ unsigned width, unsigned height,
+ float *rgba, unsigned stride);
#else
#define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0)
#define debug_dump_surface(prefix, surface) ((void)0)
#define debug_dump_surface_bmp(filename, surface) ((void)0)
+#define debug_dump_transfer_bmp(filename, transfer) ((void)0)
+#define debug_dump_rgba_float_bmp(filename, width, height, rgba, stride) ((void)0)
#endif
diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c
index e9891fde8a..528a1c394b 100644
--- a/src/gallium/auxiliary/util/u_debug_stack.c
+++ b/src/gallium/auxiliary/util/u_debug_stack.c
@@ -62,6 +62,8 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace,
#ifdef PIPE_ARCH_X86
while(nr_frames) {
+ const void **next_frame_pointer;
+
if(!frame_pointer)
break;
@@ -72,7 +74,14 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace,
--nr_frames;
}
- frame_pointer = (const void **)frame_pointer[0];
+ next_frame_pointer = (const void **)frame_pointer[0];
+
+ /* Limit the stack walk to avoid referencing undefined memory */
+ if((uintptr_t)next_frame_pointer <= (uintptr_t)frame_pointer ||
+ (uintptr_t)next_frame_pointer > (uintptr_t)frame_pointer + 64*1024)
+ break;
+
+ frame_pointer = next_frame_pointer;
}
#endif
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index b32ad1cbe9..ca797486a0 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1278,10 +1278,6 @@ util_create_gen_mipmap(struct pipe_context *pipe,
/* disabled blending/masking */
memset(&ctx->blend, 0, sizeof(ctx->blend));
- ctx->blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
- ctx->blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
- ctx->blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
- ctx->blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
ctx->blend.colormask = PIPE_MASK_RGBA;
/* no-op depth/stencil/alpha */
@@ -1320,7 +1316,6 @@ util_create_gen_mipmap(struct pipe_context *pipe,
for (i = 0; i < 4; i++) {
ctx->vertices[i][0][2] = 0.0f; /* z */
ctx->vertices[i][0][3] = 1.0f; /* w */
- ctx->vertices[i][1][2] = 0.0f; /* r */
ctx->vertices[i][1][3] = 1.0f; /* q */
}
@@ -1354,29 +1349,104 @@ get_next_slot(struct gen_mipmap_state *ctx)
static unsigned
-set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
+set_vertex_data(struct gen_mipmap_state *ctx,
+ enum pipe_texture_target tex_target,
+ uint face, float width, float height)
{
unsigned offset;
+ /* vert[0].position */
ctx->vertices[0][0][0] = 0.0f; /*x*/
ctx->vertices[0][0][1] = 0.0f; /*y*/
- ctx->vertices[0][1][0] = 0.0f; /*s*/
- ctx->vertices[0][1][1] = 0.0f; /*t*/
+ /* vert[1].position */
ctx->vertices[1][0][0] = width;
ctx->vertices[1][0][1] = 0.0f;
- ctx->vertices[1][1][0] = 1.0f;
- ctx->vertices[1][1][1] = 0.0f;
+ /* vert[2].position */
ctx->vertices[2][0][0] = width;
ctx->vertices[2][0][1] = height;
- ctx->vertices[2][1][0] = 1.0f;
- ctx->vertices[2][1][1] = 1.0f;
+ /* vert[3].position */
ctx->vertices[3][0][0] = 0.0f;
ctx->vertices[3][0][1] = height;
- ctx->vertices[3][1][0] = 0.0f;
- ctx->vertices[3][1][1] = 1.0f;
+
+ /* Setup vertex texcoords. This is a little tricky for cube maps. */
+ if (tex_target == PIPE_TEXTURE_CUBE) {
+ static const float st[4][2] = {
+ {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
+ };
+ float rx, ry, rz;
+ uint i;
+
+ /* loop over quad verts */
+ for (i = 0; i < 4; i++) {
+ /* Compute sc = +/-scale and tc = +/-scale.
+ * Not +/-1 to avoid cube face selection ambiguity near the edges,
+ * though that can still sometimes happen with this scale factor...
+ */
+ const float scale = 0.9999f;
+ const float sc = (2.0f * st[i][0] - 1.0f) * scale;
+ const float tc = (2.0f * st[i][1] - 1.0f) * scale;
+
+ switch (face) {
+ case PIPE_TEX_FACE_POS_X:
+ rx = 1.0f;
+ ry = -tc;
+ rz = -sc;
+ break;
+ case PIPE_TEX_FACE_NEG_X:
+ rx = -1.0f;
+ ry = -tc;
+ rz = sc;
+ break;
+ case PIPE_TEX_FACE_POS_Y:
+ rx = sc;
+ ry = 1.0f;
+ rz = tc;
+ break;
+ case PIPE_TEX_FACE_NEG_Y:
+ rx = sc;
+ ry = -1.0f;
+ rz = -tc;
+ break;
+ case PIPE_TEX_FACE_POS_Z:
+ rx = sc;
+ ry = -tc;
+ rz = 1.0f;
+ break;
+ case PIPE_TEX_FACE_NEG_Z:
+ rx = -sc;
+ ry = -tc;
+ rz = -1.0f;
+ break;
+ default:
+ assert(0);
+ }
+
+ ctx->vertices[i][1][0] = rx; /*s*/
+ ctx->vertices[i][1][1] = ry; /*t*/
+ ctx->vertices[i][1][2] = rz; /*r*/
+ }
+ }
+ else {
+ /* 1D/2D */
+ ctx->vertices[0][1][0] = 0.0f; /*s*/
+ ctx->vertices[0][1][1] = 0.0f; /*t*/
+ ctx->vertices[0][1][2] = 0.0f; /*r*/
+
+ ctx->vertices[1][1][0] = 1.0f;
+ ctx->vertices[1][1][1] = 0.0f;
+ ctx->vertices[1][1][2] = 0.0f;
+
+ ctx->vertices[2][1][0] = 1.0f;
+ ctx->vertices[2][1][1] = 1.0f;
+ ctx->vertices[2][1][2] = 0.0f;
+
+ ctx->vertices[3][1][0] = 0.0f;
+ ctx->vertices[3][1][1] = 1.0f;
+ ctx->vertices[3][1][2] = 0.0f;
+ }
offset = get_next_slot( ctx );
@@ -1507,6 +1577,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
/* quad coords in window coords (bypassing vs, clip and viewport) */
offset = set_vertex_data(ctx,
+ pt->target,
+ face,
(float) pt->width[dstLevel],
(float) pt->height[dstLevel]);
diff --git a/src/gallium/auxiliary/util/u_linear.c b/src/gallium/auxiliary/util/u_linear.c
index 6be365e53b..a1dce3f5cf 100644
--- a/src/gallium/auxiliary/util/u_linear.c
+++ b/src/gallium/auxiliary/util/u_linear.c
@@ -1,3 +1,34 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * Functions for converting tiled data to linear and vice versa.
+ */
+
#include "util/u_debug.h"
#include "u_linear.h"
diff --git a/src/gallium/auxiliary/util/u_linear.h b/src/gallium/auxiliary/util/u_linear.h
index 1589f029bc..b74308ffa3 100644
--- a/src/gallium/auxiliary/util/u_linear.h
+++ b/src/gallium/auxiliary/util/u_linear.h
@@ -1,3 +1,34 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * Functions for converting tiled data to linear and vice versa.
+ */
+
#ifndef U_LINEAR_H
#define U_LINEAR_H
diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c
new file mode 100644
index 0000000000..07d804ecdb
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_network.c
@@ -0,0 +1,188 @@
+
+#include "pipe/p_compiler.h"
+#include "util/u_network.h"
+#include "util/u_debug.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+# include <winsock2.h>
+# include <windows.h>
+#elif defined(PIPE_OS_LINUX)
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <netdb.h>
+#else
+# warning "No socket implementation"
+#endif
+
+boolean
+u_socket_init()
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+ /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
+ wVersionRequested = MAKEWORD(1, 1);
+
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ debug_printf("WSAStartup failed with error: %d\n", err);
+ return FALSE;
+ }
+ return TRUE;
+#elif defined(PIPE_HAVE_SOCKETS)
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+void
+u_socket_stop()
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ WSACleanup();
+#endif
+}
+
+void
+u_socket_close(int s)
+{
+ if (s < 0)
+ return;
+
+#if defined(PIPE_OS_LINUX)
+ shutdown(s, SHUT_RDWR);
+ close(s);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ shutdown(s, SD_BOTH);
+ closesocket(s);
+#else
+ assert(0);
+#endif
+}
+
+int u_socket_accept(int s)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return accept(s, NULL, NULL);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_send(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return send(s, data, size, 0);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_peek(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return recv(s, data, size, MSG_PEEK);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_recv(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return recv(s, data, size, 0);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_connect(const char *hostname, uint16_t port)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ int s;
+ struct sockaddr_in sa;
+ struct hostent *host = NULL;
+
+ memset(&sa, 0, sizeof(struct sockaddr_in));
+ host = gethostbyname(hostname);
+ if (!host)
+ return -1;
+
+ memcpy((char *)&sa.sin_addr,host->h_addr,host->h_length);
+ sa.sin_family= host->h_addrtype;
+ sa.sin_port = htons(port);
+
+ s = socket(host->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
+ if (s < 0)
+ return -1;
+
+ if (connect(s, (struct sockaddr *)&sa, sizeof(sa))) {
+ u_socket_close(s);
+ return -1;
+ }
+
+ return s;
+#else
+ assert(0);
+ return -1;
+#endif
+}
+
+int
+u_socket_listen_on_port(uint16_t portnum)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ int s;
+ struct sockaddr_in sa;
+ memset(&sa, 0, sizeof(struct sockaddr_in));
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(portnum);
+
+ s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (s < 0)
+ return -1;
+
+ if (bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1) {
+ u_socket_close(s);
+ return -1;
+ }
+
+ listen(s, 0);
+
+ return s;
+#else
+ assert(0);
+ return -1;
+#endif
+}
+
+void
+u_socket_block(int s, boolean block)
+{
+#if defined(PIPE_OS_LINUX)
+ int old = fcntl(s, F_GETFL, 0);
+ if (old == -1)
+ return;
+
+ /* TODO obey block */
+ if (block)
+ fcntl(s, F_SETFL, old & ~O_NONBLOCK);
+ else
+ fcntl(s, F_SETFL, old | O_NONBLOCK);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ u_long iMode = block ? 0 : 1;
+ ioctlsocket(s, FIONBIO, &iMode);
+#else
+ assert(0);
+#endif
+}
diff --git a/src/gallium/auxiliary/util/u_network.h b/src/gallium/auxiliary/util/u_network.h
new file mode 100644
index 0000000000..14d3884427
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_network.h
@@ -0,0 +1,24 @@
+
+#ifndef _U_NETWORK_H_
+#define _U_NETWORK_H_
+
+#include "pipe/p_compiler.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+# define PIPE_HAVE_SOCKETS
+#elif defined(PIPE_OS_LINUX)
+# define PIPE_HAVE_SOCKETS
+#endif
+
+boolean u_socket_init(void);
+void u_socket_stop(void);
+void u_socket_close(int s);
+int u_socket_listen_on_port(uint16_t portnum);
+int u_socket_accept(int s);
+int u_socket_connect(const char *host, uint16_t port);
+int u_socket_send(int s, void *data, size_t size);
+int u_socket_peek(int s, void *data, size_t size);
+int u_socket_recv(int s, void *data, size_t size);
+void u_socket_block(int s, boolean block);
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
new file mode 100644
index 0000000000..85e443204e
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -0,0 +1,113 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Surface utility functions.
+ *
+ * @author Brian Paul
+ */
+
+
+#include "pipe/p_screen.h"
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+
+#include "util/u_surface.h"
+
+
+/**
+ * Helper to quickly create an RGBA rendering surface of a certain size.
+ * \param textureOut returns the new texture
+ * \param surfaceOut returns the new surface
+ * \return TRUE for success, FALSE if failure
+ */
+boolean
+util_create_rgba_surface(struct pipe_screen *screen,
+ uint width, uint height,
+ struct pipe_texture **textureOut,
+ struct pipe_surface **surfaceOut)
+{
+ static const enum pipe_format rgbaFormats[] = {
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_FORMAT_R8G8B8A8_UNORM,
+ PIPE_FORMAT_NONE
+ };
+ const uint target = PIPE_TEXTURE_2D;
+ const uint usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ enum pipe_format format = PIPE_FORMAT_NONE;
+ struct pipe_texture templ;
+ uint i;
+
+ /* Choose surface format */
+ for (i = 0; rgbaFormats[i]; i++) {
+ if (screen->is_format_supported(screen, rgbaFormats[i],
+ target, usage, 0)) {
+ format = rgbaFormats[i];
+ break;
+ }
+ }
+ if (format == PIPE_FORMAT_NONE)
+ return FALSE; /* unable to get an rgba format!?! */
+
+ /* create texture */
+ memset(&templ, 0, sizeof(templ));
+ templ.target = target;
+ templ.format = format;
+ templ.last_level = 0;
+ templ.width[0] = width;
+ templ.height[0] = height;
+ templ.depth[0] = 1;
+ pf_get_block(format, &templ.block);
+ templ.tex_usage = usage;
+
+ *textureOut = screen->texture_create(screen, &templ);
+ if (!*textureOut)
+ return FALSE;
+
+ /* create surface / view into texture */
+ *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+ if (!*surfaceOut) {
+ pipe_texture_reference(textureOut, NULL);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * Release the surface and texture from util_create_rgba_surface().
+ */
+void
+util_destroy_rgba_surface(struct pipe_texture *texture,
+ struct pipe_surface *surface)
+{
+ pipe_surface_reference(&surface, NULL);
+ pipe_texture_reference(&texture, NULL);
+}
+
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
new file mode 100644
index 0000000000..a5b73cfc20
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -0,0 +1,52 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef U_SURFACE_H
+#define U_SURFACE_H
+
+
+#include "pipe/p_compiler.h"
+
+
+struct pipe_screen;
+struct pipe_texture;
+struct pipe_surface;
+
+
+extern boolean
+util_create_rgba_surface(struct pipe_screen *screen,
+ uint width, uint height,
+ struct pipe_texture **textureOut,
+ struct pipe_surface **surfaceOut);
+
+
+extern void
+util_destroy_rgba_surface(struct pipe_texture *texture,
+ struct pipe_surface *surface);
+
+
+#endif /* U_SURFACE_H */
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index f0a5a339eb..9747a55cbf 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -1126,7 +1126,22 @@ pipe_get_tile_z(struct pipe_transfer *pt,
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 24-bit Z to 32-bit Z */
- pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff);
+ pDest[j] = (ptrc[j] << 8) | ((ptrc[j] >> 16) & 0xff);
+ }
+ pDest += dstStride;
+ ptrc += pt->stride/4;
+ }
+ }
+ break;
+ case PIPE_FORMAT_Z24S8_UNORM:
+ case PIPE_FORMAT_Z24X8_UNORM:
+ {
+ const uint *ptrc
+ = (const uint *)(map + y * pt->stride + x*4);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert 24-bit Z to 32-bit Z */
+ pDest[j] = (ptrc[j] & 0xffffff00) | ((ptrc[j] >> 24) & 0xff);
}
pDest += dstStride;
ptrc += pt->stride/4;
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
index 8afe4fccf7..5268cbf79c 100644
--- a/src/gallium/auxiliary/util/u_time.c
+++ b/src/gallium/auxiliary/util/u_time.c
@@ -217,4 +217,9 @@ void util_time_sleep(unsigned usecs)
} while(start <= curr && curr < end ||
end < start && (curr < end || start <= curr));
}
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+void util_time_sleep(unsigned usecs)
+{
+ Sleep((usecs + 999)/ 1000);
+}
#endif
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index d9c0d7afa8..2eb98068c8 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -70,7 +70,7 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
}
-static INLINE void
+static INLINE enum pipe_error
my_buffer_write(struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned offset, unsigned size, unsigned dirty_size,
@@ -84,12 +84,14 @@ my_buffer_write(struct pipe_screen *screen,
assert(size);
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE);
- assert(map);
- if(map) {
- memcpy(map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size);
- pipe_buffer_unmap(screen, buf);
- }
+ if (map == NULL)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ memcpy(map + offset, data, size);
+ pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size);
+ pipe_buffer_unmap(screen, buf);
+
+ return PIPE_OK;
}
/* Release old buffer.
@@ -162,12 +164,14 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
/* Copy the data, using map_range if available:
*/
- my_buffer_write( upload->screen,
- upload->buffer,
- upload->offset,
- size,
- alloc_size,
- data );
+ ret = my_buffer_write( upload->screen,
+ upload->buffer,
+ upload->offset,
+ size,
+ alloc_size,
+ data );
+ if (ret)
+ return ret;
/* Emit the return values:
*/