diff options
author | Ian Romanick <idr@us.ibm.com> | 2004-05-05 20:16:17 +0000 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2004-05-05 20:16:17 +0000 |
commit | 95a0bd6762737bb25bdf5c4147da9d1372f6aac3 (patch) | |
tree | 4621bed2826ef56c66ea12e401a75bdf062a332f /src | |
parent | 4045b6e5b85ee407a21559155c34d16fd63dc79c (diff) |
Added support for the 3rd texture coordinate for cubemaps and 3D
textures. progs/demos/cubemap and progs/demos/stex3d seem to work
correctly at all tcl_mode settings. x86 / SSE codegen is currently
disabled.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_context.h | 25 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_maos_arrays.c | 50 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_swtcl.c | 21 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_texstate.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vtxfmt.c | 232 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vtxfmt_c.c | 140 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c | 5 |
8 files changed, 294 insertions, 184 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h index 69ac92b1f1..63d688718c 100644 --- a/src/mesa/drivers/dri/r200/r200_context.h +++ b/src/mesa/drivers/dri/r200/r200_context.h @@ -49,7 +49,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "colormac.h" #include "r200_reg.h" -#define ENABLE_HW_3D_TEXTURE 0 /* XXX this is temporary! */ +#define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */ struct r200_context; typedef struct r200_context r200ContextRec; @@ -365,6 +365,12 @@ struct r200_state_atom { #define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\ R200_VTX_COLOR_MASK) +/** + * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine + * how many components are in texture coordinate \c n. + */ +#define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07) + #define MAT_CMD_0 0 #define MAT_ELT_0 1 #define MAT_STATE_SIZE 17 @@ -703,10 +709,14 @@ struct dfn_lists { struct dynfn SecondaryColor3fvEXT; struct dynfn Normal3f; struct dynfn Normal3fv; + struct dynfn TexCoord3f; + struct dynfn TexCoord3fv; struct dynfn TexCoord2f; struct dynfn TexCoord2fv; struct dynfn TexCoord1f; struct dynfn TexCoord1fv; + struct dynfn MultiTexCoord3fARB; + struct dynfn MultiTexCoord3fvARB; struct dynfn MultiTexCoord2fARB; struct dynfn MultiTexCoord2fvARB; struct dynfn MultiTexCoord1fARB; @@ -732,10 +742,14 @@ struct dfn_generators { struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, const int * ); struct dynfn *(*Normal3f)( GLcontext *, const int * ); struct dynfn *(*Normal3fv)( GLcontext *, const int * ); + struct dynfn *(*TexCoord3f)( GLcontext *, const int * ); + struct dynfn *(*TexCoord3fv)( GLcontext *, const int * ); struct dynfn *(*TexCoord2f)( GLcontext *, const int * ); struct dynfn *(*TexCoord2fv)( GLcontext *, const int * ); struct dynfn *(*TexCoord1f)( GLcontext *, const int * ); struct dynfn *(*TexCoord1fv)( GLcontext *, const int * ); + struct dynfn *(*MultiTexCoord3fARB)( GLcontext *, const int * ); + struct dynfn *(*MultiTexCoord3fvARB)( GLcontext *, const int * ); struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, const int * ); struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, const int * ); struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, const int * ); @@ -756,17 +770,16 @@ struct r200_vbinfo { void (*notify)( void ); GLint vertex_size; - /* A maximum total of 15 elements per vertex: 3 floats for position, 3 + /* A maximum total of 17 elements per vertex: 3 floats for position, 3 * floats for normal, 4 floats for color, 4 bytes for secondary color, - * 2 floats for each texture unit (4 floats total). + * 3 floats for each texture unit (6 floats total). * - * As soon as the 3rd TMU is supported or cube maps (or 3D textures) are - * supported, this value will grow. + * As soon as the 3rd through 6th TMUs are supported, this value will grow. * * The position data is never actually stored here, so 3 elements could be * trimmed out of the buffer. */ - union { float f; int i; r200_color_t color; } vertex[15]; + union { float f; int i; r200_color_t color; } vertex[17]; GLfloat *normalptr; GLfloat *floatcolorptr; diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c index 9d1724db7e..301b265396 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c +++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c @@ -343,6 +343,8 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) GLuint nr = 0; GLuint vfmt0 = 0, vfmt1 = 0; GLuint count = VB->Count; + GLuint i; + GLuint re_cntl; if (1) { if (!rmesa->tcl.obj.buf) @@ -422,30 +424,34 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) /* vtx = (rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] & */ /* ~(R200_TCL_VTX_Q0|R200_TCL_VTX_Q1)); */ - if (inputs & VERT_BIT_TEX0) { - if (!rmesa->tcl.tex[0].buf) - emit_vector( ctx, - &(rmesa->tcl.tex[0]), - (char *)VB->TexCoordPtr[0]->data, - VB->TexCoordPtr[0]->size, - VB->TexCoordPtr[0]->stride, - count ); - - vfmt1 |= VB->TexCoordPtr[0]->size << R200_VTX_TEX0_COMP_CNT_SHIFT; - component[nr++] = &rmesa->tcl.tex[0]; + re_cntl = rmesa->hw.set.cmd[SET_RE_CNTL] & ~(R200_VTX_STQ0_D3D | + R200_VTX_STQ1_D3D | + R200_VTX_STQ2_D3D | + R200_VTX_STQ3_D3D | + R200_VTX_STQ4_D3D | + R200_VTX_STQ5_D3D ); + for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) { + if (inputs & (VERT_BIT_TEX0 << i)) { + if (!rmesa->tcl.tex[i].buf) + emit_vector( ctx, + &(rmesa->tcl.tex[i]), + (char *)VB->TexCoordPtr[i]->data, + VB->TexCoordPtr[i]->size, + VB->TexCoordPtr[i]->stride, + count ); + + if ( ctx->Texture.Unit[i]._ReallyEnabled == TEXTURE_CUBE_BIT ) { + re_cntl |= R200_VTX_STQ0_D3D << (2 * i); + } + + vfmt1 |= VB->TexCoordPtr[i]->size << (i * 3); + component[nr++] = &rmesa->tcl.tex[i]; + } } - if (inputs & VERT_BIT_TEX1) { - if (!rmesa->tcl.tex[1].buf) - emit_vector( ctx, - &(rmesa->tcl.tex[1]), - (char *)VB->TexCoordPtr[1]->data, - VB->TexCoordPtr[1]->size, - VB->TexCoordPtr[1]->stride, - count ); - - vfmt1 |= VB->TexCoordPtr[1]->size << R200_VTX_TEX1_COMP_CNT_SHIFT; - component[nr++] = &rmesa->tcl.tex[1]; + if ( re_cntl != rmesa->hw.set.cmd[SET_RE_CNTL] ) { + R200_STATECHANGE( rmesa, set ); + rmesa->hw.set.cmd[SET_RE_CNTL] = re_cntl; } if (vfmt0 != rmesa->hw.vtx.cmd[VTX_VTXFMT_0] || diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c index 2a0cd5b9d1..80f6f5f91c 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -147,22 +147,15 @@ static void r200SetVertexFormat( GLcontext *ctx ) GLuint sz = VB->TexCoordPtr[i]->size; GLuint emit; - /* r200 doesn't like 1D or 4D texcoords (is that true?): + /* r200 doesn't like 4D texcoords (is that true?): */ - switch (sz) { - case 1: - case 2: - case 3: /* no attempt at cube texturing so far */ - emit = EMIT_2F; - sz = 2; - break; - case 4: + if (sz != 4) { + emit = EMIT_1F + (sz - 1); + } + else { + sz = 3; emit = EMIT_3F_XYW; - sz = 3; - break; - default: - continue; - }; + } fmt_1 |= sz << (3 * i); EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0 ); diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index dbd15ac7ea..164c17e064 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -747,6 +747,7 @@ static GLboolean r200UpdateTextureEnv( GLcontext *ctx, int unit ) #define TEXOBJ_TXFORMAT_X_MASK (R200_DEPTH_LOG2_MASK | \ R200_TEXCOORD_MASK | \ + R200_CLAMP_Q_MASK | \ R200_VOLUME_FILTER_MASK) diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt.c b/src/mesa/drivers/dri/r200/r200_vtxfmt.c index f90a3a5cc1..c63518fefb 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt.c @@ -88,10 +88,14 @@ static void count_funcs( r200ContextPtr rmesa ) count_func( "SecondaryColor3ubv", &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT ); count_func( "Normal3f", &rmesa->vb.dfn_cache.Normal3f ); count_func( "Normal3fv", &rmesa->vb.dfn_cache.Normal3fv ); + count_func( "TexCoord3f", &rmesa->vb.dfn_cache.TexCoord3f ); + count_func( "TexCoord3fv", &rmesa->vb.dfn_cache.TexCoord3fv ); count_func( "TexCoord2f", &rmesa->vb.dfn_cache.TexCoord2f ); count_func( "TexCoord2fv", &rmesa->vb.dfn_cache.TexCoord2fv ); count_func( "TexCoord1f", &rmesa->vb.dfn_cache.TexCoord1f ); count_func( "TexCoord1fv", &rmesa->vb.dfn_cache.TexCoord1fv ); + count_func( "MultiTexCoord3fARB", &rmesa->vb.dfn_cache.MultiTexCoord3fARB ); + count_func( "MultiTexCoord3fvARB", &rmesa->vb.dfn_cache.MultiTexCoord3fvARB ); count_func( "MultiTexCoord2fARB", &rmesa->vb.dfn_cache.MultiTexCoord2fARB ); count_func( "MultiTexCoord2fvARB", &rmesa->vb.dfn_cache.MultiTexCoord2fvARB ); count_func( "MultiTexCoord1fARB", &rmesa->vb.dfn_cache.MultiTexCoord1fARB ); @@ -102,6 +106,7 @@ static void count_funcs( r200ContextPtr rmesa ) void r200_copy_to_current( GLcontext *ctx ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); + unsigned i; if (R200_DEBUG & DEBUG_VFMT) fprintf(stderr, "%s\n", __FUNCTION__); @@ -145,18 +150,29 @@ void r200_copy_to_current( GLcontext *ctx ) ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2] = UBYTE_TO_FLOAT( rmesa->vb.specptr->blue ); } - if (rmesa->vb.vtxfmt_1 & (7 << R200_VTX_TEX0_COMP_CNT_SHIFT)) { - ctx->Current.Attrib[VERT_ATTRIB_TEX0][0] = rmesa->vb.texcoordptr[0][0]; - ctx->Current.Attrib[VERT_ATTRIB_TEX0][1] = rmesa->vb.texcoordptr[0][1]; - ctx->Current.Attrib[VERT_ATTRIB_TEX0][2] = 0.0F; - ctx->Current.Attrib[VERT_ATTRIB_TEX0][3] = 1.0F; - } + for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) { + const unsigned count = VTX_TEXn_COUNT( rmesa->vb.vtxfmt_1, i ); + GLfloat * const src = rmesa->vb.texcoordptr[i]; + + if ( count != 0 ) { + switch( count ) { + case 3: + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][1] = src[1]; + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][2] = src[2]; + break; + case 2: + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][1] = src[1]; + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][2] = 0.0F; + break; + case 1: + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][1] = 0.0F; + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][2] = 0.0F; + break; + } - if (rmesa->vb.vtxfmt_1 & (7 << R200_VTX_TEX1_COMP_CNT_SHIFT)) { - ctx->Current.Attrib[VERT_ATTRIB_TEX1][0] = rmesa->vb.texcoordptr[1][0]; - ctx->Current.Attrib[VERT_ATTRIB_TEX1][1] = rmesa->vb.texcoordptr[1][1]; - ctx->Current.Attrib[VERT_ATTRIB_TEX1][2] = 0.0F; - ctx->Current.Attrib[VERT_ATTRIB_TEX1][3] = 1.0F; + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][0] = src[0]; + ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][3] = 1.0F; + } } ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; @@ -378,6 +394,42 @@ static void VFMT_FALLBACK_OUTSIDE_BEGIN_END( const char *caller ) } +static void dispatch_texcoord( GLuint count, GLfloat * f ) +{ + switch( count ) { + case 3: + _glapi_Dispatch->TexCoord3fv( f ); + break; + case 2: + _glapi_Dispatch->TexCoord2fv( f ); + break; + case 1: + _glapi_Dispatch->TexCoord1fv( f ); + break; + default: + assert( count == 0 ); + break; + } +} + +static void dispatch_multitexcoord( GLuint count, GLuint unit, GLfloat * f ) +{ + switch( count ) { + case 3: + _glapi_Dispatch->MultiTexCoord3fvARB( GL_TEXTURE0+unit, f ); + break; + case 2: + _glapi_Dispatch->MultiTexCoord2fvARB( GL_TEXTURE0+unit, f ); + break; + case 1: + _glapi_Dispatch->MultiTexCoord1fvARB( GL_TEXTURE0+unit, f ); + break; + default: + assert( count == 0 ); + break; + } +} + static void VFMT_FALLBACK( const char *caller ) { GET_CURRENT_CONTEXT(ctx); @@ -388,6 +440,8 @@ static void VFMT_FALLBACK( const char *caller ) GLuint ind1 = rmesa->vb.vtxfmt_1; GLuint nrverts; GLfloat alpha = 1.0; + GLuint count; + GLuint unit; if (R200_DEBUG & (DEBUG_FALLBACKS|DEBUG_VFMT)) fprintf(stderr, "%s from %s\n", __FUNCTION__, caller); @@ -425,6 +479,7 @@ static void VFMT_FALLBACK( const char *caller ) */ for (i = 0 ; i < nrverts; i++) { GLuint offset = 3; + if (ind0 & R200_VTX_N0) { _glapi_Dispatch->Normal3fv( &tmp[i][offset] ); offset += 3; @@ -448,14 +503,14 @@ static void VFMT_FALLBACK( const char *caller ) offset++; } - if (ind1 & (7 << R200_VTX_TEX0_COMP_CNT_SHIFT)) { - _glapi_Dispatch->TexCoord2fv( &tmp[i][offset] ); - offset += 2; - } + count = VTX_TEXn_COUNT( ind1, 0 ); + dispatch_texcoord( count, &tmp[i][offset] ); + offset += count; - if (ind1 & (7 << R200_VTX_TEX1_COMP_CNT_SHIFT)) { - _glapi_Dispatch->MultiTexCoord2fvARB( GL_TEXTURE1, &tmp[i][offset] ); - offset += 2; + for ( unit = 1 ; unit < ctx->Const.MaxTextureUnits ; unit++ ) { + count = VTX_TEXn_COUNT( ind1, unit ); + dispatch_multitexcoord( count, unit, &tmp[i][offset] ); + offset += count; } _glapi_Dispatch->Vertex3fv( &tmp[i][0] ); @@ -492,12 +547,12 @@ static void VFMT_FALLBACK( const char *caller ) rmesa->vb.specptr->green, rmesa->vb.specptr->blue ); - if (ind1 & (7 << R200_VTX_TEX0_COMP_CNT_SHIFT)) { - _glapi_Dispatch->TexCoord2fv( rmesa->vb.texcoordptr[0] ); - } + count = VTX_TEXn_COUNT( ind1, 0 ); + dispatch_texcoord( count, rmesa->vb.texcoordptr[0] ); - if (ind1 & (7 << R200_VTX_TEX1_COMP_CNT_SHIFT)) { - _glapi_Dispatch->MultiTexCoord2fvARB( GL_TEXTURE1, rmesa->vb.texcoordptr[1] ); + for ( unit = 1 ; unit < ctx->Const.MaxTextureUnits ; unit++ ) { + count = VTX_TEXn_COUNT( ind1, unit ); + dispatch_multitexcoord( count, unit, rmesa->vb.texcoordptr[unit] ); } } @@ -582,12 +637,34 @@ static void wrap_buffer( void ) } - +/** + * Determines the hardware vertex format based on the current state vector. + * + * \returns + * If the hardware TCL unit is capable of handling the current state vector, + * \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned. + * + * \todo + * Make this color format selection data driven. If we receive only ubytes, + * send color as ubytes. Also check if converting (with free checking for + * overflow) is cheaper than sending floats directly. + * + * \todo + * When intializing texture coordinates, it might be faster to just copy the + * entire \c VERT_ATTRIB_TEX0 vector into the vertex buffer. It may mean that + * some of the data (i.e., the last texture coordinate components) get copied + * over, but that still may be faster than the conditional branching. If + * nothing else, the code will be smaller and easier to follow. + */ static GLboolean check_vtx_fmt( GLcontext *ctx ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); GLuint ind0 = R200_VTX_Z0; GLuint ind1 = 0; + GLuint i; + GLuint count[R200_MAX_TEXTURE_UNITS]; + GLuint re_cntl; + if (rmesa->TclFallback || rmesa->vb.fell_back || ctx->CompileFlag) return GL_FALSE; @@ -600,11 +677,6 @@ static GLboolean check_vtx_fmt( GLcontext *ctx ) if (ctx->Light.Enabled) { ind0 |= R200_VTX_N0; - /* TODO: make this data driven: If we receive only ubytes, send - * color as ubytes. Also check if converting (with free - * checking for overflow) is cheaper than sending floats - * directly. - */ if (ctx->Light.ColorMaterialEnabled) ind0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT; else @@ -620,36 +692,46 @@ static GLboolean check_vtx_fmt( GLcontext *ctx ) } } - if (ctx->Texture.Unit[0]._ReallyEnabled) { - if (ctx->Texture.Unit[0].TexGenEnabled) { - if (rmesa->TexGenNeedNormals[0]) { - ind0 |= R200_VTX_N0; + re_cntl = rmesa->hw.set.cmd[SET_RE_CNTL] & ~(R200_VTX_STQ0_D3D | + R200_VTX_STQ1_D3D | + R200_VTX_STQ2_D3D | + R200_VTX_STQ3_D3D | + R200_VTX_STQ4_D3D | + R200_VTX_STQ5_D3D ); + for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) { + count[i] = 0; + + if (ctx->Texture.Unit[i]._ReallyEnabled) { + if (ctx->Texture.Unit[i].TexGenEnabled) { + if (rmesa->TexGenNeedNormals[i]) { + ind0 |= R200_VTX_N0; + } } - } else { - if (ctx->Current.Attrib[VERT_ATTRIB_TEX0][2] != 0.0F || - ctx->Current.Attrib[VERT_ATTRIB_TEX0][3] != 1.0) { - if (R200_DEBUG & (DEBUG_VFMT|DEBUG_FALLBACKS)) - fprintf(stderr, "%s: rq0\n", __FUNCTION__); - return GL_FALSE; + else { + switch( ctx->Texture.Unit[i]._ReallyEnabled ) { + case TEXTURE_CUBE_BIT: + re_cntl |= R200_VTX_STQ0_D3D << (2 * i); + /* FALLTHROUGH */ + case TEXTURE_3D_BIT: + count[i] = 3; + break; + case TEXTURE_2D_BIT: + case TEXTURE_RECT_BIT: + count[i] = 2; + break; + case TEXTURE_1D_BIT: + count[i] = 1; + break; + } + + ind1 |= count[i] << (3 * i); } - ind1 |= 2 << R200_VTX_TEX0_COMP_CNT_SHIFT; } } - if (ctx->Texture.Unit[1]._ReallyEnabled) { - if (ctx->Texture.Unit[1].TexGenEnabled) { - if (rmesa->TexGenNeedNormals[1]) { - ind0 |= R200_VTX_N0; - } - } else { - if (ctx->Current.Attrib[VERT_ATTRIB_TEX1][2] != 0.0F || - ctx->Current.Attrib[VERT_ATTRIB_TEX1][3] != 1.0) { - if (R200_DEBUG & (DEBUG_VFMT|DEBUG_FALLBACKS)) - fprintf(stderr, "%s: rq1\n", __FUNCTION__); - return GL_FALSE; - } - ind1 |= 2 << R200_VTX_TEX1_COMP_CNT_SHIFT; - } + if ( re_cntl != rmesa->hw.set.cmd[SET_RE_CNTL] ) { + R200_STATECHANGE( rmesa, set ); + rmesa->hw.set.cmd[SET_RE_CNTL] = re_cntl; } if (R200_DEBUG & (DEBUG_VFMT|DEBUG_STATE)) @@ -713,19 +795,20 @@ static GLboolean check_vtx_fmt( GLcontext *ctx ) } - if (ind1 & (7 << R200_VTX_TEX0_COMP_CNT_SHIFT)) { - rmesa->vb.texcoordptr[0] = &rmesa->vb.vertex[rmesa->vb.vertex_size].f; - rmesa->vb.vertex_size += 2; - rmesa->vb.texcoordptr[0][0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0][0]; - rmesa->vb.texcoordptr[0][1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0][1]; - } + for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) { + if ( count[i] != 0 ) { + float * const attr = ctx->Current.Attrib[VERT_ATTRIB_TEX0+i]; + unsigned j; - if (ind1 & (7 << R200_VTX_TEX1_COMP_CNT_SHIFT)) { - rmesa->vb.texcoordptr[1] = &rmesa->vb.vertex[rmesa->vb.vertex_size].f; - rmesa->vb.vertex_size += 2; - rmesa->vb.texcoordptr[1][0] = ctx->Current.Attrib[VERT_ATTRIB_TEX1][0]; - rmesa->vb.texcoordptr[1][1] = ctx->Current.Attrib[VERT_ATTRIB_TEX1][1]; - } + rmesa->vb.texcoordptr[i] = &rmesa->vb.vertex[rmesa->vb.vertex_size].f; + + for ( j = 0 ; j < count[i] ; j++ ) { + rmesa->vb.texcoordptr[i][j] = attr[j]; + } + + rmesa->vb.vertex_size += count[i]; + } + } if (rmesa->vb.installed_vertex_format != rmesa->vb.vtxfmt_0) { if (R200_DEBUG & DEBUG_VFMT) @@ -736,7 +819,10 @@ static GLboolean check_vtx_fmt( GLcontext *ctx ) if (R200_DEBUG & DEBUG_VFMT) fprintf(stderr, "%s -- success\n", __FUNCTION__); - + + fprintf( stderr, "[%s:%u] vertex size = %u\n", __func__, __LINE__, + rmesa->vb.vertex_size ); + return GL_TRUE; } @@ -1026,12 +1112,8 @@ void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen ) vfmt->EvalMesh2 = r200_fallback_EvalMesh2; vfmt->EvalPoint1 = r200_fallback_EvalPoint1; vfmt->EvalPoint2 = r200_fallback_EvalPoint2; - vfmt->TexCoord3f = r200_fallback_TexCoord3f; - vfmt->TexCoord3fv = r200_fallback_TexCoord3fv; vfmt->TexCoord4f = r200_fallback_TexCoord4f; vfmt->TexCoord4fv = r200_fallback_TexCoord4fv; - vfmt->MultiTexCoord3fARB = r200_fallback_MultiTexCoord3fARB; - vfmt->MultiTexCoord3fvARB = r200_fallback_MultiTexCoord3fvARB; vfmt->MultiTexCoord4fARB = r200_fallback_MultiTexCoord4fARB; vfmt->MultiTexCoord4fvARB = r200_fallback_MultiTexCoord4fvARB; vfmt->Vertex4f = r200_fallback_Vertex4f; @@ -1071,10 +1153,14 @@ void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen ) make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT ); make_empty_list( &rmesa->vb.dfn_cache.Normal3f ); make_empty_list( &rmesa->vb.dfn_cache.Normal3fv ); + make_empty_list( &rmesa->vb.dfn_cache.TexCoord3f ); + make_empty_list( &rmesa->vb.dfn_cache.TexCoord3fv ); make_empty_list( &rmesa->vb.dfn_cache.TexCoord2f ); make_empty_list( &rmesa->vb.dfn_cache.TexCoord2fv ); make_empty_list( &rmesa->vb.dfn_cache.TexCoord1f ); make_empty_list( &rmesa->vb.dfn_cache.TexCoord1fv ); + make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord3fARB ); + make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord3fvARB ); make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord2fARB ); make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord2fvARB ); make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fARB ); @@ -1126,10 +1212,14 @@ void r200VtxfmtDestroy( GLcontext *ctx ) free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3fvEXT ); free_funcs( &rmesa->vb.dfn_cache.Normal3f ); free_funcs( &rmesa->vb.dfn_cache.Normal3fv ); + free_funcs( &rmesa->vb.dfn_cache.TexCoord3f ); + free_funcs( &rmesa->vb.dfn_cache.TexCoord3fv ); free_funcs( &rmesa->vb.dfn_cache.TexCoord2f ); free_funcs( &rmesa->vb.dfn_cache.TexCoord2fv ); free_funcs( &rmesa->vb.dfn_cache.TexCoord1f ); free_funcs( &rmesa->vb.dfn_cache.TexCoord1fv ); + free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord3fARB ); + free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord3fvARB ); free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord2fARB ); free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord2fvARB ); free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord1fARB ); diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c index 776cb9a527..e9f66fb5d7 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c @@ -505,41 +505,30 @@ static void r200_Normal3fv( const GLfloat *v ) /* TexCoord */ -static void r200_TexCoord1f( GLfloat s ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[0]; - dest[0] = s; - dest[1] = 0; -} -static void r200_TexCoord1fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[0]; - dest[0] = v[0]; - dest[1] = 0; -} - -static void r200_TexCoord2f( GLfloat s, GLfloat t ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[0]; - dest[0] = s; - dest[1] = t; -} +#define TEX_to_nF(N, P, S, T, R) \ + static void r200_TexCoord ## N P \ + { \ + GET_CURRENT_CONTEXT(ctx); r200ContextPtr rmesa = R200_CONTEXT(ctx); \ + GLfloat * const dest = rmesa->vb.texcoordptr[0]; \ + switch( ctx->Texture.Unit[0]._ReallyEnabled ) { \ + case TEXTURE_CUBE_BIT: \ + case TEXTURE_3D_BIT: \ + dest[2] = R; \ + case TEXTURE_2D_BIT: \ + case TEXTURE_RECT_BIT: \ + dest[1] = T; \ + case TEXTURE_1D_BIT: \ + dest[0] = S; \ + } \ + } -static void r200_TexCoord2fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[0]; - dest[0] = v[0]; - dest[1] = v[1]; -} +TEX_to_nF( 1f, (GLfloat s), s, 0.0, 0.0 ) +TEX_to_nF( 2f, (GLfloat s, GLfloat t), s, t, 0.0 ) +TEX_to_nF( 3f, (GLfloat s, GLfloat t, GLfloat r), s, t, r ) +TEX_to_nF( 1fv, (const GLfloat * v), v[0], 0.0, 0.0 ) +TEX_to_nF( 2fv, (const GLfloat * v), v[0], v[1], 0.0 ) +TEX_to_nF( 3fv, (const GLfloat * v), v[0], v[1], v[2] ) /* MultiTexcoord @@ -552,41 +541,30 @@ static void r200_TexCoord2fv( const GLfloat *v ) * the subtraction has been omitted. */ -static void r200_MultiTexCoord1fARB( GLenum target, GLfloat s ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[target & 1]; - dest[0] = s; - dest[1] = 0; -} - -static void r200_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[target & 1]; - dest[0] = v[0]; - dest[1] = 0; -} +#define MTEX_to_nF(N, P, U, S, T, R) \ + static void r200_MultiTexCoord ## N ## ARB P \ + { \ + GET_CURRENT_CONTEXT(ctx); r200ContextPtr rmesa = R200_CONTEXT(ctx); \ + GLfloat * const dest = rmesa->vb.texcoordptr[U]; \ + switch( ctx->Texture.Unit[U]._ReallyEnabled ) { \ + case TEXTURE_CUBE_BIT: \ + case TEXTURE_3D_BIT: \ + dest[2] = R; \ + case TEXTURE_2D_BIT: \ + case TEXTURE_RECT_BIT: \ + dest[1] = T; \ + case TEXTURE_1D_BIT: \ + dest[0] = S; \ + } \ + } -static void r200_MultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[target & 1]; - dest[0] = s; - dest[1] = t; -} +MTEX_to_nF( 1f, (GLenum target, GLfloat s), (target & 1), s, 0.0, 0.0 ) +MTEX_to_nF( 2f, (GLenum target, GLfloat s, GLfloat t), (target & 1), s, t, 0.0 ) +MTEX_to_nF( 3f, (GLenum target, GLfloat s, GLfloat t, GLfloat r), (target & 1), s, t, r ) -static void r200_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT(ctx); - GLfloat *dest = rmesa->vb.texcoordptr[target & 1]; - dest[0] = v[0]; - dest[1] = v[1]; -} +MTEX_to_nF( 1fv, (GLenum target, const GLfloat *v), (target & 1), v[0], 0.0, 0.0 ) +MTEX_to_nF( 2fv, (GLenum target, const GLfloat *v), (target & 1), v[0], v[1], 0.0 ) +MTEX_to_nF( 3fv, (GLenum target, const GLfloat *v), (target & 1), v[0], v[1], v[2] ) static struct dynfn *lookup( struct dynfn *l, const int *key ) { @@ -732,6 +710,8 @@ static void choose_##FN ARGS1 \ + + /* VTXFMT_0 */ #define MASK_XYZW (R200_VTX_W0|R200_VTX_Z0) @@ -749,6 +729,7 @@ typedef void (*p4f)( GLfloat, GLfloat, GLfloat, GLfloat ); typedef void (*p3f)( GLfloat, GLfloat, GLfloat ); typedef void (*p2f)( GLfloat, GLfloat ); typedef void (*p1f)( GLfloat ); +typedef void (*pe3f)( GLenum, GLfloat, GLfloat, GLfloat ); typedef void (*pe2f)( GLenum, GLfloat, GLfloat ); typedef void (*pe1f)( GLenum, GLfloat ); typedef void (*p4ub)( GLubyte, GLubyte, GLubyte, GLubyte ); @@ -793,6 +774,10 @@ CHOOSE_SECONDARY_COLOR(SecondaryColor3fEXT, p3f, MASK_SPEC, 0, CHOOSE_SECONDARY_COLOR(SecondaryColor3fvEXT, pfv, MASK_SPEC, 0, (const GLfloat *v), (v)) +CHOOSE(TexCoord3f, p3f, ~0, MASK_ST0, + (GLfloat a,GLfloat b,GLfloat c), (a,b,c)) +CHOOSE(TexCoord3fv, pfv, ~0, MASK_ST0, + (const GLfloat *v), (v)) CHOOSE(TexCoord2f, p2f, ~0, MASK_ST0, (GLfloat a,GLfloat b), (a,b)) CHOOSE(TexCoord2fv, pfv, ~0, MASK_ST0, @@ -802,6 +787,10 @@ CHOOSE(TexCoord1f, p1f, ~0, MASK_ST0, CHOOSE(TexCoord1fv, pfv, ~0, MASK_ST0, (const GLfloat *v), (v)) +CHOOSE(MultiTexCoord3fARB, pe3f, ~0, ~0, + (GLenum u,GLfloat a,GLfloat b,GLfloat c), (u,a,b,c)) +CHOOSE(MultiTexCoord3fvARB, pefv, ~0, ~0, + (GLenum u,const GLfloat *v), (u,v)) CHOOSE(MultiTexCoord2fARB, pe2f, ~0, ~0, (GLenum u,GLfloat a,GLfloat b), (u,a,b)) CHOOSE(MultiTexCoord2fvARB, pefv, ~0, ~0, @@ -836,12 +825,16 @@ void r200VtxfmtInitChoosers( GLvertexformat *vfmt ) vfmt->MultiTexCoord1fvARB = choose_MultiTexCoord1fvARB; vfmt->MultiTexCoord2fARB = choose_MultiTexCoord2fARB; vfmt->MultiTexCoord2fvARB = choose_MultiTexCoord2fvARB; + vfmt->MultiTexCoord3fARB = choose_MultiTexCoord3fARB; + vfmt->MultiTexCoord3fvARB = choose_MultiTexCoord3fvARB; vfmt->Normal3f = choose_Normal3f; vfmt->Normal3fv = choose_Normal3fv; vfmt->TexCoord1f = choose_TexCoord1f; vfmt->TexCoord1fv = choose_TexCoord1fv; vfmt->TexCoord2f = choose_TexCoord2f; vfmt->TexCoord2fv = choose_TexCoord2fv; + vfmt->TexCoord3f = choose_TexCoord3f; + vfmt->TexCoord3fv = choose_TexCoord3fv; vfmt->Vertex2f = choose_Vertex2f; vfmt->Vertex2fv = choose_Vertex2fv; vfmt->Vertex3f = choose_Vertex3f; @@ -874,10 +867,21 @@ void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen ) gen->Color4ubv = codegen_noop; gen->Normal3f = codegen_noop; gen->Normal3fv = codegen_noop; + + gen->TexCoord3f = codegen_noop; + gen->TexCoord3fv = codegen_noop; gen->TexCoord2f = codegen_noop; gen->TexCoord2fv = codegen_noop; + gen->TexCoord1f = codegen_noop; + gen->TexCoord1fv = codegen_noop; + + gen->MultiTexCoord3fARB = codegen_noop; + gen->MultiTexCoord3fvARB = codegen_noop; gen->MultiTexCoord2fARB = codegen_noop; gen->MultiTexCoord2fvARB = codegen_noop; + gen->MultiTexCoord1fARB = codegen_noop; + gen->MultiTexCoord1fvARB = codegen_noop; + gen->Vertex2f = codegen_noop; gen->Vertex2fv = codegen_noop; gen->Color3ub = codegen_noop; @@ -890,10 +894,6 @@ void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen ) gen->SecondaryColor3fvEXT = codegen_noop; gen->SecondaryColor3ubEXT = codegen_noop; gen->SecondaryColor3ubvEXT = codegen_noop; - gen->TexCoord1f = codegen_noop; - gen->TexCoord1fv = codegen_noop; - gen->MultiTexCoord1fARB = codegen_noop; - gen->MultiTexCoord1fvARB = codegen_noop; if (useCodegen) { #if defined(USE_X86_ASM) diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c index 70859b627a..45950159f2 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c @@ -154,6 +154,7 @@ static struct dynfn *r200_makeSSEColor3f( GLcontext *ctx, const int * key ) } } +#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */ static struct dynfn *r200_makeSSETexCoord2fv( GLcontext *ctx, const int * key ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); @@ -205,6 +206,7 @@ static struct dynfn *r200_makeSSEMultiTexCoord2f( GLcontext *ctx, const int * ke } return dfn; } +#endif void r200InitSSECodegen( struct dfn_generators *gen ) { @@ -213,10 +215,12 @@ void r200InitSSECodegen( struct dfn_generators *gen ) gen->Normal3f = (void *) r200_makeSSENormal3f; gen->Color3fv = (void *) r200_makeSSEColor3fv; gen->Color3f = (void *) r200_makeSSEColor3f; +#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */ gen->TexCoord2fv = (void *) r200_makeSSETexCoord2fv; gen->TexCoord2f = (void *) r200_makeSSETexCoord2f; gen->MultiTexCoord2fvARB = (void *) r200_makeSSEMultiTexCoord2fv; gen->MultiTexCoord2fARB = (void *) r200_makeSSEMultiTexCoord2f; +#endif } } diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c index c4d8af85e1..3333178183 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c @@ -337,6 +337,7 @@ struct dynfn *r200_makeX86Color3f( GLcontext *ctx, const int *key ) +#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */ struct dynfn *r200_makeX86TexCoord2fv( GLcontext *ctx, const int *key ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); @@ -395,7 +396,7 @@ struct dynfn *r200_makeX86MultiTexCoord2fARB( GLcontext *ctx, } return dfn; } - +#endif void r200InitX86Codegen( struct dfn_generators *gen ) { @@ -405,10 +406,12 @@ void r200InitX86Codegen( struct dfn_generators *gen ) gen->Color4ubv = r200_makeX86Color4ubv; /* PKCOLOR only */ gen->Normal3f = r200_makeX86Normal3f; gen->Normal3fv = r200_makeX86Normal3fv; +#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */ gen->TexCoord2f = r200_makeX86TexCoord2f; gen->TexCoord2fv = r200_makeX86TexCoord2fv; gen->MultiTexCoord2fARB = r200_makeX86MultiTexCoord2fARB; gen->MultiTexCoord2fvARB = r200_makeX86MultiTexCoord2fvARB; +#endif gen->Color3f = r200_makeX86Color3f; gen->Color3fv = r200_makeX86Color3fv; |