From 9e3c6f3b8e9b2ec65586fb1ec419c619f6ce8f56 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 22 Jan 2003 18:16:33 +0000 Subject: [PATCH] (Partially) subsetted driver runs miniglxtest and texobj. Other applications segfault at null function pointers, etc -- need to remove these entrypoints from miniglx libGL.so. --- src/mesa/drivers/dri/radeon/Makefile | 7 ++- src/mesa/drivers/dri/radeon/radeon_context.c | 2 + src/mesa/drivers/dri/radeon/radeon_context.h | 1 + .../drivers/dri/radeon/radeon_subset_tcl.c | 55 ++++++++++++++++--- .../drivers/dri/radeon/radeon_subset_vtx.c | 16 ++---- src/mesa/drivers/dri/radeon/radeon_tcl.c | 11 ++++ 6 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index 1d9ef5b8643..e3d5d03712a 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.1.2.15 2003/01/22 16:19:42 keithw Exp $ +# $Id: Makefile,v 1.1.2.16 2003/01/22 18:16:33 keithw Exp $ # Mesa 3-D graphics library # Version: 5.0 @@ -45,7 +45,7 @@ DRIVER_SOURCES = server/radeon_dri.c \ SUBSET_DRIVER_SOURCES = \ radeon_subset_bitmap.c \ radeon_subset_tcl.c \ - radeon_subset_vtx.c + radeon_subset_vtx.c FULL_DRIVER_SOURCES = \ radeon_tcl.c \ @@ -86,6 +86,9 @@ default: radeon_dri.so install radeon_dri.so: $(COREMESA) $(OBJECTS) Makefile rm -f $@ && gcc -o $@ -shared $(OBJECTS) $(COREMESA) -L$(MESA)/src/miniglx -lGL -lc -lm +# wc -l $(DRIVER_SOURCES) +# wc -l $(SUBSET_DRIVER_SOURCES) +# wc -l $(FULL_DRIVER_SOURCES) install: rm -f $(MESA)/lib/radeon_dri.so && \ diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index f3abf10d4cf..0632bb9a242 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -329,6 +329,8 @@ radeonCreateContext( const __GLcontextModes *glVisual, rmesa->swtcl.RenderIndex = ~0; rmesa->lost_context = 1; + + rmesa->tcl.tcl_flag = RADEON_CP_VC_CNTL_TCL_ENABLE; /* KW: Set the maximum texture size small enough that we can * guarentee that both texture units can bind a maximal texture diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h index 0b604609298..140e6cde138 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_context.h @@ -503,6 +503,7 @@ struct radeon_tcl_info { GLuint vertex_format; GLint last_offset; GLuint hw_primitive; + GLuint tcl_flag; struct radeon_dma_region *aos_components[8]; GLuint nr_aos_components; diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_tcl.c b/src/mesa/drivers/dri/radeon/radeon_subset_tcl.c index 3e378f07e85..c0af005f3b0 100644 --- a/src/mesa/drivers/dri/radeon/radeon_subset_tcl.c +++ b/src/mesa/drivers/dri/radeon/radeon_subset_tcl.c @@ -46,13 +46,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "radeon_tcl.h" - - -/* - * Render unclipped vertex buffers by emitting vertices directly to - * dma buffers. Use strip/fan hardware primitives where possible. - * Try to simulate missing primitives with indexed vertices. +/* KW: Import a version of radeon_tcl.c plus t_dd_dmatmp2.h here. + * + * This is all just to support radeon_subset_vtx.c, and is pretty + * heavyweight for that purpose -- it shouldn't be hard to get the + * code there to turn quads into triangles, etc, in a lot less code. */ + + + #define HAVE_POINTS 1 #define HAVE_LINES 1 #define HAVE_LINE_LOOP 0 @@ -278,12 +280,12 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx, if (flags & PRIM_END) { - if (start+1 >= count) - return; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); int currentsz; + if (start+1 >= count) + return; + ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP ); currentsz = GET_CURRENT_VB_MAX_ELTS(); @@ -516,3 +518,38 @@ void radeonTclFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) if (mode) fprintf(stderr, "Warning: hit nonexistant fallback path!\n"); } + +void radeonTclPrimitive( GLcontext *ctx, + GLenum prim, + int hw_prim ) +{ + radeonContextPtr rmesa = RADEON_CONTEXT(ctx); + GLuint se_cntl; + GLuint newprim = hw_prim | rmesa->tcl.tcl_flag; + + RADEON_NEWPRIM( rmesa ); + rmesa->tcl.hw_primitive = newprim; + + se_cntl = rmesa->hw.set.cmd[SET_SE_CNTL]; + se_cntl &= ~RADEON_FLAT_SHADE_VTX_LAST; + + if (prim == GL_POLYGON && (ctx->_TriangleCaps & DD_FLATSHADE)) + se_cntl |= RADEON_FLAT_SHADE_VTX_0; + else + se_cntl |= RADEON_FLAT_SHADE_VTX_LAST; + + if (se_cntl != rmesa->hw.set.cmd[SET_SE_CNTL]) { + RADEON_STATECHANGE( rmesa, set ); + rmesa->hw.set.cmd[SET_SE_CNTL] = se_cntl; + } +} + +void radeonSubsetVtxEnableTCL( radeonContextPtr rmesa, + GLboolean flag ) +{ + if (flag) + rmesa->tcl.tcl_flag = RADEON_CP_VC_CNTL_TCL_ENABLE; + else + rmesa->tcl.tcl_flag = 0; + +} diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c b/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c index 674bc8bad28..92367223698 100644 --- a/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c +++ b/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c @@ -61,7 +61,6 @@ void radeon_copy_to_current( GLcontext *ctx ) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - assert(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT); assert(vb.context == ctx); ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] = vb.floatcolorptr[0]; @@ -75,8 +74,6 @@ void radeon_copy_to_current( GLcontext *ctx ) ctx->Current.Attrib[VERT_ATTRIB_TEX0][2] = 0.0F; ctx->Current.Attrib[VERT_ATTRIB_TEX0][3] = 1.0F; } - - ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; } @@ -322,8 +319,8 @@ static void radeonVtxfmtValidate( GLcontext *ctx ) /* Would prefer to use ubyte floats in the vertex: */ - vb.vertex_size += 4; vb.floatcolorptr = &vb.vertex[vb.vertex_size].f; + vb.vertex_size += 4; vb.floatcolorptr[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]; vb.floatcolorptr[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]; vb.floatcolorptr[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]; @@ -339,6 +336,7 @@ static void radeonVtxfmtValidate( GLcontext *ctx ) vb.texcoordptr[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; rmesa->vb.recheck = GL_FALSE; + ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT; } @@ -434,7 +432,6 @@ static void radeonFlushVertices( GLcontext *ctx, GLuint flags ) if (RADEON_DEBUG & DEBUG_VFMT) fprintf(stderr, "%s\n", __FUNCTION__); - assert(rmesa->vb.installed); assert(vb.context == ctx); if (flags & FLUSH_UPDATE_CURRENT) { @@ -442,7 +439,6 @@ static void radeonFlushVertices( GLcontext *ctx, GLuint flags ) if (RADEON_DEBUG & DEBUG_VFMT) fprintf(stderr, "reinstall on update_current\n"); _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt ); - ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; } if (flags & FLUSH_STORED_VERTICES) { @@ -468,9 +464,9 @@ static __inline__ void radeon_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) *vb.dmaptr++ = *(int *)&y; *vb.dmaptr++ = *(int *)&z; - for (i = 3; i < vb.vertex_size; i++) + for (i = 3; i < vb.vertex_size; i++) *vb.dmaptr++ = vb.vertex[i].i; - + if (--vb.counter == 0) vb.notify(); } @@ -549,6 +545,7 @@ void radeonVtxfmtInit( GLcontext *ctx ) exec->Vertex3fv = radeon_Vertex3fv; exec->Begin = radeon_Begin; exec->End = radeon_End; + exec->Rectf = _mesa_noop_Rectf; /* is this supported? */ vb.context = ctx; @@ -556,10 +553,9 @@ void radeonVtxfmtInit( GLcontext *ctx ) rmesa->vb.prim = &ctx->Driver.CurrentExecPrimitive; rmesa->vb.primflags = 0; - + ctx->Driver.FlushVertices = radeonFlushVertices; ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; radeonVtxfmtValidate( ctx ); - assert( rmesa->vb.installed ); } diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.c b/src/mesa/drivers/dri/radeon/radeon_tcl.c index a67fca2392a..207297dab7c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tcl.c +++ b/src/mesa/drivers/dri/radeon/radeon_tcl.c @@ -563,3 +563,14 @@ void radeonTclFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) fprintf(stderr, "Warning: hit nonexistant fallback path!\n"); } #endif + + +void radeonSubsetVtxEnableTCL( radeonContextPtr rmesa, + GLboolean flag ) +{ + if (flag) + rmesa->tcl.tcl_flag = RADEON_CP_VC_CNTL_TCL_ENABLE; + else + rmesa->tcl.tcl_flag = 0; + +}