summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/Makefile3
-rw-r--r--src/gallium/auxiliary/SConscript1
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c115
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe.c42
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c54
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_cull.c13
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_twoside.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_unfilled.c28
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_validate.c19
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c21
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c61
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_decompose.h96
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_emit.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c12
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c12
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c22
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h19
-rw-r--r--src/gallium/auxiliary/draw/draw_vbuf.h12
-rw-r--r--src/gallium/auxiliary/gallivm/f.cpp85
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld.h11
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.c356
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_const.c6
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_debug.h17
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_flow.c15
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format.h9
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_aos.c56
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_soa.c110
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.c18
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_limits.h2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_misc.cpp100
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c8
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h22
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c86
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_swizzle.c108
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_swizzle.h19
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.h4
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c457
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_type.c127
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_type.h12
-rw-r--r--src/gallium/auxiliary/indices/.gitignore2
-rw-r--r--src/gallium/auxiliary/indices/u_indices_gen.c5129
-rw-r--r--src/gallium/auxiliary/indices/u_unfilled_gen.c992
-rw-r--r--src/gallium/auxiliary/os/os_thread.h10
-rw-r--r--src/gallium/auxiliary/os/os_time.c2
-rw-r--r--src/gallium/auxiliary/rbug/README2
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.c21
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.h7
-rw-r--r--src/gallium/auxiliary/target-helpers/wrap_screen.c4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c32
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h22
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c15
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.h3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.c8
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.c7
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_scan.h1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c81
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h4
-rw-r--r--src/gallium/auxiliary/util/u_blit.c4
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c17
-rw-r--r--src/gallium/auxiliary/util/u_debug.c4
-rw-r--r--src/gallium/auxiliary/util/u_debug_symbol.c95
-rw-r--r--src/gallium/auxiliary/util/u_dump.h6
-rw-r--r--src/gallium/auxiliary/util/u_dump_defines.c72
-rw-r--r--src/gallium/auxiliary/util/u_dump_state.c13
-rw-r--r--src/gallium/auxiliary/util/u_format.h20
-rw-r--r--src/gallium/auxiliary/util/u_format_pack.py3
-rwxr-xr-xsrc/gallium/auxiliary/util/u_format_parse.py2
-rw-r--r--src/gallium/auxiliary/util/u_format_srgb.py1
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c3
-rw-r--r--src/gallium/auxiliary/util/u_half.py8
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h18
-rw-r--r--src/gallium/auxiliary/util/u_surface.c1
-rw-r--r--src/gallium/auxiliary/util/u_surfaces.c2
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c4
78 files changed, 1837 insertions, 6955 deletions
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index e0d9b31354..1abf12e95b 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -168,7 +168,8 @@ GALLIVM_SOURCES = \
draw/draw_pt_fetch_shade_pipeline_llvm.c \
draw/draw_llvm_translate.c
-GALLIVM_CPP_SOURCES =
+GALLIVM_CPP_SOURCES = \
+ gallivm/lp_bld_misc.cpp
GENERATED_SOURCES = \
indices/u_indices_gen.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 29a1bd0ecb..7039d5f0c5 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -205,6 +205,7 @@ if env['llvm']:
'gallivm/lp_bld_intr.c',
'gallivm/lp_bld_logic.c',
'gallivm/lp_bld_init.c',
+ 'gallivm/lp_bld_misc.cpp',
'gallivm/lp_bld_pack.c',
'gallivm/lp_bld_printf.c',
'gallivm/lp_bld_sample.c',
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 02abddf149..61980c3e4f 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -566,7 +566,7 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
memset(&rast, 0, sizeof(rast));
rast.scissor = scissor;
rast.flatshade = flatshade;
- rast.front_winding = PIPE_WINDING_CCW;
+ rast.front_ccw = 1;
rast.gl_rasterization_rules = draw->rasterizer->gl_rasterization_rules;
draw->rasterizer_no_cull[scissor][flatshade] =
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index ea9b7c90a5..7ea51621f7 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -12,6 +12,7 @@
#include "gallivm/lp_bld_printf.h"
#include "tgsi/tgsi_exec.h"
+#include "tgsi/tgsi_dump.h"
#include "util/u_cpu_detect.h"
#include "util/u_string.h"
@@ -21,6 +22,34 @@
#define DEBUG_STORE 0
+/** cast wrapper */
+static INLINE draw_jit_vert_func_elts
+voidptr_to_draw_vert_func_elts(void *v)
+{
+ union {
+ void *v;
+ draw_jit_vert_func_elts f;
+ } u;
+ assert(sizeof(u.v) == sizeof(u.f));
+ u.v = v;
+ return u.f;
+}
+
+
+/** cast wrapper */
+static INLINE draw_jit_vert_func
+voidptr_to_draw_jit_vert_func(void *v)
+{
+ union {
+ void *v;
+ draw_jit_vert_func f;
+ } u;
+ assert(sizeof(u.v) == sizeof(u.f));
+ u.v = v;
+ return u.f;
+}
+
+
/* generates the draw jit function */
static void
draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *var);
@@ -161,9 +190,16 @@ create_vertex_header(struct draw_llvm *llvm, int data_elems)
struct draw_llvm *
draw_llvm_create(struct draw_context *draw)
{
- struct draw_llvm *llvm = CALLOC_STRUCT( draw_llvm );
+ struct draw_llvm *llvm;
+#ifdef PIPE_ARCH_X86
util_cpu_detect();
+ /* require SSE2 due to LLVM PR6960. */
+ if (!util_cpu_caps.has_sse2)
+ return NULL;
+#endif
+
+ llvm = CALLOC_STRUCT( draw_llvm );
llvm->draw = draw;
llvm->engine = draw->engine;
@@ -179,27 +215,34 @@ draw_llvm_create(struct draw_context *draw)
llvm->pass = LLVMCreateFunctionPassManager(llvm->provider);
LLVMAddTargetData(llvm->target, llvm->pass);
- /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
- * but there are more on SVN. */
- /* TODO: Add more passes */
- LLVMAddCFGSimplificationPass(llvm->pass);
- LLVMAddPromoteMemoryToRegisterPass(llvm->pass);
- LLVMAddConstantPropagationPass(llvm->pass);
- if(util_cpu_caps.has_sse4_1) {
- /* FIXME: There is a bug in this pass, whereby the combination of fptosi
- * and sitofp (necessary for trunc/floor/ceil/round implementation)
- * somehow becomes invalid code.
+
+ if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) {
+ /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
+ * but there are more on SVN. */
+ /* TODO: Add more passes */
+ LLVMAddCFGSimplificationPass(llvm->pass);
+ LLVMAddPromoteMemoryToRegisterPass(llvm->pass);
+ LLVMAddConstantPropagationPass(llvm->pass);
+ if(util_cpu_caps.has_sse4_1) {
+ /* FIXME: There is a bug in this pass, whereby the combination of fptosi
+ * and sitofp (necessary for trunc/floor/ceil/round implementation)
+ * somehow becomes invalid code.
+ */
+ LLVMAddInstructionCombiningPass(llvm->pass);
+ }
+ LLVMAddGVNPass(llvm->pass);
+ } else {
+ /* We need at least this pass to prevent the backends to fail in
+ * unexpected ways.
*/
- LLVMAddInstructionCombiningPass(llvm->pass);
+ LLVMAddPromoteMemoryToRegisterPass(llvm->pass);
}
- LLVMAddGVNPass(llvm->pass);
init_globals(llvm);
-
-#if 0
- LLVMDumpModule(llvm->module);
-#endif
+ if (gallivm_debug & GALLIVM_DEBUG_IR) {
+ LLVMDumpModule(llvm->module);
+ }
return llvm;
}
@@ -248,7 +291,10 @@ generate_vs(struct draw_llvm *llvm,
num_vs = 4; /* number of vertices per block */
#endif
- /*tgsi_dump(tokens, 0);*/
+ if (gallivm_debug & GALLIVM_DEBUG_IR) {
+ tgsi_dump(tokens, 0);
+ }
+
lp_build_tgsi_soa(builder,
tokens,
vs_type,
@@ -579,6 +625,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
struct lp_type vs_type = lp_type_float_vec(32);
const int max_vertices = 4;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
+ void *code;
arg_types[0] = llvm->context_ptr_type; /* context */
arg_types[1] = llvm->vertex_header_ptr_type; /* vertex_header */
@@ -684,21 +731,24 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
*/
#ifdef DEBUG
if(LLVMVerifyFunction(variant->function, LLVMPrintMessageAction)) {
- LLVMDumpValue(variant->function);
+ lp_debug_dump_value(variant->function);
assert(0);
}
#endif
LLVMRunFunctionPassManager(llvm->pass, variant->function);
- if (0) {
- LLVMDumpValue(variant->function);
+ if (gallivm_debug & GALLIVM_DEBUG_IR) {
+ lp_debug_dump_value(variant->function);
debug_printf("\n");
}
- variant->jit_func = (draw_jit_vert_func)LLVMGetPointerToGlobal(llvm->draw->engine, variant->function);
- if (0)
- lp_disassemble(variant->jit_func);
+ code = LLVMGetPointerToGlobal(llvm->draw->engine, variant->function);
+ variant->jit_func = voidptr_to_draw_jit_vert_func(code);
+
+ if (gallivm_debug & GALLIVM_DEBUG_ASM) {
+ lp_disassemble(code);
+ }
}
@@ -721,6 +771,7 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian
const int max_vertices = 4;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
LLVMValueRef fetch_max;
+ void *code;
arg_types[0] = llvm->context_ptr_type; /* context */
arg_types[1] = llvm->vertex_header_ptr_type; /* vertex_header */
@@ -835,22 +886,24 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian
*/
#ifdef DEBUG
if(LLVMVerifyFunction(variant->function_elts, LLVMPrintMessageAction)) {
- LLVMDumpValue(variant->function_elts);
+ lp_debug_dump_value(variant->function_elts);
assert(0);
}
#endif
LLVMRunFunctionPassManager(llvm->pass, variant->function_elts);
- if (0) {
- LLVMDumpValue(variant->function_elts);
+ if (gallivm_debug & GALLIVM_DEBUG_IR) {
+ lp_debug_dump_value(variant->function_elts);
debug_printf("\n");
}
- variant->jit_func_elts = (draw_jit_vert_func_elts)LLVMGetPointerToGlobal(
- llvm->draw->engine, variant->function_elts);
- if (0)
- lp_disassemble(variant->jit_func_elts);
+ code = LLVMGetPointerToGlobal(llvm->draw->engine, variant->function_elts);
+ variant->jit_func_elts = voidptr_to_draw_vert_func_elts(code);
+
+ if (gallivm_debug & GALLIVM_DEBUG_ASM) {
+ lp_disassemble(code);
+ }
}
void
diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c
index 64c3502508..7ea04e3819 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.c
+++ b/src/gallium/auxiliary/draw/draw_pipe.c
@@ -170,7 +170,25 @@ static void do_triangle( struct draw_context *draw,
* Set up macros for draw_pt_decompose.h template code.
* This code uses vertex indexes / elements.
*/
-#define QUAD(i0,i1,i2,i3) \
+
+/* emit first quad vertex as first vertex in triangles */
+#define QUAD_FIRST_PV(i0,i1,i2,i3) \
+ do_triangle( draw, \
+ ( DRAW_PIPE_RESET_STIPPLE | \
+ DRAW_PIPE_EDGE_FLAG_0 | \
+ DRAW_PIPE_EDGE_FLAG_1 ), \
+ verts + stride * elts[i0], \
+ verts + stride * elts[i1], \
+ verts + stride * elts[i2]); \
+ do_triangle( draw, \
+ ( DRAW_PIPE_EDGE_FLAG_1 | \
+ DRAW_PIPE_EDGE_FLAG_2 ), \
+ verts + stride * elts[i0], \
+ verts + stride * elts[i2], \
+ verts + stride * elts[i3])
+
+/* emit last quad vertex as last vertex in triangles */
+#define QUAD_LAST_PV(i0,i1,i2,i3) \
do_triangle( draw, \
( DRAW_PIPE_RESET_STIPPLE | \
DRAW_PIPE_EDGE_FLAG_0 | \
@@ -261,9 +279,27 @@ void draw_pipeline_run( struct draw_context *draw,
/*
* Set up macros for draw_pt_decompose.h template code.
- * This code is for non-indexed rendering (no elts).
+ * This code is for non-indexed (aka linear) rendering (no elts).
*/
-#define QUAD(i0,i1,i2,i3) \
+
+/* emit first quad vertex as first vertex in triangles */
+#define QUAD_FIRST_PV(i0,i1,i2,i3) \
+ do_triangle( draw, \
+ ( DRAW_PIPE_RESET_STIPPLE | \
+ DRAW_PIPE_EDGE_FLAG_0 | \
+ DRAW_PIPE_EDGE_FLAG_1 ), \
+ verts + stride * ((i0) & ~DRAW_PIPE_FLAG_MASK), \
+ verts + stride * (i1), \
+ verts + stride * (i2)); \
+ do_triangle( draw, \
+ ( DRAW_PIPE_EDGE_FLAG_1 | \
+ DRAW_PIPE_EDGE_FLAG_2 ), \
+ verts + stride * ((i0) & ~DRAW_PIPE_FLAG_MASK), \
+ verts + stride * (i2), \
+ verts + stride * (i3))
+
+/* emit last quad vertex as last vertex in triangles */
+#define QUAD_LAST_PV(i0,i1,i2,i3) \
do_triangle( draw, \
( DRAW_PIPE_RESET_STIPPLE | \
DRAW_PIPE_EDGE_FLAG_0 | \
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 51a6115ebf..df8d82e367 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -157,6 +157,10 @@ static void interp( const struct clip_stage *clip,
}
+/**
+ * Emit a post-clip polygon to the next pipeline stage. The polygon
+ * will be convex and the provoking vertex will always be vertex[0].
+ */
static void emit_poly( struct draw_stage *stage,
struct vertex_header **inlist,
unsigned n,
@@ -164,10 +168,18 @@ static void emit_poly( struct draw_stage *stage,
{
struct prim_header header;
unsigned i;
+ ushort edge_first, edge_middle, edge_last;
- const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2;
- const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0;
- const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1;
+ if (stage->draw->rasterizer->flatshade_first) {
+ edge_first = DRAW_PIPE_EDGE_FLAG_0;
+ edge_middle = DRAW_PIPE_EDGE_FLAG_1;
+ edge_last = DRAW_PIPE_EDGE_FLAG_2;
+ }
+ else {
+ edge_first = DRAW_PIPE_EDGE_FLAG_2;
+ edge_middle = DRAW_PIPE_EDGE_FLAG_0;
+ edge_last = DRAW_PIPE_EDGE_FLAG_1;
+ }
/* later stages may need the determinant, but only the sign matters */
header.det = origPrim->det;
@@ -175,9 +187,17 @@ static void emit_poly( struct draw_stage *stage,
header.pad = 0;
for (i = 2; i < n; i++, header.flags = edge_middle) {
- header.v[0] = inlist[i-1];
- header.v[1] = inlist[i];
- header.v[2] = inlist[0]; /* keep in v[2] for flatshading */
+ /* order the triangle verts to respect the provoking vertex mode */
+ if (stage->draw->rasterizer->flatshade_first) {
+ header.v[0] = inlist[0]; /* the provoking vertex */
+ header.v[1] = inlist[i-1];
+ header.v[2] = inlist[i];
+ }
+ else {
+ header.v[0] = inlist[i-1];
+ header.v[1] = inlist[i];
+ header.v[2] = inlist[0]; /* the provoking vertex */
+ }
if (i == n-1)
header.flags |= edge_last;
@@ -185,7 +205,8 @@ static void emit_poly( struct draw_stage *stage,
if (0) {
const struct draw_vertex_shader *vs = stage->draw->vs.vertex_shader;
uint j, k;
- debug_printf("Clipped tri:\n");
+ debug_printf("Clipped tri: (flat-shade-first = %d)\n",
+ stage->draw->rasterizer->flatshade_first);
for (j = 0; j < 3; j++) {
for (k = 0; k < vs->info.num_outputs; k++) {
debug_printf(" Vert %d: Attr %d: %f %f %f %f\n", j, k,
@@ -291,12 +312,21 @@ do_clip_tri( struct draw_stage *stage,
}
}
- /* If flat-shading, copy color to new provoking vertex.
+ /* If flat-shading, copy provoking vertex color to polygon vertex[0]
*/
- if (clipper->flat && inlist[0] != header->v[2]) {
- inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
-
- copy_colors(stage, inlist[0], header->v[2]);
+ if (clipper->flat) {
+ if (stage->draw->rasterizer->flatshade_first) {
+ if (inlist[0] != header->v[0]) {
+ inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
+ copy_colors(stage, inlist[0], header->v[0]);
+ }
+ }
+ else {
+ if (inlist[0] != header->v[2]) {
+ inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
+ copy_colors(stage, inlist[0], header->v[2]);
+ }
+ }
}
/* Emit the polygon as triangles to the setup stage:
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index dc66c65a56..bf84ce30ed 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -40,7 +40,8 @@
struct cull_stage {
struct draw_stage stage;
- unsigned winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */
+ unsigned cull_face; /**< which face(s) to cull (one of PIPE_FACE_x) */
+ unsigned front_ccw;
};
@@ -73,9 +74,12 @@ static void cull_tri( struct draw_stage *stage,
/* if det < 0 then Z points toward the camera and the triangle is
* counter-clockwise winding.
*/
- unsigned winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW;
+ unsigned ccw = (header->det < 0);
+ unsigned face = ((ccw == cull_stage(stage)->front_ccw) ?
+ PIPE_FACE_FRONT :
+ PIPE_FACE_BACK);
- if ((winding & cull_stage(stage)->winding) == 0) {
+ if ((face & cull_stage(stage)->cull_face) == 0) {
/* triangle is not culled, pass to next stage */
stage->next->tri( stage->next, header );
}
@@ -88,7 +92,8 @@ static void cull_first_tri( struct draw_stage *stage,
{
struct cull_stage *cull = cull_stage(stage);
- cull->winding = stage->draw->rasterizer->cull_mode;
+ cull->cull_face = stage->draw->rasterizer->cull_face;
+ cull->front_ccw = stage->draw->rasterizer->front_ccw;
stage->tri = cull_tri;
stage->tri( stage, header );
diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
index eef0238b15..808b2fb0b5 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
@@ -141,7 +141,7 @@ static void twoside_first_tri( struct draw_stage *stage,
* if the triangle is back-facing (negative).
* sign = -1 for CCW, +1 for CW
*/
- twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f;
+ twoside->sign = stage->draw->rasterizer->front_ccw ? -1.0f : 1.0f;
stage->tri = twoside_tri;
stage->tri( stage, header );
diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
index 03bb842e20..e333d26a93 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
@@ -105,6 +105,23 @@ static void lines( struct draw_stage *stage,
}
+/** For debugging */
+static void
+print_header_flags(unsigned flags)
+{
+ debug_printf("header->flags = ");
+ if (flags & DRAW_PIPE_RESET_STIPPLE)
+ debug_printf("RESET_STIPPLE ");
+ if (flags & DRAW_PIPE_EDGE_FLAG_0)
+ debug_printf("EDGE_FLAG_0 ");
+ if (flags & DRAW_PIPE_EDGE_FLAG_1)
+ debug_printf("EDGE_FLAG_1 ");
+ if (flags & DRAW_PIPE_EDGE_FLAG_2)
+ debug_printf("EDGE_FLAG_2 ");
+ debug_printf("\n");
+}
+
+
/* Unfilled tri:
*
* Note edgeflags in the vertex struct is not sufficient as we will
@@ -117,8 +134,12 @@ static void unfilled_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct unfilled_stage *unfilled = unfilled_stage(stage);
- unsigned mode = unfilled->mode[header->det >= 0.0];
+ unsigned cw = header->det >= 0.0;
+ unsigned mode = unfilled->mode[cw];
+ if (0)
+ print_header_flags(header->flags);
+
switch (mode) {
case PIPE_POLYGON_MODE_FILL:
stage->next->tri( stage->next, header );
@@ -139,9 +160,10 @@ static void unfilled_first_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct unfilled_stage *unfilled = unfilled_stage(stage);
+ const struct pipe_rasterizer_state *rast = stage->draw->rasterizer;
- unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */
- unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */
+ unfilled->mode[0] = rast->front_ccw ? rast->fill_front : rast->fill_back;
+ unfilled->mode[1] = rast->front_ccw ? rast->fill_back : rast->fill_front;
stage->tri = unfilled_tri;
stage->tri( stage, header );
diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c
index 2a50af7a41..eafa29276f 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_validate.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c
@@ -122,12 +122,14 @@ draw_need_pipeline(const struct draw_context *draw,
return TRUE;
/* unfilled polygons */
- if (rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
- rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL)
+ if (rasterizer->fill_front != PIPE_POLYGON_MODE_FILL ||
+ rasterizer->fill_back != PIPE_POLYGON_MODE_FILL)
return TRUE;
/* polygon offset */
- if (rasterizer->offset_cw || rasterizer->offset_ccw)
+ if (rasterizer->offset_point ||
+ rasterizer->offset_line ||
+ rasterizer->offset_tri)
return TRUE;
/* two-side lighting */
@@ -222,8 +224,8 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
next = draw->pipeline.pstipple;
}
- if (rast->fill_cw != PIPE_POLYGON_MODE_FILL ||
- rast->fill_ccw != PIPE_POLYGON_MODE_FILL) {
+ if (rast->fill_front != PIPE_POLYGON_MODE_FILL ||
+ rast->fill_back != PIPE_POLYGON_MODE_FILL) {
draw->pipeline.unfilled->next = next;
next = draw->pipeline.unfilled;
precalc_flat = TRUE; /* only needed for triangles really */
@@ -235,8 +237,9 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
next = draw->pipeline.flatshade;
}
- if (rast->offset_cw ||
- rast->offset_ccw) {
+ if (rast->offset_point ||
+ rast->offset_line ||
+ rast->offset_tri) {
draw->pipeline.offset->next = next;
next = draw->pipeline.offset;
need_det = TRUE;
@@ -255,7 +258,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
* to less work emitting vertices, smaller vertex buffers, etc.
* It's difficult to say whether this will be true in general.
*/
- if (need_det || rast->cull_mode) {
+ if (need_det || rast->cull_face != PIPE_FACE_NONE) {
draw->pipeline.cull->next = next;
next = draw->pipeline.cull;
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index abbf6247ab..3c93c9014a 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -159,19 +159,8 @@ vbuf_tri( struct draw_stage *stage,
check_space( vbuf, 3 );
- if (vbuf->stage.draw->rasterizer->flatshade_first) {
- /* Put provoking vertex in position expected by the driver.
- * Emit last provoking vertex in first pos.
- * Swap verts 0 & 1 to preserve polygon winding.
- */
- vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[2] );
- vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[0] );
- vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[1] );
- }
- else {
- for (i = 0; i < 3; i++) {
- vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[i] );
- }
+ for (i = 0; i < 3; i++) {
+ vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[i] );
}
}
@@ -335,9 +324,9 @@ vbuf_flush_vertices( struct vbuf_stage *vbuf )
if (vbuf->nr_indices)
{
- vbuf->render->draw(vbuf->render,
- vbuf->indices,
- vbuf->nr_indices );
+ vbuf->render->draw_elements(vbuf->render,
+ vbuf->indices,
+ vbuf->nr_indices );
vbuf->nr_indices = 0;
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index ab16706581..d7ac95b740 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -77,8 +77,11 @@ static void wideline_line( struct draw_stage *stage,
const float dx = fabsf(pos0[0] - pos2[0]);
const float dy = fabsf(pos0[1] - pos2[1]);
+ const boolean gl_rasterization_rules =
+ stage->draw->rasterizer->gl_rasterization_rules;
+
/* small tweak to meet GL specification */
- const float bias = 0.125f;
+ const float bias = gl_rasterization_rules ? 0.125f : 0.0f;
/*
* Draw wide line as a quad (two tris) by "stretching" the line along
@@ -92,19 +95,21 @@ static void wideline_line( struct draw_stage *stage,
pos1[1] = pos1[1] + half_width - bias;
pos2[1] = pos2[1] - half_width - bias;
pos3[1] = pos3[1] + half_width - bias;
- if (pos0[0] < pos2[0]) {
- /* left to right line */
- pos0[0] -= 0.5f;
- pos1[0] -= 0.5f;
- pos2[0] -= 0.5f;
- pos3[0] -= 0.5f;
- }
- else {
- /* right to left line */
- pos0[0] += 0.5f;
- pos1[0] += 0.5f;
- pos2[0] += 0.5f;
- pos3[0] += 0.5f;
+ if (gl_rasterization_rules) {
+ if (pos0[0] < pos2[0]) {
+ /* left to right line */
+ pos0[0] -= 0.5f;
+ pos1[0] -= 0.5f;
+ pos2[0] -= 0.5f;
+ pos3[0] -= 0.5f;
+ }
+ else {
+ /* right to left line */
+ pos0[0] += 0.5f;
+ pos1[0] += 0.5f;
+ pos2[0] += 0.5f;
+ pos3[0] += 0.5f;
+ }
}
}
else {
@@ -113,19 +118,21 @@ static void wideline_line( struct draw_stage *stage,
pos1[0] = pos1[0] + half_width + bias;
pos2[0] = pos2[0] - half_width + bias;
pos3[0] = pos3[0] + half_width + bias;
- if (pos0[1] < pos2[1]) {
- /* top to bottom line */
- pos0[1] -= 0.5f;
- pos1[1] -= 0.5f;
- pos2[1] -= 0.5f;
- pos3[1] -= 0.5f;
- }
- else {
- /* bottom to top line */
- pos0[1] += 0.5f;
- pos1[1] += 0.5f;
- pos2[1] += 0.5f;
- pos3[1] += 0.5f;
+ if (gl_rasterization_rules) {
+ if (pos0[1] < pos2[1]) {
+ /* top to bottom line */
+ pos0[1] -= 0.5f;
+ pos1[1] -= 0.5f;
+ pos2[1] -= 0.5f;
+ pos3[1] -= 0.5f;
+ }
+ else {
+ /* bottom to top line */
+ pos0[1] += 0.5f;
+ pos1[1] += 0.5f;
+ pos2[1] += 0.5f;
+ pos3[1] += 0.5f;
+ }
}
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_decompose.h b/src/gallium/auxiliary/draw/draw_pt_decompose.h
index 3c44f7c11e..52f9593d46 100644
--- a/src/gallium/auxiliary/draw/draw_pt_decompose.h
+++ b/src/gallium/auxiliary/draw/draw_pt_decompose.h
@@ -47,33 +47,26 @@ static void FUNC( ARGS,
case PIPE_PRIM_TRIANGLES:
for (i = 0; i+2 < count; i += 3) {
- if (flatfirst) {
- /* put provoking vertex in last pos for clipper */
- TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
- (i + 1),
- (i + 2),
- (i + 0 ));
- }
- else {
- TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
- (i + 0),
- (i + 1),
- (i + 2 ));
- }
+ TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ (i + 0),
+ (i + 1),
+ (i + 2 ));
}
break;
case PIPE_PRIM_TRIANGLE_STRIP:
if (flatfirst) {
for (i = 0; i+2 < count; i++) {
+ /* Emit first triangle vertex as first triangle vertex */
TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ (i + 0),
(i + 1 + (i&1)),
- (i + 2 - (i&1)),
- (i + 0) );
+ (i + 2 - (i&1)) );
}
}
else {
for (i = 0; i+2 < count; i++) {
+ /* Emit last triangle vertex as last triangle vertex */
TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
(i + 0 + (i&1)),
(i + 1 - (i&1)),
@@ -87,9 +80,9 @@ static void FUNC( ARGS,
if (flatfirst) {
for (i = 0; i+2 < count; i++) {
TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ (i + 1),
(i + 2),
- 0,
- (i + 1) );
+ 0 );
}
}
else {
@@ -105,24 +98,52 @@ static void FUNC( ARGS,
case PIPE_PRIM_QUADS:
- for (i = 0; i+3 < count; i += 4) {
- QUAD( (i + 0),
- (i + 1),
- (i + 2),
- (i + 3));
+ /* GL quads don't follow provoking vertex convention */
+ if (flatfirst) {
+ for (i = 0; i+3 < count; i += 4) {
+ /* emit last quad vertex as first triangle vertex */
+ QUAD_FIRST_PV( (i + 3),
+ (i + 0),
+ (i + 1),
+ (i + 2) );
+ }
+ }
+ else {
+ for (i = 0; i+3 < count; i += 4) {
+ /* emit last quad vertex as last triangle vertex */
+ QUAD_LAST_PV( (i + 0),
+ (i + 1),
+ (i + 2),
+ (i + 3) );
+ }
}
break;
case PIPE_PRIM_QUAD_STRIP:
- for (i = 0; i+3 < count; i += 2) {
- QUAD( (i + 2),
- (i + 0),
- (i + 1),
- (i + 3));
+ /* GL quad strips don't follow provoking vertex convention */
+ if (flatfirst) {
+ for (i = 0; i+3 < count; i += 2) {
+ /* emit last quad vertex as first triangle vertex */
+ QUAD_FIRST_PV( (i + 3),
+ (i + 2),
+ (i + 0),
+ (i + 1) );
+
+ }
+ }
+ else {
+ for (i = 0; i+3 < count; i += 2) {
+ /* emit last quad vertex as last triangle vertex */
+ QUAD_LAST_PV( (i + 2),
+ (i + 0),
+ (i + 1),
+ (i + 3) );
+ }
}
break;
case PIPE_PRIM_POLYGON:
+ /* GL polygons don't follow provoking vertex convention */
{
/* These bitflags look a little odd because we submit the
* vertices as (1,2,0) to satisfy flatshade requirements.
@@ -138,10 +159,20 @@ static void FUNC( ARGS,
if (i + 3 == count)
flags |= edge_last;
- TRIANGLE( flags,
- (i + 1),
- (i + 2),
- (0));
+ if (flatfirst) {
+ /* emit first polygon vertex as first triangle vertex */
+ TRIANGLE( flags,
+ (0),
+ (i + 1),
+ (i + 2) );
+ }
+ else {
+ /* emit first polygon vertex as last triangle vertex */
+ TRIANGLE( flags,
+ (i + 1),
+ (i + 2),
+ (0));
+ }
}
}
break;
@@ -156,7 +187,8 @@ static void FUNC( ARGS,
#undef TRIANGLE
-#undef QUAD
+#undef QUAD_FIRST_PV
+#undef QUAD_LAST_PV
#undef POINT
#undef LINE
#undef FUNC
diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c
index ad48fa39a4..f623c0743d 100644
--- a/src/gallium/auxiliary/draw/draw_pt_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_emit.c
@@ -190,9 +190,9 @@ void draw_pt_emit( struct pt_emit *emit,
0,
vertex_count - 1 );
- render->draw(render,
- elts,
- count);
+ render->draw_elements(render,
+ elts,
+ count);
render->release_vertices(render);
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index d7735bf1ac..5158c6341c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -254,9 +254,9 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle,
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
- draw->render->draw( draw->render,
- draw_elts,
- draw_count );
+ draw->render->draw_elements( draw->render,
+ draw_elts,
+ draw_count );
/* Done -- that was easy, wasn't it:
*/
@@ -363,9 +363,9 @@ static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
- draw->render->draw( draw->render,
- draw_elts,
- draw_count );
+ draw->render->draw_elements( draw->render,
+ draw_elts,
+ draw_count );
/* Done -- that was easy, wasn't it:
*/
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
index cbb5b6c960..f0fc591bf5 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
@@ -307,9 +307,9 @@ fse_run(struct draw_pt_middle_end *middle,
draw->render->unmap_vertices( draw->render, 0, (ushort)(fetch_count - 1) );
- draw->render->draw( draw->render,
- draw_elts,
- draw_count );
+ draw->render->draw_elements( draw->render,
+ draw_elts,
+ draw_count );
draw->render->release_vertices( draw->render );
@@ -357,9 +357,9 @@ static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle,
hw_verts );
- draw->render->draw( draw->render,
- draw_elts,
- draw_count );
+ draw->render->draw_elements( draw->render,
+ draw_elts,
+ draw_count );
draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
index 6d00b0fbd4..d56889b5f6 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
@@ -32,7 +32,6 @@
#include "draw/draw_vertex.h"
#include "draw/draw_pt.h"
#include "draw/draw_vs.h"
-#include "draw/draw_gs.h"
#include "draw/draw_llvm.h"
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index 37ffbac4f9..6a48e61e62 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -183,8 +183,16 @@ vcache_quad( struct vcache_frontend *vcache,
unsigned i2,
unsigned i3 )
{
- vcache_triangle( vcache, i0, i1, i3 );
- vcache_triangle( vcache, i1, i2, i3 );
+ if (vcache->draw->rasterizer->flatshade_first) {
+ /* pass last quad vertex as first triangle vertex */
+ vcache_triangle( vcache, i3, i0, i1 );
+ vcache_triangle( vcache, i3, i1, i2 );
+ }
+ else {
+ /* pass last quad vertex as last triangle vertex */
+ vcache_triangle( vcache, i0, i1, i3 );
+ vcache_triangle( vcache, i1, i2, i3 );
+ }
}
static INLINE void
@@ -195,18 +203,20 @@ vcache_ef_quad( struct vcache_frontend *vcache,
unsigned i3 )
{
if (vcache->draw->rasterizer->flatshade_first) {
+ /* pass last quad vertex as first triangle vertex */
vcache_triangle_flags( vcache,
( DRAW_PIPE_RESET_STIPPLE |
DRAW_PIPE_EDGE_FLAG_0 |
DRAW_PIPE_EDGE_FLAG_1 ),
- i0, i1, i2 );
+ i3, i0, i1 );
vcache_triangle_flags( vcache,
- ( DRAW_PIPE_EDGE_FLAG_2 |
- DRAW_PIPE_EDGE_FLAG_1 ),
- i0, i2, i3 );
+ ( DRAW_PIPE_EDGE_FLAG_1 |
+ DRAW_PIPE_EDGE_FLAG_2 ),
+ i3, i1, i2 );
}
else {
+ /* pass last quad vertex as last triangle vertex */
vcache_triangle_flags( vcache,
( DRAW_PIPE_RESET_STIPPLE |
DRAW_PIPE_EDGE_FLAG_0 |
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
index f7a63de3ba..dac68ad439 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
@@ -142,20 +142,21 @@ static void FUNC( struct draw_pt_front_end *frontend,
/* These bitflags look a little odd because we submit the
* vertices as (1,2,0) to satisfy flatshade requirements.
*/
- const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2;
- const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0;
- const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1;
ushort edge_next, edge_finish;
if (flatfirst) {
- flags = DRAW_PIPE_RESET_STIPPLE | edge_middle | edge_last;
- edge_next = edge_last;
- edge_finish = edge_first;
+ flags = (DRAW_PIPE_RESET_STIPPLE |
+ DRAW_PIPE_EDGE_FLAG_1 |
+ DRAW_PIPE_EDGE_FLAG_2);
+ edge_next = DRAW_PIPE_EDGE_FLAG_2;
+ edge_finish = DRAW_PIPE_EDGE_FLAG_0;
}
else {
- flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
- edge_next = edge_middle;
- edge_finish = edge_last;
+ flags = (DRAW_PIPE_RESET_STIPPLE |
+ DRAW_PIPE_EDGE_FLAG_2 |
+ DRAW_PIPE_EDGE_FLAG_0);
+ edge_next = DRAW_PIPE_EDGE_FLAG_0;
+ edge_finish = DRAW_PIPE_EDGE_FLAG_1;
}
for (i = 0; i+2 < count; i++, flags = edge_next) {
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index cccd3bf435..83ae26a9c2 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -98,14 +98,14 @@ struct vbuf_render {
boolean (*set_primitive)( struct vbuf_render *, unsigned prim );
/**
- * DrawElements, note indices are ushort. The driver must complete
- * this call, if necessary splitting the index list itself.
+ * Draw indexed primitives. Note that indices are ushort. The driver
+ * must complete this call, if necessary splitting the index list itself.
*/
- void (*draw)( struct vbuf_render *,
- const ushort *indices,
- uint nr_indices );
+ void (*draw_elements)( struct vbuf_render *,
+ const ushort *indices,
+ uint nr_indices );
- /* Draw Arrays path too.
+ /* Draw non-indexed primitives.
*/
void (*draw_arrays)( struct vbuf_render *,
unsigned start,
diff --git a/src/gallium/auxiliary/gallivm/f.cpp b/src/gallium/auxiliary/gallivm/f.cpp
new file mode 100644
index 0000000000..5eb09c01ab
--- /dev/null
+++ b/src/gallium/auxiliary/gallivm/f.cpp
@@ -0,0 +1,85 @@
+/**************************************************************************
+ *
+ * (C) Copyright VMware, Inc 2010.
+ * (C) Copyright John Maddock 2006.
+ * Use, modification and distribution are subject to the
+ * Boost Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ *
+ **************************************************************************/
+
+
+/*
+ * This file allows to compute the minimax polynomial coefficients we use
+ * for fast exp2/log2.
+ *
+ * How to use this source:
+ *
+ * - Download and abuild the NTL library from
+ * http://shoup.net/ntl/download.html
+ *
+ * - Download boost source code matching to your distro.
+ *
+ * - Goto libs/math/minimax and replace f.cpp with this file.
+ *
+ * - Build as
+ *
+ * g++ -o minimax -I /path/to/ntl/include main.cpp f.cpp /path/to/ntl/src/ntl.a -lboost_math_tr1
+ *
+ * - Run as
+ *
+ * ./minimax
+ *
+ * - For example, to compute exp2 5th order polynomial between [0, 1] do:
+ *
+ * variant 1
+ * range 0 1
+ * order 5 0
+ * steps 200
+ * info
+ *
+ * - For more info see
+ * http://www.boost.org/doc/libs/1_36_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/minimax.html
+ */
+
+#define L22
+#include <boost/math/bindings/rr.hpp>
+#include <boost/math/tools/polynomial.hpp>
+
+#include <cmath>
+
+
+boost::math::ntl::RR f(const boost::math::ntl::RR& x, int variant)
+{
+ static const boost::math::ntl::RR tiny = boost::math::tools::min_value<boost::math::ntl::RR>() * 64;
+
+ switch(variant)
+ {
+ case 0:
+ // log2(x)/(x - 1)
+ return log(x)/log(2.0)/(x - 1.0);
+
+ case 1:
+ // exp2(x)
+ return exp(x*log(2.0));
+ }
+
+ return 0;
+}
+
+
+void show_extra(
+ const boost::math::tools::polynomial<boost::math::ntl::RR>& n,
+ const boost::math::tools::polynomial<boost::math::ntl::RR>& d,
+ const boost::math::ntl::RR& x_offset,
+ const boost::math::ntl::RR& y_offset,
+ int variant)
+{
+ switch(variant)
+ {
+ default:
+ // do nothing here...
+ ;
+ }
+}
+
diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h
index 2fa682f400..8103bc917f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld.h
@@ -35,6 +35,17 @@
#define LP_BLD_H
+/**
+ * @file
+ * LLVM IR building helpers interfaces.
+ *
+ * We use LLVM-C bindings for now. They are not documented, but follow the C++
+ * interfaces very closely, and appear to be complete enough for code
+ * genration. See
+ * http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
+ * for a standalone example.
+ */
+
#include <llvm-c/Core.h>
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index f372a48846..b55c863aa0 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -54,6 +54,7 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_intr.h"
+#include "lp_bld_init.h" /* for lp_build_engine */
#include "lp_bld_logic.h"
#include "lp_bld_pack.h"
#include "lp_bld_debug.h"
@@ -239,7 +240,7 @@ lp_build_sum_vector(struct lp_build_context *bld,
{
const struct lp_type type = bld->type;
LLVMValueRef index, res;
- int i;
+ unsigned i;
if (a == bld->zero)
return bld->zero;
@@ -675,26 +676,13 @@ lp_build_abs(struct lp_build_context *bld,
if(type.floating) {
/* Mask out the sign bit */
- if (type.length == 1) {
- LLVMTypeRef int_type = LLVMIntType(type.width);
- LLVMTypeRef float_type = LLVMFloatType();
- unsigned long long absMask = ~(1ULL << (type.width - 1));
- LLVMValueRef mask = LLVMConstInt(int_type, absMask, 0);
- a = LLVMBuildBitCast(bld->builder, a, int_type, "");
- a = LLVMBuildAnd(bld->builder, a, mask, "");
- a = LLVMBuildBitCast(bld->builder, a, float_type, "");
- return a;
- }
- else {
- /* vector of floats */
- LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
- unsigned long long absMask = ~(1ULL << (type.width - 1));
- LLVMValueRef mask = lp_build_const_int_vec(type, ((unsigned long long) absMask));
- a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
- a = LLVMBuildAnd(bld->builder, a, mask, "");
- a = LLVMBuildBitCast(bld->builder, a, vec_type, "");
- return a;
- }
+ LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
+ unsigned long long absMask = ~(1ULL << (type.width - 1));
+ LLVMValueRef mask = lp_build_const_int_vec(type, ((unsigned long long) absMask));
+ a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
+ a = LLVMBuildAnd(bld->builder, a, mask, "");
+ a = LLVMBuildBitCast(bld->builder, a, vec_type, "");
+ return a;
}
if(type.width*type.length == 128 && util_cpu_caps.has_ssse3) {
@@ -742,17 +730,9 @@ lp_build_sgn(struct lp_build_context *bld,
LLVMValueRef one;
unsigned long long maskBit = (unsigned long long)1 << (type.width - 1);
- if (type.length == 1) {
- int_type = lp_build_int_elem_type(type);
- vec_type = lp_build_elem_type(type);
- mask = LLVMConstInt(int_type, maskBit, 0);
- }
- else {
- /* vector */
- int_type = lp_build_int_vec_type(type);
- vec_type = lp_build_vec_type(type);
- mask = lp_build_const_int_vec(type, maskBit);
- }
+ int_type = lp_build_int_vec_type(type);
+ vec_type = lp_build_vec_type(type);
+ mask = lp_build_const_int_vec(type, maskBit);
/* Take the sign bit and add it to 1 constant */
sign = LLVMBuildBitCast(bld->builder, a, int_type, "");
@@ -819,21 +799,11 @@ lp_build_int_to_float(struct lp_build_context *bld,
LLVMValueRef a)
{
const struct lp_type type = bld->type;
+ LLVMTypeRef vec_type = lp_build_vec_type(type);
assert(type.floating);
- /*assert(lp_check_value(type, a));*/
- if (type.length == 1) {
- LLVMTypeRef float_type = LLVMFloatType();
- return LLVMBuildSIToFP(bld->builder, a, float_type, "");
- }
- else {
- LLVMTypeRef vec_type = lp_build_vec_type(type);
- /*LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);*/
- LLVMValueRef res;
- res = LLVMBuildSIToFP(bld->builder, a, vec_type, "");
- return res;
- }
+ return LLVMBuildSIToFP(bld->builder, a, vec_type, "");
}
@@ -887,7 +857,7 @@ lp_build_trunc(struct lp_build_context *bld,
assert(type.floating);
assert(lp_check_value(type, a));
- if(util_cpu_caps.has_sse4_1)
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128)
return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_TRUNCATE);
else {
LLVMTypeRef vec_type = lp_build_vec_type(type);
@@ -909,7 +879,7 @@ lp_build_round(struct lp_build_context *bld,
assert(type.floating);
assert(lp_check_value(type, a));
- if(util_cpu_caps.has_sse4_1)
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128)
return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_NEAREST);
else {
LLVMTypeRef vec_type = lp_build_vec_type(type);
@@ -928,15 +898,9 @@ lp_build_floor(struct lp_build_context *bld,
const struct lp_type type = bld->type;
assert(type.floating);
+ assert(lp_check_value(type, a));
- if (type.length == 1) {
- LLVMValueRef res;
- res = lp_build_ifloor(bld, a);
- res = LLVMBuildSIToFP(bld->builder, res, LLVMFloatType(), "");
- return res;
- }
-
- if(util_cpu_caps.has_sse4_1)
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128)
return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_FLOOR);
else {
LLVMTypeRef vec_type = lp_build_vec_type(type);
@@ -957,7 +921,7 @@ lp_build_ceil(struct lp_build_context *bld,
assert(type.floating);
assert(lp_check_value(type, a));
- if(util_cpu_caps.has_sse4_1)
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128)
return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_CEIL);
else {
LLVMTypeRef vec_type = lp_build_vec_type(type);
@@ -991,18 +955,12 @@ lp_build_itrunc(struct lp_build_context *bld,
LLVMValueRef a)
{
const struct lp_type type = bld->type;
+ LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
assert(type.floating);
+ assert(lp_check_value(type, a));
- if (type.length == 1) {
- LLVMTypeRef int_type = LLVMIntType(type.width);
- return LLVMBuildFPToSI(bld->builder, a, int_type, "");
- }
- else {
- LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
- assert(lp_check_value(type, a));
- return LLVMBuildFPToSI(bld->builder, a, int_vec_type, "");
- }
+ return LLVMBuildFPToSI(bld->builder, a, int_vec_type, "");
}
@@ -1019,17 +977,9 @@ lp_build_iround(struct lp_build_context *bld,
assert(type.floating);
- if (type.length == 1) {
- /* scalar float to int */
- LLVMTypeRef int_type = LLVMIntType(type.width);
- /* XXX we want rounding here! */
- res = LLVMBuildFPToSI(bld->builder, a, int_type, "");
- return res;
- }
-
assert(lp_check_value(type, a));
- if(util_cpu_caps.has_sse4_1) {
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) {
res = lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_NEAREST);
}
else {
@@ -1069,17 +1019,9 @@ lp_build_ifloor(struct lp_build_context *bld,
LLVMValueRef res;
assert(type.floating);
-
- if (type.length == 1) {
- /* scalar float to int */
- LLVMTypeRef int_type = LLVMIntType(type.width);
- res = LLVMBuildFPToSI(bld->builder, a, int_type, "");
- return res;
- }
-
assert(lp_check_value(type, a));
- if(util_cpu_caps.has_sse4_1) {
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) {
res = lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_FLOOR);
}
else {
@@ -1127,10 +1069,11 @@ lp_build_iceil(struct lp_build_context *bld,
assert(type.floating);
assert(lp_check_value(type, a));
- if(util_cpu_caps.has_sse4_1) {
+ if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) {
res = lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_CEIL);
}
else {
+ /* TODO: mimic lp_build_ifloor() here */
assert(0);
res = bld->undef;
}
@@ -1228,6 +1171,92 @@ lp_build_rsqrt(struct lp_build_context *bld,
}
+#ifdef PIPE_OS_WINDOWS
+
+/*
+ * XXX: X86 backend translates llvm.cos.v4f32 to 4 calls to CRT's cosf()
+ * which is neither efficient nor does the CRT linkage work on Windows
+ * causing segmentation fault.
+ *
+ * XXX: With LLVM 2.7 both schemes cause an assertion failure.
+ */
+static LLVMValueRef
+lp_build_sincos(struct lp_build_context *bld,
+ const char *name,
+ float (*func)(float),
+ LLVMValueRef a)
+{
+ LLVMModuleRef module =
+ LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld->builder)));
+ LLVMValueRef function;
+ LLVMValueRef res;
+ unsigned i;
+
+ assert(bld->type.floating);
+ assert(bld->type.width == 32);
+
+ function = LLVMGetNamedFunction(module, name);
+ if (!function) {
+ LLVMTypeRef ret_type;
+ LLVMTypeRef arg_types[1];
+ LLVMTypeRef function_type;
+
+ ret_type = LLVMFloatType();
+ arg_types[0] = LLVMFloatType();
+ function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0);
+ function = LLVMAddFunction(module, name, function_type);
+
+ LLVMSetFunctionCallConv(function, LLVMCCallConv);
+ LLVMSetLinkage(function, LLVMPrivateLinkage);
+
+ assert(LLVMIsDeclaration(function));
+
+ LLVMAddGlobalMapping(lp_build_engine, function, func);
+ }
+
+ res = bld->undef;
+
+ for (i = 0; i < bld->type.length; ++i) {
+ LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+ LLVMValueRef args[1];
+ LLVMValueRef tmp;
+
+ args[0] = LLVMBuildExtractElement(bld->builder, a, index, "");
+
+ tmp = LLVMBuildCall(bld->builder, function, args, Elements(args), "");
+
+ res = LLVMBuildInsertElement(bld->builder, res, tmp, index, "");
+ }
+
+ return res;
+}
+
+static float c_cosf( float f )
+{
+ return (float) cos( (double) f );
+}
+
+static float c_sinf( float f )
+{
+ return (float) sin( (double) f );
+}
+
+LLVMValueRef
+lp_build_cos(struct lp_build_context *bld,
+ LLVMValueRef a)
+{
+ return lp_build_sincos(bld, "cosf", &c_cosf, a);
+}
+
+LLVMValueRef
+lp_build_sin(struct lp_build_context *bld,
+ LLVMValueRef a)
+{
+ return lp_build_sincos(bld, "sinf", &c_sinf, a);
+}
+
+#else /* !PIPE_OS_WINDOWS */
+
/**
* Generate cos(a)
*/
@@ -1235,14 +1264,6 @@ LLVMValueRef
lp_build_cos(struct lp_build_context *bld,
LLVMValueRef a)
{
-#ifdef PIPE_OS_WINDOWS
- /*
- * FIXME: X86 backend translates llvm.cos.v4f32 to 4 calls to CRT's cosf()
- * which is neither efficient nor does the CRT linkage work on Windows
- * causing segmentation fault. So simply disable the code for now.
- */
- return bld->one;
-#else
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(type);
char intrinsic[32];
@@ -1253,7 +1274,6 @@ lp_build_cos(struct lp_build_context *bld,
util_snprintf(intrinsic, sizeof intrinsic, "llvm.cos.v%uf%u", type.length, type.width);
return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a);
-#endif
}
@@ -1264,14 +1284,6 @@ LLVMValueRef
lp_build_sin(struct lp_build_context *bld,
LLVMValueRef a)
{
-#ifdef PIPE_OS_WINDOWS
- /*
- * FIXME: X86 backend translates llvm.sin.v4f32 to 4 calls to CRT's sinf()
- * which is neither efficient nor does the CRT linkage work on Windows
- * causing segmentation fault. So simply disable the code for now.
- */
- return bld->zero;
-#else
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(type);
char intrinsic[32];
@@ -1282,9 +1294,10 @@ lp_build_sin(struct lp_build_context *bld,
util_snprintf(intrinsic, sizeof intrinsic, "llvm.sin.v%uf%u", type.length, type.width);
return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a);
-#endif
}
+#endif /* !PIPE_OS_WINDOWS */
+
/**
* Generate pow(x, y)
@@ -1346,7 +1359,6 @@ lp_build_polynomial(struct lp_build_context *bld,
unsigned num_coeffs)
{
const struct lp_type type = bld->type;
- LLVMTypeRef float_type = LLVMFloatType();
LLVMValueRef res = NULL;
unsigned i;
@@ -1358,10 +1370,7 @@ lp_build_polynomial(struct lp_build_context *bld,
for (i = num_coeffs; i--; ) {
LLVMValueRef coeff;
- if (type.length == 1)
- coeff = LLVMConstReal(float_type, coeffs[i]);
- else
- coeff = lp_build_const_vec(type, coeffs[i]);
+ coeff = lp_build_const_vec(type, coeffs[i]);
if(res)
res = lp_build_add(bld, coeff, lp_build_mul(bld, x, res));
@@ -1377,17 +1386,31 @@ lp_build_polynomial(struct lp_build_context *bld,
/**
- * Minimax polynomial fit of 2**x, in range [-0.5, 0.5[
+ * Minimax polynomial fit of 2**x, in range [0, 1[
*/
const double lp_build_exp2_polynomial[] = {
#if EXP_POLY_DEGREE == 5
- 9.9999994e-1, 6.9315308e-1, 2.4015361e-1, 5.5826318e-2, 8.9893397e-3, 1.8775767e-3
+ 0.999999999690134838155,
+ 0.583974334321735217258,
+ 0.164553105719676828492,
+ 0.0292811063701710962255,
+ 0.00354944426657875141846,
+ 0.000296253726543423377365
#elif EXP_POLY_DEGREE == 4
- 1.0000026, 6.9300383e-1, 2.4144275e-1, 5.2011464e-2, 1.3534167e-2
+ 1.00000001502262084505,
+ 0.563586057338685991394,
+ 0.150436017652442413623,
+ 0.0243220604213317927308,
+ 0.0025359088446580436489
#elif EXP_POLY_DEGREE == 3
- 9.9992520e-1, 6.9583356e-1, 2.2606716e-1, 7.8024521e-2
+ 0.999925218562710312959,
+ 0.695833540494823811697,
+ 0.226067155427249155588,
+ 0.0780245226406372992967
#elif EXP_POLY_DEGREE == 2
- 1.0017247, 6.5763628e-1, 3.3718944e-1
+ 1.00172476321474503578,
+ 0.657636275736077639316,
+ 0.33718943461968720704
#else
#error
#endif
@@ -1421,17 +1444,16 @@ lp_build_exp2_approx(struct lp_build_context *bld,
x = lp_build_min(bld, x, lp_build_const_vec(type, 129.0));
x = lp_build_max(bld, x, lp_build_const_vec(type, -126.99999));
- /* ipart = int(x - 0.5) */
- ipart = LLVMBuildSub(bld->builder, x, lp_build_const_vec(type, 0.5f), "");
- ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, "");
+ /* ipart = floor(x) */
+ ipart = lp_build_floor(bld, x);
/* fpart = x - ipart */
- fpart = LLVMBuildSIToFP(bld->builder, ipart, vec_type, "");
- fpart = LLVMBuildSub(bld->builder, x, fpart, "");
+ fpart = LLVMBuildSub(bld->builder, x, ipart, "");
}
if(p_exp2_int_part || p_exp2) {
/* expipart = (float) (1 << ipart) */
+ ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, "");
expipart = LLVMBuildAdd(bld->builder, ipart, lp_build_const_int_vec(type, 127), "");
expipart = LLVMBuildShl(bld->builder, expipart, lp_build_const_int_vec(type, 23), "");
expipart = LLVMBuildBitCast(bld->builder, expipart, vec_type, "");
@@ -1472,13 +1494,27 @@ lp_build_exp2(struct lp_build_context *bld,
*/
const double lp_build_log2_polynomial[] = {
#if LOG_POLY_DEGREE == 6
- 3.11578814719469302614, -3.32419399085241980044, 2.59883907202499966007, -1.23152682416275988241, 0.318212422185251071475, -0.0344359067839062357313
+ 3.11578814719469302614,
+ -3.32419399085241980044,
+ 2.59883907202499966007,
+ -1.23152682416275988241,
+ 0.318212422185251071475,
+ -0.0344359067839062357313
#elif LOG_POLY_DEGREE == 5
- 2.8882704548164776201, -2.52074962577807006663, 1.48116647521213171641, -0.465725644288844778798, 0.0596515482674574969533
+ 2.8882704548164776201,
+ -2.52074962577807006663,
+ 1.48116647521213171641,
+ -0.465725644288844778798,
+ 0.0596515482674574969533
#elif LOG_POLY_DEGREE == 4
- 2.61761038894603480148, -1.75647175389045657003, 0.688243882994381274313, -0.107254423828329604454
+ 2.61761038894603480148,
+ -1.75647175389045657003,
+ 0.688243882994381274313,
+ -0.107254423828329604454
#elif LOG_POLY_DEGREE == 3
- 2.28330284476918490682, -1.04913055217340124191, 0.204446009836232697516
+ 2.28330284476918490682,
+ -1.04913055217340124191,
+ 0.204446009836232697516
#else
#error
#endif
@@ -1558,89 +1594,11 @@ lp_build_log2_approx(struct lp_build_context *bld,
}
-/** scalar version of above function */
-static void
-lp_build_float_log2_approx(struct lp_build_context *bld,
- LLVMValueRef x,
- LLVMValueRef *p_exp,
- LLVMValueRef *p_floor_log2,
- LLVMValueRef *p_log2)
-{
- const struct lp_type type = bld->type;
- LLVMTypeRef float_type = LLVMFloatType();
- LLVMTypeRef int_type = LLVMIntType(type.width);
-
- LLVMValueRef expmask = LLVMConstInt(int_type, 0x7f800000, 0);
- LLVMValueRef mantmask = LLVMConstInt(int_type, 0x007fffff, 0);
- LLVMValueRef one = LLVMConstBitCast(bld->one, int_type);
-
- LLVMValueRef i = NULL;
- LLVMValueRef exp = NULL;
- LLVMValueRef mant = NULL;
- LLVMValueRef logexp = NULL;
- LLVMValueRef logmant = NULL;
- LLVMValueRef res = NULL;
-
- if(p_exp || p_floor_log2 || p_log2) {
- /* TODO: optimize the constant case */
- if(LLVMIsConstant(x))
- debug_printf("%s: inefficient/imprecise constant arithmetic\n",
- __FUNCTION__);
-
- assert(type.floating && type.width == 32);
-
- i = LLVMBuildBitCast(bld->builder, x, int_type, "");
-
- /* exp = (float) exponent(x) */
- exp = LLVMBuildAnd(bld->builder, i, expmask, "");
- }
-
- if(p_floor_log2 || p_log2) {
- LLVMValueRef c23 = LLVMConstInt(int_type, 23, 0);
- LLVMValueRef c127 = LLVMConstInt(int_type, 127, 0);
- logexp = LLVMBuildLShr(bld->builder, exp, c23, "");
- logexp = LLVMBuildSub(bld->builder, logexp, c127, "");
- logexp = LLVMBuildSIToFP(bld->builder, logexp, float_type, "");
- }
-
- if(p_log2) {
- /* mant = (float) mantissa(x) */
- mant = LLVMBuildAnd(bld->builder, i, mantmask, "");
- mant = LLVMBuildOr(bld->builder, mant, one, "");
- mant = LLVMBuildBitCast(bld->builder, mant, float_type, "");
-
- logmant = lp_build_polynomial(bld, mant, lp_build_log2_polynomial,
- Elements(lp_build_log2_polynomial));
-
- /* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/
- logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildSub(bld->builder, mant, bld->one, ""), "");
-
- res = LLVMBuildAdd(bld->builder, logmant, logexp, "");
- }
-
- if(p_exp) {
- exp = LLVMBuildBitCast(bld->builder, exp, float_type, "");
- *p_exp = exp;
- }
-
- if(p_floor_log2)
- *p_floor_log2 = logexp;
-
- if(p_log2)
- *p_log2 = res;
-}
-
-
LLVMValueRef
lp_build_log2(struct lp_build_context *bld,
LLVMValueRef x)
{
LLVMValueRef res;
- if (bld->type.length == 1) {
- lp_build_float_log2_approx(bld, x, NULL, NULL, &res);
- }
- else {
- lp_build_log2_approx(bld, x, NULL, NULL, &res);
- }
+ lp_build_log2_approx(bld, x, NULL, NULL, &res);
return res;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c
index 57843e9a60..031ce9d1a3 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
@@ -301,6 +301,9 @@ lp_build_const_vec(struct lp_type type,
elems[0] = LLVMConstInt(elem_type, val*dscale + 0.5, 0);
}
+ if (type.length == 1)
+ return elems[0];
+
for(i = 1; i < type.length; ++i)
elems[i] = elems[0];
@@ -321,6 +324,9 @@ lp_build_const_int_vec(struct lp_type type,
for(i = 0; i < type.length; ++i)
elems[i] = LLVMConstInt(elem_type, val, type.sign ? 1 : 0);
+ if (type.length == 1)
+ return elems[0];
+
return LLVMConstVector(elems, type.length);
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
index 7b010cbdb0..858002b34f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
@@ -36,6 +36,19 @@
#include "util/u_string.h"
+#define GALLIVM_DEBUG_TGSI 0x1
+#define GALLIVM_DEBUG_IR 0x2
+#define GALLIVM_DEBUG_ASM 0x4
+#define GALLIVM_DEBUG_NO_OPT 0x8
+
+
+#ifdef DEBUG
+extern unsigned gallivm_debug;
+#else
+#define gallivm_debug 0
+#endif
+
+
static INLINE void
lp_build_name(LLVMValueRef val, const char *format, ...)
{
@@ -53,6 +66,10 @@ lp_build_name(LLVMValueRef val, const char *format, ...)
}
+void
+lp_debug_dump_value(LLVMValueRef value);
+
+
boolean
lp_check_alignment(const void *ptr, unsigned alignment);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
index 8f15b1d287..823a8ec7b7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
@@ -821,8 +821,11 @@ lp_build_alloca(LLVMBuilderRef builder,
LLVMBuilderRef first_builder = LLVMCreateBuilder();
LLVMValueRef res;
- LLVMPositionBuilderAtEnd(first_builder, first_block);
- LLVMPositionBuilderBefore(first_builder, first_instr);
+ if (first_instr) {
+ LLVMPositionBuilderBefore(first_builder, first_instr);
+ } else {
+ LLVMPositionBuilderAtEnd(first_builder, first_block);
+ }
res = LLVMBuildAlloca(first_builder, type, name);
@@ -840,7 +843,7 @@ lp_build_alloca(LLVMBuilderRef builder,
* first block may prevent the X86 backend from successfully align the stack as
* required.
*
- * Also the scalarrepl pass is supossedly more powerful and can promote
+ * Also the scalarrepl pass is supposedly more powerful and can promote
* arrays in many cases.
*
* See also:
@@ -859,7 +862,11 @@ lp_build_array_alloca(LLVMBuilderRef builder,
LLVMBuilderRef first_builder = LLVMCreateBuilder();
LLVMValueRef res;
- LLVMPositionBuilderBefore(first_builder, first_instr);
+ if (first_instr) {
+ LLVMPositionBuilderBefore(first_builder, first_instr);
+ } else {
+ LLVMPositionBuilderAtEnd(first_builder, first_block);
+ }
res = LLVMBuildArrayAlloca(first_builder, type, count, name);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h
index 085937588f..5f5036e7bd 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h
@@ -40,6 +40,7 @@
struct util_format_description;
struct lp_type;
+struct lp_build_context;
/*
@@ -70,16 +71,16 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
void
lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
- struct lp_type type,
+ struct lp_build_context *bld,
const LLVMValueRef *unswizzled,
- LLVMValueRef *swizzled);
+ LLVMValueRef swizzled_out[4]);
void
lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef packed,
- LLVMValueRef *rgba);
+ LLVMValueRef rgba_out[4]);
void
@@ -90,7 +91,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
LLVMValueRef offsets,
LLVMValueRef i,
LLVMValueRef j,
- LLVMValueRef *rgba);
+ LLVMValueRef rgba_out[4]);
#endif /* !LP_BLD_FORMAT_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index 6257e9a404..eb49204238 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -47,7 +47,8 @@
/**
* Unpack a single pixel into its RGBA components.
*
- * @param packed integer.
+ * @param desc the pixel format for the packed pixel value
+ * @param packed integer pixel in a format such as PIPE_FORMAT_B8G8R8A8_UNORM
*
* @return RGBA in a 4 floats vector.
*/
@@ -62,9 +63,9 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef scales[4];
LLVMValueRef swizzles[4];
LLVMValueRef aux[4];
- bool normalized;
+ boolean normalized;
int empty_channel;
- bool needs_uitofp;
+ boolean needs_uitofp;
unsigned shift;
unsigned i;
@@ -79,7 +80,10 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
if (desc->block.bits < 32)
packed = LLVMBuildZExt(builder, packed, LLVMInt32Type(), "");
- /* Broadcast the packed value to all four channels */
+ /* Broadcast the packed value to all four channels
+ * before: packed = BGRA
+ * after: packed = {BGRA, BGRA, BGRA, BGRA}
+ */
packed = LLVMBuildInsertElement(builder,
LLVMGetUndef(LLVMVectorType(LLVMInt32Type(), 4)),
packed,
@@ -96,6 +100,8 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
needs_uitofp = FALSE;
empty_channel = -1;
shift = 0;
+
+ /* Loop over 4 color components */
for (i = 0; i < 4; ++i) {
unsigned bits = desc->channel[i].size;
@@ -128,8 +134,13 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
shift += bits;
}
+ /* Ex: convert packed = {BGRA, BGRA, BGRA, BGRA}
+ * into masked = {B, G, R, A}
+ */
shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), "");
masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), "");
+
+
if (!needs_uitofp) {
/* UIToFP can't be expressed in SSE2 */
casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), "");
@@ -137,6 +148,11 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
casted = LLVMBuildUIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), "");
}
+ /* At this point 'casted' may be a vector of floats such as
+ * {255.0, 255.0, 255.0, 255.0}. Next, if the pixel values are normalized
+ * we'll scale this to {1.0, 1.0, 1.0, 1.0}.
+ */
+
if (normalized)
scaled = LLVMBuildMul(builder, casted, LLVMConstVector(scales, 4), "");
else
@@ -145,6 +161,7 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
for (i = 0; i < 4; ++i)
aux[i] = LLVMGetUndef(LLVMFloatType());
+ /* Build swizzles vector to put components into R,G,B,A order */
for (i = 0; i < 4; ++i) {
enum util_format_swizzle swizzle;
@@ -185,7 +202,8 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
}
}
- return LLVMBuildShuffleVector(builder, scaled, LLVMConstVector(aux, 4), LLVMConstVector(swizzles, 4), "");
+ return LLVMBuildShuffleVector(builder, scaled, LLVMConstVector(aux, 4),
+ LLVMConstVector(swizzles, 4), "");
}
@@ -208,7 +226,7 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
LLVMValueRef shifted, casted, scaled, unswizzled;
LLVMValueRef shifts[4];
LLVMValueRef scales[4];
- bool normalized;
+ boolean normalized;
unsigned shift;
unsigned i, j;
@@ -292,10 +310,29 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
}
+typedef void (*fetch_func)(float *, const uint8_t *, unsigned, unsigned);
+
+/** cast wrapper */
+static void *
+fetch_func_ptr_to_voidptr(fetch_func f)
+{
+ union {
+ void *v;
+ fetch_func f;
+ } u;
+ u.f = f;
+ return u.v;
+}
+
+
/**
* Fetch a pixel into a 4 float AoS.
*
- * i and j are the sub-block pixel coordinates.
+ * \param format_desc describes format of the image we're fetching from
+ * \param ptr address of the pixel block (or the texel if uncompressed)
+ * \param i, j the sub-block pixel coordinates. For non-compressed formats
+ * these will always be (0,).
+ * \return valueRef with the float[4] RGBA pixel
*/
LLVMValueRef
lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
@@ -368,7 +405,8 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
assert(LLVMIsDeclaration(function));
- LLVMAddGlobalMapping(lp_build_engine, function, format_desc->fetch_rgba_float);
+ LLVMAddGlobalMapping(lp_build_engine, function,
+ fetch_func_ptr_to_voidptr(format_desc->fetch_rgba_float));
}
tmp = lp_build_alloca(builder, LLVMVectorType(LLVMFloatType(), 4), "");
@@ -384,7 +422,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
args[2] = i;
args[3] = j;
- LLVMBuildCall(builder, function, args, 4, "");
+ LLVMBuildCall(builder, function, args, Elements(args), "");
return LLVMBuildLoad(builder, tmp, "");
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
index 26b947b3b1..e1b94adc85 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
@@ -26,6 +26,8 @@
**************************************************************************/
+#include "pipe/p_defines.h"
+
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_string.h"
@@ -33,51 +35,38 @@
#include "lp_bld_type.h"
#include "lp_bld_const.h"
#include "lp_bld_conv.h"
+#include "lp_bld_swizzle.h"
#include "lp_bld_sample.h" /* for lp_build_gather */
#include "lp_bld_format.h"
-static LLVMValueRef
-lp_build_format_swizzle_chan_soa(struct lp_type type,
- const LLVMValueRef *unswizzled,
- enum util_format_swizzle swizzle)
-{
- switch (swizzle) {
- case UTIL_FORMAT_SWIZZLE_X:
- case UTIL_FORMAT_SWIZZLE_Y:
- case UTIL_FORMAT_SWIZZLE_Z:
- case UTIL_FORMAT_SWIZZLE_W:
- return unswizzled[swizzle];
- case UTIL_FORMAT_SWIZZLE_0:
- return lp_build_zero(type);
- case UTIL_FORMAT_SWIZZLE_1:
- return lp_build_one(type);
- case UTIL_FORMAT_SWIZZLE_NONE:
- return lp_build_undef(type);
- default:
- assert(0);
- return lp_build_undef(type);
- }
-}
-
-
void
lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
- struct lp_type type,
+ struct lp_build_context *bld,
const LLVMValueRef *unswizzled,
- LLVMValueRef *swizzled)
+ LLVMValueRef swizzled_out[4])
{
- if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+ assert(UTIL_FORMAT_SWIZZLE_0 == PIPE_SWIZZLE_ZERO);
+ assert(UTIL_FORMAT_SWIZZLE_1 == PIPE_SWIZZLE_ONE);
+
+ if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+ /*
+ * Return zzz1 for depth-stencil formats.
+ *
+ * XXX: Allow to control the depth swizzle with an additional parameter,
+ * as the caller may wish another depth swizzle, or retain the stencil
+ * value.
+ */
enum util_format_swizzle swizzle = format_desc->swizzle[0];
- LLVMValueRef depth = lp_build_format_swizzle_chan_soa(type, unswizzled, swizzle);
- swizzled[2] = swizzled[1] = swizzled[0] = depth;
- swizzled[3] = lp_build_one(type);
+ LLVMValueRef depth = lp_build_swizzle_soa_channel(bld, unswizzled, swizzle);
+ swizzled_out[2] = swizzled_out[1] = swizzled_out[0] = depth;
+ swizzled_out[3] = bld->one;
}
else {
unsigned chan;
for (chan = 0; chan < 4; ++chan) {
enum util_format_swizzle swizzle = format_desc->swizzle[chan];
- swizzled[chan] = lp_build_format_swizzle_chan_soa(type, unswizzled, swizzle);
+ swizzled_out[chan] = lp_build_swizzle_soa_channel(bld, unswizzled, swizzle);
}
}
}
@@ -100,14 +89,20 @@ lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
* It requires that a packed pixel fits into an element of the output
* channels. The common case is when converting pixel with a depth of 32 bit or
* less into floats.
+ *
+ * \param format_desc the format of the 'packed' incoming pixel vector
+ * \param type the desired type for rgba_out (type.length = n, above)
+ * \param packed the incoming vector of packed pixels
+ * \param rgba_out returns the SoA R,G,B,A vectors
*/
void
lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
const struct util_format_description *format_desc,
struct lp_type type,
LLVMValueRef packed,
- LLVMValueRef *rgba)
+ LLVMValueRef rgba_out[4])
{
+ struct lp_build_context bld;
LLVMValueRef inputs[4];
unsigned start;
unsigned chan;
@@ -120,11 +115,13 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
assert(type.floating);
assert(type.width == 32);
+ lp_build_context_init(&bld, builder, type);
+
/* Decode the input vector components */
start = 0;
for (chan = 0; chan < format_desc->nr_channels; ++chan) {
- unsigned width = format_desc->channel[chan].size;
- unsigned stop = start + width;
+ const unsigned width = format_desc->channel[chan].size;
+ const unsigned stop = start + width;
LLVMValueRef input;
input = packed;
@@ -250,14 +247,24 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
start = stop;
}
- lp_build_format_swizzle_soa(format_desc, type, inputs, rgba);
+ lp_build_format_swizzle_soa(format_desc, &bld, inputs, rgba_out);
}
/**
- * Fetch a pixel into a SoA.
+ * Fetch a texels from a texture, returning them in SoA layout.
*
- * i and j are the sub-block pixel coordinates.
+ * \param type the desired return type for 'rgba'. The vector length
+ * is the number of texels to fetch
+ *
+ * \param base_ptr points to start of the texture image block. For non-
+ * compressed formats, this simply points to the texel.
+ * For compressed formats, it points to the start of the
+ * compressed data block.
+ *
+ * \param i, j the sub-block pixel coordinates. For non-compressed formats
+ * these will always be (0,0). For compressed formats, i will
+ * be in [0, block_width-1] and j will be in [0, block_height-1].
*/
void
lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
@@ -267,7 +274,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
LLVMValueRef offset,
LLVMValueRef i,
LLVMValueRef j,
- LLVMValueRef *rgba)
+ LLVMValueRef rgba_out[4])
{
if (format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
@@ -281,7 +288,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
{
/*
* The packed pixel fits into an element of the destination format. Put
- * the packed pixels into a vector and estract each component for all
+ * the packed pixels into a vector and extract each component for all
* vector elements in parallel.
*/
@@ -289,6 +296,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
/*
* gather the texels from the texture
+ * Ex: packed = {BGRA, BGRA, BGRA, BGRA}.
*/
packed = lp_build_gather(builder,
type.length,
@@ -302,16 +310,16 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
lp_build_unpack_rgba_soa(builder,
format_desc,
type,
- packed, rgba);
+ packed, rgba_out);
}
else {
/*
* Fallback to calling lp_build_fetch_rgba_aos for each pixel.
*
- * This is not the most efficient way of fetching pixels, as
- * we miss some opportunities to do vectorization, but this it is a
- * convenient for formats or scenarios for which there was no opportunity
- * or incentive to optimize.
+ * This is not the most efficient way of fetching pixels, as we
+ * miss some opportunities to do vectorization, but this is
+ * convenient for formats or scenarios for which there was no
+ * opportunity or incentive to optimize.
*/
unsigned k, chan;
@@ -319,9 +327,10 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
assert(type.floating);
for (chan = 0; chan < 4; ++chan) {
- rgba[chan] = lp_build_undef(type);
+ rgba_out[chan] = lp_build_undef(type);
}
+ /* loop over number of pixels */
for(k = 0; k < type.length; ++k) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), k, 0);
LLVMValueRef offset_elem;
@@ -335,16 +344,19 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder,
i_elem = LLVMBuildExtractElement(builder, i, index, "");
j_elem = LLVMBuildExtractElement(builder, j, index, "");
- tmp = lp_build_fetch_rgba_aos(builder, format_desc, ptr, i_elem, j_elem);
+ /* Get a single float[4]={R,G,B,A} pixel */
+ tmp = lp_build_fetch_rgba_aos(builder, format_desc, ptr,
+ i_elem, j_elem);
/*
- * AoS to SoA
+ * Insert the AoS tmp value channels into the SoA result vectors at
+ * position = 'index'.
*/
-
for (chan = 0; chan < 4; ++chan) {
LLVMValueRef chan_val = LLVMConstInt(LLVMInt32Type(), chan, 0),
tmp_chan = LLVMBuildExtractElement(builder, tmp, chan_val, "");
- rgba[chan] = LLVMBuildInsertElement(builder, rgba[chan], tmp_chan, index, "");
+ rgba_out[chan] = LLVMBuildInsertElement(builder, rgba_out[chan],
+ tmp_chan, index, "");
}
}
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 5067d0a164..bd080f397a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -29,9 +29,23 @@
#include "pipe/p_compiler.h"
#include "util/u_cpu_detect.h"
#include "util/u_debug.h"
+#include "lp_bld_debug.h"
#include "lp_bld_init.h"
+#ifdef DEBUG
+unsigned gallivm_debug = 0;
+
+static const struct debug_named_value lp_bld_debug_flags[] = {
+ { "tgsi", GALLIVM_DEBUG_TGSI },
+ { "ir", GALLIVM_DEBUG_IR },
+ { "asm", GALLIVM_DEBUG_ASM },
+ { "nopt", GALLIVM_DEBUG_NO_OPT },
+ {NULL, 0}
+};
+#endif
+
+
LLVMModuleRef lp_build_module = NULL;
LLVMExecutionEngineRef lp_build_engine = NULL;
LLVMModuleProviderRef lp_build_provider = NULL;
@@ -41,6 +55,10 @@ LLVMTargetDataRef lp_build_target = NULL;
void
lp_build_init(void)
{
+#ifdef DEBUG
+ gallivm_debug = debug_get_flags_option("GALLIVM_DEBUG", lp_bld_debug_flags, 0 );
+#endif
+
LLVMInitializeNativeTarget();
LLVMLinkInJIT();
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
index e095a0abe3..369c8121b5 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
@@ -42,6 +42,8 @@
#define LP_MAX_TGSI_IMMEDIATES 256
+#define LP_MAX_TGSI_PREDS 16
+
/**
* Maximum control flow nesting
*
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
new file mode 100644
index 0000000000..db0ca606e5
--- /dev/null
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -0,0 +1,100 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE 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 COPYRIGHT HOLDERS, AUTHORS 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.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
+
+#ifndef __STDC_CONSTANT_MACROS
+#define __STDC_CONSTANT_MACROS
+#endif
+
+#include "llvm-c/Core.h"
+
+#include "pipe/p_config.h"
+#include "util/u_debug.h"
+
+
+#if (defined(PIPE_OS_WINDOWS) && !defined(PIPE_CC_MSVC)) || defined(PIPE_OS_EMBDDED)
+
+#include "llvm/Support/raw_ostream.h"
+
+class raw_debug_ostream :
+ public llvm::raw_ostream
+{
+ uint64_t pos;
+
+ void write_impl(const char *Ptr, size_t Size);
+ uint64_t current_pos() { return pos; }
+ uint64_t current_pos() const { return pos; }
+
+#if HAVE_LLVM >= 0x207
+ uint64_t preferred_buffer_size() { return 512; }
+#else
+ size_t preferred_buffer_size() { return 512; }
+#endif
+};
+
+
+void
+raw_debug_ostream::write_impl(const char *Ptr, size_t Size)
+{
+ if (Size > 0) {
+ char *lastPtr = (char *)&Ptr[Size];
+ char last = *lastPtr;
+ *lastPtr = 0;
+ _debug_printf("%*s", Size, Ptr);
+ *lastPtr = last;
+ pos += Size;
+ }
+}
+
+
+/**
+ * Same as LLVMDumpValue, but through our debugging channels.
+ */
+extern "C" void
+lp_debug_dump_value(LLVMValueRef value)
+{
+ raw_debug_ostream os;
+ llvm::unwrap(value)->print(os);
+ os.flush();
+}
+
+
+#else
+
+
+extern "C" void
+lp_debug_dump_value(LLVMValueRef value)
+{
+ LLVMDumpValue(value);
+}
+
+
+#endif
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 195a4953ab..c7f9b1083b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -120,10 +120,12 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
/**
* Gather elements from scatter positions in memory into a single vector.
+ * Use for fetching texels from a texture.
+ * For SSE, typical values are length=4, src_width=32, dst_width=32.
*
- * @param src_width src element width
- * @param dst_width result element width (source will be expanded to fit)
- * @param length length of the offsets,
+ * @param length length of the offsets
+ * @param src_width src element width in bits
+ * @param dst_width result element width in bits (src will be expanded to fit)
* @param base_ptr base pointer, should be a i8 pointer type.
* @param offsets vector with offsets
*/
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 955b1d21ee..51e98ab2f9 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -56,14 +56,14 @@ struct lp_sampler_static_state
{
/* pipe_sampler_view's state */
enum pipe_format format;
- unsigned swizzle_r:3;
+ unsigned swizzle_r:3; /**< PIPE_SWIZZLE_* */
unsigned swizzle_g:3;
unsigned swizzle_b:3;
unsigned swizzle_a:3;
/* pipe_texture's state */
- unsigned target:3;
- unsigned pot_width:1;
+ unsigned target:3; /**< PIPE_TEXTURE_* */
+ unsigned pot_width:1; /**< is the width a power of two? */
unsigned pot_height:1;
unsigned pot_depth:1;
@@ -97,40 +97,40 @@ struct lp_sampler_dynamic_state
/** Obtain the base texture width. */
LLVMValueRef
- (*width)( struct lp_sampler_dynamic_state *state,
+ (*width)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
/** Obtain the base texture height. */
LLVMValueRef
- (*height)( struct lp_sampler_dynamic_state *state,
+ (*height)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
/** Obtain the base texture depth. */
LLVMValueRef
- (*depth)( struct lp_sampler_dynamic_state *state,
+ (*depth)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
/** Obtain the number of mipmap levels (minus one). */
LLVMValueRef
- (*last_level)( struct lp_sampler_dynamic_state *state,
+ (*last_level)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
LLVMValueRef
- (*row_stride)( struct lp_sampler_dynamic_state *state,
+ (*row_stride)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
LLVMValueRef
- (*img_stride)( struct lp_sampler_dynamic_state *state,
+ (*img_stride)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
LLVMValueRef
- (*data_ptr)( struct lp_sampler_dynamic_state *state,
+ (*data_ptr)( const struct lp_sampler_dynamic_state *state,
LLVMBuilderRef builder,
unsigned unit);
@@ -177,7 +177,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
const LLVMValueRef *ddy,
LLVMValueRef lod_bias,
LLVMValueRef explicit_lod,
- LLVMValueRef *texel);
+ LLVMValueRef texel_out[4]);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 3f0ea05b79..bc7213db8b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -186,50 +186,18 @@ texture_dims(enum pipe_texture_target tex)
}
-static LLVMValueRef
-lp_build_swizzle_chan_soa(struct lp_type type,
- const LLVMValueRef *unswizzled,
- enum util_format_swizzle swizzle)
-{
- switch (swizzle) {
- case PIPE_SWIZZLE_RED:
- case PIPE_SWIZZLE_GREEN:
- case PIPE_SWIZZLE_BLUE:
- case PIPE_SWIZZLE_ALPHA:
- return unswizzled[swizzle];
- case PIPE_SWIZZLE_ZERO:
- return lp_build_zero(type);
- case PIPE_SWIZZLE_ONE:
- return lp_build_one(type);
- default:
- assert(0);
- return lp_build_undef(type);
- }
-}
-
-
static void
-lp_build_swizzle_soa(struct lp_build_sample_context *bld,
- LLVMValueRef *texel)
+apply_sampler_swizzle(struct lp_build_sample_context *bld,
+ LLVMValueRef *texel)
{
- LLVMValueRef unswizzled[4];
unsigned char swizzles[4];
- unsigned chan;
-
- for (chan = 0; chan < 4; ++chan) {
- unswizzled[chan] = texel[chan];
- }
swizzles[0] = bld->static_state->swizzle_r;
swizzles[1] = bld->static_state->swizzle_g;
swizzles[2] = bld->static_state->swizzle_b;
swizzles[3] = bld->static_state->swizzle_a;
- for (chan = 0; chan < 4; ++chan) {
- unsigned swizzle = swizzles[chan];
- texel[chan] = lp_build_swizzle_chan_soa(bld->texel_type,
- unswizzled, swizzle);
- }
+ lp_build_swizzle_soa_inplace(&bld->texel_bld, texel, swizzles);
}
@@ -254,7 +222,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
LLVMValueRef y_stride,
LLVMValueRef z_stride,
LLVMValueRef data_ptr,
- LLVMValueRef *texel)
+ LLVMValueRef texel_out[4])
{
const int dims = texture_dims(bld->static_state->target);
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
@@ -343,9 +311,9 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
bld->texel_type,
data_ptr, offset,
i, j,
- texel);
+ texel_out);
- lp_build_swizzle_soa(bld, texel);
+ apply_sampler_swizzle(bld, texel_out);
/*
* Note: if we find an app which frequently samples the texture border
@@ -369,8 +337,8 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
LLVMValueRef border_chan =
lp_build_const_vec(bld->texel_type,
bld->static_state->border_color[chan]);
- texel[chan] = lp_build_select(&bld->texel_bld, use_border,
- border_chan, texel[chan]);
+ texel_out[chan] = lp_build_select(&bld->texel_bld, use_border,
+ border_chan, texel_out[chan]);
}
}
}
@@ -950,7 +918,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
}
else {
const int dims = texture_dims(bld->static_state->target);
- LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy;
+ LLVMValueRef dsdx, dsdy;
+ LLVMValueRef dtdx = NULL, dtdy = NULL, drdx = NULL, drdy = NULL;
LLVMValueRef rho;
/*
@@ -1078,8 +1047,10 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
int_bld->zero,
last_level);
/* compute level 1 and clamp to legal range of levels */
- *level1_out = lp_build_add(int_bld, *level0_out, int_bld->one);
- *level1_out = lp_build_min(int_bld, *level1_out, last_level);
+ level = lp_build_add(int_bld, level, int_bld->one);
+ *level1_out = lp_build_clamp(int_bld, level,
+ int_bld->zero,
+ last_level);
*weight_out = lp_build_fract(float_bld, lod);
}
@@ -1830,7 +1801,7 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
LLVMValueRef height,
LLVMValueRef stride_array,
LLVMValueRef data_array,
- LLVMValueRef *texel)
+ LLVMValueRef texel_out[4])
{
LLVMBuilderRef builder = bld->builder;
struct lp_build_context i32, h16, u8n;
@@ -2023,17 +1994,17 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
packed, unswizzled);
lp_build_format_swizzle_soa(bld->format_desc,
- bld->texel_type, unswizzled,
- texel);
+ &bld->texel_bld,
+ unswizzled, texel_out);
- lp_build_swizzle_soa(bld, texel);
+ apply_sampler_swizzle(bld, texel_out);
}
static void
lp_build_sample_compare(struct lp_build_sample_context *bld,
LLVMValueRef p,
- LLVMValueRef *texel)
+ LLVMValueRef texel[4])
{
struct lp_build_context *texel_bld = &bld->texel_bld;
LLVMValueRef res;
@@ -2071,14 +2042,14 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
*/
static void
lp_build_sample_nop(struct lp_build_sample_context *bld,
- LLVMValueRef *texel)
+ LLVMValueRef texel_out[4])
{
struct lp_build_context *texel_bld = &bld->texel_bld;
unsigned chan;
for (chan = 0; chan < 4; chan++) {
/*lp_bld_mov(texel_bld, texel, texel_bld->one);*/
- texel[chan] = texel_bld->one;
+ texel_out[chan] = texel_bld->one;
}
}
@@ -2101,7 +2072,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
const LLVMValueRef *ddy,
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef *texel)
+ LLVMValueRef texel_out[4])
{
struct lp_build_sample_context bld;
LLVMValueRef width, width_vec;
@@ -2113,6 +2084,11 @@ lp_build_sample_soa(LLVMBuilderRef builder,
LLVMValueRef t;
LLVMValueRef r;
+ if (0) {
+ enum pipe_format fmt = static_state->format;
+ debug_printf("Sample from %s\n", util_format_name(fmt));
+ }
+
/* Setup our build context */
memset(&bld, 0, sizeof bld);
bld.builder = builder;
@@ -2153,7 +2129,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
if (0) {
/* For debug: no-op texture sampling */
- lp_build_sample_nop(&bld, texel);
+ lp_build_sample_nop(&bld, texel_out);
}
else if (util_format_is_rgba8_variant(bld.format_desc) &&
static_state->target == PIPE_TEXTURE_2D &&
@@ -2164,7 +2140,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
is_simple_wrap_mode(static_state->wrap_t)) {
/* special case */
lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec,
- row_stride_array, data_array, texel);
+ row_stride_array, data_array, texel_out);
}
else {
lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy,
@@ -2173,8 +2149,8 @@ lp_build_sample_soa(LLVMBuilderRef builder,
width_vec, height_vec, depth_vec,
row_stride_array, img_stride_array,
data_array,
- texel);
+ texel_out);
}
- lp_build_sample_compare(&bld, r, texel);
+ lp_build_sample_compare(&bld, r, texel_out);
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
index 278c838eac..3c8a7bc09e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
@@ -60,21 +60,38 @@ lp_build_broadcast(LLVMBuilderRef builder,
}
+/**
+ * Broadcast
+ */
LLVMValueRef
lp_build_broadcast_scalar(struct lp_build_context *bld,
LLVMValueRef scalar)
{
const struct lp_type type = bld->type;
- LLVMValueRef res;
- unsigned i;
- res = bld->undef;
- for(i = 0; i < type.length; ++i) {
- LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
- res = LLVMBuildInsertElement(bld->builder, res, scalar, index, "");
- }
+ assert(lp_check_elem_type(type, LLVMTypeOf(scalar)));
- return res;
+ if (type.length == 1) {
+ return scalar;
+ }
+ else {
+ LLVMValueRef res;
+#if HAVE_LLVM >= 0x207
+ res = LLVMBuildInsertElement(bld->builder, bld->undef, scalar,
+ LLVMConstInt(LLVMInt32Type(), 0, 0), "");
+ res = LLVMBuildShuffleVector(bld->builder, res, bld->undef,
+ lp_build_const_int_vec(type, 0), "");
+#else
+ /* XXX: The above path provokes a bug in LLVM 2.6 */
+ unsigned i;
+ res = bld->undef;
+ for(i = 0; i < type.length; ++i) {
+ LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+ res = LLVMBuildInsertElement(bld->builder, res, scalar, index, "");
+ }
+#endif
+ return res;
+ }
}
@@ -237,3 +254,78 @@ lp_build_swizzle2_aos(struct lp_build_context *bld,
}
+/**
+ * Extended swizzle of a single channel of a SoA vector.
+ *
+ * @param bld building context
+ * @param unswizzled array with the 4 unswizzled values
+ * @param swizzle one of the PIPE_SWIZZLE_*
+ *
+ * @return the swizzled value.
+ */
+LLVMValueRef
+lp_build_swizzle_soa_channel(struct lp_build_context *bld,
+ const LLVMValueRef *unswizzled,
+ unsigned swizzle)
+{
+ switch (swizzle) {
+ case PIPE_SWIZZLE_RED:
+ case PIPE_SWIZZLE_GREEN:
+ case PIPE_SWIZZLE_BLUE:
+ case PIPE_SWIZZLE_ALPHA:
+ return unswizzled[swizzle];
+ case PIPE_SWIZZLE_ZERO:
+ return bld->zero;
+ case PIPE_SWIZZLE_ONE:
+ return bld->one;
+ default:
+ assert(0);
+ return bld->undef;
+ }
+}
+
+
+/**
+ * Extended swizzle of a SoA vector.
+ *
+ * @param bld building context
+ * @param unswizzled array with the 4 unswizzled values
+ * @param swizzles array of PIPE_SWIZZLE_*
+ * @param swizzled output swizzled values
+ */
+void
+lp_build_swizzle_soa(struct lp_build_context *bld,
+ const LLVMValueRef *unswizzled,
+ const unsigned char swizzles[4],
+ LLVMValueRef *swizzled)
+{
+ unsigned chan;
+
+ for (chan = 0; chan < 4; ++chan) {
+ swizzled[chan] = lp_build_swizzle_soa_channel(bld, unswizzled,
+ swizzles[chan]);
+ }
+}
+
+
+/**
+ * Do an extended swizzle of a SoA vector inplace.
+ *
+ * @param bld building context
+ * @param values intput/output array with the 4 values
+ * @param swizzles array of PIPE_SWIZZLE_*
+ */
+void
+lp_build_swizzle_soa_inplace(struct lp_build_context *bld,
+ LLVMValueRef *values,
+ const unsigned char swizzles[4])
+{
+ LLVMValueRef unswizzled[4];
+ unsigned chan;
+
+ for (chan = 0; chan < 4; ++chan) {
+ unswizzled[chan] = values[chan];
+ }
+
+ lp_build_swizzle_soa(bld, unswizzled, swizzles, values);
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h
index 138ca620e6..4f4fa777c9 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h
@@ -88,4 +88,23 @@ lp_build_swizzle2_aos(struct lp_build_context *bld,
const unsigned char swizzle[4]);
+LLVMValueRef
+lp_build_swizzle_soa_channel(struct lp_build_context *bld,
+ const LLVMValueRef *unswizzled,
+ unsigned swizzle);
+
+
+void
+lp_build_swizzle_soa(struct lp_build_context *bld,
+ const LLVMValueRef *unswizzled,
+ const unsigned char swizzles[4],
+ LLVMValueRef *swizzled);
+
+
+void
+lp_build_swizzle_soa_inplace(struct lp_build_context *bld,
+ LLVMValueRef *values,
+ const unsigned char swizzles[4]);
+
+
#endif /* !LP_BLD_SWIZZLE_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 5ce1385c48..4d415b6d41 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -59,7 +59,7 @@ struct lp_build_sampler_soa
(*destroy)( struct lp_build_sampler_soa *sampler );
void
- (*emit_fetch_texel)( struct lp_build_sampler_soa *sampler,
+ (*emit_fetch_texel)( const struct lp_build_sampler_soa *sampler,
LLVMBuilderRef builder,
struct lp_type type,
unsigned unit,
@@ -83,7 +83,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
const LLVMValueRef (*inputs)[4],
LLVMValueRef (*outputs)[4],
struct lp_build_sampler_soa *sampler,
- struct tgsi_shader_info *info);
+ const struct tgsi_shader_info *info);
#endif /* LP_BLD_TGSI_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 0b1a28a7ab..40ea94c493 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -81,6 +81,8 @@
#define QUAD_BOTTOM_LEFT 2
#define QUAD_BOTTOM_RIGHT 3
+#define LP_MAX_INSTRUCTIONS 256
+
struct lp_exec_mask {
struct lp_build_context *bld;
@@ -93,18 +95,24 @@ struct lp_exec_mask {
int cond_stack_size;
LLVMValueRef cond_mask;
- LLVMValueRef break_stack[LP_MAX_TGSI_NESTING];
- int break_stack_size;
- LLVMValueRef break_mask;
-
- LLVMValueRef cont_stack[LP_MAX_TGSI_NESTING];
- int cont_stack_size;
+ LLVMBasicBlockRef loop_block;
LLVMValueRef cont_mask;
-
- LLVMBasicBlockRef loop_stack[LP_MAX_TGSI_NESTING];
+ LLVMValueRef break_mask;
+ LLVMValueRef break_var;
+ struct {
+ LLVMBasicBlockRef loop_block;
+ LLVMValueRef cont_mask;
+ LLVMValueRef break_mask;
+ LLVMValueRef break_var;
+ } loop_stack[LP_MAX_TGSI_NESTING];
int loop_stack_size;
- LLVMBasicBlockRef loop_block;
+ LLVMValueRef ret_mask;
+ struct {
+ int pc;
+ LLVMValueRef ret_mask;
+ } call_stack[LP_MAX_TGSI_NESTING];
+ int call_stack_size;
LLVMValueRef exec_mask;
};
@@ -113,16 +121,20 @@ struct lp_build_tgsi_soa_context
{
struct lp_build_context base;
+ /* Builder for integer masks and indices */
+ struct lp_build_context int_bld;
+
LLVMValueRef consts_ptr;
const LLVMValueRef *pos;
const LLVMValueRef (*inputs)[NUM_CHANNELS];
LLVMValueRef (*outputs)[NUM_CHANNELS];
- struct lp_build_sampler_soa *sampler;
+ const struct lp_build_sampler_soa *sampler;
LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES][NUM_CHANNELS];
LLVMValueRef temps[LP_MAX_TGSI_TEMPS][NUM_CHANNELS];
LLVMValueRef addr[LP_MAX_TGSI_ADDRS][NUM_CHANNELS];
+ LLVMValueRef preds[LP_MAX_TGSI_PREDS][NUM_CHANNELS];
/* we allocate an array of temps if we have indirect
* addressing and then the temps above is unused */
@@ -131,6 +143,9 @@ struct lp_build_tgsi_soa_context
struct lp_build_mask_context *mask;
struct lp_exec_mask exec_mask;
+
+ struct tgsi_full_instruction *instructions;
+ uint max_instructions;
};
static const unsigned char
@@ -163,10 +178,11 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context
mask->has_mask = FALSE;
mask->cond_stack_size = 0;
mask->loop_stack_size = 0;
- mask->break_stack_size = 0;
- mask->cont_stack_size = 0;
+ mask->call_stack_size = 0;
mask->int_vec_type = lp_build_int_vec_type(mask->bld->type);
+ mask->exec_mask = mask->ret_mask = mask->break_mask = mask->cont_mask = mask->cond_mask =
+ LLVMConstAllOnes(mask->int_vec_type);
}
static void lp_exec_mask_update(struct lp_exec_mask *mask)
@@ -186,34 +202,45 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask)
} else
mask->exec_mask = mask->cond_mask;
+ if (mask->call_stack_size) {
+ mask->exec_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->exec_mask,
+ mask->ret_mask,
+ "callmask");
+ }
mask->has_mask = (mask->cond_stack_size > 0 ||
- mask->loop_stack_size > 0);
+ mask->loop_stack_size > 0 ||
+ mask->call_stack_size > 0);
}
static void lp_exec_mask_cond_push(struct lp_exec_mask *mask,
LLVMValueRef val)
{
assert(mask->cond_stack_size < LP_MAX_TGSI_NESTING);
+ if (mask->cond_stack_size == 0) {
+ assert(mask->cond_mask == LLVMConstAllOnes(mask->int_vec_type));
+ }
mask->cond_stack[mask->cond_stack_size++] = mask->cond_mask;
- mask->cond_mask = LLVMBuildBitCast(mask->bld->builder, val,
- mask->int_vec_type, "");
+ assert(LLVMTypeOf(val) == mask->int_vec_type);
+ mask->cond_mask = val;
lp_exec_mask_update(mask);
}
static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask)
{
- LLVMValueRef prev_mask = mask->cond_stack[mask->cond_stack_size - 1];
- LLVMValueRef inv_mask = LLVMBuildNot(mask->bld->builder,
- mask->cond_mask, "");
-
- /* means that we didn't have any mask before and that
- * we were fully enabled */
- if (mask->cond_stack_size <= 1) {
- prev_mask = LLVMConstAllOnes(mask->int_vec_type);
+ LLVMValueRef prev_mask;
+ LLVMValueRef inv_mask;
+
+ assert(mask->cond_stack_size);
+ prev_mask = mask->cond_stack[mask->cond_stack_size - 1];
+ if (mask->cond_stack_size == 1) {
+ assert(prev_mask == LLVMConstAllOnes(mask->int_vec_type));
}
+ inv_mask = LLVMBuildNot(mask->bld->builder, mask->cond_mask, "");
+
mask->cond_mask = LLVMBuildAnd(mask->bld->builder,
inv_mask,
prev_mask, "");
@@ -222,31 +249,37 @@ static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask)
static void lp_exec_mask_cond_pop(struct lp_exec_mask *mask)
{
+ assert(mask->cond_stack_size);
mask->cond_mask = mask->cond_stack[--mask->cond_stack_size];
lp_exec_mask_update(mask);
}
static void lp_exec_bgnloop(struct lp_exec_mask *mask)
{
+ if (mask->loop_stack_size == 0) {
+ assert(mask->loop_block == NULL);
+ assert(mask->cont_mask == LLVMConstAllOnes(mask->int_vec_type));
+ assert(mask->break_mask == LLVMConstAllOnes(mask->int_vec_type));
+ assert(mask->break_var == NULL);
+ }
- if (mask->cont_stack_size == 0)
- mask->cont_mask = LLVMConstAllOnes(mask->int_vec_type);
- if (mask->break_stack_size == 0)
- mask->break_mask = LLVMConstAllOnes(mask->int_vec_type);
- if (mask->cond_stack_size == 0)
- mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type);
+ assert(mask->loop_stack_size < LP_MAX_TGSI_NESTING);
- assert(mask->break_stack_size < LP_MAX_TGSI_NESTING);
- assert(mask->cont_stack_size < LP_MAX_TGSI_NESTING);
- assert(mask->break_stack_size < LP_MAX_TGSI_NESTING);
+ mask->loop_stack[mask->loop_stack_size].loop_block = mask->loop_block;
+ mask->loop_stack[mask->loop_stack_size].cont_mask = mask->cont_mask;
+ mask->loop_stack[mask->loop_stack_size].break_mask = mask->break_mask;
+ mask->loop_stack[mask->loop_stack_size].break_var = mask->break_var;
+ ++mask->loop_stack_size;
+
+ mask->break_var = lp_build_alloca(mask->bld->builder, mask->int_vec_type, "");
+ LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var);
- mask->break_stack[mask->break_stack_size++] = mask->break_mask;
- mask->cont_stack[mask->cont_stack_size++] = mask->cont_mask;
- mask->loop_stack[mask->loop_stack_size++] = mask->loop_block;
mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop");
LLVMBuildBr(mask->bld->builder, mask->loop_block);
LLVMPositionBuilderAtEnd(mask->bld->builder, mask->loop_block);
+ mask->break_mask = LLVMBuildLoad(mask->bld->builder, mask->break_var, "");
+
lp_exec_mask_update(mask);
}
@@ -286,11 +319,24 @@ static void lp_exec_endloop(struct lp_exec_mask *mask)
assert(mask->break_mask);
+ /*
+ * Restore the cont_mask, but don't pop
+ */
+ assert(mask->loop_stack_size);
+ mask->cont_mask = mask->loop_stack[mask->loop_stack_size - 1].cont_mask;
+ lp_exec_mask_update(mask);
+
+ /*
+ * Unlike the continue mask, the break_mask must be preserved across loop
+ * iterations
+ */
+ LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var);
+
/* i1cond = (mask == 0) */
i1cond = LLVMBuildICmp(
mask->bld->builder,
LLVMIntNE,
- LLVMBuildBitCast(mask->bld->builder, mask->break_mask, reg_type, ""),
+ LLVMBuildBitCast(mask->bld->builder, mask->exec_mask, reg_type, ""),
LLVMConstNull(reg_type), "");
endloop = lp_build_insert_new_block(mask->bld->builder, "endloop");
@@ -300,15 +346,12 @@ static void lp_exec_endloop(struct lp_exec_mask *mask)
LLVMPositionBuilderAtEnd(mask->bld->builder, endloop);
- mask->loop_block = mask->loop_stack[--mask->loop_stack_size];
- /* pop the cont mask */
- if (mask->cont_stack_size) {
- mask->cont_mask = mask->cont_stack[--mask->cont_stack_size];
- }
- /* pop the break mask */
- if (mask->break_stack_size) {
- mask->break_mask = mask->break_stack[--mask->break_stack_size];
- }
+ assert(mask->loop_stack_size);
+ --mask->loop_stack_size;
+ mask->loop_block = mask->loop_stack[mask->loop_stack_size].loop_block;
+ mask->cont_mask = mask->loop_stack[mask->loop_stack_size].cont_mask;
+ mask->break_mask = mask->loop_stack[mask->loop_stack_size].break_mask;
+ mask->break_var = mask->loop_stack[mask->loop_stack_size].break_var;
lp_exec_mask_update(mask);
}
@@ -319,15 +362,25 @@ static void lp_exec_endloop(struct lp_exec_mask *mask)
* (0 means don't store this bit, 1 means do store).
*/
static void lp_exec_mask_store(struct lp_exec_mask *mask,
+ LLVMValueRef pred,
LLVMValueRef val,
LLVMValueRef dst)
{
+ /* Mix the predicate and execution mask */
if (mask->has_mask) {
+ if (pred) {
+ pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, "");
+ } else {
+ pred = mask->exec_mask;
+ }
+ }
+
+ if (pred) {
LLVMValueRef real_val, dst_val;
dst_val = LLVMBuildLoad(mask->bld->builder, dst, "");
real_val = lp_build_select(mask->bld,
- mask->exec_mask,
+ pred,
val, dst_val);
LLVMBuildStore(mask->bld->builder, real_val, dst);
@@ -335,6 +388,49 @@ static void lp_exec_mask_store(struct lp_exec_mask *mask,
LLVMBuildStore(mask->bld->builder, val, dst);
}
+static void lp_exec_mask_call(struct lp_exec_mask *mask,
+ int func,
+ int *pc)
+{
+ assert(mask->call_stack_size < LP_MAX_TGSI_NESTING);
+ mask->call_stack[mask->call_stack_size].pc = *pc;
+ mask->call_stack[mask->call_stack_size].ret_mask = mask->ret_mask;
+ mask->call_stack_size++;
+ *pc = func;
+}
+
+static void lp_exec_mask_ret(struct lp_exec_mask *mask, int *pc)
+{
+ LLVMValueRef exec_mask;
+
+ if (mask->call_stack_size == 0) {
+ /* returning from main() */
+ *pc = -1;
+ return;
+ }
+ exec_mask = LLVMBuildNot(mask->bld->builder,
+ mask->exec_mask,
+ "ret");
+
+ mask->ret_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->ret_mask,
+ exec_mask, "ret_full");
+
+ lp_exec_mask_update(mask);
+}
+
+static void lp_exec_mask_bgnsub(struct lp_exec_mask *mask)
+{
+}
+
+static void lp_exec_mask_endsub(struct lp_exec_mask *mask, int *pc)
+{
+ assert(mask->call_stack_size);
+ mask->call_stack_size--;
+ *pc = mask->call_stack[mask->call_stack_size].pc;
+ mask->ret_mask = mask->call_stack[mask->call_stack_size].ret_mask;
+ lp_exec_mask_update(mask);
+}
static LLVMValueRef
emit_ddx(struct lp_build_tgsi_soa_context *bld,
@@ -358,15 +454,16 @@ emit_ddy(struct lp_build_tgsi_soa_context *bld,
static LLVMValueRef
get_temp_ptr(struct lp_build_tgsi_soa_context *bld,
unsigned index,
- unsigned swizzle,
+ unsigned chan,
boolean is_indirect,
LLVMValueRef addr)
{
+ assert(chan < 4);
if (!bld->has_indirect_addressing) {
- return bld->temps[index][swizzle];
+ return bld->temps[index][chan];
} else {
LLVMValueRef lindex =
- LLVMConstInt(LLVMInt32Type(), index*4 + swizzle, 0);
+ LLVMConstInt(LLVMInt32Type(), index * 4 + chan, 0);
if (is_indirect)
lindex = lp_build_add(&bld->base, lindex, addr);
return LLVMBuildGEP(bld->base.builder, bld->temps_array, &lindex, 1, "");
@@ -384,34 +481,36 @@ emit_fetch(
const unsigned chan_index )
{
const struct tgsi_full_src_register *reg = &inst->Src[index];
- unsigned swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index );
+ const unsigned swizzle =
+ tgsi_util_get_full_src_register_swizzle(reg, chan_index);
LLVMValueRef res;
- LLVMValueRef addr;
-
- switch (swizzle) {
- case TGSI_SWIZZLE_X:
- case TGSI_SWIZZLE_Y:
- case TGSI_SWIZZLE_Z:
- case TGSI_SWIZZLE_W:
-
- if (reg->Register.Indirect) {
- LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->base.type);
- unsigned swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, chan_index );
- addr = LLVMBuildLoad(bld->base.builder,
- bld->addr[reg->Indirect.Index][swizzle],
- "");
- /* for indexing we want integers */
- addr = LLVMBuildFPToSI(bld->base.builder, addr,
- int_vec_type, "");
- addr = LLVMBuildExtractElement(bld->base.builder,
- addr, LLVMConstInt(LLVMInt32Type(), 0, 0),
- "");
- addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0));
- }
-
- switch (reg->Register.File) {
- case TGSI_FILE_CONSTANT: {
- LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), reg->Register.Index*4 + swizzle, 0);
+ LLVMValueRef addr = NULL;
+
+ if (swizzle > 3) {
+ assert(0 && "invalid swizzle in emit_fetch()");
+ return bld->base.undef;
+ }
+
+ if (reg->Register.Indirect) {
+ LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->base.type);
+ unsigned swizzle = tgsi_util_get_src_register_swizzle( &reg->Indirect, chan_index );
+ addr = LLVMBuildLoad(bld->base.builder,
+ bld->addr[reg->Indirect.Index][swizzle],
+ "");
+ /* for indexing we want integers */
+ addr = LLVMBuildFPToSI(bld->base.builder, addr,
+ int_vec_type, "");
+ addr = LLVMBuildExtractElement(bld->base.builder,
+ addr, LLVMConstInt(LLVMInt32Type(), 0, 0),
+ "");
+ addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0));
+ }
+
+ switch (reg->Register.File) {
+ case TGSI_FILE_CONSTANT:
+ {
+ LLVMValueRef index = LLVMConstInt(LLVMInt32Type(),
+ reg->Register.Index*4 + swizzle, 0);
LLVMValueRef scalar, scalar_ptr;
if (reg->Register.Indirect) {
@@ -419,24 +518,26 @@ emit_fetch(
"\taddr = %d\n", addr);*/
index = lp_build_add(&bld->base, index, addr);
}
- scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, &index, 1, "");
+ scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr,
+ &index, 1, "");
scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
res = lp_build_broadcast_scalar(&bld->base, scalar);
- break;
}
+ break;
- case TGSI_FILE_IMMEDIATE:
- res = bld->immediates[reg->Register.Index][swizzle];
- assert(res);
- break;
+ case TGSI_FILE_IMMEDIATE:
+ res = bld->immediates[reg->Register.Index][swizzle];
+ assert(res);
+ break;
- case TGSI_FILE_INPUT:
- res = bld->inputs[reg->Register.Index][swizzle];
- assert(res);
- break;
+ case TGSI_FILE_INPUT:
+ res = bld->inputs[reg->Register.Index][swizzle];
+ assert(res);
+ break;
- case TGSI_FILE_TEMPORARY: {
+ case TGSI_FILE_TEMPORARY:
+ {
LLVMValueRef temp_ptr = get_temp_ptr(bld, reg->Register.Index,
swizzle,
reg->Register.Indirect,
@@ -444,17 +545,11 @@ emit_fetch(
res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
if(!res)
return bld->base.undef;
- break;
- }
-
- default:
- assert( 0 );
- return bld->base.undef;
}
break;
default:
- assert( 0 );
+ assert(0 && "invalid src register in emit_fetch()");
return bld->base.undef;
}
@@ -512,6 +607,73 @@ emit_fetch_deriv(
/**
+ * Predicate.
+ */
+static void
+emit_fetch_predicate(
+ struct lp_build_tgsi_soa_context *bld,
+ const struct tgsi_full_instruction *inst,
+ LLVMValueRef *pred)
+{
+ unsigned index;
+ unsigned char swizzles[4];
+ LLVMValueRef unswizzled[4] = {NULL, NULL, NULL, NULL};
+ LLVMValueRef value;
+ unsigned chan;
+
+ if (!inst->Instruction.Predicate) {
+ FOR_EACH_CHANNEL( chan ) {
+ pred[chan] = NULL;
+ }
+ return;
+ }
+
+ swizzles[0] = inst->Predicate.SwizzleX;
+ swizzles[1] = inst->Predicate.SwizzleY;
+ swizzles[2] = inst->Predicate.SwizzleZ;
+ swizzles[3] = inst->Predicate.SwizzleW;
+
+ index = inst->Predicate.Index;
+ assert(index < LP_MAX_TGSI_PREDS);
+
+ FOR_EACH_CHANNEL( chan ) {
+ unsigned swizzle = swizzles[chan];
+
+ /*
+ * Only fetch the predicate register channels that are actually listed
+ * in the swizzles
+ */
+ if (!unswizzled[swizzle]) {
+ value = LLVMBuildLoad(bld->base.builder,
+ bld->preds[index][swizzle], "");
+
+ /*
+ * Convert the value to an integer mask.
+ *
+ * TODO: Short-circuit this comparison -- a D3D setp_xx instructions
+ * is needlessly causing two comparisons due to storing the intermediate
+ * result as float vector instead of an integer mask vector.
+ */
+ value = lp_build_compare(bld->base.builder,
+ bld->base.type,
+ PIPE_FUNC_NOTEQUAL,
+ value,
+ bld->base.zero);
+ if (inst->Predicate.Negate) {
+ value = LLVMBuildNot(bld->base.builder, value, "");
+ }
+
+ unswizzled[swizzle] = value;
+ } else {
+ value = unswizzled[swizzle];
+ }
+
+ pred[chan] = value;
+ }
+}
+
+
+/**
* Register store.
*/
static void
@@ -520,10 +682,11 @@ emit_store(
const struct tgsi_full_instruction *inst,
unsigned index,
unsigned chan_index,
+ LLVMValueRef pred,
LLVMValueRef value)
{
const struct tgsi_full_dst_register *reg = &inst->Dst[index];
- LLVMValueRef addr;
+ LLVMValueRef addr = NULL;
switch( inst->Instruction.Saturate ) {
case TGSI_SAT_NONE:
@@ -560,7 +723,7 @@ emit_store(
switch( reg->Register.File ) {
case TGSI_FILE_OUTPUT:
- lp_exec_mask_store(&bld->exec_mask, value,
+ lp_exec_mask_store(&bld->exec_mask, pred, value,
bld->outputs[reg->Register.Index][chan_index]);
break;
@@ -569,17 +732,18 @@ emit_store(
chan_index,
reg->Register.Indirect,
addr);
- lp_exec_mask_store(&bld->exec_mask, value, temp_ptr);
+ lp_exec_mask_store(&bld->exec_mask, pred, value, temp_ptr);
break;
}
case TGSI_FILE_ADDRESS:
- lp_exec_mask_store(&bld->exec_mask, value,
+ lp_exec_mask_store(&bld->exec_mask, pred, value,
bld->addr[reg->Indirect.Index][chan_index]);
break;
case TGSI_FILE_PREDICATE:
- /* FIXME */
+ lp_exec_mask_store(&bld->exec_mask, pred, value,
+ bld->preds[index][chan_index]);
break;
default:
@@ -789,10 +953,10 @@ emit_declaration(
case TGSI_FILE_TEMPORARY:
assert(idx < LP_MAX_TGSI_TEMPS);
if (bld->has_indirect_addressing) {
- LLVMValueRef val = LLVMConstInt(LLVMInt32Type(),
- last*4 + 4, 0);
+ LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(),
+ last*4 + 4, 0);
bld->temps_array = lp_build_array_alloca(bld->base.builder,
- vec_type, val, "");
+ vec_type, array_size, "");
} else {
for (i = 0; i < NUM_CHANNELS; i++)
bld->temps[idx][i] = lp_build_alloca(bld->base.builder,
@@ -814,7 +978,10 @@ emit_declaration(
break;
case TGSI_FILE_PREDICATE:
- _debug_printf("warning: predicate registers not yet implemented\n");
+ assert(idx < LP_MAX_TGSI_PREDS);
+ for (i = 0; i < NUM_CHANNELS; i++)
+ bld->preds[idx][i] = lp_build_alloca(bld->base.builder,
+ vec_type, "");
break;
default:
@@ -833,7 +1000,8 @@ static boolean
emit_instruction(
struct lp_build_tgsi_soa_context *bld,
const struct tgsi_full_instruction *inst,
- const struct tgsi_opcode_info *info)
+ const struct tgsi_opcode_info *info,
+ int *pc)
{
unsigned chan_index;
LLVMValueRef src0, src1, src2;
@@ -857,8 +1025,10 @@ emit_instruction(
* redundant code.
*/
+ (*pc)++;
+
assert(info->num_dst <= 1);
- if(info->num_dst) {
+ if (info->num_dst) {
FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
dst0[chan_index] = bld->base.undef;
}
@@ -1455,16 +1625,18 @@ emit_instruction(
break;
case TGSI_OPCODE_CAL:
- /* FIXME */
- return FALSE;
+ lp_exec_mask_call(&bld->exec_mask,
+ inst->Label.Label,
+ pc);
+
break;
case TGSI_OPCODE_RET:
- /* FIXME */
- return FALSE;
+ lp_exec_mask_ret(&bld->exec_mask, pc);
break;
case TGSI_OPCODE_END:
+ *pc = -1;
break;
case TGSI_OPCODE_SSG:
@@ -1630,6 +1802,10 @@ emit_instruction(
lp_exec_bgnloop(&bld->exec_mask);
break;
+ case TGSI_OPCODE_BGNSUB:
+ lp_exec_mask_bgnsub(&bld->exec_mask);
+ break;
+
case TGSI_OPCODE_ELSE:
lp_exec_mask_cond_invert(&bld->exec_mask);
break;
@@ -1642,6 +1818,10 @@ emit_instruction(
lp_exec_endloop(&bld->exec_mask);
break;
+ case TGSI_OPCODE_ENDSUB:
+ lp_exec_mask_endsub(&bld->exec_mask, pc);
+ break;
+
case TGSI_OPCODE_PUSHA:
/* deprecated? */
assert(0);
@@ -1754,8 +1934,12 @@ emit_instruction(
}
if(info->num_dst) {
+ LLVMValueRef pred[NUM_CHANNELS];
+
+ emit_fetch_predicate( bld, inst, pred );
+
FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
- emit_store( bld, inst, 0, chan_index, dst0[chan_index]);
+ emit_store( bld, inst, 0, chan_index, pred[chan_index], dst0[chan_index]);
}
}
@@ -1773,16 +1957,19 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
const LLVMValueRef (*inputs)[NUM_CHANNELS],
LLVMValueRef (*outputs)[NUM_CHANNELS],
struct lp_build_sampler_soa *sampler,
- struct tgsi_shader_info *info)
+ const struct tgsi_shader_info *info)
{
struct lp_build_tgsi_soa_context bld;
struct tgsi_parse_context parse;
uint num_immediates = 0;
+ uint num_instructions = 0;
unsigned i;
+ int pc = 0;
/* Setup build context */
memset(&bld, 0, sizeof bld);
lp_build_context_init(&bld.base, builder, type);
+ lp_build_context_init(&bld.int_bld, builder, lp_int_type(type));
bld.mask = mask;
bld.pos = pos;
bld.inputs = inputs;
@@ -1791,6 +1978,13 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
bld.sampler = sampler;
bld.has_indirect_addressing = info->opcode_count[TGSI_OPCODE_ARR] > 0 ||
info->opcode_count[TGSI_OPCODE_ARL] > 0;
+ bld.instructions = (struct tgsi_full_instruction *)
+ MALLOC( LP_MAX_INSTRUCTIONS * sizeof(struct tgsi_full_instruction) );
+ bld.max_instructions = LP_MAX_INSTRUCTIONS;
+
+ if (!bld.instructions) {
+ return;
+ }
lp_exec_mask_init(&bld.exec_mask, &bld.base);
@@ -1807,11 +2001,21 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
case TGSI_TOKEN_TYPE_INSTRUCTION:
{
- unsigned opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
- const struct tgsi_opcode_info *opcode_info = tgsi_get_opcode_info(opcode);
- if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, opcode_info ))
- _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n",
- opcode_info->mnemonic);
+ /* save expanded instruction */
+ if (num_instructions == bld.max_instructions) {
+ bld.instructions = REALLOC(bld.instructions,
+ bld.max_instructions
+ * sizeof(struct tgsi_full_instruction),
+ (bld.max_instructions + LP_MAX_INSTRUCTIONS)
+ * sizeof(struct tgsi_full_instruction));
+ bld.max_instructions += LP_MAX_INSTRUCTIONS;
+ }
+
+ memcpy(bld.instructions + num_instructions,
+ &parse.FullToken.FullInstruction,
+ sizeof(bld.instructions[0]));
+
+ num_instructions++;
}
break;
@@ -1838,14 +2042,33 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
assert( 0 );
}
}
+
+ while (pc != -1) {
+ struct tgsi_full_instruction *instr = bld.instructions + pc;
+ const struct tgsi_opcode_info *opcode_info =
+ tgsi_get_opcode_info(instr->Instruction.Opcode);
+ if (!emit_instruction( &bld, instr, opcode_info, &pc ))
+ _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n",
+ opcode_info->mnemonic);
+ }
+
if (0) {
LLVMBasicBlockRef block = LLVMGetInsertBlock(builder);
LLVMValueRef function = LLVMGetBasicBlockParent(block);
debug_printf("11111111111111111111111111111 \n");
tgsi_dump(tokens, 0);
- LLVMDumpValue(function);
+ lp_debug_dump_value(function);
debug_printf("2222222222222222222222222222 \n");
}
tgsi_parse_free( &parse );
+
+ if (0) {
+ LLVMModuleRef module = LLVMGetGlobalParent(
+ LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld.base.builder)));
+ LLVMDumpModule(module);
+
+ }
+
+ FREE( bld.instructions );
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c
index 796af88caa..aac3a57bc7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c
@@ -195,6 +195,7 @@ lp_uint_type(struct lp_type type)
{
struct lp_type res_type;
+ assert(type.length <= LP_MAX_VECTOR_LENGTH);
memset(&res_type, 0, sizeof res_type);
res_type.width = type.width;
res_type.length = type.length;
@@ -211,6 +212,7 @@ lp_int_type(struct lp_type type)
{
struct lp_type res_type;
+ assert(type.length <= LP_MAX_VECTOR_LENGTH);
memset(&res_type, 0, sizeof res_type);
res_type.width = type.width;
res_type.length = type.length;
@@ -238,6 +240,131 @@ lp_wider_type(struct lp_type type)
}
+/**
+ * Return the size of the LLVMType in bits.
+ * XXX this function doesn't necessarily handle all LLVM types.
+ */
+unsigned
+lp_sizeof_llvm_type(LLVMTypeRef t)
+{
+ LLVMTypeKind k = LLVMGetTypeKind(t);
+
+ switch (k) {
+ case LLVMIntegerTypeKind:
+ return LLVMGetIntTypeWidth(t);
+ case LLVMFloatTypeKind:
+ return 8 * sizeof(float);
+ case LLVMDoubleTypeKind:
+ return 8 * sizeof(double);
+ case LLVMVectorTypeKind:
+ {
+ LLVMTypeRef elem = LLVMGetElementType(t);
+ unsigned len = LLVMGetVectorSize(t);
+ return len * lp_sizeof_llvm_type(elem);
+ }
+ break;
+ case LLVMArrayTypeKind:
+ {
+ LLVMTypeRef elem = LLVMGetElementType(t);
+ unsigned len = LLVMGetArrayLength(t);
+ return len * lp_sizeof_llvm_type(elem);
+ }
+ break;
+ default:
+ assert(0 && "Unexpected type in lp_get_llvm_type_size()");
+ return 0;
+ }
+}
+
+
+/**
+ * Return string name for a LLVMTypeKind. Useful for debugging.
+ */
+const char *
+lp_typekind_name(LLVMTypeKind t)
+{
+ switch (t) {
+ case LLVMVoidTypeKind:
+ return "LLVMVoidTypeKind";
+ case LLVMFloatTypeKind:
+ return "LLVMFloatTypeKind";
+ case LLVMDoubleTypeKind:
+ return "LLVMDoubleTypeKind";
+ case LLVMX86_FP80TypeKind:
+ return "LLVMX86_FP80TypeKind";
+ case LLVMFP128TypeKind:
+ return "LLVMFP128TypeKind";
+ case LLVMPPC_FP128TypeKind:
+ return "LLVMPPC_FP128TypeKind";
+ case LLVMLabelTypeKind:
+ return "LLVMLabelTypeKind";
+ case LLVMIntegerTypeKind:
+ return "LLVMIntegerTypeKind";
+ case LLVMFunctionTypeKind:
+ return "LLVMFunctionTypeKind";
+ case LLVMStructTypeKind:
+ return "LLVMStructTypeKind";
+ case LLVMArrayTypeKind:
+ return "LLVMArrayTypeKind";
+ case LLVMPointerTypeKind:
+ return "LLVMPointerTypeKind";
+ case LLVMOpaqueTypeKind:
+ return "LLVMOpaqueTypeKind";
+ case LLVMVectorTypeKind:
+ return "LLVMVectorTypeKind";
+ case LLVMMetadataTypeKind:
+ return "LLVMMetadataTypeKind";
+ /* Only in LLVM 2.7 and later???
+ case LLVMUnionTypeKind:
+ return "LLVMUnionTypeKind";
+ */
+ default:
+ return "unknown LLVMTypeKind";
+ }
+}
+
+
+/**
+ * Print an LLVMTypeRef. Like LLVMDumpValue(). For debugging.
+ */
+void
+lp_dump_llvmtype(LLVMTypeRef t)
+{
+ LLVMTypeKind k = LLVMGetTypeKind(t);
+
+ if (k == LLVMVectorTypeKind) {
+ LLVMTypeRef te = LLVMGetElementType(t);
+ LLVMTypeKind ke = LLVMGetTypeKind(te);
+ unsigned len = LLVMGetVectorSize(t);
+ if (ke == LLVMIntegerTypeKind) {
+ unsigned b = LLVMGetIntTypeWidth(te);
+ debug_printf("Vector [%u] of %u-bit Integer\n", len, b);
+ }
+ else {
+ debug_printf("Vector [%u] of %s\n", len, lp_typekind_name(ke));
+ }
+ }
+ else if (k == LLVMArrayTypeKind) {
+ LLVMTypeRef te = LLVMGetElementType(t);
+ LLVMTypeKind ke = LLVMGetTypeKind(te);
+ unsigned len = LLVMGetArrayLength(t);
+ debug_printf("Array [%u] of %s\n", len, lp_typekind_name(ke));
+ }
+ else if (k == LLVMIntegerTypeKind) {
+ unsigned b = LLVMGetIntTypeWidth(t);
+ debug_printf("%u-bit Integer\n", b);
+ }
+ else if (k == LLVMPointerTypeKind) {
+ LLVMTypeRef te = LLVMGetElementType(t);
+ debug_printf("Pointer to ");
+ lp_dump_llvmtype(te);
+ }
+ else {
+ debug_printf("%s\n", lp_typekind_name(k));
+ }
+}
+
+
void
lp_build_context_init(struct lp_build_context *bld,
LLVMBuilderRef builder,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h
index cd59d2faa6..17819d4d32 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h
@@ -316,6 +316,18 @@ struct lp_type
lp_wider_type(struct lp_type type);
+unsigned
+lp_sizeof_llvm_type(LLVMTypeRef t);
+
+
+const char *
+lp_typekind_name(LLVMTypeKind t);
+
+
+void
+lp_dump_llvmtype(LLVMTypeRef t);
+
+
void
lp_build_context_init(struct lp_build_context *bld,
LLVMBuilderRef builder,
diff --git a/src/gallium/auxiliary/indices/.gitignore b/src/gallium/auxiliary/indices/.gitignore
new file mode 100644
index 0000000000..7374007145
--- /dev/null
+++ b/src/gallium/auxiliary/indices/.gitignore
@@ -0,0 +1,2 @@
+u_indices_gen.c
+u_unfilled_gen.c
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.c b/src/gallium/auxiliary/indices/u_indices_gen.c
deleted file mode 100644
index 3c981e5d7f..0000000000
--- a/src/gallium/auxiliary/indices/u_indices_gen.c
+++ /dev/null
@@ -1,5129 +0,0 @@
-/* File automatically generated by indices.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_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
-static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
-
-
-
-static void generate_points_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)(i);
- }
-}
-static void generate_lines_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)(i);
- (out+i)[1] = (ushort)(i+1);
- }
-}
-static void generate_linestrip_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1);
- }
-}
-static void generate_lineloop_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1);
- }
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(0);
-}
-static void generate_tris_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)(i);
- (out+i)[1] = (ushort)(i+1);
- (out+i)[2] = (ushort)(i+2);
- }
-}
-static void generate_tristrip_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1+(i&1));
- (out+j)[2] = (ushort)(i+2-(i&1));
- }
-}
-static void generate_trifan_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i+1);
- (out+j)[2] = (ushort)(i+2);
- }
-}
-static void generate_quads_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (ushort)(i+0);
- (out+j+0)[1] = (ushort)(i+1);
- (out+j+0)[2] = (ushort)(i+3);
- (out+j+3)[0] = (ushort)(i+1);
- (out+j+3)[1] = (ushort)(i+2);
- (out+j+3)[2] = (ushort)(i+3);
- }
-}
-static void generate_quadstrip_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (ushort)(i+2);
- (out+j+0)[1] = (ushort)(i+0);
- (out+j+0)[2] = (ushort)(i+3);
- (out+j+3)[0] = (ushort)(i+0);
- (out+j+3)[1] = (ushort)(i+1);
- (out+j+3)[2] = (ushort)(i+3);
- }
-}
-static void generate_polygon_ushort_first2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i+1);
- (out+j)[2] = (ushort)(i+2);
- }
-}
-static void generate_points_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)(i);
- }
-}
-static void generate_lines_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)(i+1);
- (out+i)[1] = (ushort)(i);
- }
-}
-static void generate_linestrip_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i);
- }
-}
-static void generate_lineloop_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i);
- }
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i);
-}
-static void generate_tris_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)(i+1);
- (out+i)[1] = (ushort)(i+2);
- (out+i)[2] = (ushort)(i);
- }
-}
-static void generate_tristrip_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+1+(i&1));
- (out+j)[1] = (ushort)(i+2-(i&1));
- (out+j)[2] = (ushort)(i);
- }
-}
-static void generate_trifan_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i+2);
- (out+j)[2] = (ushort)(0);
- }
-}
-static void generate_quads_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (ushort)(i+1);
- (out+j+0)[1] = (ushort)(i+3);
- (out+j+0)[2] = (ushort)(i+0);
- (out+j+3)[0] = (ushort)(i+2);
- (out+j+3)[1] = (ushort)(i+3);
- (out+j+3)[2] = (ushort)(i+1);
- }
-}
-static void generate_quadstrip_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (ushort)(i+0);
- (out+j+0)[1] = (ushort)(i+3);
- (out+j+0)[2] = (ushort)(i+2);
- (out+j+3)[0] = (ushort)(i+1);
- (out+j+3)[1] = (ushort)(i+3);
- (out+j+3)[2] = (ushort)(i+0);
- }
-}
-static void generate_polygon_ushort_first2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i+2);
- (out+j)[2] = (ushort)(0);
- }
-}
-static void generate_points_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)(i);
- }
-}
-static void generate_lines_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)(i+1);
- (out+i)[1] = (ushort)(i);
- }
-}
-static void generate_linestrip_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i);
- }
-}
-static void generate_lineloop_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i);
- }
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i);
-}
-static void generate_tris_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)(i+2);
- (out+i)[1] = (ushort)(i);
- (out+i)[2] = (ushort)(i+1);
- }
-}
-static void generate_tristrip_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+2);
- (out+j)[1] = (ushort)(i+(i&1));
- (out+j)[2] = (ushort)(i+1-(i&1));
- }
-}
-static void generate_trifan_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+2);
- (out+j)[1] = (ushort)(0);
- (out+j)[2] = (ushort)(i+1);
- }
-}
-static void generate_quads_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (ushort)(i+3);
- (out+j+0)[1] = (ushort)(i+0);
- (out+j+0)[2] = (ushort)(i+1);
- (out+j+3)[0] = (ushort)(i+3);
- (out+j+3)[1] = (ushort)(i+1);
- (out+j+3)[2] = (ushort)(i+2);
- }
-}
-static void generate_quadstrip_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (ushort)(i+3);
- (out+j+0)[1] = (ushort)(i+2);
- (out+j+0)[2] = (ushort)(i+0);
- (out+j+3)[0] = (ushort)(i+3);
- (out+j+3)[1] = (ushort)(i+0);
- (out+j+3)[2] = (ushort)(i+1);
- }
-}
-static void generate_polygon_ushort_last2first(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i+1);
- (out+j)[2] = (ushort)(i+2);
- }
-}
-static void generate_points_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)(i);
- }
-}
-static void generate_lines_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)(i);
- (out+i)[1] = (ushort)(i+1);
- }
-}
-static void generate_linestrip_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1);
- }
-}
-static void generate_lineloop_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1);
- }
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(0);
-}
-static void generate_tris_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)(i);
- (out+i)[1] = (ushort)(i+1);
- (out+i)[2] = (ushort)(i+2);
- }
-}
-static void generate_tristrip_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+(i&1));
- (out+j)[1] = (ushort)(i+1-(i&1));
- (out+j)[2] = (ushort)(i+2);
- }
-}
-static void generate_trifan_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i+1);
- (out+j)[2] = (ushort)(i+2);
- }
-}
-static void generate_quads_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (ushort)(i+0);
- (out+j+0)[1] = (ushort)(i+1);
- (out+j+0)[2] = (ushort)(i+3);
- (out+j+3)[0] = (ushort)(i+1);
- (out+j+3)[1] = (ushort)(i+2);
- (out+j+3)[2] = (ushort)(i+3);
- }
-}
-static void generate_quadstrip_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (ushort)(i+2);
- (out+j+0)[1] = (ushort)(i+0);
- (out+j+0)[2] = (ushort)(i+3);
- (out+j+3)[0] = (ushort)(i+0);
- (out+j+3)[1] = (ushort)(i+1);
- (out+j+3)[2] = (ushort)(i+3);
- }
-}
-static void generate_polygon_ushort_last2last(
- unsigned nr,
- void *_out )
-{
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (ushort)(i+1);
- (out+j)[1] = (ushort)(i+2);
- (out+j)[2] = (ushort)(0);
- }
-}
-static void generate_points_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)(i);
- }
-}
-static void generate_lines_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)(i);
- (out+i)[1] = (uint)(i+1);
- }
-}
-static void generate_linestrip_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1);
- }
-}
-static void generate_lineloop_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1);
- }
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(0);
-}
-static void generate_tris_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)(i);
- (out+i)[1] = (uint)(i+1);
- (out+i)[2] = (uint)(i+2);
- }
-}
-static void generate_tristrip_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1+(i&1));
- (out+j)[2] = (uint)(i+2-(i&1));
- }
-}
-static void generate_trifan_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i+1);
- (out+j)[2] = (uint)(i+2);
- }
-}
-static void generate_quads_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (uint)(i+0);
- (out+j+0)[1] = (uint)(i+1);
- (out+j+0)[2] = (uint)(i+3);
- (out+j+3)[0] = (uint)(i+1);
- (out+j+3)[1] = (uint)(i+2);
- (out+j+3)[2] = (uint)(i+3);
- }
-}
-static void generate_quadstrip_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (uint)(i+2);
- (out+j+0)[1] = (uint)(i+0);
- (out+j+0)[2] = (uint)(i+3);
- (out+j+3)[0] = (uint)(i+0);
- (out+j+3)[1] = (uint)(i+1);
- (out+j+3)[2] = (uint)(i+3);
- }
-}
-static void generate_polygon_uint_first2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i+1);
- (out+j)[2] = (uint)(i+2);
- }
-}
-static void generate_points_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)(i);
- }
-}
-static void generate_lines_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)(i+1);
- (out+i)[1] = (uint)(i);
- }
-}
-static void generate_linestrip_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i);
- }
-}
-static void generate_lineloop_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i);
- }
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i);
-}
-static void generate_tris_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)(i+1);
- (out+i)[1] = (uint)(i+2);
- (out+i)[2] = (uint)(i);
- }
-}
-static void generate_tristrip_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+1+(i&1));
- (out+j)[1] = (uint)(i+2-(i&1));
- (out+j)[2] = (uint)(i);
- }
-}
-static void generate_trifan_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i+2);
- (out+j)[2] = (uint)(0);
- }
-}
-static void generate_quads_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (uint)(i+1);
- (out+j+0)[1] = (uint)(i+3);
- (out+j+0)[2] = (uint)(i+0);
- (out+j+3)[0] = (uint)(i+2);
- (out+j+3)[1] = (uint)(i+3);
- (out+j+3)[2] = (uint)(i+1);
- }
-}
-static void generate_quadstrip_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (uint)(i+0);
- (out+j+0)[1] = (uint)(i+3);
- (out+j+0)[2] = (uint)(i+2);
- (out+j+3)[0] = (uint)(i+1);
- (out+j+3)[1] = (uint)(i+3);
- (out+j+3)[2] = (uint)(i+0);
- }
-}
-static void generate_polygon_uint_first2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i+2);
- (out+j)[2] = (uint)(0);
- }
-}
-static void generate_points_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)(i);
- }
-}
-static void generate_lines_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)(i+1);
- (out+i)[1] = (uint)(i);
- }
-}
-static void generate_linestrip_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i);
- }
-}
-static void generate_lineloop_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i);
- }
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i);
-}
-static void generate_tris_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)(i+2);
- (out+i)[1] = (uint)(i);
- (out+i)[2] = (uint)(i+1);
- }
-}
-static void generate_tristrip_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+2);
- (out+j)[1] = (uint)(i+(i&1));
- (out+j)[2] = (uint)(i+1-(i&1));
- }
-}
-static void generate_trifan_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+2);
- (out+j)[1] = (uint)(0);
- (out+j)[2] = (uint)(i+1);
- }
-}
-static void generate_quads_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (uint)(i+3);
- (out+j+0)[1] = (uint)(i+0);
- (out+j+0)[2] = (uint)(i+1);
- (out+j+3)[0] = (uint)(i+3);
- (out+j+3)[1] = (uint)(i+1);
- (out+j+3)[2] = (uint)(i+2);
- }
-}
-static void generate_quadstrip_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (uint)(i+3);
- (out+j+0)[1] = (uint)(i+2);
- (out+j+0)[2] = (uint)(i+0);
- (out+j+3)[0] = (uint)(i+3);
- (out+j+3)[1] = (uint)(i+0);
- (out+j+3)[2] = (uint)(i+1);
- }
-}
-static void generate_polygon_uint_last2first(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i+1);
- (out+j)[2] = (uint)(i+2);
- }
-}
-static void generate_points_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)(i);
- }
-}
-static void generate_lines_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)(i);
- (out+i)[1] = (uint)(i+1);
- }
-}
-static void generate_linestrip_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=2, i++) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1);
- }
-}
-static void generate_lineloop_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr - 2; j+=2, i++) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1);
- }
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(0);
-}
-static void generate_tris_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)(i);
- (out+i)[1] = (uint)(i+1);
- (out+i)[2] = (uint)(i+2);
- }
-}
-static void generate_tristrip_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+(i&1));
- (out+j)[1] = (uint)(i+1-(i&1));
- (out+j)[2] = (uint)(i+2);
- }
-}
-static void generate_trifan_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i+1);
- (out+j)[2] = (uint)(i+2);
- }
-}
-static void generate_quads_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=4) {
- (out+j+0)[0] = (uint)(i+0);
- (out+j+0)[1] = (uint)(i+1);
- (out+j+0)[2] = (uint)(i+3);
- (out+j+3)[0] = (uint)(i+1);
- (out+j+3)[1] = (uint)(i+2);
- (out+j+3)[2] = (uint)(i+3);
- }
-}
-static void generate_quadstrip_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=6, i+=2) {
- (out+j+0)[0] = (uint)(i+2);
- (out+j+0)[1] = (uint)(i+0);
- (out+j+0)[2] = (uint)(i+3);
- (out+j+3)[0] = (uint)(i+0);
- (out+j+3)[1] = (uint)(i+1);
- (out+j+3)[2] = (uint)(i+3);
- }
-}
-static void generate_polygon_uint_last2last(
- unsigned nr,
- void *_out )
-{
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (j = i = 0; j < nr; j+=3, i++) {
- (out+j)[0] = (uint)(i+1);
- (out+j)[1] = (uint)(i+2);
- (out+j)[2] = (uint)(0);
- }
-}
-static void translate_points_ubyte2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ubyte2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- }
-}
-static void translate_linestrip_ubyte2ushort_first2first(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
-}
-static void translate_lineloop_ubyte2ushort_first2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[0];
-}
-static void translate_tris_ubyte2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- (out+i)[2] = (ushort)in[i+2];
- }
-}
-static void translate_tristrip_ubyte2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1+(i&1)];
- (out+j)[2] = (ushort)in[i+2-(i&1)];
- }
-}
-static void translate_trifan_ubyte2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quads_ubyte2ushort_first2first(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+1];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+2];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_quadstrip_ubyte2ushort_first2first(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+2];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+0];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_polygon_ubyte2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_points_ubyte2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ubyte2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i];
- }
-}
-static void translate_linestrip_ubyte2ushort_first2last(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
-}
-static void translate_lineloop_ubyte2ushort_first2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i];
-}
-static void translate_tris_ubyte2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i+2];
- (out+i)[2] = (ushort)in[i];
- }
-}
-static void translate_tristrip_ubyte2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1+(i&1)];
- (out+j)[1] = (ushort)in[i+2-(i&1)];
- (out+j)[2] = (ushort)in[i];
- }
-}
-static void translate_trifan_ubyte2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_quads_ubyte2ushort_first2last(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+1];
- (out+j+0)[1] = (ushort)in[i+3];
- (out+j+0)[2] = (ushort)in[i+0];
- (out+j+3)[0] = (ushort)in[i+2];
- (out+j+3)[1] = (ushort)in[i+3];
- (out+j+3)[2] = (ushort)in[i+1];
- }
-}
-static void translate_quadstrip_ubyte2ushort_first2last(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+3];
- (out+j+0)[2] = (ushort)in[i+2];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+3];
- (out+j+3)[2] = (ushort)in[i+0];
- }
-}
-static void translate_polygon_ubyte2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_points_ubyte2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ubyte2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i];
- }
-}
-static void translate_linestrip_ubyte2ushort_last2first(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
-}
-static void translate_lineloop_ubyte2ushort_last2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i];
-}
-static void translate_tris_ubyte2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i+2];
- (out+i)[1] = (ushort)in[i];
- (out+i)[2] = (ushort)in[i+1];
- }
-}
-static void translate_tristrip_ubyte2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[i+(i&1)];
- (out+j)[2] = (ushort)in[i+1-(i&1)];
- }
-}
-static void translate_trifan_ubyte2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[0];
- (out+j)[2] = (ushort)in[i+1];
- }
-}
-static void translate_quads_ubyte2ushort_last2first(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+3];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+1];
- (out+j+3)[0] = (ushort)in[i+3];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quadstrip_ubyte2ushort_last2first(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+3];
- (out+j+0)[1] = (ushort)in[i+2];
- (out+j+0)[2] = (ushort)in[i+0];
- (out+j+3)[0] = (ushort)in[i+3];
- (out+j+3)[1] = (ushort)in[i+0];
- (out+j+3)[2] = (ushort)in[i+1];
- }
-}
-static void translate_polygon_ubyte2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_points_ubyte2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ubyte2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- }
-}
-static void translate_linestrip_ubyte2ushort_last2last(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
-}
-static void translate_lineloop_ubyte2ushort_last2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[0];
-}
-static void translate_tris_ubyte2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- (out+i)[2] = (ushort)in[i+2];
- }
-}
-static void translate_tristrip_ubyte2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+(i&1)];
- (out+j)[1] = (ushort)in[i+1-(i&1)];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_trifan_ubyte2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quads_ubyte2ushort_last2last(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+1];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+2];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_quadstrip_ubyte2ushort_last2last(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+2];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+0];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_polygon_ubyte2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_points_ubyte2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ubyte2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- }
-}
-static void translate_linestrip_ubyte2uint_first2first(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
-}
-static void translate_lineloop_ubyte2uint_first2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[0];
-}
-static void translate_tris_ubyte2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- (out+i)[2] = (uint)in[i+2];
- }
-}
-static void translate_tristrip_ubyte2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1+(i&1)];
- (out+j)[2] = (uint)in[i+2-(i&1)];
- }
-}
-static void translate_trifan_ubyte2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_quads_ubyte2uint_first2first(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+1];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+2];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_quadstrip_ubyte2uint_first2first(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+2];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+0];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_polygon_ubyte2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_points_ubyte2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ubyte2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i];
- }
-}
-static void translate_linestrip_ubyte2uint_first2last(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
-}
-static void translate_lineloop_ubyte2uint_first2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i];
-}
-static void translate_tris_ubyte2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i+2];
- (out+i)[2] = (uint)in[i];
- }
-}
-static void translate_tristrip_ubyte2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1+(i&1)];
- (out+j)[1] = (uint)in[i+2-(i&1)];
- (out+j)[2] = (uint)in[i];
- }
-}
-static void translate_trifan_ubyte2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_quads_ubyte2uint_first2last(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+1];
- (out+j+0)[1] = (uint)in[i+3];
- (out+j+0)[2] = (uint)in[i+0];
- (out+j+3)[0] = (uint)in[i+2];
- (out+j+3)[1] = (uint)in[i+3];
- (out+j+3)[2] = (uint)in[i+1];
- }
-}
-static void translate_quadstrip_ubyte2uint_first2last(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+3];
- (out+j+0)[2] = (uint)in[i+2];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+3];
- (out+j+3)[2] = (uint)in[i+0];
- }
-}
-static void translate_polygon_ubyte2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_points_ubyte2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ubyte2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i];
- }
-}
-static void translate_linestrip_ubyte2uint_last2first(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
-}
-static void translate_lineloop_ubyte2uint_last2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i];
-}
-static void translate_tris_ubyte2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i+2];
- (out+i)[1] = (uint)in[i];
- (out+i)[2] = (uint)in[i+1];
- }
-}
-static void translate_tristrip_ubyte2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[i+(i&1)];
- (out+j)[2] = (uint)in[i+1-(i&1)];
- }
-}
-static void translate_trifan_ubyte2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[0];
- (out+j)[2] = (uint)in[i+1];
- }
-}
-static void translate_quads_ubyte2uint_last2first(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+3];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+1];
- (out+j+3)[0] = (uint)in[i+3];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+2];
- }
-}
-static void translate_quadstrip_ubyte2uint_last2first(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+3];
- (out+j+0)[1] = (uint)in[i+2];
- (out+j+0)[2] = (uint)in[i+0];
- (out+j+3)[0] = (uint)in[i+3];
- (out+j+3)[1] = (uint)in[i+0];
- (out+j+3)[2] = (uint)in[i+1];
- }
-}
-static void translate_polygon_ubyte2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_points_ubyte2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ubyte2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- }
-}
-static void translate_linestrip_ubyte2uint_last2last(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
-}
-static void translate_lineloop_ubyte2uint_last2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[0];
-}
-static void translate_tris_ubyte2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ubyte*in = (const ubyte*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- (out+i)[2] = (uint)in[i+2];
- }
-}
-static void translate_tristrip_ubyte2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+(i&1)];
- (out+j)[1] = (uint)in[i+1-(i&1)];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_trifan_ubyte2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_quads_ubyte2uint_last2last(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+1];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+2];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_quadstrip_ubyte2uint_last2last(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+2];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+0];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_polygon_ubyte2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_points_ushort2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ushort2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- }
-}
-static void translate_linestrip_ushort2ushort_first2first(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
-}
-static void translate_lineloop_ushort2ushort_first2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[0];
-}
-static void translate_tris_ushort2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- (out+i)[2] = (ushort)in[i+2];
- }
-}
-static void translate_tristrip_ushort2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1+(i&1)];
- (out+j)[2] = (ushort)in[i+2-(i&1)];
- }
-}
-static void translate_trifan_ushort2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quads_ushort2ushort_first2first(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+1];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+2];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_quadstrip_ushort2ushort_first2first(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+2];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+0];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_polygon_ushort2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_points_ushort2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ushort2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i];
- }
-}
-static void translate_linestrip_ushort2ushort_first2last(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
-}
-static void translate_lineloop_ushort2ushort_first2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i];
-}
-static void translate_tris_ushort2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i+2];
- (out+i)[2] = (ushort)in[i];
- }
-}
-static void translate_tristrip_ushort2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1+(i&1)];
- (out+j)[1] = (ushort)in[i+2-(i&1)];
- (out+j)[2] = (ushort)in[i];
- }
-}
-static void translate_trifan_ushort2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_quads_ushort2ushort_first2last(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+1];
- (out+j+0)[1] = (ushort)in[i+3];
- (out+j+0)[2] = (ushort)in[i+0];
- (out+j+3)[0] = (ushort)in[i+2];
- (out+j+3)[1] = (ushort)in[i+3];
- (out+j+3)[2] = (ushort)in[i+1];
- }
-}
-static void translate_quadstrip_ushort2ushort_first2last(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+3];
- (out+j+0)[2] = (ushort)in[i+2];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+3];
- (out+j+3)[2] = (ushort)in[i+0];
- }
-}
-static void translate_polygon_ushort2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_points_ushort2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ushort2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i];
- }
-}
-static void translate_linestrip_ushort2ushort_last2first(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
-}
-static void translate_lineloop_ushort2ushort_last2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i];
-}
-static void translate_tris_ushort2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i+2];
- (out+i)[1] = (ushort)in[i];
- (out+i)[2] = (ushort)in[i+1];
- }
-}
-static void translate_tristrip_ushort2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[i+(i&1)];
- (out+j)[2] = (ushort)in[i+1-(i&1)];
- }
-}
-static void translate_trifan_ushort2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[0];
- (out+j)[2] = (ushort)in[i+1];
- }
-}
-static void translate_quads_ushort2ushort_last2first(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+3];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+1];
- (out+j+3)[0] = (ushort)in[i+3];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quadstrip_ushort2ushort_last2first(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+3];
- (out+j+0)[1] = (ushort)in[i+2];
- (out+j+0)[2] = (ushort)in[i+0];
- (out+j+3)[0] = (ushort)in[i+3];
- (out+j+3)[1] = (ushort)in[i+0];
- (out+j+3)[2] = (ushort)in[i+1];
- }
-}
-static void translate_polygon_ushort2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_points_ushort2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_ushort2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- }
-}
-static void translate_linestrip_ushort2ushort_last2last(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
-}
-static void translate_lineloop_ushort2ushort_last2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[0];
-}
-static void translate_tris_ushort2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- (out+i)[2] = (ushort)in[i+2];
- }
-}
-static void translate_tristrip_ushort2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+(i&1)];
- (out+j)[1] = (ushort)in[i+1-(i&1)];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_trifan_ushort2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quads_ushort2ushort_last2last(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+1];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+2];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_quadstrip_ushort2ushort_last2last(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+2];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+0];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_polygon_ushort2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_points_ushort2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ushort2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- }
-}
-static void translate_linestrip_ushort2uint_first2first(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
-}
-static void translate_lineloop_ushort2uint_first2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[0];
-}
-static void translate_tris_ushort2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- (out+i)[2] = (uint)in[i+2];
- }
-}
-static void translate_tristrip_ushort2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1+(i&1)];
- (out+j)[2] = (uint)in[i+2-(i&1)];
- }
-}
-static void translate_trifan_ushort2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_quads_ushort2uint_first2first(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+1];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+2];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_quadstrip_ushort2uint_first2first(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+2];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+0];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_polygon_ushort2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_points_ushort2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ushort2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i];
- }
-}
-static void translate_linestrip_ushort2uint_first2last(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
-}
-static void translate_lineloop_ushort2uint_first2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i];
-}
-static void translate_tris_ushort2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i+2];
- (out+i)[2] = (uint)in[i];
- }
-}
-static void translate_tristrip_ushort2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1+(i&1)];
- (out+j)[1] = (uint)in[i+2-(i&1)];
- (out+j)[2] = (uint)in[i];
- }
-}
-static void translate_trifan_ushort2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_quads_ushort2uint_first2last(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+1];
- (out+j+0)[1] = (uint)in[i+3];
- (out+j+0)[2] = (uint)in[i+0];
- (out+j+3)[0] = (uint)in[i+2];
- (out+j+3)[1] = (uint)in[i+3];
- (out+j+3)[2] = (uint)in[i+1];
- }
-}
-static void translate_quadstrip_ushort2uint_first2last(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+3];
- (out+j+0)[2] = (uint)in[i+2];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+3];
- (out+j+3)[2] = (uint)in[i+0];
- }
-}
-static void translate_polygon_ushort2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_points_ushort2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ushort2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i];
- }
-}
-static void translate_linestrip_ushort2uint_last2first(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
-}
-static void translate_lineloop_ushort2uint_last2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i];
-}
-static void translate_tris_ushort2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i+2];
- (out+i)[1] = (uint)in[i];
- (out+i)[2] = (uint)in[i+1];
- }
-}
-static void translate_tristrip_ushort2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[i+(i&1)];
- (out+j)[2] = (uint)in[i+1-(i&1)];
- }
-}
-static void translate_trifan_ushort2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[0];
- (out+j)[2] = (uint)in[i+1];
- }
-}
-static void translate_quads_ushort2uint_last2first(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+3];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+1];
- (out+j+3)[0] = (uint)in[i+3];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+2];
- }
-}
-static void translate_quadstrip_ushort2uint_last2first(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+3];
- (out+j+0)[1] = (uint)in[i+2];
- (out+j+0)[2] = (uint)in[i+0];
- (out+j+3)[0] = (uint)in[i+3];
- (out+j+3)[1] = (uint)in[i+0];
- (out+j+3)[2] = (uint)in[i+1];
- }
-}
-static void translate_polygon_ushort2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_points_ushort2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_ushort2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- }
-}
-static void translate_linestrip_ushort2uint_last2last(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
-}
-static void translate_lineloop_ushort2uint_last2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[0];
-}
-static void translate_tris_ushort2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const ushort*in = (const ushort*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- (out+i)[2] = (uint)in[i+2];
- }
-}
-static void translate_tristrip_ushort2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+(i&1)];
- (out+j)[1] = (uint)in[i+1-(i&1)];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_trifan_ushort2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_quads_ushort2uint_last2last(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+1];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+2];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_quadstrip_ushort2uint_last2last(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+2];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+0];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_polygon_ushort2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_points_uint2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_uint2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- }
-}
-static void translate_linestrip_uint2ushort_first2first(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
-}
-static void translate_lineloop_uint2ushort_first2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[0];
-}
-static void translate_tris_uint2ushort_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- (out+i)[2] = (ushort)in[i+2];
- }
-}
-static void translate_tristrip_uint2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1+(i&1)];
- (out+j)[2] = (ushort)in[i+2-(i&1)];
- }
-}
-static void translate_trifan_uint2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quads_uint2ushort_first2first(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+1];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+2];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_quadstrip_uint2ushort_first2first(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+2];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+0];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_polygon_uint2ushort_first2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_points_uint2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_uint2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i];
- }
-}
-static void translate_linestrip_uint2ushort_first2last(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
-}
-static void translate_lineloop_uint2ushort_first2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i];
-}
-static void translate_tris_uint2ushort_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i+2];
- (out+i)[2] = (ushort)in[i];
- }
-}
-static void translate_tristrip_uint2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1+(i&1)];
- (out+j)[1] = (ushort)in[i+2-(i&1)];
- (out+j)[2] = (ushort)in[i];
- }
-}
-static void translate_trifan_uint2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_quads_uint2ushort_first2last(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+1];
- (out+j+0)[1] = (ushort)in[i+3];
- (out+j+0)[2] = (ushort)in[i+0];
- (out+j+3)[0] = (ushort)in[i+2];
- (out+j+3)[1] = (ushort)in[i+3];
- (out+j+3)[2] = (ushort)in[i+1];
- }
-}
-static void translate_quadstrip_uint2ushort_first2last(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+3];
- (out+j+0)[2] = (ushort)in[i+2];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+3];
- (out+j+3)[2] = (ushort)in[i+0];
- }
-}
-static void translate_polygon_uint2ushort_first2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_points_uint2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_uint2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i+1];
- (out+i)[1] = (ushort)in[i];
- }
-}
-static void translate_linestrip_uint2ushort_last2first(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
-}
-static void translate_lineloop_uint2ushort_last2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i];
- }
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i];
-}
-static void translate_tris_uint2ushort_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i+2];
- (out+i)[1] = (ushort)in[i];
- (out+i)[2] = (ushort)in[i+1];
- }
-}
-static void translate_tristrip_uint2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[i+(i&1)];
- (out+j)[2] = (ushort)in[i+1-(i&1)];
- }
-}
-static void translate_trifan_uint2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[0];
- (out+j)[2] = (ushort)in[i+1];
- }
-}
-static void translate_quads_uint2ushort_last2first(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+3];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+1];
- (out+j+3)[0] = (ushort)in[i+3];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quadstrip_uint2ushort_last2first(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+3];
- (out+j+0)[1] = (ushort)in[i+2];
- (out+j+0)[2] = (ushort)in[i+0];
- (out+j+3)[0] = (ushort)in[i+3];
- (out+j+3)[1] = (ushort)in[i+0];
- (out+j+3)[2] = (ushort)in[i+1];
- }
-}
-static void translate_polygon_uint2ushort_last2first(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_points_uint2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (ushort)in[i];
- }
-}
-static void translate_lines_uint2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- }
-}
-static void translate_linestrip_uint2ushort_last2last(
- 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+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
-}
-static void translate_lineloop_uint2ushort_last2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- }
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[0];
-}
-static void translate_tris_uint2ushort_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- ushort *out = (ushort*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (ushort)in[i];
- (out+i)[1] = (ushort)in[i+1];
- (out+i)[2] = (ushort)in[i+2];
- }
-}
-static void translate_tristrip_uint2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+(i&1)];
- (out+j)[1] = (ushort)in[i+1-(i&1)];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_trifan_uint2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j)[2] = (ushort)in[i+2];
- }
-}
-static void translate_quads_uint2ushort_last2last(
- 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+=4) {
- (out+j+0)[0] = (ushort)in[i+0];
- (out+j+0)[1] = (ushort)in[i+1];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+1];
- (out+j+3)[1] = (ushort)in[i+2];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_quadstrip_uint2ushort_last2last(
- 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+=2) {
- (out+j+0)[0] = (ushort)in[i+2];
- (out+j+0)[1] = (ushort)in[i+0];
- (out+j+0)[2] = (ushort)in[i+3];
- (out+j+3)[0] = (ushort)in[i+0];
- (out+j+3)[1] = (ushort)in[i+1];
- (out+j+3)[2] = (ushort)in[i+3];
- }
-}
-static void translate_polygon_uint2ushort_last2last(
- 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+=3, i++) {
- (out+j)[0] = (ushort)in[i+1];
- (out+j)[1] = (ushort)in[i+2];
- (out+j)[2] = (ushort)in[0];
- }
-}
-static void translate_points_uint2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_uint2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- }
-}
-static void translate_linestrip_uint2uint_first2first(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
-}
-static void translate_lineloop_uint2uint_first2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[0];
-}
-static void translate_tris_uint2uint_first2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- (out+i)[2] = (uint)in[i+2];
- }
-}
-static void translate_tristrip_uint2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1+(i&1)];
- (out+j)[2] = (uint)in[i+2-(i&1)];
- }
-}
-static void translate_trifan_uint2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_quads_uint2uint_first2first(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+1];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+2];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_quadstrip_uint2uint_first2first(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+2];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+0];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_polygon_uint2uint_first2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_points_uint2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_uint2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i];
- }
-}
-static void translate_linestrip_uint2uint_first2last(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
-}
-static void translate_lineloop_uint2uint_first2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i];
-}
-static void translate_tris_uint2uint_first2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i+2];
- (out+i)[2] = (uint)in[i];
- }
-}
-static void translate_tristrip_uint2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1+(i&1)];
- (out+j)[1] = (uint)in[i+2-(i&1)];
- (out+j)[2] = (uint)in[i];
- }
-}
-static void translate_trifan_uint2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_quads_uint2uint_first2last(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+1];
- (out+j+0)[1] = (uint)in[i+3];
- (out+j+0)[2] = (uint)in[i+0];
- (out+j+3)[0] = (uint)in[i+2];
- (out+j+3)[1] = (uint)in[i+3];
- (out+j+3)[2] = (uint)in[i+1];
- }
-}
-static void translate_quadstrip_uint2uint_first2last(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+3];
- (out+j+0)[2] = (uint)in[i+2];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+3];
- (out+j+3)[2] = (uint)in[i+0];
- }
-}
-static void translate_polygon_uint2uint_first2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-static void translate_points_uint2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_uint2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i+1];
- (out+i)[1] = (uint)in[i];
- }
-}
-static void translate_linestrip_uint2uint_last2first(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
-}
-static void translate_lineloop_uint2uint_last2first(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i];
- }
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i];
-}
-static void translate_tris_uint2uint_last2first(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i+2];
- (out+i)[1] = (uint)in[i];
- (out+i)[2] = (uint)in[i+1];
- }
-}
-static void translate_tristrip_uint2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[i+(i&1)];
- (out+j)[2] = (uint)in[i+1-(i&1)];
- }
-}
-static void translate_trifan_uint2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[0];
- (out+j)[2] = (uint)in[i+1];
- }
-}
-static void translate_quads_uint2uint_last2first(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+3];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+1];
- (out+j+3)[0] = (uint)in[i+3];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+2];
- }
-}
-static void translate_quadstrip_uint2uint_last2first(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+3];
- (out+j+0)[1] = (uint)in[i+2];
- (out+j+0)[2] = (uint)in[i+0];
- (out+j+3)[0] = (uint)in[i+3];
- (out+j+3)[1] = (uint)in[i+0];
- (out+j+3)[2] = (uint)in[i+1];
- }
-}
-static void translate_polygon_uint2uint_last2first(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_points_uint2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i++) {
- (out+i)[0] = (uint)in[i];
- }
-}
-static void translate_lines_uint2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=2) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- }
-}
-static void translate_linestrip_uint2uint_last2last(
- 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+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
-}
-static void translate_lineloop_uint2uint_last2last(
- 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 - 2; j+=2, i++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- }
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[0];
-}
-static void translate_tris_uint2uint_last2last(
- const void * _in,
- unsigned nr,
- void *_out )
-{
- const uint*in = (const uint*)_in;
- uint *out = (uint*)_out;
- unsigned i, j;
- (void)j;
- for (i = 0; i < nr; i+=3) {
- (out+i)[0] = (uint)in[i];
- (out+i)[1] = (uint)in[i+1];
- (out+i)[2] = (uint)in[i+2];
- }
-}
-static void translate_tristrip_uint2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+(i&1)];
- (out+j)[1] = (uint)in[i+1-(i&1)];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_trifan_uint2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j)[2] = (uint)in[i+2];
- }
-}
-static void translate_quads_uint2uint_last2last(
- 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+=4) {
- (out+j+0)[0] = (uint)in[i+0];
- (out+j+0)[1] = (uint)in[i+1];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+1];
- (out+j+3)[1] = (uint)in[i+2];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_quadstrip_uint2uint_last2last(
- 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+=2) {
- (out+j+0)[0] = (uint)in[i+2];
- (out+j+0)[1] = (uint)in[i+0];
- (out+j+0)[2] = (uint)in[i+3];
- (out+j+3)[0] = (uint)in[i+0];
- (out+j+3)[1] = (uint)in[i+1];
- (out+j+3)[2] = (uint)in[i+3];
- }
-}
-static void translate_polygon_uint2uint_last2last(
- 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+=3, i++) {
- (out+j)[0] = (uint)in[i+1];
- (out+j)[1] = (uint)in[i+2];
- (out+j)[2] = (uint)in[0];
- }
-}
-void u_index_init( void )
-{
- static int firsttime = 1;
- if (!firsttime) return;
- firsttime = 0;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_first2first;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_first2last;
-generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_first2last;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_last2first;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_last2last;
-generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_last2last;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_uint_first2first;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_first2last;
-generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_uint_first2last;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_uint_last2first;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_last2last;
-generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_uint_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_first2first;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_first2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_last2first;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_first2first;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_first2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_last2first;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_last2last;
-translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_first2first;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_first2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_last2first;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_last2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_first2first;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_first2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_last2first;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_last2last;
-translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_last2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_first2first;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_first2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_last2first;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_last2last;
-translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_last2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_first2first;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_first2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_last2first;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_last2last;
-translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_last2last;
-}
-#include "indices/u_indices.c"
diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.c b/src/gallium/auxiliary/indices/u_unfilled_gen.c
deleted file mode 100644
index 93897c98de..0000000000
--- a/src/gallium/auxiliary/indices/u_unfilled_gen.c
+++ /dev/null
@@ -1,992 +0,0 @@
-/* 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) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1);
- (out+j+2)[0] = (ushort)(i+1);
- (out+j+2)[1] = (ushort)(i+2);
- (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++) {
- (out+j)[0] = (ushort)(i);
- (out+j)[1] = (ushort)(i+1/*+(i&1)*/);
- (out+j+2)[0] = (ushort)(i+1/*+(i&1)*/);
- (out+j+2)[1] = (ushort)(i+2/*-(i&1)*/);
- (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++) {
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i+1);
- (out+j+2)[0] = (ushort)(i+1);
- (out+j+2)[1] = (ushort)(i+2);
- (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) {
- (out+j)[0] = (ushort)(i+0);
- (out+j)[1] = (ushort)(i+1);
- (out+j+2)[0] = (ushort)(i+1);
- (out+j+2)[1] = (ushort)(i+2);
- (out+j+4)[0] = (ushort)(i+2);
- (out+j+4)[1] = (ushort)(i+3);
- (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) {
- (out+j)[0] = (ushort)(i+2);
- (out+j)[1] = (ushort)(i+0);
- (out+j+2)[0] = (ushort)(i+0);
- (out+j+2)[1] = (ushort)(i+1);
- (out+j+4)[0] = (ushort)(i+1);
- (out+j+4)[1] = (ushort)(i+3);
- (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++) {
- (out+j)[0] = (ushort)(0);
- (out+j)[1] = (ushort)(i+1);
- (out+j+2)[0] = (ushort)(i+1);
- (out+j+2)[1] = (ushort)(i+2);
- (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) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1);
- (out+j+2)[0] = (uint)(i+1);
- (out+j+2)[1] = (uint)(i+2);
- (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++) {
- (out+j)[0] = (uint)(i);
- (out+j)[1] = (uint)(i+1/*+(i&1)*/);
- (out+j+2)[0] = (uint)(i+1/*+(i&1)*/);
- (out+j+2)[1] = (uint)(i+2/*-(i&1)*/);
- (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++) {
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i+1);
- (out+j+2)[0] = (uint)(i+1);
- (out+j+2)[1] = (uint)(i+2);
- (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) {
- (out+j)[0] = (uint)(i+0);
- (out+j)[1] = (uint)(i+1);
- (out+j+2)[0] = (uint)(i+1);
- (out+j+2)[1] = (uint)(i+2);
- (out+j+4)[0] = (uint)(i+2);
- (out+j+4)[1] = (uint)(i+3);
- (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) {
- (out+j)[0] = (uint)(i+2);
- (out+j)[1] = (uint)(i+0);
- (out+j+2)[0] = (uint)(i+0);
- (out+j+2)[1] = (uint)(i+1);
- (out+j+4)[0] = (uint)(i+1);
- (out+j+4)[1] = (uint)(i+3);
- (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++) {
- (out+j)[0] = (uint)(0);
- (out+j)[1] = (uint)(i+1);
- (out+j+2)[0] = (uint)(i+1);
- (out+j+2)[1] = (uint)(i+2);
- (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) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
- (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
- (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
- (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++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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) {
- (out+j)[0] = (ushort)in[i+0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (out+j+4)[0] = (ushort)in[i+2];
- (out+j+4)[1] = (ushort)in[i+3];
- (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) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[i+0];
- (out+j+2)[0] = (ushort)in[i+0];
- (out+j+2)[1] = (ushort)in[i+1];
- (out+j+4)[0] = (ushort)in[i+1];
- (out+j+4)[1] = (ushort)in[i+3];
- (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++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
- (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
- (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
- (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++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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) {
- (out+j)[0] = (uint)in[i+0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (out+j+4)[0] = (uint)in[i+2];
- (out+j+4)[1] = (uint)in[i+3];
- (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) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[i+0];
- (out+j+2)[0] = (uint)in[i+0];
- (out+j+2)[1] = (uint)in[i+1];
- (out+j+4)[0] = (uint)in[i+1];
- (out+j+4)[1] = (uint)in[i+3];
- (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++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
- (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
- (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
- (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++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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) {
- (out+j)[0] = (ushort)in[i+0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (out+j+4)[0] = (ushort)in[i+2];
- (out+j+4)[1] = (ushort)in[i+3];
- (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) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[i+0];
- (out+j+2)[0] = (ushort)in[i+0];
- (out+j+2)[1] = (ushort)in[i+1];
- (out+j+4)[0] = (ushort)in[i+1];
- (out+j+4)[1] = (ushort)in[i+3];
- (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++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
- (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
- (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
- (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++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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) {
- (out+j)[0] = (uint)in[i+0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (out+j+4)[0] = (uint)in[i+2];
- (out+j+4)[1] = (uint)in[i+3];
- (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) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[i+0];
- (out+j+2)[0] = (uint)in[i+0];
- (out+j+2)[1] = (uint)in[i+1];
- (out+j+4)[0] = (uint)in[i+1];
- (out+j+4)[1] = (uint)in[i+3];
- (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++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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++) {
- (out+j)[0] = (ushort)in[i];
- (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
- (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
- (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
- (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++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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) {
- (out+j)[0] = (ushort)in[i+0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (out+j+4)[0] = (ushort)in[i+2];
- (out+j+4)[1] = (ushort)in[i+3];
- (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) {
- (out+j)[0] = (ushort)in[i+2];
- (out+j)[1] = (ushort)in[i+0];
- (out+j+2)[0] = (ushort)in[i+0];
- (out+j+2)[1] = (ushort)in[i+1];
- (out+j+4)[0] = (ushort)in[i+1];
- (out+j+4)[1] = (ushort)in[i+3];
- (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++) {
- (out+j)[0] = (ushort)in[0];
- (out+j)[1] = (ushort)in[i+1];
- (out+j+2)[0] = (ushort)in[i+1];
- (out+j+2)[1] = (ushort)in[i+2];
- (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) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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++) {
- (out+j)[0] = (uint)in[i];
- (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
- (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
- (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
- (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++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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) {
- (out+j)[0] = (uint)in[i+0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (out+j+4)[0] = (uint)in[i+2];
- (out+j+4)[1] = (uint)in[i+3];
- (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) {
- (out+j)[0] = (uint)in[i+2];
- (out+j)[1] = (uint)in[i+0];
- (out+j+2)[0] = (uint)in[i+0];
- (out+j+2)[1] = (uint)in[i+1];
- (out+j+4)[0] = (uint)in[i+1];
- (out+j+4)[1] = (uint)in[i+3];
- (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++) {
- (out+j)[0] = (uint)in[0];
- (out+j)[1] = (uint)in[i+1];
- (out+j+2)[0] = (uint)in[i+1];
- (out+j+2)[1] = (uint)in[i+2];
- (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/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index c09e8a7a76..0238308d20 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -40,7 +40,7 @@
#include "util/u_debug.h" /* for assert */
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
#include <pthread.h> /* POSIX threads headers */
#include <stdio.h> /* for perror() */
@@ -405,7 +405,7 @@ pipe_semaphore_wait(pipe_semaphore *sema)
*/
typedef struct {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
pthread_key_t key;
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
DWORD key;
@@ -420,7 +420,7 @@ typedef struct {
static INLINE void
pipe_tsd_init(pipe_tsd *tsd)
{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
perror("pthread_key_create(): failed to allocate key for thread specific data");
exit(-1);
@@ -437,7 +437,7 @@ pipe_tsd_get(pipe_tsd *tsd)
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
pipe_tsd_init(tsd);
}
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
return pthread_getspecific(tsd->key);
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
assert(0);
@@ -454,7 +454,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
pipe_tsd_init(tsd);
}
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
if (pthread_setspecific(tsd->key, value) != 0) {
perror("pthread_set_specific() failed");
exit(-1);
diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c
index 6259142bec..84907215fe 100644
--- a/src/gallium/auxiliary/os/os_time.c
+++ b/src/gallium/auxiliary/os/os_time.c
@@ -37,7 +37,7 @@
#if !defined(PIPE_OS_EMBEDDED)
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
# include <sys/time.h> /* timeval */
#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
# include <windows.h>
diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README
index d984067893..c5156438a1 100644
--- a/src/gallium/auxiliary/rbug/README
+++ b/src/gallium/auxiliary/rbug/README
@@ -10,7 +10,7 @@ The code currently uses tcp and ip4v for connections.
Information about driver integration can be found in:
-src/gallium/drivers/trace/README
+src/gallium/drivers/rbug/README
for information about applications look in:
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
index 7595214bdf..9f70b73698 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
@@ -1743,20 +1743,35 @@ void x86_release_func( struct x86_function *p )
}
-void (*x86_get_func( struct x86_function *p ))(void)
+static INLINE x86_func
+voidptr_to_x86_func(void *v)
+{
+ union {
+ void *v;
+ x86_func f;
+ } u;
+ assert(sizeof(u.v) == sizeof(u.f));
+ u.v = v;
+ return u.f;
+}
+
+
+x86_func x86_get_func( struct x86_function *p )
{
DUMP_END();
if (DISASSEM && p->store)
debug_printf("disassemble %p %p\n", p->store, p->csr);
if (p->store == p->error_overflow)
- return (void (*)(void)) NULL;
+ return voidptr_to_x86_func(NULL);
else
- return (void (*)(void)) p->store;
+ return voidptr_to_x86_func(p->store);
}
#else
+void x86sse_dummy( void );
+
void x86sse_dummy( void )
{
}
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
index 319b836ffb..6208e8f707 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
@@ -102,6 +102,11 @@ enum sse_cc {
#define cc_Z cc_E
#define cc_NZ cc_NE
+
+/** generic pointer to function */
+typedef void (*x86_func)(void);
+
+
/* Begin/end/retrieve function creation:
*/
@@ -109,7 +114,7 @@ enum sse_cc {
void x86_init_func( struct x86_function *p );
void x86_init_func_size( struct x86_function *p, unsigned code_size );
void x86_release_func( struct x86_function *p );
-void (*x86_get_func( struct x86_function *p ))( void );
+x86_func x86_get_func( struct x86_function *p );
/* Debugging:
*/
diff --git a/src/gallium/auxiliary/target-helpers/wrap_screen.c b/src/gallium/auxiliary/target-helpers/wrap_screen.c
index eb47512319..df5d56a53c 100644
--- a/src/gallium/auxiliary/target-helpers/wrap_screen.c
+++ b/src/gallium/auxiliary/target-helpers/wrap_screen.c
@@ -33,6 +33,7 @@
#include "target-helpers/wrap_screen.h"
#include "trace/tr_public.h"
+#include "rbug/rbug_public.h"
#include "identity/id_public.h"
#include "util/u_debug.h"
@@ -56,6 +57,9 @@ gallium_wrap_screen( struct pipe_screen *screen )
/* Trace does its own checking if it should run */
screen = trace_screen_create(screen);
+ /* Rbug does its own checking if it should run */
+ screen = rbug_screen_create(screen);
+
return screen;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 1ad183b8dd..35480076ed 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -56,7 +56,7 @@ dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
va_list ap;
(void)ctx;
va_start(ap, format);
- debug_vprintf(format, ap);
+ _debug_vprintf(format, ap);
va_end(ap);
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 9b1ca7fa85..c15d970b57 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -621,12 +621,10 @@ tgsi_exec_machine_bind_shader(
{
uint k;
struct tgsi_parse_context parse;
- struct tgsi_exec_labels *labels = &mach->Labels;
struct tgsi_full_instruction *instructions;
struct tgsi_full_declaration *declarations;
uint maxInstructions = 10, numInstructions = 0;
uint maxDeclarations = 10, numDeclarations = 0;
- uint instno = 0;
#if 0
tgsi_dump(tokens, 0);
@@ -637,6 +635,23 @@ tgsi_exec_machine_bind_shader(
mach->Tokens = tokens;
mach->Samplers = samplers;
+ if (!tokens) {
+ /* unbind and free all */
+ if (mach->Declarations) {
+ FREE( mach->Declarations );
+ }
+ mach->Declarations = NULL;
+ mach->NumDeclarations = 0;
+
+ if (mach->Instructions) {
+ FREE( mach->Instructions );
+ }
+ mach->Instructions = NULL;
+ mach->NumInstructions = 0;
+
+ return;
+ }
+
k = tgsi_parse_init (&parse, mach->Tokens);
if (k != TGSI_PARSE_OK) {
debug_printf( "Problem parsing!\n" );
@@ -645,7 +660,6 @@ tgsi_exec_machine_bind_shader(
mach->Processor = parse.FullHeader.Processor.Processor;
mach->ImmLimit = 0;
- labels->count = 0;
declarations = (struct tgsi_full_declaration *)
MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) );
@@ -663,7 +677,6 @@ tgsi_exec_machine_bind_shader(
}
while( !tgsi_parse_end_of_tokens( &parse ) ) {
- uint pointer = parse.Position;
uint i;
tgsi_parse_token( &parse );
@@ -707,11 +720,6 @@ tgsi_exec_machine_bind_shader(
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
- assert( labels->count < MAX_LABELS );
-
- labels->labels[labels->count][0] = instno;
- labels->labels[labels->count][1] = pointer;
- labels->count++;
/* save expanded instruction */
if (numInstructions == maxInstructions) {
@@ -801,7 +809,9 @@ void
tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach)
{
if (mach) {
- FREE(mach->Instructions);
+ if (mach->Instructions)
+ FREE(mach->Instructions);
+ if (mach->Declarations)
FREE(mach->Declarations);
}
@@ -3126,7 +3136,7 @@ exec_instruction(
break;
case TGSI_OPCODE_DIV:
- assert( 0 );
+ exec_vector_binary(mach, inst, micro_div, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT);
break;
case TGSI_OPCODE_DP2:
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index 11bbaf6722..3caf820af6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -37,8 +37,6 @@ extern "C" {
#endif
-#define MAX_LABELS (4 * 1024) /**< basically, max instructions */
-
#define NUM_CHANNELS 4 /* R,G,B,A */
#define QUAD_SIZE 4 /* 4 pixel/quad */
@@ -93,16 +91,6 @@ struct tgsi_sampler
float rgba[NUM_CHANNELS][QUAD_SIZE]);
};
-/**
- * For branching/calling subroutines.
- */
-struct tgsi_exec_labels
-{
- unsigned labels[MAX_LABELS][2];
- unsigned count;
-};
-
-
#define TGSI_EXEC_NUM_TEMPS 128
#define TGSI_EXEC_NUM_IMMEDIATES 256
@@ -186,10 +174,11 @@ struct tgsi_exec_labels
-#define TGSI_EXEC_MAX_COND_NESTING 32
-#define TGSI_EXEC_MAX_LOOP_NESTING 32
-#define TGSI_EXEC_MAX_SWITCH_NESTING 32
-#define TGSI_EXEC_MAX_CALL_NESTING 32
+#define TGSI_EXEC_MAX_NESTING 32
+#define TGSI_EXEC_MAX_COND_NESTING TGSI_EXEC_MAX_NESTING
+#define TGSI_EXEC_MAX_LOOP_NESTING TGSI_EXEC_MAX_NESTING
+#define TGSI_EXEC_MAX_SWITCH_NESTING TGSI_EXEC_MAX_NESTING
+#define TGSI_EXEC_MAX_CALL_NESTING TGSI_EXEC_MAX_NESTING
/* The maximum number of input attributes per vertex. For 2D
* input register files, this is the stride between two 1D
@@ -324,7 +313,6 @@ struct tgsi_exec_machine
struct tgsi_full_declaration *Declarations;
uint NumDeclarations;
- struct tgsi_exec_labels Labels;
};
struct tgsi_exec_machine *
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index cfa2f631bd..e59e964ffa 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -205,3 +205,18 @@ tgsi_get_opcode_name( uint opcode )
return info->mnemonic;
}
+
+const char *
+tgsi_get_processor_name( uint processor )
+{
+ switch (processor) {
+ case TGSI_PROCESSOR_VERTEX:
+ return "vertex shader";
+ case TGSI_PROCESSOR_FRAGMENT:
+ return "fragment shader";
+ case TGSI_PROCESSOR_GEOMETRY:
+ return "geometry shader";
+ default:
+ return "unknown shader type!";
+ }
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h
index 74713c3b98..50248884fd 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.h
@@ -52,6 +52,9 @@ tgsi_get_opcode_info( uint opcode );
const char *
tgsi_get_opcode_name( uint opcode );
+const char *
+tgsi_get_processor_name( uint processor );
+
#if defined __cplusplus
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
index ad553c71a5..3521847b61 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -1366,4 +1366,12 @@ tgsi_emit_ppc(const struct tgsi_token *tokens,
return ok;
}
+#else
+
+void ppc_dummy_func(void);
+
+void ppc_dummy_func(void)
+{
+}
+
#endif /* PIPE_ARCH_PPC */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 232fc537c1..e0c5d3d3d6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -88,10 +88,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST);
info->opcode_count[fullinst->Instruction.Opcode]++;
- /* special case: scan fragment shaders for use of the fog
- * input/attribute. The X component is fog, the Y component
- * is the front/back-face flag.
- */
+ /* check if we read the frag shader FOG or FACE inputs */
if (procType == TGSI_PROCESSOR_FRAGMENT) {
uint i;
for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
@@ -109,6 +106,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
}
}
}
+
+ info->num_instructions++;
}
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 741aa7d5c4..27de33f799 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -54,6 +54,7 @@ struct tgsi_shader_info
int file_max[TGSI_FILE_COUNT]; /**< highest index of declared registers */
uint immediate_count; /**< number of immediates declared */
+ uint num_instructions;
uint opcode_count[TGSI_OPCODE_LAST]; /**< opcode histogram */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 1071298b49..d5061f8b51 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -1929,20 +1929,32 @@ emit_instruction(
break;
case TGSI_OPCODE_MUL:
+ /* do all fetches and adds, storing results in temp regs */
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_mul( func, 0, 1 );
- STORE( func, *inst, 0, 0, chan_index );
+ int r = chan_index + 1;
+ FETCH( func, *inst, 0, 0, chan_index ); /* load xmm[0] */
+ FETCH( func, *inst, r, 1, chan_index ); /* load xmm[r] */
+ emit_mul( func, r, 0 ); /* xmm[r] = xmm[r] * xmm[0] */
+ }
+ /* do all stores of the temp regs */
+ FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
+ int r = chan_index + 1;
+ STORE( func, *inst, r, 0, chan_index ); /* store xmm[r] */
}
break;
case TGSI_OPCODE_ADD:
+ /* do all fetches and adds, storing results in temp regs */
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_add( func, 0, 1 );
- STORE( func, *inst, 0, 0, chan_index );
+ int r = chan_index + 1;
+ FETCH( func, *inst, 0, 0, chan_index ); /* load xmm[0] */
+ FETCH( func, *inst, r, 1, chan_index ); /* load xmm[r] */
+ emit_add( func, r, 0 ); /* xmm[r] = xmm[r] + xmm[0] */
+ }
+ /* do all stores of the temp regs */
+ FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
+ int r = chan_index + 1;
+ STORE( func, *inst, r, 0, chan_index ); /* store xmm[r] */
}
break;
@@ -2816,6 +2828,40 @@ static void soa_to_aos( struct x86_function *func,
x86_pop( func, x86_make_reg( file_REG32, reg_BX ) );
}
+
+/**
+ * Check if the instructions dst register is the same as any src
+ * register and warn if there's a posible SOA dependency.
+ */
+static void
+check_soa_dependencies(const struct tgsi_full_instruction *inst)
+{
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_ADD:
+ case TGSI_OPCODE_MOV:
+ case TGSI_OPCODE_MUL:
+ case TGSI_OPCODE_XPD:
+ /* OK - these opcodes correctly handle SOA dependencies */
+ break;
+ default:
+ if (tgsi_check_soa_dependencies(inst)) {
+ uint opcode = inst->Instruction.Opcode;
+
+ /* XXX: we only handle src/dst aliasing in a few opcodes
+ * currently. Need to use an additional temporay to hold
+ * the result in the cases where the code is too opaque to
+ * fix.
+ */
+ if (opcode != TGSI_OPCODE_MOV) {
+ debug_printf("Warning: src/dst aliasing in instruction"
+ " is not handled:\n");
+ tgsi_dump_instruction(inst, 1);
+ }
+ }
+ }
+}
+
+
/**
* Translate a TGSI vertex/fragment shader to SSE2 code.
* Slightly different things are done for vertex vs. fragment shaders.
@@ -2905,27 +2951,14 @@ tgsi_emit_sse2(
if (!ok) {
uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
+ uint proc = parse.FullHeader.Processor.Processor;
debug_printf("failed to translate tgsi opcode %d (%s) to SSE (%s)\n",
opcode,
tgsi_get_opcode_name(opcode),
- parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_VERTEX ?
- "vertex shader" : "fragment shader");
+ tgsi_get_processor_name(proc));
}
- if (tgsi_check_soa_dependencies(&parse.FullToken.FullInstruction)) {
- uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
-
- /* XXX: we only handle src/dst aliasing in a few opcodes
- * currently. Need to use an additional temporay to hold
- * the result in the cases where the code is too opaque to
- * fix.
- */
- if (opcode != TGSI_OPCODE_MOV) {
- debug_printf("Warning: src/dst aliasing in instruction"
- " is not handled:\n");
- tgsi_dump_instruction(&parse.FullToken.FullInstruction, 1);
- }
- }
+ check_soa_dependencies(&parse.FullToken.FullInstruction);
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 49b854b123..5fda808dbe 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1467,6 +1467,12 @@ const struct tgsi_token *ureg_get_tokens( struct ureg_program *ureg,
}
+void ureg_free_tokens( const struct tgsi_token *tokens )
+{
+ FREE((struct tgsi_token *)tokens);
+}
+
+
struct ureg_program *ureg_create( unsigned processor )
{
struct ureg_program *ureg = CALLOC_STRUCT( ureg_program );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index f32420dd87..055545f3d2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -104,6 +104,10 @@ ureg_get_tokens( struct ureg_program *ureg,
unsigned *nr_tokens );
+/* Free the tokens created by ureg_get_tokens() */
+void ureg_free_tokens( const struct tgsi_token *tokens );
+
+
void
ureg_destroy( struct ureg_program * );
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 9df5f9a9d2..d4fbd658f4 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -48,7 +48,6 @@
#include "util/u_sampler.h"
#include "util/u_simple_shaders.h"
#include "util/u_surface.h"
-#include "util/u_rect.h"
#include "cso_cache/cso_context.h"
@@ -102,8 +101,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
/* rasterizer */
memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
- ctx->rasterizer.front_winding = PIPE_WINDING_CW;
- ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
+ ctx->rasterizer.cull_face = PIPE_FACE_NONE;
ctx->rasterizer.gl_rasterization_rules = 1;
/* samplers */
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index d603c7ac06..e0bd89154c 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -44,7 +44,6 @@
#include "util/u_blitter.h"
#include "util/u_draw_quad.h"
#include "util/u_pack_color.h"
-#include "util/u_rect.h"
#include "util/u_sampler.h"
#include "util/u_simple_shaders.h"
#include "util/u_surface.h"
@@ -70,8 +69,8 @@ struct blitter_context_priv
void *vs_tex; /**< Vertex shader which passes {pos, texcoord} to the output.*/
/* Fragment shaders. */
- /* FS which outputs a color to multiple color buffers. */
- void *fs_col[PIPE_MAX_COLOR_BUFS];
+ /* The shader at index i outputs color to color buffers 0,1,...,i-1. */
+ void *fs_col[PIPE_MAX_COLOR_BUFS+1];
/* FS which outputs a color from a texture,
where the index is PIPE_TEXTURE_* to be sampled. */
@@ -176,8 +175,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
/* rasterizer state */
memset(&rs_state, 0, sizeof(rs_state));
- rs_state.front_winding = PIPE_WINDING_CW;
- rs_state.cull_mode = PIPE_WINDING_NONE;
+ rs_state.cull_face = PIPE_FACE_NONE;
rs_state.gl_rasterization_rules = 1;
rs_state.flatshade = 1;
ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
@@ -249,7 +247,7 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
}
- for (i = 0; i < PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++)
+ for (i = 0; i <= PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++)
if (ctx->fs_col[i])
pipe->delete_fs_state(pipe, ctx->fs_col[i]);
@@ -496,15 +494,14 @@ static INLINE
void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
{
struct pipe_context *pipe = ctx->pipe;
- unsigned index = num_cbufs ? num_cbufs - 1 : 0;
assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
- if (!ctx->fs_col[index])
- ctx->fs_col[index] =
+ if (!ctx->fs_col[num_cbufs])
+ ctx->fs_col[num_cbufs] =
util_make_fragment_clonecolor_shader(pipe, num_cbufs);
- return ctx->fs_col[index];
+ return ctx->fs_col[num_cbufs];
}
static INLINE
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 0de38e791d..86db2c2e4b 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -123,8 +123,12 @@ debug_get_bool_option(const char *name, boolean dfault)
result = FALSE;
else if(!util_strcmp(str, "f"))
result = FALSE;
+ else if(!util_strcmp(str, "F"))
+ result = FALSE;
else if(!util_strcmp(str, "false"))
result = FALSE;
+ else if(!util_strcmp(str, "FALSE"))
+ result = FALSE;
else
result = TRUE;
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c
index 417d0cf04c..6e250575d6 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -67,21 +67,6 @@ BOOL WINAPI j_SymInitialize(HANDLE hProcess, PSTR UserSearchPath, BOOL fInvadePr
return FALSE;
}
-typedef BOOL (WINAPI *PFNSYMCLEANUP)(HANDLE);
-static PFNSYMCLEANUP pfnSymCleanup = NULL;
-
-static
-BOOL WINAPI j_SymCleanup(HANDLE hProcess)
-{
- if(
- (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) &&
- (pfnSymCleanup || (pfnSymCleanup = (PFNSYMCLEANUP) GetProcAddress(hModule_Imagehlp, "SymCleanup")))
- )
- return pfnSymCleanup(hProcess);
- else
- return FALSE;
-}
-
typedef DWORD (WINAPI *PFNSYMSETOPTIONS)(DWORD);
static PFNSYMSETOPTIONS pfnSymSetOptions = NULL;
@@ -97,36 +82,6 @@ DWORD WINAPI j_SymSetOptions(DWORD SymOptions)
return FALSE;
}
-typedef BOOL (WINAPI *PFNSYMUNDNAME)(PIMAGEHLP_SYMBOL, PSTR, DWORD);
-static PFNSYMUNDNAME pfnSymUnDName = NULL;
-
-static
-BOOL WINAPI j_SymUnDName(PIMAGEHLP_SYMBOL Symbol, PSTR UnDecName, DWORD UnDecNameLength)
-{
- if(
- (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) &&
- (pfnSymUnDName || (pfnSymUnDName = (PFNSYMUNDNAME) GetProcAddress(hModule_Imagehlp, "SymUnDName")))
- )
- return pfnSymUnDName(Symbol, UnDecName, UnDecNameLength);
- else
- return FALSE;
-}
-
-typedef PFUNCTION_TABLE_ACCESS_ROUTINE PFNSYMFUNCTIONTABLEACCESS;
-static PFNSYMFUNCTIONTABLEACCESS pfnSymFunctionTableAccess = NULL;
-
-static
-PVOID WINAPI j_SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase)
-{
- if(
- (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) &&
- (pfnSymFunctionTableAccess || (pfnSymFunctionTableAccess = (PFNSYMFUNCTIONTABLEACCESS) GetProcAddress(hModule_Imagehlp, "SymFunctionTableAccess")))
- )
- return pfnSymFunctionTableAccess(hProcess, AddrBase);
- else
- return NULL;
-}
-
typedef PGET_MODULE_BASE_ROUTINE PFNSYMGETMODULEBASE;
static PFNSYMGETMODULEBASE pfnSymGetModuleBase = NULL;
@@ -142,41 +97,6 @@ DWORD WINAPI j_SymGetModuleBase(HANDLE hProcess, DWORD dwAddr)
return 0;
}
-typedef BOOL (WINAPI *PFNSTACKWALK)(DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID, PREAD_PROCESS_MEMORY_ROUTINE, PFUNCTION_TABLE_ACCESS_ROUTINE, PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE);
-static PFNSTACKWALK pfnStackWalk = NULL;
-
-static
-BOOL WINAPI j_StackWalk(
- DWORD MachineType,
- HANDLE hProcess,
- HANDLE hThread,
- LPSTACKFRAME StackFrame,
- PVOID ContextRecord,
- PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
- PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
- PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
- PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
-)
-{
- if(
- (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) &&
- (pfnStackWalk || (pfnStackWalk = (PFNSTACKWALK) GetProcAddress(hModule_Imagehlp, "StackWalk")))
- )
- return pfnStackWalk(
- MachineType,
- hProcess,
- hThread,
- StackFrame,
- ContextRecord,
- ReadMemoryRoutine,
- FunctionTableAccessRoutine,
- GetModuleBaseRoutine,
- TranslateAddress
- );
- else
- return FALSE;
-}
-
typedef BOOL (WINAPI *PFNSYMGETSYMFROMADDR)(HANDLE, DWORD, LPDWORD, PIMAGEHLP_SYMBOL);
static PFNSYMGETSYMFROMADDR pfnSymGetSymFromAddr = NULL;
@@ -192,21 +112,6 @@ BOOL WINAPI j_SymGetSymFromAddr(HANDLE hProcess, DWORD Address, PDWORD Displacem
return FALSE;
}
-typedef BOOL (WINAPI *PFNSYMGETLINEFROMADDR)(HANDLE, DWORD, LPDWORD, PIMAGEHLP_LINE);
-static PFNSYMGETLINEFROMADDR pfnSymGetLineFromAddr = NULL;
-
-static
-BOOL WINAPI j_SymGetLineFromAddr(HANDLE hProcess, DWORD dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE Line)
-{
- if(
- (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) &&
- (pfnSymGetLineFromAddr || (pfnSymGetLineFromAddr = (PFNSYMGETLINEFROMADDR) GetProcAddress(hModule_Imagehlp, "SymGetLineFromAddr")))
- )
- return pfnSymGetLineFromAddr(hProcess, dwAddr, pdwDisplacement, Line);
- else
- return FALSE;
-}
-
static INLINE boolean
debug_symbol_print_imagehlp(const void *addr)
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index bdc73ac47d..49536c0d59 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -71,9 +71,15 @@ const char *
util_dump_blend_func(unsigned value, boolean shortened);
const char *
+util_dump_logicop(unsigned value, boolean shortened);
+
+const char *
util_dump_func(unsigned value, boolean shortened);
const char *
+util_dump_stencil_op(unsigned value, boolean shortened);
+
+const char *
util_dump_tex_target(unsigned value, boolean shortened);
const char *
diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c
index 96a2256347..692d4447c6 100644
--- a/src/gallium/auxiliary/util/u_dump_defines.c
+++ b/src/gallium/auxiliary/util/u_dump_defines.c
@@ -160,6 +160,49 @@ DEFINE_UTIL_DUMP_CONTINUOUS(blend_func)
static const char *
+util_dump_logicop_names[] = {
+ "PIPE_LOGICOP_CLEAR",
+ "PIPE_LOGICOP_NOR",
+ "PIPE_LOGICOP_AND_INVERTED",
+ "PIPE_LOGICOP_COPY_INVERTED",
+ "PIPE_LOGICOP_AND_REVERSE",
+ "PIPE_LOGICOP_INVERT",
+ "PIPE_LOGICOP_XOR",
+ "PIPE_LOGICOP_NAND",
+ "PIPE_LOGICOP_AND",
+ "PIPE_LOGICOP_EQUIV",
+ "PIPE_LOGICOP_NOOP",
+ "PIPE_LOGICOP_OR_INVERTED",
+ "PIPE_LOGICOP_COPY",
+ "PIPE_LOGICOP_OR_REVERSE",
+ "PIPE_LOGICOP_OR",
+ "PIPE_LOGICOP_SET"
+};
+
+static const char *
+util_dump_logicop_short_names[] = {
+ "clear",
+ "nor",
+ "and_inverted",
+ "copy_inverted",
+ "and_reverse",
+ "invert",
+ "xor",
+ "nand",
+ "and",
+ "equiv",
+ "noop",
+ "or_inverted",
+ "copy",
+ "or_reverse",
+ "or",
+ "set"
+};
+
+DEFINE_UTIL_DUMP_CONTINUOUS(logicop)
+
+
+static const char *
util_dump_func_names[] = {
"PIPE_FUNC_NEVER",
"PIPE_FUNC_LESS",
@@ -187,7 +230,35 @@ DEFINE_UTIL_DUMP_CONTINUOUS(func)
static const char *
+util_dump_stencil_op_names[] = {
+ "PIPE_STENCIL_OP_KEEP",
+ "PIPE_STENCIL_OP_ZERO",
+ "PIPE_STENCIL_OP_REPLACE",
+ "PIPE_STENCIL_OP_INCR",
+ "PIPE_STENCIL_OP_DECR",
+ "PIPE_STENCIL_OP_INCR_WRAP",
+ "PIPE_STENCIL_OP_DECR_WRAP",
+ "PIPE_STENCIL_OP_INVERT"
+};
+
+static const char *
+util_dump_stencil_op_short_names[] = {
+ "keep",
+ "zero",
+ "replace",
+ "incr",
+ "decr",
+ "incr_wrap",
+ "decr_wrap",
+ "invert"
+};
+
+DEFINE_UTIL_DUMP_CONTINUOUS(stencil_op)
+
+
+static const char *
util_dump_tex_target_names[] = {
+ "PIPE_BUFFER",
"PIPE_TEXTURE_1D",
"PIPE_TEXTURE_2D",
"PIPE_TEXTURE_3D",
@@ -196,6 +267,7 @@ util_dump_tex_target_names[] = {
static const char *
util_dump_tex_target_short_names[] = {
+ "buffer",
"1d",
"2d",
"3d",
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 2ce643e90c..cda5b8ba51 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -300,12 +300,13 @@ util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterize
util_dump_member(stream, bool, state, flatshade);
util_dump_member(stream, bool, state, light_twoside);
- util_dump_member(stream, uint, state, front_winding);
- util_dump_member(stream, uint, state, cull_mode);
- util_dump_member(stream, uint, state, fill_cw);
- util_dump_member(stream, uint, state, fill_ccw);
- util_dump_member(stream, bool, state, offset_cw);
- util_dump_member(stream, bool, state, offset_ccw);
+ util_dump_member(stream, uint, state, front_ccw);
+ util_dump_member(stream, uint, state, cull_face);
+ util_dump_member(stream, uint, state, fill_front);
+ util_dump_member(stream, uint, state, fill_back);
+ util_dump_member(stream, bool, state, offset_point);
+ util_dump_member(stream, bool, state, offset_line);
+ util_dump_member(stream, bool, state, offset_tri);
util_dump_member(stream, bool, state, scissor);
util_dump_member(stream, bool, state, poly_smooth);
util_dump_member(stream, bool, state, poly_stipple_enable);
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 8ba076949b..fd95bea1a7 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -367,6 +367,26 @@ util_format_is_plain(enum pipe_format format)
}
static INLINE boolean
+util_format_is_compressed(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(desc);
+ if (!desc) {
+ return FALSE;
+ }
+
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_S3TC:
+ case UTIL_FORMAT_LAYOUT_RGTC:
+ /* XXX add other formats in the future */
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+static INLINE boolean
util_format_is_s3tc(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index 0c1bbc84c1..6d0016c0ad 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -37,9 +37,6 @@
'''
-import sys
-import math
-
from u_format_parse import *
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py
index 7076c676aa..ddb9f2443d 100755
--- a/src/gallium/auxiliary/util/u_format_parse.py
+++ b/src/gallium/auxiliary/util/u_format_parse.py
@@ -43,7 +43,7 @@ ZS = 'zs'
def is_pot(x):
- return (x & (x - 1)) == 0;
+ return (x & (x - 1)) == 0
VERY_LARGE = 99999999999999999999999
diff --git a/src/gallium/auxiliary/util/u_format_srgb.py b/src/gallium/auxiliary/util/u_format_srgb.py
index a4c76dc00b..3e8000f368 100644
--- a/src/gallium/auxiliary/util/u_format_srgb.py
+++ b/src/gallium/auxiliary/util/u_format_srgb.py
@@ -39,7 +39,6 @@
'''
-import sys
import math
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 48ee042726..d19267be72 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1295,8 +1295,7 @@ util_create_gen_mipmap(struct pipe_context *pipe,
/* rasterizer */
memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
- ctx->rasterizer.front_winding = PIPE_WINDING_CW;
- ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
+ ctx->rasterizer.cull_face = PIPE_FACE_NONE;
ctx->rasterizer.gl_rasterization_rules = 1;
/* sampler state */
diff --git a/src/gallium/auxiliary/util/u_half.py b/src/gallium/auxiliary/util/u_half.py
index 8007482e97..915cf3b927 100644
--- a/src/gallium/auxiliary/util/u_half.py
+++ b/src/gallium/auxiliary/util/u_half.py
@@ -83,11 +83,11 @@ for i in xrange(1, 1024):
# normalize number
while (m & 0x00800000) == 0:
- e -= 0x00800000;
- m <<= 1;
+ e -= 0x00800000
+ m <<= 1
- m &= ~0x00800000;
- e += 0x38800000;
+ m &= ~0x00800000
+ e += 0x38800000
value(m | e)
# normals
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index a48689ee8b..540305c146 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -369,6 +369,24 @@ pipe_transfer_destroy( struct pipe_context *context,
}
+static INLINE boolean util_get_offset(
+ const struct pipe_rasterizer_state *templ,
+ unsigned fill_mode)
+{
+ switch(fill_mode) {
+ case PIPE_POLYGON_MODE_POINT:
+ return templ->offset_point;
+ case PIPE_POLYGON_MODE_LINE:
+ return templ->offset_line;
+ case PIPE_POLYGON_MODE_FILL:
+ return templ->offset_tri;
+ default:
+ assert(0);
+ return FALSE;
+ }
+}
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 6f49a72355..9adf22c471 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -38,7 +38,6 @@
#include "util/u_format.h"
#include "util/u_inlines.h"
-#include "util/u_memory.h"
#include "util/u_rect.h"
#include "util/u_surface.h"
diff --git a/src/gallium/auxiliary/util/u_surfaces.c b/src/gallium/auxiliary/util/u_surfaces.c
index 668da8c5c2..b5d21570d5 100644
--- a/src/gallium/auxiliary/util/u_surfaces.c
+++ b/src/gallium/auxiliary/util/u_surfaces.c
@@ -28,7 +28,7 @@ util_surfaces_do_get(struct util_surfaces *us, unsigned surface_struct_size, str
{ /* or 2D array */
if(!us->u.table)
us->u.table = util_hash_table_create(hash, compare);
- key = (void *)(((zslice + face) << 8) | level);
+ key = (void *)(uintptr_t)(((zslice + face) << 8) | level);
/* TODO: ouch, should have a get-reference function...
* also, shouldn't allocate a two-pointer structure for each item... */
ps = util_hash_table_get(us->u.table, key);
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index bedace3b1d..69f6fab950 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -35,12 +35,12 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
util_copy_rect(map,
resource->format,
- transfer->stride, /* bytes? */
+ transfer->stride, /* bytes */
0, 0,
box->width,
box->height,
data,
- box->width, /* bytes? texels? */
+ stride, /* bytes */
0, 0);
out: