From 1ca512c643553bd3504abd258ab80b7a550ab292 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 11:46:27 -0600 Subject: mesa: fix default buffer object access value --- src/mesa/main/bufferobj.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index ecdb4d219c8..dd4ac4679e2 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -38,6 +38,13 @@ #include "bufferobj.h" +#ifdef FEATURE_OES_mapbuffer +#define DEFAULT_ACCESS GL_WRITE_ONLY; +#else +#define DEFAULT_ACCESS GL_READ_WRITE; +#endif + + /** * Get the buffer object bound to the specified target in a GL context. * @@ -255,7 +262,7 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj, obj->RefCount = 1; obj->Name = name; obj->Usage = GL_STATIC_DRAW_ARB; - obj->Access = GL_READ_WRITE_ARB; + obj->Access = DEFAULT_ACCESS; } @@ -1037,7 +1044,7 @@ _mesa_UnmapBufferARB(GLenum target) status = ctx->Driver.UnmapBuffer( ctx, target, bufObj ); } - bufObj->Access = GL_READ_WRITE_ARB; /* initial value, OK? */ + bufObj->Access = DEFAULT_ACCESS; bufObj->Pointer = NULL; return status; -- cgit v1.2.3 From 006fb638188f083d64a2427cd28979b432622f3e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 18:27:22 -0600 Subject: mesa: fix swizzle failure, fix typo --- src/mesa/main/texenvprogram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 6877ef96f21..c699c43429a 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -375,7 +375,7 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p ) { int bit; - /* First try to find availble temp not previously used (to avoid + /* First try to find available temp not previously used (to avoid * starting a new texture indirection). According to the spec, the * ~p->temps_output isn't necessary, but will keep it there for * now: @@ -575,14 +575,16 @@ static struct ureg register_const4f( struct texenv_fragment_program *p, { GLfloat values[4]; GLuint idx, swizzle; + struct ureg r; values[0] = s0; values[1] = s1; values[2] = s2; values[3] = s3; idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle ); - ASSERT(swizzle == SWIZZLE_NOOP); - return make_ureg(PROGRAM_CONSTANT, idx); + r = make_ureg(PROGRAM_CONSTANT, idx); + r.swz = swizzle; + return r; } #define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -- cgit v1.2.3 From 3f99f501db2582e241851e63e432c18e2de415be Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 18:40:16 -0600 Subject: mesa: increase MAX_INSTRUCTIONS --- src/mesa/main/texenvprogram.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index c699c43429a..c64d88faf9c 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -37,11 +37,9 @@ #include "texenvprogram.h" /** - * This MAX is probably a bit generous, but that's OK. There can be - * up to four instructions per texture unit (TEX + 3 for combine), - * then there's fog and specular add. + * Up to nine instructions per tex unit, plus fog, specular color. */ -#define MAX_INSTRUCTIONS ((MAX_TEXTURE_UNITS * 4) + 12) +#define MAX_INSTRUCTIONS ((MAX_TEXTURE_UNITS * 9) + 12) #define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) -- cgit v1.2.3 From 092748990f75a0348f24a40e92872f08a9958e66 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 19:22:29 -0600 Subject: mesa: fix/simplify initialization of vertex/fragment program limits Defaults for program length, num ALU instructions, num indirections, etc. basically indicate no limit for software rendering. Driver should override as needed. --- src/mesa/main/config.h | 4 +--- src/mesa/main/context.c | 53 ++++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 30 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index f8109ec755c..5e9a4f89394 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -176,13 +176,11 @@ /** For GL_ARB_fragment_program */ /*@{*/ #define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0 -#define MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS 48 -#define MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS 24 -#define MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS 4 /*@}*/ /** For any program target/extension */ /*@{*/ +#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024) #define MAX_PROGRAM_LOCAL_PARAMS 128 /* KW: power of two */ #define MAX_PROGRAM_ENV_PARAMS 128 #define MAX_PROGRAM_MATRICES 8 diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ed3faecf0db..144da613843 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -819,11 +819,33 @@ _mesa_init_current(GLcontext *ctx) /** - * Init vertex/fragment program native limits from logical limits. + * Init vertex/fragment program limits. + * Important: drivers should override these with actual limits. */ static void -init_natives(struct gl_program_constants *prog) +init_program_limits(GLenum type, struct gl_program_constants *prog) { + prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxTemps = MAX_PROGRAM_TEMPS; + prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS; + prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS; + prog->MaxUniformComponents = 4 * MAX_UNIFORMS; + + if (type == GL_VERTEX_PROGRAM_ARB) { + prog->MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS; + prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; + prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; + } + else { + prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS; + prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS; + prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS; + } + + /* copy the above limits to init native limits */ prog->MaxNativeInstructions = prog->MaxInstructions; prog->MaxNativeAluInstructions = prog->MaxAluInstructions; prog->MaxNativeTexInstructions = prog->MaxTexInstructions; @@ -885,33 +907,10 @@ _mesa_init_constants(GLcontext *ctx) ctx->Const.MaxViewportWidth = MAX_WIDTH; ctx->Const.MaxViewportHeight = MAX_HEIGHT; #if FEATURE_ARB_vertex_program - ctx->Const.VertexProgram.MaxInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS; - ctx->Const.VertexProgram.MaxAluInstructions = 0; - ctx->Const.VertexProgram.MaxTexInstructions = 0; - ctx->Const.VertexProgram.MaxTexIndirections = 0; - ctx->Const.VertexProgram.MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; - ctx->Const.VertexProgram.MaxTemps = MAX_PROGRAM_TEMPS; - ctx->Const.VertexProgram.MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS; - ctx->Const.VertexProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS; - ctx->Const.VertexProgram.MaxEnvParams = MAX_PROGRAM_ENV_PARAMS; - ctx->Const.VertexProgram.MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; - ctx->Const.VertexProgram.MaxUniformComponents = 4 * MAX_UNIFORMS; - init_natives(&ctx->Const.VertexProgram); + init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram); #endif - #if FEATURE_ARB_fragment_program - ctx->Const.FragmentProgram.MaxInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS; - ctx->Const.FragmentProgram.MaxAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS; - ctx->Const.FragmentProgram.MaxTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS; - ctx->Const.FragmentProgram.MaxTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS; - ctx->Const.FragmentProgram.MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS; - ctx->Const.FragmentProgram.MaxTemps = MAX_PROGRAM_TEMPS; - ctx->Const.FragmentProgram.MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS; - ctx->Const.FragmentProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS; - ctx->Const.FragmentProgram.MaxEnvParams = MAX_PROGRAM_ENV_PARAMS; - ctx->Const.FragmentProgram.MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS; - ctx->Const.FragmentProgram.MaxUniformComponents = 4 * MAX_UNIFORMS; - init_natives(&ctx->Const.FragmentProgram); + init_program_limits(GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram); #endif ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; -- cgit v1.2.3 From 1ef90b3f9af12102101e5d30b2d73cbdabd86f24 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Sep 2008 18:31:47 -0600 Subject: mesa: add some braces --- src/mesa/shader/prog_execute.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 5afd9eb1534..768e936d5f6 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -81,11 +81,12 @@ get_register_pointer(const struct prog_src_register *source, { if (source->RelAddr) { const GLint reg = source->Index + machine->AddressReg[0][0]; - if (source->File == PROGRAM_ENV_PARAM) + if (source->File == PROGRAM_ENV_PARAM) { if (reg < 0 || reg >= MAX_PROGRAM_ENV_PARAMS) return ZeroVec; else return machine->EnvParams[reg]; + } else { const struct gl_program_parameter_list *params; ASSERT(source->File == PROGRAM_LOCAL_PARAM || -- cgit v1.2.3 From 13a8c18d3d0ca505f053a15fc664a705cbc8be84 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Sep 2008 09:25:32 -0600 Subject: gallium: rename tgsi_translate_mesa_program() to st_translate_mesa_program() --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 2 +- src/mesa/state_tracker/st_mesa_to_tgsi.h | 2 +- src/mesa/state_tracker/st_program.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 524d8890b5c..50e638df46b 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -713,7 +713,7 @@ find_temporaries(const struct gl_program *program, * \return number of tokens placed in 'tokens' buffer, or zero if error */ GLuint -tgsi_translate_mesa_program( +st_translate_mesa_program( uint procType, const struct gl_program *program, GLuint numInputs, diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index f17f2eac963..77c74644b8b 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -40,7 +40,7 @@ struct tgsi_token; struct gl_program; GLuint -tgsi_translate_mesa_program( +st_translate_mesa_program( uint procType, const struct gl_program *program, GLuint numInputs, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index b2abf0286e7..55b52c37451 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -307,7 +307,7 @@ st_translate_vertex_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, + num_tokens = st_translate_mesa_program( TGSI_PROCESSOR_VERTEX, &stvp->Base.Base, /* inputs */ vs_num_inputs, @@ -481,7 +481,7 @@ st_translate_fragment_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, + num_tokens = st_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, &stfp->Base.Base, /* inputs */ fs_num_inputs, -- cgit v1.2.3 From ee80c64be8ebeebc1cf4c4913049eb07b9326b96 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 26 Sep 2008 07:40:05 -0600 Subject: mesa: fix param indexing --- src/mesa/main/texparam.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 664adadfb9c..acddb6663bb 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -903,9 +903,9 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) #ifdef FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: params[0] = obj->CropRect[0]; - params[0] = obj->CropRect[1]; - params[0] = obj->CropRect[2]; - params[0] = obj->CropRect[3]; + params[1] = obj->CropRect[1]; + params[2] = obj->CropRect[2]; + params[3] = obj->CropRect[3]; break; #endif default: @@ -1053,9 +1053,9 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) #ifdef FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: params[0] = obj->CropRect[0]; - params[0] = obj->CropRect[1]; - params[0] = obj->CropRect[2]; - params[0] = obj->CropRect[3]; + params[1] = obj->CropRect[1]; + params[2] = obj->CropRect[2]; + params[3] = obj->CropRect[3]; break; #endif default: -- cgit v1.2.3 From 4bc39c58eb7fdf3a0be62bed666998a0d1789dcf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Sep 2008 07:40:45 -0600 Subject: mesa: fix assertion in _mesa_reference_program() --- src/mesa/shader/program.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index b3618641e50..738891a0293 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -372,7 +372,11 @@ _mesa_reference_program(GLcontext *ctx, assert(ptr); if (*ptr && prog) { /* sanity check */ - ASSERT((*ptr)->Target == prog->Target); + if ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB) + ASSERT(prog->Target == GL_VERTEX_PROGRAM_ARB); + else if ((*ptr)->Target == GL_FRAGMENT_PROGRAM_ARB) + ASSERT(prog->Target == GL_FRAGMENT_PROGRAM_ARB || + prog->Target == GL_FRAGMENT_PROGRAM_NV); } if (*ptr == prog) { return; /* no change */ -- cgit v1.2.3 From a4a5a37f2760eca97b85f699c932c746da4d8e6c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Sep 2008 07:45:06 -0600 Subject: mesa: remove invalid assertions that programs have parameters Fixes failure with demos/fplight.c --- src/mesa/main/state.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index d233201b0ba..48656bd35ee 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -258,12 +258,6 @@ update_program(GLcontext *ctx) } } - if (ctx->VertexProgram._Current) - assert(ctx->VertexProgram._Current->Base.Parameters); - if (ctx->FragmentProgram._Current) - assert(ctx->FragmentProgram._Current->Base.Parameters); - - /* XXX: get rid of _Active flag. */ #if 1 -- cgit v1.2.3 From 7d99ddcb2bb09f1f54d91e6e20e42d217a5bccdf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 26 Sep 2008 12:48:23 -0700 Subject: intel: Fix a number of memory leaks on context destroy. --- src/mesa/drivers/dri/i915/i830_vtbl.c | 7 ++++++ src/mesa/drivers/dri/i915/i915_vtbl.c | 7 ++++++ src/mesa/drivers/dri/i965/brw_draw.c | 10 +++++++++ src/mesa/drivers/dri/i965/brw_state_cache.c | 5 +++-- src/mesa/drivers/dri/i965/brw_vtbl.c | 34 +++++++++++++++++++++++++++++ src/mesa/drivers/dri/intel/intel_context.c | 12 ++++++++++ src/mesa/drivers/dri/intel/intel_context.h | 1 - src/mesa/drivers/dri/intel/intel_regions.c | 10 +++++++++ 8 files changed, 83 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index 0ab27704d52..773a8b4dd01 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -566,6 +566,13 @@ i830_destroy_context(struct intel_context *intel) GLuint i; struct i830_context *i830 = i830_context(&intel->ctx); + intel_region_release(&i830->state.draw_region); + intel_region_release(&i830->state.depth_region); + intel_region_release(&i830->meta.draw_region); + intel_region_release(&i830->meta.depth_region); + intel_region_release(&i830->initial.draw_region); + intel_region_release(&i830->initial.depth_region); + for (i = 0; i < I830_TEX_UNITS; i++) { if (i830->state.tex_buffer[i] != NULL) { dri_bo_unreference(i830->state.tex_buffer[i]); diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index edbbe23e094..7431a9cf76d 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -490,6 +490,13 @@ i915_destroy_context(struct intel_context *intel) GLuint i; struct i915_context *i915 = i915_context(&intel->ctx); + intel_region_release(&i915->state.draw_region); + intel_region_release(&i915->state.depth_region); + intel_region_release(&i915->meta.draw_region); + intel_region_release(&i915->meta.depth_region); + intel_region_release(&i915->initial.draw_region); + intel_region_release(&i915->initial.depth_region); + for (i = 0; i < I915_TEX_UNITS; i++) { if (i915->state.tex_buffer[i] != NULL) { dri_bo_unreference(i915->state.tex_buffer[i]); diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 9a353fc7b66..39ce8eb4b62 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -409,8 +409,18 @@ void brw_draw_init( struct brw_context *brw ) void brw_draw_destroy( struct brw_context *brw ) { + int i; + if (brw->vb.upload.bo != NULL) { dri_bo_unreference(brw->vb.upload.bo); brw->vb.upload.bo = NULL; } + + for (i = 0; i < VERT_ATTRIB_MAX; i++) { + dri_bo_unreference(brw->vb.inputs[i].bo); + brw->vb.inputs[i].bo = NULL; + } + + dri_bo_unreference(brw->ib.bo); + brw->ib.bo = NULL; } diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index 1318dea5940..d5b51664066 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -497,9 +497,10 @@ void brw_destroy_cache( struct brw_context *brw ) GLuint i; brw_clear_cache(brw); - for (i = 0; i < BRW_MAX_CACHE; i++) + for (i = 0; i < BRW_MAX_CACHE; i++) { + dri_bo_unreference(brw->cache.last_bo[i]); free(brw->cache.name[i]); - + } free(brw->cache.items); brw->cache.items = NULL; brw->cache.size = 0; diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 2a03fc59f3e..3780d3dad2e 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -51,6 +51,12 @@ #include "brw_vs.h" #include +static void +dri_bo_release(dri_bo **bo) +{ + dri_bo_unreference(*bo); + *bo = NULL; +} /* called from intelDestroyContext() */ @@ -58,6 +64,7 @@ static void brw_destroy_context( struct intel_context *intel ) { GLcontext *ctx = &intel->ctx; struct brw_context *brw = brw_context(&intel->ctx); + int i; brw_destroy_metaops(brw); brw_destroy_state(brw); @@ -65,6 +72,33 @@ static void brw_destroy_context( struct intel_context *intel ) brw_ProgramCacheDestroy( ctx ); brw_FrameBufferTexDestroy( brw ); + + for (i = 0; i < brw->state.nr_draw_regions; i++) + intel_region_release(&brw->state.draw_regions[i]); + brw->state.nr_draw_regions = 0; + intel_region_release(&brw->state.depth_region); + + dri_bo_release(&brw->curbe.curbe_bo); + dri_bo_release(&brw->vs.prog_bo); + dri_bo_release(&brw->vs.state_bo); + dri_bo_release(&brw->gs.prog_bo); + dri_bo_release(&brw->gs.state_bo); + dri_bo_release(&brw->clip.prog_bo); + dri_bo_release(&brw->clip.state_bo); + dri_bo_release(&brw->clip.vp_bo); + dri_bo_release(&brw->sf.prog_bo); + dri_bo_release(&brw->sf.state_bo); + dri_bo_release(&brw->sf.vp_bo); + for (i = 0; i < BRW_MAX_TEX_UNIT; i++) + dri_bo_release(&brw->wm.sdc_bo[i]); + dri_bo_release(&brw->wm.bind_bo); + for (i = 0; i < BRW_WM_MAX_SURF; i++) + dri_bo_release(&brw->wm.surf_bo[i]); + dri_bo_release(&brw->wm.prog_bo); + dri_bo_release(&brw->wm.state_bo); + dri_bo_release(&brw->cc.prog_bo); + dri_bo_release(&brw->cc.state_bo); + dri_bo_release(&brw->cc.vp_bo); } /* called from intelDrawBuffer() diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 57e574447a6..ccd74baa7c5 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -810,7 +810,12 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv) intel->Fallback = 0; /* don't call _swrast_Flush later */ intel_batchbuffer_free(intel->batch); + intel->batch = NULL; + free(intel->prim.vb); + intel->prim.vb = NULL; + dri_bo_unreference(intel->prim.vb_bo); + intel->prim.vb_bo = NULL; if (release_texture_heaps) { /* This share group is about to go away, free our private @@ -820,6 +825,13 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv) fprintf(stderr, "do something to free texture heaps\n"); } + intel_region_release(&intel->front_region); + intel_region_release(&intel->back_region); + intel_region_release(&intel->third_region); + intel_region_release(&intel->depth_region); + + driDestroyOptionCache(&intel->optionCache); + /* free the Mesa context */ _mesa_free_context_data(&intel->ctx); } diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 4af4cb9c96f..554159ac441 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -226,7 +226,6 @@ struct intel_context GLenum reduced_primitive; GLuint vertex_size; GLubyte *verts; /* points to tnl->clipspace.vertex_buf */ - struct intel_region *draw_region; /* Fallback rasterization functions */ diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index cb0f4ba083b..45faf64c713 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -478,6 +478,11 @@ intel_recreate_static(struct intel_context *intel, region->pitch = intelScreen->pitch; region->height = intelScreen->height; /* needed? */ + if (region->buffer != NULL) { + dri_bo_unreference(region->buffer); + region->buffer = NULL; + } + if (intel->ttm) { assert(region_desc->bo_handle != -1); region->buffer = intel_bo_gem_create_from_name(intel->bufmgr, @@ -486,6 +491,11 @@ intel_recreate_static(struct intel_context *intel, intel_set_region_tiling_gem(intel, region, region_desc->bo_handle); } else { + if (region->classic_map != NULL) { + drmUnmap(region->classic_map, + region->pitch * region->cpp * region->height); + region->classic_map = NULL; + } ret = drmMap(intel->driFd, region_desc->handle, region->pitch * region->cpp * region->height, ®ion->classic_map); -- cgit v1.2.3 From 8fd329d04885eba7587bbe7604d3a1088e35de40 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Sep 2008 11:18:06 -0600 Subject: mesa: fix temp register allocation problems. Complex texcombine modes were running out of registers (>32 registers for 8 tex units). --- src/mesa/main/texenvprogram.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index c64d88faf9c..97aa87e58cf 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -398,6 +398,14 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p ) } +/** Mark a temp reg as being no longer allocatable. */ +static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) +{ + if (r.file == PROGRAM_TEMPORARY) + p->temps_output |= (1 << r.idx); +} + + static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p ) { GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; @@ -491,10 +499,12 @@ emit_op(struct texenv_fragment_program *p, emit_dst( &inst->DstReg, dest, mask ); +#if 0 /* Accounting for indirection tracking: */ if (dest.file == PROGRAM_TEMPORARY) p->temps_output |= 1 << dest.idx; +#endif return inst; } @@ -549,6 +559,10 @@ static struct ureg emit_texld( struct texenv_fragment_program *p, p->program->Base.NumTexInstructions++; + /* Accounting for indirection tracking: + */ + reserve_temp(p, dest); + /* Is this a texture indirection? */ if ((coord.file == PROGRAM_TEMPORARY && @@ -1062,6 +1076,7 @@ create_new_program(GLcontext *ctx, struct state_key *key, for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) if (key->enabled_units & (1< Date: Tue, 23 Sep 2008 21:38:19 -0500 Subject: glapi: add gl_dispatch_functions_start and end --- src/mesa/glapi/glapi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 09aaea3d93a..c92b096f68e 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -290,6 +290,16 @@ _glapi_get_context(void) #endif } +#ifdef USE_X86_ASM + +#if defined( GLX_USE_TLS ) +extern GLubyte gl_dispatch_functions_start[]; +extern GLubyte gl_dispatch_functions_end[]; +#else +extern const GLubyte gl_dispatch_functions_start[]; +#endif + +#endif /* USE_X86_ASM */ #if defined(PTHREADS) || defined(GLX_USE_TLS) -- cgit v1.2.3 From 2e5d717007ba6515b094b9af8ed869130185a308 Mon Sep 17 00:00:00 2001 From: Tobias Jakobi Date: Sat, 27 Sep 2008 08:51:45 +0100 Subject: glapi: add DISPATCH_FUNCTION_SIZE --- src/mesa/glapi/glapi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index c92b096f68e..c3ebf60719f 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -302,6 +302,20 @@ extern const GLubyte gl_dispatch_functions_start[]; #endif /* USE_X86_ASM */ +#if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS) +# define DISPATCH_FUNCTION_SIZE 16 +#elif defined(USE_X86_ASM) +# if defined(THREADS) && !defined(GLX_USE_TLS) +# define DISPATCH_FUNCTION_SIZE 32 +# else +# define DISPATCH_FUNCTION_SIZE 16 +# endif +#endif + +#if !defined(DISPATCH_FUNCTION_SIZE) && !defined(XFree86Server) && !defined(XGLServer) +# define NEED_FUNCTION_POINTER +#endif + #if defined(PTHREADS) || defined(GLX_USE_TLS) /** * Perform platform-specific GL API entry-point fixups. -- cgit v1.2.3 From b5d59222ccbec9db23b6847737765a4dc0d8c47b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 25 Sep 2008 17:19:47 -0700 Subject: Remove TNL-to-VP tracking from i965 The i965 driver previously had it's own set of code to convert fixed-function TNL state to a vertex program. Core Mesa has code to do this, so there is no reason to duplicate that effort in the driver. In fact, this duplication leads to bugs when other aspects of the Mesa infrastructure change. --- src/mesa/drivers/dri/i965/brw_context.c | 2 - src/mesa/drivers/dri/i965/brw_context.h | 5 - src/mesa/drivers/dri/i965/brw_state.h | 1 - src/mesa/drivers/dri/i965/brw_state_upload.c | 1 - src/mesa/drivers/dri/i965/brw_vs.h | 4 - src/mesa/drivers/dri/i965/brw_vs_tnl.c | 1653 +------------------------- src/mesa/drivers/dri/i965/brw_vtbl.c | 1 - 7 files changed, 2 insertions(+), 1665 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 92629016d98..5f604771766 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -152,8 +152,6 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, brw_draw_init( brw ); - brw_ProgramCacheInit( ctx ); - return GL_TRUE; } diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index b04487ecee9..8bddc9da405 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -130,7 +130,6 @@ struct brw_context; #define BRW_NEW_CONTEXT 0x80 #define BRW_NEW_WM_INPUT_DIMENSIONS 0x100 #define BRW_NEW_INPUT_VARYING 0x200 -#define BRW_NEW_TNL_PROGRAM 0x400 #define BRW_NEW_PSP 0x800 #define BRW_NEW_METAOPS 0x1000 #define BRW_NEW_FENCE 0x2000 @@ -488,10 +487,6 @@ struct brw_context GLboolean active; } metaops; - /* Track fixed function t&l in a vertex program: - */ - struct gl_vertex_program *tnl_program; - struct brw_tnl_cache tnl_program_cache; /* Active vertex program: */ diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 3ea6151ae95..4c04036ef08 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -74,7 +74,6 @@ const struct brw_tracked_state brw_wm_unit; const struct brw_tracked_state brw_psp_urb_cbs; const struct brw_tracked_state brw_active_vertprog; -const struct brw_tracked_state brw_tnl_vertprog; const struct brw_tracked_state brw_pipe_control; const struct brw_tracked_state brw_clear_surface_cache; diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 7d4fd467b1c..b6a52843a81 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -45,7 +45,6 @@ const struct brw_tracked_state *atoms[] = { &brw_check_fallback, - &brw_tnl_vertprog, &brw_active_vertprog, &brw_wm_input_sizes, &brw_vs_prog, diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index 41a33ffe387..22388ec99d0 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -80,8 +80,4 @@ struct brw_vs_compile { void brw_vs_emit( struct brw_vs_compile *c ); - -void brw_ProgramCacheDestroy( GLcontext *ctx ); -void brw_ProgramCacheInit( GLcontext *ctx ); - #endif diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c index 9b04f19112a..eacc289f1f1 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c +++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c @@ -33,1635 +33,15 @@ #include "main/glheader.h" #include "main/macros.h" #include "main/enums.h" -#include "shader/prog_parameter.h" -#include "shader/prog_print.h" -#include "shader/prog_statevars.h" #include "brw_vs.h" #include "brw_state.h" -struct state_key { - unsigned light_global_enabled:1; - unsigned light_local_viewer:1; - unsigned light_twoside:1; - unsigned light_color_material:1; - unsigned light_color_material_mask:12; - unsigned light_material_mask:12; - unsigned normalize:1; - unsigned rescale_normals:1; - unsigned fog_source_is_depth:1; - unsigned tnl_do_vertex_fog:1; - unsigned separate_specular:1; - unsigned fog_option:2; - unsigned point_attenuated:1; - unsigned texture_enabled_global:1; - unsigned fragprog_inputs_read:12; - - struct { - unsigned light_enabled:1; - unsigned light_eyepos3_is_zero:1; - unsigned light_spotcutoff_is_180:1; - unsigned light_attenuated:1; - unsigned texunit_really_enabled:1; - unsigned texmat_enabled:1; - unsigned texgen_enabled:4; - unsigned texgen_mode0:4; - unsigned texgen_mode1:4; - unsigned texgen_mode2:4; - unsigned texgen_mode3:4; - } unit[8]; -}; - - - -#define FOG_NONE 0 -#define FOG_LINEAR 1 -#define FOG_EXP 2 -#define FOG_EXP2 3 - -static GLuint translate_fog_mode( GLenum mode ) -{ - switch (mode) { - case GL_LINEAR: return FOG_LINEAR; - case GL_EXP: return FOG_EXP; - case GL_EXP2: return FOG_EXP2; - default: return FOG_NONE; - } -} - -#define TXG_NONE 0 -#define TXG_OBJ_LINEAR 1 -#define TXG_EYE_LINEAR 2 -#define TXG_SPHERE_MAP 3 -#define TXG_REFLECTION_MAP 4 -#define TXG_NORMAL_MAP 5 - -static GLuint translate_texgen( GLboolean enabled, GLenum mode ) -{ - if (!enabled) - return TXG_NONE; - - switch (mode) { - case GL_OBJECT_LINEAR: return TXG_OBJ_LINEAR; - case GL_EYE_LINEAR: return TXG_EYE_LINEAR; - case GL_SPHERE_MAP: return TXG_SPHERE_MAP; - case GL_REFLECTION_MAP_NV: return TXG_REFLECTION_MAP; - case GL_NORMAL_MAP_NV: return TXG_NORMAL_MAP; - default: return TXG_NONE; - } -} - -static void make_state_key( GLcontext *ctx, struct state_key *key ) -{ - struct brw_context *brw = brw_context(ctx); - const struct gl_fragment_program *fp = brw->fragment_program; - GLuint i; - - /* This now relies on texenvprogram.c being active: - */ - assert(fp); - - memset(key, 0, sizeof(*key)); - - /* BRW_NEW_FRAGMENT_PROGRAM */ - key->fragprog_inputs_read = fp->Base.InputsRead; - - /* _NEW_LIGHT */ - key->separate_specular = (brw->attribs.Light->Model.ColorControl == - GL_SEPARATE_SPECULAR_COLOR); - - /* _NEW_LIGHT */ - if (brw->attribs.Light->Enabled) { - key->light_global_enabled = 1; - - if (brw->attribs.Light->Model.LocalViewer) - key->light_local_viewer = 1; - - if (brw->attribs.Light->Model.TwoSide) - key->light_twoside = 1; - - if (brw->attribs.Light->ColorMaterialEnabled) { - key->light_color_material = 1; - key->light_color_material_mask = brw->attribs.Light->ColorMaterialBitmask; - } - - /* BRW_NEW_INPUT_VARYING */ - - /* For these programs, material values are stuffed into the - * generic slots: - */ - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (brw->vb.info.varying & (1<<(VERT_ATTRIB_GENERIC0 + i))) - key->light_material_mask |= 1<attribs.Light->Light[i]; - - if (light->Enabled) { - key->unit[i].light_enabled = 1; - - if (light->EyePosition[3] == 0.0) - key->unit[i].light_eyepos3_is_zero = 1; - - if (light->SpotCutoff == 180.0) - key->unit[i].light_spotcutoff_is_180 = 1; - - if (light->ConstantAttenuation != 1.0 || - light->LinearAttenuation != 0.0 || - light->QuadraticAttenuation != 0.0) - key->unit[i].light_attenuated = 1; - } - } - } - - /* _NEW_TRANSFORM */ - if (brw->attribs.Transform->Normalize) - key->normalize = 1; - - if (brw->attribs.Transform->RescaleNormals) - key->rescale_normals = 1; - - /* BRW_NEW_FRAGMENT_PROGRAM */ - key->fog_option = translate_fog_mode(fp->FogOption); - if (key->fog_option) - key->fragprog_inputs_read |= FRAG_BIT_FOGC; - - /* _NEW_FOG */ - if (brw->attribs.Fog->FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) - key->fog_source_is_depth = 1; - - /* _NEW_HINT, ??? */ - if (1) - key->tnl_do_vertex_fog = 1; - - /* _NEW_POINT */ - if (brw->attribs.Point->_Attenuated) - key->point_attenuated = 1; - - /* _NEW_TEXTURE */ - if (brw->attribs.Texture->_TexGenEnabled || - brw->attribs.Texture->_TexMatEnabled || - brw->attribs.Texture->_EnabledUnits) - key->texture_enabled_global = 1; - - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[i]; - - if (texUnit->_ReallyEnabled) - key->unit[i].texunit_really_enabled = 1; - - if (brw->attribs.Texture->_TexMatEnabled & ENABLE_TEXMAT(i)) - key->unit[i].texmat_enabled = 1; - - if (texUnit->TexGenEnabled) { - key->unit[i].texgen_enabled = 1; - - key->unit[i].texgen_mode0 = - translate_texgen( texUnit->TexGenEnabled & (1<<0), - texUnit->GenModeS ); - key->unit[i].texgen_mode1 = - translate_texgen( texUnit->TexGenEnabled & (1<<1), - texUnit->GenModeT ); - key->unit[i].texgen_mode2 = - translate_texgen( texUnit->TexGenEnabled & (1<<2), - texUnit->GenModeR ); - key->unit[i].texgen_mode3 = - translate_texgen( texUnit->TexGenEnabled & (1<<3), - texUnit->GenModeQ ); - } - } -} - - - -/* Very useful debugging tool - produces annotated listing of - * generated program with line/function references for each - * instruction back into this file: - */ -#define DISASSEM 0 - -/* Should be tunable by the driver - do we want to do matrix - * multiplications with DP4's or with MUL/MAD's? SSE works better - * with the latter, drivers may differ. - */ -#define PREFER_DP4 1 - - -/* Use uregs to represent registers internally, translate to Mesa's - * expected formats on emit. - * - * NOTE: These are passed by value extensively in this file rather - * than as usual by pointer reference. If this disturbs you, try - * remembering they are just 32bits in size. - * - * GCC is smart enough to deal with these dword-sized structures in - * much the same way as if I had defined them as dwords and was using - * macros to access and set the fields. This is much nicer and easier - * to evolve. - */ -struct ureg { - GLuint file:4; - GLint idx:8; /* relative addressing may be negative */ - GLuint negate:1; - GLuint swz:12; - GLuint pad:7; -}; - - -struct tnl_program { - const struct state_key *state; - struct gl_vertex_program *program; - - GLuint nr_instructions; - GLuint temp_in_use; - GLuint temp_reserved; - - struct ureg eye_position; - struct ureg eye_position_normalized; - struct ureg eye_normal; - struct ureg identity; - - GLuint materials; - GLuint color_materials; -}; - - -const static struct ureg undef = { - PROGRAM_UNDEFINED, - ~0, - 0, - 0, - 0 -}; - -/* Local shorthand: - */ -#define X SWIZZLE_X -#define Y SWIZZLE_Y -#define Z SWIZZLE_Z -#define W SWIZZLE_W - - -/* Construct a ureg: - */ -static struct ureg make_ureg(GLuint file, GLint idx) -{ - struct ureg reg; - reg.file = file; - reg.idx = idx; - reg.negate = 0; - reg.swz = SWIZZLE_NOOP; - reg.pad = 0; - return reg; -} - - - -static struct ureg ureg_negate( struct ureg reg ) -{ - reg.negate ^= 1; - return reg; -} - - -static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) -{ - reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), - GET_SWZ(reg.swz, y), - GET_SWZ(reg.swz, z), - GET_SWZ(reg.swz, w)); - - return reg; -} - -static struct ureg swizzle1( struct ureg reg, int x ) -{ - return swizzle(reg, x, x, x, x); -} - -static struct ureg get_temp( struct tnl_program *p ) -{ - int bit = ffs( ~p->temp_in_use ); - if (!bit) { - fprintf(stderr, "%s: out of temporaries\n", __FILE__); - assert(0); - } - - if (bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, bit-1); -} - -static struct ureg reserve_temp( struct tnl_program *p ) -{ - struct ureg temp = get_temp( p ); - p->temp_reserved |= 1<temp_in_use &= ~(1<temp_in_use |= p->temp_reserved; /* can't release reserved temps */ - } -} - -static void release_temps( struct tnl_program *p ) -{ - p->temp_in_use = p->temp_reserved; -} - - - -static struct ureg register_input( struct tnl_program *p, GLuint input ) -{ - assert(input < 32); - - p->program->Base.InputsRead |= (1<program->Base.OutputsWritten |= (1<program->Base.Parameters, values, 4, - &swizzle); - assert(swizzle == SWIZZLE_NOOP); /* Need to handle swizzle in reg setup */ - return make_ureg(PROGRAM_STATE_VAR, idx); -} - -#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) -#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) -#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) - -static GLboolean is_undef( struct ureg reg ) -{ - return reg.file == PROGRAM_UNDEFINED; -} - -static struct ureg get_identity_param( struct tnl_program *p ) -{ - if (is_undef(p->identity)) - p->identity = register_const4f(p, 0,0,0,1); - - return p->identity; -} - -static struct ureg register_param5( struct tnl_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4) -{ - gl_state_index tokens[STATE_LENGTH]; - GLint idx; - tokens[0] = s0; - tokens[1] = s1; - tokens[2] = s2; - tokens[3] = s3; - tokens[4] = s4; - idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); - return make_ureg(PROGRAM_STATE_VAR, idx); -} - - -#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) -#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) -#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) - - -static void register_matrix_param5( struct tnl_program *p, - GLint s0, /* matrix name */ - GLint s1, /* texture matrix number */ - GLint s2, /* first row */ - GLint s3, /* last row */ - GLint s4, /* modifier */ - struct ureg *matrix ) -{ - GLint i; - - /* This is a bit sad as the support is there to pull the whole - * matrix out in one go: - */ - for (i = 0; i <= s3 - s2; i++) - matrix[i] = register_param5( p, s0, s1, i, i, s4 ); -} - - -static void emit_arg( struct prog_src_register *src, - struct ureg reg ) -{ - src->File = reg.file; - src->Index = reg.idx; - src->Swizzle = reg.swz; - src->RelAddr = 0; - src->NegateBase = reg.negate; - src->Abs = 0; - src->NegateAbs = 0; -} - -static void emit_dst( struct prog_dst_register *dst, - struct ureg reg, GLuint mask ) -{ - dst->File = reg.file; - dst->Index = reg.idx; - /* allow zero as a shorthand for xyzw */ - dst->WriteMask = mask ? mask : WRITEMASK_XYZW; - dst->CondMask = 0; - dst->CondSwizzle = 0; - dst->CondSrc = 0; - dst->pad = 0; -} - -static void debug_insn( struct prog_instruction *inst, const char *fn, - GLuint line ) -{ - if (DISASSEM) { - static const char *last_fn; - - if (fn != last_fn) { - last_fn = fn; - _mesa_printf("%s:\n", fn); - } - - _mesa_printf("%d:\t", line); - _mesa_print_instruction(inst); - } -} - - -static void emit_op3fn(struct tnl_program *p, - GLuint op, - struct ureg dest, - GLuint mask, - struct ureg src0, - struct ureg src1, - struct ureg src2, - const char *fn, - GLuint line) -{ - GLuint nr = p->program->Base.NumInstructions++; - - if (nr >= p->nr_instructions) { - int new_nr_instructions = p->nr_instructions * 2; - - p->program->Base.Instructions = - _mesa_realloc(p->program->Base.Instructions, - sizeof(struct prog_instruction) * p->nr_instructions, - sizeof(struct prog_instruction) * new_nr_instructions); - p->nr_instructions = new_nr_instructions; - } - - { - struct prog_instruction *inst = &p->program->Base.Instructions[nr]; - memset(inst, 0, sizeof(*inst)); - inst->Opcode = op; - inst->StringPos = 0; - inst->Data = 0; - - emit_arg( &inst->SrcReg[0], src0 ); - emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); - - emit_dst( &inst->DstReg, dest, mask ); - - debug_insn(inst, fn, line); - } -} - - - -#define emit_op3(p, op, dst, mask, src0, src1, src2) \ - emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__) - -#define emit_op2(p, op, dst, mask, src0, src1) \ - emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__) - -#define emit_op1(p, op, dst, mask, src0) \ - emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__) - - -static struct ureg make_temp( struct tnl_program *p, struct ureg reg ) -{ - if (reg.file == PROGRAM_TEMPORARY && - !(p->temp_reserved & (1<eye_position)) { - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); - struct ureg modelview[4]; - - p->eye_position = reserve_temp(p); - - if (PREFER_DP4) { - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - 0, modelview ); - - emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); - } - else { - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, modelview ); - - emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); - } - } - - return p->eye_position; -} - - -#if 0 -static struct ureg get_eye_z( struct tnl_program *p ) -{ - if (!is_undef(p->eye_position)) { - return swizzle1(p->eye_position, Z); - } - else if (!is_undef(p->eye_z)) { - struct ureg pos = register_input( p, BRW_ATTRIB_POS ); - struct ureg modelview2; - - p->eye_z = reserve_temp(p); - - register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 2, 1, - STATE_MATRIX, &modelview2 ); - - emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); - emit_op2(p, OPCODE_DP4, p->eye_z, WRITEMASK_Z, pos, modelview2); - } - - return swizzle1(p->eye_z, Z) -} -#endif - - - -static struct ureg get_eye_position_normalized( struct tnl_program *p ) -{ - if (is_undef(p->eye_position_normalized)) { - struct ureg eye = get_eye_position(p); - p->eye_position_normalized = reserve_temp(p); - emit_normalize_vec3(p, p->eye_position_normalized, eye); - } - - return p->eye_position_normalized; -} - - -static struct ureg get_eye_normal( struct tnl_program *p ) -{ - if (is_undef(p->eye_normal)) { - struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); - struct ureg mvinv[3]; - - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, - STATE_MATRIX_INVTRANS, mvinv ); - - p->eye_normal = reserve_temp(p); - - /* Transform to eye space: - */ - emit_matrix_transform_vec3( p, p->eye_normal, mvinv, normal ); - - /* Normalize/Rescale: - */ - if (p->state->normalize) { - emit_normalize_vec3( p, p->eye_normal, p->eye_normal ); - } - else if (p->state->rescale_normals) { - struct ureg rescale = register_param2(p, STATE_INTERNAL, - STATE_NORMAL_SCALE); - - emit_op2( p, OPCODE_MUL, p->eye_normal, 0, p->eye_normal, - swizzle1(rescale, X)); - } - } - - return p->eye_normal; -} - - - -static void build_hpos( struct tnl_program *p ) -{ - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); - struct ureg hpos = register_output( p, VERT_RESULT_HPOS ); - struct ureg mvp[4]; - - if (PREFER_DP4) { - register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, - 0, mvp ); - emit_matrix_transform_vec4( p, hpos, mvp, pos ); - } - else { - register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, mvp ); - emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); - } -} - - -static GLuint material_attrib( GLuint side, GLuint property ) -{ - return (property - STATE_AMBIENT) * 2 + side; -} - -/* Get a bitmask of which material values vary on a per-vertex basis. - */ -static void set_material_flags( struct tnl_program *p ) -{ - p->color_materials = 0; - p->materials = 0; - - if (p->state->light_color_material) { - p->materials = - p->color_materials = p->state->light_color_material_mask; - } - - p->materials |= p->state->light_material_mask; -} - - -static struct ureg get_material( struct tnl_program *p, GLuint side, - GLuint property ) -{ - GLuint attrib = material_attrib(side, property); - - if (p->color_materials & (1<materials & (1<materials & SCENE_COLOR_BITS(side)) { - struct ureg lm_ambient = register_param1(p, STATE_LIGHTMODEL_AMBIENT); - struct ureg material_emission = get_material(p, side, STATE_EMISSION); - struct ureg material_ambient = get_material(p, side, STATE_AMBIENT); - struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE); - struct ureg tmp = make_temp(p, material_diffuse); - emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient, - material_ambient, material_emission); - return tmp; - } - else - return register_param2( p, STATE_LIGHTMODEL_SCENECOLOR, side ); -} - - -static struct ureg get_lightprod( struct tnl_program *p, GLuint light, - GLuint side, GLuint property ) -{ - GLuint attrib = material_attrib(side, property); - if (p->materials & (1<state->unit[i].light_spotcutoff_is_180) { - struct ureg spot_dir_norm = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_SPOT_DIR_NORMALIZED, i); - struct ureg spot = get_temp(p); - struct ureg slt = get_temp(p); - - emit_op2(p, OPCODE_DP3, spot, 0, ureg_negate(VPpli), spot_dir_norm); - emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot); - emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W)); - emit_op2(p, OPCODE_MUL, att, 0, slt, spot); - - release_temp(p, spot); - release_temp(p, slt); - } - - /* Calculate distance attenuation: - */ - if (p->state->unit[i].light_attenuated) { - - /* 1/d,d,d,1/d */ - emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); - /* 1,d,d*d,1/d */ - emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); - /* 1/dist-atten */ - emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); - - if (!p->state->unit[i].light_spotcutoff_is_180) { - /* dist-atten */ - emit_op1(p, OPCODE_RCP, dist, 0, dist); - /* spot-atten * dist-atten */ - emit_op2(p, OPCODE_MUL, att, 0, dist, att); - } else { - /* dist-atten */ - emit_op1(p, OPCODE_RCP, att, 0, dist); - } - } - - return att; -} - - - - - -/* Need to add some addtional parameters to allow lighting in object - * space - STATE_SPOT_DIRECTION and STATE_HALF_VECTOR implicitly assume eye - * space lighting. - */ -static void build_lighting( struct tnl_program *p ) -{ - const GLboolean twoside = p->state->light_twoside; - const GLboolean separate = p->state->separate_specular; - GLuint nr_lights = 0, count = 0; - struct ureg normal = get_eye_normal(p); - struct ureg lit = get_temp(p); - struct ureg dots = get_temp(p); - struct ureg _col0 = undef, _col1 = undef; - struct ureg _bfc0 = undef, _bfc1 = undef; - GLuint i; - - for (i = 0; i < MAX_LIGHTS; i++) - if (p->state->unit[i].light_enabled) - nr_lights++; - - set_material_flags(p); - - { - struct ureg shininess = get_material(p, 0, STATE_SHININESS); - emit_op1(p, OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X)); - release_temp(p, shininess); - - _col0 = make_temp(p, get_scenecolor(p, 0)); - if (separate) - _col1 = make_temp(p, get_identity_param(p)); - else - _col1 = _col0; - - } - - if (twoside) { - struct ureg shininess = get_material(p, 1, STATE_SHININESS); - emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, - ureg_negate(swizzle1(shininess,X))); - release_temp(p, shininess); - - _bfc0 = make_temp(p, get_scenecolor(p, 1)); - if (separate) - _bfc1 = make_temp(p, get_identity_param(p)); - else - _bfc1 = _bfc0; - } - - - /* If no lights, still need to emit the scenecolor. - */ - /* KW: changed to do this always - v1.17 "Fix lighting alpha result"? - */ - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - { - struct ureg res0 = register_output( p, VERT_RESULT_COL0 ); - emit_op1(p, OPCODE_MOV, res0, 0, _col0); - - if (twoside) { - struct ureg res0 = register_output( p, VERT_RESULT_BFC0 ); - emit_op1(p, OPCODE_MOV, res0, 0, _bfc0); - } - } - - if (separate && (p->state->fragprog_inputs_read & FRAG_BIT_COL1)) { - - struct ureg res1 = register_output( p, VERT_RESULT_COL1 ); - emit_op1(p, OPCODE_MOV, res1, 0, _col1); - - if (twoside) { - struct ureg res1 = register_output( p, VERT_RESULT_BFC1 ); - emit_op1(p, OPCODE_MOV, res1, 0, _bfc1); - } - } - - if (nr_lights == 0) { - release_temps(p); - return; - } - - - for (i = 0; i < MAX_LIGHTS; i++) { - if (p->state->unit[i].light_enabled) { - struct ureg half = undef; - struct ureg att = undef, VPpli = undef; - - count++; - - if (p->state->unit[i].light_eyepos3_is_zero) { - /* Can used precomputed constants in this case. - * Attenuation never applies to infinite lights. - */ - VPpli = register_param3(p, STATE_LIGHT, i, - STATE_LIGHT_POSITION_NORMALIZED); - if (p->state->light_local_viewer) { - struct ureg eye_hat = get_eye_position_normalized(p); - half = get_temp(p); - emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); - emit_normalize_vec3(p, half, half); - } else { - half = register_param3(p, STATE_LIGHT, i, STATE_HALF_VECTOR); - } - } - else { - struct ureg Ppli = register_param3(p, STATE_LIGHT, i, - STATE_POSITION); - struct ureg V = get_eye_position(p); - struct ureg dist = get_temp(p); - struct ureg tmpPpli = get_temp(p); - - VPpli = get_temp(p); - half = get_temp(p); - - /* In homogeneous object coordinates - */ - emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); - emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist); - - /* Calulate VPpli vector - */ - emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); - - /* Normalize VPpli. The dist value also used in - * attenuation below. - */ - emit_op2(p, OPCODE_DP3, dist, 0, VPpli, VPpli); - emit_op1(p, OPCODE_RSQ, dist, 0, dist); - emit_op2(p, OPCODE_MUL, VPpli, 0, VPpli, dist); - - - /* Calculate attenuation: - */ - if (!p->state->unit[i].light_spotcutoff_is_180 || - p->state->unit[i].light_attenuated) { - att = calculate_light_attenuation(p, i, VPpli, dist); - } - - - /* Calculate viewer direction, or use infinite viewer: - */ - if (p->state->light_local_viewer) { - struct ureg eye_hat = get_eye_position_normalized(p); - emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); - } - else { - struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z); - emit_op2(p, OPCODE_ADD, half, 0, VPpli, z_dir); - } - - emit_normalize_vec3(p, half, half); - - release_temp(p, dist); - release_temp(p, tmpPpli); - } - - /* Calculate dot products: - */ - emit_op2(p, OPCODE_DP3, dots, WRITEMASK_X, normal, VPpli); - emit_op2(p, OPCODE_DP3, dots, WRITEMASK_Y, normal, half); - - - /* Front face lighting: - */ - { - struct ureg ambient = get_lightprod(p, i, 0, STATE_AMBIENT); - struct ureg diffuse = get_lightprod(p, i, 0, STATE_DIFFUSE); - struct ureg specular = get_lightprod(p, i, 0, STATE_SPECULAR); - struct ureg res0, res1; - GLuint mask0, mask1; - - emit_op1(p, OPCODE_LIT, lit, 0, dots); - - if (!is_undef(att)) - emit_op2(p, OPCODE_MUL, lit, 0, lit, att); - - - mask0 = 0; - mask1 = 0; - res0 = _col0; - res1 = _col1; - - if (count == nr_lights) { - if (separate) { - mask0 = WRITEMASK_XYZ; - mask1 = WRITEMASK_XYZ; - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - res0 = register_output( p, VERT_RESULT_COL0 ); - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL1) - res1 = register_output( p, VERT_RESULT_COL1 ); - } - else { - mask1 = WRITEMASK_XYZ; - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - res1 = register_output( p, VERT_RESULT_COL0 ); - } - } - - emit_op3(p, OPCODE_MAD, _col0, 0, swizzle1(lit,X), ambient, _col0); - emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0); - emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1); - - release_temp(p, ambient); - release_temp(p, diffuse); - release_temp(p, specular); - } - - /* Back face lighting: - */ - if (twoside) { - struct ureg ambient = get_lightprod(p, i, 1, STATE_AMBIENT); - struct ureg diffuse = get_lightprod(p, i, 1, STATE_DIFFUSE); - struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR); - struct ureg res0, res1; - GLuint mask0, mask1; - - emit_op1(p, OPCODE_LIT, lit, 0, ureg_negate(swizzle(dots,X,Y,W,Z))); - - if (!is_undef(att)) - emit_op2(p, OPCODE_MUL, lit, 0, lit, att); - - mask0 = 0; - mask1 = 0; - res0 = _bfc0; - res1 = _bfc1; - - if (count == nr_lights) { - if (separate) { - mask0 = WRITEMASK_XYZ; - mask1 = WRITEMASK_XYZ; - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - res0 = register_output( p, VERT_RESULT_BFC0 ); - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL1) - res1 = register_output( p, VERT_RESULT_BFC1 ); - } - else { - mask1 = WRITEMASK_XYZ; - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - res1 = register_output( p, VERT_RESULT_BFC0 ); - } - } - - emit_op3(p, OPCODE_MAD, _bfc0, 0, swizzle1(lit,X), ambient, _bfc0); - emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0); - emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1); - - release_temp(p, ambient); - release_temp(p, diffuse); - release_temp(p, specular); - } - - release_temp(p, half); - release_temp(p, VPpli); - release_temp(p, att); - } - } - - release_temps( p ); -} - - -static void build_fog( struct tnl_program *p ) -{ - struct ureg fog = register_output(p, VERT_RESULT_FOGC); - struct ureg input; - GLuint useabs = p->state->fog_source_is_depth && p->state->fog_option && - (p->state->fog_option != FOG_EXP2); - - if (p->state->fog_source_is_depth) { - input = swizzle1(get_eye_position(p), Z); - } - else { - input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); - if (p->state->fog_option && - p->state->tnl_do_vertex_fog) - input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); - else - input = register_input(p, VERT_ATTRIB_FOG); - } - - if (p->state->fog_option && - p->state->tnl_do_vertex_fog) { - struct ureg params = register_param2(p, STATE_INTERNAL, - STATE_FOG_PARAMS_OPTIMIZED); - struct ureg tmp = get_temp(p); - struct ureg id = get_identity_param(p); - - emit_op1(p, OPCODE_MOV, fog, 0, id); - - if (useabs) { - emit_op1(p, OPCODE_ABS, tmp, 0, input); - } - - switch (p->state->fog_option) { - case FOG_LINEAR: { - emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input, - swizzle1(params,X), swizzle1(params,Y)); - emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */ - emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W)); - break; - } - case FOG_EXP: - emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input, - swizzle1(params,Z)); - emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp)); - break; - case FOG_EXP2: - emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W)); - emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp); - emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp)); - break; - } - - release_temp(p, tmp); - } - else { - /* results = incoming fog coords (compute fog per-fragment later) - * - * KW: Is it really necessary to do anything in this case? - */ - emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, 0, input); - } -} - -static void build_reflect_texgen( struct tnl_program *p, - struct ureg dest, - GLuint writemask ) -{ - struct ureg normal = get_eye_normal(p); - struct ureg eye_hat = get_eye_position_normalized(p); - struct ureg tmp = get_temp(p); - - /* n.u */ - emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); - /* 2n.u */ - emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); - /* (-2n.u)n + u */ - emit_op3(p, OPCODE_MAD, dest, writemask, ureg_negate(tmp), normal, eye_hat); - - release_temp(p, tmp); -} - -static void build_sphere_texgen( struct tnl_program *p, - struct ureg dest, - GLuint writemask ) -{ - struct ureg normal = get_eye_normal(p); - struct ureg eye_hat = get_eye_position_normalized(p); - struct ureg tmp = get_temp(p); - struct ureg half = register_scalar_const(p, .5); - struct ureg r = get_temp(p); - struct ureg inv_m = get_temp(p); - struct ureg id = get_identity_param(p); - - /* Could share the above calculations, but it would be - * a fairly odd state for someone to set (both sphere and - * reflection active for different texture coordinate - * components. Of course - if two texture units enable - * reflect and/or sphere, things start to tilt in favour - * of seperating this out: - */ - - /* n.u */ - emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); - /* 2n.u */ - emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); - /* (-2n.u)n + u */ - emit_op3(p, OPCODE_MAD, r, 0, ureg_negate(tmp), normal, eye_hat); - /* r + 0,0,1 */ - emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); - /* rx^2 + ry^2 + (rz+1)^2 */ - emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); - /* 2/m */ - emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); - /* 1/m */ - emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); - /* r/m + 1/2 */ - emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); - - release_temp(p, tmp); - release_temp(p, r); - release_temp(p, inv_m); -} - - -static void build_texture_transform( struct tnl_program *p ) -{ - GLuint i, j; - - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - - if (!(p->state->fragprog_inputs_read & (FRAG_BIT_TEX0<state->unit[i].texgen_enabled || - p->state->unit[i].texmat_enabled) { - - GLuint texmat_enabled = p->state->unit[i].texmat_enabled; - struct ureg out = register_output(p, VERT_RESULT_TEX0 + i); - struct ureg out_texgen = undef; - - if (p->state->unit[i].texgen_enabled) { - GLuint copy_mask = 0; - GLuint sphere_mask = 0; - GLuint reflect_mask = 0; - GLuint normal_mask = 0; - GLuint modes[4]; - - if (texmat_enabled) - out_texgen = get_temp(p); - else - out_texgen = out; - - modes[0] = p->state->unit[i].texgen_mode0; - modes[1] = p->state->unit[i].texgen_mode1; - modes[2] = p->state->unit[i].texgen_mode2; - modes[3] = p->state->unit[i].texgen_mode3; - - for (j = 0; j < 4; j++) { - switch (modes[j]) { - case TXG_OBJ_LINEAR: { - struct ureg obj = register_input(p, VERT_ATTRIB_POS); - struct ureg plane = - register_param3(p, STATE_TEXGEN, i, - STATE_TEXGEN_OBJECT_S + j); - - emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, - obj, plane ); - break; - } - case TXG_EYE_LINEAR: { - struct ureg eye = get_eye_position(p); - struct ureg plane = - register_param3(p, STATE_TEXGEN, i, - STATE_TEXGEN_EYE_S + j); - - emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, - eye, plane ); - break; - } - case TXG_SPHERE_MAP: - sphere_mask |= WRITEMASK_X << j; - break; - case TXG_REFLECTION_MAP: - reflect_mask |= WRITEMASK_X << j; - break; - case TXG_NORMAL_MAP: - normal_mask |= WRITEMASK_X << j; - break; - case TXG_NONE: - copy_mask |= WRITEMASK_X << j; - } - - } - - - if (sphere_mask) { - build_sphere_texgen(p, out_texgen, sphere_mask); - } - - if (reflect_mask) { - build_reflect_texgen(p, out_texgen, reflect_mask); - } - - if (normal_mask) { - struct ureg normal = get_eye_normal(p); - emit_op1(p, OPCODE_MOV, out_texgen, normal_mask, normal ); - } - - if (copy_mask) { - struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i); - emit_op1(p, OPCODE_MOV, out_texgen, copy_mask, in ); - } - } - - if (texmat_enabled) { - struct ureg texmat[4]; - struct ureg in = (!is_undef(out_texgen) ? - out_texgen : - register_input(p, VERT_ATTRIB_TEX0+i)); - if (PREFER_DP4) { - register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, - 0, texmat ); - emit_matrix_transform_vec4( p, out, texmat, in ); - } - else { - register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, - STATE_MATRIX_TRANSPOSE, texmat ); - emit_transpose_matrix_transform_vec4( p, out, texmat, in ); - } - } - - release_temps(p); - } - else { - emit_passthrough(p, VERT_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i); - } - } -} - - -/* Seems like it could be tighter: - */ -static void build_pointsize( struct tnl_program *p ) -{ - struct ureg eye = get_eye_position(p); - struct ureg state_size = register_param1(p, STATE_POINT_SIZE); - struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); - struct ureg out = register_output(p, VERT_RESULT_PSIZ); - struct ureg ut = get_temp(p); - - /* 1, Z, Z * Z, 1 */ - emit_op1(p, OPCODE_MOV, ut, WRITEMASK_XW, swizzle1(get_identity_param(p), W)); - emit_op1(p, OPCODE_ABS, ut, WRITEMASK_YZ, swizzle1(eye, Z)); - emit_op2(p, OPCODE_MUL, ut, WRITEMASK_Z, ut, ut); - - - /* p1 + p2 * dist + p3 * dist * dist, 0 */ - emit_op2(p, OPCODE_DP3, ut, WRITEMASK_X, ut, state_attenuation); - - /* 1 / sqrt(factor) */ - emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut ); - - /* ut = pointSize / factor */ - emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size); - - /* Clamp to min/max - state_size.[yz] - */ - emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y)); - emit_op2(p, OPCODE_MIN, out, 0, swizzle1(ut, X), swizzle1(state_size, Z)); - - release_temp(p, ut); -} - -static void build_tnl_program( struct tnl_program *p ) -{ - /* Emit the program, starting with modelviewproject: - */ - build_hpos(p); - - /* Lighting calculations: - */ - if (p->state->fragprog_inputs_read & (FRAG_BIT_COL0|FRAG_BIT_COL1)) { - if (p->state->light_global_enabled) - build_lighting(p); - else { - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - emit_passthrough(p, VERT_ATTRIB_COLOR0, VERT_RESULT_COL0); - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL1) - emit_passthrough(p, VERT_ATTRIB_COLOR1, VERT_RESULT_COL1); - } - } - - if ((p->state->fragprog_inputs_read & FRAG_BIT_FOGC) || - p->state->fog_option != FOG_NONE) - build_fog(p); - - if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY) - build_texture_transform(p); - - if (p->state->point_attenuated) - build_pointsize(p); - - /* Finish up: - */ - emit_op1(p, OPCODE_END, undef, 0, undef); - - /* Disassemble: - */ - if (DISASSEM) { - _mesa_printf ("\n"); - } -} - - -static void build_new_tnl_program( const struct state_key *key, - struct gl_vertex_program *program, - GLuint max_temps) -{ - struct tnl_program p; - - _mesa_memset(&p, 0, sizeof(p)); - p.state = key; - p.program = program; - p.eye_position = undef; - p.eye_position_normalized = undef; - p.eye_normal = undef; - p.identity = undef; - p.temp_in_use = 0; - p.nr_instructions = 16; - - if (max_temps >= sizeof(int) * 8) - p.temp_reserved = 0; - else - p.temp_reserved = ~((1<Base.Instructions = - _mesa_malloc(sizeof(struct prog_instruction) * p.nr_instructions); - p.program->Base.String = 0; - p.program->Base.NumInstructions = - p.program->Base.NumTemporaries = - p.program->Base.NumParameters = - p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0; - p.program->Base.Parameters = _mesa_new_parameter_list(); - p.program->Base.InputsRead = 0; - p.program->Base.OutputsWritten = 0; - - build_tnl_program( &p ); -} - -static void *search_cache( struct brw_tnl_cache *cache, - GLuint hash, - const void *key, - GLuint keysize) -{ - struct brw_tnl_cache_item *c; - - for (c = cache->items[hash % cache->size]; c; c = c->next) { - if (c->hash == hash && memcmp(c->key, key, keysize) == 0) - return c->data; - } - - return NULL; -} - -static void rehash( struct brw_tnl_cache *cache ) -{ - struct brw_tnl_cache_item **items; - struct brw_tnl_cache_item *c, *next; - GLuint size, i; - - size = cache->size * 3; - items = (struct brw_tnl_cache_item**) _mesa_malloc(size * sizeof(*items)); - _mesa_memset(items, 0, size * sizeof(*items)); - - for (i = 0; i < cache->size; i++) - for (c = cache->items[i]; c; c = next) { - next = c->next; - c->next = items[c->hash % size]; - items[c->hash % size] = c; - } - - FREE(cache->items); - cache->items = items; - cache->size = size; -} - -static void cache_item( struct brw_tnl_cache *cache, - GLuint hash, - const struct state_key *key, - void *data ) -{ - struct brw_tnl_cache_item *c = MALLOC(sizeof(*c)); - c->hash = hash; - - c->key = malloc(sizeof(*key)); - memcpy(c->key, key, sizeof(*key)); - - c->data = data; - - if (++cache->n_items > cache->size * 1.5) - rehash(cache); - - c->next = cache->items[hash % cache->size]; - cache->items[hash % cache->size] = c; -} - - -static GLuint hash_key( struct state_key *key ) -{ - GLuint *ikey = (GLuint *)key; - GLuint hash = 0, i; - - /* I'm sure this can be improved on, but speed is important: - */ - for (i = 0; i < sizeof(*key)/sizeof(GLuint); i++) - hash += ikey[i]; - - return hash; -} - -static void prepare_tnl_program( struct brw_context *brw ) -{ - GLcontext *ctx = &brw->intel.ctx; - struct state_key key; - GLuint hash; - struct gl_vertex_program *old = brw->tnl_program; - - /* _NEW_PROGRAM */ - if (brw->attribs.VertexProgram->_Current) - return; - - /* Grab all the relevent state and put it in a single structure: - */ - make_state_key(ctx, &key); - hash = hash_key(&key); - - /* Look for an already-prepared program for this state: - */ - brw->tnl_program = (struct gl_vertex_program *) - search_cache( &brw->tnl_program_cache, hash, &key, sizeof(key) ); - - /* OK, we'll have to build a new one: - */ - if (!brw->tnl_program) { - brw->tnl_program = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); - - build_new_tnl_program( &key, brw->tnl_program, -/* ctx->Const.MaxVertexProgramTemps */ - 32 - ); - - if (ctx->Driver.ProgramStringNotify) - ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, - &brw->tnl_program->Base ); - - cache_item( &brw->tnl_program_cache, - hash, &key, brw->tnl_program ); - } - - if (old != brw->tnl_program) - brw->state.dirty.brw |= BRW_NEW_TNL_PROGRAM; - return; -} - -/* Note: See brw_draw.c - the vertex program must not rely on - * brw->primitive or brw->reduced_prim. - */ -const struct brw_tracked_state brw_tnl_vertprog = { - .dirty = { - .mesa = (_NEW_PROGRAM | - _NEW_LIGHT | - _NEW_TRANSFORM | - _NEW_FOG | - _NEW_HINT | - _NEW_POINT | - _NEW_TEXTURE | - _NEW_TEXTURE_MATRIX), - .brw = (BRW_NEW_FRAGMENT_PROGRAM | - BRW_NEW_INPUT_VARYING), - .cache = 0 - }, - .prepare = prepare_tnl_program -}; - - - - static void prepare_active_vertprog( struct brw_context *brw ) { const struct gl_vertex_program *prev = brw->vertex_program; - /* NEW_PROGRAM */ - if (brw->attribs.VertexProgram->_Current) { - brw->vertex_program = brw->attribs.VertexProgram->_Current; - } - else { - /* BRW_NEW_TNL_PROGRAM */ - brw->vertex_program = brw->tnl_program; - } + brw->vertex_program = brw->attribs.VertexProgram->_Current; if (brw->vertex_program != prev) brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; @@ -1672,37 +52,8 @@ static void prepare_active_vertprog( struct brw_context *brw ) const struct brw_tracked_state brw_active_vertprog = { .dirty = { .mesa = _NEW_PROGRAM, - .brw = BRW_NEW_TNL_PROGRAM, + .brw = 0, .cache = 0 }, .prepare = prepare_active_vertprog }; - - -void brw_ProgramCacheInit( GLcontext *ctx ) -{ - struct brw_context *brw = brw_context(ctx); - - brw->tnl_program_cache.size = 17; - brw->tnl_program_cache.n_items = 0; - brw->tnl_program_cache.items = (struct brw_tnl_cache_item **) - _mesa_calloc(brw->tnl_program_cache.size * - sizeof(struct brw_tnl_cache_item)); -} - -void brw_ProgramCacheDestroy( GLcontext *ctx ) -{ - struct brw_context *brw = brw_context(ctx); - struct brw_tnl_cache_item *c, *next; - GLuint i; - - for (i = 0; i < brw->tnl_program_cache.size; i++) - for (c = brw->tnl_program_cache.items[i]; c; c = next) { - next = c->next; - FREE(c->key); - FREE(c->data); - FREE(c); - } - - FREE(brw->tnl_program_cache.items); -} diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 3780d3dad2e..cd074dfed64 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -70,7 +70,6 @@ static void brw_destroy_context( struct intel_context *intel ) brw_destroy_state(brw); brw_draw_destroy( brw ); - brw_ProgramCacheDestroy( ctx ); brw_FrameBufferTexDestroy( brw ); for (i = 0; i < brw->state.nr_draw_regions; i++) -- cgit v1.2.3 From 2b8d8989fb6f9c36baf166fc715182a1407ebadb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Sun, 28 Sep 2008 20:31:46 -0700 Subject: Use 3Dnow! x86-64 routines only on processors that support 3Dnow! Added an x86-64 CPUID function and use it to detect 3Dnow! If 3Dnow! is available, use _mesa_3dnow_transform_points4_3d_no_rot, _mesa_3dnow_transform_points4_perspective, _mesa_3dnow_transform_points4_2d_no_rot, and _mesa_3dnow_transform_points4_2d. This fixes long standing bug #8724. --- src/mesa/x86-64/x86-64.c | 34 +++++++++++++++++++++++----------- src/mesa/x86-64/xform4.S | 31 +++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 19 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/x86-64/x86-64.c b/src/mesa/x86-64/x86-64.c index 9ec43c841d3..96f8da87f05 100644 --- a/src/mesa/x86-64/x86-64.c +++ b/src/mesa/x86-64/x86-64.c @@ -41,7 +41,10 @@ #include "math/m_debug.h" #endif +extern void _mesa_x86_64_cpuid(unsigned int *regs); + DECLARE_XFORM_GROUP( x86_64, 4 ) +DECLARE_XFORM_GROUP( 3dnow, 4 ) #else /* just to silence warning below */ @@ -81,6 +84,7 @@ static void message( const char *msg ) void _mesa_init_all_x86_64_transform_asm(void) { #ifdef USE_X86_64_ASM + unsigned int regs[4]; if ( _mesa_getenv( "MESA_NO_ASM" ) ) { return; @@ -88,24 +92,32 @@ void _mesa_init_all_x86_64_transform_asm(void) message("Initializing x86-64 optimizations\n"); - ASSIGN_XFORM_GROUP( x86_64, 4 ); - /* _mesa_transform_tab[4][MATRIX_GENERAL] = _mesa_x86_64_transform_points4_general; _mesa_transform_tab[4][MATRIX_IDENTITY] = _mesa_x86_64_transform_points4_identity; _mesa_transform_tab[4][MATRIX_3D] = _mesa_x86_64_transform_points4_3d; - _mesa_transform_tab[4][MATRIX_3D_NO_ROT] = - _mesa_x86_64_transform_points4_3d_no_rot; - _mesa_transform_tab[4][MATRIX_PERSPECTIVE] = - _mesa_x86_64_transform_points4_perspective; - _mesa_transform_tab[4][MATRIX_2D_NO_ROT] = - _mesa_x86_64_transform_points4_2d_no_rot; - _mesa_transform_tab[4][MATRIX_2D] = - _mesa_x86_64_transform_points4_2d; - */ + + regs[0] = 0x80000001; + regs[1] = 0x00000000; + regs[2] = 0x00000000; + regs[3] = 0x00000000; + _mesa_x86_64_cpuid(regs); + if (regs[3] & (1U << 31)) { + message("3Dnow! detected\n"); + _mesa_transform_tab[4][MATRIX_3D_NO_ROT] = + _mesa_3dnow_transform_points4_3d_no_rot; + _mesa_transform_tab[4][MATRIX_PERSPECTIVE] = + _mesa_3dnow_transform_points4_perspective; + _mesa_transform_tab[4][MATRIX_2D_NO_ROT] = + _mesa_3dnow_transform_points4_2d_no_rot; + _mesa_transform_tab[4][MATRIX_2D] = + _mesa_3dnow_transform_points4_2d; + + } + #ifdef DEBUG_MATH _math_test_all_transform_functions("x86_64"); diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S index 3f9c9d56ab7..805969127db 100644 --- a/src/mesa/x86-64/xform4.S +++ b/src/mesa/x86-64/xform4.S @@ -29,7 +29,22 @@ .text .align 16 +.globl _mesa_x86_64_cpuid +_mesa_x86_64_cpuid: + pushq %rbx + movl (%rdi), %eax + movl 8(%rdi), %ecx + + cpuid + + movl %ebx, 4(%rdi) + movl %eax, (%rdi) + movl %ecx, 8(%rdi) + movl %edx, 12(%rdi) + popq %rbx + ret +.align 16 .globl _mesa_x86_64_transform_points4_general _mesa_x86_64_transform_points4_general: /* @@ -204,8 +219,8 @@ p4_identity_done: .align 16 -.globl _mesa_x86_64_transform_points4_3d_no_rot -_mesa_x86_64_transform_points4_3d_no_rot: +.globl _mesa_3dnow_transform_points4_3d_no_rot +_mesa_3dnow_transform_points4_3d_no_rot: movl V4F_COUNT(%rdx), %ecx /* count */ movzx V4F_STRIDE(%rdx), %eax /* stride */ @@ -268,8 +283,8 @@ p4_3d_no_rot_done: .align 16 -.globl _mesa_x86_64_transform_points4_perspective -_mesa_x86_64_transform_points4_perspective: +.globl _mesa_3dnow_transform_points4_perspective +_mesa_3dnow_transform_points4_perspective: movl V4F_COUNT(%rdx), %ecx /* count */ movzx V4F_STRIDE(%rdx), %eax /* stride */ @@ -334,8 +349,8 @@ p4_perspective_done: ret .align 16 -.globl _mesa_x86_64_transform_points4_2d_no_rot -_mesa_x86_64_transform_points4_2d_no_rot: +.globl _mesa_3dnow_transform_points4_2d_no_rot +_mesa_3dnow_transform_points4_2d_no_rot: movl V4F_COUNT(%rdx), %ecx /* count */ movzx V4F_STRIDE(%rdx), %eax /* stride */ @@ -389,8 +404,8 @@ p4_2d_no_rot_done: .align 16 -.globl _mesa_x86_64_transform_points4_2d -_mesa_x86_64_transform_points4_2d: +.globl _mesa_3dnow_transform_points4_2d +_mesa_3dnow_transform_points4_2d: movl V4F_COUNT(%rdx), %ecx /* count */ movzx V4F_STRIDE(%rdx), %eax /* stride */ -- cgit v1.2.3 From e095d5812a0237d08eabae1977730e38ac5751c9 Mon Sep 17 00:00:00 2001 From: Shunichi Fuji Date: Fri, 26 Sep 2008 18:55:13 +0900 Subject: mesa: drop calloc from _mesa_get_fixed_func_vertex_program Signed-off-by: Shunichi Fuji --- src/mesa/main/ffvertex_prog.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 787672be9f1..308b4ef7115 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -178,12 +178,12 @@ static GLboolean check_active_shininess( GLcontext *ctx, -static struct state_key *make_state_key( GLcontext *ctx ) +static void make_state_key( GLcontext *ctx, struct state_key *key ) { const struct gl_fragment_program *fp; - struct state_key *key = CALLOC_STRUCT(state_key); GLuint i; + memset(key, 0, sizeof(struct state_key)); fp = ctx->FragmentProgram._Current; /* This now relies on texenvprogram.c being active: @@ -301,8 +301,6 @@ static struct state_key *make_state_key( GLcontext *ctx ) texUnit->GenModeQ ); } } - - return key; } @@ -1714,16 +1712,16 @@ struct gl_vertex_program * _mesa_get_fixed_func_vertex_program(GLcontext *ctx) { struct gl_vertex_program *prog; - struct state_key *key; + struct state_key key; /* Grab all the relevent state and put it in a single structure: */ - key = make_state_key(ctx); + make_state_key(ctx, &key); /* Look for an already-prepared program for this state: */ prog = (struct gl_vertex_program *) - _mesa_search_program_cache(ctx->VertexProgram.Cache, key, sizeof(*key)); + _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)); if (!prog) { /* OK, we'll have to build a new one */ @@ -1735,7 +1733,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) if (!prog) return NULL; - create_new_program( key, prog, + create_new_program( &key, prog, ctx->Const.VertexProgram.MaxTemps ); #if 0 @@ -1744,10 +1742,8 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) &prog->Base ); #endif _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, - key, sizeof(*key), &prog->Base); + &key, sizeof(key), &prog->Base); } - _mesa_free(key); - return prog; } -- cgit v1.2.3 From fc13269b820a842b401b7a7a4aed098e59b25b91 Mon Sep 17 00:00:00 2001 From: Jouk Jansen Date: Mon, 29 Sep 2008 08:35:05 -0600 Subject: mesa: asst updates for VMS --- src/mesa/drivers/common/descrip.mms | 5 +++-- src/mesa/glapi/descrip.mms | 10 ++++++---- src/mesa/main/descrip.mms | 32 +++++++++++++++++++++++++++++++- src/mesa/shader/descrip.mms | 6 ++++-- src/mesa/shader/grammar/descrip.mms | 5 +++-- src/mesa/tnl/descrip.mms | 7 ++++--- 6 files changed, 51 insertions(+), 14 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/common/descrip.mms b/src/mesa/drivers/common/descrip.mms index 99a2ae6c37d..d5bbc69dfd5 100644 --- a/src/mesa/drivers/common/descrip.mms +++ b/src/mesa/drivers/common/descrip.mms @@ -1,6 +1,6 @@ # Makefile for core library for VMS # contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl -# Last revision : 3 October 2007 +# Last revision : 29 September 2008 .first define gl [----.include.gl] @@ -19,7 +19,8 @@ VPATH = RCS INCDIR = [----.include],[--.main],[--.glapi],[--.shader] LIBDIR = [----.lib] -CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm +CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)\ + /float=ieee/ieee=denorm/warn=disable=(PTRMISMATCH) SOURCES = driverfuncs.c diff --git a/src/mesa/glapi/descrip.mms b/src/mesa/glapi/descrip.mms index f17e5329b60..ee96baa6fcc 100644 --- a/src/mesa/glapi/descrip.mms +++ b/src/mesa/glapi/descrip.mms @@ -1,9 +1,10 @@ # Makefile for core library for VMS -# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl -# Last revision : 16 June 2003 +# contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl +# Last revision : 29 September 2008 .first define gl [---.include.gl] + define main [-.main] .include [---]mms-config. @@ -15,9 +16,9 @@ INCDIR = [---.include],[-.main] LIBDIR = [---.lib] CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm -SOURCES = glapi.c glthread.c +SOURCES = glapi.c glthread.c glapi_getproc.c -OBJECTS = glapi.obj,glthread.obj +OBJECTS = glapi.obj,glthread.obj,glapi_getproc.obj ##### RULES ##### @@ -35,3 +36,4 @@ clean : glapi.obj : glapi.c glthread.obj : glthread.c +glapi_getproc.obj : glapi_getproc.c diff --git a/src/mesa/main/descrip.mms b/src/mesa/main/descrip.mms index 3ef215f47fa..e49ec65d42d 100644 --- a/src/mesa/main/descrip.mms +++ b/src/mesa/main/descrip.mms @@ -1,6 +1,6 @@ # Makefile for core library for VMS # contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl -# Last revision : 2 October 2007 +# Last revision : 29 September 2008 .first define gl [---.include.gl] @@ -21,6 +21,7 @@ CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ie SOURCES =accum.c \ api_arrayelt.c \ + api_exec.c \ api_loopback.c \ api_noop.c \ api_validate.c \ @@ -29,6 +30,7 @@ SOURCES =accum.c \ blend.c \ bufferobj.c \ buffers.c \ + clear.c \ clip.c \ colortab.c \ context.c \ @@ -46,6 +48,7 @@ SOURCES =accum.c \ extensions.c \ fbobject.c \ feedback.c \ + ffvertex_prog.c \ fog.c \ framebuffer.c \ get.c \ @@ -60,22 +63,29 @@ SOURCES =accum.c \ matrix.c \ mipmap.c \ mm.c \ + multisample.c \ pixel.c \ + pixelstore.c \ points.c \ polygon.c \ rastpos.c \ rbadaptors.c \ + readpix.c \ renderbuffer.c \ + scissor.c \ shaders.c \ state.c \ stencil.c \ texcompress.c \ texcompress_fxt1.c \ texcompress_s3tc.c \ + texenv.c \ texenvprogram.c \ texformat.c \ + texgen.c \ teximage.c \ texobj.c \ + texparam.c \ texrender.c \ texstate.c \ texstore.c \ @@ -86,6 +96,7 @@ SOURCES =accum.c \ OBJECTS=accum.obj,\ api_arrayelt.obj,\ +api_exec.obj,\ api_loopback.obj,\ api_noop.obj,\ api_validate.obj,\ @@ -94,6 +105,7 @@ attrib.obj,\ blend.obj,\ bufferobj.obj,\ buffers.obj,\ +clear.obj,\ clip.obj,\ colortab.obj,\ context.obj,\ @@ -111,6 +123,7 @@ execmem.obj,\ extensions.obj,\ fbobject.obj,\ feedback.obj,\ +ffvertex_prog.obj,\ fog.obj,\ framebuffer.obj,\ get.obj,\ @@ -125,21 +138,28 @@ lines.obj,\ matrix.obj,\ mipmap.obj,\ mm.obj,\ +multisample.obj,\ pixel.obj,\ +pixelstore.obj,\ points.obj,\ polygon.obj,\ rastpos.obj,\ +readpix.obj,\ renderbuffer.obj,\ +scissor.obj,\ shaders.obj,\ state.obj,\ stencil.obj,\ texcompress.obj,\ texcompress_fxt1.obj,\ texcompress_s3tc.obj,\ +texenv.obj,\ texenvprogram.obj,\ texformat.obj,\ +texgen.obj,\ teximage.obj,\ texobj.obj,\ +texparam.obj,\ texrender.obj,\ texstate.obj,\ texstore.obj,\ @@ -226,3 +246,13 @@ vtxfmt.obj : vtxfmt.c shaders.obj : shaders.c queryobj.obj : queryobj.c rbadaptors.obj : rbadaptors.c +clear.obj : clear.c +multisample.obj : multisample.c +scissor.obj : scissor.c +texenv.obj : texenv.c +texgen.obj : texgen.c +texparam.obj : texparam.c +readpix.obj : readpix.c +ffvertex_prog.obj : ffvertex_prog.c +api_exec.obj : api_exec.c +pixelstore.obj : pixelstore.c diff --git a/src/mesa/shader/descrip.mms b/src/mesa/shader/descrip.mms index bdac946efe2..19bafd48302 100644 --- a/src/mesa/shader/descrip.mms +++ b/src/mesa/shader/descrip.mms @@ -1,6 +1,6 @@ # Makefile for core library for VMS # contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl -# Last revision : 27 May 2008 +# Last revision : 29 September 2008 .first define gl [---.include.gl] define math [-.math] @@ -34,6 +34,7 @@ SOURCES = \ prog_instruction.c \ prog_parameter.c \ prog_print.c \ + prog_cache.c \ prog_statevars.c \ shader_api.c prog_uniform.c @@ -52,7 +53,7 @@ OBJECTS = \ prog_parameter.obj,\ prog_print.obj,\ prog_statevars.obj,\ - shader_api.obj,prog_uniform.obj + shader_api.obj,prog_uniform.obj,prog_cache.obj ##### RULES ##### @@ -91,3 +92,4 @@ prog_print.obj : prog_print.c prog_statevars.obj : prog_statevars.c shader_api.obj : shader_api.c prog_uniform.obj : prog_uniform.c +prog_cache.obj : prog_cache.c diff --git a/src/mesa/shader/grammar/descrip.mms b/src/mesa/shader/grammar/descrip.mms index f7fbee96bcd..6976b70d6ac 100644 --- a/src/mesa/shader/grammar/descrip.mms +++ b/src/mesa/shader/grammar/descrip.mms @@ -1,12 +1,13 @@ # Makefile for core library for VMS -# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl -# Last revision : 1 June 2005 +# contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl +# Last revision : 29 September 2008 .first define gl [----.include.gl] define math [--.math] define swrast [--.swrast] define array_cache [--.array_cache] + define main [--.main] .include [----]mms-config. diff --git a/src/mesa/tnl/descrip.mms b/src/mesa/tnl/descrip.mms index f77f672dc8f..25dd1aecb13 100644 --- a/src/mesa/tnl/descrip.mms +++ b/src/mesa/tnl/descrip.mms @@ -1,6 +1,6 @@ # Makefile for core library for VMS # contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl -# Last revision : 30 November 2007 +# Last revision : 39 September 2008 .first define gl [---.include.gl] @@ -27,13 +27,13 @@ SOURCES = t_context.c t_draw.c \ t_pipeline.c t_vb_fog.c \ t_vb_light.c t_vb_normals.c t_vb_points.c t_vb_program.c \ t_vb_render.c t_vb_texgen.c t_vb_texmat.c t_vb_vertex.c \ - t_vertex.c \ + t_vertex.c t_rasterpos.c\ t_vertex_generic.c t_vp_build.c OBJECTS = t_context.obj,t_draw.obj,\ t_pipeline.obj,t_vb_fog.obj,t_vb_light.obj,t_vb_normals.obj,\ t_vb_points.obj,t_vb_program.obj,t_vb_render.obj,t_vb_texgen.obj,\ - t_vb_texmat.obj,t_vb_vertex.obj,\ + t_vb_texmat.obj,t_vb_vertex.obj,t_rasterpos.obj,\ t_vertex.obj,t_vertex_generic.obj,\ t_vp_build.obj @@ -65,3 +65,4 @@ t_vb_vertex.obj : t_vb_vertex.c t_vertex.obj : t_vertex.c t_vertex_generic.obj : t_vertex_generic.c t_vp_build.obj : t_vp_build.c +t_rasterpos.obj : t_rasterpos.c -- cgit v1.2.3 From d806d451e660bb582c04947ae3bd8b95173e8fd4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Sep 2008 12:18:06 -0700 Subject: GLSL: AttachShader returns INVALID_OPERATION for repeated attach The GL_ARB_shader_objects spec says that glAttachShaderARB is supposed to return GL_INVALID_OPERATION if a shader is attached to a program where it is already attached. _mesa_attach_shader perviously returned without error in this case. --- src/mesa/shader/shader_api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 3c530d17271..3ab590351a7 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -455,7 +455,13 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader) n = shProg->NumShaders; for (i = 0; i < n; i++) { if (shProg->Shaders[i] == sh) { - /* already attached */ + /* The shader is already attched to this program. The + * GL_ARB_shader_objects spec says: + * + * "The error INVALID_OPERATION is generated by AttachObjectARB + * if is already attached to ." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); return; } } -- cgit v1.2.3 From 905d8e0742d200558677dac01a838e95877f7b5e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Sep 2008 12:27:00 -0700 Subject: GLSL: Implement _mesa_get_handle Implementing _mesa_get_handle in using glGetIntegerv(GL_CURRENT_PROGRAM, ...) allows glGetHandleARB to work. --- src/mesa/shader/shader_api.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 3ab590351a7..504d7693234 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -47,7 +47,7 @@ #include "shader/shader_api.h" #include "shader/slang/slang_compile.h" #include "shader/slang/slang_link.h" - +#include "glapi/dispatch.h" #ifndef GL_PROGRAM_BINARY_LENGTH_OES @@ -925,24 +925,15 @@ _mesa_get_attached_shaders(GLcontext *ctx, GLuint program, GLsizei maxCount, static GLuint _mesa_get_handle(GLcontext *ctx, GLenum pname) { -#if 0 - GET_CURRENT_CONTEXT(ctx); - - switch (pname) { - case GL_PROGRAM_OBJECT_ARB: - { - struct gl2_program_intf **pro = ctx->Shader.CurrentProgram; - - if (pro != NULL) - return (**pro)._container._generic. - GetName((struct gl2_generic_intf **) (pro)); - } - break; - default: + GLint handle = 0; + + if (pname == GL_PROGRAM_OBJECT_ARB) { + CALL_GetIntegerv(ctx->Exec, (GL_CURRENT_PROGRAM, &handle)); + } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB"); } -#endif - return 0; + + return handle; } -- cgit v1.2.3 From 3ab4b2066fd0b1493af38510e26e5a6ba83b5cf4 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Sep 2008 12:30:05 -0700 Subject: GLSL: Implement GL_OBJECT_TYPE_ARB query The GL_OBJECT_TYPE_ARB query is handled directly in _mesa_GetObjectParamterivARB because it is only supported in the extension version of the shanding language API. glGetProgramiv and glGetShaderiv should not accept this enum. --- src/mesa/main/shaders.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index f0db0d2a818..aeb5d4ca2ab 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -233,10 +233,18 @@ _mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) GET_CURRENT_CONTEXT(ctx); /* Implement in terms of GetProgramiv, GetShaderiv */ if (ctx->Driver.IsProgram(ctx, object)) { - ctx->Driver.GetProgramiv(ctx, object, pname, params); + if (pname == GL_OBJECT_TYPE_ARB) { + *params = GL_PROGRAM_OBJECT_ARB; + } else { + ctx->Driver.GetProgramiv(ctx, object, pname, params); + } } else if (ctx->Driver.IsShader(ctx, object)) { - ctx->Driver.GetShaderiv(ctx, object, pname, params); + if (pname == GL_OBJECT_TYPE_ARB) { + *params = GL_SHADER_OBJECT_ARB; + } else { + ctx->Driver.GetShaderiv(ctx, object, pname, params); + } } else { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB"); -- cgit v1.2.3 From 08b9e29c1d4d28fee13658b0421b4522d9c36b3a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Sep 2008 18:50:05 -0700 Subject: intel: Clean-up the extension string madness! - Sort extensions by ARB, then EXT, then vendor by name - Remove redundant (only one of GL_{ARB,EXT,NV}_texture_rectangle) or duplicate extension strings --- src/mesa/drivers/dri/intel/intel_context.c | 134 ++++++++++++++--------------- 1 file changed, 64 insertions(+), 70 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index ccd74baa7c5..1dd3ee7d0a6 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -68,14 +68,15 @@ int INTEL_DEBUG = (0); #endif -#define need_GL_NV_point_sprite #define need_GL_ARB_multisample +#define need_GL_ARB_occlusion_query #define need_GL_ARB_point_parameters +#define need_GL_ARB_shader_objects #define need_GL_ARB_texture_compression #define need_GL_ARB_vertex_buffer_object #define need_GL_ARB_vertex_program +#define need_GL_ARB_vertex_shader #define need_GL_ARB_window_pos -#define need_GL_ARB_occlusion_query #define need_GL_EXT_blend_color #define need_GL_EXT_blend_equation_separate #define need_GL_EXT_blend_func_separate @@ -84,14 +85,13 @@ int INTEL_DEBUG = (0); #define need_GL_EXT_fog_coord #define need_GL_EXT_framebuffer_object #define need_GL_EXT_multi_draw_arrays +#define need_GL_EXT_point_parameters #define need_GL_EXT_secondary_color -#define need_GL_NV_vertex_program #define need_GL_ATI_separate_stencil -#define need_GL_EXT_point_parameters +#define need_GL_NV_point_sprite +#define need_GL_NV_vertex_program #define need_GL_VERSION_2_0 #define need_GL_VERSION_2_1 -#define need_GL_ARB_shader_objects -#define need_GL_ARB_vertex_shader #include "extension_helper.h" @@ -344,88 +344,82 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) * i965_dri. */ static const struct dri_extension card_extensions[] = { - {"GL_ARB_multisample", GL_ARB_multisample_functions}, - {"GL_ARB_multitexture", NULL}, - {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, - {"GL_NV_point_sprite", GL_NV_point_sprite_functions}, - {"GL_ARB_texture_border_clamp", NULL}, - {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, - {"GL_ARB_texture_cube_map", NULL}, - {"GL_ARB_texture_env_add", NULL}, - {"GL_ARB_texture_env_combine", NULL}, - {"GL_ARB_texture_env_crossbar", NULL}, - {"GL_ARB_texture_env_dot3", NULL}, - {"GL_ARB_texture_mirrored_repeat", NULL}, - {"GL_ARB_texture_non_power_of_two", NULL }, - {"GL_ARB_texture_rectangle", NULL}, - {"GL_NV_texture_rectangle", NULL}, - {"GL_EXT_texture_rectangle", NULL}, - {"GL_ARB_point_parameters", NULL}, - {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, - {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, - {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, - {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, - {"GL_EXT_blend_equation_separate", - GL_EXT_blend_equation_separate_functions}, - {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, - {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, - {"GL_EXT_blend_logic_op", NULL}, - {"GL_EXT_blend_subtract", NULL}, - {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, - {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, - {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, - {"GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions}, -#if 1 /* XXX FBO temporary? */ - {"GL_EXT_packed_depth_stencil", NULL}, -#endif - {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, - {"GL_EXT_stencil_wrap", NULL}, - {"GL_EXT_texture_edge_clamp", NULL}, - {"GL_EXT_texture_env_combine", NULL}, - {"GL_EXT_texture_env_dot3", NULL}, - {"GL_EXT_texture_filter_anisotropic", NULL}, - {"GL_EXT_texture_lod_bias", NULL}, - {"GL_3DFX_texture_compression_FXT1", NULL}, - {"GL_APPLE_client_storage", NULL}, - {"GL_MESA_pack_invert", NULL}, - {"GL_MESA_ycbcr_texture", NULL}, - {"GL_NV_blend_square", NULL}, - {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, - {"GL_NV_vertex_program1_1", NULL}, - { "GL_SGIS_generate_mipmap", NULL }, - {NULL, NULL} + { "GL_ARB_multisample", GL_ARB_multisample_functions }, + { "GL_ARB_multitexture", NULL }, + { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, + { "GL_ARB_texture_border_clamp", NULL }, + { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, + { "GL_ARB_texture_cube_map", NULL }, + { "GL_ARB_texture_env_add", NULL }, + { "GL_ARB_texture_env_combine", NULL }, + { "GL_ARB_texture_env_crossbar", NULL }, + { "GL_ARB_texture_env_dot3", NULL }, + { "GL_ARB_texture_mirrored_repeat", NULL }, + { "GL_ARB_texture_non_power_of_two", NULL }, + { "GL_ARB_texture_rectangle", NULL }, + { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, + { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, + { "GL_ARB_window_pos", GL_ARB_window_pos_functions }, + { "GL_EXT_blend_color", GL_EXT_blend_color_functions }, + { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions }, + { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions }, + { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions }, + { "GL_EXT_blend_logic_op", NULL }, + { "GL_EXT_blend_subtract", NULL }, + { "GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions }, + { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, + { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions }, + { "GL_EXT_packed_depth_stencil", NULL }, + { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, + { "GL_EXT_stencil_wrap", NULL }, + { "GL_EXT_texture_edge_clamp", NULL }, + { "GL_EXT_texture_env_combine", NULL }, + { "GL_EXT_texture_env_dot3", NULL }, + { "GL_EXT_texture_filter_anisotropic", NULL }, + { "GL_EXT_texture_lod_bias", NULL }, + { "GL_3DFX_texture_compression_FXT1", NULL }, + { "GL_APPLE_client_storage", NULL }, + { "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions }, + { "GL_MESA_pack_invert", NULL }, + { "GL_MESA_ycbcr_texture", NULL }, + { "GL_NV_blend_square", NULL }, + { "GL_NV_point_sprite", GL_NV_point_sprite_functions }, + { "GL_NV_vertex_program", GL_NV_vertex_program_functions }, + { "GL_NV_vertex_program1_1", NULL }, + { "GL_SGIS_generate_mipmap", NULL }, + { NULL, NULL } }; static const struct dri_extension brw_extensions[] = { - { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions}, - { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions}, - { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions}, - { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions}, - { "GL_ARB_point_sprite", NULL}, - { "GL_ARB_fragment_shader", NULL }, - { "GL_ARB_draw_buffers", NULL }, { "GL_ARB_depth_texture", NULL }, + { "GL_ARB_draw_buffers", NULL }, { "GL_ARB_fragment_program", NULL }, + { "GL_ARB_fragment_program_shadow", NULL }, + { "GL_ARB_fragment_shader", NULL }, + { "GL_ARB_point_sprite", NULL }, + { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions }, + { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, + { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, { "GL_ARB_shadow", NULL }, + { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, { "GL_EXT_shadow_funcs", NULL }, - { "GL_ARB_fragment_program_shadow", NULL }, + { "GL_EXT_texture_sRGB", NULL }, /* ARB extn won't work if not enabled */ { "GL_SGIX_depth_texture", NULL }, - { "GL_EXT_texture_sRGB", NULL}, { NULL, NULL } }; #ifdef I915_MMIO_READ static const struct dri_extension arb_oc_extensions[] = { - {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, - {NULL, NULL} + { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions }, + { NULL, NULL } }; #endif static const struct dri_extension ttm_extensions[] = { - {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, - {"GL_ARB_pixel_buffer_object", NULL}, - {NULL, NULL} + { "GL_ARB_pixel_buffer_object", NULL }, + { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, + { NULL, NULL } }; /** -- cgit v1.2.3 From e3378790bb43d65689349545a14c8651677aff41 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Tue, 30 Sep 2008 15:38:38 -0600 Subject: cell: Fixed usage of MAX_INSTRUCTIONS to use new MAX_PROGRAM_INSTRUCTIONS instead of old MAX_NV_XXX definitions in order to allow Cell TGSI fragment program generator to work again. --- src/mesa/shader/arbprogparse.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index f499499eb3a..983f61a653b 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -64,12 +64,6 @@ having three separate program parameter arrays. #include "prog_statevars.h" #include "prog_instruction.h" - -/* For ARB programs, use the NV instruction limits */ -#define MAX_INSTRUCTIONS MAX2(MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS, \ - MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS) - - /** * This is basically a union of the vertex_program and fragment_program * structs that we can use to parse the program into @@ -3443,7 +3437,7 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst, : ctx->Const.VertexProgram.MaxInstructions; GLint err = 0; - ASSERT(MAX_INSTRUCTIONS >= maxInst); + ASSERT(MAX_PROGRAM_INSTRUCTIONS >= maxInst); Program->MajorVersion = (GLuint) * inst++; Program->MinorVersion = (GLuint) * inst++; @@ -3798,7 +3792,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, /* Initialize the arb_program struct */ program->Base.String = strz; - program->Base.Instructions = _mesa_alloc_instructions(MAX_INSTRUCTIONS); + program->Base.Instructions = _mesa_alloc_instructions(MAX_PROGRAM_INSTRUCTIONS); program->Base.NumInstructions = program->Base.NumTemporaries = program->Base.NumParameters = @@ -3843,12 +3837,12 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, _mesa_free (parsed); - /* Reallocate the instruction array from size [MAX_INSTRUCTIONS] + /* Reallocate the instruction array from size [MAX_PROGRAM_INSTRUCTIONS] * to size [ap.Base.NumInstructions]. */ program->Base.Instructions = _mesa_realloc_instructions(program->Base.Instructions, - MAX_INSTRUCTIONS, + MAX_PROGRAM_INSTRUCTIONS, program->Base.NumInstructions); return !err; -- cgit v1.2.3 From 266c5f5ccb3200c1fa195653d53748410078eac7 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 1 Oct 2008 19:36:04 +0200 Subject: mesa: Fix compiler warnings on Windows. --- src/mesa/shader/arbprogparse.c | 2 +- src/mesa/shader/slang/slang_link.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 466ae48bef3..34350ac4f3e 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -2609,7 +2609,7 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst, /* If we're referencing the Program->Parameters[] array, check if the * parameter is really a constant/literal. If so, set File to CONSTANT. */ - assert(*Index < Program->Base.Parameters->NumParameters); + assert(*Index < (GLint) Program->Base.Parameters->NumParameters); file = Program->Base.Parameters->Parameters[*Index].Type; if (file == PROGRAM_CONSTANT) *File = PROGRAM_CONSTANT; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index dd7d5be6d8b..202080d9d44 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -408,7 +408,7 @@ _slang_update_inputs_outputs(struct gl_program *prog) } } else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) { - maxAddrReg = MAX2(maxAddrReg, inst->SrcReg[j].Index + 1); + maxAddrReg = MAX2(maxAddrReg, (GLuint) (inst->SrcReg[j].Index + 1)); } } if (inst->DstReg.File == PROGRAM_OUTPUT) { -- cgit v1.2.3 From df6ae3f0a39f95cb1199ac16c98be2bf9a3bc96f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 1 Oct 2008 14:14:06 -0700 Subject: i965: Fix overwriting of depth override for SetTexOffset. Fixes black borders around windows in compiz. Bug #17233. --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 47127c04210..3790b50c976 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -274,7 +274,6 @@ brw_update_texture_surface( GLcontext *ctx, GLuint unit ) key.width = firstImage->Width; key.height = firstImage->Height; key.cpp = intelObj->mt->cpp; - key.depth = firstImage->Depth; key.tiling = intelObj->mt->region->tiling; dri_bo_unreference(brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS]); -- cgit v1.2.3 From 17fdd1ab3b48da8dff742e626c3c59bc89cafeed Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 1 Oct 2008 16:58:38 -0700 Subject: i965: sampler default color ends up in texture cache, not instructions. See volume 4, SAMPLER_BORDER_COLOR_STATE programming notes. --- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index e1db31ec08c..977b90ad43e 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -304,7 +304,7 @@ static void upload_wm_samplers( struct brw_context *brw ) continue; dri_bo_emit_reloc(brw->wm.sampler_bo, - I915_GEM_DOMAIN_INSTRUCTION, 0, + I915_GEM_DOMAIN_SAMPLER, 0, 0, i * sizeof(struct brw_sampler_state) + offsetof(struct brw_sampler_state, ss2), -- cgit v1.2.3 From 4741dbcbbc2514de370a760f4b78a17491014555 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 1 Oct 2008 15:51:56 -0700 Subject: Unify ARB_depth_texture and SGIX_depth_texture The ARB extension is a superset of the older SGIX extension. Any hardware that can support the SGIX version can also support the ARB version. In Mesa, any driver that supports one also supports the other. This unification just simplifies some bits of code. --- src/mesa/drivers/dri/i915/i915_context.c | 2 -- src/mesa/drivers/dri/intel/intel_context.c | 2 -- src/mesa/drivers/dri/intel/intel_tex_copy.c | 2 +- src/mesa/drivers/dri/r300/r300_context.c | 1 - src/mesa/main/depthstencil.c | 4 ++-- src/mesa/main/extensions.c | 3 +-- src/mesa/main/mtypes.h | 1 - src/mesa/main/texformat.c | 9 ++++----- src/mesa/main/teximage.c | 18 ++++++++---------- src/mesa/main/texparam.c | 3 +-- src/mesa/swrast/s_texstore.c | 6 +++--- 11 files changed, 20 insertions(+), 31 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index efcac911aa6..e0ddc7fd613 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -56,8 +56,6 @@ static const struct dri_extension i915_extensions[] = { {"GL_ARB_shadow", NULL}, {"GL_ARB_texture_non_power_of_two", NULL}, {"GL_EXT_shadow_funcs", NULL}, - /* ARB extn won't work if not enabled */ - {"GL_SGIX_depth_texture", NULL}, {NULL, NULL} }; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 1dd3ee7d0a6..e53972c46dd 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -404,8 +404,6 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, { "GL_EXT_shadow_funcs", NULL }, { "GL_EXT_texture_sRGB", NULL }, - /* ARB extn won't work if not enabled */ - { "GL_SGIX_depth_texture", NULL }, { NULL, NULL } }; diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index a7b88b39c04..f4cb4a781c6 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -60,7 +60,7 @@ get_teximage_source(struct intel_context *intel, GLenum internalFormat) switch (internalFormat) { case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: + case GL_DEPTH_COMPONENT16: irb = intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH); if (irb && irb->region && irb->region->cpp == 2) return irb->region; diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index ee4a69dce36..37436275e34 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -138,7 +138,6 @@ const struct dri_extension card_extensions[] = { {"GL_NV_blend_square", NULL}, {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, {"GL_SGIS_generate_mipmap", NULL}, - {"GL_SGIX_depth_texture", NULL}, {NULL, NULL} /* *INDENT-ON* */ }; diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c index fb54d6184d9..9d208e2997d 100644 --- a/src/mesa/main/depthstencil.c +++ b/src/mesa/main/depthstencil.c @@ -282,8 +282,8 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx, z24rb->RefCount = 1; z24rb->Width = dsrb->Width; z24rb->Height = dsrb->Height; - z24rb->InternalFormat = GL_DEPTH_COMPONENT24_ARB; - z24rb->_ActualFormat = GL_DEPTH_COMPONENT24_ARB; + z24rb->InternalFormat = GL_DEPTH_COMPONENT24; + z24rb->_ActualFormat = GL_DEPTH_COMPONENT24; z24rb->_BaseFormat = GL_DEPTH_COMPONENT; z24rb->DataType = GL_UNSIGNED_INT; z24rb->DepthBits = 24; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index ddcb44f06bf..de75325f152 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -165,7 +165,7 @@ static const struct { { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) }, { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, - { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) }, + { OFF, "GL_SGIX_depth_texture", F(ARB_depth_texture) }, { OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) }, { OFF, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, @@ -292,7 +292,6 @@ _mesa_enable_sw_extensions(GLcontext *ctx) ctx->Extensions.SGI_texture_color_table = GL_TRUE; ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; - ctx->Extensions.SGIX_depth_texture = GL_TRUE; ctx->Extensions.SGIX_shadow = GL_TRUE; ctx->Extensions.SGIX_shadow_ambient = GL_TRUE; #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 19cf6f56d1a..62bc65cc72c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2626,7 +2626,6 @@ struct gl_extensions GLboolean SGIS_generate_mipmap; GLboolean SGIS_texture_edge_clamp; GLboolean SGIS_texture_lod; - GLboolean SGIX_depth_texture; GLboolean SGIX_shadow; GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */ GLboolean TDFX_texture_compression_FXT1; diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index d4ccdf9fa06..4442ce39a44 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1420,14 +1420,13 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, ; /* fallthrough */ } - if (ctx->Extensions.SGIX_depth_texture || - ctx->Extensions.ARB_depth_texture) { + if (ctx->Extensions.ARB_depth_texture) { switch (internalFormat) { case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT24_SGIX: - case GL_DEPTH_COMPONENT32_SGIX: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: return &_mesa_texformat_z32; - case GL_DEPTH_COMPONENT16_SGIX: + case GL_DEPTH_COMPONENT16: return &_mesa_texformat_z16; default: ; /* fallthrough */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index b0a2d6ddb3d..4a419fde261 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -241,13 +241,12 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) } } - if (ctx->Extensions.SGIX_depth_texture || - ctx->Extensions.ARB_depth_texture) { + if (ctx->Extensions.ARB_depth_texture) { switch (internalFormat) { case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_SGIX: - case GL_DEPTH_COMPONENT24_SGIX: - case GL_DEPTH_COMPONENT32_SGIX: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: return GL_DEPTH_COMPONENT; default: ; /* fallthrough */ @@ -526,9 +525,9 @@ static GLboolean is_depth_format(GLenum format) { switch (format) { - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: case GL_DEPTH_COMPONENT: return GL_TRUE; default: @@ -2297,8 +2296,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, return; } - if (!ctx->Extensions.SGIX_depth_texture && - !ctx->Extensions.ARB_depth_texture && is_depth_format(format)) { + if (!ctx->Extensions.ARB_depth_texture && is_depth_format(format)) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); return; } diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index acddb6663bb..a9e752a6371 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -642,8 +642,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, *params = 0; break; case GL_TEXTURE_DEPTH_SIZE_ARB: - if (ctx->Extensions.SGIX_depth_texture || - ctx->Extensions.ARB_depth_texture) + if (ctx->Extensions.ARB_depth_texture) *params = img->TexFormat->DepthBits; else _mesa_error(ctx, GL_INVALID_ENUM, diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index 15d52aa587c..16b00b9fa1c 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -216,9 +216,9 @@ is_depth_format(GLenum format) { switch (format) { case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_SGIX: - case GL_DEPTH_COMPONENT24_SGIX: - case GL_DEPTH_COMPONENT32_SGIX: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: return GL_TRUE; default: return GL_FALSE; -- cgit v1.2.3 From 5620c20b24dc4f780a2246eb5270c4476b487e0a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Sep 2008 11:18:06 -0600 Subject: mesa: fix temp register allocation problems. Complex texcombine modes were running out of registers (>32 registers for 8 tex units). --- src/mesa/main/texenvprogram.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 2bce93eef1d..f6bbbcfaede 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -411,6 +411,14 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p ) } +/** Mark a temp reg as being no longer allocatable. */ +static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) +{ + if (r.file == PROGRAM_TEMPORARY) + p->temps_output |= (1 << r.idx); +} + + static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p ) { GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; @@ -504,10 +512,12 @@ emit_op(struct texenv_fragment_program *p, emit_dst( &inst->DstReg, dest, mask ); +#if 0 /* Accounting for indirection tracking: */ if (dest.file == PROGRAM_TEMPORARY) p->temps_output |= 1 << dest.idx; +#endif return inst; } @@ -562,6 +572,10 @@ static struct ureg emit_texld( struct texenv_fragment_program *p, p->program->Base.NumTexInstructions++; + /* Accounting for indirection tracking: + */ + reserve_temp(p, dest); + /* Is this a texture indirection? */ if ((coord.file == PROGRAM_TEMPORARY && @@ -1079,6 +1093,7 @@ create_new_program(GLcontext *ctx, struct state_key *key, for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) if (key->enabled_units & (1< Date: Wed, 1 Oct 2008 19:36:04 +0200 Subject: mesa: Fix compiler warnings on Windows. --- src/mesa/shader/arbprogparse.c | 2 +- src/mesa/shader/slang/slang_link.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 983f61a653b..448251b223d 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -2603,7 +2603,7 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst, /* If we're referencing the Program->Parameters[] array, check if the * parameter is really a constant/literal. If so, set File to CONSTANT. */ - assert(*Index < Program->Base.Parameters->NumParameters); + assert(*Index < (GLint) Program->Base.Parameters->NumParameters); file = Program->Base.Parameters->Parameters[*Index].Type; if (file == PROGRAM_CONSTANT) *File = PROGRAM_CONSTANT; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index d884be2a75d..00e89537685 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -408,7 +408,7 @@ _slang_update_inputs_outputs(struct gl_program *prog) } } else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) { - maxAddrReg = MAX2(maxAddrReg, inst->SrcReg[j].Index + 1); + maxAddrReg = MAX2(maxAddrReg, (GLuint) (inst->SrcReg[j].Index + 1)); } } if (inst->DstReg.File == PROGRAM_OUTPUT) { -- cgit v1.2.3 From 6280e335706f95ed0ebb089d8f72aeede9b5a1ad Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 13:51:56 +0100 Subject: mesa: shrink texenvprogram state key struct --- src/mesa/main/texenvprogram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 97aa87e58cf..ac49373604d 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -44,15 +44,17 @@ #define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) struct mode_opt { - GLuint Source:4; - GLuint Operand:3; + GLubyte Source:4; + GLubyte Operand:3; }; struct state_key { - GLbitfield enabled_units; + GLuint nr_enabled_units:8; + GLuint enabled_units:8; GLuint separate_specular:1; GLuint fog_enabled:1; GLuint fog_mode:2; + GLuint inputs_available:12; struct { GLuint enabled:1; @@ -62,10 +64,10 @@ struct state_key { GLuint NumArgsRGB:2; GLuint ModeRGB:4; - struct mode_opt OptRGB[3]; - GLuint NumArgsA:2; GLuint ModeA:4; + + struct mode_opt OptRGB[3]; struct mode_opt OptA[3]; } unit[8]; }; -- cgit v1.2.3 From 0e008d37979e4e5ede25056221583e02c08a5df7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 13:53:07 +0100 Subject: mesa: add missing state dependencies for various tracked constants --- src/mesa/shader/prog_statevars.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 8acf37c3c08..47c46f63ec9 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -488,6 +488,10 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], case STATE_PCM_BIAS: COPY_4V(value, ctx->Pixel.PostColorMatrixBias); break; + + /* XXX: make sure new tokens added here are also handled in the + * _mesa_program_state_flags() switch, below. + */ default: /* unknown state indexes are silently ignored * should be handled by the driver. @@ -561,10 +565,26 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) case STATE_INTERNAL: switch (state[1]) { + + case STATE_NORMAL_SCALE: + return _NEW_MODELVIEW; + case STATE_TEXRECT_SCALE: return _NEW_TEXTURE; case STATE_FOG_PARAMS_OPTIMIZED: return _NEW_FOG; + case STATE_LIGHT_SPOT_DIR_NORMALIZED: + case STATE_LIGHT_POSITION: + case STATE_LIGHT_POSITION_NORMALIZED: + case STATE_LIGHT_HALF_VECTOR: + return _NEW_LIGHT; + + case STATE_PT_SCALE: + case STATE_PT_BIAS: + case STATE_PCM_SCALE: + case STATE_PCM_BIAS: + return _NEW_PIXEL; + default: /* unknown state indexes are silently ignored and * no flag set, since it is handled by the driver. -- cgit v1.2.3 From fa1b533012030cd67148b5bf1e018fd5e30c96f8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 13:55:40 +0100 Subject: mesa: add new internal state for tracking current vertex attribs --- src/mesa/main/mtypes.h | 1 + src/mesa/main/state.c | 4 ++++ src/mesa/shader/prog_statevars.c | 8 ++++++++ src/mesa/shader/prog_statevars.h | 1 + src/mesa/vbo/vbo_exec_api.c | 44 ++++++++++++++++++++++++---------------- src/mesa/vbo/vbo_save_draw.c | 24 ++++++++++++++-------- 6 files changed, 56 insertions(+), 26 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a5e1cf6a276..bc099dabeb0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2744,6 +2744,7 @@ struct gl_matrix_stack #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */ #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */ #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */ +#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */ #define _NEW_ALL ~0 /*@}*/ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index d355f78a0ef..eb8dc2a3398 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -407,6 +407,9 @@ _mesa_update_state_locked( GLcontext *ctx ) GLbitfield new_state = ctx->NewState; GLbitfield prog_flags = _NEW_PROGRAM; + if (new_state == _NEW_CURRENT_ATTRIB) + goto out; + if (MESA_VERBOSE & VERBOSE_STATE) _mesa_print_state("_mesa_update_state", new_state); @@ -484,6 +487,7 @@ _mesa_update_state_locked( GLcontext *ctx ) * Set ctx->NewState to zero to avoid recursion if * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) */ + out: new_state = ctx->NewState; ctx->NewState = 0; ctx->Driver.UpdateState(ctx, new_state); diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 47c46f63ec9..9cc33fa2c11 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -395,6 +395,12 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], case STATE_INTERNAL: switch (state[1]) { + case STATE_CURRENT_ATTRIB: { + const GLuint idx = (GLuint) state[2]; + COPY_4V(value, ctx->Current.Attrib[idx]); + return; + } + case STATE_NORMAL_SCALE: ASSIGN_4V(value, ctx->_ModelViewInvScale, @@ -565,6 +571,8 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) case STATE_INTERNAL: switch (state[1]) { + case STATE_CURRENT_ATTRIB: + return _NEW_CURRENT_ATTRIB; case STATE_NORMAL_SCALE: return _NEW_MODELVIEW; diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 7b490e3d630..1f728c64e80 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -104,6 +104,7 @@ typedef enum gl_state_index_ { STATE_LOCAL, STATE_INTERNAL, /* Mesa additions */ + STATE_CURRENT_ATTRIB, /* ctx->Current vertex attrib value */ STATE_NORMAL_SCALE, STATE_TEXRECT_SCALE, STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */ diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index d70b4bb1a11..23f4f8331e3 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -143,29 +143,37 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (exec->vtx.attrsz[i]) { - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - /* Note: the exec->vtx.current[i] pointers point into the * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ - COPY_CLEAN_4V(current, - exec->vtx.attrsz[i], - exec->vtx.attrptr[i]); + GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; + GLfloat tmp[4]; + + COPY_CLEAN_4V(tmp, + exec->vtx.attrsz[i], + exec->vtx.attrptr[i]); + + if (memcmp(current, tmp, sizeof(tmp)) != 0) + { + memcpy(current, tmp, sizeof(tmp)); - /* Given that we explicitly state size here, there is no need - * for the COPY_CLEAN above, could just copy 16 bytes and be - * done. The only problem is when Mesa accesses ctx->Current - * directly. - */ - vbo->currval[i].Size = exec->vtx.attrsz[i]; - - /* This triggers rather too much recalculation of Mesa state - * that doesn't get used (eg light positions). - */ - if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && - i <= VBO_ATTRIB_MAT_BACK_INDEXES) - ctx->NewState |= _NEW_LIGHT; + /* Given that we explicitly state size here, there is no need + * for the COPY_CLEAN above, could just copy 16 bytes and be + * done. The only problem is when Mesa accesses ctx->Current + * directly. + */ + vbo->currval[i].Size = exec->vtx.attrsz[i]; + + /* This triggers rather too much recalculation of Mesa state + * that doesn't get used (eg light positions). + */ + if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && + i <= VBO_ATTRIB_MAT_BACK_INDEXES) + ctx->NewState |= _NEW_LIGHT; + + ctx->NewState |= _NEW_CURRENT_ATTRIB; + } } } diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index ed82f09958d..4c97acddb9f 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -64,18 +64,26 @@ static void _playback_copy_to_current( GLcontext *ctx, for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (node->attrsz[i]) { GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; + GLfloat tmp[4]; - COPY_CLEAN_4V(current, - node->attrsz[i], - data); + COPY_CLEAN_4V(tmp, + node->attrsz[i], + data); + + if (memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) + { + memcpy(current, tmp, 4 * sizeof(GLfloat)); - vbo->currval[i].Size = node->attrsz[i]; + vbo->currval[i].Size = node->attrsz[i]; - data += node->attrsz[i]; + if (i >= VBO_ATTRIB_FIRST_MATERIAL && + i <= VBO_ATTRIB_LAST_MATERIAL) + ctx->NewState |= _NEW_LIGHT; + + ctx->NewState |= _NEW_CURRENT_ATTRIB; + } - if (i >= VBO_ATTRIB_FIRST_MATERIAL && - i <= VBO_ATTRIB_LAST_MATERIAL) - ctx->NewState |= _NEW_LIGHT; + data += node->attrsz[i]; } } -- cgit v1.2.3 From d63a36ef3a4dd9cef1273fac5949e587c42813b5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 16:46:48 +0100 Subject: Mesa: short-circuit case when looking up the same program twice in cache --- src/mesa/shader/prog_cache.c | 29 +++++++++++++++++++++-------- src/mesa/shader/prog_cache.h | 2 +- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/prog_cache.c b/src/mesa/shader/prog_cache.c index 36a25377c55..9437e596138 100644 --- a/src/mesa/shader/prog_cache.c +++ b/src/mesa/shader/prog_cache.c @@ -44,6 +44,7 @@ struct cache_item struct gl_program_cache { struct cache_item **items; + struct cache_item *last; GLuint size, n_items; }; @@ -83,6 +84,8 @@ rehash(struct gl_program_cache *cache) struct cache_item *c, *next; GLuint size, i; + cache->last = NULL; + size = cache->size * 3; items = (struct cache_item**) _mesa_malloc(size * sizeof(*items)); _mesa_memset(items, 0, size * sizeof(*items)); @@ -105,6 +108,8 @@ clear_cache(GLcontext *ctx, struct gl_program_cache *cache) { struct cache_item *c, *next; GLuint i; + + cache->last = NULL; for (i = 0; i < cache->size; i++) { for (c = cache->items[i]; c; c = next) { @@ -149,18 +154,26 @@ _mesa_delete_program_cache(GLcontext *ctx, struct gl_program_cache *cache) struct gl_program * -_mesa_search_program_cache(const struct gl_program_cache *cache, +_mesa_search_program_cache(struct gl_program_cache *cache, const void *key, GLuint keysize) { - const GLuint hash = hash_key(key, keysize); - struct cache_item *c; - - for (c = cache->items[hash % cache->size]; c; c = c->next) { - if (c->hash == hash && memcmp(c->key, key, keysize) == 0) - return c->program; + if (cache->last && + memcmp(cache->last->key, key, keysize) == 0) { + return cache->last->program; } + else { + const GLuint hash = hash_key(key, keysize); + struct cache_item *c; + + for (c = cache->items[hash % cache->size]; c; c = c->next) { + if (c->hash == hash && memcmp(c->key, key, keysize) == 0) { + cache->last = c; + return c->program; + } + } - return NULL; + return NULL; + } } diff --git a/src/mesa/shader/prog_cache.h b/src/mesa/shader/prog_cache.h index a8c91fba011..4e1ccac03ff 100644 --- a/src/mesa/shader/prog_cache.h +++ b/src/mesa/shader/prog_cache.h @@ -42,7 +42,7 @@ _mesa_delete_program_cache(GLcontext *ctx, struct gl_program_cache *pc); extern struct gl_program * -_mesa_search_program_cache(const struct gl_program_cache *cache, +_mesa_search_program_cache(struct gl_program_cache *cache, const void *key, GLuint keysize); extern void -- cgit v1.2.3 From 1680ef869625dc1fe9cf481b180382a34e0738e7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 17:30:59 +0100 Subject: mesa: avoid generating constant vertex attributes in fixedfunc programs Keep track of enabled/active vertex attributes. Keep track of potential vertex program outputs. When generating fragment program, replace references to fragment attributes which are effectively non-varying and non-computed passthrough attributes with references to the new CURRENT_ATTRIB tracked state value. Only downside is slight ugliness in VBO code where we need to validate state twice in succession. --- src/mesa/main/mtypes.h | 2 + src/mesa/main/state.c | 38 ++++++++++++++++- src/mesa/main/state.h | 3 ++ src/mesa/main/texenvprogram.c | 94 ++++++++++++++++++++++++++++++++++++++++--- src/mesa/vbo/vbo_exec_array.c | 41 +++++++++++++++---- src/mesa/vbo/vbo_exec_draw.c | 8 ++++ src/mesa/vbo/vbo_save_draw.c | 4 ++ 7 files changed, 177 insertions(+), 13 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bc099dabeb0..ca1e369a357 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3073,6 +3073,8 @@ struct __GLcontextRec GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + GLuint varying_vp_inputs; + /** \name Derived state */ /*@{*/ GLbitfield _TriangleCaps; /**< bitwise-or of DD_* flags */ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index eb8dc2a3398..e0eb5f81e2b 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -465,7 +465,8 @@ _mesa_update_state_locked( GLcontext *ctx ) _mesa_update_tnl_spaces( ctx, new_state ); if (ctx->FragmentProgram._MaintainTexEnvProgram) { - prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR); + prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE_MATRIX | _NEW_LIGHT | + _NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR); } if (ctx->VertexProgram._MaintainTnlProgram) { prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX | @@ -504,3 +505,38 @@ _mesa_update_state( GLcontext *ctx ) _mesa_update_state_locked(ctx); _mesa_unlock_context_textures(ctx); } + + + + +/* Want to figure out which fragment program inputs are actually + * constant/current values from ctx->Current. These should be + * referenced as a tracked state variable rather than a fragment + * program input, to save the overhead of putting a constant value in + * every submitted vertex, transferring it to hardware, interpolating + * it across the triangle, etc... + * + * When there is a VP bound, just use vp->outputs. But when we're + * generating vp from fixed function state, basically want to + * calculate: + * + * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | + * potential_vp_outputs ) + * + * Where potential_vp_outputs is calculated by looking at enabled + * texgen, etc. + * + * The generated fragment program should then only declare inputs that + * may vary or otherwise differ from the ctx->Current values. + * Otherwise, the fp should track them as state values instead. + */ +void +_mesa_set_varying_vp_inputs( GLcontext *ctx, + unsigned varying_inputs ) +{ + if (ctx->varying_vp_inputs != varying_inputs) { + ctx->varying_vp_inputs = varying_inputs; + ctx->NewState |= _NEW_ARRAY; + //_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs); + } +} diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index bb7cb8f32a3..dc08043a762 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -37,5 +37,8 @@ _mesa_update_state( GLcontext *ctx ); extern void _mesa_update_state_locked( GLcontext *ctx ); +void +_mesa_set_varying_vp_inputs( GLcontext *ctx, + unsigned varying_inputs ); #endif diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index ac49373604d..7cd82f98b0d 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -189,6 +189,63 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) } } +#define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) +#define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) + +/* Identify all possible varying inputs. The fragment program will + * never reference non-varying inputs, but will track them via state + * constants instead. + * + * This function figures out all the inputs that the fragment program + * has access to. The bitmask is later reduced to just those which + * are actually referenced. + */ +static GLuint get_fp_input_mask( GLcontext *ctx ) +{ + GLuint fp_inputs = 0; + + if (1) { + GLuint varying_inputs = ctx->varying_vp_inputs; + + /* First look at what values may be computed by the generated + * vertex program: + */ + if (ctx->Light.Enabled) { + fp_inputs |= FRAG_BIT_COL0; + + if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) + fp_inputs |= FRAG_BIT_COL1; + } + + fp_inputs |= (ctx->Texture._TexGenEnabled | + ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0; + + /* Then look at what might be varying as a result of enabled + * arrays, etc: + */ + if (varying_inputs & VERT_BIT_COLOR0) fp_inputs |= FRAG_BIT_COL0; + if (varying_inputs & VERT_BIT_COLOR1) fp_inputs |= FRAG_BIT_COL1; + + fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0) + << FRAG_ATTRIB_TEX0); + + } + else { + /* calculate from vp->outputs */ + GLuint vp_outputs = 0; + + if (vp_outputs & (1 << VERT_RESULT_COL0)) fp_inputs |= FRAG_BIT_COL0; + if (vp_outputs & (1 << VERT_RESULT_COL1)) fp_inputs |= FRAG_BIT_COL1; + + fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) + << VERT_RESULT_TEX0) + >> FRAG_ATTRIB_TEX0); + } + + return fp_inputs; +} + + /** * Examine current texture environment state and generate a unique * key to identify it. @@ -196,17 +253,21 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) static void make_state_key( GLcontext *ctx, struct state_key *key ) { GLuint i, j; - + GLuint inputs_referenced = FRAG_BIT_COL0; + GLuint inputs_available = get_fp_input_mask( ctx ); + memset(key, 0, sizeof(*key)); for (i=0;iTexture.Unit[i]; - if (!texUnit->_ReallyEnabled) + if (!texUnit->_ReallyEnabled) continue; key->unit[i].enabled = 1; key->enabled_units |= (1<nr_enabled_units = i+1; + inputs_referenced |= FRAG_BIT_TEX(i); key->unit[i].source_index = translate_tex_src_bit(texUnit->_ReallyEnabled); @@ -234,13 +295,18 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) } } - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) + if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) { key->separate_specular = 1; + inputs_referenced |= FRAG_BIT_COL1; + } if (ctx->Fog.Enabled) { key->fog_enabled = 1; key->fog_mode = translate_fog_mode(ctx->Fog.Mode); + inputs_referenced |= FRAG_BIT_FOGC; /* maybe */ } + + key->inputs_available = (inputs_available & inputs_referenced); } /* Use uregs to represent registers internally, translate to Mesa's @@ -446,11 +512,29 @@ static struct ureg register_param5( struct texenv_fragment_program *p, #define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) #define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) +static GLuint frag_to_vert_attrib( GLuint attrib ) +{ + switch (attrib) { + case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0; + case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1; + default: + assert(attrib >= FRAG_ATTRIB_TEX0); + assert(attrib <= FRAG_ATTRIB_TEX7); + return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0; + } +} + static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) { - p->program->Base.InputsRead |= (1 << input); - return make_ureg(PROGRAM_INPUT, input); + if (p->state->inputs_available & (1<program->Base.InputsRead |= (1 << input); + return make_ureg(PROGRAM_INPUT, input); + } + else { + GLuint idx = frag_to_vert_attrib( input ); + return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, idx ); + } } diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 0f9d8da3568..3d74f9f4319 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -127,6 +127,7 @@ static void recalculate_input_bindings( GLcontext *ctx ) struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; const struct gl_client_array **inputs = &exec->array.inputs[0]; + GLuint const_inputs = 0; GLuint i; exec->array.program_mode = get_program_mode(ctx); @@ -141,19 +142,24 @@ static void recalculate_input_bindings( GLcontext *ctx ) for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { if (exec->array.legacy_array[i]->Enabled) inputs[i] = exec->array.legacy_array[i]; - else + else { inputs[i] = &vbo->legacy_currval[i]; + const_inputs |= 1 << i; + } } for (i = 0; i < MAT_ATTRIB_MAX; i++) { inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i]; + const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); } /* Could use just about anything, just to fill in the empty * slots: */ - for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) + for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) { inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; + const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); + } break; case VP_NV: @@ -166,15 +172,19 @@ static void recalculate_input_bindings( GLcontext *ctx ) inputs[i] = exec->array.generic_array[i]; else if (exec->array.legacy_array[i]->Enabled) inputs[i] = exec->array.legacy_array[i]; - else + else { inputs[i] = &vbo->legacy_currval[i]; + const_inputs |= 1 << i; + } } /* Could use just about anything, just to fill in the empty * slots: */ - for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) + for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) { inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0]; + const_inputs |= 1 << i; + } break; case VP_ARB: @@ -189,25 +199,34 @@ static void recalculate_input_bindings( GLcontext *ctx ) inputs[0] = exec->array.generic_array[0]; else if (exec->array.legacy_array[0]->Enabled) inputs[0] = exec->array.legacy_array[0]; - else + else { inputs[0] = &vbo->legacy_currval[0]; + const_inputs |= 1 << 0; + } for (i = 1; i <= VERT_ATTRIB_TEX7; i++) { if (exec->array.legacy_array[i]->Enabled) inputs[i] = exec->array.legacy_array[i]; - else + else { inputs[i] = &vbo->legacy_currval[i]; + const_inputs |= 1 << i; + } } for (i = 0; i < 16; i++) { if (exec->array.generic_array[i]->Enabled) inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; - else + else { inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; + const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); + } + } break; } + + _mesa_set_varying_vp_inputs( ctx, ~const_inputs ); } static void bind_arrays( GLcontext *ctx ) @@ -257,6 +276,11 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) bind_arrays( ctx ); + /* Again... + */ + if (ctx->NewState) + _mesa_update_state( ctx ); + prim[0].begin = 1; prim[0].end = 1; prim[0].weak = 0; @@ -297,6 +321,9 @@ vbo_exec_DrawRangeElements(GLenum mode, bind_arrays( ctx ); + if (ctx->NewState) + _mesa_update_state( ctx ); + ib.count = count; ib.type = type; ib.obj = ctx->Array.ElementArrayBufferObj; diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index f497e9a5a55..ad60c9b05f0 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -150,6 +150,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) GLubyte *data = exec->vtx.buffer_map; const GLuint *map; GLuint attr; + GLuint varying_inputs = 0; /* Install the default (ie Current) attributes first, then overlay * all active ones. @@ -211,8 +212,11 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) arrays[attr]._MaxElement = count; /* ??? */ data += exec->vtx.attrsz[src] * sizeof(GLfloat); + varying_inputs |= 1<NewState) + _mesa_update_state( ctx ); + + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 4c97acddb9f..b015bf27864 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -118,6 +118,7 @@ static void vbo_bind_vertex_list( GLcontext *ctx, GLuint data = node->buffer_offset; const GLuint *map; GLuint attr; + GLuint varying_inputs = 0; /* Install the default (ie Current) attributes first, then overlay * all active ones. @@ -167,8 +168,11 @@ static void vbo_bind_vertex_list( GLcontext *ctx, assert(arrays[attr].BufferObj->Name); data += node->attrsz[src] * sizeof(GLfloat); + varying_inputs |= 1< Date: Fri, 3 Oct 2008 12:16:04 -0700 Subject: intel: Don't advertise unsupported extensions on pre-965 hardware Move GL_ARB_texture_non_power_of_two and GL_ATI_separate_stencil from the generic extension list to the 965-specific list. Neither extension is supported on i830-class hardware, and GL_ATI_separate_stencil is not supported on i915-class hardare. GL_ARB_texture_non_power_of_two is supported on i915-class hardare and is already in the i915-specific list. --- src/mesa/drivers/dri/intel/intel_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index e53972c46dd..9dc32e487f4 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -355,7 +355,6 @@ static const struct dri_extension card_extensions[] = { { "GL_ARB_texture_env_crossbar", NULL }, { "GL_ARB_texture_env_dot3", NULL }, { "GL_ARB_texture_mirrored_repeat", NULL }, - { "GL_ARB_texture_non_power_of_two", NULL }, { "GL_ARB_texture_rectangle", NULL }, { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, @@ -379,7 +378,6 @@ static const struct dri_extension card_extensions[] = { { "GL_EXT_texture_lod_bias", NULL }, { "GL_3DFX_texture_compression_FXT1", NULL }, { "GL_APPLE_client_storage", NULL }, - { "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions }, { "GL_MESA_pack_invert", NULL }, { "GL_MESA_ycbcr_texture", NULL }, { "GL_NV_blend_square", NULL }, @@ -401,9 +399,11 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, { "GL_ARB_shadow", NULL }, + { "GL_ARB_texture_non_power_of_two", NULL }, { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, { "GL_EXT_shadow_funcs", NULL }, { "GL_EXT_texture_sRGB", NULL }, + { "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions }, { NULL, NULL } }; -- cgit v1.2.3 From 0370d6b359016790c6b879c2a4b6661adac20dea Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 4 Oct 2008 12:41:56 +0100 Subject: mesa: handle vertex program enabled case also in texenvprogram.c --- src/mesa/main/texenvprogram.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 7cd82f98b0d..ea2ee160e4f 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -204,7 +204,7 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) { GLuint fp_inputs = 0; - if (1) { + if (!ctx->VertexProgram._Enabled) { GLuint varying_inputs = ctx->varying_vp_inputs; /* First look at what values may be computed by the generated @@ -232,14 +232,13 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) } else { /* calculate from vp->outputs */ - GLuint vp_outputs = 0; + GLuint vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten; if (vp_outputs & (1 << VERT_RESULT_COL0)) fp_inputs |= FRAG_BIT_COL0; if (vp_outputs & (1 << VERT_RESULT_COL1)) fp_inputs |= FRAG_BIT_COL1; - fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) - << VERT_RESULT_TEX0) - >> FRAG_ATTRIB_TEX0); + fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0) + << FRAG_ATTRIB_TEX0); } return fp_inputs; -- cgit v1.2.3 From 91d0020eecb78ef2984fd0afafc5d555c0e957d8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 4 Oct 2008 18:20:35 -0700 Subject: i915: Refine the texture indirect lookup accounting. Without this, we would reject programs which sampled multiple times from registers defined in the same phase (block of instructions with the same texture indirection count), as each sample would count as a new phase beginning. Instead, keep track of which phases registers were written in, and only bump phase when we're reading from one generated in this phase. On the other hand, we failed to count oC or oD texture samples as being new phases. Bug #17865. --- src/mesa/drivers/dri/i915/i915_context.h | 3 +++ src/mesa/drivers/dri/i915/i915_program.c | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index c6958dd8d4b..a2376e50e15 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -125,6 +125,9 @@ struct i915_fragment_program GLboolean on_hardware; GLboolean error; /* If program is malformed for any reason. */ + /** Record of which phases R registers were last written in. */ + GLuint register_phases[16]; + GLuint indirections; GLuint nr_tex_indirect; GLuint nr_tex_insn; GLuint nr_alu_insn; diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c index 49193297a8c..350da5e1697 100644 --- a/src/mesa/drivers/dri/i915/i915_program.c +++ b/src/mesa/drivers/dri/i915/i915_program.c @@ -190,6 +190,9 @@ i915_emit_arith(struct i915_fragment_program * p, *(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1)); *(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2)); + if (GET_UREG_TYPE(dest) == REG_TYPE_R) + p->register_phases[GET_UREG_NR(dest)] = p->nr_tex_indirect; + p->nr_alu_insn++; return dest; } @@ -237,10 +240,22 @@ GLuint i915_emit_texld( struct i915_fragment_program *p, else { assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST); assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest))); + /* Can't use unsaved temps for coords, as the phase boundary would result + * in the contents becoming undefined. + */ + assert(GET_UREG_TYPE(coord) != REG_TYPE_U); + + /* Output register being oC or oD defines a phase boundary */ + if (GET_UREG_TYPE(dest) == REG_TYPE_OC || + GET_UREG_TYPE(dest) == REG_TYPE_OD) + p->nr_tex_indirect++; - if (GET_UREG_TYPE(coord) != REG_TYPE_T) { + /* Reading from an r# register whose contents depend on output of the + * current phase defines a phase boundary. + */ + if (GET_UREG_TYPE(coord) == REG_TYPE_R && + p->register_phases[GET_UREG_NR(coord)] == p->nr_tex_indirect) p->nr_tex_indirect++; - } *(p->csr++) = (op | T0_DEST( dest ) | @@ -249,6 +264,9 @@ GLuint i915_emit_texld( struct i915_fragment_program *p, *(p->csr++) = T1_ADDRESS_REG( coord ); *(p->csr++) = T2_MBZ; + if (GET_UREG_TYPE(dest) == REG_TYPE_R) + p->register_phases[GET_UREG_NR(dest)] = p->nr_tex_indirect; + p->nr_tex_insn++; return dest; } @@ -413,7 +431,8 @@ i915_init_program(struct i915_context *i915, struct i915_fragment_program *p) p->on_hardware = 0; p->error = 0; - p->nr_tex_indirect = 1; /* correct? */ + memset(&p->register_phases, 0, sizeof(p->register_phases)); + p->nr_tex_indirect = 1; p->nr_tex_insn = 0; p->nr_alu_insn = 0; p->nr_decl_insn = 0; -- cgit v1.2.3 From 382911bdbce5545117d5a70ce7e43b71e8396e32 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 6 Oct 2008 09:26:45 -0600 Subject: mesa: add missing GLcontext param to _mesa_delete_query(). Fixes vtk crash and others. --- src/mesa/main/queryobj.c | 2 +- src/mesa/main/queryobj.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index a1e32e70ba9..2d060300300 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -95,7 +95,7 @@ _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) * XXX maybe add Delete() method to gl_query_object class and call that instead */ void -_mesa_delete_query(struct gl_query_object *q) +_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q) { _mesa_free(q); } diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index c05a1f3da82..9a9774641bb 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -37,7 +37,7 @@ extern void _mesa_free_query_data(GLcontext *ctx); extern void -_mesa_delete_query(struct gl_query_object *q); +_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q); extern void _mesa_begin_query(GLcontext *ctx, struct gl_query_object *q); -- cgit v1.2.3 From f362788eae3d300e4003e8996dc79fc1947a0f60 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 6 Oct 2008 09:27:31 -0600 Subject: mesa: add missing GLcontext param to _mesa_delete_query(). Fixes vtk crash and others. --- src/mesa/main/queryobj.c | 2 +- src/mesa/main/queryobj.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index a1e32e70ba9..2d060300300 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -95,7 +95,7 @@ _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) * XXX maybe add Delete() method to gl_query_object class and call that instead */ void -_mesa_delete_query(struct gl_query_object *q) +_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q) { _mesa_free(q); } diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index c05a1f3da82..9a9774641bb 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -37,7 +37,7 @@ extern void _mesa_free_query_data(GLcontext *ctx); extern void -_mesa_delete_query(struct gl_query_object *q); +_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q); extern void _mesa_begin_query(GLcontext *ctx, struct gl_query_object *q); -- cgit v1.2.3 From b0ca50bd38b69593ac683a5e7635fbafa5e06676 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 6 Oct 2008 09:32:33 -0600 Subject: mesa: updated _mesa_delete_query() comments --- src/mesa/main/queryobj.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 2d060300300..6f084b6a4f1 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -90,9 +90,8 @@ _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) /** - * Delete an occlusion query object. + * Delete a query object. Called via ctx->Driver.DeleteQuery(). * Not removed from hash table here. - * XXX maybe add Delete() method to gl_query_object class and call that instead */ void _mesa_delete_query(GLcontext *ctx, struct gl_query_object *q) -- cgit v1.2.3 From 6e34fc0d374263ca40855ba4dcc237d961a79e34 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 6 Oct 2008 11:34:01 -0600 Subject: mesa: adjust texcoords for swrast sprite points. Fixes glean pointSprite test w/ software rendering --- src/mesa/swrast/s_points.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 846c485f15a..61ff4d0b84c 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -129,13 +129,13 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) s = 0.0; dsdx = 1.0 / size; if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) { - t0 = 0.0; dtdy = 1.0 / size; + t0 = 0.5 * dtdy; } else { /* GL_UPPER_LEFT */ - t0 = 1.0; dtdy = -1.0 / size; + t0 = 1.0 + 0.5 * dtdy; } ATTRIB_LOOP_BEGIN -- cgit v1.2.3 From 8e8208d6db8b764568539784a6473d545dec2265 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Mon, 6 Oct 2008 19:48:57 +0200 Subject: Mesa: fix the case where there are no vertex attributes. --- src/mesa/state_tracker/st_draw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index bdf8648ef7c..f9016923dcd 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -525,6 +525,8 @@ st_draw_vbo(GLcontext *ctx, vbuffer, velements); num_vbuffers = 1; num_velements = vp->num_inputs; + if (num_velements == 0) + num_vbuffers = 0; } else { /*printf("Draw non-interleaved\n");*/ -- cgit v1.2.3 From f8baad2d255c77c47dddeddcaf719e163e9556fb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 6 Oct 2008 12:29:29 -0600 Subject: mesa: set FRAG_BIT_FOGC bit in InputsUsed if FogOption!=GL_NONE --- src/mesa/shader/arbprogparse.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 8ce5348c09c..39988b5fca6 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -3863,6 +3863,9 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, program->FogOption = ap.FogOption; program->UsesKill = ap.UsesKill; + if (program->FogOption) + program->Base.InputsRead |= FRAG_BIT_FOGC; + if (program->Base.Instructions) _mesa_free(program->Base.Instructions); program->Base.Instructions = ap.Base.Instructions; -- cgit v1.2.3 From 4f4147eadd983bd4052c5a8e80a1750a813a25fc Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 6 Oct 2008 17:10:22 -0600 Subject: mesa: fix convolve/convolution mix-ups --- src/mesa/main/api_exec.c | 4 ++-- src/mesa/main/mfeatures.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 0c3c9c4de49..bae3bf11cb5 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -58,7 +58,7 @@ #include "colortab.h" #endif #include "context.h" -#if FEATURE_convolution +#if FEATURE_convolve #include "convolve.h" #endif #include "depth.h" @@ -402,7 +402,7 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv); #endif -#if FEATURE_convolution +#if FEATURE_convolve SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D); SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D); SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf); diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index ed78f57edf6..3819da3d680 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -39,7 +39,7 @@ #define FEATURE_accum _HAVE_FULL_GL #define FEATURE_attrib_stack _HAVE_FULL_GL #define FEATURE_colortable _HAVE_FULL_GL -#define FEATURE_convolution _HAVE_FULL_GL +#define FEATURE_convolve _HAVE_FULL_GL #define FEATURE_dispatch _HAVE_FULL_GL #define FEATURE_dlist _HAVE_FULL_GL #define FEATURE_draw_read_buffer _HAVE_FULL_GL -- cgit v1.2.3 From d055b2c001a0fb233f98c10d124b43dd2448059e Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 6 Oct 2008 17:10:45 -0600 Subject: mesa: fix convolve/convolution mix-ups --- src/mesa/main/api_exec.c | 4 ++-- src/mesa/main/mfeatures.h | 2 +- src/mesa/state_tracker/st_cb_texture.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 0c3c9c4de49..bae3bf11cb5 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -58,7 +58,7 @@ #include "colortab.h" #endif #include "context.h" -#if FEATURE_convolution +#if FEATURE_convolve #include "convolve.h" #endif #include "depth.h" @@ -402,7 +402,7 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv); #endif -#if FEATURE_convolution +#if FEATURE_convolve SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D); SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D); SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf); diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index b08c017ec8d..487493f88e1 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -39,7 +39,7 @@ #define FEATURE_accum _HAVE_FULL_GL #define FEATURE_attrib_stack _HAVE_FULL_GL #define FEATURE_colortable _HAVE_FULL_GL -#define FEATURE_convolution _HAVE_FULL_GL +#define FEATURE_convolve _HAVE_FULL_GL #define FEATURE_dispatch _HAVE_FULL_GL #define FEATURE_dlist _HAVE_FULL_GL #define FEATURE_draw_read_buffer _HAVE_FULL_GL diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 958f88bf2c4..a018cdee643 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -26,7 +26,7 @@ **************************************************************************/ #include "main/imports.h" -#if FEATURE_convolution +#if FEATURE_convolve #include "main/convolve.h" #endif #include "main/enums.h" @@ -409,7 +409,7 @@ st_TexImage(GLcontext * ctx, stImage->face = _mesa_tex_target_to_face(target); stImage->level = level; -#if FEATURE_convolution +#if FEATURE_convolve if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth, &postConvHeight); -- cgit v1.2.3 From 23e62c94ee17f21e99cc2e11fb1f960c0eb56f16 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Oct 2008 08:30:29 -0600 Subject: mesa: remove old assertion --- src/mesa/shader/arbprogparse.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 34350ac4f3e..4d89d057c7d 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -3443,8 +3443,6 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst, : ctx->Const.VertexProgram.MaxInstructions; GLint err = 0; - ASSERT(MAX_INSTRUCTIONS >= maxInst); - Program->MajorVersion = (GLuint) * inst++; Program->MinorVersion = (GLuint) * inst++; -- cgit v1.2.3 From 6ff1cf5b82488dc5a07513b0806c23e70f7a665e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 7 Oct 2008 12:31:31 +0100 Subject: mesa: protect against segfault in get_fp_input_mask() --- src/mesa/main/texenvprogram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index ea2ee160e4f..7049467c22f 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -204,7 +204,10 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) { GLuint fp_inputs = 0; - if (!ctx->VertexProgram._Enabled) { + if (!ctx->VertexProgram._Enabled || + !ctx->VertexProgram._Current) { + + /* Fixed function logic */ GLuint varying_inputs = ctx->varying_vp_inputs; /* First look at what values may be computed by the generated -- cgit v1.2.3 From 4070dba28a486bc0d14df028a085601ae7299f46 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 7 Oct 2008 16:33:17 +0100 Subject: mesa: update state after binding vertex list in dlist path --- src/mesa/vbo/vbo_save_draw.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index b015bf27864..68f3a965a5d 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -241,6 +241,11 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data ) vbo_bind_vertex_list( ctx, node ); + /* Again... + */ + if (ctx->NewState) + _mesa_update_state( ctx ); + vbo_context(ctx)->draw_prims( ctx, save->inputs, node->prim, -- cgit v1.2.3 From 239617fbe22d4dd7b2794510a6665f09602b5adf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Oct 2008 11:22:47 -0600 Subject: mesa: replace GLuint with GLbitfield to be clearer about usage Also, fix up some comments to be doxygen style. --- src/mesa/main/mtypes.h | 2 +- src/mesa/main/state.c | 2 +- src/mesa/main/state.h | 2 +- src/mesa/main/texenvprogram.c | 30 ++++++++++++++++-------------- src/mesa/vbo/vbo_exec_array.c | 2 +- src/mesa/vbo/vbo_exec_draw.c | 2 +- src/mesa/vbo/vbo_save_draw.c | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ca1e369a357..dff474d6d0e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3073,7 +3073,7 @@ struct __GLcontextRec GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ - GLuint varying_vp_inputs; + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ /** \name Derived state */ /*@{*/ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index e0eb5f81e2b..b124d48269d 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -532,7 +532,7 @@ _mesa_update_state( GLcontext *ctx ) */ void _mesa_set_varying_vp_inputs( GLcontext *ctx, - unsigned varying_inputs ) + GLbitfield varying_inputs ) { if (ctx->varying_vp_inputs != varying_inputs) { ctx->varying_vp_inputs = varying_inputs; diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index dc08043a762..79f2f6beb0c 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -39,6 +39,6 @@ _mesa_update_state_locked( GLcontext *ctx ); void _mesa_set_varying_vp_inputs( GLcontext *ctx, - unsigned varying_inputs ); + GLbitfield varying_inputs ); #endif diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 7049467c22f..638d6be5ad6 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -192,7 +192,8 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) #define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) #define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) -/* Identify all possible varying inputs. The fragment program will +/** + * Identify all possible varying inputs. The fragment program will * never reference non-varying inputs, but will track them via state * constants instead. * @@ -200,15 +201,15 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) * has access to. The bitmask is later reduced to just those which * are actually referenced. */ -static GLuint get_fp_input_mask( GLcontext *ctx ) +static GLbitfield get_fp_input_mask( GLcontext *ctx ) { - GLuint fp_inputs = 0; + GLbitfield fp_inputs = 0x0; if (!ctx->VertexProgram._Enabled || !ctx->VertexProgram._Current) { /* Fixed function logic */ - GLuint varying_inputs = ctx->varying_vp_inputs; + GLbitfield varying_inputs = ctx->varying_vp_inputs; /* First look at what values may be computed by the generated * vertex program: @@ -235,7 +236,7 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) } else { /* calculate from vp->outputs */ - GLuint vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten; + GLbitfield vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten; if (vp_outputs & (1 << VERT_RESULT_COL0)) fp_inputs |= FRAG_BIT_COL0; if (vp_outputs & (1 << VERT_RESULT_COL1)) fp_inputs |= FRAG_BIT_COL1; @@ -255,8 +256,8 @@ static GLuint get_fp_input_mask( GLcontext *ctx ) static void make_state_key( GLcontext *ctx, struct state_key *key ) { GLuint i, j; - GLuint inputs_referenced = FRAG_BIT_COL0; - GLuint inputs_available = get_fp_input_mask( ctx ); + GLbitfield inputs_referenced = FRAG_BIT_COL0; + GLbitfield inputs_available = get_fp_input_mask( ctx ); memset(key, 0, sizeof(*key)); @@ -311,7 +312,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) key->inputs_available = (inputs_available & inputs_referenced); } -/* Use uregs to represent registers internally, translate to Mesa's +/** + * Use uregs to represent registers internally, translate to Mesa's * expected formats on emit. * * NOTE: These are passed by value extensively in this file rather @@ -344,16 +346,16 @@ static const struct ureg undef = { }; -/* State used to build the fragment program: +/** State used to build the fragment program: */ struct texenv_fragment_program { struct gl_fragment_program *program; GLcontext *ctx; struct state_key *state; - GLbitfield alu_temps; /* Track texture indirections, see spec. */ - GLbitfield temps_output; /* Track texture indirections, see spec. */ - GLbitfield temp_in_use; /* Tracks temporary regs which are in use. */ + GLbitfield alu_temps; /**< Track texture indirections, see spec. */ + GLbitfield temps_output; /**< Track texture indirections, see spec. */ + GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ GLboolean error; struct ureg src_texture[MAX_TEXTURE_UNITS]; @@ -361,11 +363,11 @@ struct texenv_fragment_program { * else undef. */ - struct ureg src_previous; /* Reg containing color from previous + struct ureg src_previous; /**< Reg containing color from previous * stage. May need to be decl'd. */ - GLuint last_tex_stage; /* Number of last enabled texture unit */ + GLuint last_tex_stage; /**< Number of last enabled texture unit */ struct ureg half; struct ureg one; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 3d74f9f4319..8871e10cf60 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -127,7 +127,7 @@ static void recalculate_input_bindings( GLcontext *ctx ) struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; const struct gl_client_array **inputs = &exec->array.inputs[0]; - GLuint const_inputs = 0; + GLbitfield const_inputs = 0x0; GLuint i; exec->array.program_mode = get_program_mode(ctx); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index ad60c9b05f0..ae43857c8ae 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -150,7 +150,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) GLubyte *data = exec->vtx.buffer_map; const GLuint *map; GLuint attr; - GLuint varying_inputs = 0; + GLbitfield varying_inputs = 0x0; /* Install the default (ie Current) attributes first, then overlay * all active ones. diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 68f3a965a5d..0488c5d7182 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -118,7 +118,7 @@ static void vbo_bind_vertex_list( GLcontext *ctx, GLuint data = node->buffer_offset; const GLuint *map; GLuint attr; - GLuint varying_inputs = 0; + GLbitfield varying_inputs = 0x0; /* Install the default (ie Current) attributes first, then overlay * all active ones. -- cgit v1.2.3 From 4f1dafaa82985bf0f04a16ba2ba2d1e8ccf83724 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Tue, 7 Oct 2008 21:28:38 +0200 Subject: Mesa: fix the case where there are no vertex attributes. This is a backport of 8e8208d6db8b764568539784a6473d545dec2265 to gallium-0.1 --- src/mesa/state_tracker/st_draw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index bdf8648ef7c..61949a93884 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -525,6 +525,8 @@ st_draw_vbo(GLcontext *ctx, vbuffer, velements); num_vbuffers = 1; num_velements = vp->num_inputs; + if (num_velements == 0) + num_vbuffers = 0; } else { /*printf("Draw non-interleaved\n");*/ -- cgit v1.2.3 From 7cb723a3fd4d90ad6efa5f440e5e39f8aaa9f79c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Oct 2008 16:52:47 -0600 Subject: mesa: pass 'mask', not NULL to renderbuffer->Put functions Fixes bug 17800. --- src/mesa/swrast/s_depth.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 293eb8628e6..26e23f02d59 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.2.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -534,15 +534,15 @@ depth_test_span( GLcontext *ctx, SWspan *span) if (rb->DataType == GL_UNSIGNED_SHORT) { GLushort zbuffer[MAX_WIDTH]; rb->GetRow(ctx, rb, count, x, y, zbuffer); - passed = depth_test_span16(ctx, count, zbuffer, zValues, mask ); - rb->PutRow(ctx, rb, count, x, y, zbuffer, NULL); + passed = depth_test_span16(ctx, count, zbuffer, zValues, mask); + rb->PutRow(ctx, rb, count, x, y, zbuffer, mask); } else { GLuint zbuffer[MAX_WIDTH]; ASSERT(rb->DataType == GL_UNSIGNED_INT); rb->GetRow(ctx, rb, count, x, y, zbuffer); - passed = depth_test_span32(ctx, count, zbuffer, zValues, mask ); - rb->PutRow(ctx, rb, count, x, y, zbuffer, NULL); + passed = depth_test_span32(ctx, count, zbuffer, zValues, mask); + rb->PutRow(ctx, rb, count, x, y, zbuffer, mask); } } @@ -1080,15 +1080,15 @@ depth_test_pixels( GLcontext *ctx, SWspan *span ) if (rb->DataType == GL_UNSIGNED_SHORT) { GLushort zbuffer[MAX_WIDTH]; _swrast_get_values(ctx, rb, count, x, y, zbuffer, sizeof(GLushort)); - depth_test_span16(ctx, count, zbuffer, z, mask ); - rb->PutValues(ctx, rb, count, x, y, zbuffer, NULL); + depth_test_span16(ctx, count, zbuffer, z, mask); + rb->PutValues(ctx, rb, count, x, y, zbuffer, mask); } else { GLuint zbuffer[MAX_WIDTH]; ASSERT(rb->DataType == GL_UNSIGNED_INT); _swrast_get_values(ctx, rb, count, x, y, zbuffer, sizeof(GLuint)); - depth_test_span32(ctx, count, zbuffer, z, mask ); - rb->PutValues(ctx, rb, count, x, y, zbuffer, NULL); + depth_test_span32(ctx, count, zbuffer, z, mask); + rb->PutValues(ctx, rb, count, x, y, zbuffer, mask); } } -- cgit v1.2.3 From 94d3a30df759bb7c2724fdcee9e89a350d3a4d8b Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 8 Oct 2008 09:30:12 +0800 Subject: i965: Fix a potential assertion failure. --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 303eaac5cf9..cc3d9396acd 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -365,8 +365,10 @@ static void brw_prepare_vertices(struct brw_context *brw) if (i == 0) { /* Position array not properly enabled: */ - if (input->glarray->StrideB == 0) - return; + if (input->glarray->StrideB == 0) { + intel->Fallback = 1; + return; + } interleave = input->glarray->StrideB; ptr = input->glarray->Ptr; -- cgit v1.2.3 From fc19536aa989ad61e95c281883d32860d767f8ef Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 3 Oct 2008 16:20:00 -0700 Subject: intel: Push flushing for cliprects changes down into the cliprects changes. This lets us short-circuit when we're leaving the same cliprects in place, which becomes quite common with metaops clears, and may be useful for some of our FBO paths. --- src/mesa/drivers/dri/intel/intel_buffers.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index defa5b173d9..f5eaf765f38 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -135,6 +135,14 @@ intel_readbuf_region(struct intel_context *intel) static void intelSetRenderbufferClipRects(struct intel_context *intel) { + /* If the batch contents require looping over cliprects, flush them before + * we go changing which cliprects get referenced when that happens. + */ + if (intel->batch->cliprect_mode == LOOP_CLIPRECTS && + (intel->fboRect.x2 != intel->ctx.DrawBuffer->Width || + intel->fboRect.x2 != intel->ctx.DrawBuffer->Height)) + intel_batchbuffer_flush(intel->batch); + assert(intel->ctx.DrawBuffer->Width > 0); assert(intel->ctx.DrawBuffer->Height > 0); intel->fboRect.x1 = 0; @@ -160,6 +168,12 @@ intelSetFrontClipRects(struct intel_context *intel) if (!dPriv) return; + /* If the batch contents require looping over cliprects, flush them before + * we go changing which cliprects get referenced when that happens. + */ + if (intel->batch->cliprect_mode == LOOP_CLIPRECTS && + intel->pClipRects != dPriv->pClipRects) + intel_batchbuffer_flush(intel->batch); intel->numClipRects = dPriv->numClipRects; intel->pClipRects = dPriv->pClipRects; intel->drawX = dPriv->x; @@ -183,6 +197,10 @@ intelSetBackClipRects(struct intel_context *intel) if (intel_fb->pf_active || dPriv->numBackClipRects == 0) { /* use the front clip rects */ + if (intel->batch->cliprect_mode == LOOP_CLIPRECTS && + intel->pClipRects != dPriv->pClipRects) + intel_batchbuffer_flush(intel->batch); + intel->numClipRects = dPriv->numClipRects; intel->pClipRects = dPriv->pClipRects; intel->drawX = dPriv->x; @@ -190,6 +208,10 @@ intelSetBackClipRects(struct intel_context *intel) } else { /* use the back clip rects */ + if (intel->batch->cliprect_mode == LOOP_CLIPRECTS && + intel->pClipRects != dPriv->pBackClipRects) + intel_batchbuffer_flush(intel->batch); + intel->numClipRects = dPriv->numBackClipRects; intel->pClipRects = dPriv->pBackClipRects; intel->drawX = dPriv->backX; @@ -900,12 +922,6 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) if (fb->Name) intel_validate_paired_depth_stencil(ctx, fb); - /* If the batch contents require looping over cliprects, flush them before - * we go changing which cliprects get referenced when that happens. - */ - if (intel->batch->cliprect_mode == LOOP_CLIPRECTS) - intel_batchbuffer_flush(intel->batch); - /* * How many color buffers are we drawing into? */ -- cgit v1.2.3 From c157cfc6376f7469ab272b18868183e5ff9ac754 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 6 Oct 2008 17:34:51 -0700 Subject: i965: Add ARB_occlusion_query support. --- src/mesa/drivers/dri/i965/Makefile | 1 + src/mesa/drivers/dri/i965/brw_context.c | 4 + src/mesa/drivers/dri/i965/brw_context.h | 30 +++- src/mesa/drivers/dri/i965/brw_draw.c | 2 +- src/mesa/drivers/dri/i965/brw_draw_upload.c | 3 + src/mesa/drivers/dri/i965/brw_queryobj.c | 263 ++++++++++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_vtbl.c | 10 ++ src/mesa/drivers/dri/intel/intel_context.c | 51 +----- src/mesa/drivers/dri/intel/intel_reg.h | 19 ++ 9 files changed, 331 insertions(+), 52 deletions(-) create mode 100644 src/mesa/drivers/dri/i965/brw_queryobj.c (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index c2d555cd0cf..7bc16a02c8c 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -51,6 +51,7 @@ DRIVER_SOURCES = \ brw_metaops.c \ brw_misc_state.c \ brw_program.c \ + brw_queryobj.c \ brw_sf.c \ brw_sf_emit.c \ brw_sf_state.c \ diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 5f604771766..474158b484b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -33,6 +33,7 @@ #include "main/imports.h" #include "main/api_noop.h" #include "main/vtxfmt.h" +#include "main/simple_list.h" #include "shader/shader_api.h" #include "brw_context.h" @@ -68,6 +69,7 @@ static void brwInitDriverFunctions( struct dd_function_table *functions ) brwInitFragProgFuncs( functions ); brwInitProgFuncs( functions ); + brw_init_queryobj_functions(functions); } @@ -150,6 +152,8 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; + make_empty_list(&brw->query.active_head); + brw_draw_init( brw ); return GL_TRUE; diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 8bddc9da405..1c6a0dede0b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -410,7 +410,22 @@ struct brw_tnl_cache { GLuint size, n_items; }; +struct brw_query_object { + struct gl_query_object Base; + /** Doubly linked list of active query objects in the context. */ + struct brw_query_object *prev, *next; + + /** Last query BO associated with this query. */ + dri_bo *bo; + /** First index in bo with query data for this object. */ + int first_index; + /** Last index in bo with query data for this object. */ + int last_index; + + /* Total count of pixels from previous BOs */ + unsigned int count; +}; struct brw_context { @@ -626,7 +641,12 @@ struct brw_context dri_bo *vp_bo; } cc; - + struct { + struct brw_query_object active_head; + dri_bo *bo; + int index; + GLboolean active; + } query; /* Used to give every program string a unique id */ GLuint program_id; @@ -651,7 +671,13 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate); - +/*====================================================================== + * brw_queryobj.c + */ +void brw_init_queryobj_functions(struct dd_function_table *functions); +void brw_prepare_query_begin(struct brw_context *brw); +void brw_emit_query_begin(struct brw_context *brw); +void brw_emit_query_end(struct brw_context *brw); /*====================================================================== * brw_state.c diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 39ce8eb4b62..6c71b4abcf0 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -382,7 +382,6 @@ void brw_draw_prims( GLcontext *ctx, return; } - /* Make a first attempt at drawing: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); @@ -395,6 +394,7 @@ void brw_draw_prims( GLcontext *ctx, _swsetup_Wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } + } void brw_draw_init( struct brw_context *brw ) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index cc3d9396acd..7b88b5eaa1e 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -415,6 +415,8 @@ static void brw_prepare_vertices(struct brw_context *brw) copy_array_to_vbo_array(brw, upload[i], upload[i]->element_size); } } + + brw_prepare_query_begin(brw); } static void brw_emit_vertices(struct brw_context *brw) @@ -435,6 +437,7 @@ static void brw_emit_vertices(struct brw_context *brw) enabled[nr_enabled++] = input; } + brw_emit_query_begin(brw); /* Now emit VB and VEP state packets. * diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c new file mode 100644 index 00000000000..a1a1353dee7 --- /dev/null +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -0,0 +1,263 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt + * + */ + +/** @file support for ARB_query_object + * + * ARB_query_object is implemented by using the PIPE_CONTROL command to stall + * execution on the completion of previous depth tests, and write the + * current PS_DEPTH_COUNT to a buffer object. + * + * We use before and after counts when drawing during a query so that + * we don't pick up other clients' query data in ours. To reduce overhead, + * a single BO is used to record the query data for all active queries at + * once. This also gives us a simple bound on how much batchbuffer space is + * required for handling queries, so that we can be sure that we won't + * have to emit a batchbuffer without getting the ending PS_DEPTH_COUNT. + */ +#include "main/simple_list.h" +#include "main/imports.h" + +#include "brw_context.h" +#include "intel_batchbuffer.h" +#include "intel_reg.h" + +/** Waits on the query object's BO and totals the results for this query */ +static void +brw_queryobj_get_results(struct brw_query_object *query) +{ + int i; + uint64_t *results; + + if (query->bo == NULL) + return; + + /* Map and count the pixels from the current query BO */ + dri_bo_map(query->bo, GL_FALSE); + results = query->bo->virtual; + for (i = query->first_index; i <= query->last_index; i++) { + query->Base.Result += results[i * 2 + 1] - results[i * 2]; + } + dri_bo_unmap(query->bo); + + dri_bo_unreference(query->bo); + query->bo = NULL; +} + +static struct gl_query_object * +brw_new_query_object(GLcontext *ctx, GLuint id) +{ + struct brw_query_object *query; + + query = _mesa_calloc(sizeof(struct brw_query_object)); + + query->Base.Id = id; + query->Base.Result = 0; + query->Base.Active = GL_FALSE; + query->Base.Ready = GL_TRUE; + + return &query->Base; +} + +static void +brw_delete_query(GLcontext *ctx, struct gl_query_object *q) +{ + struct brw_query_object *query = (struct brw_query_object *)q; + + dri_bo_unreference(query->bo); + _mesa_free(query); +} + +static void +brw_begin_query(GLcontext *ctx, struct gl_query_object *q) +{ + struct brw_context *brw = brw_context(ctx); + struct intel_context *intel = intel_context(ctx); + struct brw_query_object *query = (struct brw_query_object *)q; + + /* Reset our driver's tracking of query state. */ + dri_bo_unreference(query->bo); + query->bo = NULL; + query->first_index = -1; + query->last_index = -1; + + insert_at_head(&brw->query.active_head, query); + intel->stats_wm++; +} + +/** + * Begin the ARB_occlusion_query query on a query object. + */ +static void +brw_end_query(GLcontext *ctx, struct gl_query_object *q) +{ + struct brw_context *brw = brw_context(ctx); + struct intel_context *intel = intel_context(ctx); + struct brw_query_object *query = (struct brw_query_object *)q; + + /* Flush the batchbuffer in case it has writes to our query BO. + * Have later queries write to a new query BO so that further rendering + * doesn't delay the collection of our results. + */ + if (query->bo) { + brw_emit_query_end(brw); + intel_batchbuffer_flush(intel->batch); + + dri_bo_unreference(brw->query.bo); + brw->query.bo = NULL; + } + + remove_from_list(query); + + intel->stats_wm--; +} + +static void brw_wait_query(GLcontext *ctx, struct gl_query_object *q) +{ + struct brw_query_object *query = (struct brw_query_object *)q; + + brw_queryobj_get_results(query); + query->Base.Ready = GL_TRUE; +} + +static void brw_check_query(GLcontext *ctx, struct gl_query_object *q) +{ + /* XXX: Need to expose dri_bo_is_idle from bufmgr. */ +#if 0 + struct brw_query_object *query = (struct brw_query_object *)q; + + if (dri_bo_is_idle(query->bo)) { + brw_queryobj_get_results(query); + query->Base.Ready = GL_TRUE; + } +#else + brw_wait_query(ctx, q); +#endif +} + +/** Called to set up the query BO and account for its aperture space */ +void +brw_prepare_query_begin(struct brw_context *brw) +{ + struct intel_context *intel = &brw->intel; + dri_bo *aper_array[] = { + intel->batch->buf, + brw->query.bo, + }; + + /* Skip if we're not doing any queries. */ + if (is_empty_list(&brw->query.active_head)) + return; + + /* Get a new query BO if we're going to need it. */ + if (brw->query.bo == NULL || + brw->query.index * 2 + 1 >= 4096 / sizeof(uint64_t)) { + dri_bo_unreference(brw->query.bo); + brw->query.bo = NULL; + + brw->query.bo = dri_bo_alloc(intel->bufmgr, "query", 4096, 1); + brw->query.index = 0; + } + + if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array))) + intel_batchbuffer_flush(intel->batch); +} + +/** Called just before primitive drawing to get a beginning PS_DEPTH_COUNT. */ +void +brw_emit_query_begin(struct brw_context *brw) +{ + struct intel_context *intel = &brw->intel; + struct brw_query_object *query; + + /* Skip if we're not doing any queries, or we've emitted the start. */ + if (brw->query.active || is_empty_list(&brw->query.active_head)) + return; + + BEGIN_BATCH(4, IGNORE_CLIPRECTS); + OUT_BATCH(_3DSTATE_PIPE_CONTROL | + PIPE_CONTROL_DEPTH_STALL | + PIPE_CONTROL_WRITE_DEPTH_COUNT); + /* This object could be mapped cacheable, but we don't have an exposed + * mechanism to support that. Since it's going uncached, tell GEM that + * we're writing to it. The usual clflush should be all that's required + * to pick up the results. + */ + OUT_RELOC(brw->query.bo, + I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, + PIPE_CONTROL_GLOBAL_GTT_WRITE | + ((brw->query.index * 2) * sizeof(uint64_t))); + OUT_BATCH(0); + OUT_BATCH(0); + ADVANCE_BATCH(); + + foreach(query, &brw->query.active_head) { + if (query->bo != brw->query.bo) { + if (query->bo != NULL) + brw_queryobj_get_results(query); + dri_bo_reference(brw->query.bo); + query->bo = brw->query.bo; + query->first_index = brw->query.index; + } + query->last_index = brw->query.index; + } + brw->query.active = GL_TRUE; +} + +/** Called at batchbuffer flush to get an ending PS_DEPTH_COUNT */ +void +brw_emit_query_end(struct brw_context *brw) +{ + struct intel_context *intel = &brw->intel; + + if (!brw->query.active) + return; + + BEGIN_BATCH(4, IGNORE_CLIPRECTS); + OUT_BATCH(_3DSTATE_PIPE_CONTROL | + PIPE_CONTROL_DEPTH_STALL | + PIPE_CONTROL_WRITE_DEPTH_COUNT); + OUT_RELOC(brw->query.bo, + I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, + PIPE_CONTROL_GLOBAL_GTT_WRITE | + ((brw->query.index * 2 + 1) * sizeof(uint64_t))); + OUT_BATCH(0); + OUT_BATCH(0); + ADVANCE_BATCH(); + + brw->query.active = GL_FALSE; + brw->query.index++; +} + +void brw_init_queryobj_functions(struct dd_function_table *functions) +{ + functions->NewQueryObject = brw_new_query_object; + functions->DeleteQuery = brw_delete_query; + functions->BeginQuery = brw_begin_query; + functions->EndQuery = brw_end_query; + functions->CheckQuery = brw_check_query; + functions->WaitQuery = brw_wait_query; +} diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index cd074dfed64..a64e437860f 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -120,6 +120,15 @@ static void brw_set_draw_region( struct intel_context *intel, brw->state.nr_draw_regions = num_regions; } +/* called from intel_batchbuffer_flush and children before sending a + * batchbuffer off. + */ +static void brw_finish_batch(struct intel_context *intel) +{ + struct brw_context *brw = brw_context(&intel->ctx); + + brw_emit_query_end(brw); +} /* called from intelFlushBatchLocked */ @@ -218,6 +227,7 @@ void brwInitVtbl( struct brw_context *brw ) brw->intel.vtbl.note_fence = brw_note_fence; brw->intel.vtbl.note_unlock = brw_note_unlock; brw->intel.vtbl.new_batch = brw_new_batch; + brw->intel.vtbl.finish_batch = brw_finish_batch; brw->intel.vtbl.destroy = brw_destroy_context; brw->intel.vtbl.set_draw_region = brw_set_draw_region; brw->intel.vtbl.flush_cmd = brw_flush_cmd; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 9dc32e487f4..e6c0d3175e4 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -394,6 +394,7 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_fragment_program", NULL }, { "GL_ARB_fragment_program_shadow", NULL }, { "GL_ARB_fragment_shader", NULL }, + { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions }, { "GL_ARB_point_sprite", NULL }, { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions }, { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, @@ -407,12 +408,9 @@ static const struct dri_extension brw_extensions[] = { { NULL, NULL } }; -#ifdef I915_MMIO_READ -static const struct dri_extension arb_oc_extensions[] = { - { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions }, +static const struct dri_extension arb_oq_extensions[] = { { NULL, NULL } }; -#endif static const struct dri_extension ttm_extensions[] = { { "GL_ARB_pixel_buffer_object", NULL }, @@ -437,13 +435,6 @@ void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging) if (intel == NULL || intel->ttm) driInitExtensions(ctx, ttm_extensions, GL_FALSE); -#ifdef I915_MMIO_READ - if (intel == NULL || - (IS_965(intel->intelScreen->deviceID) && - intel->intelScreen->drmMinor >= 8)) - driInitExtensions(ctx, arb_oc_extensions, GL_FALSE); -#endif - if (intel == NULL || IS_965(intel->intelScreen->deviceID)) driInitExtensions(ctx, brw_extensions, GL_FALSE); } @@ -540,39 +531,6 @@ intelFinish(GLcontext * ctx) } } -#ifdef I915_MMIO_READ -static void -intelBeginQuery(GLcontext *ctx, struct gl_query_object *q) -{ - struct intel_context *intel = intel_context( ctx ); - struct drm_i915_mmio io = { - .read_write = I915_MMIO_READ, - .reg = MMIO_REGS_PS_DEPTH_COUNT, - .data = &q->Result - }; - intel->stats_wm++; - intelFinish(&intel->ctx); - drmCommandWrite(intel->driFd, DRM_I915_MMIO, &io, sizeof(io)); -} - -static void -intelEndQuery(GLcontext *ctx, struct gl_query_object *q) -{ - struct intel_context *intel = intel_context( ctx ); - GLuint64EXT tmp; - struct drm_i915_mmio io = { - .read_write = I915_MMIO_READ, - .reg = MMIO_REGS_PS_DEPTH_COUNT, - .data = &tmp - }; - intelFinish(&intel->ctx); - drmCommandWrite(intel->driFd, DRM_I915_MMIO, &io, sizeof(io)); - q->Result = tmp - q->Result; - q->Ready = GL_TRUE; - intel->stats_wm--; -} -#endif - void intelInitDriverFunctions(struct dd_function_table *functions) { @@ -589,11 +547,6 @@ intelInitDriverFunctions(struct dd_function_table *functions) functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; -#ifdef I915_MMIO_READ - functions->BeginQuery = intelBeginQuery; - functions->EndQuery = intelEndQuery; -#endif - intelInitTextureFuncs(functions); intelInitStateFuncs(functions); intelInitBufferFuncs(functions); diff --git a/src/mesa/drivers/dri/intel/intel_reg.h b/src/mesa/drivers/dri/intel/intel_reg.h index 96af7e1a030..c21f4080935 100644 --- a/src/mesa/drivers/dri/intel/intel_reg.h +++ b/src/mesa/drivers/dri/intel/intel_reg.h @@ -44,6 +44,25 @@ #define _3DSTATE_LOAD_STATE_IMMEDIATE_1 (CMD_3D | (0x1d<<24) | (0x04<<16)) #define I1_LOAD_S(n) (1<<(4+n)) +/** @{ + * + * PIPE_CONTROL operation, a combination MI_FLUSH and register write with + * additional flushing control. + */ +#define _3DSTATE_PIPE_CONTROL (CMD_3D | (3 << 27) | (2 << 24) | 2) +#define PIPE_CONTROL_NO_WRITE (0 << 14) +#define PIPE_CONTROL_WRITE_IMMEDIATE (1 << 14) +#define PIPE_CONTROL_WRITE_DEPTH_COUNT (2 << 14) +#define PIPE_CONTROL_WRITE_TIMESTAMP (3 << 14) +#define PIPE_CONTROL_DEPTH_STALL (1 << 13) +#define PIPE_CONTROL_WRITE_FLUSH (1 << 12) +#define PIPE_CONTROL_INSTRUCTION_FLUSH (1 << 11) +#define PIPE_CONTROL_INTERRUPT_ENABLE (1 << 8) +#define PIPE_CONTROL_PPGTT_WRITE (0 << 2) +#define PIPE_CONTROL_GLOBAL_GTT_WRITE (1 << 2) + +/** @} */ + /** @{ * 915 definitions */ -- cgit v1.2.3 From 902727b7e3eb3c2c9bcddf1d55d3c95c73377cf3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 7 Oct 2008 18:47:31 -0700 Subject: mesa: Pass the context to query object delete cb to avoid null dereference. --- src/mesa/main/queryobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 6f084b6a4f1..554e0b0d181 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -545,6 +545,6 @@ delete_queryobj_cb(GLuint id, void *data, void *userData) void _mesa_free_query_data(GLcontext *ctx) { - _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, NULL); + _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); _mesa_DeleteHashTable(ctx->Query.QueryObjects); } -- cgit v1.2.3 From 5462d447aa5bce9e558594eabeddd624cd39b1de Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 8 Oct 2008 09:28:10 -0600 Subject: mesa: fix vertex format/attribute bug If the tnl output attributes matches the swsetup input attributes we still need to check if the desired vertex color type (float vs. chan) has changed so that we use the right emit functions. Fixes a conformance failure found with logicop test at pathlevel 3. --- src/mesa/swrast_setup/ss_context.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index f4d90c514bb..61172f9979b 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -112,22 +112,25 @@ setup_vertex_format(GLcontext *ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); SScontext *swsetup = SWSETUP_CONTEXT(ctx); + GLboolean intColors = !ctx->FragmentProgram._Current + && !ctx->ATIFragmentShader._Enabled + && ctx->RenderMode == GL_RENDER + && CHAN_TYPE == GL_UNSIGNED_BYTE; - if (!RENDERINPUTS_EQUAL(tnl->render_inputs_bitset, + if (intColors != swsetup->intColors || + !RENDERINPUTS_EQUAL(tnl->render_inputs_bitset, swsetup->last_index_bitset)) { DECLARE_RENDERINPUTS(index_bitset); struct tnl_attr_map map[_TNL_ATTRIB_MAX]; int i, e = 0; + swsetup->intColors = intColors; + RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] ); if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) { - swsetup->intColors = !ctx->FragmentProgram._Current - && !ctx->ATIFragmentShader._Enabled - && ctx->RenderMode == GL_RENDER - && CHAN_TYPE == GL_UNSIGNED_BYTE; if (swsetup->intColors) EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); else -- cgit v1.2.3 From a71b1af5ad7859d00f88b554ed3514561c245e0a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 8 Oct 2008 09:33:27 -0600 Subject: mesa: vertex emit debug code (disabled) --- src/mesa/tnl/t_vertex_generic.c | 80 +++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 22 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/tnl/t_vertex_generic.c b/src/mesa/tnl/t_vertex_generic.c index db70ad4dad5..f763522f91f 100644 --- a/src/mesa/tnl/t_vertex_generic.c +++ b/src/mesa/tnl/t_vertex_generic.c @@ -34,6 +34,12 @@ #include "t_vertex.h" +#if 0 +#define DEBUG_INSERT printf("%s\n", __FUNCTION__) +#else +#define DEBUG_INSERT +#endif + /* * These functions take the NDC coordinates pointed to by 'in', apply the @@ -45,7 +51,7 @@ static INLINE void insert_4f_viewport_4( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[5] * in[1] + vp[13]; out[2] = vp[10] * in[2] + vp[14]; @@ -57,7 +63,7 @@ static INLINE void insert_4f_viewport_3( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[5] * in[1] + vp[13]; out[2] = vp[10] * in[2] + vp[14]; @@ -69,7 +75,7 @@ static INLINE void insert_4f_viewport_2( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[5] * in[1] + vp[13]; out[2] = vp[14]; @@ -81,7 +87,7 @@ static INLINE void insert_4f_viewport_1( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[13]; out[2] = vp[14]; @@ -93,7 +99,7 @@ static INLINE void insert_3f_viewport_3( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[5] * in[1] + vp[13]; out[2] = vp[10] * in[2] + vp[14]; @@ -104,7 +110,7 @@ static INLINE void insert_3f_viewport_2( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[5] * in[1] + vp[13]; out[2] = vp[10] * in[2] + vp[14]; @@ -115,7 +121,7 @@ static INLINE void insert_3f_viewport_1( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[13]; out[2] = vp[14]; @@ -126,7 +132,7 @@ static INLINE void insert_2f_viewport_2( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[5] * in[1] + vp[13]; } @@ -136,7 +142,7 @@ static INLINE void insert_2f_viewport_1( const struct tnl_clipspace_attr *a, GLu { GLfloat *out = (GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = vp[0] * in[0] + vp[12]; out[1] = vp[13]; } @@ -150,7 +156,7 @@ static INLINE void insert_4f_4( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; out[2] = in[2]; @@ -161,7 +167,7 @@ static INLINE void insert_4f_3( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; out[2] = in[2]; @@ -172,7 +178,7 @@ static INLINE void insert_4f_2( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; out[2] = 0; @@ -183,7 +189,7 @@ static INLINE void insert_4f_1( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = 0; out[2] = 0; @@ -194,7 +200,7 @@ static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; out[2] = in[3]; @@ -203,6 +209,7 @@ static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { (void) a; (void) v; (void) in; + DEBUG_INSERT; _mesa_exit(1); } @@ -210,7 +217,7 @@ static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; out[2] = in[2]; @@ -220,7 +227,7 @@ static INLINE void insert_3f_2( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; out[2] = 0; @@ -230,7 +237,7 @@ static INLINE void insert_3f_1( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = 0; out[2] = 0; @@ -241,7 +248,7 @@ static INLINE void insert_2f_2( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = in[1]; } @@ -250,7 +257,7 @@ static INLINE void insert_2f_1( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; out[1] = 0; } @@ -259,12 +266,13 @@ static INLINE void insert_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, { GLfloat *out = (GLfloat *)(v); (void) a; - + DEBUG_INSERT; out[0] = in[0]; } static INLINE void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; (void) v; (void) in; } @@ -272,6 +280,7 @@ static INLINE void insert_4chan_4f_rgba_4( const struct tnl_clipspace_attr *a, G const GLfloat *in ) { GLchan *c = (GLchan *)v; + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); @@ -283,6 +292,7 @@ static INLINE void insert_4chan_4f_rgba_3( const struct tnl_clipspace_attr *a, G const GLfloat *in ) { GLchan *c = (GLchan *)v; + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); @@ -294,6 +304,7 @@ static INLINE void insert_4chan_4f_rgba_2( const struct tnl_clipspace_attr *a, G const GLfloat *in ) { GLchan *c = (GLchan *)v; + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); @@ -305,6 +316,7 @@ static INLINE void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, G const GLfloat *in ) { GLchan *c = (GLchan *)v; + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); c[1] = 0; @@ -315,6 +327,7 @@ static INLINE void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, G static INLINE void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -325,6 +338,7 @@ static INLINE void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -335,6 +349,7 @@ static INLINE void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -345,6 +360,7 @@ static INLINE void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); v[1] = 0; @@ -355,6 +371,7 @@ static INLINE void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -365,6 +382,7 @@ static INLINE void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -375,6 +393,7 @@ static INLINE void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -385,6 +404,7 @@ static INLINE void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); v[1] = 0; @@ -395,6 +415,7 @@ static INLINE void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); @@ -405,6 +426,7 @@ static INLINE void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); @@ -415,6 +437,7 @@ static INLINE void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); @@ -425,6 +448,7 @@ static INLINE void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]); v[2] = 0x00; @@ -435,6 +459,7 @@ static INLINE void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); @@ -445,6 +470,7 @@ static INLINE void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); @@ -455,6 +481,7 @@ static INLINE void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]); @@ -465,6 +492,7 @@ static INLINE void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]); v[2] = 0x00; @@ -475,6 +503,7 @@ static INLINE void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLu static INLINE void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -484,6 +513,7 @@ static INLINE void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLub static INLINE void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -493,6 +523,7 @@ static INLINE void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLub static INLINE void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); v[1] = 0; @@ -502,6 +533,7 @@ static INLINE void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLub static INLINE void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -511,6 +543,7 @@ static INLINE void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLub static INLINE void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]); @@ -520,6 +553,7 @@ static INLINE void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLub static INLINE void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]); v[1] = 0; @@ -530,6 +564,7 @@ static INLINE void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLub static INLINE void insert_1ub_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) { + DEBUG_INSERT; (void) a; UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]); } @@ -551,6 +586,7 @@ static void extract_4f_viewport( const struct tnl_clipspace_attr *a, GLfloat *ou /* Although included for completeness, the position coordinate is * usually handled differently during clipping. */ + DEBUG_INSERT; out[0] = (in[0] - vp[12]) / vp[0]; out[1] = (in[1] - vp[13]) / vp[5]; out[2] = (in[2] - vp[14]) / vp[10]; @@ -562,7 +598,7 @@ static void extract_3f_viewport( const struct tnl_clipspace_attr *a, GLfloat *ou { const GLfloat *in = (const GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = (in[0] - vp[12]) / vp[0]; out[1] = (in[1] - vp[13]) / vp[5]; out[2] = (in[2] - vp[14]) / vp[10]; @@ -575,7 +611,7 @@ static void extract_2f_viewport( const struct tnl_clipspace_attr *a, GLfloat *ou { const GLfloat *in = (const GLfloat *)v; const GLfloat * const vp = a->vp; - + DEBUG_INSERT; out[0] = (in[0] - vp[12]) / vp[0]; out[1] = (in[1] - vp[13]) / vp[5]; out[2] = 0; -- cgit v1.2.3 From 5c4bd76cb65245467d4ba04e893157055d738b2d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 8 Oct 2008 14:02:24 -0600 Subject: mesa: in _mesa_combine_programs() take new STATE_CURRENT_ATTRIB color into account Commit 1680ef869625dc1fe9cf481b180382a34e0738e7 changed the texenv program to get color from a state register instead of a constant-valued vertex attribute. This broke program concatenation (so glDraw/CopyPixels broke). Now check if the second program get's color from a constant register and handle that case appropriately. --- src/mesa/shader/program.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index b03dd24d112..723c46ee8cf 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -594,17 +594,47 @@ _mesa_combine_programs(GLcontext *ctx, if (newProg->Target == GL_FRAGMENT_PROGRAM_ARB) { struct gl_fragment_program *fprogA, *fprogB, *newFprog; + GLbitfield progB_inputsRead = progB->InputsRead; + GLint progB_colorFile, progB_colorIndex; + fprogA = (struct gl_fragment_program *) progA; fprogB = (struct gl_fragment_program *) progB; newFprog = (struct gl_fragment_program *) newProg; newFprog->UsesKill = fprogA->UsesKill || fprogB->UsesKill; + /* We'll do a search and replace for instances + * of progB_colorFile/progB_colorIndex below... + */ + progB_colorFile = PROGRAM_INPUT; + progB_colorIndex = FRAG_ATTRIB_COL0; + + /* + * The fragment program may get color from a state var rather than + * a fragment input (vertex output) if it's constant. + * See the texenvprogram.c code. + * So, search the program's parameter list now to see if the program + * gets color from a state var instead of a conventional fragment + * input register. + */ + for (i = 0; i < progB->Parameters->NumParameters; i++) { + struct gl_program_parameter *p = &progB->Parameters->Parameters[i]; + if (p->Type == PROGRAM_STATE_VAR && + p->StateIndexes[0] == STATE_INTERNAL && + p->StateIndexes[1] == STATE_CURRENT_ATTRIB && + p->StateIndexes[2] == VERT_ATTRIB_COLOR0) { + progB_inputsRead |= FRAG_BIT_COL0; + progB_colorFile = PROGRAM_STATE_VAR; + progB_colorIndex = i; + break; + } + } + /* Connect color outputs of fprogA to color inputs of fprogB, via a * new temporary register. */ if ((progA->OutputsWritten & (1 << FRAG_RESULT_COLR)) && - (progB->InputsRead & (1 << FRAG_ATTRIB_COL0))) { + (progB_inputsRead & FRAG_BIT_COL0)) { GLint tempReg = _mesa_find_free_register(newProg, PROGRAM_TEMPORARY); if (tempReg < 0) { _mesa_problem(ctx, "No free temp regs found in " @@ -615,13 +645,14 @@ _mesa_combine_programs(GLcontext *ctx, replace_registers(newInst, lenA, PROGRAM_OUTPUT, FRAG_RESULT_COLR, PROGRAM_TEMPORARY, tempReg); - /* replace reads from input.color[0] with tempReg */ + /* replace reads from the input color with tempReg */ replace_registers(newInst + lenA, lenB, - PROGRAM_INPUT, FRAG_ATTRIB_COL0, - PROGRAM_TEMPORARY, tempReg); + progB_colorFile, progB_colorIndex, /* search for */ + PROGRAM_TEMPORARY, tempReg /* replace with */ ); } - inputsB = progB->InputsRead; + /* compute combined program's InputsRead */ + inputsB = progB_inputsRead; if (progA->OutputsWritten & (1 << FRAG_RESULT_COLR)) { inputsB &= ~(1 << FRAG_ATTRIB_COL0); } -- cgit v1.2.3 From 9aec1288eeae8e87adc9a99f377be536892941b2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 8 Oct 2008 23:34:38 -0700 Subject: i915: Accelerate depth textures with border color. The fallback was introduced to fix bug #16697, but made the test it was fixing run excessively long. --- src/mesa/drivers/dri/i915/i915_texstate.c | 19 +++++++++++++++---- src/mesa/drivers/dri/intel/intel_tex_validate.c | 5 +---- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index ae42b102db8..d1b0dcdf319 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -307,10 +307,21 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) } - state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0], - tObj->_BorderChan[1], - tObj->_BorderChan[2], - tObj->_BorderChan[3]); + if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) { + /* GL specs that border color for depth textures is taken from the + * R channel, while the hardware uses A. Spam R into all the channels + * for safety. + */ + state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0], + tObj->_BorderChan[0], + tObj->_BorderChan[0], + tObj->_BorderChan[0]); + } else { + state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0], + tObj->_BorderChan[1], + tObj->_BorderChan[2], + tObj->_BorderChan[3]); + } I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(unit), GL_TRUE); diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index 3dae738ac2e..820683d42eb 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -141,10 +141,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) /* Fallback case: */ - if (firstImage->base.Border || - ((firstImage->base._BaseFormat == GL_DEPTH_COMPONENT) && - ((tObj->WrapS == GL_CLAMP_TO_BORDER) || - (tObj->WrapT == GL_CLAMP_TO_BORDER)))) { + if (firstImage->base.Border) { if (intelObj->mt) { intel_miptree_release(intel, &intelObj->mt); } -- cgit v1.2.3 From 91221483a633d6230a4f8d2500ed180428754215 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 9 Oct 2008 10:23:47 -0700 Subject: i965: Actually hook up the accelerated DrawPixels support. --- src/mesa/drivers/dri/i965/Makefile | 3 ++- src/mesa/drivers/dri/intel/intel_pixel.c | 2 +- src/mesa/drivers/dri/intel/intel_pixel_draw.c | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 7bc16a02c8c..005460f3547 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -18,8 +18,9 @@ DRIVER_SOURCES = \ intel_screen.c \ intel_span.c \ intel_pixel.c \ - intel_pixel_copy.c \ intel_pixel_bitmap.c \ + intel_pixel_copy.c \ + intel_pixel_draw.c \ intel_state.c \ intel_tex.c \ intel_tex_copy.c \ diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c index f39fac13cf5..b267ffd890c 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel.c +++ b/src/mesa/drivers/dri/intel/intel_pixel.c @@ -181,9 +181,9 @@ intelInitPixelFuncs(struct dd_function_table *functions) if (!getenv("INTEL_NO_BLIT")) { functions->Bitmap = intelBitmap; functions->CopyPixels = intelCopyPixels; + functions->DrawPixels = intelDrawPixels; #ifdef I915 functions->ReadPixels = intelReadPixels; - functions->DrawPixels = intelDrawPixels; #endif } } diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index be213e7b961..b60dad74601 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -51,7 +51,6 @@ #include "intel_regions.h" #include "intel_pixel.h" #include "intel_buffer_objects.h" -#include "intel_tris.h" static GLboolean -- cgit v1.2.3 From 7216679c1998b49ff5b08e6b43f8d5779415bf54 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 9 Oct 2008 11:45:58 -0700 Subject: i965: Accelerate depth textures with border color. The fallback was introduced to fix bug #16697, but made the test it was fixing run excessively long. --- src/mesa/drivers/dri/i965/brw_fallback.c | 5 +---- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c index 2f6b7febbde..4ea660a51a3 100644 --- a/src/mesa/drivers/dri/i965/brw_fallback.c +++ b/src/mesa/drivers/dri/i965/brw_fallback.c @@ -74,10 +74,7 @@ static GLboolean do_check_fallback(struct brw_context *brw) if (texUnit->_ReallyEnabled) { struct intel_texture_object *intelObj = intel_texture_object(texUnit->_Current); struct gl_texture_image *texImage = intelObj->base.Image[0][intelObj->firstLevel]; - if (texImage->Border || - ((texImage->_BaseFormat == GL_DEPTH_COMPONENT) && - ((texImage->TexObject->WrapS == GL_CLAMP_TO_BORDER) || - (texImage->TexObject->WrapT == GL_CLAMP_TO_BORDER)))) { + if (texImage->Border) { DBG("FALLBACK: texture border\n"); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 977b90ad43e..f12ef47a7d7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -229,6 +229,9 @@ brw_wm_sampler_populate_key(struct brw_context *brw, struct wm_sampler_entry *entry = &key->sampler[unit]; struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[unit]; struct gl_texture_object *texObj = texUnit->_Current; + struct intel_texture_object *intelObj = intel_texture_object(texObj); + struct gl_texture_image *firstImage = + texObj->Image[0][intelObj->firstLevel]; entry->wrap_r = texObj->WrapR; entry->wrap_s = texObj->WrapS; @@ -244,8 +247,22 @@ brw_wm_sampler_populate_key(struct brw_context *brw, entry->comparefunc = texObj->CompareFunc; dri_bo_unreference(brw->wm.sdc_bo[unit]); - brw->wm.sdc_bo[unit] = upload_default_color(brw, texObj->BorderColor); - + if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) { + float bordercolor[4] = { + texObj->BorderColor[0], + texObj->BorderColor[0], + texObj->BorderColor[0], + texObj->BorderColor[0] + }; + /* GL specs that border color for depth textures is taken from the + * R channel, while the hardware uses A. Spam R into all the + * channels for safety. + */ + brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor); + } else { + brw->wm.sdc_bo[unit] = upload_default_color(brw, + texObj->BorderColor); + } key->sampler_count = unit + 1; } } -- cgit v1.2.3 From f7556fdd40ed2719beaba271eee4a7551e212ad1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 9 Oct 2008 16:39:59 -0600 Subject: mesa: rasterizer state depends on ST_NEW_VERTEX_PROGRAM Check for per-vertex point size must be done when vertex program changes. --- src/mesa/state_tracker/st_atom_rasterizer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index fc47896c242..5eef4ebe92e 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -215,6 +215,9 @@ static void update_raster_state( struct st_context *st ) raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; } } + + /* ST_NEW_VERTEX_PROGRAM + */ if (vertProg) { if (vertProg->Base.Id == 0) { if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { @@ -277,7 +280,7 @@ const struct st_tracked_state st_update_rasterizer = { _NEW_POLYGON | _NEW_PROGRAM | _NEW_SCISSOR), /* mesa state dependencies*/ - 0, /* state tracker dependencies */ + ST_NEW_VERTEX_PROGRAM, /* state tracker dependencies */ }, update_raster_state /* update function */ }; -- cgit v1.2.3 From 5e9cb42aa662022c63563b4bc7f9e1d99f6d81ee Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 10 Oct 2008 09:43:15 -0700 Subject: i965: Add missing intel_pixel_draw.c symlink to fix build. --- src/mesa/drivers/dri/i965/intel_pixel_draw.c | 1 + 1 file changed, 1 insertion(+) create mode 120000 src/mesa/drivers/dri/i965/intel_pixel_draw.c (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_pixel_draw.c b/src/mesa/drivers/dri/i965/intel_pixel_draw.c new file mode 120000 index 00000000000..8431a24edfc --- /dev/null +++ b/src/mesa/drivers/dri/i965/intel_pixel_draw.c @@ -0,0 +1 @@ +../intel/intel_pixel_draw.c \ No newline at end of file -- cgit v1.2.3 From e7002694418cd0decb1cd0d9121f634480e5f0d6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 10 Oct 2008 11:47:43 -0700 Subject: intel: GLSL 1.20 is broken in Mesa, so disable it in the i965 driver --- src/mesa/drivers/dri/intel/intel_context.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index e6c0d3175e4..2b3a9b9d371 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -398,7 +398,11 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_point_sprite", NULL }, { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions }, { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, +#if 0 + /* Support for GLSL 1.20 is currently broken in core Mesa. + */ { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, +#endif { "GL_ARB_shadow", NULL }, { "GL_ARB_texture_non_power_of_two", NULL }, { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, -- cgit v1.2.3 From f63594bfef883fa9e15ab7f3f69affe4901353aa Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 10 Oct 2008 16:21:52 -0600 Subject: mesa: remove unneeded includes --- src/mesa/main/api_loopback.c | 1 - src/mesa/main/dlist.c | 1 - 2 files changed, 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c index 924d7134a27..0e3f5ff9570 100644 --- a/src/mesa/main/api_loopback.c +++ b/src/mesa/main/api_loopback.c @@ -31,7 +31,6 @@ #include "glheader.h" #include "macros.h" -#include "colormac.h" #include "api_loopback.h" #include "mtypes.h" #include "glapi/glapi.h" diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index f7660930a9c..c7db435506e 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -41,7 +41,6 @@ #endif #include "arrayobj.h" #include "clip.h" -#include "colormac.h" #include "colortab.h" #include "context.h" #include "convolve.h" -- cgit v1.2.3 From 3210a6d6c7e3d5660d31f6c736e0d0f7e34bcf6d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 10 Oct 2008 16:23:31 -0600 Subject: mesa: rename macro params to emphasize that there's no particular color ordering --- src/mesa/main/colormac.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h index a19521fc85b..a34bd2ed388 100644 --- a/src/mesa/main/colormac.h +++ b/src/mesa/main/colormac.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.3 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -180,20 +180,20 @@ do { \ */ /*@{*/ -#define PACK_COLOR_8888( R, G, B, A ) \ - (((R) << 24) | ((G) << 16) | ((B) << 8) | (A)) +#define PACK_COLOR_8888( X, Y, Z, W ) \ + (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W)) -#define PACK_COLOR_8888_REV( R, G, B, A ) \ - (((A) << 24) | ((B) << 16) | ((G) << 8) | (R)) +#define PACK_COLOR_8888_REV( X, Y, Z, W ) \ + (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X)) -#define PACK_COLOR_888( R, G, B ) \ - (((R) << 16) | ((G) << 8) | (B)) +#define PACK_COLOR_888( X, Y, Z ) \ + (((X) << 16) | ((Y) << 8) | (Z)) -#define PACK_COLOR_565( R, G, B ) \ - ((((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | (((B) & 0xf8) >> 3)) +#define PACK_COLOR_565( X, Y, Z ) \ + ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3)) -#define PACK_COLOR_565_REV( R, G, B ) \ - (((R) & 0xf8) | ((G) & 0xe0) >> 5 | (((G) & 0x1c) << 11) | (((B) & 0xf8) << 5)) +#define PACK_COLOR_565_REV( X, Y, Z ) \ + (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5)) #define PACK_COLOR_1555( A, B, G, R ) \ ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ -- cgit v1.2.3 From 85a3bf6dabc8b2d545dab078516fdfee9c4cd792 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 10 Oct 2008 16:26:15 -0600 Subject: mesa: fix error codes in _mesa_GetObjectParameterivARB(), bug 17861 --- src/mesa/main/shaders.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index aeb5d4ca2ab..e5c54bb10d7 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -247,7 +247,18 @@ _mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) } } else { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB"); + /* error code depends on pname */ + GLenum err; + switch (pname) { + case GL_OBJECT_TYPE_ARB: + case GL_OBJECT_DELETE_STATUS_ARB: + case GL_OBJECT_INFO_LOG_LENGTH_ARB: + err = GL_INVALID_OPERATION; + break; + default: + err = GL_INVALID_VALUE; + } + _mesa_error(ctx, err, "glGetObjectParameterivARB"); } } -- cgit v1.2.3 From f863ae1a040c358728d8608531ae3eb695f3af9e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 10 Oct 2008 16:29:54 -0600 Subject: mesa: remove unneeded includes --- src/mesa/main/blend.c | 1 - src/mesa/main/getstring.c | 1 - 2 files changed, 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 4d4a8971419..39cf6153e28 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -31,7 +31,6 @@ #include "glheader.h" #include "blend.h" -#include "colormac.h" #include "context.h" #include "enums.h" #include "macros.h" diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 1a82ccce59a..94bf5de1e8b 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -25,7 +25,6 @@ #include "glheader.h" -#include "colormac.h" #include "context.h" #include "get.h" #include "version.h" -- cgit v1.2.3 From bf9d9a9d01b7697f4a30305cb9574430cba351fa Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 10 Oct 2008 16:30:18 -0600 Subject: mesa: include needed header --- src/mesa/swrast/s_texcombine.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa') diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index 4e3d329075c..632d650007e 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -26,6 +26,7 @@ #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" +#include "main/image.h" #include "main/imports.h" #include "main/macros.h" #include "main/pixel.h" -- cgit v1.2.3 From 24748268a3ac7bedc2c9ae5bf76c4c741d539f80 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 10 Oct 2008 16:30:43 -0600 Subject: mesa: fix asst. issues in _mesa_texstore_argb8888() If we shift bytes into the texel word (or use the PACK_COLOR_8888 macro), we don't have to worry about big vs. little endian. See comments about texel formats in texformat.h. Remove an unneeded/incorrect else-if clause that produced wrong results on big-endian systems. --- src/mesa/main/texstore.c | 50 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 56f5b2ebaa1..75b14c2bf06 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.3 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * @@ -1536,10 +1536,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLuint *d4 = (GLuint *) dstRow; for (col = 0; col < srcWidth; col++) { - d4[col] = ((0xff << 24) | - (srcRow[col * 3 + RCOMP] << 16) | - (srcRow[col * 3 + GCOMP] << 8) | - (srcRow[col * 3 + BCOMP] << 0)); + d4[col] = PACK_COLOR_8888(0xff, + srcRow[col * 3 + RCOMP], + srcRow[col * 3 + GCOMP], + srcRow[col * 3 + BCOMP]); } dstRow += dstRowStride; srcRow += srcRowStride; @@ -1551,8 +1551,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) dstFormat == &_mesa_texformat_argb8888 && srcFormat == GL_RGBA && baseInternalFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { + srcType == GL_UNSIGNED_BYTE) { /* same as above case, but src data has alpha too */ GLint img, row, col; /* For some reason, streaming copies to write-combined regions @@ -1573,39 +1572,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLuint *d4 = (GLuint *) dstRow; for (col = 0; col < srcWidth; col++) { - d4[col] = ((srcRow[col * 4 + ACOMP] << 24) | - (srcRow[col * 4 + RCOMP] << 16) | - (srcRow[col * 4 + GCOMP] << 8) | - (srcRow[col * 4 + BCOMP] << 0)); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == &_mesa_texformat_argb8888 && - srcFormat == GL_RGBA && - baseInternalFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - - GLint img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, - srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes - + dstYoffset * dstRowStride - + dstXoffset * dstFormat->TexelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 4 + 0] = srcRow[col * 4 + BCOMP]; - dstRow[col * 4 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 4 + 2] = srcRow[col * 4 + RCOMP]; - dstRow[col * 4 + 3] = srcRow[col * 4 + ACOMP]; + d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], + srcRow[col * 4 + RCOMP], + srcRow[col * 4 + GCOMP], + srcRow[col * 4 + BCOMP]); } dstRow += dstRowStride; srcRow += srcRowStride; -- cgit v1.2.3 From c011a9ca8c83f27eb2c9198f9b4a95ccbf9accf9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 10 Oct 2008 09:43:15 -0700 Subject: i965: Add missing intel_pixel_draw.c symlink to fix build. --- src/mesa/drivers/dri/i965/intel_pixel_draw.c | 1 + 1 file changed, 1 insertion(+) create mode 120000 src/mesa/drivers/dri/i965/intel_pixel_draw.c (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/intel_pixel_draw.c b/src/mesa/drivers/dri/i965/intel_pixel_draw.c new file mode 120000 index 00000000000..8431a24edfc --- /dev/null +++ b/src/mesa/drivers/dri/i965/intel_pixel_draw.c @@ -0,0 +1 @@ +../intel/intel_pixel_draw.c \ No newline at end of file -- cgit v1.2.3 From 33ff407874d6fed998b1f01dab68a2b4f1df988a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 10 Oct 2008 11:47:43 -0700 Subject: intel: GLSL 1.20 is broken in Mesa, so disable it in the i965 driver --- src/mesa/drivers/dri/intel/intel_context.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index e6c0d3175e4..2b3a9b9d371 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -398,7 +398,11 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_point_sprite", NULL }, { "GL_ARB_shader_objects", GL_ARB_shader_objects_functions }, { "GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, +#if 0 + /* Support for GLSL 1.20 is currently broken in core Mesa. + */ { "GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, +#endif { "GL_ARB_shadow", NULL }, { "GL_ARB_texture_non_power_of_two", NULL }, { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, -- cgit v1.2.3 From 5bc8ebb12be99ac769a0f2ad1f77a16ebb2bf41f Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Mon, 13 Oct 2008 12:30:40 +0100 Subject: mesa: when emitting an address load instruction, for indexed elements ensure we write to a single register. --- src/mesa/shader/slang/slang_emit.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 9e8daa10517..f3c3fa6c5b3 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -1579,13 +1579,17 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n) else { /* Variable array index */ struct prog_instruction *inst; + slang_ir_storage dstStore = *n->Store; /* do codegen for array index expression */ emit(emitInfo, n->Children[1]); inst = new_instruction(emitInfo, OPCODE_ARL); - storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask); + if (dstStore.Size > 4) + dstStore.Size = 4; /* only emit one instruction */ + + storage_to_dst_reg(&inst->DstReg, &dstStore, n->Writemask); storage_to_src_reg(&inst->SrcReg[0], n->Children[1]->Store); inst->DstReg.File = PROGRAM_ADDRESS; -- cgit v1.2.3 From 5d4f3b841753e16fbb33e444b6a787663e54fce5 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 14 Oct 2008 11:54:20 +0100 Subject: dri: don't check the number of cliprects before swap, let the swap handle the requirements. --- src/mesa/drivers/dri/common/dri_util.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index ceedd914fb3..a16cb504c73 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -315,9 +315,6 @@ static void driSwapBuffers(__DRIdrawable *dPriv) { __DRIscreen *psp = dPriv->driScreenPriv; - if (!dPriv->numClipRects) - return; - psp->DriverAPI.SwapBuffers(dPriv); driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects); -- cgit v1.2.3