diff options
author | David Nusinow <[email protected]> | 2006-09-24 21:11:46 +0000 |
---|---|---|
committer | David Nusinow <[email protected]> | 2006-09-24 21:11:46 +0000 |
commit | eadb76b3f8e0e9b82da762bd29e53895bf9e6351 (patch) | |
tree | b9f68fc763f9ea055287c366e61de84191b200ce /src/mesa/drivers/dri/r300 | |
parent | b3f7313ae4f4cd418522595e90e7d06ef6992f0a (diff) |
Bump to latest mesa in Debian
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r-- | src/mesa/drivers/dri/r300/Makefile | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_cmdbuf.c | 23 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.c | 60 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 33 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_fragprog.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_ioctl.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_maos.c | 133 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_reg.h | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_render.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 172 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texmem.c | 18 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_vertexprog.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/radeon_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/radeon_span.c | 29 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c | 87 |
15 files changed, 469 insertions, 134 deletions
diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 3158ac8412b..5abb91d9876 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -5,7 +5,6 @@ TOP = ../../../../.. include $(TOP)/configs/current LIBNAME = r300_dri.so -DEFINES += -DCOMPILE_R300 -DGLX_DIRECT_RENDERING -DR200_MERGED=0 MINIGLX_SOURCES = server/radeon_dri.c @@ -70,7 +69,8 @@ C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES) X86_SOURCES = #r200_vtxtmp_x86.S -DEFINES += -DRADEON_COMMON=1 -DRADEON_COMMON_FOR_R300 +DRIVER_DEFINES = -DCOMPILE_R300 -DGLX_DIRECT_RENDERING -DR200_MERGED=0 \ + -DRADEON_COMMON=1 -DRADEON_COMMON_FOR_R300 SYMLINKS = \ server/radeon_dri.c \ diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 09f7669bd71..f39f71584ce 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -337,8 +337,10 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3); ALLOC_STATE( unk4274, always, 5, "unk4274", 0 ); r300->hw.unk4274.cmd[0] = cmdpacket0(0x4274, 4); - ALLOC_STATE( unk4288, always, 6, "unk4288", 0 ); - r300->hw.unk4288.cmd[0] = cmdpacket0(0x4288, 5); + ALLOC_STATE( unk4288, always, 4, "unk4288", 0 ); + r300->hw.unk4288.cmd[0] = cmdpacket0(0x4288, 3); + ALLOC_STATE( fogp, always, 3, "fogp", 0 ); + r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2); ALLOC_STATE( unk42A0, always, 2, "unk42A0", 0 ); r300->hw.unk42A0.cmd[0] = cmdpacket0(0x42A0, 1); ALLOC_STATE( zbs, always, R300_ZBS_CMDSIZE, "zbs", 0 ); @@ -374,10 +376,10 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, 1); ALLOC_STATE( fpi[3], variable, R300_FPI_CMDSIZE, "fpi/3", 3 ); r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, 1); - ALLOC_STATE( unk4BC0, always, 2, "unk4BC0", 0 ); - r300->hw.unk4BC0.cmd[0] = cmdpacket0(0x4BC0, 1); - ALLOC_STATE( unk4BC8, always, 4, "unk4BC8", 0 ); - r300->hw.unk4BC8.cmd[0] = cmdpacket0(0x4BC8, 3); + ALLOC_STATE( fogs, always, R300_FOGS_CMDSIZE, "fogs", 0 ); + r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_RE_FOG_STATE, 1); + ALLOC_STATE( fogc, always, R300_FOGC_CMDSIZE, "fogc", 0 ); + r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FOG_COLOR_R, 3); ALLOC_STATE( at, always, R300_AT_CMDSIZE, "at", 0 ); r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_PP_ALPHA_TEST, 2); ALLOC_STATE( unk4BD8, always, 2, "unk4BD8", 0 ); @@ -478,6 +480,7 @@ void r300InitCmdBuf(r300ContextPtr r300) insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4260); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4274); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4288); + insert_at_tail(&r300->hw.atomlist, &r300->hw.fogp); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42A0); insert_at_tail(&r300->hw.atomlist, &r300->hw.zbs); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42B4); @@ -495,8 +498,8 @@ void r300InitCmdBuf(r300ContextPtr r300) insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[1]); insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[2]); insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[3]); - insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BC0); - insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BC8); + insert_at_tail(&r300->hw.atomlist, &r300->hw.fogs); + insert_at_tail(&r300->hw.atomlist, &r300->hw.fogc); insert_at_tail(&r300->hw.atomlist, &r300->hw.at); insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BD8); insert_at_tail(&r300->hw.atomlist, &r300->hw.fpp); @@ -541,9 +544,9 @@ void r300InitCmdBuf(r300ContextPtr r300) size = 64*256; if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA)) { - fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%d\n", + fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%ld\n", sizeof(drm_r300_cmd_header_t)); - fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%d\n", + fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%ld\n", sizeof(drm_radeon_cmd_buffer_t)); fprintf(stderr, "Allocating %d bytes command buffer (max state is %d bytes)\n", diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 4943d549973..cadb27ba8b9 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -372,6 +372,61 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, return GL_TRUE; } +static void r300FreeGartAllocations(r300ContextPtr r300) +{ + int i, ret, tries=0, done_age; + drm_radeon_mem_free_t memfree; + + memfree.region = RADEON_MEM_REGION_GART; + +#ifdef USER_BUFFERS + done_age = radeonGetAge((radeonContextPtr)r300); + + for (i = r300->rmm->u_last; i > 0; i--) { + if (r300->rmm->u_list[i].ptr == NULL) { + continue; + } + + assert(r300->rmm->u_list[i].pending); + assert(r300->rmm->u_list[i].h_pending == 0); + + tries = 0; + while(r300->rmm->u_list[i].age > done_age && tries++ < 1000) { + usleep(10); + done_age = radeonGetAge((radeonContextPtr)r300); + } + if (tries >= 1000) { + WARN_ONCE("Failed to idle region!"); + } + + memfree.region_offset = (char *)r300->rmm->u_list[i].ptr - + (char *)r300->radeon.radeonScreen->gartTextures.map; + + ret = drmCommandWrite(r300->radeon.radeonScreen->driScreen->fd, + DRM_RADEON_FREE, &memfree, sizeof(memfree)); + if (ret) { + fprintf(stderr, "Failed to free at %p\nret = %s\n", + r300->rmm->u_list[i].ptr, strerror(-ret)); + } else { + if (i == r300->rmm->u_last) + r300->rmm->u_last--; + + r300->rmm->u_list[i].pending = 0; + r300->rmm->u_list[i].ptr = NULL; + if (r300->rmm->u_list[i].fb) { + LOCK_HARDWARE(&(r300->radeon)); + ret = mmFreeMem(r300->rmm->u_list[i].fb); + UNLOCK_HARDWARE(&(r300->radeon)); + if (ret) fprintf(stderr, "failed to free!\n"); + r300->rmm->u_list[i].fb = NULL; + } + r300->rmm->u_list[i].ref_count = 0; + } + } + r300->rmm->u_head = i; +#endif /* USER_BUFFERS */ +} + /* Destroy the device specific context. */ void r300DestroyContext(__DRIcontextPrivate * driContextPriv) @@ -403,12 +458,11 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv) _ac_DestroyContext(r300->radeon.glCtx); _swrast_DestroyContext(r300->radeon.glCtx); - r300ReleaseArrays(r300->radeon.glCtx); if (r300->dma.current.buf) { r300ReleaseDmaRegion(r300, &r300->dma.current, __FUNCTION__ ); - r300FlushCmdBuf(r300, __FUNCTION__ ); } - + r300FlushCmdBuf(r300, __FUNCTION__); + r300FreeGartAllocations(r300); r300DestroyCmdBuf(r300); if (radeon->state.scissor.pClipRects) { diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 176341d7715..7ff805fd5d3 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -47,11 +47,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "colormac.h" #include "radeon_context.h" -/* PPC doesnt support 16 bit elts ... */ -#ifndef MESA_BIG_ENDIAN #define USER_BUFFERS #define RADEON_VTXFMT_A #define HW_VBOS + +/* We don't handle 16 bits elts swapping yet */ +#ifdef MESA_BIG_ENDIAN +#define FORCE_32BITS_ELTS #endif //#define OPTIMIZE_ELTS @@ -346,6 +348,21 @@ struct r300_state_atom { #define R300_FPP_PARAM_0 1 #define R300_FPP_CMDSIZE (32*4+1) +#define R300_FOGS_CMD_0 0 +#define R300_FOGS_STATE 1 +#define R300_FOGS_CMDSIZE 2 + +#define R300_FOGC_CMD_0 0 +#define R300_FOGC_R 1 +#define R300_FOGC_G 2 +#define R300_FOGC_B 3 +#define R300_FOGC_CMDSIZE 4 + +#define R300_FOGP_CMD_0 0 +#define R300_FOGP_SCALE 1 +#define R300_FOGP_START 2 +#define R300_FOGP_CMDSIZE 3 + #define R300_AT_CMD_0 0 #define R300_AT_ALPHA_TEST 1 #define R300_AT_UNKNOWN 2 @@ -432,6 +449,8 @@ struct r300_hw_state { struct r300_state_atom unk4260; /* (4260) */ struct r300_state_atom unk4274; /* (4274) */ struct r300_state_atom unk4288; /* (4288) */ + struct r300_state_atom fogp; /* fog parameters (4294) */ + struct r300_state_atom unk429C; /* (429C) */ struct r300_state_atom unk42A0; /* (42A0) */ struct r300_state_atom zbs; /* zbias (42A4) */ struct r300_state_atom unk42B4; /* (42B4) */ @@ -446,8 +465,8 @@ struct r300_hw_state { struct r300_state_atom fpt; /* texi - (4620) */ struct r300_state_atom unk46A4; /* (46A4) */ struct r300_state_atom fpi[4]; /* fp instructions (46C0/47C0/48C0/49C0) */ - struct r300_state_atom unk4BC0; /* (4BC0) */ - struct r300_state_atom unk4BC8; /* (4BC8) */ + struct r300_state_atom fogs; /* fog state (4BC0) */ + struct r300_state_atom fogc; /* fog color (4BC8) */ struct r300_state_atom at; /* alpha test (4BD4) */ struct r300_state_atom unk4BD8; /* (4BD8) */ struct r300_state_atom fpp; /* 0x4C00 and following */ @@ -532,7 +551,8 @@ struct r300_vap_reg_state { /* Vertex shader state */ /* Perhaps more if we store programs in vmem? */ -#define VSF_MAX_FRAGMENT_LENGTH (256*4) +/* drm_r300_cmd_header_t->vpu->count is unsigned char */ +#define VSF_MAX_FRAGMENT_LENGTH (255*4) /* Can be tested with colormat currently. */ #define VSF_MAX_FRAGMENT_TEMPS (14) @@ -759,7 +779,7 @@ struct r300_state { GLuint *Elts; struct r300_dma_region elt_dma; - GLuint render_inputs; /* actual render inputs that R300 was configured for. + DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for. They are the same as tnl->render_inputs for fixed pipeline */ struct { @@ -810,6 +830,7 @@ struct r300_context { #endif GLboolean texmicrotile; + GLboolean span_dlocking; }; struct r300_buffer_object { diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c index db509059dd7..e045f0c6a1e 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog.c @@ -1039,7 +1039,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp) const struct prog_instruction *inst = mp->Base.Instructions; struct prog_instruction *fpi; pfs_reg_t src[3], dest, temp; - int flags, mask; + int flags, mask = 0; if (!inst || inst[0].Opcode == OPCODE_END) { ERROR("empty program?\n"); diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 0115d622a99..159285962d2 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -380,10 +380,16 @@ static void r300EmitClearState(GLcontext * ctx) int i; LOCAL_VARS; + R300_STATECHANGE(r300, vir[0]); reg_start(R300_VAP_INPUT_ROUTE_0_0, 0); e32(0x21030003); + /* disable fog */ + R300_STATECHANGE(r300, fogs); + reg_start(R300_RE_FOG_STATE, 0); + e32(0x0); + R300_STATECHANGE(r300, vir[1]); reg_start(R300_VAP_INPUT_ROUTE_1_0, 0); e32(0xF688F688); @@ -553,7 +559,7 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask, GLboolean all, #ifdef CB_DPATH /* Make sure it fits there. */ - r300EnsureCmdBufSpace(r300, 419*3, __FUNCTION__); + r300EnsureCmdBufSpace(r300, 421*3, __FUNCTION__); if(flags || bits) r300EmitClearState(ctx); #endif diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c index 1aa005c7207..6b8365e6d9e 100644 --- a/src/mesa/drivers/dri/r300/r300_maos.c +++ b/src/mesa/drivers/dri/r300/r300_maos.c @@ -252,6 +252,43 @@ void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts, int elt_siz memcpy(out, elts, n_elts * elt_size); } + /* 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)) + + +static GLuint t_comps(GLuint aos_size) +{ + GLuint mask; + mask = (1 << (aos_size*3)) - 1; + return (ALL_COMPONENTS & mask) | (ALL_DEFAULT & ~mask); +} + +static GLuint fix_comps(GLuint dw, int fmt) +{ +#ifdef MESA_BIG_ENDIAN + if (fmt == 2) { + GLuint dw_temp = 0; + + dw_temp |= ((dw >> R300_INPUT_ROUTE_X_SHIFT) & R300_INPUT_ROUTE_SELECT_MASK) << R300_INPUT_ROUTE_W_SHIFT; + dw_temp |= ((dw >> R300_INPUT_ROUTE_Y_SHIFT) & R300_INPUT_ROUTE_SELECT_MASK) << R300_INPUT_ROUTE_Z_SHIFT; + dw_temp |= ((dw >> R300_INPUT_ROUTE_Z_SHIFT) & R300_INPUT_ROUTE_SELECT_MASK) << R300_INPUT_ROUTE_Y_SHIFT; + dw_temp |= ((dw >> R300_INPUT_ROUTE_W_SHIFT) & R300_INPUT_ROUTE_SELECT_MASK) << R300_INPUT_ROUTE_X_SHIFT; + + return dw_temp; + } +#endif /* MESA_BIG_ENDIAN */ + return dw; + +} + /* Emit vertex data to GART memory (unless immediate mode) * Route inputs to the vertex processor */ @@ -264,12 +301,14 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) //struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLuint nr = 0; GLuint count = VB->Count; - GLuint dw,mask; + GLuint dw; GLuint vic_1 = 0; /* R300_VAP_INPUT_CNTL_1 */ GLuint aa_vap_reg = 0; /* VAP register assignment */ GLuint i; - GLuint inputs = 0; - + DECLARE_RENDERINPUTS(inputs_bitset); + + RENDERINPUTS_ZERO( inputs_bitset ); + #define CONFIGURE_AOS(r, f, v, sz, cn) { \ if (RADEON_DEBUG & DEBUG_STATE) \ fprintf(stderr, "Enabling "#v "\n"); \ @@ -300,23 +339,23 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) 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; + RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_POS ); rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_POS]; } if (InputsRead & (1<<VERT_ATTRIB_NORMAL)) { - inputs |= _TNL_BIT_NORMAL; + RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_NORMAL ); rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_NORMAL]; } if (InputsRead & (1<<VERT_ATTRIB_COLOR0)) { - inputs |= _TNL_BIT_COLOR0; + RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_COLOR0 ); rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR0]; } if (InputsRead & (1<<VERT_ATTRIB_COLOR1)) { - inputs |= _TNL_BIT_COLOR1; + RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_COLOR1 ); rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR1]; } if (InputsRead & (1<<VERT_ATTRIB_FOG)) { - inputs |= _TNL_BIT_FOG; + RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_FOG ); rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_FOG]; } if(ctx->Const.MaxTextureUnits > 8) { /* Not sure if this can even happen... */ @@ -325,17 +364,17 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) } for (i=0;i<ctx->Const.MaxTextureUnits;i++) { if (InputsRead & (1<<(VERT_ATTRIB_TEX0+i))) { - inputs |= _TNL_BIT_TEX0<<i; + RENDERINPUTS_SET( inputs_bitset, _TNL_ATTRIB_TEX(i) ); rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_TEX0+i]; } } nr = 0; } else { - inputs = TNL_CONTEXT(ctx)->render_inputs; + RENDERINPUTS_COPY( inputs_bitset, TNL_CONTEXT(ctx)->render_inputs_bitset ); } - rmesa->state.render_inputs = inputs; + RENDERINPUTS_COPY( rmesa->state.render_inputs_bitset, inputs_bitset ); - if (inputs & _TNL_BIT_POS) { + if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_POS )) { CONFIGURE_AOS(i_coords, AOS_FORMAT_FLOAT, VB->AttribPtr[VERT_ATTRIB_POS], immd ? 4 : VB->AttribPtr[VERT_ATTRIB_POS].size, @@ -344,7 +383,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) vic_1 |= R300_INPUT_CNTL_POS; } - if (inputs & _TNL_BIT_NORMAL) { + if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_NORMAL )) { CONFIGURE_AOS(i_normal, AOS_FORMAT_FLOAT, VB->AttribPtr[VERT_ATTRIB_NORMAL], immd ? 4 : VB->AttribPtr[VERT_ATTRIB_NORMAL].size, @@ -353,7 +392,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) vic_1 |= R300_INPUT_CNTL_NORMAL; } - if (inputs & _TNL_BIT_COLOR0) { + if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR0 )) { int emitsize=4; if (!immd) { @@ -376,7 +415,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) vic_1 |= R300_INPUT_CNTL_COLOR; } - if (inputs & _TNL_BIT_COLOR1) { + if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR1 )) { int emitsize=4; if (!immd) { @@ -398,7 +437,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) } #if 0 - if (inputs & _TNL_BIT_FOG) { + if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_FOG )) { CONFIGURE_AOS( AOS_FORMAT_FLOAT, VB->FogCoordPtr, immd ? 4 : VB->FogCoordPtr->size, @@ -408,7 +447,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) r300->state.texture.tc_count = 0; for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (inputs & (_TNL_BIT_TEX0 << i)) { + if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_TEX(i) )) { CONFIGURE_AOS(i_tex[i], AOS_FORMAT_FLOAT, VB->AttribPtr[VERT_ATTRIB_TEX0+i], immd ? 4 : VB->AttribPtr[VERT_ATTRIB_TEX0+i].size, @@ -467,17 +506,6 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) ((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 < nr; i++) @@ -486,33 +514,22 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) r300->state.aos[i].aos_size=/*3*/4; /* XXX */ } - - for(i=0;i+1<nr;i+=2){ + 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; - + dw = fix_comps(t_comps(r300->state.aos[i].aos_size), r300->state.aos[i].aos_format) | 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; - + dw |= (fix_comps(t_comps(r300->state.aos[i+1].aos_size), r300->state.aos[i+1].aos_format) | R300_INPUT_ROUTE_ENABLE) << 16; + //fprintf(stderr, "vir1 dw=%08x\n", dw); 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; + } + if (nr & 1) { + dw = fix_comps(t_comps(r300->state.aos[nr-1].aos_size), r300->state.aos[nr-1].aos_format) | R300_INPUT_ROUTE_ENABLE; + //fprintf(stderr, "vir1 dw=%08x\n", dw); - } + r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(nr>>1)]=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; @@ -531,17 +548,17 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) #if 0 r300->hw.vic.cmd[R300_VIC_CNTL_1]=0; - if(r300->state.render_inputs & _TNL_BIT_POS) + if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_POS )) r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_POS; - if(r300->state.render_inputs & _TNL_BIT_NORMAL) + if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_NORMAL )) r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_NORMAL; - if(r300->state.render_inputs & _TNL_BIT_COLOR0) + if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_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)) + if(RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_TEX(i) )) r300->hw.vic.cmd[R300_VIC_CNTL_1]|=(R300_INPUT_CNTL_TC0<<i); #endif @@ -573,15 +590,15 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) if(OutputsWritten & (1<<(VERT_RESULT_TEX0+i))) r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4<<(3*i)); } else { - if(inputs & _TNL_BIT_POS) + if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_POS )) r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; - if(inputs & _TNL_BIT_COLOR0) + if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR0 )) r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; - if(inputs & _TNL_BIT_COLOR1) + if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_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)) + if(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_TEX(i) )) r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i)); } diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index c78462af2ed..4afe4f239c2 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -517,6 +517,10 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_PM_BACK_LINE (1 << 7) # define R300_PM_BACK_FILL (1 << 8) +/* Fog parameters */ +#define R300_RE_FOG_SCALE 0x4294 +#define R300_RE_FOG_START 0x4298 + /* Not sure why there are duplicate of factor and constant values. My best guess so far is that there are seperate zbiases for test and write. Ordering might be wrong. @@ -1113,7 +1117,17 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_FPI2_UNKNOWN_31 (1 << 31) /* END */ -/* gap */ +/* Fog state and color */ +#define R300_RE_FOG_STATE 0x4BC0 +# define R300_FOG_ENABLE (1 << 0) +# define R300_FOG_MODE_LINEAR (0 << 1) +# define R300_FOG_MODE_EXP (1 << 1) +# define R300_FOG_MODE_EXP2 (2 << 1) +# define R300_FOG_MODE_MASK (3 << 1) +#define R300_FOG_COLOR_R 0x4BC8 +#define R300_FOG_COLOR_G 0x4BCC +#define R300_FOG_COLOR_B 0x4BD0 + #define R300_PP_ALPHA_TEST 0x4BD4 # define R300_REF_ALPHA_MASK 0x000000ff # define R300_ALPHA_TEST_FAIL (0 << 8) diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index a0375f90227..f86a439bc29 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -382,7 +382,6 @@ GLboolean r300_run_vb_render(GLcontext *ctx, r300UpdateShaders(rmesa); if (rmesa->state.VB.LockCount == 0 || 1) { - r300ReleaseArrays(ctx); r300EmitArrays(ctx, GL_FALSE); r300UpdateShaderStates(rmesa); @@ -446,6 +445,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx, #ifdef USER_BUFFERS r300UseArrays(ctx); #endif + r300ReleaseArrays(ctx); return GL_FALSE; } @@ -462,19 +462,19 @@ int r300Fallback(GLcontext *ctx) { int i; - //FALLBACK_IF(ctx->RenderMode != GL_RENDER); // We do not do SELECT or FEEDBACK (yet ?) + FALLBACK_IF(ctx->RenderMode != GL_RENDER); // We do not do SELECT or FEEDBACK (yet ?) #if 0 /* These should work now.. */ FALLBACK_IF(ctx->Color.DitherFlag); FALLBACK_IF(ctx->Color.AlphaEnabled); // GL_ALPHA_TEST FALLBACK_IF(ctx->Color.BlendEnabled); // GL_BLEND FALLBACK_IF(ctx->Polygon.OffsetFill); // GL_POLYGON_OFFSET_FILL + FALLBACK_IF(ctx->Fog.Enabled); #endif FALLBACK_IF(ctx->Polygon.OffsetPoint); // GL_POLYGON_OFFSET_POINT FALLBACK_IF(ctx->Polygon.OffsetLine); // GL_POLYGON_OFFSET_LINE //FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST - //FALLBACK_IF(ctx->Fog.Enabled); // GL_FOG disable as swtcl doesnt seem to support this //FALLBACK_IF(ctx->Polygon.SmoothFlag); // GL_POLYGON_SMOOTH disabling to get blender going FALLBACK_IF(ctx->Polygon.StippleFlag); // GL_POLYGON_STIPPLE FALLBACK_IF(ctx->Multisample.Enabled); // GL_MULTISAMPLE_ARB diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index d4dafe62a73..70d42c2ea3b 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -417,6 +417,24 @@ static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state) case GL_TEXTURE_3D: break; + case GL_FOG: + R300_STATECHANGE(r300, fogs); + if (state) { + r300->hw.fogs.cmd[R300_FOGS_STATE] |= + R300_FOG_ENABLE; + + ctx->Driver.Fogfv( ctx, GL_FOG_MODE, NULL ); + ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); + ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start ); + ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End ); + ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color ); + } else { + r300->hw.fogs.cmd[R300_FOGS_STATE] &= + ~R300_FOG_ENABLE; + } + + break; + case GL_ALPHA_TEST: R300_STATECHANGE(r300, at); if (state) { @@ -640,6 +658,101 @@ static void r300ColorMask(GLcontext* ctx, } /* ============================================================= + * Fog + */ +static void r300Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) +{ + r300ContextPtr r300 = R300_CONTEXT(ctx); + union { int i; float f; } fogScale, fogStart; + + (void) param; + + fogScale.i = r300->hw.fogp.cmd[R300_FOGP_SCALE]; + fogStart.i = r300->hw.fogp.cmd[R300_FOGP_START]; + + switch (pname) { + case GL_FOG_MODE: + if (!ctx->Fog.Enabled) + return; + switch (ctx->Fog.Mode) { + case GL_LINEAR: + R300_STATECHANGE(r300, fogs); + r300->hw.fogs.cmd[R300_FOGS_STATE] = + (r300->hw.fogs.cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) | R300_FOG_MODE_LINEAR; + + if (ctx->Fog.Start == ctx->Fog.End) { + fogScale.f = -1.0; + fogStart.f = 1.0; + } + else { + fogScale.f = 1.0 / (ctx->Fog.End-ctx->Fog.Start); + fogStart.f = -ctx->Fog.Start / (ctx->Fog.End-ctx->Fog.Start); + } + break; + case GL_EXP: + R300_STATECHANGE(r300, fogs); + r300->hw.fogs.cmd[R300_FOGS_STATE] = + (r300->hw.fogs.cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) | R300_FOG_MODE_EXP; + fogScale.f = 0.0933*ctx->Fog.Density; + fogStart.f = 0.0; + break; + case GL_EXP2: + R300_STATECHANGE(r300, fogs); + r300->hw.fogs.cmd[R300_FOGS_STATE] = + (r300->hw.fogs.cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) | R300_FOG_MODE_EXP2; + fogScale.f = 0.3*ctx->Fog.Density; + fogStart.f = 0.0; + default: + return; + } + break; + case GL_FOG_DENSITY: + switch (ctx->Fog.Mode) { + case GL_EXP: + fogScale.f = 0.0933*ctx->Fog.Density; + fogStart.f = 0.0; + break; + case GL_EXP2: + fogScale.f = 0.3*ctx->Fog.Density; + fogStart.f = 0.0; + default: + break; + } + break; + case GL_FOG_START: + case GL_FOG_END: + if (ctx->Fog.Mode == GL_LINEAR) { + if (ctx->Fog.Start == ctx->Fog.End) { + fogScale.f = -1.0; + fogStart.f = 1.0; + } + else { + fogScale.f = 1.0 / (ctx->Fog.End-ctx->Fog.Start); + fogStart.f = -ctx->Fog.Start / (ctx->Fog.End-ctx->Fog.Start); + } + } + break; + case GL_FOG_COLOR: + R300_STATECHANGE(r300, fogc); + r300->hw.fogc.cmd[R300_FOGC_R] = (GLuint) (ctx->Fog.Color[0]*1023.0F) & 0x3FF; + r300->hw.fogc.cmd[R300_FOGC_G] = (GLuint) (ctx->Fog.Color[1]*1023.0F) & 0x3FF; + r300->hw.fogc.cmd[R300_FOGC_B] = (GLuint) (ctx->Fog.Color[2]*1023.0F) & 0x3FF; + break; + case GL_FOG_COORD_SRC: + break; + default: + return; + } + + if (fogScale.i != r300->hw.fogp.cmd[R300_FOGP_SCALE] || + fogStart.i != r300->hw.fogp.cmd[R300_FOGP_START]) { + R300_STATECHANGE(r300, fogp); + r300->hw.fogp.cmd[R300_FOGP_SCALE] = fogScale.i; + r300->hw.fogp.cmd[R300_FOGP_START] = fogStart.i; + } +} + +/* ============================================================= * Point state */ static void r300PointSize(GLcontext * ctx, GLfloat size) @@ -750,8 +863,8 @@ static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face, GLenum func, GLint ref, GLuint mask) { r300ContextPtr rmesa = R300_CONTEXT(ctx); - GLuint refmask = ((ctx->Stencil.Ref[0] << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | - (ctx->Stencil.ValueMask[0] << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); + GLuint refmask = (((ctx->Stencil.Ref[0] & 0xff) << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | + ((ctx->Stencil.ValueMask[0] & 0xff) << R300_RB3D_ZS2_STENCIL_MASK_SHIFT)); GLuint flag; @@ -777,7 +890,7 @@ static void r300StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask) R300_STATECHANGE(rmesa, zs); rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~(R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT); - rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT; + rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= (ctx->Stencil.WriteMask[0] & 0xff) << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT; } @@ -807,9 +920,9 @@ static void r300ClearStencil(GLcontext * ctx, GLint s) r300ContextPtr rmesa = R300_CONTEXT(ctx); rmesa->state.stencil.clear = - ((GLuint) ctx->Stencil.Clear | + ((GLuint) (ctx->Stencil.Clear & 0xff) | (R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT) | - (ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT)); + ((ctx->Stencil.WriteMask[0] & 0xff) << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT)); } /* ============================================================= @@ -1157,6 +1270,15 @@ void r300_setup_textures(GLcontext *ctx) fprintf(stderr, "TX_ENABLE: %08x last_hw_tmu=%d\n", r300->hw.txe.cmd[R300_TXE_ENABLE], last_hw_tmu); } +union r300_outputs_written { + GLuint vp_outputs; /* hw_tcl_on */ + DECLARE_RENDERINPUTS(index_bitset); /* !hw_tcl_on */ +}; + +#define R300_OUTPUTS_WRITTEN_TEST(ow, vp_result, tnl_attrib) \ + ((hw_tcl_on) ? (ow).vp_outputs & (1 << (vp_result)) : \ + RENDERINPUTS_TEST( (ow.index_bitset), (tnl_attrib) )) + void r300_setup_rs_unit(GLcontext *ctx) { r300ContextPtr r300 = R300_CONTEXT(ctx); @@ -1171,16 +1293,16 @@ void r300_setup_rs_unit(GLcontext *ctx) 0x00, 0x00 }; - GLuint OutputsWritten; + union r300_outputs_written OutputsWritten; GLuint InputsRead; int fp_reg, high_rr; int in_texcoords, col_interp_nr; int i; if(hw_tcl_on) - OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten; + OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten; else - OutputsWritten = r300->state.render_inputs; + RENDERINPUTS_COPY( OutputsWritten.index_bitset, r300->state.render_inputs_bitset ); if (ctx->FragmentProgram._Current) InputsRead = ctx->FragmentProgram._Current->Base.InputsRead; @@ -1211,7 +1333,7 @@ void r300_setup_rs_unit(GLcontext *ctx) | (fp_reg << R300_RS_ROUTE_DEST_SHIFT); high_rr = fp_reg; - if (!(OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i)))) { + if (!R300_OUTPUTS_WRITTEN_TEST( OutputsWritten, VERT_RESULT_TEX0+i, _TNL_ATTRIB_TEX(i) )) { /* Passing invalid data here can lock the GPU. */ WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i); //_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base); @@ -1221,12 +1343,12 @@ void r300_setup_rs_unit(GLcontext *ctx) fp_reg++; } /* Need to count all coords enabled at vof */ - if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i))) + if (R300_OUTPUTS_WRITTEN_TEST( OutputsWritten, VERT_RESULT_TEX0+i, _TNL_ATTRIB_TEX(i) )) in_texcoords++; } if (InputsRead & FRAG_BIT_COL0) { - if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL0) : _TNL_BIT_COLOR0))) { + if (!R300_OUTPUTS_WRITTEN_TEST( OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0 )) { WARN_ONCE("fragprog wants col0, vp doesn't provide it\n"); goto out; /* FIXME */ //_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base); @@ -1242,7 +1364,7 @@ void r300_setup_rs_unit(GLcontext *ctx) out: if (InputsRead & FRAG_BIT_COL1) { - if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL1) : _TNL_BIT_COLOR1))) { + if (!R300_OUTPUTS_WRITTEN_TEST( OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1 )) { WARN_ONCE("fragprog wants col1, vp doesn't provide it\n"); //exit(-1); } @@ -1281,6 +1403,7 @@ void r300_setup_rs_unit(GLcontext *ctx) #define bump_vpu_count(ptr, new_count) do{\ drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\ int _nc=(new_count)/4; \ + assert(_nc < 256); \ if(_nc>_p->vpu.count)_p->vpu.count=_nc;\ }while(0) @@ -1402,7 +1525,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) ) o_reg += 2; - if (r300->state.render_inputs & _TNL_BIT_COLOR1) { + if (RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_COLOR1 )) { WRITE_OP( EASY_VSF_OP(MUL, o_reg++, ALL, RESULT), VSF_REG(r300->state.vap_reg.i_color[1]), @@ -1413,7 +1536,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) /* 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)){ + if (RENDERINPUTS_TEST( r300->state.render_inputs_bitset, _TNL_ATTRIB_TEX(i) )){ // fprintf(stderr, "i_tex[%d]=%d\n", i, r300->state.vap_reg.i_tex[i]); WRITE_OP( EASY_VSF_OP(MUL, o_reg++ /* 2+i */, ALL, RESULT), @@ -1870,7 +1993,8 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV300 | R300_GB_TILE_SIZE_16; - r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = 0x00000000; + /* set to 0 when fog is disabled? */ + r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = R300_GB_FOG_SELECT_1_1_W; r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = 0x00000000; /* No antialiasing */ //r300->hw.txe.cmd[R300_TXE_ENABLE] = 0; @@ -1907,9 +2031,6 @@ void r300ResetHwState(r300ContextPtr r300) r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode); r300->hw.unk4288.cmd[2] = 0x00000001; r300->hw.unk4288.cmd[3] = 0x00000000; - r300->hw.unk4288.cmd[4] = 0x00000000; - r300->hw.unk4288.cmd[5] = 0x00000000; - r300->hw.unk42A0.cmd[1] = 0x00000000; r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor, ctx->Polygon.OffsetUnits); @@ -1949,13 +2070,13 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.fpi[3].cmd[i] = FP_SELA(0,W,NO,FP_TMP(0),0,0); } #endif - - r300->hw.unk4BC0.cmd[1] = 0; - - r300->hw.unk4BC8.cmd[1] = 0; - r300->hw.unk4BC8.cmd[2] = 0; - r300->hw.unk4BC8.cmd[3] = 0; - + r300Enable(ctx, GL_FOG, ctx->Fog.Enabled); + ctx->Driver.Fogfv( ctx, GL_FOG_MODE, NULL ); + ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); + ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start ); + ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End ); + ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color ); + ctx->Driver.Fogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL ); r300->hw.at.cmd[R300_AT_UNKNOWN] = 0; r300->hw.unk4BD8.cmd[1] = 0; @@ -2128,6 +2249,7 @@ void r300InitStateFuncs(struct dd_function_table* functions) functions->DepthFunc = r300DepthFunc; functions->DepthMask = r300DepthMask; functions->CullFace = r300CullFace; + functions->Fogfv = r300Fogfv; functions->FrontFace = r300FrontFace; functions->ShadeModel = r300ShadeModel; diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c index a9f64b47c4c..c1d01020cdb 100644 --- a/src/mesa/drivers/dri/r300/r300_texmem.c +++ b/src/mesa/drivers/dri/r300/r300_texmem.c @@ -130,6 +130,12 @@ static void r300UploadGARTClientSubImage(r300ContextPtr rmesa, srcPitch = t->image[0][0].width * texFormat->TexelBytes; dstPitch = t->image[0][0].width * texFormat->TexelBytes; break; + case 8: + case 16: + blit_format = R200_CP_COLOR_FORMAT_CI8; + srcPitch = t->image[0][0].width * texFormat->TexelBytes; + dstPitch = t->image[0][0].width * texFormat->TexelBytes; + break; default: return; } @@ -144,6 +150,10 @@ static void r300UploadGARTClientSubImage(r300ContextPtr rmesa, width = texImage->Width; height = texImage->Height; + if (texFormat->TexelBytes > 4) { + width *= texFormat->TexelBytes; + } + r300EmitWait(rmesa, R300_WAIT_3D); r300EmitBlit(rmesa, blit_format, @@ -177,6 +187,10 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa, case 4: blit_format = R200_CP_COLOR_FORMAT_ARGB8888; break; + case 8: + case 16: + blit_format = R200_CP_COLOR_FORMAT_CI8; + break; default: return; } @@ -189,6 +203,10 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa, height = texImage->Height; dstPitch = t->pitch; + if (texFormat->TexelBytes > 4) { + width *= texFormat->TexelBytes; + } + if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) { /* In this case, could also use GART texturing. This is * currently disabled, but has been tested & works. diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertexprog.c index f794c9aa67a..9e32cfcfef9 100644 --- a/src/mesa/drivers/dri/r300/r300_vertexprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertexprog.c @@ -916,6 +916,16 @@ void r300_translate_vertex_shader(struct r300_vertex_program *vp) fprintf(stderr, "Dont know how to handle op %d yet\n", vpi->Opcode); exit(-1); break; + case OPCODE_SWZ: + hw_op=(src[0].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; + + o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); + o_inst->src1=t_src(vp, &src[0]); + o_inst->src2=ONE_SRC_0; + o_inst->src3=ZERO_SRC_0; + + goto next; case OPCODE_END: break; default: diff --git a/src/mesa/drivers/dri/r300/radeon_context.c b/src/mesa/drivers/dri/r300/radeon_context.c index 4e351dd66b0..0147c6492e5 100644 --- a/src/mesa/drivers/dri/r300/radeon_context.c +++ b/src/mesa/drivers/dri/r300/radeon_context.c @@ -76,7 +76,7 @@ static const GLubyte *radeonGetString(GLcontext * ctx, GLenum name) case GL_RENDERER: { unsigned offset; - GLuint agp_mode = radeon->radeonScreen->IsPCI ? 0 : + GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 : radeon->radeonScreen->AGPMode; const char* chipname; diff --git a/src/mesa/drivers/dri/r300/radeon_span.c b/src/mesa/drivers/dri/r300/radeon_span.c index 1f000b97666..1b74f6779b4 100644 --- a/src/mesa/drivers/dri/r300/radeon_span.c +++ b/src/mesa/drivers/dri/r300/radeon_span.c @@ -40,7 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell <[email protected]> * */ - +#include <unistd.h> #include "glheader.h" #include "imports.h" #include "swrast/swrast.h" @@ -252,6 +252,29 @@ do { \ static void radeonSpanRenderStart( GLcontext *ctx ) { radeonContextPtr rmesa = RADEON_CONTEXT( ctx ); + { + static int first = 1; + r300ContextPtr r300 = (r300ContextPtr)rmesa; + + if (first) { + r300->span_dlocking = getenv("R300_SPAN_DISABLE_LOCKING") ? 1 : 0; + if (r300->span_dlocking == 0) { + fprintf(stderr, "Try R300_SPAN_DISABLE_LOCKING env var if this hangs.\n"); + fflush(stderr); + sleep(1); + } + first = 0; + } + + if (r300->span_dlocking) { + r300Flush(ctx); + LOCK_HARDWARE( rmesa ); + radeonWaitForIdleLocked( rmesa ); + UNLOCK_HARDWARE( rmesa ); + + return; + } + } // R300_FIREVERTICES( rmesa ); // old code has flush r300Flush(ctx); @@ -262,8 +285,10 @@ static void radeonSpanRenderStart( GLcontext *ctx ) static void radeonSpanRenderFinish( GLcontext *ctx ) { radeonContextPtr rmesa = RADEON_CONTEXT( ctx ); + r300ContextPtr r300 = (r300ContextPtr)rmesa; _swrast_flush( ctx ); - UNLOCK_HARDWARE( rmesa ); + if (r300->span_dlocking == 0) + UNLOCK_HARDWARE( rmesa ); } void radeonInitSpanFuncs( GLcontext *ctx ) diff --git a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c index 5ea9bb4eb45..1044973b001 100644 --- a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c +++ b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c @@ -71,7 +71,7 @@ void radeon_vb_to_rvb(r300ContextPtr rmesa, struct radeon_vertex_buffer *rvb, st CONV_VB(VERT_ATTRIB_COLOR1, SecondaryColorPtr[0]); CONV_VB(VERT_ATTRIB_FOG, FogCoordPtr); - for (i=0; i < MAX_TEXTURE_COORD_UNITS; i++) + for (i=0; i < ctx->Const.MaxTextureCoordUnits; i++) CONV_VB(VERT_ATTRIB_TEX0 + i, TexCoordPtr[i]); rvb->Primitive = vb->Primitive; @@ -182,7 +182,7 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G unsigned int min = ~0, max = 0; struct tnl_prim prim; static void *ptr = NULL; - static struct r300_dma_region rvb; + struct r300_dma_region rvb; const GLvoid *indices = c_indices; if (count > 65535) { @@ -205,8 +205,8 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G return; FLUSH_CURRENT( ctx, 0 ); - r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__); + memset(&rvb, 0, sizeof(rvb)); switch (type) { case GL_UNSIGNED_BYTE: for (i=0; i < count; i++) { @@ -216,14 +216,22 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G max = ((unsigned char *)indices)[i]; } +#ifdef FORCE_32BITS_ELTS + elt_size = 4; +#else elt_size = 2; - +#endif r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size); rvb.aos_offset = GET_START(&rvb); ptr = rvb.address + rvb.start; +#ifdef FORCE_32BITS_ELTS + for (i=0; i < count; i++) + ((unsigned int *)ptr)[i] = ((unsigned char *)indices)[i] - min; +#else for (i=0; i < count; i++) ((unsigned short int *)ptr)[i] = ((unsigned char *)indices)[i] - min; +#endif break; case GL_UNSIGNED_SHORT: @@ -234,14 +242,23 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G max = ((unsigned short int *)indices)[i]; } +#ifdef FORCE_32BITS_ELTS + elt_size = 4; +#else elt_size = 2; +#endif r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size); rvb.aos_offset = GET_START(&rvb); ptr = rvb.address + rvb.start; +#ifdef FORCE_32BITS_ELTS + for (i=0; i < count; i++) + ((unsigned int *)ptr)[i] = ((unsigned short int *)indices)[i] - min; +#else for (i=0; i < count; i++) ((unsigned short int *)ptr)[i] = ((unsigned short int *)indices)[i] - min; +#endif break; case GL_UNSIGNED_INT: @@ -252,17 +269,20 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G max = ((unsigned int *)indices)[i]; } +#ifdef FORCE_32BITS_ELTS + elt_size = 4; +#else if (max - min <= 65535) elt_size = 2; else elt_size = 4; - +#endif r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size); rvb.aos_offset = GET_START(&rvb); ptr = rvb.address + rvb.start; - if (max - min <= 65535) + if (elt_size == 2) for (i=0; i < count; i++) ((unsigned short int *)ptr)[i] = ((unsigned int *)indices)[i] - min; else @@ -278,12 +298,12 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G if (ctx->NewState) _mesa_update_state( ctx ); - for (i=_TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + for (i=_TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { rmesa->temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i]; TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &rmesa->dummy_attrib[i]; } r300UpdateShaders(rmesa); - for (i=_TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + for (i=_TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { TNL_CONTEXT(ctx)->vb.AttribPtr[i] = rmesa->temp_attrib[i]; } @@ -311,8 +331,10 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G return; } } else { - if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) + if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) { + r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__); goto fallback; + } rmesa->state.VB.Count = max - min + 1; } @@ -337,6 +359,7 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G if(rvb.buf) radeon_mm_use(rmesa, rvb.buf->id); + r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__); return; fallback: @@ -355,7 +378,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei int elt_size; int i; void *ptr = NULL; - static struct r300_dma_region rvb; + struct r300_dma_region rvb; const GLvoid *indices = c_indices; if (count > 65535) { @@ -381,23 +404,34 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei #ifdef OPTIMIZE_ELTS min = 0; #endif - r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__); - switch(type){ + memset(&rvb, 0, sizeof(rvb)); + switch (type){ case GL_UNSIGNED_BYTE: +#ifdef FORCE_32BITS_ELTS + elt_size = 4; +#else elt_size = 2; - +#endif r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size); rvb.aos_offset = GET_START(&rvb); ptr = rvb.address + rvb.start; +#ifdef FORCE_32BITS_ELTS + for(i=0; i < count; i++) + ((unsigned int *)ptr)[i] = ((unsigned char *)indices)[i] - min; +#else for(i=0; i < count; i++) ((unsigned short int *)ptr)[i] = ((unsigned char *)indices)[i] - min; +#endif break; case GL_UNSIGNED_SHORT: +#ifdef FORCE_32BITS_ELTS + elt_size = 4; +#else elt_size = 2; - +#endif #ifdef OPTIMIZE_ELTS if (min == 0 && ctx->Array.ElementArrayBufferObj->Name){ ptr = indices; @@ -408,21 +442,29 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei rvb.aos_offset = GET_START(&rvb); ptr = rvb.address + rvb.start; +#ifdef FORCE_32BITS_ELTS + for(i=0; i < count; i++) + ((unsigned int *)ptr)[i] = ((unsigned short int *)indices)[i] - min; +#else for(i=0; i < count; i++) ((unsigned short int *)ptr)[i] = ((unsigned short int *)indices)[i] - min; +#endif break; case GL_UNSIGNED_INT: +#ifdef FORCE_32BITS_ELTS + elt_size = 4; +#else if (max - min <= 65535) elt_size = 2; else elt_size = 4; - +#endif r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size); rvb.aos_offset = GET_START(&rvb); ptr = rvb.address + rvb.start; - if (max - min <= 65535) + if (elt_size == 2) for (i=0; i < count; i++) ((unsigned short int *)ptr)[i] = ((unsigned int *)indices)[i] - min; else @@ -440,12 +482,12 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei if (ctx->NewState) _mesa_update_state( ctx ); - for (i=_TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + for (i=_TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { rmesa->temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i]; TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &rmesa->dummy_attrib[i]; } r300UpdateShaders(rmesa); - for (i=_TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + for (i=_TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { TNL_CONTEXT(ctx)->vb.AttribPtr[i] = rmesa->temp_attrib[i]; } @@ -473,8 +515,10 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei return; }*/ } else { - if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) + if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) { + r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__); goto fallback; + } rmesa->state.VB.Count = max - min + 1; } @@ -501,6 +545,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei if(rvb.buf) radeon_mm_use(rmesa, rvb.buf->id); + r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__); return ; fallback: @@ -533,12 +578,12 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count ) /* XXX: setup_arrays before state update? */ - for (i=_TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + for (i=_TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { rmesa->temp_attrib[i] = TNL_CONTEXT(ctx)->vb.AttribPtr[i]; TNL_CONTEXT(ctx)->vb.AttribPtr[i] = &rmesa->dummy_attrib[i]; } r300UpdateShaders(rmesa); - for (i=_TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + for (i=_TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { TNL_CONTEXT(ctx)->vb.AttribPtr[i] = rmesa->temp_attrib[i]; } |