From 69e42ec4568e824bf16271830751436afb2e8ef9 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 4 Mar 2009 20:34:54 +0100 Subject: nouveau: Use proper SIFM object on NV30 --- src/gallium/drivers/nv04/nv04_surface_2d.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index e8fd3166ab..3c8257ad25 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -437,13 +437,17 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws) return NULL; } - if (chan->device->chipset < 0x10) { - class = NV04_SCALED_IMAGE_FROM_MEMORY; - } else - if (chan->device->chipset < 0x40) { - class = NV10_SCALED_IMAGE_FROM_MEMORY; - } else { + switch (chan->device->chipset & 0xf0) { + case 0x30: + class = NV30_SCALED_IMAGE_FROM_MEMORY; + break; + case 0x40: + case 0x60: class = NV40_SCALED_IMAGE_FROM_MEMORY; + break; + default: + class = NV04_SCALED_IMAGE_FROM_MEMORY; + break; } ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm); -- cgit v1.2.3 From 41117b1a018baa7ce2c2e4f0eba7a56d33626e97 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 4 Mar 2009 20:38:14 +0100 Subject: nouveau: oops, forgot to keep the NV10_SIFM object --- src/gallium/drivers/nv04/nv04_surface_2d.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index 3c8257ad25..f3a8d7efee 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -438,6 +438,10 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws) } switch (chan->device->chipset & 0xf0) { + case 0x10: + case 0x20: + class = NV10_SCALED_IMAGE_FROM_MEMORY; + break; case 0x30: class = NV30_SCALED_IMAGE_FROM_MEMORY; break; -- cgit v1.2.3 From 79a05a6b3f8a995c80d27a1f32f85ad84b1a6f9d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 21:35:17 +0000 Subject: indices: add translate/generate functions for unfilled modes Most of the time unfilled rendering requires a lot more thought than just translating triangles to lines or points. But sometimes, you can do exactly that, and it can be quite a bit quicker. Add code to do the translation. The caller has to determine whether it's a legal thing to do in the current state, in particular you'd need: - culling disabled - offset disabled - same front and back fill modes - possibly other stuff I can't think of. --- src/gallium/auxiliary/indices/Makefile | 6 +- src/gallium/auxiliary/indices/SConscript | 9 + src/gallium/auxiliary/indices/u_indices.h | 23 + src/gallium/auxiliary/indices/u_unfilled_gen.c | 1152 ++++++++++++++++++++ src/gallium/auxiliary/indices/u_unfilled_gen.py | 247 +++++ src/gallium/auxiliary/indices/u_unfilled_indices.c | 186 ++++ 6 files changed, 1622 insertions(+), 1 deletion(-) create mode 100644 src/gallium/auxiliary/indices/u_unfilled_gen.c create mode 100644 src/gallium/auxiliary/indices/u_unfilled_gen.py create mode 100644 src/gallium/auxiliary/indices/u_unfilled_indices.c (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/indices/Makefile b/src/gallium/auxiliary/indices/Makefile index 25ee899c40..f2ebc3f410 100644 --- a/src/gallium/auxiliary/indices/Makefile +++ b/src/gallium/auxiliary/indices/Makefile @@ -4,9 +4,13 @@ include $(TOP)/configs/current LIBNAME = indices C_SOURCES = \ - u_indices_gen.c + u_indices_gen.c \ + u_unfilled_gen.c include ../../Makefile.template u_indices_gen.c: u_indices_gen.py python $< > $@ + +u_unfilled_gen.c: u_unfilled_gen.py + python $< > $@ diff --git a/src/gallium/auxiliary/indices/SConscript b/src/gallium/auxiliary/indices/SConscript index 65a43a9f64..e5f7ee9484 100644 --- a/src/gallium/auxiliary/indices/SConscript +++ b/src/gallium/auxiliary/indices/SConscript @@ -7,11 +7,20 @@ env.CodeGenerate( command = 'python $SCRIPT > $TARGET' ) +env.CodeGenerate( + target = 'u_unfilled_gen.c', + script = 'u_unfilled_gen.py', + source = [], + command = 'python $SCRIPT > $TARGET' +) + indices = env.ConvenienceLibrary( target = 'indices', source = [ # 'u_indices.c', +# 'u_unfilled_indices.c', 'u_indices_gen.c', + 'u_unfilled_gen.c', ]) auxiliaries.insert(0, indices) diff --git a/src/gallium/auxiliary/indices/u_indices.h b/src/gallium/auxiliary/indices/u_indices.h index abf5a3037d..be522c6725 100644 --- a/src/gallium/auxiliary/indices/u_indices.h +++ b/src/gallium/auxiliary/indices/u_indices.h @@ -80,4 +80,27 @@ int u_index_generator( unsigned hw_mask, u_generate_func *out_generate ); +void u_unfilled_init( void ); + +int u_unfilled_translator( unsigned prim, + unsigned in_index_size, + unsigned nr, + unsigned unfilled_mode, + unsigned *out_prim, + unsigned *out_index_size, + unsigned *out_nr, + u_translate_func *out_translate ); + +int u_unfilled_generator( unsigned prim, + unsigned start, + unsigned nr, + unsigned unfilled_mode, + unsigned *out_prim, + unsigned *out_index_size, + unsigned *out_nr, + u_generate_func *out_generate ); + + + + #endif diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.c b/src/gallium/auxiliary/indices/u_unfilled_gen.c new file mode 100644 index 0000000000..fd082ebbb3 --- /dev/null +++ b/src/gallium/auxiliary/indices/u_unfilled_gen.c @@ -0,0 +1,1152 @@ +/* File automatically generated by u_unfilled_gen.py */ + +/* + * 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. + */ + + + +/** + * @file + * Functions to translate and generate index lists + */ + +#include "indices/u_indices.h" +#include "indices/u_indices_priv.h" +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "pipe/p_defines.h" +#include "util/u_memory.h" + + +static unsigned out_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return OUT_UINT; + case 2: return OUT_USHORT; + default: assert(0); return OUT_USHORT; + } +} + +static unsigned in_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return IN_UINT; + case 2: return IN_USHORT; + case 1: return IN_UBYTE; + default: assert(0); return IN_UBYTE; + } +} + + +static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT]; +static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT]; + + +static void generate_tris_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + 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); + } +} +static void generate_tristrip_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + 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); + } +} +static void generate_trifan_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + 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); + } +} +static void generate_quads_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + 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); + } +} +static void generate_quadstrip_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + 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); + } +} +static void generate_polygon_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + 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); + } +} +static void generate_tris_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + 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); + } +} +static void generate_tristrip_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + 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); + } +} +static void generate_trifan_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + 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); + } +} +static void generate_quads_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + 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); + } +} +static void generate_quadstrip_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + 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); + } +} +static void generate_polygon_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + 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); + } +} +static void translate_tris_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_tristrip_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_trifan_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_quads_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_quadstrip_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_polygon_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_tris_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_tristrip_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_trifan_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_quads_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_quadstrip_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_polygon_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_tris_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_tristrip_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_trifan_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_quads_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_quadstrip_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_polygon_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_tris_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_tristrip_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_trifan_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_quads_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_quadstrip_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_polygon_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_tris_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_tristrip_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_trifan_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_quads_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_quadstrip_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_polygon_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + 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]; + } +} +static void translate_tris_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_tristrip_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_trifan_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_quads_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_quadstrip_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + 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]; + } +} +static void translate_polygon_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + 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]; + } +} +void u_unfilled_init( void ) +{ + static int firsttime = 1; + if (!firsttime) return; + firsttime = 0; +generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES] = generate_tris_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_QUADS] = generate_quads_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_POLYGON] = generate_polygon_ushort; +generate_line[OUT_UINT][PIPE_PRIM_TRIANGLES] = generate_tris_uint; +generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint; +generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint; +generate_line[OUT_UINT][PIPE_PRIM_QUADS] = generate_quads_uint; +generate_line[OUT_UINT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint; +generate_line[OUT_UINT][PIPE_PRIM_POLYGON] = generate_polygon_uint; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint; +} +#include "indices/u_unfilled_indices.c" diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py new file mode 100644 index 0000000000..d0344fe313 --- /dev/null +++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py @@ -0,0 +1,247 @@ +#!/usr/bin/env python +copyright = ''' +/* + * 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. + */ +''' + +GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint' +FIRST, LAST = 'first', 'last' + +INTYPES = (GENERATE, UBYTE, USHORT, UINT) +OUTTYPES = (USHORT, UINT) +PRIMS=('tris', + 'trifan', + 'tristrip', + 'quads', + 'quadstrip', + 'polygon') + +LONGPRIMS=('PIPE_PRIM_TRIANGLES', + 'PIPE_PRIM_TRIANGLE_FAN', + 'PIPE_PRIM_TRIANGLE_STRIP', + 'PIPE_PRIM_QUADS', + 'PIPE_PRIM_QUAD_STRIP', + 'PIPE_PRIM_POLYGON') + +longprim = dict(zip(PRIMS, LONGPRIMS)) +intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT') +outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT') + + +def prolog(): + print '''/* File automatically generated by u_unfilled_gen.py */''' + print copyright + print r''' + +/** + * @file + * Functions to translate and generate index lists + */ + +#include "indices/u_indices.h" +#include "indices/u_indices_priv.h" +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "pipe/p_defines.h" +#include "util/u_memory.h" + + +static unsigned out_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return OUT_UINT; + case 2: return OUT_USHORT; + default: assert(0); return OUT_USHORT; + } +} + +static unsigned in_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return IN_UINT; + case 2: return IN_USHORT; + case 1: return IN_UBYTE; + default: assert(0); return IN_UBYTE; + } +} + + +static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT]; +static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT]; + +''' + +def vert( intype, outtype, v0 ): + if intype == GENERATE: + return '(' + outtype + ')(' + v0 + ')' + else: + 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 ) + ';' + +# XXX: have the opportunity here to avoid over-drawing shared lines in +# tristrips, fans, etc, by integrating this into the calling functions +# and only emitting each line at most once. +# +def do_tri( intype, outtype, ptr, v0, v1, v2 ): + line( intype, outtype, ptr, v0, v1 ) + line( intype, outtype, ptr + '+2', v1, v2 ) + line( intype, outtype, ptr + '+4', v2, v0 ) + +def do_quad( intype, outtype, ptr, v0, v1, v2, v3 ): + line( intype, outtype, ptr, v0, v1 ) + line( intype, outtype, ptr + '+2', v1, v2 ) + line( intype, outtype, ptr + '+4', v2, v3 ) + line( intype, outtype, ptr + '+6', v3, v0 ) + +def name(intype, outtype, prim): + if intype == GENERATE: + return 'generate_' + prim + '_' + outtype + else: + return 'translate_' + prim + '_' + intype + '2' + outtype + +def preamble(intype, outtype, prim): + print 'static void ' + name( intype, outtype, prim ) + '(' + if intype != GENERATE: + print ' const void * _in,' + print ' unsigned nr,' + print ' void *_out )' + print '{' + if intype != GENERATE: + print ' const ' + intype + '*in = (const ' + intype + '*)_in;' + print ' ' + outtype + ' *out = (' + outtype + '*)_out;' + print ' unsigned i, j;' + print ' (void)j;' + +def postamble(): + print '}' + + +def tris(intype, outtype): + preamble(intype, outtype, prim='tris') + print ' for (j = i = 0; j < nr; j+=6, i+=3) { ' + do_tri( intype, outtype, 'out+j', 'i', 'i+1', 'i+2' ); + print ' }' + postamble() + + +def tristrip(intype, outtype): + preamble(intype, outtype, prim='tristrip') + print ' for (j = i = 0; j < nr; j+=6, i++) { ' + do_tri( intype, outtype, 'out+j', 'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' ); + print ' }' + postamble() + + +def trifan(intype, outtype): + preamble(intype, outtype, prim='trifan') + print ' for (j = i = 0; j < nr; j+=6, i++) { ' + do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' ); + print ' }' + postamble() + + + +def polygon(intype, outtype): + preamble(intype, outtype, prim='polygon') + print ' for (j = i = 0; j < nr; j+=6, i++) { ' + do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' ); + print ' }' + postamble() + + +def quads(intype, outtype): + preamble(intype, outtype, prim='quads') + print ' for (j = i = 0; j < nr; j+=8, i+=4) { ' + do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' ); + print ' }' + postamble() + + +def quadstrip(intype, outtype): + preamble(intype, outtype, prim='quadstrip') + print ' for (j = i = 0; j < nr; j+=8, i+=2) { ' + do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' ); + print ' }' + postamble() + + +def emit_funcs(): + for intype in INTYPES: + for outtype in OUTTYPES: + tris(intype, outtype) + tristrip(intype, outtype) + trifan(intype, outtype) + quads(intype, outtype) + quadstrip(intype, outtype) + polygon(intype, outtype) + +def init(intype, outtype, prim): + if intype == GENERATE: + print ('generate_line[' + + outtype_idx[outtype] + + '][' + longprim[prim] + + '] = ' + name( intype, outtype, prim ) + ';') + else: + print ('translate_line[' + + intype_idx[intype] + + '][' + outtype_idx[outtype] + + '][' + longprim[prim] + + '] = ' + name( intype, outtype, prim ) + ';') + + +def emit_all_inits(): + for intype in INTYPES: + for outtype in OUTTYPES: + for prim in PRIMS: + init(intype, outtype, prim) + +def emit_init(): + print 'void u_unfilled_init( void )' + print '{' + print ' static int firsttime = 1;' + print ' if (!firsttime) return;' + print ' firsttime = 0;' + emit_all_inits() + print '}' + + + + +def epilog(): + print '#include "indices/u_unfilled_indices.c"' + + +def main(): + prolog() + emit_funcs() + emit_init() + epilog() + + +if __name__ == '__main__': + main() diff --git a/src/gallium/auxiliary/indices/u_unfilled_indices.c b/src/gallium/auxiliary/indices/u_unfilled_indices.c new file mode 100644 index 0000000000..26c5d4d4c7 --- /dev/null +++ b/src/gallium/auxiliary/indices/u_unfilled_indices.c @@ -0,0 +1,186 @@ +/* + * 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 "u_indices.h" +#include "u_indices_priv.h" + + +static void translate_ubyte_ushort( const void *in, + unsigned nr, + void *out ) +{ + const ubyte *in_ub = (const ubyte *)in; + ushort *out_us = (ushort *)out; + unsigned i; + for (i = 0; i < nr; i++) + out_us[i] = (ushort) in_ub[i]; +} + +static void translate_memcpy_ushort( const void *in, + unsigned nr, + void *out ) +{ + memcpy(out, in, nr*sizeof(short)); +} + +static void translate_memcpy_uint( const void *in, + unsigned nr, + void *out ) +{ + memcpy(out, in, nr*sizeof(int)); +} + + +static void generate_linear_ushort( unsigned nr, + void *out ) +{ + ushort *out_us = (ushort *)out; + unsigned i; + for (i = 0; i < nr; i++) + out_us[i] = (ushort) i; +} + +static void generate_linear_uint( unsigned nr, + void *out ) +{ + unsigned *out_ui = (unsigned *)out; + unsigned i; + for (i = 0; i < nr; i++) + out_ui[i] = i; +} + + +static unsigned nr_lines( unsigned prim, + unsigned nr ) +{ + switch (prim) { + case PIPE_PRIM_TRIANGLES: + return (nr / 3) * 6; + case PIPE_PRIM_TRIANGLE_STRIP: + return (nr - 2) * 6; + case PIPE_PRIM_TRIANGLE_FAN: + return (nr - 2) * 6; + case PIPE_PRIM_QUADS: + return (nr / 4) * 8; + case PIPE_PRIM_QUAD_STRIP: + return (nr - 2) / 2 * 8; + case PIPE_PRIM_POLYGON: + return (nr - 2) * 6; + default: + assert(0); + return 0; + } +} + + + +int u_unfilled_translator( unsigned prim, + unsigned in_index_size, + unsigned nr, + unsigned unfilled_mode, + unsigned *out_prim, + unsigned *out_index_size, + unsigned *out_nr, + u_translate_func *out_translate ) +{ + unsigned in_idx; + unsigned out_idx; + + u_unfilled_init(); + + in_idx = in_size_idx(in_index_size); + *out_index_size = (in_index_size == 4) ? 4 : 2; + out_idx = out_size_idx(*out_index_size); + + if (unfilled_mode == PIPE_POLYGON_MODE_POINT) + { + *out_prim = PIPE_PRIM_POINTS; + *out_nr = nr; + + switch (in_index_size) + { + case 1: + *out_translate = translate_ubyte_ushort; + return U_TRANSLATE_NORMAL; + case 2: + *out_translate = translate_memcpy_uint; + return U_TRANSLATE_MEMCPY; + case 4: + *out_translate = translate_memcpy_ushort; + return U_TRANSLATE_MEMCPY; + default: + *out_translate = translate_memcpy_uint; + *out_nr = 0; + assert(0); + return U_TRANSLATE_ERROR; + } + } + else { + assert(unfilled_mode == PIPE_POLYGON_MODE_LINE); + *out_prim = PIPE_PRIM_LINES; + *out_translate = translate_line[in_idx][out_idx][prim]; + *out_nr = nr_lines( prim, nr ); + return U_TRANSLATE_NORMAL; + } +} + + + +int u_unfilled_generator( unsigned prim, + unsigned start, + unsigned nr, + unsigned unfilled_mode, + unsigned *out_prim, + unsigned *out_index_size, + unsigned *out_nr, + u_generate_func *out_generate ) +{ + unsigned out_idx; + + u_unfilled_init(); + + *out_index_size = ((start + nr) > 0xfffe) ? 4 : 2; + out_idx = out_size_idx(*out_index_size); + + if (unfilled_mode == PIPE_POLYGON_MODE_POINT) { + + if (*out_index_size == 4) + *out_generate = generate_linear_uint; + else + *out_generate = generate_linear_ushort; + + *out_prim = PIPE_PRIM_POINTS; + *out_nr = nr; + return U_GENERATE_LINEAR; + } + else { + assert(unfilled_mode == PIPE_POLYGON_MODE_LINE); + *out_prim = PIPE_PRIM_LINES; + *out_generate = generate_line[out_idx][prim]; + *out_nr = nr_lines( prim, nr ); + + return U_GENERATE_REUSABLE; + } +} + -- cgit v1.2.3