From: Ben Skeggs Date: Sat, 27 Jan 2007 07:36:01 +0000 (+1100) Subject: nouveau: maintain a map of which vtxprog input corresponds to which array X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cafbc459f51ce6645e1fc4b6b2b7ec34efedd874;p=mesa.git nouveau: maintain a map of which vtxprog input corresponds to which array --- diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.h b/src/mesa/drivers/dri/nouveau/nouveau_shader.h index 82eb27b053e..e2515c1c79a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.h @@ -55,6 +55,7 @@ typedef struct _nouveauShader { int inst_count; nvsCardPriv card_priv; + int vp_attrib_map[NVS_MAX_ATTRIBS]; struct { GLfloat *source_val; /* NULL if invariant */ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c index 3bcc2ba755c..81ed012c783 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c @@ -787,6 +787,50 @@ pass0_translate_instructions(nouveauShader *nvs, int ipos, int fpos, return GL_TRUE; } +static void +pass0_build_attrib_map(nouveauShader *nvs, struct gl_vertex_program *vp) +{ + GLuint inputs_read = vp->Base.InputsRead; + GLuint input_alloc = ~0xFFFF; + int i; + + for (i=0; ivp_attrib_map[i] = -1; + + while (inputs_read) { + int in = ffs(inputs_read) - 1; + int hw; + inputs_read &= ~(1<IsNVProgram) { + /* NVvp: must alias */ + if (in >= VERT_ATTRIB_GENERIC0) + hw = in - VERT_ATTRIB_GENERIC0; + else + hw = in; + } else { + /* ARBvp: may alias + * GL2.0: must not alias + */ + if (in >= VERT_ATTRIB_GENERIC0) + hw = ffs(~input_alloc) - 1; + else + hw = in; + input_alloc |= (1<vp_attrib_map[hw] = in; + } + + if (NOUVEAU_DEBUG & DEBUG_SHADERS) { + printf("vtxprog attrib map:\n"); + for (i=0; ivp_attrib_map[i]); + } + } +} + GLboolean nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs) { @@ -801,6 +845,8 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs) case GL_VERTEX_PROGRAM_ARB: nvs->func = &nmesa->VPfunc; + pass0_build_attrib_map(nvs, vp); + if (vp->IsPositionInvariant) _mesa_insert_mvp_code(ctx, vp); #if 0