From 50853e295bb4e14f6e206162f9279c37ad1909e6 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 11 Aug 2009 09:42:15 +0200 Subject: [PATCH] wined3d: Make the "texcoord" shader_reg_maps member a bitmap. --- dlls/wined3d/arb_program_shader.c | 12 +++++++----- dlls/wined3d/baseshader.c | 2 +- dlls/wined3d/glsl_shader.c | 15 ++++++--------- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 991fe697fc6..08ca52fea89 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -615,6 +615,7 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s char pshader = shader_is_pshader_version(reg_maps->shader_version.type); unsigned max_constantsF; const local_constant *lconst; + DWORD map; /* In pixel shaders, all private constants are program local, we don't need anything * from program.env. Thus we can advertise the full set of constants in pixel shaders. @@ -668,10 +669,11 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s shader_addline(buffer, "ADDRESS A%d;\n", i); } - if(pshader && reg_maps->shader_version.major == 1 && reg_maps->shader_version.minor <= 3) { - for(i = 0; i < This->baseShader.limits.texcoord; i++) { - if (reg_maps->texcoord[i] && pshader) - shader_addline(buffer,"TEMP T%u;\n", i); + if (pshader && reg_maps->shader_version.major == 1 && reg_maps->shader_version.minor <= 3) + { + for (i = 0, map = reg_maps->texcoord; map; map >>= 1, ++i) + { + if (map & 1) shader_addline(buffer, "TEMP T%u;\n", i); } } @@ -3923,7 +3925,7 @@ static void find_clip_texcoord(IWineD3DPixelShaderImpl *ps) { for(i = GL_LIMITS(texture_stages); i > 0; i--) { - if(!ps->baseShader.reg_maps.texcoord[i - 1]) + if (!(ps->baseShader.reg_maps.texcoord & (1 << (i - 1)))) { shader_priv->clipplane_emulation = i; return; diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index ec05dd9dbac..1669c7c6d1f 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -257,7 +257,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct sh switch (reg->type) { case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */ - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord[reg->idx] = 1; + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx; else reg_maps->address[reg->idx] = 1; break; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 0737c35d56c..3fd92fde0a3 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -814,6 +814,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont const struct wined3d_gl_info *gl_info = context->gl_info; unsigned int i, extra_constants_needed = 0; const local_constant *lconst; + DWORD map; /* There are some minor differences between pixel and vertex shaders */ char pshader = shader_is_pshader_version(reg_maps->shader_version.type); @@ -1009,9 +1010,9 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont } /* Declare texture coordinate temporaries and initialize them */ - for (i = 0; i < This->baseShader.limits.texcoord; i++) { - if (reg_maps->texcoord[i]) - shader_addline(buffer, "vec4 T%u = gl_TexCoord[%u];\n", i, i); + for (i = 0, map = reg_maps->texcoord; map; map >>= 1, ++i) + { + if (map & 1) shader_addline(buffer, "vec4 T%u = gl_TexCoord[%u];\n", i, i); } /* Declare input register varyings. Only pixel shader, vertex shaders have that declared in the @@ -1045,13 +1046,9 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont /* Declare attributes */ if (reg_maps->shader_version.type == WINED3D_SHADER_TYPE_VERTEX) { - WORD map = reg_maps->input_registers; - - for (i = 0; map; map >>= 1, ++i) + for (i = 0, map = reg_maps->input_registers; map; map >>= 1, ++i) { - if (!(map & 1)) continue; - - shader_addline(buffer, "attribute vec4 attrib%i;\n", i); + if (map & 1) shader_addline(buffer, "attribute vec4 attrib%i;\n", i); } } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8b670863b3e..f95adcbda61 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -628,7 +628,7 @@ struct wined3d_shader_version typedef struct shader_reg_maps { struct wined3d_shader_version shader_version; - char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */ + BYTE texcoord; /* MAX_REG_TEXCRD, 8 */ char temporary[MAX_REG_TEMP]; /* pixel, vertex */ char address[MAX_REG_ADDR]; /* vertex */ char labels[MAX_LABELS]; /* pixel, vertex */