X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fffvertex_prog.c;h=43325b13529be1927e211449aa0f542cabb2422e;hb=0491142152dcc61ebe0b46b05c94957e54c44bd9;hp=e6c7c1040faf4c2e32d34975f841ea6374ac1f22;hpb=aa3ab377e6e2e5811cdd704d87c3e24acb5eff72;p=mesa.git
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index e6c7c1040fa..43325b13529 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -26,7 +26,7 @@
**************************************************************************/
/**
- * \file ffvertex_prog.
+ * \file ffvertex_prog.c
*
* Create a vertex program to execute the current fixed function T&L pipeline.
* \author Keith Whitwell
@@ -47,25 +47,28 @@
struct state_key {
+ unsigned light_color_material_mask:12;
+ unsigned light_material_mask:12;
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 material_shininess_is_zero:1;
-
unsigned need_eye_coords:1;
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_mode:2;
unsigned point_attenuated:1;
+ unsigned point_array:1;
unsigned texture_enabled_global:1;
unsigned fragprog_inputs_read:12;
+ unsigned varying_vp_inputs;
+
struct {
unsigned light_enabled:1;
unsigned light_eyepos3_is_zero:1;
@@ -98,6 +101,7 @@ static GLuint translate_fog_mode( GLenum mode )
}
}
+
#define TXG_NONE 0
#define TXG_OBJ_LINEAR 1
#define TXG_EYE_LINEAR 2
@@ -142,6 +146,7 @@ tnl_get_per_vertex_materials(GLcontext *ctx)
return mask;
}
+
/**
* Should fog be computed per-vertex?
*/
@@ -156,6 +161,7 @@ tnl_get_per_vertex_fog(GLcontext *ctx)
#endif
}
+
static GLboolean check_active_shininess( GLcontext *ctx,
const struct state_key *key,
GLuint side )
@@ -173,16 +179,14 @@ static GLboolean check_active_shininess( GLcontext *ctx,
return GL_FALSE;
}
-
-
-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:
@@ -192,6 +196,7 @@ static struct state_key *make_state_key( GLcontext *ctx )
key->need_eye_coords = ctx->_NeedEyeCoords;
key->fragprog_inputs_read = fp->Base.InputsRead;
+ key->varying_vp_inputs = ctx->varying_vp_inputs;
if (ctx->RenderMode == GL_FEEDBACK) {
/* make sure the vertprog emits color and tex0 */
@@ -264,12 +269,17 @@ static struct state_key *make_state_key( GLcontext *ctx )
if (ctx->Point._Attenuated)
key->point_attenuated = 1;
+#if FEATURE_point_size_array
+ if (ctx->Array.ArrayObj->PointSize.Enabled)
+ key->point_array = 1;
+#endif
+
if (ctx->Texture._TexGenEnabled ||
ctx->Texture._TexMatEnabled ||
ctx->Texture._EnabledUnits)
key->texture_enabled_global = 1;
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
if (texUnit->_ReallyEnabled)
@@ -283,20 +293,18 @@ static struct state_key *make_state_key( GLcontext *ctx )
key->unit[i].texgen_mode0 =
translate_texgen( texUnit->TexGenEnabled & (1<<0),
- texUnit->GenModeS );
+ texUnit->GenS.Mode );
key->unit[i].texgen_mode1 =
translate_texgen( texUnit->TexGenEnabled & (1<<1),
- texUnit->GenModeT );
+ texUnit->GenT.Mode );
key->unit[i].texgen_mode2 =
translate_texgen( texUnit->TexGenEnabled & (1<<2),
- texUnit->GenModeR );
+ texUnit->GenR.Mode );
key->unit[i].texgen_mode3 =
translate_texgen( texUnit->TexGenEnabled & (1<<3),
- texUnit->GenModeQ );
+ texUnit->GenQ.Mode );
}
}
-
- return key;
}
@@ -307,13 +315,6 @@ static struct state_key *make_state_key( GLcontext *ctx )
*/
#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 0
-
-#define MAX_INSN 256
/* Use uregs to represent registers internally, translate to Mesa's
* expected formats on emit.
@@ -329,16 +330,19 @@ static struct state_key *make_state_key( GLcontext *ctx )
*/
struct ureg {
GLuint file:4;
- GLint idx:8; /* relative addressing may be negative */
+ GLint idx:9; /* relative addressing may be negative */
+ /* sizeof(idx) should == sizeof(prog_src_reg::Index) */
GLuint negate:1;
GLuint swz:12;
- GLuint pad:7;
+ GLuint pad:6;
};
struct tnl_program {
const struct state_key *state;
struct gl_vertex_program *program;
+ GLint max_inst; /** number of instructions allocated for program */
+ GLboolean mvp_with_dp4;
GLuint temp_in_use;
GLuint temp_reserved;
@@ -354,9 +358,9 @@ struct tnl_program {
};
-static const struct ureg undef = {
+static const struct ureg undef = {
PROGRAM_UNDEFINED,
- ~0,
+ 0,
0,
0,
0
@@ -389,7 +393,7 @@ static struct 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 )
@@ -398,15 +402,16 @@ static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
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 = _mesa_ffs( ~p->temp_in_use );
@@ -422,6 +427,7 @@ static struct ureg get_temp( struct tnl_program *p )
return make_ureg(PROGRAM_TEMPORARY, bit-1);
}
+
static struct ureg reserve_temp( struct tnl_program *p )
{
struct ureg temp = get_temp( p );
@@ -429,6 +435,7 @@ static struct ureg reserve_temp( struct tnl_program *p )
return temp;
}
+
static void release_temp( struct tnl_program *p, struct ureg reg )
{
if (reg.file == PROGRAM_TEMPORARY) {
@@ -443,19 +450,59 @@ static void release_temps( struct tnl_program *p )
}
+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)
+
+
+/**
+ * \param input one of VERT_ATTRIB_x tokens.
+ */
static struct ureg register_input( struct tnl_program *p, GLuint input )
{
- p->program->Base.InputsRead |= (1<= 32
+ */
+ if (input >= 32 || (p->state->varying_vp_inputs & (1<program->Base.InputsRead |= (1<program->Base.OutputsWritten |= (1<