}
}
-
-/* Emit any changed arrays to new GART memory, re-emit a packet to
- * update the arrays.
+
+/* Emit vertex data to GART memory (unless immediate mode)
+ * Route inputs to the vertex processor
*/
-void r300EmitArrays(GLcontext * ctx, GLuint inputs)
+void r300EmitArrays(GLcontext * ctx, GLboolean immd)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
r300ContextPtr r300 = rmesa;
GLuint vic_1 = 0; /* R300_VAP_INPUT_CNTL_1 */
GLuint aa_vap_reg = 0; /* VAP register assignment */
GLuint i;
+ GLuint inputs = 0;
+
+#define CONFIGURE_AOS(f, v, sz, cn) { \
+ if (RADEON_DEBUG & DEBUG_STATE) \
+ fprintf(stderr, "Enabling "#v "\n"); \
+ if (++nr >= R300_MAX_AOS_ARRAYS) { \
+ fprintf(stderr, "Aieee! AOS array count exceeded!\n"); \
+ exit(-1); \
+ } \
+ \
+ if (rmesa->current_vp == NULL) \
+ rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++; \
+ rmesa->state.aos[nr-1].aos_format = f; \
+ if (immd) { \
+ rmesa->state.aos[nr-1].aos_size = 4; \
+ rmesa->state.aos[nr-1].aos_stride = 4; \
+ rmesa->state.aos[nr-1].aos_offset = 0; \
+ } else { \
+ emit_vector(ctx, \
+ &rmesa->state.aos[nr-1], \
+ v->data, \
+ sz, \
+ v->stride, \
+ cn); \
+ } \
+}
+
+ if (rmesa->current_vp != NULL) {
+ if (rmesa->current_vp->inputs[VERT_ATTRIB_POS] != -1) {
+ inputs |= _TNL_BIT_POS;
+ rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_POS];
+ }
+ if (rmesa->current_vp->inputs[VERT_ATTRIB_NORMAL] != -1) {
+ inputs |= _TNL_BIT_NORMAL;
+ rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_NORMAL];
+ }
+ if (rmesa->current_vp->inputs[VERT_ATTRIB_COLOR0] != -1) {
+ inputs |= _TNL_BIT_COLOR0;
+ rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_COLOR0];
+ }
+ if (rmesa->current_vp->inputs[VERT_ATTRIB_COLOR1] != -1) {
+ inputs |= _TNL_BIT_COLOR1;
+ rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_COLOR1];
+ }
+ if (rmesa->current_vp->inputs[VERT_ATTRIB_FOG] != -1) {
+ inputs |= _TNL_BIT_FOG;
+ rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_FOG];
+ }
+ for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
+ if (rmesa->current_vp->inputs[VERT_ATTRIB_TEX0+i] != -1)
+ inputs |= _TNL_BIT_TEX0<<i;
+ rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_TEX0+i];
+ }
+ nr = 0;
+ } else {
+ inputs = TNL_CONTEXT(ctx)->render_inputs;
+ }
+ rmesa->state.render_inputs = inputs;
-/*FIXME: handle vertex program input */
if (inputs & _TNL_BIT_POS) {
- if (RADEON_DEBUG & DEBUG_ALL)
- fprintf(stderr, "[%d] _TNL_BIT_POS: sz=%d, st=%d, c=%d\n",
- nr, VB->ObjPtr->size, VB->ObjPtr->stride, count);
- emit_vector(ctx, &rmesa->state.aos[nr++],
- (char *)VB->ObjPtr->data,
- VB->ObjPtr->size,
- VB->ObjPtr->stride, count);
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT,
+ VB->ObjPtr,
+ immd ? 4 : VB->ObjPtr->size,
+ count);
vic_1 |= R300_INPUT_CNTL_POS;
- rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++;
- rmesa->state.aos[nr-1].aos_format = AOS_FORMAT_FLOAT;
}
if (inputs & _TNL_BIT_NORMAL) {
- if (RADEON_DEBUG & DEBUG_ALL)
- fprintf(stderr, "[%d] _TNL_BIT_NORMAL: sz=%d, st=%d, c=%d\n",
- nr, VB->NormalPtr->size, VB->NormalPtr->stride, count);
- emit_vector(ctx, &rmesa->state.aos[nr++],
- (char *)VB->NormalPtr->data,
- VB->NormalPtr->size,
- VB->NormalPtr->stride, count);
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT,
+ VB->NormalPtr,
+ immd ? 4 : VB->NormalPtr->size,
+ count);
vic_1 |= R300_INPUT_CNTL_NORMAL;
- rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++;
- rmesa->state.aos[nr-1].aos_format = AOS_FORMAT_FLOAT;
}
- if (inputs & VERT_BIT_COLOR0) {
+ if (inputs & _TNL_BIT_COLOR0) {
int emitsize;
- if (RADEON_DEBUG & DEBUG_ALL)
- fprintf(stderr, "[%d] _TNL_BIT_COLOR0: sz=%d, st=%d, c=%d\n",
- nr, VB->ColorPtr[0]->size, VB->ColorPtr[0]->stride, count);
-
- if (VB->ColorPtr[0]->size == 4 &&
- (VB->ColorPtr[0]->stride != 0 ||
- VB->ColorPtr[0]->data[0][3] != 1.0)) {
- emitsize = 4;
- } else {
- emitsize = 3;
+
+ if (!immd) {
+ if (VB->ColorPtr[0]->size == 4 &&
+ (VB->ColorPtr[0]->stride != 0 ||
+ VB->ColorPtr[0]->data[0][3] != 1.0)) {
+ emitsize = 4;
+ } else {
+ emitsize = 3;
+ }
}
- emit_vector(ctx,
- &(rmesa->state.aos[nr++]),
- (char *)VB->ColorPtr[0]->data,
- emitsize, VB->ColorPtr[0]->stride, count);
-// emitsize, VB->ColorPtr[0]->stride, count);
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT_COLOR,
+ VB->ColorPtr[0],
+ immd ? 4 : emitsize,
+ count);
vic_1 |= R300_INPUT_CNTL_COLOR;
- rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++;
- rmesa->state.aos[nr-1].aos_format = AOS_FORMAT_FLOAT_COLOR;
}
- if (inputs & VERT_BIT_COLOR1) {
- if (RADEON_DEBUG & DEBUG_ALL)
- fprintf(stderr, "[%d] _TNL_BIT_COLOR1: sz=%d, st=%d, c=%d\n",
- nr, VB->SecondaryColorPtr[0]->size, VB->SecondaryColorPtr[0]->stride, count);
-
- emit_vector(ctx,
- &rmesa->state.aos[nr++],
- (char *)VB->SecondaryColorPtr[0]->data,
- VB->SecondaryColorPtr[0]->size, VB->SecondaryColorPtr[0]->stride, count);
- rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++;
- rmesa->state.aos[nr-1].aos_format = AOS_FORMAT_FLOAT_COLOR;
+ if (inputs & _TNL_BIT_COLOR1) {
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT_COLOR,
+ VB->SecondaryColorPtr[0],
+ immd ? 4 : VB->SecondaryColorPtr[0]->size,
+ count);
+ }
+
+ if (inputs & _TNL_BIT_FOG) {
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT,
+ VB->FogCoordPtr,
+ immd ? 4 : VB->FogCoordPtr->size,
+ count);
}
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
if (inputs & (_TNL_BIT_TEX0 << i)) {
- if (RADEON_DEBUG & DEBUG_ALL)
- fprintf(stderr, "[%d] _TNL_BIT_TEX%02d: sz=%d, st=%d, c=%d\n",
- nr, i, VB->TexCoordPtr[i]->size, VB->TexCoordPtr[i]->stride, count);
- emit_vector(ctx,
- &(rmesa->state.aos[nr++]),
- (char *)VB->TexCoordPtr[i]->data,
- VB->TexCoordPtr[i]->size,
- VB->TexCoordPtr[i]->stride, count);
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT,
+ VB->TexCoordPtr[i],
+ immd ? 4 : VB->TexCoordPtr[i]->size,
+ count);
vic_1 |= R300_INPUT_CNTL_TC0 << i;
- rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++;
- rmesa->state.aos[nr-1].aos_format = AOS_FORMAT_FLOAT;
}
}
((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->unchecked_state.count = (nr+1)>>1;
/* Set up input_cntl */
-
+ /* I don't think this is needed for vertex buffers, but it doesn't hurt anything */
R300_STATECHANGE(r300, vic);
r300->hw.vic.cmd[R300_VIC_CNTL_0]=0x5555; /* Hard coded value, no idea what it means */
r300->hw.vic.cmd[R300_VIC_CNTL_1]=vic_1;
#define CONFIGURE_AOS(v, o, r, f) \
{\
if (RADEON_DEBUG & DEBUG_STATE)fprintf(stderr, "Enabling "#r "\n"); \
- if(immediate){ \
- r300->state.aos[count].element_size=4; \
- r300->state.aos[count].stride=4; \
- r300->state.aos[count].ncomponents=4; \
- } else { \
- r300->state.aos[count].element_size=v->size; \
- r300->state.aos[count].stride=v->size; \
- r300->state.aos[count].ncomponents=v->size; \
- } \
- r300->state.aos[count].offset=o; \
- r300->state.aos[count].reg=reg; \
- r300->state.aos[count].format=(f); \
+ r300->state.aos[count].aos_size=4; \
+ r300->state.aos[count].aos_stride=4; \
+ r300->state.aos[count].aos_offset=o; \
+ r300->state.aos[count].aos_reg=reg; \
+ r300->state.aos[count].aos_format=(f); \
r300->state.vap_reg.r=reg; \
count++; \
reg++; \
/* setup INPUT_ROUTE */
R300_STATECHANGE(r300, vir[0]);
for(i=0;i+1<count;i+=2){
- dw=(r300->state.aos[i].ncomponents-1)
- | ((r300->state.aos[i].reg)<<8)
- | (r300->state.aos[i].format<<14)
- | (((r300->state.aos[i+1].ncomponents-1)
- | ((r300->state.aos[i+1].reg)<<8)
- | (r300->state.aos[i+1].format<<14))<<16);
+ dw=(r300->state.aos[i].aos_size-1)
+ | ((r300->state.aos[i].aos_reg)<<8)
+ | (r300->state.aos[i].aos_format<<14)
+ | (((r300->state.aos[i+1].aos_size-1)
+ | ((r300->state.aos[i+1].aos_reg)<<8)
+ | (r300->state.aos[i+1].aos_format<<14))<<16);
if(i+2==count){
dw|=(1<<(13+16));
r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
}
if(count & 1){
- dw=(r300->state.aos[count-1].ncomponents-1)
- | (r300->state.aos[count-1].format<<14)
- | ((r300->state.aos[count-1].reg)<<8)
+ dw=(r300->state.aos[count-1].aos_size-1)
+ | (r300->state.aos[count-1].aos_format<<14)
+ | ((r300->state.aos[count-1].aos_reg)<<8)
| (1<<13);
r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(count>>1)]=dw;
//fprintf(stderr, "vir0 dw=%08x\n", dw);
for(i=0;i+1<count;i+=2){
/* do i first.. */
- mask=(1<<(r300->state.aos[i].ncomponents*3))-1;
+ mask=(1<<(r300->state.aos[i].aos_size*3))-1;
dw=(ALL_COMPONENTS & mask)
| (ALL_DEFAULT & ~mask)
| R300_INPUT_ROUTE_ENABLE;
/* i+1 */
- mask=(1<<(r300->state.aos[i+1].ncomponents*3))-1;
+ mask=(1<<(r300->state.aos[i+1].aos_size*3))-1;
dw|=(
(ALL_COMPONENTS & mask)
| (ALL_DEFAULT & ~mask)
r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
}
if(count & 1){
- mask=(1<<(r300->state.aos[count-1].ncomponents*3))-1;
+ mask=(1<<(r300->state.aos[count-1].aos_size*3))-1;
dw=(ALL_COMPONENTS & mask)
| (ALL_DEFAULT & ~mask)
| R300_INPUT_ROUTE_ENABLE;
r300UpdateTextureState(ctx);
- r300_setup_routing(ctx, GL_TRUE);
+// r300_setup_routing(ctx, GL_TRUE);
+ r300EmitArrays(ctx, GL_TRUE); /* Just do the routing */
r300_setup_textures(ctx);
r300_setup_rs_unit(ctx);