aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAapo Tahkola <[email protected]>2006-03-19 18:04:12 +0000
committerAapo Tahkola <[email protected]>2006-03-19 18:04:12 +0000
commit77174f0072be992eeffb6a53a3311fbd33463c5f (patch)
treeedb65204572c3928f4783809e96ce2387cd68d0c
parent21a4fb41376ab90afdfca67375e55e4a0ded6c0f (diff)
-fix texrect fallback when using vtxfmt_a (glitz, xgl, etc.)
-struct vertex_buffer to struct radeon_vertex_buffer conversion -vertex attrib arrays did not supersede conventinal arrays when enabled
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h16
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.c302
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.h4
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c147
-rw-r--r--src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c113
5 files changed, 102 insertions, 480 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index f948752e750..4a7772aaa7a 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -714,7 +714,6 @@ struct r300_fragment_program {
#define REG_COLOR0 1
#define REG_TEX0 2
-#ifdef USER_BUFFERS
struct dt {
GLint size;
GLenum type;
@@ -736,7 +735,6 @@ struct radeon_vertex_buffer {
GLsizei LockCount;
int lock_uptodate;
};
-#endif
struct r300_aos_rec {
GLuint offset;
@@ -759,9 +757,7 @@ struct r300_state {
struct r300_pfs_compile_state pfs_compile;
struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
int aos_count;
-#ifdef USER_BUFFERS
struct radeon_vertex_buffer VB;
-#endif
GLuint *Elts;
struct r300_dma_region elt_dma;
@@ -777,6 +773,9 @@ struct r300_state {
};
+#define R300_FALLBACK_NONE 0
+#define R300_FALLBACK_TCL 1
+#define R300_FALLBACK_RAST 2
/**
* R300 context structure.
@@ -808,9 +807,6 @@ struct r300_context {
GLuint prefer_gart_client_texturing;
#ifdef USER_BUFFERS
- key_t mm_ipc_key;
- int mm_shm_id;
- int mm_sem_id;
struct radeon_memory_manager *rmm;
GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
@@ -847,11 +843,13 @@ extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
void r300_translate_vertex_shader(struct r300_vertex_program *vp);
extern void r300InitShaderFuncs(struct dd_function_table *functions);
extern int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp, float *dst);
-extern GLboolean r300Fallback(GLcontext *ctx);
+extern int r300Fallback(GLcontext *ctx);
+
+extern void radeon_vb_to_rvb(r300ContextPtr rmesa, struct radeon_vertex_buffer *rvb, struct vertex_buffer *vb);
+extern GLboolean r300_run_vb_render(GLcontext *ctx, struct tnl_pipeline_stage *stage);
#ifdef RADEON_VTXFMT_A
extern void radeon_init_vtxfmt_a(r300ContextPtr rmesa);
-extern GLboolean r300_run_vb_render_vtxfmt_a(GLcontext *ctx, struct tnl_pipeline_stage *stage);
#endif
#ifdef HW_VBOS
diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c
index d9f8c031751..c2ff9c5d983 100644
--- a/src/mesa/drivers/dri/r300/r300_maos.c
+++ b/src/mesa/drivers/dri/r300/r300_maos.c
@@ -255,306 +255,8 @@ void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts, int elt_siz
/* Emit vertex data to GART memory (unless immediate mode)
* Route inputs to the vertex processor
*/
-void r300EmitArrays(GLcontext * ctx, GLboolean immd)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- r300ContextPtr r300 = rmesa;
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLuint nr = 0;
- GLuint count = VB->Count;
- GLuint dw,mask;
- 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(r, 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 (hw_tcl_on == GL_FALSE) \
- 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); \
- rmesa->state.vap_reg.r=rmesa->state.aos[nr-1].aos_reg; \
- } \
-}
-
- if (hw_tcl_on) {
- GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->Base.InputsRead;
- struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
- if (InputsRead & (1<<VERT_ATTRIB_POS)) {
- inputs |= _TNL_BIT_POS;
- rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_POS];
- }
- if (InputsRead & (1<<VERT_ATTRIB_NORMAL)) {
- inputs |= _TNL_BIT_NORMAL;
- rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_NORMAL];
- }
- if (InputsRead & (1<<VERT_ATTRIB_COLOR0)) {
- inputs |= _TNL_BIT_COLOR0;
- rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR0];
- }
- if (InputsRead & (1<<VERT_ATTRIB_COLOR1)) {
- inputs |= _TNL_BIT_COLOR1;
- rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR1];
- }
- if (InputsRead & (1<<VERT_ATTRIB_FOG)) {
- inputs |= _TNL_BIT_FOG;
- rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_FOG];
- }
- if(ctx->Const.MaxTextureUnits > 8) { /* Not sure if this can even happen... */
- fprintf(stderr, "%s: Cant handle that many inputs\n", __FUNCTION__);
- exit(-1);
- }
- for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
- if (InputsRead & (1<<(VERT_ATTRIB_TEX0+i))) {
- inputs |= _TNL_BIT_TEX0<<i;
- rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_TEX0+i];
- }
- }
- nr = 0;
- } else {
- inputs = TNL_CONTEXT(ctx)->render_inputs;
- }
- rmesa->state.render_inputs = inputs;
-
- if (inputs & _TNL_BIT_POS) {
- CONFIGURE_AOS(i_coords, AOS_FORMAT_FLOAT,
- VB->ObjPtr,
- immd ? 4 : VB->ObjPtr->size,
- count);
-
- vic_1 |= R300_INPUT_CNTL_POS;
- }
-
- if (inputs & _TNL_BIT_NORMAL) {
- CONFIGURE_AOS(i_normal, AOS_FORMAT_FLOAT,
- VB->NormalPtr,
- immd ? 4 : VB->NormalPtr->size,
- count);
-
- vic_1 |= R300_INPUT_CNTL_NORMAL;
- }
-
- if (inputs & _TNL_BIT_COLOR0) {
- int emitsize=4;
-
- 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;
- }
- }
-
- CONFIGURE_AOS(i_color[0], AOS_FORMAT_FLOAT_COLOR,
- VB->ColorPtr[0],
- immd ? 4 : emitsize,
- count);
-
- vic_1 |= R300_INPUT_CNTL_COLOR;
- }
-
- if (inputs & _TNL_BIT_COLOR1) {
- CONFIGURE_AOS(i_color[1], AOS_FORMAT_FLOAT_COLOR,
- VB->SecondaryColorPtr[0],
- immd ? 4 : VB->SecondaryColorPtr[0]->size,
- count);
- }
-
-#if 0
- if (inputs & _TNL_BIT_FOG) {
- CONFIGURE_AOS( AOS_FORMAT_FLOAT,
- VB->FogCoordPtr,
- immd ? 4 : VB->FogCoordPtr->size,
- count);
- }
-#endif
-
- r300->state.texture.tc_count = 0;
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- if (inputs & (_TNL_BIT_TEX0 << i)) {
- CONFIGURE_AOS(i_tex[i], AOS_FORMAT_FLOAT,
- VB->TexCoordPtr[i],
- immd ? 4 : VB->TexCoordPtr[i]->size,
- count);
-
- vic_1 |= R300_INPUT_CNTL_TC0 << i;
- r300->state.texture.tc_count++;
- }
- }
-
-#define SHOW_INFO(n) do { \
- if (RADEON_DEBUG & DEBUG_ALL) { \
- fprintf(stderr, "RR[%d] - sz=%d, reg=%d, fmt=%d -- st=%d, of=0x%08x\n", \
- n, \
- r300->state.aos[n].aos_size, \
- r300->state.aos[n].aos_reg, \
- r300->state.aos[n].aos_format, \
- r300->state.aos[n].aos_stride, \
- r300->state.aos[n].aos_offset); \
- } \
-} while(0);
- /* setup INPUT_ROUTE */
- R300_STATECHANGE(r300, vir[0]);
- for(i=0;i+1<nr;i+=2){
- SHOW_INFO(i)
- SHOW_INFO(i+1)
- 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==nr){
- dw|=(1<<(13+16));
- }
- r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
- }
- if(nr & 1){
- SHOW_INFO(nr-1)
- dw=(r300->state.aos[nr-1].aos_size-1)
- | (r300->state.aos[nr-1].aos_format<<14)
- | ((r300->state.aos[nr-1].aos_reg)<<8)
- | (1<<13);
- r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(nr>>1)]=dw;
- //fprintf(stderr, "vir0 dw=%08x\n", dw);
- }
- /* Set the rest of INPUT_ROUTE_0 to 0 */
- //for(i=((count+1)>>1); i<8; i++)r300->hw.vir[0].cmd[R300_VIR_CNTL_0+i]=(0x0);
- ((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count = (nr+1)>>1;
-
-
- /* Mesa assumes that all missing components are from (0, 0, 0, 1) */
-#define ALL_COMPONENTS ((R300_INPUT_ROUTE_SELECT_X<<R300_INPUT_ROUTE_X_SHIFT) \
- | (R300_INPUT_ROUTE_SELECT_Y<<R300_INPUT_ROUTE_Y_SHIFT) \
- | (R300_INPUT_ROUTE_SELECT_Z<<R300_INPUT_ROUTE_Z_SHIFT) \
- | (R300_INPUT_ROUTE_SELECT_W<<R300_INPUT_ROUTE_W_SHIFT))
-
-#define ALL_DEFAULT ((R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_X_SHIFT) \
- | (R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_Y_SHIFT) \
- | (R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_Z_SHIFT) \
- | (R300_INPUT_ROUTE_SELECT_ONE<<R300_INPUT_ROUTE_W_SHIFT))
-
- R300_STATECHANGE(r300, vir[1]);
-
- for(i=0;i+1<nr;i+=2){
- /* do i first.. */
- 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].aos_size*3))-1;
- dw|=(
- (ALL_COMPONENTS & mask)
- | (ALL_DEFAULT & ~mask)
- | R300_INPUT_ROUTE_ENABLE
- )<<16;
-
- r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
- }
- if(nr & 1){
- mask=(1<<(r300->state.aos[nr-1].aos_size*3))-1;
- dw=(ALL_COMPONENTS & mask)
- | (ALL_DEFAULT & ~mask)
- | R300_INPUT_ROUTE_ENABLE;
- r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(nr>>1)]=dw;
- //fprintf(stderr, "vir1 dw=%08x\n", dw);
- }
- /* Set the rest of INPUT_ROUTE_1 to 0 */
- //for(i=((count+1)>>1); i<8; i++)r300->hw.vir[1].cmd[R300_VIR_CNTL_0+i]=0x0;
- ((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.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;
-
-#if 0
- r300->hw.vic.cmd[R300_VIC_CNTL_1]=0;
-
- if(r300->state.render_inputs & _TNL_BIT_POS)
- r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_POS;
-
- if(r300->state.render_inputs & _TNL_BIT_NORMAL)
- r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_NORMAL;
-
- if(r300->state.render_inputs & _TNL_BIT_COLOR0)
- r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_COLOR;
-
- for(i=0;i < ctx->Const.MaxTextureUnits;i++)
- if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i))
- r300->hw.vic.cmd[R300_VIC_CNTL_1]|=(R300_INPUT_CNTL_TC0<<i);
-#endif
-
- /* Stage 3: VAP output */
-
- R300_STATECHANGE(r300, vof);
-
- r300->hw.vof.cmd[R300_VOF_CNTL_0]=0;
- r300->hw.vof.cmd[R300_VOF_CNTL_1]=0;
- if (hw_tcl_on){
- GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
-
- if(OutputsWritten & (1<<VERT_RESULT_HPOS))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
- if(OutputsWritten & (1<<VERT_RESULT_COL0))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
- if(OutputsWritten & (1<<VERT_RESULT_COL1))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
- /*if(OutputsWritten & (1<<VERT_RESULT_BFC0))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
- if(OutputsWritten & (1<<VERT_RESULT_BFC1))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;*/
- //if(OutputsWritten & (1<<VERT_RESULT_FOGC))
-
- if(OutputsWritten & (1<<VERT_RESULT_PSIZ))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
-
- for(i=0;i < ctx->Const.MaxTextureUnits;i++)
- if(OutputsWritten & (1<<(VERT_RESULT_TEX0+i)))
- r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4<<(3*i));
- } else {
- if(inputs & _TNL_BIT_POS)
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
- if(inputs & _TNL_BIT_COLOR0)
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
- if(inputs & _TNL_BIT_COLOR1)
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
-
- for(i=0;i < ctx->Const.MaxTextureUnits;i++)
- if(inputs & (_TNL_BIT_TEX0<<i))
- r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i));
- }
-
- rmesa->state.aos_count = nr;
-}
-
-#ifdef RADEON_VTXFMT_A
-void r300EmitArraysVtx(GLcontext * ctx, GLboolean immd)
+void r300EmitArrays(GLcontext * ctx, GLboolean immd)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
r300ContextPtr r300 = rmesa;
@@ -568,7 +270,6 @@ void r300EmitArraysVtx(GLcontext * ctx, GLboolean immd)
GLuint i;
GLuint inputs = 0;
-#undef CONFIGURE_AOS
#define CONFIGURE_AOS(r, f, v, sz, cn) { \
if (RADEON_DEBUG & DEBUG_STATE) \
fprintf(stderr, "Enabling "#v "\n"); \
@@ -872,7 +573,6 @@ void r300EmitArraysVtx(GLcontext * ctx, GLboolean immd)
rmesa->state.aos_count = nr;
}
-#endif
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx)
diff --git a/src/mesa/drivers/dri/r300/r300_maos.h b/src/mesa/drivers/dri/r300/r300_maos.h
index c75589085bf..7235af6ef6b 100644
--- a/src/mesa/drivers/dri/r300/r300_maos.h
+++ b/src/mesa/drivers/dri/r300/r300_maos.h
@@ -43,10 +43,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
extern void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts, int elt_size);
extern void r300EmitArrays(GLcontext * ctx, GLboolean immd);
-#ifdef RADEON_VTXFMT_A
-extern void r300EmitArraysVtx(GLcontext * ctx, GLboolean immd);
-#endif
-
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx);
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
index ee24f14f615..acdecb54ec2 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -282,99 +282,6 @@ static void r300_render_vb_primitive(r300ContextPtr rmesa,
int prim)
{
int type, num_verts;
- LOCAL_VARS
-
- type=r300_get_primitive_type(rmesa, ctx, prim);
- num_verts=r300_get_num_verts(rmesa, ctx, end-start, prim);
-
- if(type<0 || num_verts <= 0)return;
-
- if(rmesa->state.Elts){
- r300EmitAOS(rmesa, rmesa->state.aos_count, 0);
-#if 0
- int i;
- start_index32_packet(num_verts, type);
- for(i=0; i < num_verts; i++)
- e32(rmesa->state.Elts[start+i]); /* start ? */
-#else
- if(num_verts == 1){
- start_index32_packet(num_verts, type);
- e32(rmesa->state.Elts[start]);
- return;
- }
-
- if(num_verts > 65535){ /* not implemented yet */
- WARN_ONCE("Too many elts\n");
- return;
- }
- r300EmitElts(ctx, rmesa->state.Elts+start, num_verts, 4);
- fire_EB(PASS_PREFIX GET_START(&(rmesa->state.elt_dma)), num_verts, type, 4);
-#endif
- }else{
- r300EmitAOS(rmesa, rmesa->state.aos_count, start);
- fire_AOS(PASS_PREFIX num_verts, type);
- }
-}
-
-static GLboolean r300_run_vb_render(GLcontext *ctx,
- struct tnl_pipeline_stage *stage)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- int i;
- LOCAL_VARS
-
- if (RADEON_DEBUG & DEBUG_PRIMS)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
-
- //r300UpdateShaders(rmesa);
-
- r300ReleaseArrays(ctx);
- r300EmitArrays(ctx, GL_FALSE);
-
- r300UpdateShaderStates(rmesa);
-
- reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
- e32(0x0000000a);
-
- reg_start(0x4f18,0);
- e32(0x00000003);
- r300EmitState(rmesa);
-
- rmesa->state.Elts = VB->Elts;
-
- for(i=0; i < VB->PrimitiveCount; i++){
- GLuint prim = VB->Primitive[i].mode;
- GLuint start = VB->Primitive[i].start;
- GLuint length = VB->Primitive[i].count;
-
- r300_render_vb_primitive(rmesa, ctx, start, start + length, prim);
- }
-
- reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
- e32(0x0000000a);
-
- reg_start(0x4f18,0);
- e32(0x00000003);
-
-#ifdef USER_BUFFERS
- r300UseArrays(ctx);
-#endif
-
- return GL_FALSE;
-}
-
-#ifdef RADEON_VTXFMT_A
-
-static void r300_render_vb_primitive_vtxfmt_a(r300ContextPtr rmesa,
- GLcontext *ctx,
- int start,
- int end,
- int prim)
-{
- int type, num_verts;
type=r300_get_primitive_type(rmesa, ctx, prim);
num_verts=r300_get_num_verts(rmesa, ctx, end-start, prim);
@@ -416,6 +323,7 @@ void dump_array(struct r300_dma_region *rvb, int count)
int *out = (int *)(rvb->address + rvb->start);
int i, ci;
+ fprintf(stderr, "stride %d:", rvb->aos_stride);
for (i=0; i < count; i++) {
fprintf(stderr, "{");
if (rvb->aos_format == AOS_FORMAT_FLOAT)
@@ -437,7 +345,7 @@ void dump_dt(struct dt *dt, int count)
int *out = dt->data;
int i, ci;
- fprintf(stderr, "base at %p ", out);
+ fprintf(stderr, "stride %d", dt->stride);
for (i=0; i < count; i++){
fprintf(stderr, "{");
@@ -456,23 +364,27 @@ void dump_dt(struct dt *dt, int count)
}
#endif
-/*static */GLboolean r300_run_vb_render_vtxfmt_a(GLcontext *ctx,
+GLboolean r300_run_vb_render(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- //TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct radeon_vertex_buffer *VB = &rmesa->state.VB; //&tnl->vb;
- int i;
- LOCAL_VARS
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct radeon_vertex_buffer *VB = &rmesa->state.VB;
+ int i;
+ LOCAL_VARS
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (stage) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ radeon_vb_to_rvb(rmesa, VB, &tnl->vb);
+ }
r300UpdateShaders(rmesa);
if (rmesa->state.VB.LockCount == 0 || 1) {
r300ReleaseArrays(ctx);
- r300EmitArraysVtx(ctx, GL_FALSE);
-
+ r300EmitArrays(ctx, GL_FALSE);
+
r300UpdateShaderStates(rmesa);
} else {
/* TODO: Figure out why do we need these. */
@@ -496,7 +408,7 @@ void dump_dt(struct dt *dt, int count)
#endif
#if 0
r300ReleaseArrays(ctx);
- r300EmitArraysVtx(ctx, GL_FALSE);
+ r300EmitArrays(ctx, GL_FALSE);
fprintf(stderr, "after:\n");
for(i=0; i < rmesa->state.aos_count; i++){
@@ -522,7 +434,7 @@ void dump_dt(struct dt *dt, int count)
GLuint start = VB->Primitive[i].start;
GLuint length = VB->Primitive[i].count;
- r300_render_vb_primitive_vtxfmt_a(rmesa, ctx, start, start + length, prim);
+ r300_render_vb_primitive(rmesa, ctx, start, start + length, prim);
}
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
@@ -536,19 +448,19 @@ void dump_dt(struct dt *dt, int count)
#endif
return GL_FALSE;
}
-#endif
#define FALLBACK_IF(expr) \
do { \
if (expr) { \
if (1 || RADEON_DEBUG & DEBUG_FALLBACKS) \
WARN_ONCE("fallback:%s\n", #expr); \
- return GL_TRUE; \
+ return R300_FALLBACK_RAST; \
} \
} while(0)
-GLboolean r300Fallback(GLcontext *ctx)
+int r300Fallback(GLcontext *ctx)
{
+ int i;
//FALLBACK_IF(ctx->RenderMode != GL_RENDER); // We do not do SELECT or FEEDBACK (yet ?)
@@ -576,8 +488,12 @@ GLboolean r300Fallback(GLcontext *ctx)
/* Rest could be done with vertex fragments */
if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite)
FALLBACK_IF(ctx->Point.PointSprite); // GL_POINT_SPRITE_NV
-
- return GL_FALSE;
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
+ if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_RECT_BIT)
+ return R300_FALLBACK_TCL;
+
+ return R300_FALLBACK_NONE;
}
/**
@@ -593,9 +509,9 @@ static GLboolean r300_run_render(GLcontext *ctx,
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
- if (r300Fallback(ctx))
+ if (r300Fallback(ctx) >= R300_FALLBACK_RAST)
return GL_TRUE;
-
+
return r300_run_vb_render(ctx, stage);
}
@@ -613,7 +529,6 @@ static GLboolean r300_run_tcl_render(GLcontext *ctx,
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_vertex_program *vp;
- int i;
hw_tcl_on=future_hw_tcl_on;
@@ -622,17 +537,11 @@ static GLboolean r300_run_tcl_render(GLcontext *ctx,
if(hw_tcl_on == GL_FALSE)
return GL_TRUE;
- if (r300Fallback(ctx)) {
+ if (r300Fallback(ctx) >= R300_FALLBACK_TCL) {
hw_tcl_on = GL_FALSE;
return GL_TRUE;
}
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) /* XXX: Needs to be part of r300Fallback */
- if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_RECT_BIT) {
- hw_tcl_on = GL_FALSE;
- return GL_TRUE;
- }
-
r300UpdateShaders(rmesa);
vp = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
diff --git a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c
index 053af1ac661..5ea9bb4eb45 100644
--- a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c
+++ b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c
@@ -45,15 +45,55 @@
#include "api_validate.h"
#include "state.h"
+#define CONV_VB(a, b) rvb->AttribPtr[(a)].size = vb->b->size, \
+ rvb->AttribPtr[(a)].type = GL_FLOAT, \
+ rvb->AttribPtr[(a)].stride = vb->b->stride, \
+ rvb->AttribPtr[(a)].data = vb->b->data
+
+void radeon_vb_to_rvb(r300ContextPtr rmesa, struct radeon_vertex_buffer *rvb, struct vertex_buffer *vb)
+{
+ int i;
+ GLcontext *ctx;
+ ctx = rmesa->radeon.glCtx;
+
+ memset(rvb, 0, sizeof(*rvb));
+
+ rvb->Elts = vb->Elts;
+ rvb->elt_size = 4;
+ rvb->elt_min = 0;
+ rvb->elt_max = vb->Count;
+
+ rvb->Count = vb->Count;
+
+ CONV_VB(VERT_ATTRIB_POS, ObjPtr);
+ CONV_VB(VERT_ATTRIB_NORMAL, NormalPtr);
+ CONV_VB(VERT_ATTRIB_COLOR0, ColorPtr[0]);
+ CONV_VB(VERT_ATTRIB_COLOR1, SecondaryColorPtr[0]);
+ CONV_VB(VERT_ATTRIB_FOG, FogCoordPtr);
+
+ for (i=0; i < MAX_TEXTURE_COORD_UNITS; i++)
+ CONV_VB(VERT_ATTRIB_TEX0 + i, TexCoordPtr[i]);
+
+ rvb->Primitive = vb->Primitive;
+ rvb->PrimitiveCount = vb->PrimitiveCount;
+ rvb->LockFirst = rvb->LockCount = 0;
+ rvb->lock_uptodate = GL_FALSE;
+}
+
#ifdef RADEON_VTXFMT_A
extern void _tnl_array_init( GLcontext *ctx );
-#define CONV(a, b) rmesa->state.VB.AttribPtr[(a)].size = ctx->Array.b.Size, \
- rmesa->state.VB.AttribPtr[(a)].data = ctx->Array.b.BufferObj->Name ? \
- (void *)ADD_POINTERS(ctx->Array.b.Ptr, ctx->Array.b.BufferObj->Data) : (void *)ctx->Array.b.Ptr, \
- rmesa->state.VB.AttribPtr[(a)].stride = ctx->Array.b.StrideB, \
- rmesa->state.VB.AttribPtr[(a)].type = ctx->Array.b.Type
+#define CONV(a, b) do { \
+ if (ctx->Array.b.Enabled) { \
+ rmesa->state.VB.AttribPtr[(a)].size = ctx->Array.b.Size; \
+ rmesa->state.VB.AttribPtr[(a)].data = ctx->Array.b.BufferObj->Name ? \
+ (void *)ADD_POINTERS(ctx->Array.b.Ptr, ctx->Array.b.BufferObj->Data) : (void *)ctx->Array.b.Ptr; \
+ rmesa->state.VB.AttribPtr[(a)].stride = ctx->Array.b.StrideB; \
+ rmesa->state.VB.AttribPtr[(a)].type = ctx->Array.b.Type; \
+ enabled |= 1 << (a); \
+ } \
+ } while (0)
static int setup_arrays(r300ContextPtr rmesa, GLint start)
{
@@ -63,40 +103,25 @@ static int setup_arrays(r300ContextPtr rmesa, GLint start)
GLuint enabled = 0;
ctx = rmesa->radeon.glCtx;
- if (r300Fallback(ctx))
- return -1;
+ i = r300Fallback(ctx);
+ if (i)
+ return i;
memset(rmesa->state.VB.AttribPtr, 0, VERT_ATTRIB_MAX*sizeof(struct dt));
CONV(VERT_ATTRIB_POS, Vertex);
- if (ctx->Array.Vertex.Enabled)
- enabled |= 1 << VERT_ATTRIB_POS;
-
CONV(VERT_ATTRIB_NORMAL, Normal);
- if (ctx->Array.Normal.Enabled)
- enabled |= 1 << VERT_ATTRIB_NORMAL;
-
CONV(VERT_ATTRIB_COLOR0, Color);
- if (ctx->Array.Color.Enabled)
- enabled |= 1 << VERT_ATTRIB_COLOR0;
-
CONV(VERT_ATTRIB_COLOR1, SecondaryColor);
- if (ctx->Array.SecondaryColor.Enabled)
- enabled |= 1 << VERT_ATTRIB_COLOR1;
-
CONV(VERT_ATTRIB_FOG, FogCoord);
- if (ctx->Array.FogCoord.Enabled)
- enabled |= 1 << VERT_ATTRIB_FOG;
- for (i=0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+ for (i=0; i < MAX_TEXTURE_COORD_UNITS; i++)
CONV(VERT_ATTRIB_TEX0 + i, TexCoord[i]);
-
- if(ctx->Array.TexCoord[i].Enabled) {
- enabled |= 1 << (VERT_ATTRIB_TEX0+i);
- }
-
- }
-
+
+ if (ctx->VertexProgram._Enabled)
+ for (i=0; i < VERT_ATTRIB_MAX; i++)
+ CONV(i, VertexAttrib[i]);
+
for (i=0; i < VERT_ATTRIB_MAX; i++) {
if (enabled & (1 << i)) {
rmesa->state.VB.AttribPtr[i].data += rmesa->state.VB.AttribPtr[i].stride * start;
@@ -113,12 +138,12 @@ static int setup_arrays(r300ContextPtr rmesa, GLint start)
if(rmesa->state.VB.AttribPtr[i].type != GL_UNSIGNED_BYTE &&
rmesa->state.VB.AttribPtr[i].type != GL_FLOAT){
WARN_ONCE("Unsupported format %d at index %d\n", rmesa->state.VB.AttribPtr[i].type, i);
- return -1;
+ return R300_FALLBACK_TCL;
}
if(rmesa->state.VB.AttribPtr[i].type == GL_UNSIGNED_BYTE &&
rmesa->state.VB.AttribPtr[i].size != 4){
WARN_ONCE("Unsupported component count for ub colors\n");
- return -1;
+ return R300_FALLBACK_TCL;
}
/*fprintf(stderr, "%d: ", i);
@@ -143,7 +168,7 @@ static int setup_arrays(r300ContextPtr rmesa, GLint start)
fprintf(stderr, "Stride %d ", rmesa->state.VB.AttribPtr[i].stride);
fprintf(stderr, "\n");*/
}
- return 0;
+ return R300_FALLBACK_NONE;
}
void radeon_init_vtxfmt_a(r300ContextPtr rmesa);
@@ -180,12 +205,6 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G
return;
FLUSH_CURRENT( ctx, 0 );
- /*
- fprintf(stderr, "dt at %s:\n", __FUNCTION__);
- for(i=0; i < VERT_ATTRIB_MAX; i++){
- fprintf(stderr, "dt %d:", i);
- dump_dt(&rmesa->state.VB.AttribPtr[i], rmesa->state.VB.Count);
- }*/
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
switch (type) {
@@ -276,7 +295,7 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G
rmesa->state.VB.Count = rmesa->state.VB.LockCount;
r300ReleaseArrays(ctx);
- r300EmitArraysVtx(ctx, GL_FALSE);
+ r300EmitArrays(ctx, GL_FALSE);
rmesa->state.VB.lock_uptodate = GL_TRUE;
}
@@ -292,7 +311,7 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G
return;
}
} else {
- if (setup_arrays(rmesa, min))
+ if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL)
goto fallback;
rmesa->state.VB.Count = max - min + 1;
@@ -313,7 +332,7 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G
rmesa->state.VB.Elts = ptr;
rmesa->state.VB.elt_size = elt_size;
- r300_run_vb_render_vtxfmt_a(ctx, NULL);
+ r300_run_vb_render(ctx, NULL);
if(rvb.buf)
radeon_mm_use(rmesa, rvb.buf->id);
@@ -438,7 +457,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
rmesa->state.VB.Count = rmesa->state.VB.LockCount;
r300ReleaseArrays(ctx);
- r300EmitArraysVtx(ctx, GL_FALSE);
+ r300EmitArrays(ctx, GL_FALSE);
rmesa->state.VB.lock_uptodate = GL_TRUE;
}
@@ -454,7 +473,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
return;
}*/
} else {
- if (setup_arrays(rmesa, min))
+ if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL)
goto fallback;
rmesa->state.VB.Count = max - min + 1;
@@ -477,7 +496,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
rmesa->state.VB.elt_min = min;
rmesa->state.VB.elt_max = max;
- r300_run_vb_render_vtxfmt_a(ctx, NULL);
+ r300_run_vb_render(ctx, NULL);
if(rvb.buf)
radeon_mm_use(rmesa, rvb.buf->id);
@@ -531,7 +550,7 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
rmesa->state.VB.Count = rmesa->state.VB.LockCount;
r300ReleaseArrays(ctx);
- r300EmitArraysVtx(ctx, GL_FALSE);
+ r300EmitArrays(ctx, GL_FALSE);
rmesa->state.VB.lock_uptodate = GL_TRUE;
}
@@ -547,7 +566,7 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
goto fallback;
}
} else {
- if (setup_arrays(rmesa, start))
+ if (setup_arrays(rmesa, start) >= R300_FALLBACK_TCL)
goto fallback;
rmesa->state.VB.Count = count;
@@ -570,7 +589,7 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
rmesa->state.VB.elt_min = 0;
rmesa->state.VB.elt_max = 0;
- r300_run_vb_render_vtxfmt_a(ctx, NULL);
+ r300_run_vb_render(ctx, NULL);
return ;