summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw/draw_pt_elts.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-03-23 16:44:59 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2008-03-23 17:36:49 +0000
commitf40357e25c0520ef1d64ffab03501da4c8b93529 (patch)
tree4fbb13daaa1b63b97ce81b59d5e879e2feae03fb /src/gallium/auxiliary/draw/draw_pt_elts.c
parenta35c1ca3ad4361fee30d21ef13d8d37ae91aee66 (diff)
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize. Initially just implementing a passthrough mode, this will fairly soon replace all the vertex_cache/prim_queue/shader_queue stuff that's so hard to understand... Split the vertex processing into a couple of distinct stages: - Frontend - Prepares two lists of elements (fetch and draw) to be processed by the next stage. This stage doesn't fetch or draw vertices, but makes the decision which to draw. Multiple implementations of this will implement different strategies, currently just a vcache implementation. - MiddleEnd - Takes the list of fetch elements, fetches them, runs the vertex shader, cliptest, viewport transform on them to produce a linear array of vertex_header vertices. - Passes that list of vertices, plus the draw_elements (which index into that list) onto the backend - Backend - Either the existing primitive/clipping pipeline, or the vbuf_render hardware backend provided by the driver. Currently, the middle-end is the old passthrough code, and it build hardware vertices, not vertex_header vertices as above. It may be that passthrough is a special case in this respect.
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pt_elts.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_elts.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt_elts.c b/src/gallium/auxiliary/draw/draw_pt_elts.c
new file mode 100644
index 0000000000..585b83fa90
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_pt_elts.c
@@ -0,0 +1,88 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "draw/draw_pt.h"
+#include "draw/draw_private.h"
+
+/* Neat get_elt func that also works for varrays drawing by encoding
+ * the start value into a pointer.
+ */
+
+static ushort elt_uint( const void *elts, ushort idx )
+{
+ return *(((const uint *)elts) + idx);
+}
+
+static ushort elt_ushort( const void *elts, ushort idx )
+{
+ return *(((const ushort *)elts) + idx);
+}
+
+static ushort elt_ubyte( const void *elts, ushort idx )
+{
+ return *(((const ubyte *)elts) + idx);
+}
+
+static ushort elt_vert( const void *elts, ushort idx )
+{
+ return (const ubyte *)elts - (const ubyte *)NULL + idx;
+}
+
+pt_elt_func draw_pt_elt_func( struct draw_context *draw )
+{
+ switch (draw->user.eltSize) {
+ case 0: return elt_vert;
+ case 1: return elt_ubyte;
+ case 2: return elt_ushort;
+ case 4: return elt_uint;
+ default: return NULL;
+ }
+}
+
+const void *draw_pt_elt_ptr( struct draw_context *draw,
+ unsigned start )
+{
+ const char *elts = draw->user.elts;
+
+ switch (draw->user.eltSize) {
+ case 0:
+ return (const void *)(((const ubyte *)NULL) + start);
+ case 1:
+ return (const void *)(((const ubyte *)elts) + start);
+ case 2:
+ return (const void *)(((const ushort *)elts) + start);
+ case 4:
+ return (const void *)(((const uint *)elts) + start);
+ default:
+ return NULL;
+ }
+}