From c54b2199759e688ae89530f39106557c762b2fa4 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 9 Apr 2009 22:38:07 +0200 Subject: tgsi/sse2: Fix LIT instruction. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index d70bcd03c5..e399b9b9d5 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1553,7 +1553,7 @@ emit_instruction( func, make_xmm( 2 ), make_xmm( 0 ), - cc_LessThanEqual ); + cc_LessThan ); sse_andps( func, make_xmm( 2 ), -- cgit v1.2.3 From 790a18f2c2a4df78cf4b4f88e55036d54324497a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 9 Apr 2009 22:47:06 +0200 Subject: tgsi/sse2: Fix ARL instruction. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index e399b9b9d5..98994d8494 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1477,6 +1477,7 @@ emit_instruction( case TGSI_OPCODE_ARL: FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( func, *inst, 0, 0, chan_index ); + emit_flr(func, 0); emit_f2it( func, 0 ); STORE( func, *inst, 0, 0, chan_index ); } -- cgit v1.2.3 From f97df61d26af658f9ffdabfc268ce31bbca6f17f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 9 Apr 2009 14:55:19 -0600 Subject: gallium: remove unneeded compressed=0 assignment --- src/gallium/auxiliary/util/u_blit.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index deb68c43a6..29c3f85194 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -337,7 +337,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); -- cgit v1.2.3 From 5f31890861981d431607b2361ecde04e19726f1e Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 9 Apr 2009 23:17:02 +0200 Subject: draw: Fix LIT instruction. --- src/gallium/auxiliary/draw/draw_vs_aos_machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary') 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; } -- cgit v1.2.3 From c27c670ad8fc9f8276caeaff69eeb75e929dac9a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 9 Apr 2009 23:24:57 +0200 Subject: tgsi/sse2: Fix build. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 98994d8494..31225ba430 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1477,7 +1477,7 @@ emit_instruction( case TGSI_OPCODE_ARL: FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( func, *inst, 0, 0, chan_index ); - emit_flr(func, 0); + emit_flr(func, 0, 0); emit_f2it( func, 0 ); STORE( func, *inst, 0, 0, chan_index ); } -- cgit v1.2.3 From f4cc0692e6f285515e6a86367cf771be30665797 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 10 Apr 2009 08:54:47 +0200 Subject: draw: Fix vertex_header initialisation. --- src/gallium/auxiliary/draw/draw_pt_fetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 058caf7dcc..505d32f2c3 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -114,7 +114,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, -- cgit v1.2.3 From 13be57df3ac00a4bdfdafb10605c3be7056a21a5 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 10 Apr 2009 08:59:20 +0200 Subject: draw: Silence pointer-to-integer cast warning. --- src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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; -- cgit v1.2.3 From 05c70f8f5d95708cb4564946effb5c49d09068ec Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 10 Apr 2009 09:00:57 +0200 Subject: rtasm: Silence `static function not used' warning. --- src/gallium/auxiliary/rtasm/rtasm_cpu.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium/auxiliary') 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) { -- cgit v1.2.3 From 5fae9514c235cc5590f15fd802bd762107fc689d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 10 Apr 2009 11:58:49 +0200 Subject: tgsi/sse2: Cleanup NRM/NRM4 implementation. Fix comments. Make sure .w is set to 1.0 for NRM. Optimise for non-.xyzw writemasks. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 101 +++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 25 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 31225ba430..4b4e34b29e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -2178,32 +2178,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; -- cgit v1.2.3 From 49b40f9bf4aef3a32ddb88f7e8d378f08e26b081 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 15 Apr 2009 09:36:03 -0600 Subject: gallium: new, simple RGBA surface create/destroy helpers Use these for quickly creating an RGBA drawing surface. --- src/gallium/auxiliary/util/Makefile | 1 + src/gallium/auxiliary/util/SConscript | 1 + src/gallium/auxiliary/util/u_surface.c | 113 +++++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_surface.h | 52 +++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_surface.c create mode 100644 src/gallium/auxiliary/util/u_surface.h (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile index 5035e9cc13..2995aba1b9 100644 --- a/src/gallium/auxiliary/util/Makefile +++ b/src/gallium/auxiliary/util/Makefile @@ -23,6 +23,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..d3ac7f747f 100644 --- a/src/gallium/auxiliary/util/SConscript +++ b/src/gallium/auxiliary/util/SConscript @@ -24,6 +24,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_surface.c b/src/gallium/auxiliary/util/u_surface.c new file mode 100644 index 0000000000..8c2c227915 --- /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, usage); + if (!*surfaceOut) { + screen->texture_destroy(*textureOut); + 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 */ -- cgit v1.2.3 From 5a118d46507f4d551cba64014ac0dbbbad493742 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 15 Apr 2009 23:33:07 +0200 Subject: util: Fix surface usage --- src/gallium/auxiliary/util/u_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 8c2c227915..85e443204e 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -90,9 +90,9 @@ util_create_rgba_surface(struct pipe_screen *screen, return FALSE; /* create surface / view into texture */ - *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, usage); + *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); if (!*surfaceOut) { - screen->texture_destroy(*textureOut); + pipe_texture_reference(textureOut, NULL); return FALSE; } -- cgit v1.2.3 From 29a2f6fead25b8231c27ec47cadb9265736d8527 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 17 Apr 2009 10:38:07 +0100 Subject: util: flush stdout before emitting debug_printf on stderr A lot of the mesa demos emit commentary on stdout, try to keep it in sync with the corresponding output from debug_printf(). --- src/gallium/auxiliary/util/u_debug.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 96a2222f9b..ae47a274a6 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 -- cgit v1.2.3 From c7c76ba561197b15cf9ad9028335fbc8c2c48890 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 17 Apr 2009 11:29:39 +0100 Subject: util: don't set unused blend state Try to avoid creating multiple blend atoms. --- src/gallium/auxiliary/util/u_blit.c | 4 ---- src/gallium/auxiliary/util/u_gen_mipmap.c | 4 ---- 2 files changed, 8 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 29c3f85194..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 */ diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index b32ad1cbe9..690412ae7d 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 */ -- cgit v1.2.3 From c5a97eda32d37de7d1154288bf4298dff3542551 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 22 Apr 2009 15:12:22 -0600 Subject: gallium: license, copyright --- src/gallium/auxiliary/util/u_linear.c | 31 +++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_linear.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'src/gallium/auxiliary') 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 -- cgit v1.2.3 From f4a286e5f5ac11b2e5266ef39db5d1d1cb5f77ce Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 23 Apr 2009 05:42:26 +0200 Subject: util: Add more entry points for dumping to bmp --- src/gallium/auxiliary/util/u_debug.c | 56 ++++++++++++++++++++++++------------ src/gallium/auxiliary/util/u_debug.h | 5 ++++ 2 files changed, 43 insertions(+), 18 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index ae47a274a6..18597ef839 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -721,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; @@ -733,6 +734,7 @@ debug_dump_surface_bmp(const char *filename, debug_dump_transfer_bmp(filename, transfer); screen->tex_transfer_destroy(transfer); +#endif } void @@ -740,32 +742,56 @@ 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; rgba = MALLOC(transfer->width*transfer->height*4*sizeof(float)); + 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; @@ -773,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]); @@ -797,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..bcd8f0f3cf 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -347,10 +347,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 -- cgit v1.2.3 From 29d9abf72d73c4ccd3ad605f68ab1adf5e13c67a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 24 Apr 2009 12:43:04 +0100 Subject: pipebuffer: don't fail when validating mapped buffers This can be almost impossible to avoid - hopefully we won't encounter a situation where this is a true requirement. Would probably require drivers to flush between hardware and software vertex processing. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 2cd0b8a8cd..044e8e1dd3 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) -- cgit v1.2.3 From 91eb8baaca21d24bfd3640c9f6b316610a7c5910 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 24 Apr 2009 17:08:59 -0600 Subject: tgis: SSE code generator doesn't yet support indirect addressing of temp regs Fall back to interpreter in this case. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 4b4e34b29e..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,6 +1498,10 @@ 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 ) { -- cgit v1.2.3 From b618827fac84ca12a354da5808f30e96bedbc92a Mon Sep 17 00:00:00 2001 From: Micah Dowty Date: Fri, 24 Apr 2009 23:45:16 +0200 Subject: util: Add debug_printf_once --- src/gallium/auxiliary/util/u_debug.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index bcd8f0f3cf..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 -- cgit v1.2.3 From 5250eec652af46d20261624fd043992355a0b4ba Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 27 Apr 2009 14:43:31 +0100 Subject: util/time: add util_time_sleep() for windows userspace Somebody with a clue could probably do a better implemenation... --- src/gallium/auxiliary/util/u_time.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c index 8afe4fccf7..8e167d3c42 100644 --- a/src/gallium/auxiliary/util/u_time.c +++ b/src/gallium/auxiliary/util/u_time.c @@ -217,4 +217,13 @@ void util_time_sleep(unsigned usecs) } while(start <= curr && curr < end || end < start && (curr < end || start <= curr)); } +#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#include +#include + + +void util_time_sleep(unsigned usecs) +{ + Sleep((usecs + 999)/ 1000); +} #endif -- cgit v1.2.3 From 3ebcf2dd7489ecaf19a7167892069c4d58c285d8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 27 Apr 2009 17:13:40 +0100 Subject: util: Remove unix includes. --- src/gallium/auxiliary/util/u_time.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c index 8e167d3c42..5268cbf79c 100644 --- a/src/gallium/auxiliary/util/u_time.c +++ b/src/gallium/auxiliary/util/u_time.c @@ -218,10 +218,6 @@ void util_time_sleep(unsigned usecs) end < start && (curr < end || start <= curr)); } #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) -#include -#include - - void util_time_sleep(unsigned usecs) { Sleep((usecs + 999)/ 1000); -- cgit v1.2.3 From b91e5f8e197793feac016242140bf489bd16071c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 27 Apr 2009 19:36:42 +0100 Subject: util/indices: remove debug prints --- src/gallium/auxiliary/indices/u_unfilled_gen.c | 160 ------------------------ src/gallium/auxiliary/indices/u_unfilled_gen.py | 1 - 2 files changed, 161 deletions(-) (limited to 'src/gallium/auxiliary') 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 ) + ';' -- cgit v1.2.3 From eb979cef8535914f428d2462e78f713da558fc18 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 28 Apr 2009 14:50:05 +0100 Subject: gallium/draw: add ability to print out active pipeline stages --- src/gallium/auxiliary/draw/draw_pipe.h | 1 + src/gallium/auxiliary/draw/draw_pipe_aaline.c | 1 + src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 1 + src/gallium/auxiliary/draw/draw_pipe_clip.c | 1 + src/gallium/auxiliary/draw/draw_pipe_cull.c | 1 + src/gallium/auxiliary/draw/draw_pipe_flatshade.c | 1 + src/gallium/auxiliary/draw/draw_pipe_offset.c | 1 + src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 1 + src/gallium/auxiliary/draw/draw_pipe_stipple.c | 1 + src/gallium/auxiliary/draw/draw_pipe_twoside.c | 1 + src/gallium/auxiliary/draw/draw_pipe_unfilled.c | 1 + src/gallium/auxiliary/draw/draw_pipe_validate.c | 11 ++++++++++- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 1 + src/gallium/auxiliary/draw/draw_pipe_wide_line.c | 1 + src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 1 + 15 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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..9fedeef2d3 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -746,6 +746,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; diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 3133abe5dc..66839f7873 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -757,6 +757,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; 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..9287fc130e 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -586,6 +586,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; 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..49034ae86a 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -279,6 +279,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; -- cgit v1.2.3 From 8fa6c1ac9299402c1faf75b264cf70b1b83d1eff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 29 Apr 2009 11:56:57 -0600 Subject: tgsi: added tgsi_check_soa_dependencies() and related debug code (disabled) The TGSI interpeter operates in SOA style. We need to check for data dependencies in instructions which read from and write to the same register. For now just adding some debug code to detect that condition. Actual fixes to follow. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'src/gallium/auxiliary') 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; -- cgit v1.2.3 From 986d4a9ec60ee52067b2d6f81c05f8ec3b8dc8b1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 May 2009 17:52:23 -0600 Subject: draw: added some inf/nan debug code (disabled) --- src/gallium/auxiliary/draw/draw_vs_exec.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium/auxiliary') 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]; -- cgit v1.2.3 From 4fd6f296f8d3416472ec83374d459ecb12db60f4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 17:07:01 +0100 Subject: pb: Dump the fenced buffer sizes. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 044e8e1dd3..4698efa69c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -531,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; @@ -552,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"); -- cgit v1.2.3 From a47f15ba1da4c7f8649d7064dfc23cf571df705c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 18:53:52 +0100 Subject: pb: Save the stack backtrace when creating/mapping a debug buffer. --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 102 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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; } -- cgit v1.2.3 From c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 10:59:19 +0100 Subject: gallium/draw: cope with unused vertex_elements --- src/gallium/auxiliary/draw/draw_pt.h | 1 + src/gallium/auxiliary/draw/draw_pt_fetch.c | 8 +++++++- src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary') 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 505d32f2c3..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; 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. */ -- cgit v1.2.3 From b865501bda8f2f99bfa8ee365aa4a3da64291e6e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 13:09:34 +0100 Subject: gallium/tgsi: hack around linker/archiver breakage Add a dummy function which 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. --- src/gallium/auxiliary/tgsi/tgsi_transform.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/gallium/auxiliary') 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 ); +} -- cgit v1.2.3 From 3537c3420d0887ed22565b9e4469952b99f1b76f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 30 Apr 2009 13:10:58 +0100 Subject: util: Limit the stack walk to avoid referencing undefined memory. --- src/gallium/auxiliary/util/u_debug_stack.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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 -- cgit v1.2.3 From 79ada8c6331a801a0475f38a540670b14e168f19 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 May 2009 10:11:51 -0600 Subject: gallium: fix texcoords for cubemap mipmap generation We need to use (s,t,r) cubemap coords when sampling from the cubemap texture so the rendered quad gets texture samples from the correct cube face. --- src/gallium/auxiliary/util/u_gen_mipmap.c | 96 +++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 10 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 690412ae7d..6fa13a8ce1 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1316,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 */ } @@ -1350,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.9999; + 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 ); @@ -1503,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]); -- cgit v1.2.3 From 4a333c64faf78dd39f07574bb94f62ba48995e7d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 09:24:37 +0100 Subject: util/upload: catch failures to map_range and return error Caller may be able to do something about this - eg flush and retry. --- src/gallium/auxiliary/util/u_upload_mgr.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/gallium/auxiliary') 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: */ -- cgit v1.2.3 From 606a5476131059b012bb2522b204ed8b868db122 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 17:07:01 +0100 Subject: pb: Dump the fenced buffer sizes. --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 044e8e1dd3..4698efa69c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -531,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; @@ -552,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"); -- cgit v1.2.3 From 1248ff7d45ce4b78af8c7a091cb64f1f992f88dd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 28 Apr 2009 18:53:52 +0100 Subject: pb: Save the stack backtrace when creating/mapping a debug buffer. --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 102 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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; } -- cgit v1.2.3 From af09ba96e9e2d783fb0538a82513716c1c9aed3b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 10:59:19 +0100 Subject: gallium/draw: cope with unused vertex_elements --- src/gallium/auxiliary/draw/draw_pt.h | 1 + src/gallium/auxiliary/draw/draw_pt_fetch.c | 8 +++++++- src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary') 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 505d32f2c3..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; 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. */ -- cgit v1.2.3 From f628d7f5eebe9743f85ea8edf7c09b32cf393e4a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 30 Apr 2009 13:09:34 +0100 Subject: gallium/tgsi: hack around linker/archiver breakage Add a dummy function which 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. --- src/gallium/auxiliary/tgsi/tgsi_transform.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/gallium/auxiliary') 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 ); +} -- cgit v1.2.3 From be3f9dd26cf59cadc21e4d5cc27dd199c9752b1c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 30 Apr 2009 13:10:58 +0100 Subject: util: Limit the stack walk to avoid referencing undefined memory. --- src/gallium/auxiliary/util/u_debug_stack.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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 -- cgit v1.2.3 From e6a3801f3daaaf7e7e048ad0c43e838bac6a2d9a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 May 2009 09:24:37 +0100 Subject: util/upload: catch failures to map_range and return error Caller may be able to do something about this - eg flush and retry. --- src/gallium/auxiliary/util/u_upload_mgr.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/gallium/auxiliary') 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: */ -- cgit v1.2.3 From 5e39a8c4503596a019dc7c3ed4e24ee4117b1fca Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 16 May 2009 09:58:54 -0700 Subject: Create common trace_drm code, add to radeon_winsys. --- src/gallium/auxiliary/trace/trace_drm.h | 165 ++++++++++++++++++++++++ src/gallium/winsys/drm/radeon/core/radeon_drm.c | 8 ++ src/gallium/winsys/drm/radeon/dri/Makefile | 1 + src/gallium/winsys/drm/radeon/egl/Makefile | 1 + 4 files changed, 175 insertions(+) create mode 100644 src/gallium/auxiliary/trace/trace_drm.h (limited to 'src/gallium/auxiliary') 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 + * Corbin Simpson + * + * 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/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 428d3f65a1..5406d2bbea 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -30,6 +30,10 @@ #include "radeon_drm.h" +#ifdef DEBUG +#include "trace/trace_drm.h" +#endif + /* Create a pipe_screen. */ struct pipe_screen* radeon_create_screen(int drmFB, struct drm_create_screen_arg *arg) @@ -112,7 +116,11 @@ boolean radeon_global_handle_from_buffer(struct pipe_screen* screen, return TRUE; } +#ifdef DEBUG +struct drm_api hooks = { +#else struct drm_api drm_api_hooks = { +#endif .create_screen = radeon_create_screen, .create_context = radeon_create_context, /* XXX fix this */ diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile index c218ee9d01..a9889444de 100644 --- a/src/gallium/winsys/drm/radeon/dri/Makefile +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -10,6 +10,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a C_SOURCES = \ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile index d989b3aa93..6a1448d1b9 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -8,6 +8,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a DRIVER_SOURCES = -- cgit v1.2.3 From 713b636a0e0356266b714548886b66864b830fff Mon Sep 17 00:00:00 2001 From: Mike Kaplinksiy Date: Thu, 28 May 2009 01:20:37 -0400 Subject: draw: Fix assertion failure at fetch_emit_prepare --- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium/auxiliary') 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; -- cgit v1.2.3 From aee1a6f70413235c0c4c2c2adfca97d5128a155e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 22 Mar 2009 04:22:33 +0100 Subject: util: Add simple network functions --- src/gallium/auxiliary/util/Makefile | 1 + src/gallium/auxiliary/util/SConscript | 1 + src/gallium/auxiliary/util/u_network.c | 188 +++++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_network.h | 24 +++++ 4 files changed, 214 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_network.c create mode 100644 src/gallium/auxiliary/util/u_network.h (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile index 2995aba1b9..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 \ diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript index d3ac7f747f..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', diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c new file mode 100644 index 0000000000..465d50255e --- /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 +# include +#elif defined(PIPE_OS_LINUX) +# include +# include +# include +# include +# include +#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 -- cgit v1.2.3 From dfa4ebcbcc9c7e9e7562f73a4ddc367756623e5e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 May 2009 01:07:05 +0200 Subject: rbug: Add Gallium Remote Debugger Protocol code This is the (de)marshalling and connection managment code --- configs/default | 2 +- configure.ac | 2 +- src/gallium/SConscript | 1 + src/gallium/auxiliary/rbug/Makefile | 14 + src/gallium/auxiliary/rbug/README | 21 + src/gallium/auxiliary/rbug/SConscript | 14 + src/gallium/auxiliary/rbug/rbug.h | 33 ++ src/gallium/auxiliary/rbug/rbug_connection.c | 167 +++++++ src/gallium/auxiliary/rbug/rbug_connection.h | 45 ++ src/gallium/auxiliary/rbug/rbug_context.c | 442 +++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_context.h | 128 ++++++ src/gallium/auxiliary/rbug/rbug_core.c | 359 +++++++++++++++ src/gallium/auxiliary/rbug/rbug_core.h | 101 +++++ src/gallium/auxiliary/rbug/rbug_demarshal.c | 85 ++++ src/gallium/auxiliary/rbug/rbug_internal.h | 100 +++++ src/gallium/auxiliary/rbug/rbug_proto.h | 90 ++++ src/gallium/auxiliary/rbug/rbug_shader.c | 468 ++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_shader.h | 144 ++++++ src/gallium/auxiliary/rbug/rbug_texture.c | 631 +++++++++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_texture.h | 207 +++++++++ 20 files changed, 3052 insertions(+), 2 deletions(-) create mode 100644 src/gallium/auxiliary/rbug/Makefile create mode 100644 src/gallium/auxiliary/rbug/README create mode 100644 src/gallium/auxiliary/rbug/SConscript create mode 100644 src/gallium/auxiliary/rbug/rbug.h create mode 100644 src/gallium/auxiliary/rbug/rbug_connection.c create mode 100644 src/gallium/auxiliary/rbug/rbug_connection.h create mode 100644 src/gallium/auxiliary/rbug/rbug_context.c create mode 100644 src/gallium/auxiliary/rbug/rbug_context.h create mode 100644 src/gallium/auxiliary/rbug/rbug_core.c create mode 100644 src/gallium/auxiliary/rbug/rbug_core.h create mode 100644 src/gallium/auxiliary/rbug/rbug_demarshal.c create mode 100644 src/gallium/auxiliary/rbug/rbug_internal.h create mode 100644 src/gallium/auxiliary/rbug/rbug_proto.h create mode 100644 src/gallium/auxiliary/rbug/rbug_shader.c create mode 100644 src/gallium/auxiliary/rbug/rbug_shader.h create mode 100644 src/gallium/auxiliary/rbug/rbug_texture.c create mode 100644 src/gallium/auxiliary/rbug/rbug_texture.h (limited to 'src/gallium/auxiliary') diff --git a/configs/default b/configs/default index 9c479fccdf..d2ea3b2487 100644 --- a/configs/default +++ b/configs/default @@ -90,7 +90,7 @@ EGL_DRIVERS_DIRS = demo # Gallium directories and GALLIUM_DIRS = auxiliary drivers state_trackers -GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util indices +GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a) GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) diff --git a/configure.ac b/configure.ac index 8110e0f869..24aa13a7ca 100644 --- a/configure.ac +++ b/configure.ac @@ -409,7 +409,7 @@ WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_WINSYS_DIRS="" GALLIUM_WINSYS_DRM_DIRS="" -GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util indices" +GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices" GALLIUM_DRIVERS_DIRS="softpipe failover trace" GALLIUM_STATE_TRACKERS_DIRS="" diff --git a/src/gallium/SConscript b/src/gallium/SConscript index b6ceaf3edf..32b7c2980a 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -22,6 +22,7 @@ SConscript([ 'auxiliary/draw/SConscript', 'auxiliary/pipebuffer/SConscript', 'auxiliary/indices/SConscript', + 'auxiliary/rbug/SConscript', ]) for driver in env['drivers']: 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 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..b4fad5300d --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -0,0 +1,442 @@ +/* + * 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_block_draw(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_BLOCK_DRAW)); + 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_BLOCK_DRAW, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_unblock_draw(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_UNBLOCK_DRAW)); + 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_UNBLOCK_DRAW, __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_texture_t *cbufs, + uint32_t cbufs_len, + rbug_texture_t zdbuf, + uint8_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_ARRAY(8, cbufs); /* cbufs */ + LEN(8); /* zdbuf */ + LEN(1); /* 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_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ + WRITE(8, rbug_texture_t, zdbuf); /* zdbuf */ + WRITE(1, uint8_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; +} + +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_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_block_draw *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_BLOCK_DRAW) + 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_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_unblock_draw *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (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_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ + READ(8, rbug_texture_t, zdbuf); /* zdbuf */ + READ(1, uint8_t, blocked); /* blocked */ + + 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..bcd2a826a7 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -0,0 +1,128 @@ +/* + * 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_texture.h" + +typedef uint64_t rbug_context_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_block_draw +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_unblock_draw +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_context_t *contexts; + uint32_t contexts_len; +}; + +struct rbug_proto_context_info_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_texture_t *cbufs; + uint32_t cbufs_len; + rbug_texture_t zdbuf; + uint8_t blocked; +}; + +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_block_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_unblock_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_context_t *contexts, + uint32_t contexts_len, + uint32_t *__serial); + +int rbug_send_context_info_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *cbufs, + uint32_t cbufs_len, + rbug_texture_t zdbuf, + uint8_t blocked, + 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_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header); + +struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(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); + +#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..d63a8c8076 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_core.h @@ -0,0 +1,101 @@ +/* + * 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" + +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..e3c0954f9e --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -0,0 +1,85 @@ +/* + * 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_BLOCK_DRAW: + return (struct rbug_header *)rbug_demarshal_context_block_draw(header); + case RBUG_OP_CONTEXT_UNBLOCK_DRAW: + return (struct rbug_header *)rbug_demarshal_context_unblock_draw(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_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 + +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..8fa1836771 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -0,0 +1,90 @@ +/* + * 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_BLOCK_DRAW = 514, + RBUG_OP_CONTEXT_UNBLOCK_DRAW = 515, + RBUG_OP_CONTEXT_LIST_REPLY = -512, + RBUG_OP_CONTEXT_INFO_REPLY = -513, + 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..fe1b9ac0f7 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_shader.h @@ -0,0 +1,144 @@ +/* + * 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_context.h" + +typedef uint64_t rbug_shader_t; + +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..2bcc3566f3 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_texture.h @@ -0,0 +1,207 @@ +/* + * 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" + +typedef uint64_t rbug_texture_t; + +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 -- cgit v1.2.3 From 427554211b5b8ab2c6afcd5bd574ac97fb3457da Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 1 Jun 2009 14:28:57 -0600 Subject: draw: reset extra_vp_outputs.slot to zero in widepoint_flush() Fixes a crash when clearing the window with a quad after drawing large points. We were asking the draw module how many vertex shader outputs there were and got 3 instead of 2. This led to creating vertices with too many attributes and trying to read invalid memory. We reset extra_vp_outputs.slot to zero in the aaline/aapoint stage's flush functions already. This omission was just an oversight in the wide_point stage. --- src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index 49034ae86a..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; } -- cgit v1.2.3 From 69a765df1c3bf6acc549a5a6a047bbde16988721 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 1 Jun 2009 19:48:40 -0700 Subject: draw: avoid leaking tokens when building pstipple fragment shader Add missing FREE() after MALLOC(). --- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 9287fc130e..bc63b700de 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; } -- cgit v1.2.3 From 003cfd4dd2491675058c53a8f59553f2443be349 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 1 Jun 2009 20:15:28 -0700 Subject: draw: free more token arrays The AA line and point code also needs to free token arrays after building driver shaders. --- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 9 ++++++--- src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 9fedeef2d3..0d322b0aab 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; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 66839f7873..729cf75e65 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; } -- cgit v1.2.3 From 1aef032d438aaa40ec28bf279ad5c089370773f0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 1 Jun 2009 20:16:20 -0700 Subject: gallium/draw: Free specialized versions of driver shaders The pstipple, aaline and aapoint code would create specialized versions of shaders and upload them to the driver -- but never free them. --- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 4 ++++ src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 5 +++++ src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 4 ++++ 3 files changed, 13 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 0d322b0aab..9f956715a2 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -819,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 729cf75e65..ae1712fe12 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -829,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_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index bc63b700de..30a6d2919d 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -650,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); } -- cgit v1.2.3 From c91df4c1534e2db2274b6d08e90470bf21a49e2a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 2 Jun 2009 11:46:06 -0700 Subject: util: Fix 24 to 32 bit expansion binary arithmetic expression. When approaching y = x * 0xffffffff / 0xffffff with bit arithmetic, the 8 least significant bits of y should come from the 8 most significant bits of x. --- src/gallium/auxiliary/util/u_tile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index f0a5a339eb..9becd9fea4 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1126,7 +1126,7 @@ 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; -- cgit v1.2.3 From 840af5fd62edc01769cc3818702ea399a0c68c40 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 2 Jun 2009 11:46:53 -0700 Subject: util: Support Z24S8/Z24X8 -> unsigned conversion. --- src/gallium/auxiliary/util/u_tile.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 9becd9fea4..a2fcdad9e4 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1133,6 +1133,21 @@ pipe_get_tile_z(struct pipe_transfer *pt, } } 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] & 0xff); + } + pDest += dstStride; + ptrc += pt->stride/4; + } + } + break; case PIPE_FORMAT_Z16_UNORM: { const ushort *ptrc -- cgit v1.2.3 From 273117ceed47bff58a0f475dd36b37721e997f91 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 2 Jun 2009 16:41:45 -0700 Subject: util: Unsaved change missing from last commit. --- src/gallium/auxiliary/util/u_tile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index a2fcdad9e4..9747a55cbf 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -1141,7 +1141,7 @@ 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] & 0xffffff00) | (ptrc[j] & 0xff); + pDest[j] = (ptrc[j] & 0xffffff00) | ((ptrc[j] >> 24) & 0xff); } pDest += dstStride; ptrc += pt->stride/4; -- cgit v1.2.3 From 45e744dddc8a8f3b42610bfa512bc296bd5264bc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Jun 2009 13:08:52 -0600 Subject: tgsi: increase MAX_LABELS to 4096 --- src/gallium/auxiliary/tgsi/tgsi_exec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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 */ -- cgit v1.2.3 From 384bbe278d7e634cf1af5f786bfbde651c14df62 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 4 Jun 2009 14:36:10 +0100 Subject: rbug: Update rbug protocol with new context calls --- src/gallium/auxiliary/rbug/rbug_context.c | 267 +++++++++++++++++++++++++--- src/gallium/auxiliary/rbug/rbug_context.h | 80 +++++++-- src/gallium/auxiliary/rbug/rbug_core.h | 4 + src/gallium/auxiliary/rbug/rbug_demarshal.c | 14 +- src/gallium/auxiliary/rbug/rbug_proto.h | 7 +- src/gallium/auxiliary/rbug/rbug_shader.h | 4 +- src/gallium/auxiliary/rbug/rbug_texture.h | 3 +- 7 files changed, 336 insertions(+), 43 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c index b4fad5300d..787f650f71 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.c +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -110,8 +110,9 @@ int rbug_send_context_info(struct rbug_connection *__con, return __ret; } -int rbug_send_context_block_draw(struct rbug_connection *__con, +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; @@ -121,6 +122,7 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, LEN(8); /* header */ LEN(8); /* context */ + LEN(4); /* block */ /* align */ PAD(__len, 8); @@ -129,9 +131,10 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, if (!__data) return -ENOMEM; - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_BLOCK_DRAW)); + 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); @@ -139,7 +142,7 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, if (__pos != __len) { __ret = -EINVAL; } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_BLOCK_DRAW, __len); + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCK, __len); rbug_connection_write(__con, __data, __len); __ret = rbug_connection_send_finish(__con, __serial); } @@ -148,8 +151,50 @@ int rbug_send_context_block_draw(struct rbug_connection *__con, return __ret; } -int rbug_send_context_unblock_draw(struct rbug_connection *__con, +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; @@ -159,6 +204,7 @@ int rbug_send_context_unblock_draw(struct rbug_connection *__con, LEN(8); /* header */ LEN(8); /* context */ + LEN(4); /* unblock */ /* align */ PAD(__len, 8); @@ -167,9 +213,10 @@ int rbug_send_context_unblock_draw(struct rbug_connection *__con, if (!__data) return -ENOMEM; - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW)); + 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); @@ -177,7 +224,48 @@ int rbug_send_context_unblock_draw(struct rbug_connection *__con, if (__pos != __len) { __ret = -EINVAL; } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_UNBLOCK_DRAW, __len); + 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_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); } @@ -230,10 +318,13 @@ int rbug_send_context_list_reply(struct rbug_connection *__con, int rbug_send_context_info_reply(struct rbug_connection *__con, uint32_t serial, + rbug_shader_t vertex, + rbug_shader_t fragment, rbug_texture_t *cbufs, uint32_t cbufs_len, - rbug_texture_t zdbuf, - uint8_t blocked, + rbug_texture_t zsbuf, + rbug_block_t blocker, + rbug_block_t blocked, uint32_t *__serial) { uint32_t __len = 0; @@ -243,9 +334,12 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, LEN(8); /* header */ LEN(4); /* serial */ + LEN(8); /* vertex */ + LEN(8); /* fragment */ LEN_ARRAY(8, cbufs); /* cbufs */ - LEN(8); /* zdbuf */ - LEN(1); /* blocked */ + LEN(8); /* zsbuf */ + LEN(4); /* blocker */ + LEN(4); /* blocked */ /* align */ PAD(__len, 8); @@ -257,9 +351,12 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, 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, cbufs); /* cbufs */ - WRITE(8, rbug_texture_t, zdbuf); /* zdbuf */ - WRITE(1, uint8_t, blocked); /* blocked */ + 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); @@ -276,6 +373,47 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, 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; @@ -329,16 +467,72 @@ struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_h return ret; } -struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header) +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_block_draw *ret; + struct rbug_proto_context_draw_unblock *ret; if (!header) return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_BLOCK_DRAW) + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK) return NULL; pos = 0; @@ -352,20 +546,21 @@ struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct 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_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header) +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_unblock_draw *ret; + struct rbug_proto_context_flush *ret; if (!header) return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW) + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_FLUSH) return NULL; pos = 0; @@ -379,6 +574,7 @@ struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(str ret->header.opcode = header->opcode; READ(8, rbug_context_t, context); /* context */ + READ(4, int32_t, flags); /* flags */ return ret; } @@ -434,9 +630,40 @@ struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct 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, cbufs); /* cbufs */ - READ(8, rbug_texture_t, zdbuf); /* zdbuf */ - READ(1, uint8_t, blocked); /* blocked */ + 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 index bcd2a826a7..9f1726d64d 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.h +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -39,9 +39,13 @@ #define _RBUG_PROTO_CONTEXT_H_ #include "rbug/rbug_proto.h" -#include "rbug/rbug_texture.h" +#include "rbug/rbug_core.h" -typedef uint64_t rbug_context_t; +typedef enum +{ + RBUG_BLOCK_BEFORE = 1, + RBUG_BLOCK_AFTER = 2, +} rbug_block_t; struct rbug_proto_context_list { @@ -54,16 +58,32 @@ struct rbug_proto_context_info rbug_context_t context; }; -struct rbug_proto_context_block_draw +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_unblock_draw +struct rbug_proto_context_draw_unblock { struct rbug_header header; rbug_context_t context; + rbug_block_t unblock; +}; + +struct rbug_proto_context_flush +{ + struct rbug_header header; + rbug_context_t context; + int32_t flags; }; struct rbug_proto_context_list_reply @@ -78,10 +98,20 @@ struct rbug_proto_context_info_reply { struct rbug_header header; uint32_t serial; + rbug_shader_t vertex; + rbug_shader_t fragment; rbug_texture_t *cbufs; uint32_t cbufs_len; - rbug_texture_t zdbuf; - uint8_t blocked; + 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, @@ -91,14 +121,26 @@ int rbug_send_context_info(struct rbug_connection *__con, rbug_context_t context, uint32_t *__serial); -int rbug_send_context_block_draw(struct rbug_connection *__con, +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_unblock_draw(struct rbug_connection *__con, +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_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, @@ -107,22 +149,36 @@ int rbug_send_context_list_reply(struct rbug_connection *__con, int rbug_send_context_info_reply(struct rbug_connection *__con, uint32_t serial, + rbug_shader_t vertex, + rbug_shader_t fragment, rbug_texture_t *cbufs, uint32_t cbufs_len, - rbug_texture_t zdbuf, - uint8_t blocked, + 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_block_draw * rbug_demarshal_context_block_draw(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_unblock_draw * rbug_demarshal_context_unblock_draw(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_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.h b/src/gallium/auxiliary/rbug/rbug_core.h index d63a8c8076..99a36a0163 100644 --- a/src/gallium/auxiliary/rbug/rbug_core.h +++ b/src/gallium/auxiliary/rbug/rbug_core.h @@ -40,6 +40,10 @@ #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; diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c index e3c0954f9e..80894f4a64 100644 --- a/src/gallium/auxiliary/rbug/rbug_demarshal.c +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -59,14 +59,20 @@ struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) 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_BLOCK_DRAW: - return (struct rbug_header *)rbug_demarshal_context_block_draw(header); - case RBUG_OP_CONTEXT_UNBLOCK_DRAW: - return (struct rbug_header *)rbug_demarshal_context_unblock_draw(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_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: diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h index 8fa1836771..db9fa68500 100644 --- a/src/gallium/auxiliary/rbug/rbug_proto.h +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -52,10 +52,13 @@ enum rbug_opcode RBUG_OP_TEXTURE_READ_REPLY = -259, RBUG_OP_CONTEXT_LIST = 512, RBUG_OP_CONTEXT_INFO = 513, - RBUG_OP_CONTEXT_BLOCK_DRAW = 514, - RBUG_OP_CONTEXT_UNBLOCK_DRAW = 515, + RBUG_OP_CONTEXT_DRAW_BLOCK = 514, + RBUG_OP_CONTEXT_DRAW_STEP = 515, + RBUG_OP_CONTEXT_DRAW_UNBLOCK = 516, + RBUG_OP_CONTEXT_FLUSH = 518, 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, diff --git a/src/gallium/auxiliary/rbug/rbug_shader.h b/src/gallium/auxiliary/rbug/rbug_shader.h index fe1b9ac0f7..b5d886781d 100644 --- a/src/gallium/auxiliary/rbug/rbug_shader.h +++ b/src/gallium/auxiliary/rbug/rbug_shader.h @@ -39,9 +39,7 @@ #define _RBUG_PROTO_SHADER_H_ #include "rbug/rbug_proto.h" -#include "rbug/rbug_context.h" - -typedef uint64_t rbug_shader_t; +#include "rbug/rbug_core.h" struct rbug_proto_shader_list { diff --git a/src/gallium/auxiliary/rbug/rbug_texture.h b/src/gallium/auxiliary/rbug/rbug_texture.h index 2bcc3566f3..fbb247e1d4 100644 --- a/src/gallium/auxiliary/rbug/rbug_texture.h +++ b/src/gallium/auxiliary/rbug/rbug_texture.h @@ -39,8 +39,7 @@ #define _RBUG_PROTO_TEXTURE_H_ #include "rbug/rbug_proto.h" - -typedef uint64_t rbug_texture_t; +#include "rbug/rbug_core.h" struct rbug_proto_texture_list { -- cgit v1.2.3 From b04470b0bce6a24a74a0ec8cf16d9d3f03aff5f2 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 5 Jun 2009 14:32:31 +0200 Subject: util: Fix winsock include. --- src/gallium/auxiliary/util/u_network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c index 465d50255e..07d804ecdb 100644 --- a/src/gallium/auxiliary/util/u_network.c +++ b/src/gallium/auxiliary/util/u_network.c @@ -4,8 +4,8 @@ #include "util/u_debug.h" #if defined(PIPE_SUBSYSTEM_WINDOWS_USER) +# include # include -# include #elif defined(PIPE_OS_LINUX) # include # include -- cgit v1.2.3 From 8064a517b24169fa2b03f27bf70e3d62f54c830d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 8 Jun 2009 18:17:21 +1000 Subject: llvm: fix compile on gcc 4.4 --- src/gallium/auxiliary/gallivm/instructionssoa.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium/auxiliary') 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 #include "instructionssoa.h" #include "storagesoa.h" -- cgit v1.2.3 From 77c329a2773820c57e7b286858e80a596f89ef94 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 8 Jun 2009 16:46:06 +0200 Subject: pipebuffer: Silence out of heap space debug print --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') 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); -- cgit v1.2.3 From f0c21c02945f8379decfa3b2f294651d6b5af8ef Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 9 Jun 2009 15:58:14 +0100 Subject: rbug: Extend context info and block ops --- src/gallium/auxiliary/rbug/rbug_context.c | 228 ++++++++++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_context.h | 56 +++++++ src/gallium/auxiliary/rbug/rbug_demarshal.c | 6 + src/gallium/auxiliary/rbug/rbug_proto.h | 3 + 4 files changed, 293 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c index 787f650f71..55e049f313 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.c +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -274,6 +274,100 @@ int rbug_send_context_flush(struct rbug_connection *__con, return __ret; } +int rbug_send_context_rule_add(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_RULE_ADD)); + 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_RULE_ADD, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_rule_delete(struct rbug_connection *__con, + rbug_context_t context, + rbug_block_rule_t rule, + 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); /* rule */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_RULE_DELETE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_block_rule_t, rule); /* rule */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_RULE_DELETE, __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, @@ -320,6 +414,8 @@ 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, @@ -336,6 +432,7 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, 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 */ @@ -353,6 +450,7 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, 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 */ @@ -373,6 +471,47 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, return __ret; } +int rbug_send_context_rule_add_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_block_rule_t rule, + 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); /* rule */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_RULE_ADD_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(8, rbug_block_rule_t, rule); /* rule */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_RULE_ADD_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, @@ -579,6 +718,66 @@ struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto return ret; } +struct rbug_proto_context_rule_add * rbug_demarshal_context_rule_add(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_rule_add *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_RULE_ADD) + 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_rule_delete * rbug_demarshal_context_rule_delete(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_rule_delete *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_RULE_DELETE) + 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_block_rule_t, rule); /* rule */ + + return ret; +} + struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header) { uint32_t len = 0; @@ -632,6 +831,7 @@ struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct 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 */ @@ -640,6 +840,34 @@ struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct return ret; } +struct rbug_proto_context_rule_add_reply * rbug_demarshal_context_rule_add_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_rule_add_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_RULE_ADD_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_block_rule_t, rule); /* rule */ + + return ret; +} + struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header) { uint32_t len = 0; diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h index 9f1726d64d..178a3bce24 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.h +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -41,6 +41,8 @@ #include "rbug/rbug_proto.h" #include "rbug/rbug_core.h" +typedef uint64_t rbug_block_rule_t; + typedef enum { RBUG_BLOCK_BEFORE = 1, @@ -86,6 +88,24 @@ struct rbug_proto_context_flush int32_t flags; }; +struct rbug_proto_context_rule_add +{ + 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_rule_delete +{ + struct rbug_header header; + rbug_context_t context; + rbug_block_rule_t rule; +}; + struct rbug_proto_context_list_reply { struct rbug_header header; @@ -100,6 +120,8 @@ struct rbug_proto_context_info_reply 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; @@ -107,6 +129,13 @@ struct rbug_proto_context_info_reply rbug_block_t blocked; }; +struct rbug_proto_context_rule_add_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_block_rule_t rule; +}; + struct rbug_proto_context_draw_blocked { struct rbug_header header; @@ -141,6 +170,20 @@ int rbug_send_context_flush(struct rbug_connection *__con, int32_t flags, uint32_t *__serial); +int rbug_send_context_rule_add(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_rule_delete(struct rbug_connection *__con, + rbug_context_t context, + rbug_block_rule_t rule, + uint32_t *__serial); + int rbug_send_context_list_reply(struct rbug_connection *__con, uint32_t serial, rbug_context_t *contexts, @@ -151,6 +194,8 @@ 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, @@ -158,6 +203,11 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, rbug_block_t blocked, uint32_t *__serial); +int rbug_send_context_rule_add_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_block_rule_t rule, + uint32_t *__serial); + int rbug_send_context_draw_blocked(struct rbug_connection *__con, rbug_context_t context, rbug_block_t block, @@ -175,10 +225,16 @@ struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(str struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header); +struct rbug_proto_context_rule_add * rbug_demarshal_context_rule_add(struct rbug_proto_header *header); + +struct rbug_proto_context_rule_delete * rbug_demarshal_context_rule_delete(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_rule_add_reply * rbug_demarshal_context_rule_add_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_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c index 80894f4a64..b3929b9cb4 100644 --- a/src/gallium/auxiliary/rbug/rbug_demarshal.c +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -67,10 +67,16 @@ struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) return (struct rbug_header *)rbug_demarshal_context_draw_unblock(header); case RBUG_OP_CONTEXT_FLUSH: return (struct rbug_header *)rbug_demarshal_context_flush(header); + case RBUG_OP_CONTEXT_RULE_ADD: + return (struct rbug_header *)rbug_demarshal_context_rule_add(header); + case RBUG_OP_CONTEXT_RULE_DELETE: + return (struct rbug_header *)rbug_demarshal_context_rule_delete(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_RULE_ADD_REPLY: + return (struct rbug_header *)rbug_demarshal_context_rule_add_reply(header); case RBUG_OP_CONTEXT_DRAW_BLOCKED: return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header); case RBUG_OP_SHADER_LIST: diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h index db9fa68500..5ef345d72d 100644 --- a/src/gallium/auxiliary/rbug/rbug_proto.h +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -56,8 +56,11 @@ enum rbug_opcode RBUG_OP_CONTEXT_DRAW_STEP = 515, RBUG_OP_CONTEXT_DRAW_UNBLOCK = 516, RBUG_OP_CONTEXT_FLUSH = 518, + RBUG_OP_CONTEXT_RULE_ADD = 521, + RBUG_OP_CONTEXT_RULE_DELETE = 522, RBUG_OP_CONTEXT_LIST_REPLY = -512, RBUG_OP_CONTEXT_INFO_REPLY = -513, + RBUG_OP_CONTEXT_RULE_ADD_REPLY = -521, RBUG_OP_CONTEXT_DRAW_BLOCKED = 517, RBUG_OP_SHADER_LIST = 768, RBUG_OP_SHADER_INFO = 769, -- cgit v1.2.3 From f3cf3d2fc2c0cb09cb1c18c08a135009904166b7 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 9 Jun 2009 19:22:40 +0100 Subject: rbug: Change block protocol around a bit --- src/gallium/auxiliary/rbug/rbug_context.c | 188 ++++------------------------ src/gallium/auxiliary/rbug/rbug_context.h | 60 +++------ src/gallium/auxiliary/rbug/rbug_demarshal.c | 8 +- src/gallium/auxiliary/rbug/rbug_proto.h | 6 +- 4 files changed, 45 insertions(+), 217 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c index 55e049f313..1832425658 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.c +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -233,55 +233,14 @@ int rbug_send_context_draw_unblock(struct rbug_connection *__con, 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_rule_add(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_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; @@ -303,7 +262,7 @@ int rbug_send_context_rule_add(struct rbug_connection *__con, if (!__data) return -ENOMEM; - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_RULE_ADD)); + 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 */ @@ -318,7 +277,7 @@ int rbug_send_context_rule_add(struct rbug_connection *__con, if (__pos != __len) { __ret = -EINVAL; } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_RULE_ADD, __len); + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_RULE, __len); rbug_connection_write(__con, __data, __len); __ret = rbug_connection_send_finish(__con, __serial); } @@ -327,10 +286,10 @@ int rbug_send_context_rule_add(struct rbug_connection *__con, return __ret; } -int rbug_send_context_rule_delete(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_rule_t rule, - uint32_t *__serial) +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; @@ -339,7 +298,7 @@ int rbug_send_context_rule_delete(struct rbug_connection *__con, LEN(8); /* header */ LEN(8); /* context */ - LEN(8); /* rule */ + LEN(4); /* flags */ /* align */ PAD(__len, 8); @@ -348,10 +307,10 @@ int rbug_send_context_rule_delete(struct rbug_connection *__con, if (!__data) return -ENOMEM; - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_RULE_DELETE)); + 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(8, rbug_block_rule_t, rule); /* rule */ + WRITE(4, int32_t, flags); /* flags */ /* final pad */ PAD(__pos, 8); @@ -359,7 +318,7 @@ int rbug_send_context_rule_delete(struct rbug_connection *__con, if (__pos != __len) { __ret = -EINVAL; } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_RULE_DELETE, __len); + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_FLUSH, __len); rbug_connection_write(__con, __data, __len); __ret = rbug_connection_send_finish(__con, __serial); } @@ -471,47 +430,6 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, return __ret; } -int rbug_send_context_rule_add_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_block_rule_t rule, - 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); /* rule */ - - /* align */ - PAD(__len, 8); - - __data = (uint8_t*)MALLOC(__len); - if (!__data) - return -ENOMEM; - - WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_RULE_ADD_REPLY)); - WRITE(4, uint32_t, ((uint32_t)(__len / 4))); - WRITE(4, uint32_t, serial); /* serial */ - WRITE(8, rbug_block_rule_t, rule); /* rule */ - - /* final pad */ - PAD(__pos, 8); - - if (__pos != __len) { - __ret = -EINVAL; - } else { - rbug_connection_send_start(__con, RBUG_OP_CONTEXT_RULE_ADD_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, @@ -690,44 +608,16 @@ struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(str 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_rule_add * rbug_demarshal_context_rule_add(struct rbug_proto_header *header) +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_rule_add *ret; + struct rbug_proto_context_draw_rule *ret; if (!header) return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_RULE_ADD) + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_RULE) return NULL; pos = 0; @@ -750,16 +640,16 @@ struct rbug_proto_context_rule_add * rbug_demarshal_context_rule_add(struct rbug return ret; } -struct rbug_proto_context_rule_delete * rbug_demarshal_context_rule_delete(struct rbug_proto_header *header) +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_rule_delete *ret; + struct rbug_proto_context_flush *ret; if (!header) return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_RULE_DELETE) + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_FLUSH) return NULL; pos = 0; @@ -773,7 +663,7 @@ struct rbug_proto_context_rule_delete * rbug_demarshal_context_rule_delete(struc ret->header.opcode = header->opcode; READ(8, rbug_context_t, context); /* context */ - READ(8, rbug_block_rule_t, rule); /* rule */ + READ(4, int32_t, flags); /* flags */ return ret; } @@ -840,34 +730,6 @@ struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct return ret; } -struct rbug_proto_context_rule_add_reply * rbug_demarshal_context_rule_add_reply(struct rbug_proto_header *header) -{ - uint32_t len = 0; - uint32_t pos = 0; - uint8_t *data = NULL; - struct rbug_proto_context_rule_add_reply *ret; - - if (!header) - return NULL; - if (header->opcode != (int16_t)RBUG_OP_CONTEXT_RULE_ADD_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_block_rule_t, rule); /* rule */ - - return ret; -} - struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header) { uint32_t len = 0; diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h index 178a3bce24..da61c2365b 100644 --- a/src/gallium/auxiliary/rbug/rbug_context.h +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -41,12 +41,12 @@ #include "rbug/rbug_proto.h" #include "rbug/rbug_core.h" -typedef uint64_t rbug_block_rule_t; - 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 @@ -81,14 +81,7 @@ struct rbug_proto_context_draw_unblock rbug_block_t unblock; }; -struct rbug_proto_context_flush -{ - struct rbug_header header; - rbug_context_t context; - int32_t flags; -}; - -struct rbug_proto_context_rule_add +struct rbug_proto_context_draw_rule { struct rbug_header header; rbug_context_t context; @@ -99,11 +92,11 @@ struct rbug_proto_context_rule_add rbug_block_t block; }; -struct rbug_proto_context_rule_delete +struct rbug_proto_context_flush { struct rbug_header header; rbug_context_t context; - rbug_block_rule_t rule; + int32_t flags; }; struct rbug_proto_context_list_reply @@ -129,13 +122,6 @@ struct rbug_proto_context_info_reply rbug_block_t blocked; }; -struct rbug_proto_context_rule_add_reply -{ - struct rbug_header header; - uint32_t serial; - rbug_block_rule_t rule; -}; - struct rbug_proto_context_draw_blocked { struct rbug_header header; @@ -165,25 +151,20 @@ int rbug_send_context_draw_unblock(struct rbug_connection *__con, 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_rule_add(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_rule_delete(struct rbug_connection *__con, - rbug_context_t context, - rbug_block_rule_t rule, - uint32_t *__serial); - int rbug_send_context_list_reply(struct rbug_connection *__con, uint32_t serial, rbug_context_t *contexts, @@ -203,11 +184,6 @@ int rbug_send_context_info_reply(struct rbug_connection *__con, rbug_block_t blocked, uint32_t *__serial); -int rbug_send_context_rule_add_reply(struct rbug_connection *__con, - uint32_t serial, - rbug_block_rule_t rule, - uint32_t *__serial); - int rbug_send_context_draw_blocked(struct rbug_connection *__con, rbug_context_t context, rbug_block_t block, @@ -223,18 +199,14 @@ struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rb struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header); -struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header); - -struct rbug_proto_context_rule_add * rbug_demarshal_context_rule_add(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_rule_delete * rbug_demarshal_context_rule_delete(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_rule_add_reply * rbug_demarshal_context_rule_add_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_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c index b3929b9cb4..47390fbcee 100644 --- a/src/gallium/auxiliary/rbug/rbug_demarshal.c +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -65,18 +65,14 @@ struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) 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_RULE_ADD: - return (struct rbug_header *)rbug_demarshal_context_rule_add(header); - case RBUG_OP_CONTEXT_RULE_DELETE: - return (struct rbug_header *)rbug_demarshal_context_rule_delete(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_RULE_ADD_REPLY: - return (struct rbug_header *)rbug_demarshal_context_rule_add_reply(header); case RBUG_OP_CONTEXT_DRAW_BLOCKED: return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header); case RBUG_OP_SHADER_LIST: diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h index 5ef345d72d..d273be0166 100644 --- a/src/gallium/auxiliary/rbug/rbug_proto.h +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -55,12 +55,10 @@ enum rbug_opcode RBUG_OP_CONTEXT_DRAW_BLOCK = 514, RBUG_OP_CONTEXT_DRAW_STEP = 515, RBUG_OP_CONTEXT_DRAW_UNBLOCK = 516, - RBUG_OP_CONTEXT_FLUSH = 518, - RBUG_OP_CONTEXT_RULE_ADD = 521, - RBUG_OP_CONTEXT_RULE_DELETE = 522, + 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_RULE_ADD_REPLY = -521, RBUG_OP_CONTEXT_DRAW_BLOCKED = 517, RBUG_OP_SHADER_LIST = 768, RBUG_OP_SHADER_INFO = 769, -- cgit v1.2.3 From 4d16eb5e180734638fac38a8ce88541926f75c21 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Jun 2009 15:39:47 +0100 Subject: util: Single precision constants. --- src/gallium/auxiliary/util/u_gen_mipmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 6fa13a8ce1..ca797486a0 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1385,7 +1385,7 @@ set_vertex_data(struct gen_mipmap_state *ctx, * 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.9999; + 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; -- cgit v1.2.3