summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nv10_swtcl.c')
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_swtcl.c150
1 files changed, 85 insertions, 65 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
index 37d9f001d1..32da40661b 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
@@ -23,7 +23,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-/* Software TCL for NV10, NV20, NV30, NV40, G70 */
+/* Software TCL for NV10, NV20, NV30, NV40, NV50 */
#include <stdio.h>
#include <math.h>
@@ -56,9 +56,6 @@ static void nv10ResetLineStipple( GLcontext *ctx );
-/* the size above which we fire the ring. this is a performance-tunable */
-#define NOUVEAU_FIRE_SIZE (2048/4)
-
static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size)
{
if (nmesa->screen->card->type==NV_10)
@@ -99,52 +96,6 @@ static inline void nv10ExtendPrimitive(struct nouveau_context* nmesa, int size)
}
}
-static inline void nv10_draw_quad(nouveauContextPtr nmesa,
- nouveauVertexPtr v0,
- nouveauVertexPtr v1,
- nouveauVertexPtr v2,
- nouveauVertexPtr v3)
-{
- GLuint vertsize = nmesa->vertex_size;
- nv10ExtendPrimitive(nmesa, 4 * 4 * vertsize);
-
- OUT_RINGp(v0,vertsize);
- OUT_RINGp(v1,vertsize);
- OUT_RINGp(v2,vertsize);
- OUT_RINGp(v3,vertsize);
-}
-
-static inline void nv10_draw_triangle(nouveauContextPtr nmesa,
- nouveauVertexPtr v0,
- nouveauVertexPtr v1,
- nouveauVertexPtr v2)
-{
- GLuint vertsize = nmesa->vertex_size;
- nv10ExtendPrimitive(nmesa, 3 * 4 * vertsize);
-
- OUT_RINGp(v0,vertsize);
- OUT_RINGp(v1,vertsize);
- OUT_RINGp(v2,vertsize);
-}
-
-static inline void nv10_draw_line(nouveauContextPtr nmesa,
- nouveauVertexPtr v0,
- nouveauVertexPtr v1)
-{
- GLuint vertsize = nmesa->vertex_size;
- nv10ExtendPrimitive(nmesa, 2 * 4 * vertsize);
- OUT_RINGp(v0,vertsize);
- OUT_RINGp(v1,vertsize);
-}
-
-static inline void nv10_draw_point(nouveauContextPtr nmesa,
- nouveauVertexPtr v0)
-{
- GLuint vertsize = nmesa->vertex_size;
- nv10ExtendPrimitive(nmesa, 1 * 4 * vertsize);
- OUT_RINGp(v0,vertsize);
-}
-
/**********************************************************************/
/* Render unclipped begin/end objects */
/**********************************************************************/
@@ -247,7 +198,7 @@ static inline void nv10_render_generic_primitive_elts(GLcontext *ctx,GLuint star
nv10ExtendPrimitive(nmesa, size_dword);
nv10StartPrimitive(nmesa,prim+1,size_dword);
for (j=start; j<count; j++ ) {
- OUT_RINGp((nouveauVertex*)(vertptr+(elt[j]*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(elt[j]*vertsize)),vertsize/4);
}
nv10FinishPrimitive(nmesa);
}
@@ -337,20 +288,86 @@ do { \
nmesa->vertex_attr_count++; \
} while (0)
+static void nv10_render_clipped_line(GLcontext *ctx,GLuint ii,GLuint jj)
+{
-static void nv10ChooseRenderState(GLcontext *ctx)
+}
+
+static void nv10_render_clipped_poly(GLcontext *ctx,const GLuint *elts,GLuint n)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ nv10_render_generic_primitive_elts( ctx, 0, n, PRIM_BEGIN|PRIM_END,GL_POLYGON );
+ VB->Elts = tmp;
+}
+
+static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last)
+{
+ WARN_ONCE("Unimplemented\n");
+}
+
+static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2)
+{
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+ GLubyte *vertptr = (GLubyte *)nmesa->verts;
+ GLuint vertsize = nmesa->vertex_size;
+ GLuint size_dword = vertsize*(2)/4;
- nmesa->draw_point = nv10_draw_point;
- nmesa->draw_line = nv10_draw_line;
- nmesa->draw_tri = nv10_draw_triangle;
+ nv10ExtendPrimitive(nmesa, size_dword);
+ nv10StartPrimitive(nmesa,GL_LINES+1,size_dword);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v1*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v2*vertsize)),vertsize);
+ nv10FinishPrimitive(nmesa);
+}
+
+static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3)
+{
+ struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+ GLubyte *vertptr = (GLubyte *)nmesa->verts;
+ GLuint vertsize = nmesa->vertex_size;
+ GLuint size_dword = vertsize*(3)/4;
+
+ nv10ExtendPrimitive(nmesa, size_dword);
+ nv10StartPrimitive(nmesa,GL_TRIANGLES+1,size_dword);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v1*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v2*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v3*vertsize)),vertsize);
+ nv10FinishPrimitive(nmesa);
+}
+
+static inline void nv10_render_quad(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3,GLuint v4)
+{
+ struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+ GLubyte *vertptr = (GLubyte *)nmesa->verts;
+ GLuint vertsize = nmesa->vertex_size;
+ GLuint size_dword = vertsize*(4)/4;
+
+ nv10ExtendPrimitive(nmesa, size_dword);
+ nv10StartPrimitive(nmesa,GL_QUADS+1,size_dword);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v1*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v2*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v3*vertsize)),vertsize);
+ OUT_RINGp((nouveauVertex*)(vertptr+(v4*vertsize)),vertsize);
+ nv10FinishPrimitive(nmesa);
+}
+
+
+
+static void nv10ChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
tnl->Driver.Render.PrimTabVerts = nv10_render_tab_verts;
tnl->Driver.Render.PrimTabElts = nv10_render_tab_elts;
- tnl->Driver.Render.ClippedLine = NULL;
- tnl->Driver.Render.ClippedPolygon = NULL;
+ tnl->Driver.Render.ClippedLine = nv10_render_clipped_line;
+ tnl->Driver.Render.ClippedPolygon = nv10_render_clipped_poly;
+ tnl->Driver.Render.Points = nv10_render_points;
+ tnl->Driver.Render.Line = nv10_render_line;
+ tnl->Driver.Render.Triangle = nv10_render_triangle;
+ tnl->Driver.Render.Quad = nv10_render_quad;
}
@@ -376,6 +393,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa)
0.0, 0.0, 0.0, 1.0
};
+ nmesa->vertex_attr_count = 0;
RENDERINPUTS_COPY(index, nmesa->render_inputs_bitset);
/*
@@ -509,14 +527,21 @@ static void nv10ChooseVertexState( GLcontext *ctx )
nv10OutputVertexFormat(nmesa);
}
+ if (nmesa->screen->card->type == NV_30) {
+ nouveauShader *fp;
+
+ if (ctx->FragmentProgram.Enabled) {
+ fp = (nouveauShader *) ctx->FragmentProgram.Current;
+ nvsUpdateShader(ctx, fp);
+ } else
+ nvsUpdateShader(ctx, nmesa->passthrough_fp);
+ }
+
if (nmesa->screen->card->type >= NV_40) {
/* Ensure passthrough shader is being used, and mvp matrix
* is up to date
*/
nvsUpdateShader(ctx, nmesa->passthrough_vp);
- BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_IN_REG, 2);
- OUT_RING_CACHE (0xff09); /*IN : POS, COL, TC0-7 */
- OUT_RING_CACHE (0x3fc001); /*OUT: COL, TC0-7, POS implied */
/* Update texenv shader / user fragprog */
nvsUpdateShader(ctx, (nouveauShader*)ctx->FragmentProgram._Current);
@@ -538,11 +563,6 @@ static void nv10RenderStart(GLcontext *ctx)
nmesa->new_render_state |= nmesa->new_state;
}
- if (nmesa->Fallback) {
- tnl->Driver.Render.Start(ctx);
- return;
- }
-
if (nmesa->new_render_state) {
nv10ChooseVertexState(ctx);
nv10ChooseRenderState(ctx);