wined3d: Pass a struct wined3d_shader_register to shader_record_register_usage().

This commit is contained in:
Henri Verbeet 2009-05-11 16:43:49 +02:00 committed by Alexandre Julliard
parent 2039702035
commit adc9bfe3fd
1 changed files with 33 additions and 42 deletions

View File

@ -246,24 +246,24 @@ static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
}
static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps,
DWORD register_type, UINT register_idx, BOOL has_rel_addr, BOOL pshader)
const struct wined3d_shader_register *reg, BOOL pshader)
{
switch (register_type)
switch (reg->type)
{
case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
if (pshader) reg_maps->texcoord[register_idx] = 1;
else reg_maps->address[register_idx] = 1;
if (pshader) reg_maps->texcoord[reg->idx] = 1;
else reg_maps->address[reg->idx] = 1;
break;
case WINED3DSPR_TEMP:
reg_maps->temporary[register_idx] = 1;
reg_maps->temporary[reg->idx] = 1;
break;
case WINED3DSPR_INPUT:
if (!pshader) reg_maps->attributes[register_idx] = 1;
if (!pshader) reg_maps->attributes[reg->idx] = 1;
else
{
if (has_rel_addr)
if (reg->rel_addr)
{
/* If relative addressing is used, we must assume that all registers
* are used. Even if it is a construct like v3[aL], we can't assume
@ -276,68 +276,68 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct sh
}
else
{
((IWineD3DPixelShaderImpl *)This)->input_reg_used[register_idx] = TRUE;
((IWineD3DPixelShaderImpl *)This)->input_reg_used[reg->idx] = TRUE;
}
}
break;
case WINED3DSPR_RASTOUT:
if (register_idx == 1) reg_maps->fog = 1;
if (reg->idx == 1) reg_maps->fog = 1;
break;
case WINED3DSPR_MISCTYPE:
if (pshader && register_idx == 0) reg_maps->vpos = 1;
if (pshader && reg->idx == 0) reg_maps->vpos = 1;
break;
case WINED3DSPR_CONST:
if (has_rel_addr)
if (reg->rel_addr)
{
if (!pshader)
{
if (register_idx <= ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
((IWineD3DVertexShaderImpl *)This)->min_rel_offset = register_idx;
else if (register_idx >= ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
((IWineD3DVertexShaderImpl *)This)->max_rel_offset = register_idx;
if (reg->idx <= ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
((IWineD3DVertexShaderImpl *)This)->min_rel_offset = reg->idx;
else if (reg->idx >= ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
((IWineD3DVertexShaderImpl *)This)->max_rel_offset = reg->idx;
}
reg_maps->usesrelconstF = TRUE;
}
else
{
set_bitmap_bit(reg_maps->constf, register_idx);
set_bitmap_bit(reg_maps->constf, reg->idx);
}
break;
case WINED3DSPR_CONSTINT:
reg_maps->integer_constants |= (1 << register_idx);
reg_maps->integer_constants |= (1 << reg->idx);
break;
case WINED3DSPR_CONSTBOOL:
reg_maps->boolean_constants |= (1 << register_idx);
reg_maps->boolean_constants |= (1 << reg->idx);
break;
default:
TRACE("Not recording register of type %#x and idx %u\n", register_type, register_idx);
TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx);
break;
}
}
static unsigned char get_instr_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, int param)
static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
{
switch(instr)
{
case WINED3DSIH_M4x4:
case WINED3DSIH_M3x4:
return param == 1 ? 4 : 1;
return param == 1 ? 3 : 0;
case WINED3DSIH_M4x3:
case WINED3DSIH_M3x3:
return param == 1 ? 3 : 1;
return param == 1 ? 2 : 0;
case WINED3DSIH_M3x2:
return param == 1 ? 2 : 1;
return param == 1 ? 1 : 0;
default:
return 1;
return 0;
}
}
@ -558,8 +558,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
}
else
{
shader_record_register_usage(This, reg_maps, dst_param.reg.type,
dst_param.reg.idx, !!dst_param.reg.rel_addr, pshader);
shader_record_register_usage(This, reg_maps, &dst_param.reg, pshader);
}
/* Declare 1.X samplers implicitly, based on the destination reg. number */
@ -617,25 +616,17 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
for (i = 0; i < limit; ++i)
{
struct wined3d_shader_src_param src_param, src_rel_addr;
unsigned int count;
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
switch(get_instr_regcount(ins.handler_idx, i))
count = get_instr_extra_regcount(ins.handler_idx, i);
shader_record_register_usage(This, reg_maps, &src_param.reg, pshader);
while (count)
{
case 4:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx + 3, !!src_param.reg.rel_addr, pshader);
/* drop through */
case 3:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx + 2, !!src_param.reg.rel_addr, pshader);
/* drop through */
case 2:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx + 1, !!src_param.reg.rel_addr, pshader);
/* drop through */
case 1:
shader_record_register_usage(This, reg_maps, src_param.reg.type,
src_param.reg.idx, !!src_param.reg.rel_addr, pshader);
++src_param.reg.idx;
shader_record_register_usage(This, reg_maps, &src_param.reg, pshader);
--count;
}
}
}