From 4c3f0418629f81c921d30b2e8d593dea3b3a3329 Mon Sep 17 00:00:00 2001 From: Vladimir Dergachev Date: Wed, 29 Dec 2004 04:33:33 +0000 Subject: [PATCH] Get most primitives working using immediate mode. Glxgears displays "rotating" gears, all in the same place (no transform mode, remember ?) Work needs to be done to understand how to have glxgears working properly. --- src/mesa/drivers/dri/r300/r300_render.c | 161 ++++++++++++++++++------ 1 file changed, 126 insertions(+), 35 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index d229b7d5593..bafaf272d82 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -63,22 +63,40 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * rasterization hardware for rendering. **********************************************************************/ - -static void r300_render_primitive(r300ContextPtr rmesa, +static void r300_render_flat_primitive(r300ContextPtr rmesa, GLcontext *ctx, int start, int end, - int prim) + int type) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLuint i; int k; ADAPTOR adaptor; + AOS_DATA vb_arrays[2]; LOCAL_VARS if(end<=start)return; /* do we need to watch for this ? */ + /* setup array of structures data */ + + /* Note: immediate vertex data includes all coordinates. + To save bandwidth use either VBUF or state-based vertex generation */ + /* xyz */ + vb_arrays[0].element_size=4; + vb_arrays[0].stride=4; + vb_arrays[0].offset=0; /* Not used */ + vb_arrays[0].format=AOS_FORMAT_FLOAT; + vb_arrays[0].ncomponents=4; + + /* color */ + vb_arrays[1].element_size=4; + vb_arrays[1].stride=4; + vb_arrays[1].offset=0; /* Not used */ + vb_arrays[1].format=AOS_FORMAT_FLOAT_COLOR; + vb_arrays[1].ncomponents=4; + adaptor=TWO_PIPE_ADAPTOR; adaptor.color_offset[0]=rmesa->radeon.radeonScreen->backOffset+rmesa->radeon.radeonScreen->fbLocation; @@ -103,70 +121,143 @@ static void r300_render_primitive(r300ContextPtr rmesa, set_quad0(PASS_PREFIX 1.0,1.0,1.0,1.0); set_init21(PASS_PREFIX 0.0,1.0); + /* We need LOAD_VBPNTR to setup AOS_ATTR fields.. the offsets are irrelevant */ + setup_AOS(PASS_PREFIX vb_arrays, 2); + + + start_immediate_packet(end-start, type, 8); + + for(i=start;iObjPtr, GLfloat, i)[0], + VEC_ELT(VB->ObjPtr, GLfloat, i)[1], + VEC_ELT(VB->ObjPtr, GLfloat, i)[2], + VEC_ELT(VB->ObjPtr, GLfloat, i)[3], + + VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0], + VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1], + VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2], + VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3] + ); + #endif + + /* coordinates */ + efloat(VEC_ELT(VB->ObjPtr, GLfloat, i)[0]); + efloat(VEC_ELT(VB->ObjPtr, GLfloat, i)[1]); + efloat(VEC_ELT(VB->ObjPtr, GLfloat, i)[2]); + #if 0 + efloat(VEC_ELT(VB->ObjPtr, GLfloat, i)[3]); + #else + efloat(1.0); + #endif + + /* color components */ + efloat(VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0]); + efloat(VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1]); + efloat(VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2]); + #if 0 + efloat(VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3]); + #else + efloat(0.0); + #endif + } + + end_3d(PASS_PREFIX_VOID); + + start_packet3(RADEON_CP_PACKET3_NOP, 0); + e32(0x0); +} + +static void r300_render_primitive(r300ContextPtr rmesa, + GLcontext *ctx, + int start, + int end, + int prim) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + GLuint i; + int type=-1; + + if(end<=start)return; /* do we need to watch for this ? */ + fprintf(stderr, "[%d-%d]", start, end); switch (prim & PRIM_MODE_MASK) { case GL_LINES: fprintf(stderr, "L "); + type=R300_VAP_VF_CNTL__PRIM_LINES; + if(endObjPtr, GLfloat, i+k)[0], - VEC_ELT(VB->ObjPtr, GLfloat, i+k)[1], - VEC_ELT(VB->ObjPtr, GLfloat, i+k)[2], - - VEC_ELT(VB->ColorPtr[0], GLfloat, i+k)[0], - VEC_ELT(VB->ColorPtr[0], GLfloat, i+k)[1], - VEC_ELT(VB->ColorPtr[0], GLfloat, i+k)[2] - ); - #endif - emit_flat_vertex(PASS_PREFIX - /* coordinates */ - VEC_ELT(VB->ObjPtr, GLfloat, i+k)[0], - VEC_ELT(VB->ObjPtr, GLfloat, i+k)[1], - VEC_ELT(VB->ObjPtr, GLfloat, i+k)[2], - /* colors */ - VEC_ELT(VB->ColorPtr[0], GLfloat, i+k)[0], - VEC_ELT(VB->ColorPtr[0], GLfloat, i+k)[1], - VEC_ELT(VB->ColorPtr[0], GLfloat, i+k)[2] - ); - } - end_primitive(PASS_PREFIX_VOID); + type=R300_VAP_VF_CNTL__PRIM_QUADS; + if(endPrimitive[i].mode & PRIM_MODE_MASK); + fprintf(stderr, "Cannot handle primitive %02x ", prim & PRIM_MODE_MASK); + return; break; } - end_3d(PASS_PREFIX_VOID); - - start_packet3(RADEON_CP_PACKET3_NOP, 0); - e32(0x0); + r300_render_flat_primitive(rmesa, ctx, start, end, type); + } + /** * Called by the pipeline manager to render a batch of primitives. * We can return true to pass on to the next stage (i.e. software -- 2.30.2