diff options
author | Vladimir Dergachev <[email protected]> | 2005-02-03 15:44:06 +0000 |
---|---|---|
committer | Vladimir Dergachev <[email protected]> | 2005-02-03 15:44:06 +0000 |
commit | 4c56261075500d7434e24fb47bf5b1a0196b2b11 (patch) | |
tree | df0b32fbdb178dd9a62cfd27bed2171e5d56c3c5 /src | |
parent | 19b260119a8ef78bbe1815d8011ff64a22208b3d (diff) |
Get vertex programs supplied by the user work properly with immediate mode - vertex buffer mode worked by accident.
Fix alu_offset in SINGLE_TEXTURE_PIPELINE.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/r300/Makefile | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_fixed_pipelines.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_render.c | 29 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 80 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texmem.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texstate.c | 1 |
7 files changed, 69 insertions, 48 deletions
diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 1ea07584aa5..f76ffd974de 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -5,7 +5,7 @@ TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = r300_dri.so -DEFINES += -DCOMPILE_R300 +DEFINES += -DCOMPILE_R300 -DGLX_DIRECT_RENDERING MINIGLX_SOURCES = server/radeon_dri.c diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index a5d034e0cd4..37c58a0f2fd 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -642,6 +642,8 @@ struct r300_state { struct r300_pixel_shader_state pixel_shader; struct r300_aos_rec aos[R300_MAX_AOS_ARRAYS]; int aos_count; + GLuint render_inputs; /* actual render inputs that R300 was configured for. + They are the same as tnl->render_inputs for fixed pipeline */ int hw_stencil; }; diff --git a/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h b/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h index 0b74ed82e23..e10318f954d 100644 --- a/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h +++ b/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h @@ -263,7 +263,7 @@ static struct r300_pixel_shader_state SINGLE_TEXTURE_PIXEL_SHADER={ tex_offset: 0, tex_end: 0, - alu_offset: 1, + alu_offset: 0, alu_end: 0 }, diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 16b7258481b..7092842e9d6 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -190,7 +190,7 @@ static void r300_render_immediate_primitive(r300ContextPtr rmesa, { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - GLuint i; + GLuint i, render_inputs; int k, type; LOCAL_VARS @@ -224,6 +224,13 @@ static void r300_render_immediate_primitive(r300ContextPtr rmesa, return; } + render_inputs = rmesa->state.render_inputs; + + if(!render_inputs){ + WARN_ONCE("Aeiee ! render_inputs==0. Skipping rendering.\n"); + return; + } + start_immediate_packet(end-start, type, 4*rmesa->state.aos_count); for(i=start;i<end;i++){ @@ -243,28 +250,28 @@ static void r300_render_immediate_primitive(r300ContextPtr rmesa, /* coordinates */ - if(tnl->render_inputs & _TNL_BIT_POS) + if(render_inputs & _TNL_BIT_POS) output_vector(VB->ObjPtr, i); - if(tnl->render_inputs & _TNL_BIT_NORMAL) + if(render_inputs & _TNL_BIT_NORMAL) output_vector(VB->NormalPtr, i); /* color components */ - if(tnl->render_inputs & _TNL_BIT_COLOR0) + if(render_inputs & _TNL_BIT_COLOR0) output_vector(VB->ColorPtr[0], i); - if(tnl->render_inputs & _TNL_BIT_COLOR1) + if(render_inputs & _TNL_BIT_COLOR1) output_vector(VB->SecondaryColorPtr[0], i); - if(tnl->render_inputs & _TNL_BIT_FOG) + if(render_inputs & _TNL_BIT_FOG) output_vector(VB->FogCoordPtr, i); /* texture coordinates */ for(k=0;k < ctx->Const.MaxTextureUnits;k++) - if(tnl->render_inputs & (_TNL_BIT_TEX0<<k)) + if(render_inputs & (_TNL_BIT_TEX0<<k)) output_vector(VB->TexCoordPtr[k], i); - if(tnl->render_inputs & _TNL_BIT_INDEX) + if(render_inputs & _TNL_BIT_INDEX) output_vector(VB->IndexPtr[0], i); - if(tnl->render_inputs & _TNL_BIT_POINTSIZE) + if(render_inputs & _TNL_BIT_POINTSIZE) output_vector(VB->PointSizePtr, i); } @@ -290,12 +297,12 @@ static GLboolean r300_run_immediate_render(GLcontext *ctx, if (RADEON_DEBUG == DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__); - + #if 1 /* we need this, somehow */ /* Flush state - make sure command buffer is nice and large */ r300Flush(ctx); /* Make sure we have enough space */ - #else 0 + #else /* Count is very imprecize, but should be good upper bound */ r300EnsureCmdBufSpace(rmesa, rmesa->hw.max_state_size + 4+2+30 +VB->PrimitiveCount*(1+8)+VB->Count*4*rmesa->state.texture.tc_count+4, __FUNCTION__); diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index abd87728c94..5a577b2ce31 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -864,47 +864,42 @@ void r300_setup_routing(GLcontext *ctx, GLboolean immediate) /* All offsets are 0 - for use by immediate mode. Should change later to handle vertex buffers */ - if(r300->current_vp){ + if(r300->current_vp!=NULL){ /* VERT_ATTRIB_WEIGHT, VERT_ATTRIB_SIX, VERT_ATTRIB_SEVEN, VERT_ATTRIB_GENERIC0, VERT_ATTRIB_GENERIC1, VERT_ATTRIB_GENERIC2, VERT_ATTRIB_GENERIC3 */ - + r300->state.render_inputs = 0; + if(r300->current_vp->inputs[VERT_ATTRIB_POS] != -1){ - if(tnl->render_inputs & _TNL_BIT_POS){ - reg=r300->current_vp->inputs[VERT_ATTRIB_POS]; - CONFIGURE_AOS(VB->ObjPtr, 0, i_coords, AOS_FORMAT_FLOAT); - }else WARN_ONCE("vp expects pos but none was given\n"); + reg=r300->current_vp->inputs[VERT_ATTRIB_POS]; + CONFIGURE_AOS(VB->ObjPtr, 0, i_coords, AOS_FORMAT_FLOAT); + r300->state.render_inputs |= _TNL_BIT_POS; } if(r300->current_vp->inputs[VERT_ATTRIB_NORMAL] != -1){ - if(tnl->render_inputs & _TNL_BIT_NORMAL){ - reg=r300->current_vp->inputs[VERT_ATTRIB_NORMAL]; - CONFIGURE_AOS(VB->NormalPtr, 0, i_normal, AOS_FORMAT_FLOAT); - }else WARN_ONCE("vp expects normal but none was given\n"); + reg=r300->current_vp->inputs[VERT_ATTRIB_NORMAL]; + CONFIGURE_AOS(VB->NormalPtr, 0, i_normal, AOS_FORMAT_FLOAT); + r300->state.render_inputs |= _TNL_BIT_NORMAL; } if(r300->current_vp->inputs[VERT_ATTRIB_COLOR0] != -1){ - if(tnl->render_inputs & _TNL_BIT_COLOR0){ - reg=r300->current_vp->inputs[VERT_ATTRIB_COLOR0]; - CONFIGURE_AOS(VB->ColorPtr[0], 0, i_color[0], AOS_FORMAT_FLOAT_COLOR); - }else WARN_ONCE("vp expects primary color but none was given\n"); + reg=r300->current_vp->inputs[VERT_ATTRIB_COLOR0]; + CONFIGURE_AOS(VB->ColorPtr[0], 0, i_color[0], AOS_FORMAT_FLOAT_COLOR); + r300->state.render_inputs |= _TNL_BIT_COLOR0; } if(r300->current_vp->inputs[VERT_ATTRIB_COLOR1] != -1){ - if(tnl->render_inputs & _TNL_BIT_COLOR1){ - reg=r300->current_vp->inputs[VERT_ATTRIB_COLOR1]; - CONFIGURE_AOS(VB->SecondaryColorPtr[0], 0, i_color[1], AOS_FORMAT_FLOAT_COLOR); - }else WARN_ONCE("vp expects secondary color but none was given\n"); + reg=r300->current_vp->inputs[VERT_ATTRIB_COLOR1]; + CONFIGURE_AOS(VB->SecondaryColorPtr[0], 0, i_color[1], AOS_FORMAT_FLOAT_COLOR); + r300->state.render_inputs |= _TNL_BIT_COLOR1; } if(r300->current_vp->inputs[VERT_ATTRIB_FOG] != -1){ - if(tnl->render_inputs & _TNL_BIT_FOG){ - reg=r300->current_vp->inputs[VERT_ATTRIB_FOG]; - CONFIGURE_AOS(VB->FogCoordPtr, 0, i_fog, AOS_FORMAT_FLOAT); - }else WARN_ONCE("vp expects fog but none was given\n"); + reg=r300->current_vp->inputs[VERT_ATTRIB_FOG]; + CONFIGURE_AOS(VB->FogCoordPtr, 0, i_fog, AOS_FORMAT_FLOAT); + r300->state.render_inputs |= _TNL_BIT_FOG; } for(i=0;i < ctx->Const.MaxTextureUnits;i++) // tex 7 is last if(r300->current_vp->inputs[VERT_ATTRIB_TEX0+i] != -1){ - if(tnl->render_inputs & (_TNL_BIT_TEX0<<i)){ - reg=r300->current_vp->inputs[VERT_ATTRIB_TEX0+i]; - CONFIGURE_AOS(VB->TexCoordPtr[i], 0, i_tex[i], AOS_FORMAT_FLOAT); - }else fprintf(stderr, "vp expects tex%d but none was given\n", i); + reg=r300->current_vp->inputs[VERT_ATTRIB_TEX0+i]; + CONFIGURE_AOS(VB->TexCoordPtr[i], 0, i_tex[i], AOS_FORMAT_FLOAT); + r300->state.render_inputs |= _TNL_BIT_TEX0<<i; } #if 0 if((tnl->render_inputs & _TNL_BIT_INDEX)) @@ -915,6 +910,8 @@ void r300_setup_routing(GLcontext *ctx, GLboolean immediate) #endif }else{ + r300->state.render_inputs = tnl->render_inputs; + if(tnl->render_inputs & _TNL_BIT_POS) CONFIGURE_AOS(VB->ObjPtr, 0, i_coords, AOS_FORMAT_FLOAT); if(tnl->render_inputs & _TNL_BIT_NORMAL) @@ -941,7 +938,8 @@ void r300_setup_routing(GLcontext *ctx, GLboolean immediate) r300->state.aos_count=count; if (RADEON_DEBUG & DEBUG_STATE) - fprintf(stderr, "aos_count=%d\n", count); + fprintf(stderr, "aos_count=%d render_inputs=%08x\n", count, r300->state.render_inputs); + if(count>R300_MAX_AOS_ARRAYS){ fprintf(stderr, "Aieee ! AOS array count exceeded !\n"); @@ -1025,11 +1023,19 @@ void r300_setup_routing(GLcontext *ctx, GLboolean immediate) 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]=R300_INPUT_CNTL_POS - | R300_INPUT_CNTL_COLOR; + 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(ctx->Texture.Unit[i].Enabled) + if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)) r300->hw.vic.cmd[R300_VIC_CNTL_1]|=(R300_INPUT_CNTL_TC0<<i); /* Stage 3: VAP output */ @@ -1039,7 +1045,7 @@ void r300_setup_routing(GLcontext *ctx, GLboolean immediate) r300->hw.vof.cmd[R300_VOF_CNTL_1]=0; for(i=0;i < ctx->Const.MaxTextureUnits;i++) - if(ctx->Texture.Unit[i].Enabled) + if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)) r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i)); } @@ -1181,7 +1187,10 @@ void r300_setup_textures(GLcontext *ctx) exit(-1); } for(i=0;i<mtu;i++){ - if(ctx->Texture.Unit[i].Enabled){ + if( ((r300->state.render_inputs & (_TNL_BIT_TEX0<<i))!=0) != ((ctx->Texture.Unit[i].Enabled)!=0) ) { + WARN_ONCE("Mismatch between render_inputs and ctx->Texture.Unit[i].Enabled value.\n"); + } + if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)){ t=r300->state.texture.unit[i].texobj; //fprintf(stderr, "format=%08x\n", r300->state.texture.unit[i].format); r300->state.texture.tc_count++; @@ -1323,10 +1332,11 @@ void r300SetupVertexShader(r300ContextPtr rmesa) { GLcontext* ctx = rmesa->radeon.glCtx; - if(rmesa->current_vp){ + if(rmesa->current_vp != NULL){ r300SetupVertexProgram(rmesa); return ; } + /* Reset state, in case we don't use something */ ((drm_r300_cmd_header_t*)rmesa->hw.vpp.cmd)->vpu.count = 0; ((drm_r300_cmd_header_t*)rmesa->hw.vpi.cmd)->vpu.count = 0; @@ -1540,9 +1550,9 @@ void r300ResetHwState(r300ContextPtr r300) r300UpdateCulling(ctx); - r300_setup_routing(ctx, GL_TRUE); - r300UpdateTextureState(ctx); + + r300_setup_routing(ctx, GL_TRUE); r300_setup_textures(ctx); r300_setup_rs_unit(ctx); diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c index fd66c3e0af9..3cfa4793ebe 100644 --- a/src/mesa/drivers/dri/r300/r300_texmem.c +++ b/src/mesa/drivers/dri/r300/r300_texmem.c @@ -47,6 +47,7 @@ SOFTWARE. #include "radeon_reg.h" /* gets definition for usleep */ #include "r300_context.h" #include "r300_state.h" +#include "r300_cmdbuf.h" #include "radeon_ioctl.h" /* #include "r300_swtcl.h" diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index 09864ccad8e..76be5c649aa 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_context.h" #include "r300_state.h" +#include "r300_ioctl.h" #include "radeon_ioctl.h" //#include "r300_swtcl.h" #include "r300_tex.h" |