From: Michal Date: Sun, 18 Nov 2007 13:20:57 +0000 (+0000) Subject: Fix compatibility issues between gcc and msvc. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e31e24659a1e691bdfa213fcd073bbfaa4ed6e9;p=mesa.git Fix compatibility issues between gcc and msvc. --- diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index e4a65b9f243..f8fc23b5101 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -61,7 +61,7 @@ static void draw_prim_queue_flush( struct draw_context *draw ) unsigned i; if (0) - printf("Flushing with %d prims, %d verts\n", + fprintf(stdout,"Flushing with %d prims, %d verts\n", draw->pq.queue_nr, draw->vs.queue_nr); /* Make sure all vertices are available/shaded: diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index b510a4dbba2..88fa80dddcd 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -80,6 +80,13 @@ fetch_attrib4(const void *ptr, unsigned format, float attrib[4]) attrib[0] = (float) ((int *) ptr)[0]; break; + case PIPE_FORMAT_U_A8_R8_G8_B8: + attrib[0] = (float) ((unsigned char *) ptr)[2] / 255.0f; + attrib[1] = (float) ((unsigned char *) ptr)[1] / 255.0f; + attrib[2] = (float) ((unsigned char *) ptr)[0] / 255.0f; + attrib[3] = (float) ((unsigned char *) ptr)[3] / 255.0f; + break; + default: assert(0); } diff --git a/src/mesa/pipe/i915simple/i915_debug.c b/src/mesa/pipe/i915simple/i915_debug.c index 001f695e2bf..94db44e1aaf 100644 --- a/src/mesa/pipe/i915simple/i915_debug.c +++ b/src/mesa/pipe/i915simple/i915_debug.c @@ -33,7 +33,21 @@ #include "i915_debug.h" #include "pipe/p_winsys.h" -#define PRINTF( ... ) (stream)->winsys->printf( (stream)->winsys, __VA_ARGS__ ) + +static void +PRINTF( + struct debug_stream *stream, + const char *fmt, + ... ) +{ + va_list args; + char buffer[256]; + + va_start( args, fmt ); + vsprintf( buffer, fmt, args ); + stream->winsys->printf( stream->winsys, buffer ); + va_end( args ); +} static boolean debug( struct debug_stream *stream, const char *name, unsigned len ) @@ -42,19 +56,19 @@ static boolean debug( struct debug_stream *stream, const char *name, unsigned le unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); if (len == 0) { - PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return FALSE; } if (stream->print_addresses) - PRINTF("%08x: ", stream->offset); + PRINTF(stream, "%08x: ", stream->offset); - PRINTF("%s (%d dwords):\n", name, len); + PRINTF(stream, "%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - PRINTF("\t0x%08x\n", ptr[i]); - PRINTF("\n"); + PRINTF(stream, "\t0x%08x\n", ptr[i]); + PRINTF(stream, "\n"); stream->offset += len * sizeof(unsigned); @@ -91,17 +105,17 @@ static boolean debug_prim( struct debug_stream *stream, const char *name, - PRINTF("%s %s (%d dwords):\n", name, prim, len); - PRINTF("\t0x%08x\n", ptr[0]); + PRINTF(stream, "%s %s (%d dwords):\n", name, prim, len); + PRINTF(stream, "\t0x%08x\n", ptr[0]); for (i = 1; i < len; i++) { if (dump_floats) - PRINTF("\t0x%08x // %f\n", ptr[i], *(float *)&ptr[i]); + PRINTF(stream, "\t0x%08x // %f\n", ptr[i], *(float *)&ptr[i]); else - PRINTF("\t0x%08x\n", ptr[i]); + PRINTF(stream, "\t0x%08x\n", ptr[i]); } - PRINTF("\n"); + PRINTF(stream, "\n"); stream->offset += len * sizeof(unsigned); @@ -116,15 +130,15 @@ static boolean debug_program( struct debug_stream *stream, const char *name, uns unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); if (len == 0) { - PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return FALSE; } if (stream->print_addresses) - PRINTF("%08x: ", stream->offset); + PRINTF(stream, "%08x: ", stream->offset); - PRINTF("%s (%d dwords):\n", name, len); + PRINTF(stream, "%s (%d dwords):\n", name, len); i915_disassemble_program( stream, ptr, len ); stream->offset += len * sizeof(unsigned); @@ -138,17 +152,17 @@ static boolean debug_chain( struct debug_stream *stream, const char *name, unsig unsigned old_offset = stream->offset + len * sizeof(unsigned); unsigned i; - PRINTF("%s (%d dwords):\n", name, len); + PRINTF(stream, "%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - PRINTF("\t0x%08x\n", ptr[i]); + PRINTF(stream, "\t0x%08x\n", ptr[i]); stream->offset = ptr[1] & ~0x3; if (stream->offset < old_offset) - PRINTF("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", + PRINTF(stream, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); else - PRINTF("\n... skipping from 0x%x --> 0x%x ...\n\n", + PRINTF(stream, "\n... skipping from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); @@ -168,23 +182,38 @@ static boolean debug_variable_length_prim( struct debug_stream *stream ) len = 1+(i+2)/2; - PRINTF("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); + PRINTF(stream, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); for (i = 0; i < len; i++) - PRINTF("\t0x%08x\n", ptr[i]); - PRINTF("\n"); + PRINTF(stream, "\t0x%08x\n", ptr[i]); + PRINTF(stream, "\n"); stream->offset += len * sizeof(unsigned); return TRUE; } -#define BITS( dw, hi, lo, ... ) \ -do { \ - unsigned himask = ~0UL >> (31 - (hi)); \ - PRINTF("\t\t "); \ - PRINTF(__VA_ARGS__); \ - PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \ -} while (0) +static void +BITS( + struct debug_stream *stream, + unsigned dw, + unsigned hi, + unsigned lo, + const char *fmt, + ... ) +{ + va_list args; + char buffer[256]; + unsigned himask = ~0UL >> (31 - (hi)); + + PRINTF(stream, "\t\t "); + + va_start( args, fmt ); + vsprintf( buffer, fmt, args ); + stream->winsys->printf( stream->winsys, buffer ); + va_end( args ); + + PRINTF(stream, ": 0x%x\n", ((dw) & himask) >> (lo)); +} #define MBZ( dw, hi, lo) do { \ unsigned x = (dw) >> (lo); \ @@ -194,14 +223,28 @@ do { \ assert ((x & himask & ~lomask) == 0); \ } while (0) -#define FLAG( dw, bit, ... ) \ -do { \ - if (((dw) >> (bit)) & 1) { \ - PRINTF("\t\t "); \ - PRINTF(__VA_ARGS__); \ - PRINTF("\n"); \ - } \ -} while (0) +static void +FLAG( + struct debug_stream *stream, + unsigned dw, + unsigned bit, + const char *fmt, + ... ) +{ + if (((dw) >> (bit)) & 1) { + va_list args; + char buffer[256]; + + PRINTF(stream, "\t\t "); + + va_start( args, fmt ); + vsprintf( buffer, fmt, args ); + stream->winsys->printf( stream->winsys, buffer ); + va_end( args ); + + PRINTF(stream, "\n"); + } +} static boolean debug_load_immediate( struct debug_stream *stream, const char *name, @@ -211,95 +254,95 @@ static boolean debug_load_immediate( struct debug_stream *stream, unsigned bits = (ptr[0] >> 4) & 0xff; unsigned j = 0; - PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords, flags: %x):\n", name, len, bits); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); if (bits & (1<<0)) { - PRINTF("\t LIS0: 0x%08x\n", ptr[j]); - PRINTF("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); - BITS(ptr[j], 0, 0, "vb invalidate disable"); + PRINTF(stream, "\t LIS0: 0x%08x\n", ptr[j]); + PRINTF(stream, "\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); + BITS(stream, ptr[j], 0, 0, "vb invalidate disable"); j++; } if (bits & (1<<1)) { - PRINTF("\t LIS1: 0x%08x\n", ptr[j]); - BITS(ptr[j], 29, 24, "vb dword width"); - BITS(ptr[j], 21, 16, "vb dword pitch"); - BITS(ptr[j], 15, 0, "vb max index"); + PRINTF(stream, "\t LIS1: 0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 29, 24, "vb dword width"); + BITS(stream, ptr[j], 21, 16, "vb dword pitch"); + BITS(stream, ptr[j], 15, 0, "vb max index"); j++; } if (bits & (1<<2)) { int i; - PRINTF("\t LIS2: 0x%08x\n", ptr[j]); + PRINTF(stream, "\t LIS2: 0x%08x\n", ptr[j]); for (i = 0; i < 8; i++) { unsigned tc = (ptr[j] >> (i * 4)) & 0xf; if (tc != 0xf) - BITS(tc, 3, 0, "tex coord %d", i); + BITS(stream, tc, 3, 0, "tex coord %d", i); } j++; } if (bits & (1<<3)) { - PRINTF("\t LIS3: 0x%08x\n", ptr[j]); + PRINTF(stream, "\t LIS3: 0x%08x\n", ptr[j]); j++; } if (bits & (1<<4)) { - PRINTF("\t LIS4: 0x%08x\n", ptr[j]); - BITS(ptr[j], 31, 23, "point width"); - BITS(ptr[j], 22, 19, "line width"); - FLAG(ptr[j], 18, "alpha flatshade"); - FLAG(ptr[j], 17, "fog flatshade"); - FLAG(ptr[j], 16, "spec flatshade"); - FLAG(ptr[j], 15, "rgb flatshade"); - BITS(ptr[j], 14, 13, "cull mode"); - FLAG(ptr[j], 12, "vfmt: point width"); - FLAG(ptr[j], 11, "vfmt: specular/fog"); - FLAG(ptr[j], 10, "vfmt: rgba"); - FLAG(ptr[j], 9, "vfmt: depth offset"); - BITS(ptr[j], 8, 6, "vfmt: position (2==xyzw)"); - FLAG(ptr[j], 5, "force dflt diffuse"); - FLAG(ptr[j], 4, "force dflt specular"); - FLAG(ptr[j], 3, "local depth offset enable"); - FLAG(ptr[j], 2, "vfmt: fp32 fog coord"); - FLAG(ptr[j], 1, "sprite point"); - FLAG(ptr[j], 0, "antialiasing"); + PRINTF(stream, "\t LIS4: 0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 31, 23, "point width"); + BITS(stream, ptr[j], 22, 19, "line width"); + FLAG(stream, ptr[j], 18, "alpha flatshade"); + FLAG(stream, ptr[j], 17, "fog flatshade"); + FLAG(stream, ptr[j], 16, "spec flatshade"); + FLAG(stream, ptr[j], 15, "rgb flatshade"); + BITS(stream, ptr[j], 14, 13, "cull mode"); + FLAG(stream, ptr[j], 12, "vfmt: point width"); + FLAG(stream, ptr[j], 11, "vfmt: specular/fog"); + FLAG(stream, ptr[j], 10, "vfmt: rgba"); + FLAG(stream, ptr[j], 9, "vfmt: depth offset"); + BITS(stream, ptr[j], 8, 6, "vfmt: position (2==xyzw)"); + FLAG(stream, ptr[j], 5, "force dflt diffuse"); + FLAG(stream, ptr[j], 4, "force dflt specular"); + FLAG(stream, ptr[j], 3, "local depth offset enable"); + FLAG(stream, ptr[j], 2, "vfmt: fp32 fog coord"); + FLAG(stream, ptr[j], 1, "sprite point"); + FLAG(stream, ptr[j], 0, "antialiasing"); j++; } if (bits & (1<<5)) { - PRINTF("\t LIS5: 0x%08x\n", ptr[j]); - BITS(ptr[j], 31, 28, "rgba write disables"); - FLAG(ptr[j], 27, "force dflt point width"); - FLAG(ptr[j], 26, "last pixel enable"); - FLAG(ptr[j], 25, "global z offset enable"); - FLAG(ptr[j], 24, "fog enable"); - BITS(ptr[j], 23, 16, "stencil ref"); - BITS(ptr[j], 15, 13, "stencil test"); - BITS(ptr[j], 12, 10, "stencil fail op"); - BITS(ptr[j], 9, 7, "stencil pass z fail op"); - BITS(ptr[j], 6, 4, "stencil pass z pass op"); - FLAG(ptr[j], 3, "stencil write enable"); - FLAG(ptr[j], 2, "stencil test enable"); - FLAG(ptr[j], 1, "color dither enable"); - FLAG(ptr[j], 0, "logiop enable"); + PRINTF(stream, "\t LIS5: 0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 31, 28, "rgba write disables"); + FLAG(stream, ptr[j], 27, "force dflt point width"); + FLAG(stream, ptr[j], 26, "last pixel enable"); + FLAG(stream, ptr[j], 25, "global z offset enable"); + FLAG(stream, ptr[j], 24, "fog enable"); + BITS(stream, ptr[j], 23, 16, "stencil ref"); + BITS(stream, ptr[j], 15, 13, "stencil test"); + BITS(stream, ptr[j], 12, 10, "stencil fail op"); + BITS(stream, ptr[j], 9, 7, "stencil pass z fail op"); + BITS(stream, ptr[j], 6, 4, "stencil pass z pass op"); + FLAG(stream, ptr[j], 3, "stencil write enable"); + FLAG(stream, ptr[j], 2, "stencil test enable"); + FLAG(stream, ptr[j], 1, "color dither enable"); + FLAG(stream, ptr[j], 0, "logiop enable"); j++; } if (bits & (1<<6)) { - PRINTF("\t LIS6: 0x%08x\n", ptr[j]); - FLAG(ptr[j], 31, "alpha test enable"); - BITS(ptr[j], 30, 28, "alpha func"); - BITS(ptr[j], 27, 20, "alpha ref"); - FLAG(ptr[j], 19, "depth test enable"); - BITS(ptr[j], 18, 16, "depth func"); - FLAG(ptr[j], 15, "blend enable"); - BITS(ptr[j], 14, 12, "blend func"); - BITS(ptr[j], 11, 8, "blend src factor"); - BITS(ptr[j], 7, 4, "blend dst factor"); - FLAG(ptr[j], 3, "depth write enable"); - FLAG(ptr[j], 2, "color write enable"); - BITS(ptr[j], 1, 0, "provoking vertex"); + PRINTF(stream, "\t LIS6: 0x%08x\n", ptr[j]); + FLAG(stream, ptr[j], 31, "alpha test enable"); + BITS(stream, ptr[j], 30, 28, "alpha func"); + BITS(stream, ptr[j], 27, 20, "alpha ref"); + FLAG(stream, ptr[j], 19, "depth test enable"); + BITS(stream, ptr[j], 18, 16, "depth func"); + FLAG(stream, ptr[j], 15, "blend enable"); + BITS(stream, ptr[j], 14, 12, "blend func"); + BITS(stream, ptr[j], 11, 8, "blend src factor"); + BITS(stream, ptr[j], 7, 4, "blend dst factor"); + FLAG(stream, ptr[j], 3, "depth write enable"); + FLAG(stream, ptr[j], 2, "color write enable"); + BITS(stream, ptr[j], 1, 0, "provoking vertex"); j++; } - PRINTF("\n"); + PRINTF(stream, "\n"); assert(j == len); @@ -318,34 +361,34 @@ static boolean debug_load_indirect( struct debug_stream *stream, unsigned bits = (ptr[0] >> 8) & 0x3f; unsigned i, j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); for (i = 0; i < 6; i++) { if (bits & (1<ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR22(stream, ptr[j++]); @@ -458,8 +501,8 @@ static boolean debug_color_blit( struct debug_stream *stream, unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR22(stream, ptr[j++]); @@ -479,13 +522,13 @@ static boolean debug_modes4( struct debug_stream *stream, unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j]); - BITS(ptr[j], 21, 18, "logicop func"); - FLAG(ptr[j], 17, "stencil test mask modify-enable"); - FLAG(ptr[j], 16, "stencil write mask modify-enable"); - BITS(ptr[j], 15, 8, "stencil test mask"); - BITS(ptr[j], 7, 0, "stencil write mask"); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 21, 18, "logicop func"); + FLAG(stream, ptr[j], 17, "stencil test mask modify-enable"); + FLAG(stream, ptr[j], 16, "stencil write mask modify-enable"); + BITS(stream, ptr[j], 15, 8, "stencil test mask"); + BITS(stream, ptr[j], 7, 0, "stencil write mask"); j++; stream->offset += len * sizeof(unsigned); @@ -500,42 +543,42 @@ static boolean debug_map_state( struct debug_stream *stream, unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); unsigned j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); - BITS(ptr[j], 15, 0, "map mask"); + PRINTF(stream, "\t0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 15, 0, "map mask"); j++; } while (j < len) { { - PRINTF("\t TMn.0: 0x%08x\n", ptr[j]); - PRINTF("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); - FLAG(ptr[j], 1, "vertical line stride"); - FLAG(ptr[j], 0, "vertical line stride offset"); + PRINTF(stream, "\t TMn.0: 0x%08x\n", ptr[j]); + PRINTF(stream, "\t map address: 0x%08x\n", (ptr[j] & ~0x3)); + FLAG(stream, ptr[j], 1, "vertical line stride"); + FLAG(stream, ptr[j], 0, "vertical line stride offset"); j++; } { - PRINTF("\t TMn.1: 0x%08x\n", ptr[j]); - BITS(ptr[j], 31, 21, "height"); - BITS(ptr[j], 20, 10, "width"); - BITS(ptr[j], 9, 7, "surface format"); - BITS(ptr[j], 6, 3, "texel format"); - FLAG(ptr[j], 2, "use fence regs"); - FLAG(ptr[j], 1, "tiled surface"); - FLAG(ptr[j], 0, "tile walk ymajor"); + PRINTF(stream, "\t TMn.1: 0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 31, 21, "height"); + BITS(stream, ptr[j], 20, 10, "width"); + BITS(stream, ptr[j], 9, 7, "surface format"); + BITS(stream, ptr[j], 6, 3, "texel format"); + FLAG(stream, ptr[j], 2, "use fence regs"); + FLAG(stream, ptr[j], 1, "tiled surface"); + FLAG(stream, ptr[j], 0, "tile walk ymajor"); j++; } { - PRINTF("\t TMn.2: 0x%08x\n", ptr[j]); - BITS(ptr[j], 31, 21, "dword pitch"); - BITS(ptr[j], 20, 15, "cube face enables"); - BITS(ptr[j], 14, 9, "max lod"); - FLAG(ptr[j], 8, "mip layout right"); - BITS(ptr[j], 7, 0, "depth"); + PRINTF(stream, "\t TMn.2: 0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 31, 21, "dword pitch"); + BITS(stream, ptr[j], 20, 15, "cube face enables"); + BITS(stream, ptr[j], 14, 9, "max lod"); + FLAG(stream, ptr[j], 8, "mip layout right"); + BITS(stream, ptr[j], 7, 0, "depth"); j++; } } @@ -552,50 +595,50 @@ static boolean debug_sampler_state( struct debug_stream *stream, unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); unsigned j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); - BITS(ptr[j], 15, 0, "sampler mask"); + PRINTF(stream, "\t0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 15, 0, "sampler mask"); j++; } while (j < len) { { - PRINTF("\t TSn.0: 0x%08x\n", ptr[j]); - FLAG(ptr[j], 31, "reverse gamma"); - FLAG(ptr[j], 30, "planar to packed"); - FLAG(ptr[j], 29, "yuv->rgb"); - BITS(ptr[j], 28, 27, "chromakey index"); - BITS(ptr[j], 26, 22, "base mip level"); - BITS(ptr[j], 21, 20, "mip mode filter"); - BITS(ptr[j], 19, 17, "mag mode filter"); - BITS(ptr[j], 16, 14, "min mode filter"); - BITS(ptr[j], 13, 5, "lod bias (s4.4)"); - FLAG(ptr[j], 4, "shadow enable"); - FLAG(ptr[j], 3, "max-aniso-4"); - BITS(ptr[j], 2, 0, "shadow func"); + PRINTF(stream, "\t TSn.0: 0x%08x\n", ptr[j]); + FLAG(stream, ptr[j], 31, "reverse gamma"); + FLAG(stream, ptr[j], 30, "planar to packed"); + FLAG(stream, ptr[j], 29, "yuv->rgb"); + BITS(stream, ptr[j], 28, 27, "chromakey index"); + BITS(stream, ptr[j], 26, 22, "base mip level"); + BITS(stream, ptr[j], 21, 20, "mip mode filter"); + BITS(stream, ptr[j], 19, 17, "mag mode filter"); + BITS(stream, ptr[j], 16, 14, "min mode filter"); + BITS(stream, ptr[j], 13, 5, "lod bias (s4.4)"); + FLAG(stream, ptr[j], 4, "shadow enable"); + FLAG(stream, ptr[j], 3, "max-aniso-4"); + BITS(stream, ptr[j], 2, 0, "shadow func"); j++; } { - PRINTF("\t TSn.1: 0x%08x\n", ptr[j]); - BITS(ptr[j], 31, 24, "min lod"); + PRINTF(stream, "\t TSn.1: 0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 31, 24, "min lod"); MBZ( ptr[j], 23, 18 ); - FLAG(ptr[j], 17, "kill pixel enable"); - FLAG(ptr[j], 16, "keyed tex filter mode"); - FLAG(ptr[j], 15, "chromakey enable"); - BITS(ptr[j], 14, 12, "tcx wrap mode"); - BITS(ptr[j], 11, 9, "tcy wrap mode"); - BITS(ptr[j], 8, 6, "tcz wrap mode"); - FLAG(ptr[j], 5, "normalized coords"); - BITS(ptr[j], 4, 1, "map (surface) index"); - FLAG(ptr[j], 0, "EAST deinterlacer enable"); + FLAG(stream, ptr[j], 17, "kill pixel enable"); + FLAG(stream, ptr[j], 16, "keyed tex filter mode"); + FLAG(stream, ptr[j], 15, "chromakey enable"); + BITS(stream, ptr[j], 14, 12, "tcx wrap mode"); + BITS(stream, ptr[j], 11, 9, "tcy wrap mode"); + BITS(stream, ptr[j], 8, 6, "tcz wrap mode"); + FLAG(stream, ptr[j], 5, "normalized coords"); + BITS(stream, ptr[j], 4, 1, "map (surface) index"); + FLAG(stream, ptr[j], 0, "EAST deinterlacer enable"); j++; } { - PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); + PRINTF(stream, "\t TSn.2: 0x%08x (default color)\n", ptr[j]); j++; } } @@ -612,26 +655,26 @@ static boolean debug_dest_vars( struct debug_stream *stream, unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); - FLAG(ptr[j], 31, "early classic ztest"); - FLAG(ptr[j], 30, "opengl tex default color"); - FLAG(ptr[j], 29, "bypass iz"); - FLAG(ptr[j], 28, "lod preclamp"); - BITS(ptr[j], 27, 26, "dither pattern"); - FLAG(ptr[j], 25, "linear gamma blend"); - FLAG(ptr[j], 24, "debug dither"); - BITS(ptr[j], 23, 20, "dstorg x"); - BITS(ptr[j], 19, 16, "dstorg y"); + PRINTF(stream, "\t0x%08x\n", ptr[j]); + FLAG(stream, ptr[j], 31, "early classic ztest"); + FLAG(stream, ptr[j], 30, "opengl tex default color"); + FLAG(stream, ptr[j], 29, "bypass iz"); + FLAG(stream, ptr[j], 28, "lod preclamp"); + BITS(stream, ptr[j], 27, 26, "dither pattern"); + FLAG(stream, ptr[j], 25, "linear gamma blend"); + FLAG(stream, ptr[j], 24, "debug dither"); + BITS(stream, ptr[j], 23, 20, "dstorg x"); + BITS(stream, ptr[j], 19, 16, "dstorg y"); MBZ (ptr[j], 15, 15 ); - BITS(ptr[j], 14, 12, "422 write select"); - BITS(ptr[j], 11, 8, "cbuf format"); - BITS(ptr[j], 3, 2, "zbuf format"); - FLAG(ptr[j], 1, "vert line stride"); - FLAG(ptr[j], 1, "vert line stride offset"); + BITS(stream, ptr[j], 14, 12, "422 write select"); + BITS(stream, ptr[j], 11, 8, "cbuf format"); + BITS(stream, ptr[j], 3, 2, "zbuf format"); + FLAG(stream, ptr[j], 1, "vert line stride"); + FLAG(stream, ptr[j], 1, "vert line stride offset"); j++; } @@ -647,23 +690,23 @@ static boolean debug_buf_info( struct debug_stream *stream, unsigned *ptr = (unsigned *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); - BITS(ptr[j], 28, 28, "aux buffer id"); - BITS(ptr[j], 27, 24, "buffer id (7=depth, 3=back)"); - FLAG(ptr[j], 23, "use fence regs"); - FLAG(ptr[j], 22, "tiled surface"); - FLAG(ptr[j], 21, "tile walk ymajor"); + PRINTF(stream, "\t0x%08x\n", ptr[j]); + BITS(stream, ptr[j], 28, 28, "aux buffer id"); + BITS(stream, ptr[j], 27, 24, "buffer id (7=depth, 3=back)"); + FLAG(stream, ptr[j], 23, "use fence regs"); + FLAG(stream, ptr[j], 22, "tiled surface"); + FLAG(stream, ptr[j], 21, "tile walk ymajor"); MBZ (ptr[j], 20, 14); - BITS(ptr[j], 13, 2, "dword pitch"); + BITS(stream, ptr[j], 13, 2, "dword pitch"); MBZ (ptr[j], 2, 0); j++; } - PRINTF("\t0x%08x -- buffer base address\n", ptr[j++]); + PRINTF(stream, "\t0x%08x -- buffer base address\n", ptr[j++]); stream->offset += len * sizeof(unsigned); assert(j == len); diff --git a/src/mesa/pipe/i915simple/i915_debug.h b/src/mesa/pipe/i915simple/i915_debug.h index 356c751a5a4..63f7195626a 100644 --- a/src/mesa/pipe/i915simple/i915_debug.h +++ b/src/mesa/pipe/i915simple/i915_debug.h @@ -31,6 +31,8 @@ #ifndef I915_DEBUG_H #define I915_DEBUG_H +#include + struct i915_context; struct debug_stream @@ -68,14 +70,38 @@ void i915_print_ureg(const char *msg, unsigned ureg); #define DEBUG_WINSYS 0x4000 #ifdef DEBUG + #include "pipe/p_winsys.h" -#define I915_DBG( i915, ... ) do { \ - if ((i915)->debug & FILE_DEBUG_FLAG) \ - (i915)->pipe.winsys->printf( (i915)->pipe.winsys, __VA_ARGS__ ); \ -} while(0) + +static void +I915_DBG( + struct i915_context *i915, + const char *fmt, + ... ) +{ + if ((i915)->debug & FILE_DEBUG_FLAG) { + va_list args; + char buffer[256]; + + va_start( args, fmt ); + vsprintf( buffer, fmt, args ); + i915->pipe.winsys->printf( i915->pipe.winsys, buffer ); + va_end( args ); + } +} + #else -#define I915_DBG( i915, ... ) \ - (void)i915 + +static void +I915_DBG( + struct i915_context *i915, + const char *fmt, + ... ) +{ + (void) i915; + (void) fmt; +} + #endif diff --git a/src/mesa/pipe/i915simple/i915_debug_fp.c b/src/mesa/pipe/i915simple/i915_debug_fp.c index ec6b0cbf195..ebfdb3d93c5 100644 --- a/src/mesa/pipe/i915simple/i915_debug_fp.c +++ b/src/mesa/pipe/i915simple/i915_debug_fp.c @@ -32,11 +32,20 @@ #include "pipe/p_util.h" +static void +PRINTF( + struct debug_stream *stream, + const char *fmt, + ... ) +{ + va_list args; + char buffer[256]; - -#define PRINTF( ... ) (stream)->winsys->printf( (stream)->winsys, __VA_ARGS__ ) - - + va_start( args, fmt ); + vsprintf( buffer, fmt, args ); + stream->winsys->printf( stream->winsys, buffer ); + va_end( args ); +} static const char *opcodes[0x20] = { @@ -129,27 +138,27 @@ print_reg_type_nr(struct debug_stream *stream, unsigned type, unsigned nr) case REG_TYPE_T: switch (nr) { case T_DIFFUSE: - PRINTF("T_DIFFUSE"); + PRINTF(stream, "T_DIFFUSE"); return; case T_SPECULAR: - PRINTF("T_SPECULAR"); + PRINTF(stream, "T_SPECULAR"); return; case T_FOG_W: - PRINTF("T_FOG_W"); + PRINTF(stream, "T_FOG_W"); return; default: - PRINTF("T_TEX%d", nr); + PRINTF(stream, "T_TEX%d", nr); return; } case REG_TYPE_OC: if (nr == 0) { - PRINTF("oC"); + PRINTF(stream, "oC"); return; } break; case REG_TYPE_OD: if (nr == 0) { - PRINTF("oD"); + PRINTF(stream, "oD"); return; } break; @@ -157,7 +166,7 @@ print_reg_type_nr(struct debug_stream *stream, unsigned type, unsigned nr) break; } - PRINTF("%s[%d]", regname[type], nr); + PRINTF(stream, "%s[%d]", regname[type], nr); } #define REG_SWIZZLE_MASK 0x7777 @@ -178,33 +187,33 @@ print_reg_neg_swizzle(struct debug_stream *stream, unsigned reg) (reg & REG_NEGATE_MASK) == 0) return; - PRINTF("."); + PRINTF(stream, "."); for (i = 3; i >= 0; i--) { if (reg & (1 << ((i * 4) + 3))) - PRINTF("-"); + PRINTF(stream, "-"); switch ((reg >> (i * 4)) & 0x7) { case 0: - PRINTF("x"); + PRINTF(stream, "x"); break; case 1: - PRINTF("y"); + PRINTF(stream, "y"); break; case 2: - PRINTF("z"); + PRINTF(stream, "z"); break; case 3: - PRINTF("w"); + PRINTF(stream, "w"); break; case 4: - PRINTF("0"); + PRINTF(stream, "0"); break; case 5: - PRINTF("1"); + PRINTF(stream, "1"); break; default: - PRINTF("?"); + PRINTF(stream, "?"); break; } } @@ -229,15 +238,15 @@ print_dest_reg(struct debug_stream *stream, unsigned dword) print_reg_type_nr(stream, type, nr); if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) return; - PRINTF("."); + PRINTF(stream, "."); if (dword & A0_DEST_CHANNEL_X) - PRINTF("x"); + PRINTF(stream, "x"); if (dword & A0_DEST_CHANNEL_Y) - PRINTF("y"); + PRINTF(stream, "y"); if (dword & A0_DEST_CHANNEL_Z) - PRINTF("z"); + PRINTF(stream, "z"); if (dword & A0_DEST_CHANNEL_W) - PRINTF("w"); + PRINTF(stream, "w"); } @@ -253,29 +262,29 @@ print_arith_op(struct debug_stream *stream, if (opcode != A0_NOP) { print_dest_reg(stream, program[0]); if (program[0] & A0_DEST_SATURATE) - PRINTF(" = SATURATE "); + PRINTF(stream, " = SATURATE "); else - PRINTF(" = "); + PRINTF(stream, " = "); } - PRINTF("%s ", opcodes[opcode]); + PRINTF(stream, "%s ", opcodes[opcode]); print_src_reg(stream, GET_SRC0_REG(program[0], program[1])); if (args[opcode] == 1) { - PRINTF("\n"); + PRINTF(stream, "\n"); return; } - PRINTF(", "); + PRINTF(stream, ", "); print_src_reg(stream, GET_SRC1_REG(program[1], program[2])); if (args[opcode] == 2) { - PRINTF("\n"); + PRINTF(stream, "\n"); return; } - PRINTF(", "); + PRINTF(stream, ", "); print_src_reg(stream, GET_SRC2_REG(program[2])); - PRINTF("\n"); + PRINTF(stream, "\n"); return; } @@ -285,40 +294,40 @@ print_tex_op(struct debug_stream *stream, unsigned opcode, const unsigned * program) { print_dest_reg(stream, program[0] | A0_DEST_CHANNEL_ALL); - PRINTF(" = "); + PRINTF(stream, " = "); - PRINTF("%s ", opcodes[opcode]); + PRINTF(stream, "%s ", opcodes[opcode]); - PRINTF("S[%d],", program[0] & T0_SAMPLER_NR_MASK); + PRINTF(stream, "S[%d],", program[0] & T0_SAMPLER_NR_MASK); print_reg_type_nr(stream, (program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK, (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - PRINTF("\n"); + PRINTF(stream, "\n"); } static void print_texkil_op(struct debug_stream *stream, unsigned opcode, const unsigned * program) { - PRINTF("TEXKIL "); + PRINTF(stream, "TEXKIL "); print_reg_type_nr(stream, (program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK, (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - PRINTF("\n"); + PRINTF(stream, "\n"); } static void print_dcl_op(struct debug_stream *stream, unsigned opcode, const unsigned * program) { - PRINTF("%s ", opcodes[opcode]); + PRINTF(stream, "%s ", opcodes[opcode]); print_dest_reg(stream, program[0] | A0_DEST_CHANNEL_ALL); - PRINTF("\n"); + PRINTF(stream, "\n"); } @@ -329,7 +338,7 @@ i915_disassemble_program(struct debug_stream *stream, unsigned size = program[0] & 0x1ff; unsigned i; - PRINTF("\t\tBEGIN\n"); + PRINTF(stream, "\t\tBEGIN\n"); assert(size + 2 == sz); @@ -337,7 +346,7 @@ i915_disassemble_program(struct debug_stream *stream, for (i = 1; i < sz; i += 3, program += 3) { unsigned opcode = program[0] & (0x1f << 24); - PRINTF("\t\t"); + PRINTF(stream, "\t\t"); if ((int) opcode >= A0_NOP && opcode <= A0_SLT) print_arith_op(stream, opcode >> 24, program); @@ -348,10 +357,10 @@ i915_disassemble_program(struct debug_stream *stream, else if (opcode == D0_DCL) print_dcl_op(stream, opcode >> 24, program); else - PRINTF("Unknown opcode 0x%x\n", opcode); + PRINTF(stream, "Unknown opcode 0x%x\n", opcode); } - PRINTF("\t\tEND\n\n"); + PRINTF(stream, "\t\tEND\n\n"); } diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index f9673e54245..0382aa26a98 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -117,11 +117,13 @@ void i915_program_error(struct i915_fp_compile *p, const char *msg, ...) { va_list args; + char buffer[1024]; fprintf(stderr, "i915_program_error: "); va_start( args, msg ); - vfprintf( stderr, msg, args ); + vsprintf( buffer, msg, args ); va_end( args ); + fprintf(stderr, buffer); fprintf(stderr, "\n"); p->error = 1; @@ -381,6 +383,9 @@ emit_simple_arith(struct i915_fp_compile *p, arg3 ); } +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif /* * Translate TGSI instruction to i915 instruction. @@ -430,7 +435,7 @@ i915_translate_instruction(struct i915_fp_compile *p, i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0f / (M_PI * 2.0f)), 0); + src0, i915_emit_const1f(p, 1.0f / (float) (M_PI * 2.0)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -439,7 +444,7 @@ i915_translate_instruction(struct i915_fp_compile *p, i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2.0f)), 0); + tmp, i915_emit_const1f(p, (float) (M_PI * 2.0)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 @@ -772,7 +777,7 @@ i915_translate_instruction(struct i915_fp_compile *p, i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0f / (float) (M_PI * 2.0)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -781,7 +786,7 @@ i915_translate_instruction(struct i915_fp_compile *p, i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (float) (M_PI * 2.0)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index 1c8c6a37ba6..736a08fb09b 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -202,7 +202,7 @@ static void vbuf_tri( struct draw_stage *stage, for (i = 0; i < 3; i++) { emit_vertex( vbuf, prim->v[i] ); - vbuf->element_map[vbuf->nr_elements++] = prim->v[i]->vertex_id; + vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[i]->vertex_id; } } @@ -218,7 +218,7 @@ static void vbuf_line(struct draw_stage *stage, for (i = 0; i < 2; i++) { emit_vertex( vbuf, prim->v[i] ); - vbuf->element_map[vbuf->nr_elements++] = prim->v[i]->vertex_id; + vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[i]->vertex_id; } } @@ -232,7 +232,7 @@ static void vbuf_point(struct draw_stage *stage, emit_vertex( vbuf, prim->v[0] ); - vbuf->element_map[vbuf->nr_elements++] = prim->v[0]->vertex_id; + vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[0]->vertex_id; } diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c index 08fa513de49..8cfbdddd19b 100644 --- a/src/mesa/pipe/i915simple/i915_state_dynamic.c +++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c @@ -45,7 +45,7 @@ * (active) state every time a 4kb boundary is crossed. */ -static inline void set_dynamic_indirect( struct i915_context *i915, +static INLINE void set_dynamic_indirect( struct i915_context *i915, unsigned offset, const unsigned *src, unsigned dwords ) diff --git a/src/mesa/pipe/i915simple/i915_strings.c b/src/mesa/pipe/i915simple/i915_strings.c index a9b0bfc7c27..c713bf72086 100644 --- a/src/mesa/pipe/i915simple/i915_strings.c +++ b/src/mesa/pipe/i915simple/i915_strings.c @@ -70,7 +70,7 @@ static const char *i915_get_name( struct pipe_context *pipe ) break; } - snprintf(buffer, sizeof(buffer), "pipe/i915 (chipset: %s)", chipset); + sprintf(buffer, "pipe/i915 (chipset: %s)", chipset); return buffer; } diff --git a/src/mesa/pipe/tgsi/tgsi_platform.h b/src/mesa/pipe/tgsi/tgsi_platform.h index b98a1f21bec..e7a381b201b 100644 --- a/src/mesa/pipe/tgsi/tgsi_platform.h +++ b/src/mesa/pipe/tgsi/tgsi_platform.h @@ -1,19 +1,16 @@ -#if !defined TGSI_PLATFORM_H -#define TGSI_PLATFORM_H - -#if defined __cplusplus -extern "C" { -#endif // defined __cplusplus - -#include "imports.h" -#include "mtypes.h" -#include "prog_instruction.h" -#include "program.h" -#include "pipe/p_compiler.h" - -#if defined __cplusplus -} // extern "C" -#endif // defined __cplusplus - -#endif // !defined TGSI_PLATFORM_H - +#if !defined TGSI_PLATFORM_H +#define TGSI_PLATFORM_H + +#if defined __cplusplus +extern "C" { +#endif // defined __cplusplus + +#include "pipe/p_compiler.h" +#include "pipe/p_util.h" + +#if defined __cplusplus +} // extern "C" +#endif // defined __cplusplus + +#endif // !defined TGSI_PLATFORM_H +