wined3d: Avoid NOP additions.

This commit is contained in:
Stefan Dösinger 2007-11-02 01:50:20 +01:00 committed by Alexandre Julliard
parent c7c785861a
commit 0183f3e305
1 changed files with 23 additions and 17 deletions

View File

@ -802,8 +802,15 @@ static void shader_glsl_get_register_name(
glsl_src_param_t rel_param;
shader_glsl_add_src_param(arg, addr_token, 0, WINED3DSP_WRITEMASK_0, &rel_param);
sprintf(tmpStr, "IN[%s + %u]", rel_param.param_str,
((IWineD3DPixelShaderImpl *) This)->input_reg_map[reg]);
/* Removing a + 0 would be an obvious optimization, but macos doesn't see the NOP
* operation there
*/
if(((IWineD3DPixelShaderImpl *) This)->input_reg_map[reg]) {
sprintf(tmpStr, "IN[%s + %u]", rel_param.param_str,
((IWineD3DPixelShaderImpl *) This)->input_reg_map[reg]);
} else {
sprintf(tmpStr, "IN[%s]", rel_param.param_str);
}
} else {
sprintf(tmpStr, "IN[%u]",
((IWineD3DPixelShaderImpl *) This)->input_reg_map[reg]);
@ -832,9 +839,18 @@ static void shader_glsl_get_register_name(
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2) {
glsl_src_param_t rel_param;
shader_glsl_add_src_param(arg, addr_token, 0, WINED3DSP_WRITEMASK_0, &rel_param);
sprintf(tmpStr, "%s[%s + %u]", prefix, rel_param.param_str, reg);
} else
sprintf(tmpStr, "%s[A0.x + %u]", prefix, reg);
if(reg) {
sprintf(tmpStr, "%s[%s + %u]", prefix, rel_param.param_str, reg);
} else {
sprintf(tmpStr, "%s[%s]", prefix, rel_param.param_str);
}
} else {
if(reg) {
sprintf(tmpStr, "%s[A0.x + %u]", prefix, reg);
} else {
sprintf(tmpStr, "%s[A0.x]", prefix);
}
}
} else
sprintf(tmpStr, "%s[%u]", prefix, reg);
@ -1299,18 +1315,8 @@ void shader_glsl_mov(SHADER_OPCODE_ARG* arg) {
* shader versions WINED3DSIO_MOVA is used for this. */
if ((WINED3DSHADER_VERSION_MAJOR(shader->baseShader.hex_version) == 1 &&
!shader_is_pshader_version(shader->baseShader.hex_version) &&
shader_get_regtype(arg->dst) == WINED3DSPR_ADDR)) {
/* This is a simple floor(). Msdn claims it is a round to nearest, but our test shows
* that it is just a floor(). ATI docs confirm that, and the test succeeds on the
* reference rasterizer too
*/
size_t mask_size = shader_glsl_get_write_mask_size(write_mask);
if (mask_size > 1) {
shader_addline(buffer, "ivec%d(floor(%s)));\n", mask_size, src0_param.param_str);
} else {
shader_addline(buffer, "int(floor(%s)));\n", src0_param.param_str);
}
} else if(arg->opcode->opcode == WINED3DSIO_MOVA) {
shader_get_regtype(arg->dst) == WINED3DSPR_ADDR) ||
arg->opcode->opcode == WINED3DSIO_MOVA) {
/* We need to *round* to the nearest int here. */
size_t mask_size = shader_glsl_get_write_mask_size(write_mask);
if (mask_size > 1) {