diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2007-03-16 18:56:56 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2007-03-16 18:56:56 +0000 |
commit | 013b0c3138d9de0fc13b7348f9e8d68c95f81b3b (patch) | |
tree | 4f8a35454ce77a5c2acc7093312c44bddaee566e | |
parent | 58229720e9e63b3a6ef03fde20eb0216499f7eb9 (diff) |
Get program parameter tracking and fog working.
Fog is implemented with the shader-instruction-appending code
in core mesa.
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_cache.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_context.h | 41 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_fpc_translate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_indirect.c | 159 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_program.c | 30 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_state.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_state.h | 14 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_state_constants.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_state_dynamic.c | 43 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_state_program.c | 17 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/i915_state_vertex.c | 28 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915tex/intel_context.h | 3 |
13 files changed, 101 insertions, 248 deletions
diff --git a/src/mesa/drivers/dri/i915tex/i915_cache.c b/src/mesa/drivers/dri/i915tex/i915_cache.c index 73511c3649..448d8a4300 100644 --- a/src/mesa/drivers/dri/i915tex/i915_cache.c +++ b/src/mesa/drivers/dri/i915tex/i915_cache.c @@ -228,6 +228,7 @@ void i915_cache_emit(struct i915_cache_context *cctx, { struct intel_context *intel = &cctx->i915->intel; GLuint size = packet_size( packet ); + #if 1 GLuint hash = hash_packet( packet, size ); struct i915_cache *cache = &cctx->cache[packet->cache_id]; diff --git a/src/mesa/drivers/dri/i915tex/i915_context.c b/src/mesa/drivers/dri/i915tex/i915_context.c index bf4e7b7f2f..57958cd742 100644 --- a/src/mesa/drivers/dri/i915tex/i915_context.c +++ b/src/mesa/drivers/dri/i915tex/i915_context.c @@ -137,11 +137,9 @@ i915CreateContext(const __GLcontextModes *mesaVis, driInitExtensions(ctx, i915_extensions, GL_FALSE); - /* always enbale pixel fog. vertex fog uses precaculted fog coord - * will conflict with appended fog program - */ _tnl_allow_vertex_fog( ctx, 0 ); _tnl_allow_pixel_fog( ctx, 1 ); + _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, 36 * sizeof(GLfloat)); diff --git a/src/mesa/drivers/dri/i915tex/i915_context.h b/src/mesa/drivers/dri/i915tex/i915_context.h index 024d8f3c61..9ae3ee97e9 100644 --- a/src/mesa/drivers/dri/i915tex/i915_context.h +++ b/src/mesa/drivers/dri/i915tex/i915_context.h @@ -32,7 +32,6 @@ #define I915_MAX_CONSTANT 32 -#define I915_CONSTANT_SIZE (2+(4*I915_MAX_CONSTANT)) #define I915_PROGRAM_SIZE 192 @@ -79,13 +78,8 @@ struct i915_fragment_program - - - #define I915_TEX_UNITS 8 - - #define I915_DYNAMIC_MODES4 0 #define I915_DYNAMIC_DEPTHSCALE_0 1 #define I915_DYNAMIC_DEPTHSCALE_1 2 @@ -105,8 +99,6 @@ struct i915_context struct intel_context intel; struct i915_cache_context *cctx; - struct i915_fragment_program *fragment_program; - struct { /* Regions aren't actually that appropriate here as the memory may * be from a PBO or FBO. Just use the buffer id. Will have to do @@ -136,8 +128,6 @@ struct i915_context GLboolean done_reset; } dyn_indirect; - - GLuint program_id; }; @@ -148,7 +138,6 @@ struct i915_context extern void i915InitVtbl(struct i915_context *i915); - /*====================================================================== * i915_context.c */ @@ -156,39 +145,27 @@ extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, __DRIcontextPrivate * driContextPriv, void *sharedContextPrivate); - -/*====================================================================== - * i915_state.c - */ -extern void i915InitStateFunctions(struct dd_function_table *functions); - - -/*====================================================================== - * i915_tex.c - */ -extern void i915UpdateTextureState(struct intel_context *intel); -extern void i915InitTextureFuncs(struct dd_function_table *functions); - - - /*====================================================================== * i915_program.c */ extern void i915InitFragProgFuncs(struct dd_function_table *functions); + + /*====================================================================== - * Inline conversion functions. These are better-typed than the - * macros used previously: + * Inline conversion functions. */ static INLINE struct i915_context * -i915_context(GLcontext * ctx) +i915_context( GLcontext *ctx ) { return (struct i915_context *) ctx; } - - -#define I915_CONTEXT(ctx) i915_context(ctx) +static INLINE struct i915_fragment_program * +i915_fragment_program( struct gl_fragment_program *fp ) +{ + return (struct i915_fragment_program *) fp; +} diff --git a/src/mesa/drivers/dri/i915tex/i915_fpc_translate.c b/src/mesa/drivers/dri/i915tex/i915_fpc_translate.c index 26c3894978..2d4ecf3aca 100644 --- a/src/mesa/drivers/dri/i915tex/i915_fpc_translate.c +++ b/src/mesa/drivers/dri/i915tex/i915_fpc_translate.c @@ -273,7 +273,7 @@ i915_translate_program(struct i915_fp_compile *p) const struct gl_fragment_program *program = &p->fp->Base; const struct prog_instruction *inst = program->Base.Instructions; - if (1) + if (0) i915_print_mesa_instructions(inst, program->Base.NumInstructions); /* Is this a parse-failed program? Ensure a valid program is diff --git a/src/mesa/drivers/dri/i915tex/i915_indirect.c b/src/mesa/drivers/dri/i915tex/i915_indirect.c deleted file mode 100644 index 9c3f6aaf2c..0000000000 --- a/src/mesa/drivers/dri/i915tex/i915_indirect.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Emit packets to preserved batch buffers, which can then be - * referenced by the LOAD_INDIRECT command. - * - * Need to figure out what STATIC vs DYNAMIC state is supposed to be. - */ - - - -static GLuint i915_emit_indirect(struct intel_context *intel, - GLuint flag, - const GLuint *state, - GLuint size ) -{ - GLuint delta; - GLuint segment; - - switch (flag) { - case LI0_STATE_DYNAMIC_INDIRECT: - segment = SEGMENT_DYNAMIC_INDIRECT; - - /* Dynamic indirect state is different - tell it the ending - * address, it will execute from either the previous end address - * or the beginning of the 4k page, depending on what it feels - * like. - */ - delta = ((intel->batch->segment_finish_offset[segment] + size - 4) | - DIS0_BUFFER_VALID | - DIS0_BUFFER_RESET); - - - BEGIN_BATCH(2,0); - OUT_BATCH( _3DSTATE_LOAD_INDIRECT | flag | (1<<14) | 0); - OUT_RELOC( intel->batch->buffer, - DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, - DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE, - delta ); - ADVANCE_BATCH(); - break; - - default: - segment = SEGMENT_OTHER_INDIRECT; - - /* Other state is more conventional: tell the hardware the start - * point and size. - */ - delta = (intel->batch->segment_finish_offset[segment] | - SIS0_FORCE_LOAD | /* XXX: fix me */ - SIS0_BUFFER_VALID); - - BEGIN_BATCH(3,0); - OUT_BATCH( _3DSTATE_LOAD_INDIRECT | flag | (1<<14) | 1); - OUT_RELOC( intel->batch->buffer, - DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, - DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE, - delta ); - OUT_BATCH( (size/4)-1 ); - ADVANCE_BATCH(); - - - break; - } - - { - GLuint offset = intel->batch->segment_finish_offset[segment]; - intel->batch->segment_finish_offset[segment] += size; - - if (state != NULL) - memcpy(intel->batch->map + offset, state, size); - - return offset; - } -} - - -/* "constant state", or constant-ish?? - */ -static void emit_static_indirect_state() -{ -} - -/* "slow state", compared probably to the state in - * LOAD_STATE_IMMEDIATE. - */ -static void emit_dynamic_indirect_state() -{ -} - -/* Need to figure out how to do driBO relocations on addresses in the - * indirect state buffers. When do the relocations become invalid? - */ - -static void emit_sampler_state() -{ -} - -static void emit_map_state() -{ -} - -static void emit_program() -{ -} - -static void emit_constants() -{ -} - -void emit_indirect_state() -{ - /* Just emit the packet straight to batch: - */ - - /* Look at the dirty flags and figure out what needs to be sent. - */ -} - -const struct i915_tracked_state i915_indirect_state = { - .dirty = { - .mesa = 0, - .i915 = I915_NEW_STATE_MODE, - .indirect = (INDIRECT_NEW_STATIC | - INDIRECT_NEW_DYNAMIC | - INDIRECT_NEW_SAMPLER | - INDIRECT_NEW_MAP | - INDIRECT_NEW_PROGRAM | - INDIRECT_NEW_CONSTANTS); - }, - .update = upload_indirect_state -}; - - -#if 0 - GLuint size = I915_DYNAMIC_SIZE * 4; - GLuint flag = i915->dyn_indirect.done_reset ? 0 : DIS0_BUFFER_RESET; - - GLuint delta = ( (intel->batch->segment_finish_offset[segment] + size - 4) | - DIS0_BUFFER_VALID | - flag ); - - BEGIN_BATCH(2,0); - OUT_BATCH( _3DSTATE_LOAD_INDIRECT | LI0_STATE_DYNAMIC_INDIRECT | (1<<14) | 0); - OUT_RELOC( intel->batch->buffer, - DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, - DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE, - delta ); - ADVANCE_BATCH(); - - - { - GLuint segment = SEGMENT_DYNAMIC_INDIRECT; - GLuint offset = intel->batch->segment_finish_offset[segment]; - intel->batch->segment_finish_offset[segment] += size; - - if (state != NULL) - memcpy(intel->batch->map + offset, state, size); - - return offset; - } -#endif diff --git a/src/mesa/drivers/dri/i915tex/i915_program.c b/src/mesa/drivers/dri/i915tex/i915_program.c index fdfe39abea..ca21f1147d 100644 --- a/src/mesa/drivers/dri/i915tex/i915_program.c +++ b/src/mesa/drivers/dri/i915tex/i915_program.c @@ -71,7 +71,7 @@ static struct gl_program *i915NewProgram( GLcontext *ctx, case GL_FRAGMENT_PROGRAM_ARB: { struct i915_fragment_program *prog = CALLOC_STRUCT(i915_fragment_program); if (prog) { - prog->id = i915->program_id++; + prog->id = i915->intel.program_id++; return _mesa_init_fragment_program( ctx, &prog->Base, target, id ); @@ -105,13 +105,27 @@ static void i915ProgramStringNotify( GLcontext *ctx, struct gl_program *prog ) { if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct i915_context *i915 = i915_context(ctx); - struct i915_fragment_program *p = (struct i915_fragment_program *)prog; - struct i915_fragment_program *fp = (struct i915_fragment_program *)i915->fragment_program; - if (p == fp) - i915->intel.state.dirty.intel |= INTEL_NEW_FRAGMENT_PROGRAM; - p->id = i915->program_id++; - p->param_state = p->Base.Base.Parameters->StateFlags; + struct intel_context *intel = intel_context(ctx); + + if (prog == &intel->state.FragmentProgram->_Current->Base) + { + struct i915_fragment_program *p = + (struct i915_fragment_program *) prog; + + intel->state.dirty.intel |= INTEL_NEW_FRAGMENT_PROGRAM; + + p->id = intel->program_id++; + p->param_state = p->Base.Base.Parameters->StateFlags; + p->translated = 0; + + /* Gack! do this in the compiler: + */ + if (p->Base.FogOption) { + /* add extra instructions to do fog, then turn off FogOption field */ + _mesa_append_fog_code(ctx, &p->Base); + p->Base.FogOption = GL_NONE; + } + } } else if (target == GL_VERTEX_PROGRAM_ARB) { diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c index b680d4fb49..237e30f816 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state.c +++ b/src/mesa/drivers/dri/i915tex/i915_state.c @@ -76,6 +76,8 @@ const struct intel_tracked_state *atoms[] = &i915_upload_BFO, &i915_upload_BLENDCOLOR, &i915_upload_DEPTHSCALE, +/* &i915_upload_FOGCOLOR, */ +/* &i915_upload_FOGMODE, */ &i915_upload_IAB, &i915_upload_MODES4, &i915_upload_dynamic_indirect, diff --git a/src/mesa/drivers/dri/i915tex/i915_state.h b/src/mesa/drivers/dri/i915tex/i915_state.h index 0f8464fdd7..ca625bf3ff 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state.h +++ b/src/mesa/drivers/dri/i915tex/i915_state.h @@ -57,6 +57,8 @@ const struct intel_tracked_state i915_upload_S7; const struct intel_tracked_state i915_upload_BFO; const struct intel_tracked_state i915_upload_BLENDCOLOR; const struct intel_tracked_state i915_upload_DEPTHSCALE; +const struct intel_tracked_state i915_upload_FOGCOLOR; +const struct intel_tracked_state i915_upload_FOGMODE; const struct intel_tracked_state i915_upload_IAB; const struct intel_tracked_state i915_upload_MODES4; const struct intel_tracked_state i915_upload_dynamic_indirect; @@ -95,4 +97,16 @@ i915_translate_blend_equation(GLenum mode) } } +static INLINE GLuint U_FIXED(GLfloat value, GLuint frac_bits) +{ + value *= (1<<frac_bits); + return value < 0 ? 0 : value; +} + +static INLINE GLint S_FIXED(GLfloat value, GLuint frac_bits) +{ + return value * (1<<frac_bits); +} + + #endif diff --git a/src/mesa/drivers/dri/i915tex/i915_state_constants.c b/src/mesa/drivers/dri/i915tex/i915_state_constants.c index 630f2418b9..bde4f7748a 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state_constants.c +++ b/src/mesa/drivers/dri/i915tex/i915_state_constants.c @@ -44,7 +44,8 @@ static void upload_constants(struct intel_context *intel) { struct i915_context *i915 = i915_context( &intel->ctx ); - struct i915_fragment_program *p = i915->fragment_program; + struct i915_fragment_program *p = + i915_fragment_program(intel->state.FragmentProgram->_Current); GLint i; /* XXX: Pull from state, not ctx!!! Luckily no metaops programs @@ -89,7 +90,7 @@ upload_constants(struct intel_context *intel) * each context will maintain a copy of this internally and update as * required. */ -const struct intel_tracked_state i915_fp_constants = { +const struct intel_tracked_state i915_upload_constants = { .dirty = { .mesa = 0, /* plus fp state flags */ .intel = INTEL_NEW_FRAGMENT_PROGRAM, diff --git a/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c b/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c index 0654a25922..e485184536 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c +++ b/src/mesa/drivers/dri/i915tex/i915_state_dynamic.c @@ -128,6 +128,8 @@ const struct intel_tracked_state i915_upload_MODES4 = { }; + + /*********************************************************************** */ @@ -135,9 +137,7 @@ static void upload_BFO( struct intel_context *intel ) { GLuint bf[2]; - bf[0] = 0; - bf[1] = 0; - + memset( bf, 0, sizeof(bf) ); /* _NEW_STENCIL */ @@ -206,6 +206,8 @@ static void upload_BLENDCOLOR( struct intel_context *intel ) { GLuint bc[2]; + memset( bc, 0, sizeof(bc) ); + /* _NEW_COLOR */ if (intel->state.Color->BlendEnabled) { @@ -221,10 +223,6 @@ static void upload_BLENDCOLOR( struct intel_context *intel ) bc[1] = (a << 24) | (r << 16) | (g << 8) | b; } - else { - bc[0] = 0; - bc[1] = 0; - } set_dynamic_indirect( intel, I915_DYNAMIC_BC_0, @@ -312,8 +310,7 @@ static void upload_DEPTHSCALE( struct intel_context *intel ) { union { GLfloat f; GLuint u; } ds[2]; - ds[0].u = 0; - ds[1].u = 0; + memset( ds, 0, sizeof(ds) ); if (intel->state.Polygon->OffsetFill) { @@ -354,22 +351,34 @@ const struct intel_tracked_state i915_upload_DEPTHSCALE = { static void emit_indirect( struct intel_context *intel ) { struct i915_context *i915 = i915_context( &intel->ctx ); - GLuint buf[I915_DYNAMIC_SIZE], count = 0; - - CHECK( I915_DYNAMIC_MODES4, 1 ); - CHECK( I915_DYNAMIC_DEPTHSCALE_0, 2 ); - CHECK( I915_DYNAMIC_IAB, 1 ); - CHECK( I915_DYNAMIC_BC_0, 2 ); - CHECK( I915_DYNAMIC_BFO_0, 2 ); + GLboolean active; + GLuint i; /* XXX: need to check if we wrap 4kb and if so pad. */ +/* GLuint buf[I915_DYNAMIC_SIZE], count = 0; */ +/* CHECK( I915_DYNAMIC_MODES4, 1 ); */ +/* CHECK( I915_DYNAMIC_DEPTHSCALE_0, 2 ); */ +/* CHECK( I915_DYNAMIC_IAB, 1 ); */ +/* CHECK( I915_DYNAMIC_BC_0, 2 ); */ +/* CHECK( I915_DYNAMIC_BFO_0, 2 ); */ + + + /* Or just emit the whole lot, zeros and all (fix later...): */ + for (active = 0, i = 0; i < I915_DYNAMIC_SIZE; i++) + if (i915->dyn_indirect.buf[i] != 0) { + active = 1; + break; + } + + + /* Also - want to check that something has changed & we're not just * re-emitting the same stuff. */ - if (count) { + if (active) { GLuint size = I915_DYNAMIC_SIZE * 4; GLuint flag = i915->dyn_indirect.done_reset ? 0 : DIS0_BUFFER_RESET; GLuint segment = SEGMENT_DYNAMIC_INDIRECT; diff --git a/src/mesa/drivers/dri/i915tex/i915_state_program.c b/src/mesa/drivers/dri/i915tex/i915_state_program.c index 17ac40c3c5..44d578dd8c 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state_program.c +++ b/src/mesa/drivers/dri/i915tex/i915_state_program.c @@ -46,18 +46,11 @@ static void upload_program( struct intel_context *intel ) { struct i915_context *i915 = i915_context( &intel->ctx ); - struct i915_fragment_program *fp = i915->fragment_program; + struct i915_fragment_program *fp = + i915_fragment_program(intel->state.FragmentProgram->_Current); GLuint i; + - if (&fp->Base != intel->state.FragmentProgram->_Current) { - i915->fragment_program = (struct i915_fragment_program *) - intel->state.FragmentProgram->_Current; - - fp = i915->fragment_program; - /* This is stupid - */ - intel->state.dirty.intel |= INTEL_NEW_FRAGMENT_PROGRAM; - } /* As the compiled program depends only on the original program * text, just store the compiled version in the fragment program @@ -67,6 +60,10 @@ static void upload_program( struct intel_context *intel ) i915_compile_fragment_program(i915, fp); } + if (0) + i915_disassemble_program( fp->program, + fp->program_size ); + /* This is an unnnecessary copy - fix the interface... */ { diff --git a/src/mesa/drivers/dri/i915tex/i915_state_vertex.c b/src/mesa/drivers/dri/i915tex/i915_state_vertex.c index 0cd0e69237..631352db16 100644 --- a/src/mesa/drivers/dri/i915tex/i915_state_vertex.c +++ b/src/mesa/drivers/dri/i915tex/i915_state_vertex.c @@ -102,7 +102,8 @@ do { \ static void i915_calculate_vertex_format( struct intel_context *intel ) { struct i915_context *i915 = i915_context( &intel->ctx ); - struct i915_fragment_program *fp = i915->fragment_program; + struct i915_fragment_program *fp = + i915_fragment_program(intel->state.FragmentProgram->_Current); const GLuint inputsRead = fp->Base.Base.InputsRead; GLuint s2 = S2_TEXCOORD_NONE; GLuint s4 = 0; @@ -127,21 +128,14 @@ static void i915_calculate_vertex_format( struct intel_context *intel ) EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4); } - if (inputsRead & (FRAG_BIT_COL1 | FRAG_BIT_FOGC)) { - if (inputsRead & FRAG_BIT_COL1) { - intel->specoffset = offset / 4; - EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3); - } - else - EMIT_PAD(3); - - if (inputsRead & FRAG_BIT_FOGC) - EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1); - else - EMIT_PAD(1); + if (inputsRead & FRAG_BIT_COL1) { + intel->specoffset = offset / 4; + EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3); + EMIT_PAD(1); } if (inputsRead & FRAG_BIT_FOGC) { + EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4); } @@ -183,9 +177,11 @@ static void i915_calculate_vertex_format( struct intel_context *intel ) intel->vertex_size = vs >> 2; - _mesa_printf("inputs %x vertex size %d\n", - inputsRead, - intel->vertex_size); + if (0) + _mesa_printf("inputs %x vertex size %d\n", + inputsRead, + intel->vertex_size); + i915->vertex_format.LIS2 = s2; i915->vertex_format.LIS4 = s4; intel->state.dirty.intel |= I915_NEW_VERTEX_FORMAT; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 5486f63a1d..27dbc02263 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -234,6 +234,9 @@ struct intel_context */ struct bufmgr *bm; + /* Counter to track program string changes: + */ + GLuint program_id; /* State for intelvb.c and inteltris.c. */ |