summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/glamo/glamo_render.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/glamo/glamo_render.c')
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_render.c189
1 files changed, 189 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c
new file mode 100644
index 0000000000..3e7aec2dc5
--- /dev/null
+++ b/src/mesa/drivers/dri/glamo/glamo_render.c
@@ -0,0 +1,189 @@
+/*
+ * Direct Rendering Support for SMedia Glamo 336x/337x
+ *
+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS 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.
+ *
+ *
+ * Based on intel_render.c, to which the following notice applies:
+ *
+ * Copyright 2003 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.
+ *
+ */
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware acceleration where possible.
+ *
+ */
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/enums.h"
+
+#include "tnl/t_context.h"
+#include "tnl/t_vertex.h"
+#include "tnl/t_pipeline.h"
+
+#include "glamo_context.h"
+#include "glamo_tris.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * VRAM buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 0
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0 /* Has it, template can't use it yet */
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+#define HAVE_ELTS 0
+
+
+static inline GLuint glamoGetVBMax(struct glamo_context *glamo)
+{
+ return GLAMO_VB_SIZE / (4 * 4);
+}
+
+static inline GLuint glamoGetCurrentMax(struct glamo_context *glamo)
+{
+ /* How many more vertices can be accommodated?
+ * Each vertex takes up 4x 32-bit fixed point values */
+ return (GLAMO_VB_SIZE - glamo->prim.current_offset) / (4 * 4);
+}
+
+#define LOCAL_VARS \
+ struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
+
+#define INIT(prim)
+
+#define FLUSH() \
+ do { \
+ if ((gCtx)->prim.flush) \
+ (gCtx)->prim.flush(gCtx); \
+ } while (0)
+
+#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx)
+#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx)
+
+#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr)
+
+#define EMIT_VERTS(ctx, j, nr, buf) \
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
+
+#define TAG(x) glamo_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean glamoRunRender(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ /* Don't handle clipping */
+ if ( !glamo_validate_render(ctx, VB) ) {
+ return GL_TRUE; /* Failed */
+ }
+
+ tnl->clipspace.new_inputs |= VERT_BIT_POS;
+
+ tnl->Driver.Render.Start(ctx);
+
+ for ( i=0; i<VB->PrimitiveCount; i++ ) {
+ GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length) continue;
+
+ glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start,
+ start + length, prim);
+ }
+
+ tnl->Driver.Render.Finish(ctx);
+
+ if ((gCtx)->prim.flush)
+ (gCtx)->prim.flush(gCtx);
+
+ return GL_FALSE; /* Ok */
+}
+
+
+static const struct tnl_pipeline_stage _glamo_render_stage = {
+ "glamo render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ glamoRunRender
+};
+
+
+const struct tnl_pipeline_stage *glamo_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_vertex_cull_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+ &_tnl_vertex_program_stage,
+ &_glamo_render_stage, /* ADD: unclipped rastersetup-to-dma */
+ &_tnl_render_stage,
+ 0,
+};