wined3d: Make the "bumpmat" shader_reg_maps member a bitmap.

This commit is contained in:
Henri Verbeet 2009-08-12 09:44:25 +02:00 committed by Alexandre Julliard
parent 3d718d6414
commit 95bb4c0486
5 changed files with 16 additions and 13 deletions

View File

@ -3360,8 +3360,9 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
next_local = shader_generate_arb_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, next_local = shader_generate_arb_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION,
lconst_map, NULL, &priv_ctx); lconst_map, NULL, &priv_ctx);
for(i = 0; i < (sizeof(reg_maps->bumpmat) / sizeof(reg_maps->bumpmat[0])); i++) { for (i = 0, map = reg_maps->bumpmat; map; map >>= 1, ++i)
if(!reg_maps->bumpmat[i]) continue; {
if (!(map & 1)) continue;
cur = compiled->numbumpenvmatconsts; cur = compiled->numbumpenvmatconsts;
compiled->bumpenvmatconst[cur].const_num = WINED3D_CONST_NUM_UNUSED; compiled->bumpenvmatconst[cur].const_num = WINED3D_CONST_NUM_UNUSED;
@ -5224,8 +5225,9 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, s
if (use_ps(stateblock)) if (use_ps(stateblock))
{ {
if(stage != 0 && if (stage != 0
((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.bumpmat[stage]) { && (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage)))
{
/* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
* anyway * anyway
*/ */

View File

@ -686,7 +686,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
if (ins.handler_idx == WINED3DSIH_TEXBEM if (ins.handler_idx == WINED3DSIH_TEXBEM
|| ins.handler_idx == WINED3DSIH_TEXBEML) || ins.handler_idx == WINED3DSIH_TEXBEML)
{ {
reg_maps->bumpmat[sampler_code] = TRUE; reg_maps->bumpmat |= 1 << dst_param.reg.idx;
if (ins.handler_idx == WINED3DSIH_TEXBEML) if (ins.handler_idx == WINED3DSIH_TEXBEML)
{ {
reg_maps->luminanceparams[sampler_code] = TRUE; reg_maps->luminanceparams[sampler_code] = TRUE;
@ -695,7 +695,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
} }
else if (ins.handler_idx == WINED3DSIH_BEM) else if (ins.handler_idx == WINED3DSIH_BEM)
{ {
reg_maps->bumpmat[dst_param.reg.idx] = TRUE; reg_maps->bumpmat |= 1 << dst_param.reg.idx;
} }
} }

View File

@ -899,10 +899,9 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
shader_addline(buffer, "void order_ps_input();\n"); shader_addline(buffer, "void order_ps_input();\n");
} }
} else { } else {
for(i = 0; i < (sizeof(reg_maps->bumpmat) / sizeof(reg_maps->bumpmat[0])); i++) { for (i = 0, map = reg_maps->bumpmat; map; map >>= 1, ++i)
if(!reg_maps->bumpmat[i]) { {
continue; if (!(map & 1)) continue;
}
shader_addline(buffer, "uniform mat2 bumpenvmat%d;\n", i); shader_addline(buffer, "uniform mat2 bumpenvmat%d;\n", i);

View File

@ -3529,8 +3529,9 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{ {
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
if(stateblock->pixelShader && stage != 0 && if (stateblock->pixelShader && stage != 0
((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.bumpmat[stage]) { && (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage)))
{
/* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
* anyway * anyway
*/ */

View File

@ -642,7 +642,8 @@ typedef struct shader_reg_maps
WORD local_bool_consts; /* MAX_CONST_B, 16 */ WORD local_bool_consts; /* MAX_CONST_B, 16 */
WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)]; WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
BOOL bumpmat[MAX_TEXTURES], luminanceparams[MAX_TEXTURES]; BYTE bumpmat; /* MAX_TEXTURES, 8 */
BOOL luminanceparams[MAX_TEXTURES];
WORD usesnrm : 1; WORD usesnrm : 1;
WORD vpos : 1; WORD vpos : 1;