diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2003-11-24 15:21:14 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2003-11-24 15:21:14 +0000 |
commit | 57c9814b9e87924696df4c741861c29d4236d1eb (patch) | |
tree | 63c9139693032c681fad3e7b50d743b762e0a64d /src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h | |
parent | 5b5cf9cb8b3f540365e3da8e4a70f6a5040a1c6c (diff) |
Import vtx-0-2-branch
Diffstat (limited to 'src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h')
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h | 214 |
1 files changed, 65 insertions, 149 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h b/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h index b379bad985..c16234a943 100644 --- a/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h +++ b/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h @@ -39,13 +39,14 @@ static void TAG(emit)( GLcontext *ctx, void *dest ) { LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLuint (*tc0)[4], (*tc1)[4], (*tc2)[4]; + GLfloat (*col)[4], (*spec)[4]; GLfloat (*fog)[4]; GLuint (*norm)[4]; - GLubyte (*col)[4], (*spec)[4]; GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride; GLuint tc2_stride, norm_stride; + GLuint fill_tex = 0; GLuint (*coord)[4]; GLuint coord_stride; /* object coordinates */ GLubyte dummy[4]; @@ -56,36 +57,20 @@ static void TAG(emit)( GLcontext *ctx, if (RADEON_DEBUG & DEBUG_VERTS) fprintf(stderr, "%s\n", __FUNCTION__); - /* The vertex code expects Obj to be clean to element 3. To fix - * this, add more vertex code (for obj-2, obj-3) or preferably move - * to maos. - */ - if (VB->ObjPtr->size < 3) { - if (VB->ObjPtr->flags & VEC_NOT_WRITEABLE) { - VB->import_data( ctx, VERT_BIT_POS, VEC_NOT_WRITEABLE ); - } - _mesa_vector4f_clean_elem( VB->ObjPtr, VB->Count, 2 ); - } - - if (DO_W && VB->ObjPtr->size < 4) { - if (VB->ObjPtr->flags & VEC_NOT_WRITEABLE) { - VB->import_data( ctx, VERT_BIT_POS, VEC_NOT_WRITEABLE ); - } - _mesa_vector4f_clean_elem( VB->ObjPtr, VB->Count, 3 ); - } - coord = (GLuint (*)[4])VB->ObjPtr->data; coord_stride = VB->ObjPtr->stride; if (DO_TEX2) { - const GLuint t2 = GET_TEXSOURCE(2); - tc2 = (GLuint (*)[4])VB->TexCoordPtr[t2]->data; - tc2_stride = VB->TexCoordPtr[t2]->stride; - if (DO_PTEX && VB->TexCoordPtr[t2]->size < 4) { - if (VB->TexCoordPtr[t2]->flags & VEC_NOT_WRITEABLE) { - VB->import_data( ctx, VERT_BIT_TEX2, VEC_NOT_WRITEABLE ); + if (VB->TexCoordPtr[2]) { + const GLuint t2 = GET_TEXSOURCE(2); + tc2 = (GLuint (*)[4])VB->TexCoordPtr[t2]->data; + tc2_stride = VB->TexCoordPtr[t2]->stride; + if (DO_PTEX && VB->TexCoordPtr[t2]->size < 4) { + fill_tex |= (1<<2); } - _mesa_vector4f_clean_elem( VB->TexCoordPtr[t2], VB->Count, 3 ); + } else { + tc2 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX2]; + tc2_stride = 0; } } @@ -95,13 +80,10 @@ static void TAG(emit)( GLcontext *ctx, tc1 = (GLuint (*)[4])VB->TexCoordPtr[t1]->data; tc1_stride = VB->TexCoordPtr[t1]->stride; if (DO_PTEX && VB->TexCoordPtr[t1]->size < 4) { - if (VB->TexCoordPtr[t1]->flags & VEC_NOT_WRITEABLE) { - VB->import_data( ctx, VERT_BIT_TEX1, VEC_NOT_WRITEABLE ); - } - _mesa_vector4f_clean_elem( VB->TexCoordPtr[t1], VB->Count, 3 ); + fill_tex |= (1<<1); } } else { - tc1 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX1]; /* could be anything, really */ + tc1 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX1]; tc1_stride = 0; } } @@ -112,13 +94,10 @@ static void TAG(emit)( GLcontext *ctx, tc0_stride = VB->TexCoordPtr[t0]->stride; tc0 = (GLuint (*)[4])VB->TexCoordPtr[t0]->data; if (DO_PTEX && VB->TexCoordPtr[t0]->size < 4) { - if (VB->TexCoordPtr[t0]->flags & VEC_NOT_WRITEABLE) { - VB->import_data( ctx, VERT_BIT_TEX0, VEC_NOT_WRITEABLE ); - } - _mesa_vector4f_clean_elem( VB->TexCoordPtr[t0], VB->Count, 3 ); + fill_tex |= (1<<0); } } else { - tc0 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX0]; /* could be anything, really */ + tc0 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX0]; tc0_stride = 0; } @@ -136,28 +115,20 @@ static void TAG(emit)( GLcontext *ctx, if (DO_RGBA) { if (VB->ColorPtr[0]) { - /* This is incorrect when colormaterial is enabled: - */ - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) { - if (0) fprintf(stderr, "IMPORTING FLOAT COLORS\n"); - IMPORT_FLOAT_COLORS( ctx ); - } - col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; + col = VB->ColorPtr[0]->data; + col_stride = VB->ColorPtr[0]->stride; } else { - col = &dummy; /* any old memory is fine */ + col = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; col_stride = 0; } } if (DO_SPEC) { if (VB->SecondaryColorPtr[0]) { - if (VB->SecondaryColorPtr[0]->Type != GL_UNSIGNED_BYTE) - IMPORT_FLOAT_SPEC_COLORS( ctx ); - spec = (GLubyte (*)[4])VB->SecondaryColorPtr[0]->Ptr; - spec_stride = VB->SecondaryColorPtr[0]->StrideB; + spec = VB->SecondaryColorPtr[0]->data; + spec_stride = VB->SecondaryColorPtr[0]->stride; } else { - spec = &dummy; + spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; spec_stride = 0; } } @@ -173,33 +144,33 @@ static void TAG(emit)( GLcontext *ctx, } - if (VB->importable_data) { - if (start) { - coord = (GLuint (*)[4])((GLubyte *)coord + start * coord_stride); - if (DO_TEX0) - tc0 = (GLuint (*)[4])((GLubyte *)tc0 + start * tc0_stride); - if (DO_TEX1) - tc1 = (GLuint (*)[4])((GLubyte *)tc1 + start * tc1_stride); - if (DO_TEX2) - tc2 = (GLuint (*)[4])((GLubyte *)tc2 + start * tc2_stride); - if (DO_NORM) - norm = (GLuint (*)[4])((GLubyte *)norm + start * norm_stride); - if (DO_RGBA) - STRIDE_4UB(col, start * col_stride); - if (DO_SPEC) - STRIDE_4UB(spec, start * spec_stride); - if (DO_FOG) - fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride); - } + if (start) { + coord = (GLuint (*)[4])((GLubyte *)coord + start * coord_stride); + if (DO_TEX0) + tc0 = (GLuint (*)[4])((GLubyte *)tc0 + start * tc0_stride); + if (DO_TEX1) + tc1 = (GLuint (*)[4])((GLubyte *)tc1 + start * tc1_stride); + if (DO_TEX2) + tc2 = (GLuint (*)[4])((GLubyte *)tc2 + start * tc2_stride); + if (DO_NORM) + norm = (GLuint (*)[4])((GLubyte *)norm + start * norm_stride); + if (DO_RGBA) + STRIDE_4F(col, start * col_stride); + if (DO_SPEC) + STRIDE_4F(spec, start * spec_stride); + if (DO_FOG) + STRIDE_4F(fog, start * fog_stride); + } + + { for (i=start; i < end; i++) { + v[0].ui = coord[0][0]; v[1].ui = coord[0][1]; v[2].ui = coord[0][2]; - if (TCL_DEBUG) fprintf(stderr, "%d: %.2f %.2f %.2f ", i, v[0].f, v[1].f, v[2].f); if (DO_W) { v[3].ui = coord[0][3]; - if (TCL_DEBUG) fprintf(stderr, "%.2f ", v[3].f); v += 4; } else @@ -210,26 +181,27 @@ static void TAG(emit)( GLcontext *ctx, v[0].ui = norm[0][0]; v[1].ui = norm[0][1]; v[2].ui = norm[0][2]; - if (TCL_DEBUG) fprintf(stderr, "norm: %.2f %.2f %.2f ", v[0].f, v[1].f, v[2].f); v += 3; norm = (GLuint (*)[4])((GLubyte *)norm + norm_stride); } if (DO_RGBA) { - v[0].ui = LE32_TO_CPU(*(GLuint *)&col[0]); - STRIDE_4UB(col, col_stride); - if (TCL_DEBUG) fprintf(stderr, "%x ", v[0].ui); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.red, col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.green, col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.blue, col[0][2]); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.alpha, col[0][3]); + STRIDE_4F(col, col_stride); v++; } if (DO_SPEC || DO_FOG) { if (DO_SPEC) { - v[0].specular.red = spec[0][0]; - v[0].specular.green = spec[0][1]; - v[0].specular.blue = spec[0][2]; - STRIDE_4UB(spec, spec_stride); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.red, spec[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.green, spec[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.blue, spec[0][2]); + STRIDE_4F(spec, spec_stride); } if (DO_FOG) { - v[0].specular.alpha = fog[0][0] * 255.0; - fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); + UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.alpha, fog[0][0]); + fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); } if (TCL_DEBUG) fprintf(stderr, "%x ", v[0].ui); v++; @@ -239,7 +211,10 @@ static void TAG(emit)( GLcontext *ctx, v[1].ui = tc0[0][1]; if (TCL_DEBUG) fprintf(stderr, "t0: %.2f %.2f ", v[0].f, v[1].f); if (DO_PTEX) { - v[2].ui = tc0[0][3]; + if (fill_tex & (1<<0)) + v[2].f = 1.0; + else + v[2].ui = tc0[0][3]; if (TCL_DEBUG) fprintf(stderr, "%.2f ", v[2].f); v += 3; } @@ -252,7 +227,10 @@ static void TAG(emit)( GLcontext *ctx, v[1].ui = tc1[0][1]; if (TCL_DEBUG) fprintf(stderr, "t1: %.2f %.2f ", v[0].f, v[1].f); if (DO_PTEX) { - v[2].ui = tc1[0][3]; + if (fill_tex & (1<<1)) + v[2].f = 1.0; + else + v[2].ui = tc1[0][3]; if (TCL_DEBUG) fprintf(stderr, "%.2f ", v[2].f); v += 3; } @@ -264,7 +242,10 @@ static void TAG(emit)( GLcontext *ctx, v[0].ui = tc2[0][0]; v[1].ui = tc2[0][1]; if (DO_PTEX) { - v[2].ui = tc2[0][3]; + if (fill_tex & (1<<2)) + v[2].f = 1.0; + else + v[2].ui = tc2[0][3]; v += 3; } else @@ -273,71 +254,6 @@ static void TAG(emit)( GLcontext *ctx, } if (TCL_DEBUG) fprintf(stderr, "\n"); } - } else { - for (i=start; i < end; i++) { - v[0].ui = coord[i][0]; - v[1].ui = coord[i][1]; - v[2].ui = coord[i][2]; - if (DO_W) { - v[3].ui = coord[i][3]; - v += 4; - } - else - v += 3; - - if (DO_NORM) { - v[0].ui = norm[i][0]; - v[1].ui = norm[i][1]; - v[2].ui = norm[i][2]; - v += 3; - } - if (DO_RGBA) { - v[0].ui = LE32_TO_CPU(*(GLuint *)&col[i]); - v++; - } - if (DO_SPEC || DO_FOG) { - if (DO_SPEC) { - v[0].specular.red = spec[i][0]; - v[0].specular.green = spec[i][1]; - v[0].specular.blue = spec[i][2]; - } - if (DO_FOG) { - GLfloat *f = (GLfloat *) ((GLubyte *)fog + fog_stride); - v[0].specular.alpha = *f * 255.0; - } - v++; - } - if (DO_TEX0) { - v[0].ui = tc0[i][0]; - v[1].ui = tc0[i][1]; - if (DO_PTEX) { - v[2].ui = tc0[i][3]; - v += 3; - } - else - v += 2; - } - if (DO_TEX1) { - v[0].ui = tc1[i][0]; - v[1].ui = tc1[i][1]; - if (DO_PTEX) { - v[2].ui = tc1[i][3]; - v += 3; - } - else - v += 2; - } - if (DO_TEX2) { - v[0].ui = tc2[i][0]; - v[1].ui = tc2[i][1]; - if (DO_PTEX) { - v[2].ui = tc2[i][3]; - v += 3; - } - else - v += 2; - } - } } } |