diff options
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_maos.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 102 |
3 files changed, 113 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index ae9711d5514..f4911fd311d 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -666,7 +666,10 @@ struct r300_state { struct r300_dma_region elt_ao; GLuint render_inputs; /* actual render inputs that R300 was configured for. - They are the same as tnl->render_inputs for fixed pipeline */ + They are the same as tnl->render_inputs for fixed pipeline */ + struct { + int transform_offset; /* Transform matrix offset, -1 if none */ + } vap_param; /* vertex processor parameter allocation - tells where to write parameters */ int hw_stencil; }; diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c index af5d00892a2..04abe8c54fd 100644 --- a/src/mesa/drivers/dri/r300/r300_maos.c +++ b/src/mesa/drivers/dri/r300/r300_maos.c @@ -304,7 +304,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) GLuint i; GLuint inputs = 0; -#define CONFIGURE_AOS(f, v, sz, cn) { \ +#define CONFIGURE_AOS(r, f, v, sz, cn) { \ if (RADEON_DEBUG & DEBUG_STATE) \ fprintf(stderr, "Enabling "#v "\n"); \ if (++nr >= R300_MAX_AOS_ARRAYS) { \ @@ -326,6 +326,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) sz, \ v->stride, \ cn); \ + rmesa->state.vap_reg.r=rmesa->state.aos[nr-1].aos_reg; \ } \ } @@ -362,7 +363,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) rmesa->state.render_inputs = inputs; if (inputs & _TNL_BIT_POS) { - CONFIGURE_AOS( AOS_FORMAT_FLOAT, + CONFIGURE_AOS(i_coords, AOS_FORMAT_FLOAT, VB->ObjPtr, immd ? 4 : VB->ObjPtr->size, count); @@ -371,7 +372,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) } if (inputs & _TNL_BIT_NORMAL) { - CONFIGURE_AOS( AOS_FORMAT_FLOAT, + CONFIGURE_AOS(i_normal, AOS_FORMAT_FLOAT, VB->NormalPtr, immd ? 4 : VB->NormalPtr->size, count); @@ -392,7 +393,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) } } - CONFIGURE_AOS( AOS_FORMAT_FLOAT_COLOR, + CONFIGURE_AOS(i_color[0], AOS_FORMAT_FLOAT_COLOR, VB->ColorPtr[0], immd ? 4 : emitsize, count); @@ -401,7 +402,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) } if (inputs & _TNL_BIT_COLOR1) { - CONFIGURE_AOS( AOS_FORMAT_FLOAT_COLOR, + CONFIGURE_AOS(i_color[1], AOS_FORMAT_FLOAT_COLOR, VB->SecondaryColorPtr[0], immd ? 4 : VB->SecondaryColorPtr[0]->size, count); @@ -418,7 +419,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { if (inputs & (_TNL_BIT_TEX0 << i)) { - CONFIGURE_AOS( AOS_FORMAT_FLOAT, + CONFIGURE_AOS(i_tex[i], AOS_FORMAT_FLOAT, VB->TexCoordPtr[i], immd ? 4 : VB->TexCoordPtr[i]->size, count); diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index b47957054db..1229cd678b4 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1504,6 +1504,105 @@ void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s void r300SetupVertexProgram(r300ContextPtr rmesa); +/* just a skeleton for now.. */ + +/* Generate a vertex shader that simply transforms vertex and texture coordinates, + while leaving colors intact. Nothing fancy (like lights) + + If implementing lights make a copy first, so it is easy to switch between the two versions */ +void r300GenerateSimpleVertexShader(r300ContextPtr r300) +{ + int i; + + /* Allocate parameters */ + r300->state.vap_param.transform_offset=0x0; /* transform matrix */ + r300->state.vertex_shader.param_offset=0x0; + r300->state.vertex_shader.param_count=0x4; /* 4 vector values - 4x4 matrix */ + + r300->state.vertex_shader.program_start=0x0; + r300->state.vertex_shader.unknown_ptr1=0x4; /* magic value ? */ + r300->state.vertex_shader.program_end=0x0; + + r300->state.vertex_shader.unknown_ptr2=0x0; /* magic value */ + r300->state.vertex_shader.unknown_ptr3=0x4; /* magic value */ + + /* Initialize matrix and vector parameters.. these should really be restructured */ + /* TODO: fix vertex_shader structure */ + r300->state.vertex_shader.matrix[0].length=16; + r300->state.vertex_shader.matrix[1].length=0; + r300->state.vertex_shader.matrix[2].length=0; + r300->state.vertex_shader.vector[0].length=0; + r300->state.vertex_shader.vector[1].length=0; + r300->state.vertex_shader.unknown1.length=0; + r300->state.vertex_shader.unknown2.length=0; + +#define WRITE_OP(oper,source1,source2,source3) {\ + r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].op=(oper); \ + r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src1=(source1); \ + r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src2=(source2); \ + r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src3=(source3); \ + r300->state.vertex_shader.program_end++; \ + } + + /* Multiply vertex coordinates with transform matrix */ + + WRITE_OP( + EASY_VSF_OP(MUL, 0, ALL, TMP), + VSF_PARAM(3), + VSF_ATTR_W(0), + EASY_VSF_SOURCE(0, W, W, W, W, NONE, NONE) + ) + + WRITE_OP( + EASY_VSF_OP(MUL, 1, ALL, RESULT), + VSF_REG(1), + VSF_ATTR_UNITY(1), + VSF_UNITY(1) + ) + + WRITE_OP( + EASY_VSF_OP(MAD, 0, ALL, TMP), + VSF_PARAM(2), + VSF_ATTR_Z(0), + VSF_TMP(0) + ) + + WRITE_OP( + EASY_VSF_OP(MAD, 0, ALL, TMP), + VSF_PARAM(1), + VSF_ATTR_Y(0), + VSF_TMP(0) + ) + + WRITE_OP( + EASY_VSF_OP(MAD, 0, ALL, RESULT), + VSF_PARAM(0), + VSF_ATTR_X(0), + VSF_TMP(0) + ) + + /* Pass through texture coordinates, if any */ + for(i=0;i < r300->radeon.glCtx->Const.MaxTextureUnits;i++) + if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)){ + // fprintf(stderr, "i_tex[%d]=%d\n", i, r300->state.vap_reg.i_tex[i]); + WRITE_OP( + EASY_VSF_OP(MUL, 2+i, ALL, RESULT), + VSF_REG(r300->state.vap_reg.i_tex[i]), + VSF_ATTR_UNITY(r300->state.vap_reg.i_tex[i]), + VSF_UNITY(r300->state.vap_reg.i_tex[i]) + ) + } + + r300->state.vertex_shader.program_end--; /* r300 wants program length to be one more - no idea why */ + r300->state.vertex_shader.program.length=(r300->state.vertex_shader.program_end+1)*4; + + r300->state.vertex_shader.unknown_ptr1=r300->state.vertex_shader.program_end; /* magic value ? */ + r300->state.vertex_shader.unknown_ptr2=r300->state.vertex_shader.program_end; /* magic value ? */ + r300->state.vertex_shader.unknown_ptr3=r300->state.vertex_shader.program_end; /* magic value ? */ + +} + + void r300SetupVertexShader(r300ContextPtr rmesa) { GLcontext* ctx = rmesa->radeon.glCtx; @@ -1522,13 +1621,16 @@ void r300SetupVertexShader(r300ContextPtr rmesa) /* This needs to be replaced by vertex shader generation code */ +#if 0 /* textures enabled ? */ if(rmesa->state.texture.tc_count>0){ rmesa->state.vertex_shader=SINGLE_TEXTURE_VERTEX_SHADER; } else { rmesa->state.vertex_shader=FLAT_COLOR_VERTEX_SHADER; } +#endif + r300GenerateSimpleVertexShader(rmesa); rmesa->state.vertex_shader.matrix[0].length=16; memcpy(rmesa->state.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4); |