X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fffvertex_prog.c;h=34cc9218addd447f46910003f8f37f1fa37288a1;hb=70dff4a55e767de8b9ce10f055b94ebb1f6a9755;hp=08665c6b6f97b9f17974875bca14f3407f20fa2e;hpb=12cbe995edbbf2791459579918486413965d4bf0;p=mesa.git diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 08665c6b6f9..34cc9218add 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2007 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +18,7 @@ * 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. @@ -135,7 +135,7 @@ static GLboolean check_active_shininess( struct gl_context *ctx, (key->light_color_material_mask & (1 << attr))) return GL_TRUE; - if (key->varying_vp_inputs & VERT_ATTRIB_GENERIC(attr)) + if (key->varying_vp_inputs & VERT_BIT_GENERIC(attr)) return GL_TRUE; if (ctx->Light.Material.Attrib[attr][0] != 0.0F) @@ -189,15 +189,15 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key ) if (light->Enabled) { key->unit[i].light_enabled = 1; - if (light->EyePosition[3] == 0.0) + if (light->EyePosition[3] == 0.0F) key->unit[i].light_eyepos3_is_zero = 1; - if (light->SpotCutoff == 180.0) + if (light->SpotCutoff == 180.0F) key->unit[i].light_spotcutoff_is_180 = 1; - if (light->ConstantAttenuation != 1.0 || - light->LinearAttenuation != 0.0 || - light->QuadraticAttenuation != 0.0) + if (light->ConstantAttenuation != 1.0F || + light->LinearAttenuation != 0.0F || + light->QuadraticAttenuation != 0.0F) key->unit[i].light_attenuated = 1; } } @@ -228,18 +228,18 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key ) if (ctx->Point._Attenuated) key->point_attenuated = 1; - if (ctx->Array.ArrayObj->_VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled) + if (ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled) key->point_array = 1; if (ctx->Texture._TexGenEnabled || ctx->Texture._TexMatEnabled || - ctx->Texture._EnabledUnits) + ctx->Texture._MaxEnabledTexImageUnit != -1) key->texture_enabled_global = 1; for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; - if (texUnit->_ReallyEnabled) + if (texUnit->_Current) key->unit[i].texunit_really_enabled = 1; if (ctx->Point.PointSprite) @@ -293,16 +293,17 @@ struct ureg { GLuint file:4; GLint idx:9; /* relative addressing may be negative */ /* sizeof(idx) should == sizeof(prog_src_reg::Index) */ + GLuint abs:1; GLuint negate:1; GLuint swz:12; - GLuint pad:6; + GLuint pad:5; }; struct tnl_program { const struct state_key *state; struct gl_vertex_program *program; - GLint max_inst; /** number of instructions allocated for program */ + GLuint max_inst; /** number of instructions allocated for program */ GLboolean mvp_with_dp4; GLuint temp_in_use; @@ -324,6 +325,7 @@ static const struct ureg undef = { 0, 0, 0, + 0, 0 }; @@ -342,6 +344,7 @@ static struct ureg make_ureg(GLuint file, GLint idx) struct ureg reg; reg.file = file; reg.idx = idx; + reg.abs = 0; reg.negate = 0; reg.swz = SWIZZLE_NOOP; reg.pad = 0; @@ -350,6 +353,14 @@ static struct ureg make_ureg(GLuint file, GLint idx) +static struct ureg absolute( struct ureg reg ) +{ + reg.abs = 1; + reg.negate = 0; + return reg; +} + + static struct ureg negate( struct ureg reg ) { reg.negate ^= 1; @@ -479,7 +490,7 @@ static struct ureg register_const4f( struct tnl_program *p, values[3].f = s3; idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle ); - ASSERT(swizzle == SWIZZLE_NOOP); + assert(swizzle == SWIZZLE_NOOP); return make_ureg(PROGRAM_CONSTANT, idx); } @@ -526,11 +537,11 @@ static void emit_arg( struct prog_src_register *src, src->File = reg.file; src->Index = reg.idx; src->Swizzle = reg.swz; + src->Abs = reg.abs; src->Negate = reg.negate ? NEGATE_XYZW : NEGATE_NONE; - src->Abs = 0; src->RelAddr = 0; /* Check that bitfield sizes aren't exceeded */ - ASSERT(src->Index == reg.idx); + assert(src->Index == reg.idx); } @@ -544,7 +555,7 @@ static void emit_dst( struct prog_dst_register *dst, dst->CondMask = COND_TR; /* always pass cond test */ dst->CondSwizzle = SWIZZLE_NOOP; /* Check that bitfield sizes aren't exceeded */ - ASSERT(dst->Index == reg.idx); + assert(dst->Index == reg.idx); } @@ -578,7 +589,7 @@ static void emit_op3fn(struct tnl_program *p, GLuint nr; struct prog_instruction *inst; - assert((GLint) p->program->Base.NumInstructions <= p->max_inst); + assert(p->program->Base.NumInstructions <= p->max_inst); if (p->program->Base.NumInstructions == p->max_inst) { /* need to extend the program's instruction array */ @@ -619,13 +630,13 @@ static void emit_op3fn(struct tnl_program *p, #define emit_op3(p, op, dst, mask, src0, src1, src2) \ - emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__) + emit_op3fn(p, op, dst, mask, src0, src1, src2, __func__, __LINE__) #define emit_op2(p, op, dst, mask, src0, src1) \ - emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__) + emit_op3fn(p, op, dst, mask, src0, src1, undef, __func__, __LINE__) #define emit_op1(p, op, dst, mask, src0) \ - emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__) + emit_op3fn(p, op, dst, mask, src0, undef, undef, __func__, __LINE__) static struct ureg make_temp( struct tnl_program *p, struct ureg reg ) @@ -953,7 +964,7 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p, emit_op2(p, OPCODE_DP3, spot, 0, 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_POW, spot, 0, absolute(spot), swizzle1(attenuation, W)); emit_op2(p, OPCODE_MUL, att, 0, slt, spot); release_temp(p, spot); @@ -1306,20 +1317,22 @@ static void build_fog( struct tnl_program *p ) switch (p->state->fog_distance_mode) { case FDM_EYE_RADIAL: /* Z = sqrt(Xe*Xe + Ye*Ye + Ze*Ze) */ - input = get_eye_position(p); - emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input); - emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog); - emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog); - break; + input = get_eye_position(p); + emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input); + emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog); + emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog); + break; case FDM_EYE_PLANE: /* Z = Ze */ - input = get_eye_position_z(p); - emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input); - break; + input = get_eye_position_z(p); + emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input); + break; case FDM_EYE_PLANE_ABS: /* Z = abs(Ze) */ - input = get_eye_position_z(p); - emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); - break; - default: assert(0); break; /* can't happen */ + input = get_eye_position_z(p); + emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); + break; + default: + assert(!"Bad fog mode in build_fog()"); + break; } } @@ -1655,7 +1668,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx) struct gl_vertex_program *prog; struct state_key key; - /* Grab all the relevent state and put it in a single structure: + /* Grab all the relevant state and put it in a single structure: */ make_state_key(ctx, &key); @@ -1674,14 +1687,13 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx) return NULL; create_new_program( &key, prog, - ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4, - ctx->Const.VertexProgram.MaxTemps ); + ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS, + ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps ); -#if 0 if (ctx->Driver.ProgramStringNotify) ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, &prog->Base ); -#endif + _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, &key, sizeof(key), &prog->Base); }