cmd.nbox = r300->radeon.numClipRects;
cmd.boxes = (drm_clip_rect_t *)r300->radeon.pClipRects;
}
-
+
ret = drmCommandWrite(r300->radeon.dri.fd,
DRM_RADEON_CMDBUF, &cmd, sizeof(cmd));
-
+
if (RADEON_DEBUG & DEBUG_SYNC) {
fprintf(stderr, "Syncing in %s (from %s)\n\n", __FUNCTION__, caller);
radeonWaitForIdleLocked(&r300->radeon);
#include "r300_state.h"
#include "r300_ioctl.h"
#include "r300_tex.h"
+#include "r300_maos.h"
#ifdef USER_BUFFERS
#include "radeon_mm.h"
#include "colormac.h"
#include "radeon_context.h"
-#define USE_ARB_F_P 1
-
/* PPC doesnt support 16 bit elts ... */
#ifndef MESA_BIG_ENDIAN
#define USER_BUFFERS
and pixel_shader structure later on */
#define CARD32 GLuint
#include "vertex_shader.h"
-#if USE_ARB_F_P == 1
#include "r300_fragprog.h"
-#else
-#include "pixel_shader.h"
-#endif
#undef CARD32
static __inline__ uint32_t r300PackFloat32(float fl)
drmBufPtr buf;
int id;
};
+#undef GET_START
#ifdef USER_BUFFERS
#define GET_START(rvb) (r300GartOffsetFromVirtual(rmesa, (rvb)->address+(rvb)->start))
#else
int use_ref_count;
};
-#if USE_ARB_F_P == 1
#define PFS_MAX_ALU_INST 64
#define PFS_MAX_TEX_INST 64
#define PFS_MAX_TEX_INDIRECT 4
int max_temp_idx;
};
-#else
-/* 64 appears to be the maximum */
-#define PSF_MAX_PROGRAM_LENGTH 64
-
-struct r300_pixel_shader_program {
- struct {
- int length;
- GLuint inst[PSF_MAX_PROGRAM_LENGTH];
- } tex;
-
- /* ALU intructions (logic and integer) */
- struct {
- int length;
- struct {
- GLuint inst0;
- GLuint inst1;
- GLuint inst2;
- GLuint inst3;
- } inst[PSF_MAX_PROGRAM_LENGTH];
- } alu;
-
- /* node information */
- /* nodes are used to synchronize ALU and TEX streams */
- /* There could be up to 4 nodes each consisting of
- a number of TEX instructions followed by some ALU
- instructions */
- /* the last node of a program should always be node3 */
- struct {
- int tex_offset;
- int tex_end;
- int alu_offset;
- int alu_end;
- } node[4];
-
- int active_nodes; /* must be between 1 and 4, inclusive */
- int first_node_has_tex; /* other nodes always have it */
-
- int temp_register_count; /* magic value goes into PFS_CNTL_1 */
-
- /* entire program */
- int tex_offset;
- int tex_end;
- int alu_offset;
- int alu_end;
-
- };
-
-#define MAX_PIXEL_SHADER_PARAMS 32
-struct r300_pixel_shader_state {
- struct r300_pixel_shader_program program;
-
- int translated;
- int have_sample;
- GLuint color_reg;
- GLuint src_previous;
-
- /* parameters */
- int param_length; /* to limit the number of unnecessary writes */
- struct {
- float x;
- float y;
- float z;
- float w;
- } param[MAX_PIXEL_SHADER_PARAMS];
- };
-#endif // USE_ARB_F_P
-
-/* 8 is somewhat bogus... it is probably something like 24 */
#define R300_MAX_AOS_ARRAYS 16
#define AOS_FORMAT_FLOAT 1
struct r300_texture_state texture;
struct r300_vap_reg_state vap_reg;
struct r300_vertex_shader_state vertex_shader;
-#if USE_ARB_F_P == 0
- struct r300_pixel_shader_state pixel_shader;
-#else
struct r300_pfs_compile_state pfs_compile;
-#endif
struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
int aos_count;
#ifdef USER_BUFFERS
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
-void translate_vertex_shader(struct r300_vertex_program *vp);
+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);
#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
return r;
}
+#if 0
static pfs_reg_t emit_const4fv(struct r300_fragment_program *rp, GLfloat *cp)
{
pfs_reg_t r = undef;
r.valid = GL_TRUE;
return r;
}
+#endif
static __inline pfs_reg_t negate(pfs_reg_t r)
{
struct prog_src_register fpsrc)
{
pfs_reg_t r = undef;
+#if 0
pfs_reg_t n = undef;
+#endif
switch (fpsrc.File) {
case PROGRAM_TEMPORARY:
return;
};
+#if 0
static pfs_reg_t get_attrib(struct r300_fragment_program *rp, GLuint attr)
{
struct fragment_program *mp = &rp->mesa_program;
r.valid = GL_TRUE;
return r;
}
+#endif
static GLboolean parse_program(struct r300_fragment_program *rp)
{
((0 | SRC_CONST) << R300_FPI3_SRC1A_SHIFT) | \
((0 | SRC_CONST) << R300_FPI3_SRC2A_SHIFT))
+#include "r300_context.h"
+
+struct r300_fragment_program;
+
+extern void r300_translate_fragment_shader(struct r300_fragment_program *rp);
#endif
void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
{
struct r300_dma_buffer *dmabuf;
- int fd = rmesa->radeon.dri.fd;
- int index = 0;
- int size = 0;
- drmDMAReq dma;
- int ret;
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
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"); \
return num_verts - verts_off;
}
-/* This function compiles GL context into state registers that
- describe data routing inside of R300 pipeline.
-
- In particular, it programs input_route, output_vtx_fmt, texture
- unit configuration and gb_output_vtx_fmt
-
- This function encompasses setup_AOS() from r300_lib.c
-*/
-
-
-
-
-/* Immediate implementation - vertex data is sent via command stream */
-
-static GLfloat default_vector[4]={0.0, 0.0, 0.0, 1.0};
-
-#define output_vector(v, i) { \
- int _i; \
- for(_i=0;_i<v->size;_i++){ \
- if(VB->Elts){ \
- efloat(VEC_ELT(v, GLfloat, VB->Elts[i])[_i]); \
- }else{ \
- efloat(VEC_ELT(v, GLfloat, i)[_i]); \
- } \
- } \
- for(_i=v->size;_i<4;_i++){ \
- efloat(default_vector[_i]); \
- } \
-}
-
-/* Immediate implementation - vertex data is sent via command stream */
-
-static void r300_render_immediate_primitive(r300ContextPtr rmesa,
- GLcontext *ctx,
- int start,
- int end,
- int prim)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLuint i, render_inputs;
- int k, 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 0
- fprintf(stderr,"ObjPtr: size=%d stride=%d\n",
- VB->ObjPtr->size, VB->ObjPtr->stride);
- fprintf(stderr,"ColorPtr[0]: size=%d stride=%d\n",
- VB->ColorPtr[0]->size, VB->ColorPtr[0]->stride);
- fprintf(stderr,"TexCoordPtr[0]: size=%d stride=%d\n",
- VB->TexCoordPtr[0]->size, VB->TexCoordPtr[0]->stride);
-#endif
-
- if(type<0 || num_verts <= 0)return;
-
- if(!VB->ObjPtr){
- WARN_ONCE("FIXME: Don't know how to handle GL_ARB_vertex_buffer_object correctly\n");
- return;
- }
- /* A packet cannot have more than 16383 data words.. */
- if((num_verts*4*rmesa->state.aos_count)>16380){
- WARN_ONCE("Too many vertices to paint. Fix me !\n");
- return;
- }
-
- //fprintf(stderr, "aos_count=%d start=%d end=%d\n", rmesa->state.aos_count, start, end);
-
- if(rmesa->state.aos_count==0){
- WARN_ONCE("Aeiee ! aos_count==0, while it shouldn't. Skipping rendering\n");
- return;
- }
-
- render_inputs = rmesa->state.render_inputs;
-
- if(!render_inputs){
- WARN_ONCE("Aeiee ! render_inputs==0. Skipping rendering.\n");
- return;
- }
-
-
- start_immediate_packet(num_verts, type, 4*rmesa->state.aos_count);
-
- for(i=start;i<start+num_verts;i++){
-#if 0
- fprintf(stderr, "* (%f %f %f %f) (%f %f %f %f)\n",
- VEC_ELT(VB->ObjPtr, GLfloat, i)[0],
- VEC_ELT(VB->ObjPtr, GLfloat, i)[1],
- VEC_ELT(VB->ObjPtr, GLfloat, i)[2],
- VEC_ELT(VB->ObjPtr, GLfloat, i)[3],
-
- VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0],
- VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1],
- VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2],
- VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3]
- );
-#endif
-
-
- /* coordinates */
- if(render_inputs & _TNL_BIT_POS)
- output_vector(VB->ObjPtr, i);
- if(render_inputs & _TNL_BIT_NORMAL)
- output_vector(VB->NormalPtr, i);
-
- /* color components */
- if(render_inputs & _TNL_BIT_COLOR0)
- output_vector(VB->ColorPtr[0], i);
- if(render_inputs & _TNL_BIT_COLOR1)
- output_vector(VB->SecondaryColorPtr[0], i);
-
-/* if(render_inputs & _TNL_BIT_FOG) // Causes lock ups when immediate mode is on
- output_vector(VB->FogCoordPtr, i);*/
-
- /* texture coordinates */
- for(k=0;k < ctx->Const.MaxTextureUnits;k++)
- if(render_inputs & (_TNL_BIT_TEX0<<k))
- output_vector(VB->TexCoordPtr[k], i);
-
- if(render_inputs & _TNL_BIT_INDEX)
- output_vector(VB->IndexPtr[0], i);
- if(render_inputs & _TNL_BIT_POINTSIZE)
- output_vector(VB->PointSizePtr, i);
- }
-
-}
-
-
-static GLboolean r300_run_immediate_render(GLcontext *ctx,
- struct tnl_pipeline_stage *stage)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLuint i;
- LOCAL_VARS
-
-
- /* Update texture state - needs to be done only when actually changed..
- All the time for now.. */
-
-
- 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
- /* 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__);
-#endif
-
- /* needed before starting 3d operation .. */
- reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
- e32(0x0000000a);
-
- reg_start(0x4f18,0);
- e32(0x00000003);
-
-
-#if 0 /* looks like the Z offset issue got fixed */
- rmesa->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
- | R300_VPORT_X_OFFSET_ENA
- | R300_VPORT_Y_SCALE_ENA
- | R300_VPORT_Y_OFFSET_ENA
- | R300_VTX_W0_FMT;
- R300_STATECHANGE(rmesa, vte);
-#endif
-
-
-
- /* Magic register - note it is right after 20b0 */
-
-
- if(rmesa->state.texture.tc_count>0){
- reg_start(0x20b4,0);
- e32(0x0000000c);
-
- }
-
- r300EmitState(rmesa);
-
-/* Setup INPUT_ROUTE and INPUT_CNTL */
- r300EmitArrays(ctx, GL_TRUE);
-
-/* Why do we need this for immediate mode?? Vertex processor needs it to know proper regs */
-// r300EmitLOAD_VBPNTR(rmesa, 0);
-/* Okay, it seems I misunderstood something, EmitAOS does the same thing */
- r300EmitAOS(rmesa, rmesa->state.aos_count, 0);
-
- 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_immediate_primitive(rmesa, ctx, start, start + length, prim);
- }
-
- /* This sequence is required after any 3d drawing packet
- I suspect it work arounds a bug (or deficiency) in hardware */
-
- reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
- e32(0x0000000a);
-
- reg_start(0x4f18,0);
- e32(0x00000003);
-
- return GL_FALSE;
-}
-
+/* Immediate implementation has been removed from CVS. */
/* vertex buffer implementation */
r300EmitArrays(ctx, GL_FALSE);
r300UpdateShaderStates(rmesa);
-// LOCK_HARDWARE(&(rmesa->radeon));
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
#ifdef USER_BUFFERS
r300UseArrays(ctx);
#endif
-// end_3d(PASS_PREFIX_VOID);
- /* Flush state - we are done drawing.. */
-// r300FlushCmdBufLocked(rmesa, __FUNCTION__);
-// radeonWaitForIdleLocked(&(rmesa->radeon));
-
-// UNLOCK_HARDWARE(&(rmesa->radeon));
return GL_FALSE;
}
int prim)
{
int type, num_verts;
- radeonScreenPtr rsp=rmesa->radeon.radeonScreen;
- LOCAL_VARS
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- int i;
type=r300_get_primitive_type(rmesa, ctx, prim);
num_verts=r300_get_num_verts(rmesa, ctx, end-start, prim);
if(rmesa->state.VB.Elts){
r300EmitAOS(rmesa, rmesa->state.aos_count, /*0*/start);
#if 0
+ LOCAL_VARS
+ int i;
start_index32_packet(num_verts, type);
for(i=0; i < num_verts; i++)
e32(((unsigned long *)rmesa->state.VB.Elts)[i]/*rmesa->state.Elts[start+i]*/); /* start ? */
}
}
+#if 0
void dump_array(struct r300_dma_region *rvb, int count)
{
int *out = (int *)(rvb->address + rvb->start);
fprintf(stderr, "%d ", ((unsigned char *)out)[ci]);
fprintf(stderr, "}");
- out = (char *)out + dt->stride;
+ out = (int *)((char *)out + dt->stride);
}
fprintf(stderr, "\n");
}
+#endif
/*static */GLboolean r300_run_vb_render_vtxfmt_a(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, j;
+ int i;
LOCAL_VARS
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
r300UpdateShaders(rmesa);
- if (rmesa->state.VB.LockCount == 0) {
+ if (rmesa->state.VB.LockCount == 0 || 1) {
r300ReleaseArrays(ctx);
r300EmitArraysVtx(ctx, GL_FALSE);
#endif
}
-// LOCK_HARDWARE(&(rmesa->radeon));
-
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(0x0000000a);
#ifdef USER_BUFFERS
r300UseArrays(ctx);
#endif
-// end_3d(PASS_PREFIX_VOID);
-
- /* Flush state - we are done drawing.. */
-// r300FlushCmdBufLocked(rmesa, __FUNCTION__);
-// radeonWaitForIdleLocked(&(rmesa->radeon));
-
-// UNLOCK_HARDWARE(&(rmesa->radeon));
return GL_FALSE;
}
#endif
GLboolean r300Fallback(GLcontext *ctx)
{
- 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);
if (r300Fallback(ctx))
return GL_TRUE;
-#if 0
- return r300_run_immediate_render(ctx, stage);
-#else
- return r300_run_vb_render(ctx, stage);
-#endif
+
+ return r300_run_vb_render(ctx, stage);
}
const struct tnl_pipeline_stage _r300_render_stage = {
return GL_TRUE;
}
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
+ 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;
vp->native &= 1;
//vp->native = GL_FALSE;
#endif
+
+#if 0 /* You dont want to know what this does... */
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_cache *cache;
+ struct tnl_cache_item *c;
+
+ cache = tnl->vp_cache;
+ c = cache->items[0xc000cc0e % cache->size];
+
+ if(c && c->data == vp)
+ vp->native = GL_FALSE;
+
+#endif
+#if 0
+ vp->native = GL_FALSE;
+#endif
if (vp->native == GL_FALSE) {
hw_tcl_on = GL_FALSE;
return GL_TRUE;
#include "program.h"
#include "r300_context.h"
-#include "program_instruction.h"
-#if USE_ARB_F_P == 1
#include "r300_fragprog.h"
-#endif
static void r300BindProgram(GLcontext *ctx, GLenum target, struct program *prog)
{
switch(target){
case GL_VERTEX_PROGRAM_ARB:
- rmesa->curr_vp = vp;
+ rmesa->curr_vp = (struct vertex_program *)vp;
vp->ref_count++;
#if 0
if((vp->ref_count % 1500) == 0) {
{
struct r300_vertex_program *vp;
struct r300_fragment_program *fp;
- struct ati_fragment_shader *afs;
switch(target){
case GL_VERTEX_STATE_PROGRAM_NV:
case GL_FRAGMENT_PROGRAM_NV:
fp=CALLOC_STRUCT(r300_fragment_program);
return _mesa_init_fragment_program(ctx, &fp->mesa_program, target, id);
-#if 00
- /* _mesa_new_ati_fragment_shader() is now called instead */
- case GL_FRAGMENT_SHADER_ATI:
- afs=CALLOC_STRUCT(ati_fragment_shader);
- return _mesa_init_ati_fragment_shader(ctx, afs, target, id);
-#endif
default:
_mesa_problem(ctx, "Bad target in r300NewProgram");
}
static void r300DeleteProgram(GLcontext *ctx, struct program *prog)
{
+#if 0
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_vertex_program *vp=(void *)prog;
- /*if(rmesa->curr_vp == vp)
- rmesa->curr_vp = NULL;*/
-
+ if(rmesa->curr_vp == vp)
+ rmesa->curr_vp = NULL;
+#endif
+
_mesa_delete_program(ctx, prog);
}
case GL_VERTEX_PROGRAM_ARB:
vp->translated = GL_FALSE;
memset(&vp->translated, 0, sizeof(struct r300_vertex_program) - sizeof(struct vertex_program));
- /*translate_vertex_shader(vp);*/
+ /*r300_translate_vertex_shader(vp);*/
break;
case GL_FRAGMENT_PROGRAM_ARB:
fp->translated = GL_FALSE;
struct r300_tex_obj *t;
r300ContextPtr r300 = R300_CONTEXT(ctx);
int hw_tmu=0;
- int first_hw_tmu=0, last_hw_tmu=-1; /* -1 translates into no setup costs for fields */
+ int last_hw_tmu=-1; /* -1 translates into no setup costs for fields */
int tmu_mappings[R300_MAX_TEXTURE_UNITS] = { -1 };
struct r300_fragment_program *rp =
(struct r300_fragment_program *)
vp = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
if (vp->translated == GL_FALSE)
- translate_vertex_shader(vp);
+ r300_translate_vertex_shader(vp);
if (vp->translated == GL_FALSE) {
fprintf(stderr, "Failing back to sw-tcl\n");
-// debug_vp(ctx, &vp->mesa_program);
hw_tcl_on = future_hw_tcl_on = 0;
r300ResetHwState(rmesa);
extern void r300InitState(r300ContextPtr r300);
extern void r300InitStateFuncs(struct dd_function_table* functions);
+extern void r300UpdateViewportOffset( GLcontext *ctx );
extern void r300UpdateWindow(GLcontext * ctx);
+extern void r300UpdateDrawBuffer(GLcontext *ctx);
extern void r300SetupVertexShader(r300ContextPtr rmesa);
extern void r300SetupPixelShader(r300ContextPtr rmesa);
static void r300TexEnv(GLcontext * ctx, GLenum target,
GLenum pname, const GLfloat * param)
{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- GLuint unit = ctx->Texture.CurrentUnit;
-
if (RADEON_DEBUG & DEBUG_STATE) {
fprintf(stderr, "%s( %s )\n",
__FUNCTION__, _mesa_lookup_enum_by_nr(pname));
#include "r300_state.h"
#include "r300_ioctl.h"
#include "radeon_ioctl.h"
-//#include "r300_swtcl.h"
#include "r300_tex.h"
-//#include "r300_tcl.h"
#include "r300_reg.h"
#define R200_TXFORMAT_A8 R200_TXFORMAT_I8
t->format &= ~(R200_TXFORMAT_FORMAT_MASK |
R200_TXFORMAT_ALPHA_IN_MAP);
-#if 0
- t->filter &= ~R200_YUV_TO_RGB;
-#endif
+
if (VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
t->format =
tx_table[baseImage->TexFormat->MesaFormat].format;
/* Hardware state:
*/
-#if 0
- t->filter &= ~R200_MAX_MIP_LEVEL_MASK;
- t->filter |= (numLevels - 1) << R200_MAX_MIP_LEVEL_SHIFT;
-#endif
#if 0
t->format &= ~(R200_TXFORMAT_WIDTH_MASK |
R200_TXFORMAT_HEIGHT_MASK |
/* FYI: r300UploadTexImages( rmesa, t ) used to be called here */
}
-/* ================================================================
- * Texture combine functions
- */
-
-/* GL_ARB_texture_env_combine support
- */
-
-/* The color tables have combine functions for GL_SRC_COLOR,
- * GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
- */
-static GLuint r300_register_color[][R200_MAX_TEXTURE_UNITS] = {
- {
- R200_TXC_ARG_A_R0_COLOR,
- R200_TXC_ARG_A_R1_COLOR,
- R200_TXC_ARG_A_R2_COLOR,
- R200_TXC_ARG_A_R3_COLOR,
- R200_TXC_ARG_A_R4_COLOR,
- R200_TXC_ARG_A_R5_COLOR},
- {
- R200_TXC_ARG_A_R0_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R1_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R2_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R3_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R4_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R5_COLOR | R200_TXC_COMP_ARG_A},
- {
- R200_TXC_ARG_A_R0_ALPHA,
- R200_TXC_ARG_A_R1_ALPHA,
- R200_TXC_ARG_A_R2_ALPHA,
- R200_TXC_ARG_A_R3_ALPHA,
- R200_TXC_ARG_A_R4_ALPHA,
- R200_TXC_ARG_A_R5_ALPHA},
- {
- R200_TXC_ARG_A_R0_ALPHA | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R1_ALPHA | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R2_ALPHA | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R3_ALPHA | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R4_ALPHA | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_R5_ALPHA | R200_TXC_COMP_ARG_A},
-};
-
-static GLuint r300_tfactor_color[] = {
- R200_TXC_ARG_A_TFACTOR_COLOR,
- R200_TXC_ARG_A_TFACTOR_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_TFACTOR_ALPHA,
- R200_TXC_ARG_A_TFACTOR_ALPHA | R200_TXC_COMP_ARG_A
-};
-
-static GLuint r300_primary_color[] = {
- R200_TXC_ARG_A_DIFFUSE_COLOR,
- R200_TXC_ARG_A_DIFFUSE_COLOR | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_DIFFUSE_ALPHA,
- R200_TXC_ARG_A_DIFFUSE_ALPHA | R200_TXC_COMP_ARG_A
-};
-
-/* GL_ZERO table - indices 0-3
- * GL_ONE table - indices 1-4
- */
-static GLuint r300_zero_color[] = {
- R200_TXC_ARG_A_ZERO,
- R200_TXC_ARG_A_ZERO | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_ZERO,
- R200_TXC_ARG_A_ZERO | R200_TXC_COMP_ARG_A,
- R200_TXC_ARG_A_ZERO
-};
-
-/* The alpha tables only have GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
- */
-static GLuint r300_register_alpha[][R200_MAX_TEXTURE_UNITS] = {
- {
- R200_TXA_ARG_A_R0_ALPHA,
- R200_TXA_ARG_A_R1_ALPHA,
- R200_TXA_ARG_A_R2_ALPHA,
- R200_TXA_ARG_A_R3_ALPHA,
- R200_TXA_ARG_A_R4_ALPHA,
- R200_TXA_ARG_A_R5_ALPHA},
- {
- R200_TXA_ARG_A_R0_ALPHA | R200_TXA_COMP_ARG_A,
- R200_TXA_ARG_A_R1_ALPHA | R200_TXA_COMP_ARG_A,
- R200_TXA_ARG_A_R2_ALPHA | R200_TXA_COMP_ARG_A,
- R200_TXA_ARG_A_R3_ALPHA | R200_TXA_COMP_ARG_A,
- R200_TXA_ARG_A_R4_ALPHA | R200_TXA_COMP_ARG_A,
- R200_TXA_ARG_A_R5_ALPHA | R200_TXA_COMP_ARG_A},
-};
-
-static GLuint r300_tfactor_alpha[] = {
- R200_TXA_ARG_A_TFACTOR_ALPHA,
- R200_TXA_ARG_A_TFACTOR_ALPHA | R200_TXA_COMP_ARG_A
-};
-
-static GLuint r300_primary_alpha[] = {
- R200_TXA_ARG_A_DIFFUSE_ALPHA,
- R200_TXA_ARG_A_DIFFUSE_ALPHA | R200_TXA_COMP_ARG_A
-};
-
-/* GL_ZERO table - indices 0-1
- * GL_ONE table - indices 1-2
- */
-static GLuint r300_zero_alpha[] = {
- R200_TXA_ARG_A_ZERO,
- R200_TXA_ARG_A_ZERO | R200_TXA_COMP_ARG_A,
- R200_TXA_ARG_A_ZERO,
-};
-
-/* Extract the arg from slot A, shift it into the correct argument slot
- * and set the corresponding complement bit.
- */
-#define R200_COLOR_ARG( n, arg ) \
-do { \
- color_combine |= \
- ((color_arg[n] & R200_TXC_ARG_A_MASK) \
- << R200_TXC_ARG_##arg##_SHIFT); \
- color_combine |= \
- ((color_arg[n] >> R200_TXC_COMP_ARG_A_SHIFT) \
- << R200_TXC_COMP_ARG_##arg##_SHIFT); \
-} while (0)
-
-#define R200_ALPHA_ARG( n, arg ) \
-do { \
- alpha_combine |= \
- ((alpha_arg[n] & R200_TXA_ARG_A_MASK) \
- << R200_TXA_ARG_##arg##_SHIFT); \
- alpha_combine |= \
- ((alpha_arg[n] >> R200_TXA_COMP_ARG_A_SHIFT) \
- << R200_TXA_COMP_ARG_##arg##_SHIFT); \
-} while (0)
/* ================================================================
* Texture unit state management
*/
-static GLboolean r300UpdateTextureEnv(GLcontext * ctx, int unit)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLuint color_combine, alpha_combine;
-
-#if 0 /* disable for now.. */
- GLuint color_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] &
- ~(R200_TXC_SCALE_MASK);
- GLuint alpha_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] &
- ~(R200_TXA_DOT_ALPHA | R200_TXA_SCALE_MASK);
-#endif
-
- GLuint color_scale=0, alpha_scale=0;
-
- /* texUnit->_Current can be NULL if and only if the texture unit is
- * not actually enabled.
- */
- assert((texUnit->_ReallyEnabled == 0)
- || (texUnit->_Current != NULL));
-
- if (RADEON_DEBUG & DEBUG_TEXTURE) {
- fprintf(stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx,
- unit);
- }
-
- /* Set the texture environment state. Isn't this nice and clean?
- * The chip will automagically set the texture alpha to 0xff when
- * the texture format does not include an alpha component. This
- * reduces the amount of special-casing we have to do, alpha-only
- * textures being a notable exception.
- */
- /* Don't cache these results.
- */
-#if 0
- rmesa->state.texture.unit[unit].format = 0;
-#endif
- rmesa->state.texture.unit[unit].envMode = 0;
-
-
- if (!texUnit->_ReallyEnabled) {
- if (unit == 0) {
- color_combine =
- R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO |
- R200_TXC_ARG_C_DIFFUSE_COLOR | R200_TXC_OP_MADD;
- alpha_combine =
- R200_TXA_ARG_A_ZERO | R200_TXA_ARG_B_ZERO |
- R200_TXA_ARG_C_DIFFUSE_ALPHA | R200_TXA_OP_MADD;
- } else {
- color_combine =
- R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO |
- R200_TXC_ARG_C_R0_COLOR | R200_TXC_OP_MADD;
- alpha_combine =
- R200_TXA_ARG_A_ZERO | R200_TXA_ARG_B_ZERO |
- R200_TXA_ARG_C_R0_ALPHA | R200_TXA_OP_MADD;
- }
- } else {
- GLuint color_arg[3], alpha_arg[3];
- GLuint i;
- const GLuint numColorArgs =
- texUnit->_CurrentCombine->_NumArgsRGB;
- const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA;
- GLuint RGBshift = texUnit->_CurrentCombine->ScaleShiftRGB;
- GLuint Ashift = texUnit->_CurrentCombine->ScaleShiftA;
-
- /* Step 1:
- * Extract the color and alpha combine function arguments.
- */
- for (i = 0; i < numColorArgs; i++) {
- const GLint op =
- texUnit->_CurrentCombine->OperandRGB[i] -
- GL_SRC_COLOR;
- assert(op >= 0);
- assert(op <= 3);
- switch (texUnit->_CurrentCombine->SourceRGB[i]) {
- case GL_TEXTURE:
- color_arg[i] = r300_register_color[op][unit];
- break;
- case GL_CONSTANT:
- color_arg[i] = r300_tfactor_color[op];
- break;
- case GL_PRIMARY_COLOR:
- color_arg[i] = r300_primary_color[op];
- break;
- case GL_PREVIOUS:
- if (unit == 0)
- color_arg[i] = r300_primary_color[op];
- else
- color_arg[i] =
- r300_register_color[op][0];
- break;
- case GL_ZERO:
- color_arg[i] = r300_zero_color[op];
- break;
- case GL_ONE:
- color_arg[i] = r300_zero_color[op + 1];
- break;
- default:
- return GL_FALSE;
- }
- }
-
- for (i = 0; i < numAlphaArgs; i++) {
- const GLint op =
- texUnit->_CurrentCombine->OperandA[i] -
- GL_SRC_ALPHA;
- assert(op >= 0);
- assert(op <= 1);
- switch (texUnit->_CurrentCombine->SourceA[i]) {
- case GL_TEXTURE:
- alpha_arg[i] = r300_register_alpha[op][unit];
- break;
- case GL_CONSTANT:
- alpha_arg[i] = r300_tfactor_alpha[op];
- break;
- case GL_PRIMARY_COLOR:
- alpha_arg[i] = r300_primary_alpha[op];
- break;
- case GL_PREVIOUS:
- if (unit == 0)
- alpha_arg[i] = r300_primary_alpha[op];
- else
- alpha_arg[i] =
- r300_register_alpha[op][0];
- break;
- case GL_ZERO:
- alpha_arg[i] = r300_zero_alpha[op];
- break;
- case GL_ONE:
- alpha_arg[i] = r300_zero_alpha[op + 1];
- break;
- default:
- return GL_FALSE;
- }
- }
-
- /* Step 2:
- * Build up the color and alpha combine functions.
- */
- switch (texUnit->_CurrentCombine->ModeRGB) {
- case GL_REPLACE:
- color_combine = (R200_TXC_ARG_A_ZERO |
- R200_TXC_ARG_B_ZERO |
- R200_TXC_OP_MADD);
- R200_COLOR_ARG(0, C);
- break;
- case GL_MODULATE:
- color_combine = (R200_TXC_ARG_C_ZERO |
- R200_TXC_OP_MADD);
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, B);
- break;
- case GL_ADD:
- color_combine = (R200_TXC_ARG_B_ZERO |
- R200_TXC_COMP_ARG_B |
- R200_TXC_OP_MADD);
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, C);
- break;
- case GL_ADD_SIGNED:
- color_combine = (R200_TXC_ARG_B_ZERO | R200_TXC_COMP_ARG_B | R200_TXC_BIAS_ARG_C | /* new */
- R200_TXC_OP_MADD); /* was ADDSIGNED */
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, C);
- break;
- case GL_SUBTRACT:
- color_combine = (R200_TXC_ARG_B_ZERO |
- R200_TXC_COMP_ARG_B |
- R200_TXC_NEG_ARG_C | R200_TXC_OP_MADD);
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, C);
- break;
- case GL_INTERPOLATE:
- color_combine = (R200_TXC_OP_LERP);
- R200_COLOR_ARG(0, B);
- R200_COLOR_ARG(1, A);
- R200_COLOR_ARG(2, C);
- break;
-
- case GL_DOT3_RGB_EXT:
- case GL_DOT3_RGBA_EXT:
- /* The EXT version of the DOT3 extension does not support the
- * scale factor, but the ARB version (and the version in OpenGL
- * 1.3) does.
- */
- RGBshift = 0;
- /* FALLTHROUGH */
-
- case GL_DOT3_RGB:
- case GL_DOT3_RGBA:
- /* DOT3 works differently on R200 than on R100. On R100, just
- * setting the DOT3 mode did everything for you. On R200, the
- * driver has to enable the biasing and scale in the inputs to
- * put them in the proper [-1,1] range. This is what the 4x and
- * the -0.5 in the DOT3 spec do. The post-scale is then set
- * normally.
- */
-
- color_combine = (R200_TXC_ARG_C_ZERO |
- R200_TXC_OP_DOT3 |
- R200_TXC_BIAS_ARG_A |
- R200_TXC_BIAS_ARG_B |
- R200_TXC_SCALE_ARG_A |
- R200_TXC_SCALE_ARG_B);
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, B);
- break;
-
- case GL_MODULATE_ADD_ATI:
- color_combine = (R200_TXC_OP_MADD);
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, C);
- R200_COLOR_ARG(2, B);
- break;
- case GL_MODULATE_SIGNED_ADD_ATI:
- color_combine = (R200_TXC_BIAS_ARG_C | /* new */
- R200_TXC_OP_MADD); /* was ADDSIGNED */
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, C);
- R200_COLOR_ARG(2, B);
- break;
- case GL_MODULATE_SUBTRACT_ATI:
- color_combine = (R200_TXC_NEG_ARG_C | R200_TXC_OP_MADD);
- R200_COLOR_ARG(0, A);
- R200_COLOR_ARG(1, C);
- R200_COLOR_ARG(2, B);
- break;
- default:
- return GL_FALSE;
- }
-
- switch (texUnit->_CurrentCombine->ModeA) {
- case GL_REPLACE:
- alpha_combine = (R200_TXA_ARG_A_ZERO |
- R200_TXA_ARG_B_ZERO |
- R200_TXA_OP_MADD);
- R200_ALPHA_ARG(0, C);
- break;
- case GL_MODULATE:
- alpha_combine = (R200_TXA_ARG_C_ZERO |
- R200_TXA_OP_MADD);
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, B);
- break;
- case GL_ADD:
- alpha_combine = (R200_TXA_ARG_B_ZERO |
- R200_TXA_COMP_ARG_B |
- R200_TXA_OP_MADD);
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, C);
- break;
- case GL_ADD_SIGNED:
- alpha_combine = (R200_TXA_ARG_B_ZERO | R200_TXA_COMP_ARG_B | R200_TXA_BIAS_ARG_C | /* new */
- R200_TXA_OP_MADD); /* was ADDSIGNED */
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, C);
- break;
- case GL_SUBTRACT:
- alpha_combine = (R200_TXA_ARG_B_ZERO |
- R200_TXA_COMP_ARG_B |
- R200_TXA_NEG_ARG_C | R200_TXA_OP_MADD);
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, C);
- break;
- case GL_INTERPOLATE:
- alpha_combine = (R200_TXA_OP_LERP);
- R200_ALPHA_ARG(0, B);
- R200_ALPHA_ARG(1, A);
- R200_ALPHA_ARG(2, C);
- break;
-
- case GL_MODULATE_ADD_ATI:
- alpha_combine = (R200_TXA_OP_MADD);
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, C);
- R200_ALPHA_ARG(2, B);
- break;
- case GL_MODULATE_SIGNED_ADD_ATI:
- alpha_combine = (R200_TXA_BIAS_ARG_C | /* new */
- R200_TXA_OP_MADD); /* was ADDSIGNED */
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, C);
- R200_ALPHA_ARG(2, B);
- break;
- case GL_MODULATE_SUBTRACT_ATI:
- alpha_combine = (R200_TXA_NEG_ARG_C | R200_TXA_OP_MADD);
- R200_ALPHA_ARG(0, A);
- R200_ALPHA_ARG(1, C);
- R200_ALPHA_ARG(2, B);
- break;
- default:
- return GL_FALSE;
- }
-
- if ((texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA_EXT)
- || (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA)) {
- alpha_scale |= R200_TXA_DOT_ALPHA;
- Ashift = RGBshift;
- }
-
- /* Step 3:
- * Apply the scale factor.
- */
- color_scale |= (RGBshift << R200_TXC_SCALE_SHIFT);
- alpha_scale |= (Ashift << R200_TXA_SCALE_SHIFT);
-
- /* All done!
- */
- }
-
-#if 0
- fprintf(stderr, "color_combine=%08x alpha_combine=%08x color_scale=%08x alpha_scale=%08x\n",
- color_combine, alpha_combine, color_scale, alpha_scale);
-#endif
-
-#if 0
- if (rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND] != color_combine ||
- rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND] != alpha_combine ||
- rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] != color_scale ||
- rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] != alpha_scale) {
- R300_STATECHANGE(rmesa, pix[unit]);
- rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND] = color_combine;
- rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND] = alpha_combine;
- rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] = color_scale;
- rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] = alpha_scale;
- }
-
-#endif
-
- return GL_TRUE;
-}
-
-#define TEXOBJ_TXFILTER_MASK (R200_MAX_MIP_LEVEL_MASK | \
- R200_MIN_FILTER_MASK | \
- R200_MAG_FILTER_MASK | \
- R200_MAX_ANISO_MASK | \
- R200_YUV_TO_RGB | \
- R200_YUV_TEMPERATURE_MASK | \
- R200_CLAMP_S_MASK | \
- R200_CLAMP_T_MASK | \
- R200_BORDER_MODE_D3D )
-
-#define TEXOBJ_TXFORMAT_MASK (R200_TXFORMAT_WIDTH_MASK | \
- R200_TXFORMAT_HEIGHT_MASK | \
- R200_TXFORMAT_FORMAT_MASK | \
- R200_TXFORMAT_F5_WIDTH_MASK | \
- R200_TXFORMAT_F5_HEIGHT_MASK | \
- R200_TXFORMAT_ALPHA_IN_MAP | \
- R200_TXFORMAT_CUBIC_MAP_ENABLE | \
- R200_TXFORMAT_NON_POWER2)
-
-#define TEXOBJ_TXFORMAT_X_MASK (R200_DEPTH_LOG2_MASK | \
- R200_TEXCOORD_MASK | \
- R200_CLAMP_Q_MASK | \
- R200_VOLUME_FILTER_MASK)
-
-static void disable_tex(GLcontext * ctx, int unit)
-{
-#if 0 /* This needs to be redone.. or done elsewhere */
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
- if (rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE << unit)) {
- /* Texture unit disabled */
- if (rmesa->state.texture.unit[unit].texobj != NULL) {
- /* The old texture is no longer bound to this texture unit.
- * Mark it as such.
- */
-
- rmesa->state.texture.unit[unit].texobj->base.bound &=
- ~(1UL << unit);
- rmesa->state.texture.unit[unit].texobj = NULL;
- }
-
- R300_STATECHANGE(rmesa, ctx);
- rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~((R200_TEX_0_ENABLE |
- R200_TEX_BLEND_0_ENABLE) <<
- unit);
- rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_BLEND_0_ENABLE;
-
- R300_STATECHANGE(rmesa, tcl);
- rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &=
- ~(7 << (unit * 3));
-
- if (rmesa->radeon.TclFallback & (RADEON_TCL_FALLBACK_TEXGEN_0 << unit)) {
- TCL_FALLBACK(ctx, (RADEON_TCL_FALLBACK_TEXGEN_0 << unit),
- GL_FALSE);
- }
-
- /* Actually want to keep all units less than max active texture
- * enabled, right? Fix this for >2 texunits.
- */
- /* FIXME: What should happen here if r300UpdateTextureEnv fails? */
- if (unit == 0)
- r300UpdateTextureEnv(ctx, unit);
-
- {
- GLuint inputshift =
- R200_TEXGEN_0_INPUT_SHIFT + unit * 4;
- GLuint tmp = rmesa->TexGenEnabled;
-
- rmesa->TexGenEnabled &=
- ~(R200_TEXGEN_TEXMAT_0_ENABLE << unit);
- rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE << unit);
- rmesa->TexGenEnabled &=
- ~(R200_TEXGEN_INPUT_MASK << inputshift);
- rmesa->TexGenNeedNormals[unit] = 0;
- rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
- rmesa->TexGenInputs &=
- ~(R200_TEXGEN_INPUT_MASK << inputshift);
-
- if (tmp != rmesa->TexGenEnabled) {
- rmesa->recheck_texgen[unit] = GL_TRUE;
- rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
- }
- }
- }
-#endif
-}
-
static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_object *tObj = texUnit->_Current;
r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
- /* Need to load the 2d images associated with this unit.
- */
-#if 0
- if (t->format & R200_TXFORMAT_NON_POWER2) {
- t->format &= ~R200_TXFORMAT_NON_POWER2;
- t->base.dirty_images[0] = ~0;
- }
-#endif
-
ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
if (t->base.dirty_images[0]) {
struct gl_texture_object *tObj = texUnit->_Current;
r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
-#if 0
- if (!(t->format & R200_TXFORMAT_NON_POWER2)) {
- t->format |= R200_TXFORMAT_NON_POWER2;
- t->base.dirty_images[0] = ~0;
- }
-#endif
-
ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
if (t->base.dirty_images[0]) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *tObj = texUnit->_Current;
r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
- GLenum format;
/* Fallback if there's a texture border */
if (tObj->Image[0][tObj->BaseLevel]->Border > 0)
driUpdateTextureLRU((driTextureObject *) t); /* XXX: should be locked! */
}
-#if 0 /* do elsewhere ? */
- /* Newly enabled?
- */
- if (1
- || !(rmesa->hw.ctx.
- cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE << unit))) {
- R300_STATECHANGE(rmesa, ctx);
- rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_0_ENABLE |
- R200_TEX_BLEND_0_ENABLE) <<
- unit;
-
- R300_STATECHANGE(rmesa, vtx);
- rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] |= 4 << (unit * 3);
-
- rmesa->recheck_texgen[unit] = GL_TRUE;
- }
-
- if (t->dirty_state & (1 << unit)) {
- import_tex_obj_state(rmesa, unit, t);
- }
-
- if (rmesa->recheck_texgen[unit]) {
- GLboolean fallback = !r300_validate_texgen(ctx, unit);
- TCL_FALLBACK(ctx, (RADEON_TCL_FALLBACK_TEXGEN_0 << unit),
- fallback);
- rmesa->recheck_texgen[unit] = 0;
- rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
- }
-#endif
-#if 0
- format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
- if (rmesa->state.texture.unit[unit].format != format ||
- rmesa->state.texture.unit[unit].envMode != texUnit->EnvMode) {
- //rmesa->state.texture.unit[unit].format = format;
- rmesa->state.texture.unit[unit].envMode = texUnit->EnvMode;
- if (!r300UpdateTextureEnv(ctx, unit)) {
- return GL_FALSE;
- }
- }
-#endif
#if R200_MERGED
FALLBACK(&rmesa->radeon, RADEON_FALLBACK_BORDER_MODE, t->border_fallback);
#endif
} else if (texUnit->_ReallyEnabled) {
return GL_FALSE;
} else {
- disable_tex(ctx, unit);
return GL_TRUE;
- }
+ }
}
void r300UpdateTextureState(GLcontext * ctx)
{
-#if 0
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- GLuint dbg;
- int i;
-#endif
GLboolean ok;
ok = (r300UpdateTextureUnit(ctx, 0) &&
#if R200_MERGED
FALLBACK(&rmesa->radeon, RADEON_FALLBACK_TEXTURE, !ok);
#endif
-
- /* This needs correction, or just be done elsewhere
- if (rmesa->radeon.TclFallback)
- r300ChooseVertexState(ctx);
- */
-
-#if 0 /* Workaround - disable.. */
- if (GET_CHIP(rmesa->radeon.radeonScreen) == RADEON_CHIP_REAL_R200) {
- /*
- * T0 hang workaround -------------
- * not needed for r200 derivatives?
- */
- if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_ENABLE_MASK) ==
- R200_TEX_0_ENABLE
- && (rmesa->hw.tex[0].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) >
- R200_MIN_FILTER_LINEAR) {
-
- R300_STATECHANGE(rmesa, ctx);
- R300_STATECHANGE(rmesa, tex[1]);
- rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_1_ENABLE;
- rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &=
- ~TEXOBJ_TXFORMAT_MASK;
- rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
- } else {
- if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_1_ENABLE)
- && (rmesa->hw.tex[1].
- cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
- R300_STATECHANGE(rmesa, tex[1]);
- rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &=
- ~0x08000000;
- }
- }
-
- /* maybe needs to be done pairwise due to 2 parallel (physical) tex units ?
- looks like that's not the case, if 8500/9100 owners don't complain remove this...
- for ( i = 0; i < ctx->Const.MaxTextureUnits; i += 2) {
- if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & ((R200_TEX_0_ENABLE |
- R200_TEX_1_ENABLE ) << i)) == (R200_TEX_0_ENABLE << i)) &&
- ((rmesa->hw.tex[i].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) >
- R200_MIN_FILTER_LINEAR)) {
- R300_STATECHANGE(rmesa, ctx);
- R300_STATECHANGE(rmesa, tex[i+1]);
- rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_1_ENABLE << i);
- rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
- rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
- }
- else {
- if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE << i)) &&
- (rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
- R300_STATECHANGE(rmesa, tex[i+1]);
- rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~0x08000000;
- }
- }
- } */
-
- /*
- * Texture cache LRU hang workaround -------------
- * not needed for r200 derivatives?
- */
- dbg = 0x0;
-
- if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE)) &&
- ((((rmesa->hw.tex[0].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) & 0x04)
- == 0))
- || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_2_ENABLE)
- &&
- ((((rmesa->hw.tex[2].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
- 0x04) == 0))
- || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_4_ENABLE)
- &&
- ((((rmesa->hw.tex[4].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
- 0x04) == 0))) {
- dbg |= 0x02;
- }
-
- if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE)) &&
- ((((rmesa->hw.tex[1].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) & 0x04)
- == 0))
- || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_3_ENABLE)
- &&
- ((((rmesa->hw.tex[3].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
- 0x04) == 0))
- || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_5_ENABLE)
- &&
- ((((rmesa->hw.tex[5].
- cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
- 0x04) == 0))) {
- dbg |= 0x04;
- }
-
- if (dbg != rmesa->hw.tam.cmd[TAM_DEBUG3]) {
- R300_STATECHANGE(rmesa, tam);
- rmesa->hw.tam.cmd[TAM_DEBUG3] = dbg;
- if (0)
- printf("TEXCACHE LRU HANG WORKAROUND %x\n",
- dbg);
- }
- }
-#endif
}
#include "glheader.h"
#include "macros.h"
#include "enums.h"
-
#include "program.h"
+#include "nvvertexec.h"
+
#include "r300_context.h"
#include "r300_program.h"
#include "program_instruction.h"
OPN(END, 0, 0),
};
#undef OPN
-#define OPN(rf) {#rf, PROGRAM_##rf}
-
-static struct{
- char *name;
- int id;
-}register_file_names[]={
- OPN(TEMPORARY),
- OPN(INPUT),
- OPN(OUTPUT),
- OPN(LOCAL_PARAM),
- OPN(ENV_PARAM),
- OPN(NAMED_PARAM),
- OPN(STATE_VAR),
- OPN(WRITE_ONLY),
- OPN(ADDRESS),
-};
-static char *dst_mask_names[4]={ "X", "Y", "Z", "W" };
-
int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp, float *dst)
{
int pi;
}
}
+#if 0
static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
{
int i;
fprintf(stderr, ">\n");
}
+#endif
static unsigned long t_src_index(struct r300_vertex_program *vp, struct prog_src_register *src)
{
u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
} while (0)
-void translate_vertex_shader(struct r300_vertex_program *vp)
+void r300_translate_vertex_shader(struct r300_vertex_program *vp)
{
struct vertex_program *mesa_vp=(void *)vp;
struct prog_instruction *vpi;
#include "radeon_reg.h"
#include "r200_state.h"
+#include "r300_state.h"
+
#include "utils.h"
#include "vblank.h"
#include "xmlpool.h" /* for symbolic values of enum-type options */
#include "radeon_ioctl.h"
#include "radeon_state.h"
#include "r300_context.h"
+#include "r300_state.h"
#include "framebuffer.h"
* Authors:
* Aapo Tahkola <aet@rasterburn.org>
*/
+#include <unistd.h>
#include "r300_context.h"
#include "r300_cmdbuf.h"
+#include "r300_ioctl.h"
#include "radeon_mm.h"
#ifdef USER_BUFFERS
int radeon_mm_find(r300ContextPtr rmesa, void *ptr)
{
int i;
- int id = 0;
for (i=1; i < rmesa->rmm->u_size+1; i++)
if(rmesa->rmm->u_list[i].ptr &&
int i, free=-1;
int done_age;
drm_radeon_mem_free_t memfree;
- int tries=0, tries2=0;
- static int t=0;
+ int tries=0;
static int bytes_wasted=0, allocated=0;
if(size < 4096)
allocated += size;
#if 0
+ static int t=0;
if (t != time(NULL)) {
t = time(NULL);
fprintf(stderr, "slots used %d, wasted %d kb, allocated %d\n", rmesa->rmm->u_last, bytes_wasted/1024, allocated/1024);
}
}
}
- done:
rmesa->rmm->u_head = i;
if (free == -1) {
}
#include "r300_emit.h"
-void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long src, unsigned long size)
+static void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long src, unsigned long size)
{
LOCAL_VARS
int cp_size;
void radeon_mm_use(r300ContextPtr rmesa, int id)
{
- unsigned long long ull;
+ uint64_t ull;
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, rmesa->radeon.radeonScreen->scratch[RADEON_MM_SCRATCH]);
#endif
}*/
#endif
- cmd = r300AllocCmdBuf(rmesa, 2 + sizeof(ull) / 4, __FUNCTION__);
+ cmd = (drm_r300_cmd_header_t *)r300AllocCmdBuf(rmesa, 2 + sizeof(ull) / 4, __FUNCTION__);
cmd[0].scratch.cmd_type = R300_CMD_SCRATCH;
cmd[0].scratch.reg = RADEON_MM_SCRATCH;
cmd[0].scratch.n_bufs = 1;
cmd[0].scratch.flags = 0;
cmd ++;
- ull = (unsigned long long)&rmesa->rmm->u_list[id].age;
+ ull = (uint64_t)(intptr_t)&rmesa->rmm->u_list[id].age;
_mesa_memcpy(cmd, &ull, sizeof(ull));
cmd += sizeof(ull) / 4;
#include "context.h"
#include "r300_context.h"
#include "r300_cmdbuf.h"
+#include "r300_ioctl.h"
+#include "r300_maos.h"
+#include "r300_state.h"
#include "radeon_mm.h"
+#include "hash.h"
#include "dispatch.h"
+#include "bufferobj.h"
+#include "vtxfmt.h"
+#include "api_validate.h"
+#include "state.h"
#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 ? \
- ADD_POINTERS(ctx->Array.b.Ptr, ctx->Array.b.BufferObj->Data) : ctx->Array.b.Ptr, \
+ (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
void radeon_init_vtxfmt_a(r300ContextPtr rmesa);
-void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *c_indices )
+static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *c_indices )
{
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct tnl_prim prim;
static void *ptr = NULL;
static struct r300_dma_region rvb;
- GLvoid *indices = c_indices;
+ const GLvoid *indices = c_indices;
if (count > 65535) {
WARN_ONCE("Too many verts!\n");
_mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
}
-void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei count, GLenum type, const GLvoid *c_indices)
+static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei count, GLenum type, const GLvoid *c_indices)
{
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int i;
void *ptr = NULL;
static struct r300_dma_region rvb;
- GLvoid *indices = c_indices;
+ const GLvoid *indices = c_indices;
if (count > 65535) {
WARN_ONCE("Too many verts!\n");
_mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
}
-void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
+static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
{
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLvertexformat *vfmt;
ctx = rmesa->radeon.glCtx;
- vfmt = ctx->TnlModule.Current;
+ vfmt = (GLvertexformat *)ctx->TnlModule.Current;
vfmt->DrawElements = radeonDrawElements;
vfmt->DrawArrays = radeonDrawArrays;
#ifdef HW_VBOS
-void radeonLockArraysEXT(GLcontext *ctx, GLint first, GLsizei count)
+#if 0
+static void radeonLockArraysEXT(GLcontext *ctx, GLint first, GLsizei count)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
- int i;
/* Only when CB_DPATH is defined.
r300Clear tampers over the aos setup without it.
rmesa->state.VB.lock_uptodate = GL_FALSE;
}
-void radeonUnlockArraysEXT(GLcontext *ctx)
+static void radeonUnlockArraysEXT(GLcontext *ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
rmesa->state.VB.LockCount = 0;
rmesa->state.VB.lock_uptodate = GL_FALSE;
}
+#endif
-struct gl_buffer_object *
+static struct gl_buffer_object *
r300NewBufferObject(GLcontext *ctx, GLuint name, GLenum target )
{
struct r300_buffer_object *obj;
return &obj->mesa_obj;
}
-void r300BufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+static void r300BufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
const GLvoid *data, GLenum usage, struct gl_buffer_object *obj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)obj;
- drm_radeon_mem_alloc_t alloc;
- int offset, ret;
/* Free previous buffer */
if (obj->OnCard) {
obj->Usage = usage;
}
-void r300BufferSubData(GLcontext *ctx, GLenum target, GLintptrARB offset,
+static void r300BufferSubData(GLcontext *ctx, GLenum target, GLintptrARB offset,
GLsizeiptrARB size, const GLvoid * data, struct gl_buffer_object * bufObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
}
}
-void *r300MapBuffer(GLcontext *ctx, GLenum target, GLenum access,
+static void *r300MapBuffer(GLcontext *ctx, GLenum target, GLenum access,
struct gl_buffer_object *bufObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
return bufObj->Pointer;
}
-GLboolean r300UnmapBuffer(GLcontext *ctx, GLenum target, struct gl_buffer_object *bufObj)
+static GLboolean r300UnmapBuffer(GLcontext *ctx, GLenum target, struct gl_buffer_object *bufObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)bufObj;
return GL_TRUE;
}
-void r300DeleteBuffer(GLcontext *ctx, struct gl_buffer_object *obj)
+static void r300DeleteBuffer(GLcontext *ctx, struct gl_buffer_object *obj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)obj;
void r300_evict_vbos(GLcontext *ctx, int amount)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
- const struct _mesa_HashTable *hash = ctx->Shared->BufferObjects;
+ struct _mesa_HashTable *hash = ctx->Shared->BufferObjects;
GLuint k = _mesa_HashFirstEntry(hash);
struct gl_buffer_object *obj;
struct r300_buffer_object *r300_obj;