wined3d: Get rid of redundant comparisons against NULL / 0.

This commit is contained in:
Henri Verbeet 2010-09-14 13:38:39 +02:00 committed by Alexandre Julliard
parent fd7c1cbf05
commit b68d257710
23 changed files with 299 additions and 268 deletions

View File

@ -575,7 +575,7 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
checkGLcall("y correction loading"); checkGLcall("y correction loading");
} }
if(gl_shader->num_int_consts == 0) return; if (!gl_shader->num_int_consts) return;
for(i = 0; i < MAX_CONST_I; i++) for(i = 0; i < MAX_CONST_I; i++)
{ {
@ -605,7 +605,7 @@ static inline void shader_arb_vs_local_constants(IWineD3DDeviceImpl* deviceImpl)
/* Upload the position fixup */ /* Upload the position fixup */
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->pos_fixup, deviceImpl->posFixup)); GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->pos_fixup, deviceImpl->posFixup));
if(gl_shader->num_int_consts == 0) return; if (!gl_shader->num_int_consts) return;
stateBlock = deviceImpl->stateBlock; stateBlock = deviceImpl->stateBlock;
@ -922,7 +922,7 @@ static void shader_arb_request_a0(const struct wined3d_shader_instruction *ins,
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data; struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer; struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
if(strcmp(priv->addr_reg, src) == 0) return; if (!strcmp(priv->addr_reg, src)) return;
strcpy(priv->addr_reg, src); strcpy(priv->addr_reg, src);
shader_addline(buffer, "ARL A0.x, %s;\n", src); shader_addline(buffer, "ARL A0.x, %s;\n", src);
@ -953,7 +953,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
{ {
if(This->baseShader.reg_maps.shader_version.major < 3) if(This->baseShader.reg_maps.shader_version.major < 3)
{ {
if (reg->idx == 0) strcpy(register_name, "fragment.color.primary"); if (!reg->idx) strcpy(register_name, "fragment.color.primary");
else strcpy(register_name, "fragment.color.secondary"); else strcpy(register_name, "fragment.color.secondary");
} }
else else
@ -963,7 +963,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
char rel_reg[50]; char rel_reg[50];
shader_arb_get_src_param(ins, reg->rel_addr, 0, rel_reg); shader_arb_get_src_param(ins, reg->rel_addr, 0, rel_reg);
if(strcmp(rel_reg, "**aL_emul**") == 0) if (!strcmp(rel_reg, "**aL_emul**"))
{ {
DWORD idx = ctx->aL + reg->idx; DWORD idx = ctx->aL + reg->idx;
if(idx < MAX_REG_INPUT) if(idx < MAX_REG_INPUT)
@ -1045,7 +1045,8 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
} else { } else {
shader_arb_get_src_param(ins, reg->rel_addr, 0, rel_reg); shader_arb_get_src_param(ins, reg->rel_addr, 0, rel_reg);
if(ctx->target_version == ARB) { if(ctx->target_version == ARB) {
if(strcmp(rel_reg, "**aL_emul**") == 0) { if (!strcmp(rel_reg, "**aL_emul**"))
{
aL = TRUE; aL = TRUE;
} else { } else {
shader_arb_request_a0(ins, rel_reg); shader_arb_request_a0(ins, rel_reg);
@ -1097,7 +1098,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
break; break;
case WINED3DSPR_COLOROUT: case WINED3DSPR_COLOROUT:
if(ctx->cur_ps_args->super.srgb_correction && reg->idx == 0) if (ctx->cur_ps_args->super.srgb_correction && !reg->idx)
{ {
strcpy(register_name, "TMP_COLOR"); strcpy(register_name, "TMP_COLOR");
} }
@ -1173,7 +1174,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
break; break;
case WINED3DSPR_MISCTYPE: case WINED3DSPR_MISCTYPE:
if(reg->idx == 0) if (!reg->idx)
{ {
sprintf(register_name, "vpos"); sprintf(register_name, "vpos");
} }
@ -1807,7 +1808,7 @@ static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
shader_addline(buffer, "ARL A0.x, %s;\n", src0_param); shader_addline(buffer, "ARL A0.x, %s;\n", src0_param);
} }
} }
else if(ins->dst[0].reg.type == WINED3DSPR_COLOROUT && ins->dst[0].reg.idx == 0 && pshader) else if (ins->dst[0].reg.type == WINED3DSPR_COLOROUT && !ins->dst[0].reg.idx && pshader)
{ {
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) shader; IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) shader;
if(ctx->cur_ps_args->super.srgb_correction && ps->color0_mov) if(ctx->cur_ps_args->super.srgb_correction && ps->color0_mov)
@ -3438,11 +3439,11 @@ static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_
{ {
semantic_name = sig[i].semantic_name; semantic_name = sig[i].semantic_name;
semantic_idx = sig[i].semantic_idx; semantic_idx = sig[i].semantic_idx;
if(semantic_name == NULL) continue; if (!semantic_name) continue;
if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{ {
if(semantic_idx == 0) priv->ps_input[i] = "fragment.color.primary"; if (!semantic_idx) priv->ps_input[i] = "fragment.color.primary";
else if(semantic_idx == 1) priv->ps_input[i] = "fragment.color.secondary"; else if(semantic_idx == 1) priv->ps_input[i] = "fragment.color.secondary";
else priv->ps_input[i] = "0.0"; else priv->ps_input[i] = "0.0";
} }
@ -3457,7 +3458,7 @@ static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG))
{ {
if(semantic_idx == 0) priv->ps_input[i] = "fragment.fogcoord"; if (!semantic_idx) priv->ps_input[i] = "fragment.fogcoord";
else priv->ps_input[i] = "0.0"; else priv->ps_input[i] = "0.0";
} }
else else
@ -3508,7 +3509,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
{ {
if (!(map & 1) if (!(map & 1)
|| (This->color0_mov && i == This->color0_reg) || (This->color0_mov && i == This->color0_reg)
|| (reg_maps->shader_version.major < 2 && i == 0)) || (reg_maps->shader_version.major < 2 && !i))
continue; continue;
sprintf(srgbtmp[found], "R%u", i); sprintf(srgbtmp[found], "R%u", i);
@ -3827,15 +3828,14 @@ static int compare_sig(const struct wined3d_shader_signature_element *sig1, cons
for(i = 0; i < MAX_REG_INPUT; i++) for(i = 0; i < MAX_REG_INPUT; i++)
{ {
if(sig1[i].semantic_name == NULL || sig2[i].semantic_name == NULL) if (!sig1[i].semantic_name || !sig2[i].semantic_name)
{ {
/* Compare pointers, not contents. One string is NULL(element does not exist), the other one is not NULL */ /* Compare pointers, not contents. One string is NULL(element does not exist), the other one is not NULL */
if(sig1[i].semantic_name != sig2[i].semantic_name) return sig1[i].semantic_name < sig2[i].semantic_name ? -1 : 1; if(sig1[i].semantic_name != sig2[i].semantic_name) return sig1[i].semantic_name < sig2[i].semantic_name ? -1 : 1;
continue; continue;
} }
ret = strcmp(sig1[i].semantic_name, sig2[i].semantic_name); if ((ret = strcmp(sig1[i].semantic_name, sig2[i].semantic_name))) return ret;
if(ret != 0) return ret;
if(sig1[i].semantic_idx != sig2[i].semantic_idx) return sig1[i].semantic_idx < sig2[i].semantic_idx ? -1 : 1; if(sig1[i].semantic_idx != sig2[i].semantic_idx) return sig1[i].semantic_idx < sig2[i].semantic_idx ? -1 : 1;
if(sig1[i].sysval_semantic != sig2[i].sysval_semantic) return sig1[i].sysval_semantic < sig2[i].sysval_semantic ? -1 : 1; if(sig1[i].sysval_semantic != sig2[i].sysval_semantic) return sig1[i].sysval_semantic < sig2[i].sysval_semantic ? -1 : 1;
if(sig1[i].component_type != sig2[i].component_type) return sig1[i].sysval_semantic < sig2[i].component_type ? -1 : 1; if(sig1[i].component_type != sig2[i].component_type) return sig1[i].sysval_semantic < sig2[i].component_type ? -1 : 1;
@ -3854,10 +3854,7 @@ static struct wined3d_shader_signature_element *clone_sig(const struct wined3d_s
new = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*new) * MAX_REG_INPUT); new = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*new) * MAX_REG_INPUT);
for(i = 0; i < MAX_REG_INPUT; i++) for(i = 0; i < MAX_REG_INPUT; i++)
{ {
if(sig[i].semantic_name == NULL) if (!sig[i].semantic_name) continue;
{
continue;
}
new[i] = sig[i]; new[i] = sig[i];
/* Clone the semantic string */ /* Clone the semantic string */
@ -3873,7 +3870,7 @@ static DWORD find_input_signature(struct shader_arb_priv *priv, const struct win
struct wine_rb_entry *entry = wine_rb_get(&priv->signature_tree, sig); struct wine_rb_entry *entry = wine_rb_get(&priv->signature_tree, sig);
struct ps_signature *found_sig; struct ps_signature *found_sig;
if(entry != NULL) if (entry)
{ {
found_sig = WINE_RB_ENTRY_VALUE(entry, struct ps_signature, entry); found_sig = WINE_RB_ENTRY_VALUE(entry, struct ps_signature, entry);
TRACE("Found existing signature %u\n", found_sig->idx); TRACE("Found existing signature %u\n", found_sig->idx);
@ -3931,24 +3928,24 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
for (i = 0; i < (sizeof(baseshader->output_signature) / sizeof(*baseshader->output_signature)); ++i) for (i = 0; i < (sizeof(baseshader->output_signature) / sizeof(*baseshader->output_signature)); ++i)
{ {
semantic_name = baseshader->output_signature[i].semantic_name; semantic_name = baseshader->output_signature[i].semantic_name;
if(semantic_name == NULL) continue; if (!semantic_name) continue;
if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)) if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION))
{ {
TRACE("o%u is TMP_OUT\n", i); TRACE("o%u is TMP_OUT\n", i);
if (baseshader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "TMP_OUT"; if (!baseshader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "TMP_OUT";
else priv_ctx->vs_output[i] = "TA"; else priv_ctx->vs_output[i] = "TA";
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE))
{ {
TRACE("o%u is result.pointsize\n", i); TRACE("o%u is result.pointsize\n", i);
if (baseshader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "result.pointsize"; if (!baseshader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "result.pointsize";
else priv_ctx->vs_output[i] = "TA"; else priv_ctx->vs_output[i] = "TA";
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{ {
TRACE("o%u is result.color.?, idx %u\n", i, baseshader->output_signature[i].semantic_idx); TRACE("o%u is result.color.?, idx %u\n", i, baseshader->output_signature[i].semantic_idx);
if (baseshader->output_signature[i].semantic_idx == 0) if (!baseshader->output_signature[i].semantic_idx)
priv_ctx->vs_output[i] = "result.color.primary"; priv_ctx->vs_output[i] = "result.color.primary";
else if (baseshader->output_signature[i].semantic_idx == 1) else if (baseshader->output_signature[i].semantic_idx == 1)
priv_ctx->vs_output[i] = "result.color.secondary"; priv_ctx->vs_output[i] = "result.color.secondary";
@ -3994,7 +3991,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
semantic_name = sig[i].semantic_name; semantic_name = sig[i].semantic_name;
semantic_idx = sig[i].semantic_idx; semantic_idx = sig[i].semantic_idx;
reg_idx = sig[i].register_idx; reg_idx = sig[i].register_idx;
if(semantic_name == NULL) continue; if (!semantic_name) continue;
/* If a declared input register is not written by builtin arguments, don't write to it. /* If a declared input register is not written by builtin arguments, don't write to it.
* GL_NV_vertex_program makes sure the input defaults to 0.0, which is correct with D3D * GL_NV_vertex_program makes sure the input defaults to 0.0, which is correct with D3D
@ -4012,15 +4009,15 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG))
{ {
if(semantic_idx == 0) priv_ctx->fog_output = decl_idx_to_string[reg_idx]; if (!semantic_idx) priv_ctx->fog_output = decl_idx_to_string[reg_idx];
} }
else else
{ {
continue; continue;
} }
if(strcmp(decl_idx_to_string[reg_idx], "result.color.primary") == 0 || if (!strcmp(decl_idx_to_string[reg_idx], "result.color.primary")
strcmp(decl_idx_to_string[reg_idx], "result.color.secondary") == 0) || !strcmp(decl_idx_to_string[reg_idx], "result.color.secondary"))
{ {
compiled->need_color_unclamp = TRUE; compiled->need_color_unclamp = TRUE;
} }
@ -4032,19 +4029,16 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
/* Write unread output to TA to throw them away */ /* Write unread output to TA to throw them away */
priv_ctx->vs_output[i] = "TA"; priv_ctx->vs_output[i] = "TA";
semantic_name = baseshader->output_signature[i].semantic_name; semantic_name = baseshader->output_signature[i].semantic_name;
if(semantic_name == NULL) if (!semantic_name) continue;
{
continue;
}
if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION) if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)
&& baseshader->output_signature[i].semantic_idx == 0) && !baseshader->output_signature[i].semantic_idx)
{ {
priv_ctx->vs_output[i] = "TMP_OUT"; priv_ctx->vs_output[i] = "TMP_OUT";
continue; continue;
} }
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE) else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)
&& baseshader->output_signature[i].semantic_idx == 0) && !baseshader->output_signature[i].semantic_idx)
{ {
priv_ctx->vs_output[i] = "result.pointsize"; priv_ctx->vs_output[i] = "result.pointsize";
continue; continue;
@ -4052,18 +4046,15 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
for(j = 0; j < MAX_REG_INPUT; j++) for(j = 0; j < MAX_REG_INPUT; j++)
{ {
if(sig[j].semantic_name == NULL) if (!sig[j].semantic_name) continue;
{
continue;
}
if (strcmp(sig[j].semantic_name, semantic_name) == 0 if (!strcmp(sig[j].semantic_name, semantic_name)
&& sig[j].semantic_idx == baseshader->output_signature[i].semantic_idx) && sig[j].semantic_idx == baseshader->output_signature[i].semantic_idx)
{ {
priv_ctx->vs_output[i] = decl_idx_to_string[sig[j].register_idx]; priv_ctx->vs_output[i] = decl_idx_to_string[sig[j].register_idx];
if(strcmp(priv_ctx->vs_output[i], "result.color.primary") == 0 || if (!strcmp(priv_ctx->vs_output[i], "result.color.primary")
strcmp(priv_ctx->vs_output[i], "result.color.secondary") == 0) || !strcmp(priv_ctx->vs_output[i], "result.color.secondary"))
{ {
compiled->need_color_unclamp = TRUE; compiled->need_color_unclamp = TRUE;
} }
@ -4175,10 +4166,9 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
const char *one = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_ONE); const char *one = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_ONE);
for(i = 0; i < min(8, MAX_REG_TEXCRD); i++) for(i = 0; i < min(8, MAX_REG_TEXCRD); i++)
{ {
if (This->baseShader.reg_maps.texcoord_mask[i] != 0 && if (This->baseShader.reg_maps.texcoord_mask[i]
This->baseShader.reg_maps.texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL) { && This->baseShader.reg_maps.texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL)
shader_addline(buffer, "MOV result.texcoord[%u].w, %s\n", i, one); shader_addline(buffer, "MOV result.texcoord[%u].w, %s\n", i, one);
}
} }
} }
} }
@ -4271,10 +4261,10 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
* so a linear search is more performant than a hashmap or a binary search * so a linear search is more performant than a hashmap or a binary search
* (cache coherency etc) * (cache coherency etc)
*/ */
for(i = 0; i < shader_data->num_gl_shaders; i++) { for (i = 0; i < shader_data->num_gl_shaders; ++i)
if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) { {
if (!memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)))
return &shader_data->gl_shaders[i]; return &shader_data->gl_shaders[i];
}
} }
TRACE("No matching GL shader found, compiling a new shader\n"); TRACE("No matching GL shader found, compiling a new shader\n");
@ -4326,7 +4316,7 @@ static inline BOOL vs_args_equal(const struct arb_vs_compile_args *stored, const
if(stored->vertex.samplers_compare != new->vertex.samplers_compare) return FALSE; if(stored->vertex.samplers_compare != new->vertex.samplers_compare) return FALSE;
if(skip_int) return TRUE; if(skip_int) return TRUE;
return memcmp(stored->loop_ctrl, new->loop_ctrl, sizeof(stored->loop_ctrl)) == 0; return !memcmp(stored->loop_ctrl, new->loop_ctrl, sizeof(stored->loop_ctrl));
} }
static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl *shader, const struct arb_vs_compile_args *args) static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl *shader, const struct arb_vs_compile_args *args)
@ -4919,7 +4909,7 @@ static void shader_arb_add_instruction_modifiers(const struct wined3d_shader_ins
dst = &ins->dst[0]; dst = &ins->dst[0];
shift = dst->shift; shift = dst->shift;
if(shift == 0) return; /* Saturate alone is handled by the instructions */ if (!shift) return; /* Saturate alone is handled by the instructions */
shader_arb_get_write_mask(ins, dst, write_mask); shader_arb_get_write_mask(ins, dst, write_mask);
shader_arb_get_register_name(ins, &dst->reg, regstr, &is_color); shader_arb_get_register_name(ins, &dst->reg, regstr, &is_color);
@ -5596,8 +5586,8 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, s
if (use_ps(stateblock)) if (use_ps(stateblock))
{ {
if (stage != 0 IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
&& (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage))) if (stage && (ps->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
@ -5633,8 +5623,8 @@ static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock
if (use_ps(stateblock)) if (use_ps(stateblock))
{ {
if (stage != 0 IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
&& (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.luminanceparams & (1 << stage))) if (stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
{ {
/* The pixel shader has to know the luminance offset. Do a constants update if it /* The pixel shader has to know the luminance offset. Do a constants update if it
* isn't scheduled anyway * isn't scheduled anyway
@ -5672,7 +5662,7 @@ static const char *get_argreg(struct wined3d_shader_buffer *buffer, DWORD argnum
ret = "fragment.color.primary"; break; ret = "fragment.color.primary"; break;
case WINED3DTA_CURRENT: case WINED3DTA_CURRENT:
if(stage == 0) ret = "fragment.color.primary"; if (!stage) ret = "fragment.color.primary";
else ret = "ret"; else ret = "ret";
break; break;
@ -5753,7 +5743,7 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
switch(op) { switch(op) {
case WINED3DTOP_DISABLE: case WINED3DTOP_DISABLE:
if(stage == 0) shader_addline(buffer, "MOV %s%s, fragment.color.primary;\n", dstreg, dstmask); if (!stage) shader_addline(buffer, "MOV %s%s, fragment.color.primary;\n", dstreg, dstmask);
break; break;
case WINED3DTOP_SELECTARG2: case WINED3DTOP_SELECTARG2:
@ -5766,7 +5756,8 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
mul = 2; mul = 2;
case WINED3DTOP_MODULATE2X: case WINED3DTOP_MODULATE2X:
mul *= 2; mul *= 2;
if(strcmp(dstreg, "result.color") == 0) { if (!strcmp(dstreg, "result.color"))
{
dstreg = "ret"; dstreg = "ret";
mul_final_dest = TRUE; mul_final_dest = TRUE;
} }
@ -5776,7 +5767,8 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
case WINED3DTOP_ADDSIGNED2X: case WINED3DTOP_ADDSIGNED2X:
mul = 2; mul = 2;
if(strcmp(dstreg, "result.color") == 0) { if (!strcmp(dstreg, "result.color"))
{
dstreg = "ret"; dstreg = "ret";
mul_final_dest = TRUE; mul_final_dest = TRUE;
} }
@ -5838,7 +5830,8 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
case WINED3DTOP_DOTPRODUCT3: case WINED3DTOP_DOTPRODUCT3:
mul = 4; mul = 4;
if(strcmp(dstreg, "result.color") == 0) { if (!strcmp(dstreg, "result.color"))
{
dstreg = "ret"; dstreg = "ret";
mul_final_dest = TRUE; mul_final_dest = TRUE;
} }
@ -6061,11 +6054,11 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi
} }
/* Generate the main shader */ /* Generate the main shader */
for(stage = 0; stage < MAX_TEXTURES; stage++) { for (stage = 0; stage < MAX_TEXTURES; ++stage)
if(settings->op[stage].cop == WINED3DTOP_DISABLE) { {
if(stage == 0) { if (settings->op[stage].cop == WINED3DTOP_DISABLE)
final_combiner_src = "fragment.color.primary"; {
} if (!stage) final_combiner_src = "fragment.color.primary";
break; break;
} }
@ -6092,10 +6085,11 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi
gen_ffp_instr(&buffer, stage, TRUE, FALSE, settings->op[stage].dst, gen_ffp_instr(&buffer, stage, TRUE, FALSE, settings->op[stage].dst,
settings->op[stage].cop, settings->op[stage].carg0, settings->op[stage].cop, settings->op[stage].carg0,
settings->op[stage].carg1, settings->op[stage].carg2); settings->op[stage].carg1, settings->op[stage].carg2);
if(stage == 0) { if (!stage)
shader_addline(&buffer, "MOV ret.w, fragment.color.primary.w;\n"); shader_addline(&buffer, "MOV ret.w, fragment.color.primary.w;\n");
} }
} else if(op_equal) { else if (op_equal)
{
gen_ffp_instr(&buffer, stage, TRUE, TRUE, settings->op[stage].dst, gen_ffp_instr(&buffer, stage, TRUE, TRUE, settings->op[stage].dst,
settings->op[stage].cop, settings->op[stage].carg0, settings->op[stage].cop, settings->op[stage].carg0,
settings->op[stage].carg1, settings->op[stage].carg2); settings->op[stage].carg1, settings->op[stage].carg2);

View File

@ -273,11 +273,7 @@ static GLuint register_for_arg(DWORD arg, const struct wined3d_gl_info *gl_info,
* instruction writing to reg0. Afterwards texture0 is not used any longer. * instruction writing to reg0. Afterwards texture0 is not used any longer.
* If we're reading from current * If we're reading from current
*/ */
if(stage == 0) { ret = stage ? GL_REG_0_ATI : GL_PRIMARY_COLOR;
ret = GL_PRIMARY_COLOR;
} else {
ret = GL_REG_0_ATI;
}
break; break;
case WINED3DTA_TEXTURE: case WINED3DTA_TEXTURE:
@ -517,9 +513,12 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con
} }
/* Pass 4: Generate the arithmetic instructions */ /* Pass 4: Generate the arithmetic instructions */
for(stage = 0; stage < MAX_TEXTURES; stage++) { for (stage = 0; stage < MAX_TEXTURES; ++stage)
if(op[stage].cop == WINED3DTOP_DISABLE) { {
if(stage == 0) { if (op[stage].cop == WINED3DTOP_DISABLE)
{
if (!stage)
{
/* Handle complete texture disabling gracefully */ /* Handle complete texture disabling gracefully */
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
GL_PRIMARY_COLOR, GL_NONE, GL_NONE); GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
@ -679,7 +678,8 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con
switch(op[stage].aop) { switch(op[stage].aop) {
case WINED3DTOP_DISABLE: case WINED3DTOP_DISABLE:
/* Get the primary color to the output if on stage 0, otherwise leave register 0 untouched */ /* Get the primary color to the output if on stage 0, otherwise leave register 0 untouched */
if(stage == 0) { if (!stage)
{
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_ALPHA, GL_NONE, wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_ALPHA, GL_NONE,
GL_PRIMARY_COLOR, GL_NONE, GL_NONE); GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
} }

View File

@ -277,7 +277,8 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface); textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
ENTER_GL(); ENTER_GL();
/* Generate a texture name if we don't already have one */ /* Generate a texture name if we don't already have one */
if (gl_tex->name == 0) { if (!gl_tex->name)
{
*set_surface_desc = TRUE; *set_surface_desc = TRUE;
glGenTextures(1, &gl_tex->name); glGenTextures(1, &gl_tex->name);
checkGLcall("glGenTextures"); checkGLcall("glGenTextures");
@ -319,7 +320,8 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
} }
/* Bind the texture */ /* Bind the texture */
if (gl_tex->name != 0) { if (gl_tex->name)
{
glBindTexture(textureDimensions, gl_tex->name); glBindTexture(textureDimensions, gl_tex->name);
checkGLcall("glBindTexture"); checkGLcall("glBindTexture");
if (isNewTexture) { if (isNewTexture) {

View File

@ -78,7 +78,7 @@ static inline void buffer_clear_dirty_areas(struct wined3d_buffer *This)
static inline BOOL buffer_is_dirty(struct wined3d_buffer *This) static inline BOOL buffer_is_dirty(struct wined3d_buffer *This)
{ {
return This->modified_areas != 0; return !!This->modified_areas;
} }
static inline BOOL buffer_is_fully_dirty(struct wined3d_buffer *This) static inline BOOL buffer_is_fully_dirty(struct wined3d_buffer *This)
@ -87,7 +87,7 @@ static inline BOOL buffer_is_fully_dirty(struct wined3d_buffer *This)
for(i = 0; i < This->modified_areas; i++) for(i = 0; i < This->modified_areas; i++)
{ {
if(This->maps[i].offset == 0 && This->maps[i].size == This->resource.size) if (!This->maps[i].offset && This->maps[i].size == This->resource.size)
{ {
return TRUE; return TRUE;
} }
@ -534,7 +534,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
if (float16_used) FIXME("Float16 conversion used with fixed function vertex processing\n"); if (float16_used) FIXME("Float16 conversion used with fixed function vertex processing\n");
} }
if (stride_this_run == 0 && This->conversion_map) if (!stride_this_run && This->conversion_map)
{ {
/* Sanity test */ /* Sanity test */
if (!ret) ERR("no converted attributes found, old conversion map exists, and no declaration change?\n"); if (!ret) ERR("no converted attributes found, old conversion map exists, and no declaration change?\n");
@ -1348,7 +1348,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
* number of Map calls, d3d returns always D3D_OK. * number of Map calls, d3d returns always D3D_OK.
* This is also needed to prevent Map from returning garbage on * This is also needed to prevent Map from returning garbage on
* the next call (this will happen if the lock_count is < 0). */ * the next call (this will happen if the lock_count is < 0). */
if(This->lock_count == 0) if (!This->lock_count)
{ {
TRACE("Unmap called without a previous Map call!\n"); TRACE("Unmap called without a previous Map call!\n");
return WINED3D_OK; return WINED3D_OK;

View File

@ -63,12 +63,9 @@ static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1); TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (ref == 0) if (!ref) HeapFree(GetProcessHeap(), 0, This);
{
HeapFree(GetProcessHeap(), 0, This); return ref;
return 0;
}
else return ref;
} }
static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd) static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd)
@ -135,7 +132,7 @@ static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, co
{ {
static int warned = 0; static int warned = 0;
if (warned++ < 10 || rgn == NULL) if (warned++ < 10 || !rgn)
FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags); FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags);
return WINED3D_OK; return WINED3D_OK;

View File

@ -146,17 +146,17 @@ static WINED3DPRIMITIVETYPE d3d_primitive_type_from_gl(GLenum primitive_type)
static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum) static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum)
{ {
if ((usage == WINED3DDECLUSAGE_POSITION || usage == WINED3DDECLUSAGE_POSITIONT) && usage_idx == 0) if ((usage == WINED3DDECLUSAGE_POSITION || usage == WINED3DDECLUSAGE_POSITIONT) && !usage_idx)
*regnum = WINED3D_FFP_POSITION; *regnum = WINED3D_FFP_POSITION;
else if (usage == WINED3DDECLUSAGE_BLENDWEIGHT && usage_idx == 0) else if (usage == WINED3DDECLUSAGE_BLENDWEIGHT && !usage_idx)
*regnum = WINED3D_FFP_BLENDWEIGHT; *regnum = WINED3D_FFP_BLENDWEIGHT;
else if (usage == WINED3DDECLUSAGE_BLENDINDICES && usage_idx == 0) else if (usage == WINED3DDECLUSAGE_BLENDINDICES && !usage_idx)
*regnum = WINED3D_FFP_BLENDINDICES; *regnum = WINED3D_FFP_BLENDINDICES;
else if (usage == WINED3DDECLUSAGE_NORMAL && usage_idx == 0) else if (usage == WINED3DDECLUSAGE_NORMAL && !usage_idx)
*regnum = WINED3D_FFP_NORMAL; *regnum = WINED3D_FFP_NORMAL;
else if (usage == WINED3DDECLUSAGE_PSIZE && usage_idx == 0) else if (usage == WINED3DDECLUSAGE_PSIZE && !usage_idx)
*regnum = WINED3D_FFP_PSIZE; *regnum = WINED3D_FFP_PSIZE;
else if (usage == WINED3DDECLUSAGE_COLOR && usage_idx == 0) else if (usage == WINED3DDECLUSAGE_COLOR && !usage_idx)
*regnum = WINED3D_FFP_DIFFUSE; *regnum = WINED3D_FFP_DIFFUSE;
else if (usage == WINED3DDECLUSAGE_COLOR && usage_idx == 1) else if (usage == WINED3DDECLUSAGE_COLOR && usage_idx == 1)
*regnum = WINED3D_FFP_SPECULAR; *regnum = WINED3D_FFP_SPECULAR;
@ -1387,16 +1387,16 @@ static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the
DWORD fvf, WINED3DVERTEXELEMENT **ppVertexElements) DWORD fvf, WINED3DVERTEXELEMENT **ppVertexElements)
{ {
const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
BOOL has_pos = (fvf & WINED3DFVF_POSITION_MASK) != 0; BOOL has_pos = !!(fvf & WINED3DFVF_POSITION_MASK);
BOOL has_blend = (fvf & WINED3DFVF_XYZB5) > WINED3DFVF_XYZRHW; BOOL has_blend = (fvf & WINED3DFVF_XYZB5) > WINED3DFVF_XYZRHW;
BOOL has_blend_idx = has_blend && BOOL has_blend_idx = has_blend &&
(((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB5) || (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB5) ||
(fvf & WINED3DFVF_LASTBETA_D3DCOLOR) || (fvf & WINED3DFVF_LASTBETA_D3DCOLOR) ||
(fvf & WINED3DFVF_LASTBETA_UBYTE4)); (fvf & WINED3DFVF_LASTBETA_UBYTE4));
BOOL has_normal = (fvf & WINED3DFVF_NORMAL) != 0; BOOL has_normal = !!(fvf & WINED3DFVF_NORMAL);
BOOL has_psize = (fvf & WINED3DFVF_PSIZE) != 0; BOOL has_psize = !!(fvf & WINED3DFVF_PSIZE);
BOOL has_diffuse = (fvf & WINED3DFVF_DIFFUSE) != 0; BOOL has_diffuse = !!(fvf & WINED3DFVF_DIFFUSE);
BOOL has_specular = (fvf & WINED3DFVF_SPECULAR) !=0; BOOL has_specular = !!(fvf & WINED3DFVF_SPECULAR);
DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT; DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
DWORD texcoords = (fvf & 0xFFFF0000) >> 16; DWORD texcoords = (fvf & 0xFFFF0000) >> 16;
@ -2209,21 +2209,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, U
devmode.dmPelsHeight = pMode->Height; devmode.dmPelsHeight = pMode->Height;
devmode.dmDisplayFrequency = pMode->RefreshRate; devmode.dmDisplayFrequency = pMode->RefreshRate;
if (pMode->RefreshRate != 0) { if (pMode->RefreshRate)
devmode.dmFields |= DM_DISPLAYFREQUENCY; devmode.dmFields |= DM_DISPLAYFREQUENCY;
}
/* Only change the mode if necessary */ /* Only change the mode if necessary */
if( (This->ddraw_width == pMode->Width) && if (This->ddraw_width == pMode->Width && This->ddraw_height == pMode->Height
(This->ddraw_height == pMode->Height) && && This->ddraw_format == pMode->Format && !pMode->RefreshRate)
(This->ddraw_format == pMode->Format) &&
(pMode->RefreshRate == 0) ) {
return WINED3D_OK; return WINED3D_OK;
}
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL); ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL);
if (ret != DISP_CHANGE_SUCCESSFUL) { if (ret != DISP_CHANGE_SUCCESSFUL)
if(devmode.dmDisplayFrequency != 0) { {
if (devmode.dmDisplayFrequency)
{
WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate\n"); WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate\n");
devmode.dmFields &= ~DM_DISPLAYFREQUENCY; devmode.dmFields &= ~DM_DISPLAYFREQUENCY;
devmode.dmDisplayFrequency = 0; devmode.dmDisplayFrequency = 0;
@ -2307,11 +2305,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface,
return WINED3D_OK; return WINED3D_OK;
} }
if (pStreamData != NULL) { if (pStreamData)
{
InterlockedIncrement(&((struct wined3d_buffer *)pStreamData)->bind_count); InterlockedIncrement(&((struct wined3d_buffer *)pStreamData)->bind_count);
IWineD3DBuffer_AddRef(pStreamData); IWineD3DBuffer_AddRef(pStreamData);
} }
if (oldSrc != NULL) { if (oldSrc)
{
InterlockedDecrement(&((struct wined3d_buffer *)oldSrc)->bind_count); InterlockedDecrement(&((struct wined3d_buffer *)oldSrc)->bind_count);
IWineD3DBuffer_Release(oldSrc); IWineD3DBuffer_Release(oldSrc);
} }
@ -2341,9 +2341,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSource(IWineD3DDevice *iface,
*pOffset = This->stateBlock->streamOffset[StreamNumber]; *pOffset = This->stateBlock->streamOffset[StreamNumber];
} }
if (*pStream != NULL) { if (*pStream) IWineD3DBuffer_AddRef(*pStream);
IWineD3DBuffer_AddRef(*pStream); /* We have created a new reference to the VB */
}
return WINED3D_OK; return WINED3D_OK;
} }
@ -2357,11 +2356,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSourceFreq(IWineD3DDevice *ifa
WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL\n"); WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if( (Divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && StreamNumber == 0 ){ if ((Divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && !StreamNumber)
{
WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL\n"); WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if( Divider == 0 ){ if (!Divider)
{
WARN("Divider is 0, returning D3DERR_INVALIDCALL\n"); WARN("Divider is 0, returning D3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@ -2597,7 +2598,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I
* however spot lights are rather rarely used in games (if ever used at all). * however spot lights are rather rarely used in games (if ever used at all).
* furthermore if still used, probably nobody pays attention to such details. * furthermore if still used, probably nobody pays attention to such details.
*/ */
if (pLight->Falloff == 0) { if (!pLight->Falloff)
{
/* Falloff = 0 is easy, because d3d's and opengl's spot light equations have the /* Falloff = 0 is easy, because d3d's and opengl's spot light equations have the
* falloff resp. exponent parameter as an exponent, so the spot light lighting * falloff resp. exponent parameter as an exponent, so the spot light lighting
* will always be 1.0 for both of them, and we don't have to care for the * will always be 1.0 for both of them, and we don't have to care for the
@ -2644,7 +2646,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD I
lightInfo = NULL; lightInfo = NULL;
} }
if (lightInfo == NULL) { if (!lightInfo)
{
TRACE("Light information requested but light not defined\n"); TRACE("Light information requested but light not defined\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@ -2674,8 +2677,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
TRACE("Found light: %p\n", lightInfo); TRACE("Found light: %p\n", lightInfo);
/* Special case - enabling an undefined light creates one with a strict set of parms! */ /* Special case - enabling an undefined light creates one with a strict set of parms! */
if (lightInfo == NULL) { if (!lightInfo)
{
TRACE("Light enabled requested but light not defined, so defining one!\n"); TRACE("Light enabled requested but light not defined, so defining one!\n");
IWineD3DDeviceImpl_SetLight(iface, Index, &WINED3D_default_light); IWineD3DDeviceImpl_SetLight(iface, Index, &WINED3D_default_light);
@ -2686,7 +2689,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
if(lightInfo->OriginalIndex == Index) break; if(lightInfo->OriginalIndex == Index) break;
lightInfo = NULL; lightInfo = NULL;
} }
if (lightInfo == NULL) { if (!lightInfo)
{
FIXME("Adding default lights has failed dismally\n"); FIXME("Adding default lights has failed dismally\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@ -2712,8 +2716,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, D
} else { } else {
int i; int i;
/* Find a free gl light */ /* Find a free gl light */
for(i = 0; i < This->maxConcurrentLights; i++) { for (i = 0; i < This->maxConcurrentLights; ++i)
if(This->updateStateBlock->activeLights[i] == NULL) { {
if (!This->updateStateBlock->activeLights[i])
{
This->updateStateBlock->activeLights[i] = lightInfo; This->updateStateBlock->activeLights[i] = lightInfo;
lightInfo->glIndex = i; lightInfo->glIndex = i;
break; break;
@ -2756,7 +2762,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetLightEnable(IWineD3DDevice *iface, D
lightInfo = NULL; lightInfo = NULL;
} }
if (lightInfo == NULL) { if (!lightInfo)
{
TRACE("Light enabled state requested but light not defined\n"); TRACE("Light enabled state requested but light not defined\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@ -2830,9 +2837,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetClipPlane(IWineD3DDevice *iface, DWO
static HRESULT WINAPI IWineD3DDeviceImpl_SetClipStatus(IWineD3DDevice *iface, CONST WINED3DCLIPSTATUS* pClipStatus) { static HRESULT WINAPI IWineD3DDeviceImpl_SetClipStatus(IWineD3DDevice *iface, CONST WINED3DCLIPSTATUS* pClipStatus) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
FIXME("(%p) : stub\n", This); FIXME("(%p) : stub\n", This);
if (NULL == pClipStatus) {
return WINED3DERR_INVALIDCALL; if (!pClipStatus)
} return WINED3DERR_INVALIDCALL;
This->updateStateBlock->clip_status.ClipUnion = pClipStatus->ClipUnion; This->updateStateBlock->clip_status.ClipUnion = pClipStatus->ClipUnion;
This->updateStateBlock->clip_status.ClipIntersection = pClipStatus->ClipIntersection; This->updateStateBlock->clip_status.ClipIntersection = pClipStatus->ClipIntersection;
return WINED3D_OK; return WINED3D_OK;
@ -2841,9 +2849,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetClipStatus(IWineD3DDevice *iface,
static HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, WINED3DCLIPSTATUS* pClipStatus) { static HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, WINED3DCLIPSTATUS* pClipStatus) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
FIXME("(%p) : stub\n", This); FIXME("(%p) : stub\n", This);
if (NULL == pClipStatus) {
return WINED3DERR_INVALIDCALL; if (!pClipStatus)
} return WINED3DERR_INVALIDCALL;
pClipStatus->ClipUnion = This->updateStateBlock->clip_status.ClipUnion; pClipStatus->ClipUnion = This->updateStateBlock->clip_status.ClipUnion;
pClipStatus->ClipIntersection = This->updateStateBlock->clip_status.ClipIntersection; pClipStatus->ClipIntersection = This->updateStateBlock->clip_status.ClipIntersection;
return WINED3D_OK; return WINED3D_OK;
@ -3177,7 +3186,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* if
TRACE("(%p) : ppDecl=%p\n", This, ppDecl); TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
*ppDecl = This->stateBlock->vertexDecl; *ppDecl = This->stateBlock->vertexDecl;
if (NULL != *ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl); if (*ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
return WINED3D_OK; return WINED3D_OK;
} }
@ -3261,7 +3270,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB(
TRACE("(iface %p, dstData %p, start %d, count %d)\n", TRACE("(iface %p, dstData %p, start %d, count %d)\n",
iface, dstData, start, count); iface, dstData, start, count);
if (dstData == NULL || cnt < 0) if (!dstData || cnt < 0)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(dstData, &This->stateBlock->vertexShaderConstantB[start], cnt * sizeof(BOOL)); memcpy(dstData, &This->stateBlock->vertexShaderConstantB[start], cnt * sizeof(BOOL));
@ -3308,7 +3317,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantI(
TRACE("(iface %p, dstData %p, start %d, count %d)\n", TRACE("(iface %p, dstData %p, start %d, count %d)\n",
iface, dstData, start, count); iface, dstData, start, count);
if (dstData == NULL || ((signed int) MAX_CONST_I - (signed int) start) <= 0) if (!dstData || ((signed int)MAX_CONST_I - (signed int)start) <= 0)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(dstData, &This->stateBlock->vertexShaderConstantI[start * 4], cnt * sizeof(int) * 4); memcpy(dstData, &This->stateBlock->vertexShaderConstantI[start * 4], cnt * sizeof(int) * 4);
@ -3328,7 +3337,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(
iface, srcData, start, count); iface, srcData, start, count);
/* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */ /* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */
if (srcData == NULL || start + count > This->d3d_vshader_constantF || start > This->d3d_vshader_constantF) if (!srcData || start + count > This->d3d_vshader_constantF || start > This->d3d_vshader_constantF)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(&This->updateStateBlock->vertexShaderConstantF[start * 4], srcData, count * sizeof(float) * 4); memcpy(&This->updateStateBlock->vertexShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
@ -3362,7 +3371,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(
TRACE("(iface %p, dstData %p, start %d, count %d)\n", TRACE("(iface %p, dstData %p, start %d, count %d)\n",
iface, dstData, start, count); iface, dstData, start, count);
if (dstData == NULL || cnt < 0) if (!dstData || cnt < 0)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(dstData, &This->stateBlock->vertexShaderConstantF[start * 4], cnt * sizeof(float) * 4); memcpy(dstData, &This->stateBlock->vertexShaderConstantF[start * 4], cnt * sizeof(float) * 4);
@ -3657,7 +3666,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantB(
TRACE("(iface %p, dstData %p, start %d, count %d)\n", TRACE("(iface %p, dstData %p, start %d, count %d)\n",
iface, dstData, start, count); iface, dstData, start, count);
if (dstData == NULL || cnt < 0) if (!dstData || cnt < 0)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(dstData, &This->stateBlock->pixelShaderConstantB[start], cnt * sizeof(BOOL)); memcpy(dstData, &This->stateBlock->pixelShaderConstantB[start], cnt * sizeof(BOOL));
@ -3704,7 +3713,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantI(
TRACE("(iface %p, dstData %p, start %d, count %d)\n", TRACE("(iface %p, dstData %p, start %d, count %d)\n",
iface, dstData, start, count); iface, dstData, start, count);
if (dstData == NULL || cnt < 0) if (!dstData || cnt < 0)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(dstData, &This->stateBlock->pixelShaderConstantI[start * 4], cnt * sizeof(int) * 4); memcpy(dstData, &This->stateBlock->pixelShaderConstantI[start * 4], cnt * sizeof(int) * 4);
@ -3724,7 +3733,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF(
iface, srcData, start, count); iface, srcData, start, count);
/* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */ /* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */
if (srcData == NULL || start + count > This->d3d_pshader_constantF || start > This->d3d_pshader_constantF) if (!srcData || start + count > This->d3d_pshader_constantF || start > This->d3d_pshader_constantF)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(&This->updateStateBlock->pixelShaderConstantF[start * 4], srcData, count * sizeof(float) * 4); memcpy(&This->updateStateBlock->pixelShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
@ -3758,7 +3767,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF(
TRACE("(iface %p, dstData %p, start %d, count %d)\n", TRACE("(iface %p, dstData %p, start %d, count %d)\n",
iface, dstData, start, count); iface, dstData, start, count);
if (dstData == NULL || cnt < 0) if (!dstData || cnt < 0)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(dstData, &This->stateBlock->pixelShaderConstantF[start * 4], cnt * sizeof(float) * 4); memcpy(dstData, &This->stateBlock->pixelShaderConstantF[start * 4], cnt * sizeof(float) * 4);
@ -4646,7 +4655,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UI
This->stateBlock->streamIsUP = FALSE; This->stateBlock->streamIsUP = FALSE;
} }
if(This->stateBlock->loadBaseVertexIndex != 0) { if (This->stateBlock->loadBaseVertexIndex)
{
This->stateBlock->loadBaseVertexIndex = 0; This->stateBlock->loadBaseVertexIndex = 0;
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
} }
@ -5151,7 +5161,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCurrentTexturePalette(IWineD3DDevi
static HRESULT WINAPI IWineD3DDeviceImpl_GetCurrentTexturePalette(IWineD3DDevice *iface, UINT* PaletteNumber) { static HRESULT WINAPI IWineD3DDeviceImpl_GetCurrentTexturePalette(IWineD3DDevice *iface, UINT* PaletteNumber) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
if (PaletteNumber == NULL) {
if (!PaletteNumber)
{
WARN("(%p) : returning Invalid Call\n", This); WARN("(%p) : returning Invalid Call\n", This);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@ -5424,9 +5436,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UI
patch = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*patch)); patch = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*patch));
} }
if(pNumSegs[0] != patch->numSegs[0] || pNumSegs[1] != patch->numSegs[1] || if (pNumSegs[0] != patch->numSegs[0] || pNumSegs[1] != patch->numSegs[1]
pNumSegs[2] != patch->numSegs[2] || pNumSegs[3] != patch->numSegs[3] || || pNumSegs[2] != patch->numSegs[2] || pNumSegs[3] != patch->numSegs[3]
(pRectPatchInfo && memcmp(pRectPatchInfo, &patch->RectPatchInfo, sizeof(*pRectPatchInfo)) != 0) ) { || (pRectPatchInfo && memcmp(pRectPatchInfo, &patch->RectPatchInfo, sizeof(*pRectPatchInfo))))
{
HRESULT hr; HRESULT hr;
TRACE("Tesselation density or patch info changed, retesselating\n"); TRACE("Tesselation density or patch info changed, retesselating\n");
@ -6256,18 +6269,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
swapchain->presentParms.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz; swapchain->presentParms.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
/* What to do about these? */ /* What to do about these? */
if(pPresentationParameters->BackBufferCount != 0 && if (pPresentationParameters->BackBufferCount
pPresentationParameters->BackBufferCount != swapchain->presentParms.BackBufferCount) { && pPresentationParameters->BackBufferCount != swapchain->presentParms.BackBufferCount)
ERR("Cannot change the back buffer count yet\n"); ERR("Cannot change the back buffer count yet\n");
}
if(pPresentationParameters->BackBufferFormat != WINED3DFMT_UNKNOWN && if(pPresentationParameters->BackBufferFormat != WINED3DFMT_UNKNOWN &&
pPresentationParameters->BackBufferFormat != swapchain->presentParms.BackBufferFormat) { pPresentationParameters->BackBufferFormat != swapchain->presentParms.BackBufferFormat) {
ERR("Cannot change the back buffer format yet\n"); ERR("Cannot change the back buffer format yet\n");
} }
if(pPresentationParameters->hDeviceWindow != NULL &&
pPresentationParameters->hDeviceWindow != swapchain->presentParms.hDeviceWindow) { if (pPresentationParameters->hDeviceWindow
&& pPresentationParameters->hDeviceWindow != swapchain->presentParms.hDeviceWindow)
ERR("Cannot change the device window yet\n"); ERR("Cannot change the device window yet\n");
}
if (pPresentationParameters->EnableAutoDepthStencil && !This->auto_depth_stencil) if (pPresentationParameters->EnableAutoDepthStencil && !This->auto_depth_stencil)
{ {
HRESULT hrc; HRESULT hrc;
@ -6321,9 +6335,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
} }
/* Should Width == 800 && Height == 0 set 800x600? */ /* Should Width == 800 && Height == 0 set 800x600? */
if(pPresentationParameters->BackBufferWidth != 0 && pPresentationParameters->BackBufferHeight != 0 && if (pPresentationParameters->BackBufferWidth && pPresentationParameters->BackBufferHeight
(pPresentationParameters->BackBufferWidth != swapchain->presentParms.BackBufferWidth || && (pPresentationParameters->BackBufferWidth != swapchain->presentParms.BackBufferWidth
pPresentationParameters->BackBufferHeight != swapchain->presentParms.BackBufferHeight)) || pPresentationParameters->BackBufferHeight != swapchain->presentParms.BackBufferHeight))
{ {
UINT i; UINT i;

View File

@ -375,7 +375,9 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
ULONG ref; ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref); TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
if (!ref)
{
unsigned int i; unsigned int i;
for (i = 0; i < This->adapter_count; ++i) for (i = 0; i < This->adapter_count; ++i)
@ -414,7 +416,8 @@ static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_inf
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog)); GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(testcode), testcode)); strlen(testcode), testcode));
if(glGetError() != 0) { if (glGetError())
{
TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n"); TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
ret = TRUE; ret = TRUE;
@ -2719,22 +2722,24 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
if(GL_EXTCALL(wglGetExtensionsStringARB)) if(GL_EXTCALL(wglGetExtensionsStringARB))
WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc)); WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc));
if (NULL == WGL_Extensions) { if (!WGL_Extensions)
{
ERR(" WGL_Extensions returns NULL\n"); ERR(" WGL_Extensions returns NULL\n");
} else { }
else
{
TRACE_(d3d_caps)("WGL_Extensions reported:\n"); TRACE_(d3d_caps)("WGL_Extensions reported:\n");
while (*WGL_Extensions != 0x00) { while (*WGL_Extensions)
{
const char *Start; const char *Start;
char ThisExtn[256]; char ThisExtn[256];
while (isspace(*WGL_Extensions)) WGL_Extensions++; while (isspace(*WGL_Extensions)) WGL_Extensions++;
Start = WGL_Extensions; Start = WGL_Extensions;
while (!isspace(*WGL_Extensions) && *WGL_Extensions != 0x00) { while (!isspace(*WGL_Extensions) && *WGL_Extensions) ++WGL_Extensions;
WGL_Extensions++;
}
len = WGL_Extensions - Start; len = WGL_Extensions - Start;
if (len == 0 || len >= sizeof(ThisExtn)) if (!len || len >= sizeof(ThisExtn))
continue; continue;
memcpy(ThisExtn, Start, len); memcpy(ThisExtn, Start, len);
@ -2885,7 +2890,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
} }
} }
if (i == 0) if (!i)
{ {
TRACE_(d3d_caps)("No modes found for format (%x - %s)\n", format_id, debug_d3dformat(format_id)); TRACE_(d3d_caps)("No modes found for format (%x - %s)\n", format_id, debug_d3dformat(format_id));
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -2928,10 +2933,8 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT A
{ {
TRACE("iface %p, adapter_idx %u, display_mode %p.\n", iface, Adapter, pMode); TRACE("iface %p, adapter_idx %u, display_mode %p.\n", iface, Adapter, pMode);
if (NULL == pMode || if (!pMode || Adapter >= IWineD3D_GetAdapterCount(iface))
Adapter >= IWineD3D_GetAdapterCount(iface)) {
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */ if (Adapter == 0) { /* Display */
int bpp = 0; int bpp = 0;

View File

@ -221,8 +221,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
*/ */
/* For indexed data, we need to go a few more strides in */ /* For indexed data, we need to go a few more strides in */
if (idxData != NULL) { if (idxData)
{
/* Indexed so work out the number of strides to skip */ /* Indexed so work out the number of strides to skip */
if (idxSize == 2) if (idxSize == 2)
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex; SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
@ -284,7 +284,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
} }
/* Normal -------------------------------- */ /* Normal -------------------------------- */
if (normal != NULL) { if (normal)
{
const void *ptrToCoords = normal + SkipnStrides * si->elements[WINED3D_FFP_NORMAL].stride; const void *ptrToCoords = normal + SkipnStrides * si->elements[WINED3D_FFP_NORMAL].stride;
normal_funcs[si->elements[WINED3D_FFP_NORMAL].format->emit_idx](ptrToCoords); normal_funcs[si->elements[WINED3D_FFP_NORMAL].format->emit_idx](ptrToCoords);
} }
@ -296,9 +297,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
} }
/* For non indexed mode, step onto next parts */ /* For non indexed mode, step onto next parts */
if (idxData == NULL) { if (!idxData) ++SkipnStrides;
++SkipnStrides;
}
} }
glEnd(); glEnd();
@ -450,9 +449,10 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
/* Start drawing in GL */ /* Start drawing in GL */
glBegin(glPrimitiveType); glBegin(glPrimitiveType);
for (vx_index = 0; vx_index < numberOfVertices; ++vx_index) { for (vx_index = 0; vx_index < numberOfVertices; ++vx_index)
if (idxData != NULL) { {
if (idxData)
{
/* Indexed so work out the number of strides to skip */ /* Indexed so work out the number of strides to skip */
if (idxSize == 2) if (idxSize == 2)
SkipnStrides = pIdxBufS[startIdx + vx_index] + stateblock->loadBaseVertexIndex; SkipnStrides = pIdxBufS[startIdx + vx_index] + stateblock->loadBaseVertexIndex;
@ -487,7 +487,8 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DStateBlockImpl *stateblock = This->stateBlock; IWineD3DStateBlockImpl *stateblock = This->stateBlock;
if (idxSize == 0) { if (!idxSize)
{
/* This is a nasty thing. MSDN says no hardware supports that and apps have to use software vertex processing. /* This is a nasty thing. MSDN says no hardware supports that and apps have to use software vertex processing.
* We don't support this for now * We don't support this for now
* *
@ -501,16 +502,17 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine
TRACE("(%p) : glElements(%x, %d, ...)\n", This, glPrimitiveType, numberOfVertices); TRACE("(%p) : glElements(%x, %d, ...)\n", This, glPrimitiveType, numberOfVertices);
/* First, figure out how many instances we have to draw */ /* First, figure out how many instances we have to draw */
for(i = 0; i < MAX_STREAMS; i++) { for (i = 0; i < MAX_STREAMS; ++i)
{
/* Look at the streams and take the first one which matches */ /* Look at the streams and take the first one which matches */
if(((stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INSTANCEDATA) || (stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INDEXEDDATA)) && stateblock->streamSource[i]) { if (stateblock->streamSource[i] && ((stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INSTANCEDATA)
/* D3D9 could set streamFreq 0 with (INSTANCEDATA or INDEXEDDATA) and then it is handled as 1. See d3d9/tests/visual.c-> stream_test() */ || (stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INDEXEDDATA)))
if(stateblock->streamFreq[i] == 0){ {
numInstances = 1; /* Use the specified number of instances from the first matched
} else { * stream. A streamFreq of 0 (with INSTANCEDATA or INDEXEDDATA)
numInstances = stateblock->streamFreq[i]; /* use the specified number of instances from the first matched stream. See d3d9/tests/visual.c-> stream_test() */ * is handled as 1. See d3d9/tests/visual.c-> stream_test(). */
} numInstances = stateblock->streamFreq[i] ? stateblock->streamFreq[i] : 1;
break; /* break, because only the first suitable value is interesting */ break;
} }
} }

View File

@ -232,8 +232,10 @@ static void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLhandleA
GL_EXTCALL(glGetInfoLogARB(obj, infologLength, NULL, infoLog)); GL_EXTCALL(glGetInfoLogARB(obj, infologLength, NULL, infoLog));
is_spam = FALSE; is_spam = FALSE;
for(i = 0; i < sizeof(spam) / sizeof(spam[0]); i++) { for (i = 0; i < sizeof(spam) / sizeof(*spam); ++i)
if(strcmp(infoLog, spam[i]) == 0) { {
if (!strcmp(infoLog, spam[i]))
{
is_spam = TRUE; is_spam = TRUE;
break; break;
} }
@ -1374,7 +1376,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
} }
else else
{ {
if (reg->idx == 0) strcpy(register_name, "gl_Color"); if (!reg->idx) strcpy(register_name, "gl_Color");
else strcpy(register_name, "gl_SecondaryColor"); else strcpy(register_name, "gl_SecondaryColor");
break; break;
} }
@ -1442,7 +1444,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
break; break;
case WINED3DSPR_ATTROUT: case WINED3DSPR_ATTROUT:
if (reg->idx == 0) sprintf(register_name, "OUT[8]"); if (!reg->idx) sprintf(register_name, "OUT[8]");
else sprintf(register_name, "OUT[9]"); else sprintf(register_name, "OUT[9]");
break; break;
@ -1452,7 +1454,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
break; break;
case WINED3DSPR_MISCTYPE: case WINED3DSPR_MISCTYPE:
if (reg->idx == 0) if (!reg->idx)
{ {
/* vPos */ /* vPos */
sprintf(register_name, "vpos"); sprintf(register_name, "vpos");
@ -3655,7 +3657,7 @@ static void shader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_sh
} }
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{ {
if (semantic_idx == 0) if (!semantic_idx)
shader_addline(buffer, "IN[%u]%s = vec4(gl_Color)%s;\n", shader_addline(buffer, "IN[%u]%s = vec4(gl_Color)%s;\n",
This->input_reg_map[i], reg_mask, reg_mask); This->input_reg_map[i], reg_mask, reg_mask);
else if (semantic_idx == 1) else if (semantic_idx == 1)
@ -3851,7 +3853,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{ {
if (semantic_idx == 0) if (!semantic_idx)
shader_addline(buffer, "gl_FrontColor%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n", shader_addline(buffer, "gl_FrontColor%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
reg_mask, i, reg_mask); reg_mask, i, reg_mask);
else if (semantic_idx == 1) else if (semantic_idx == 1)
@ -4147,9 +4149,11 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
* so a linear search is more performant than a hashmap or a binary search * so a linear search is more performant than a hashmap or a binary search
* (cache coherency etc) * (cache coherency etc)
*/ */
for(i = 0; i < shader_data->num_gl_shaders; i++) { for (i = 0; i < shader_data->num_gl_shaders; ++i)
if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) { {
if(args->np2_fixup) *np2fixup_info = &shader_data->gl_shaders[i].np2fixup; if (!memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)))
{
if (args->np2_fixup) *np2fixup_info = &shader_data->gl_shaders[i].np2fixup;
return shader_data->gl_shaders[i].prgId; return shader_data->gl_shaders[i].prgId;
} }
} }
@ -4674,7 +4678,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
if(pshader) { if(pshader) {
struct glsl_pshader_private *shader_data; struct glsl_pshader_private *shader_data;
shader_data = This->baseShader.backend_data; shader_data = This->baseShader.backend_data;
if(!shader_data || shader_data->num_gl_shaders == 0) if (!shader_data || !shader_data->num_gl_shaders)
{ {
HeapFree(GetProcessHeap(), 0, shader_data); HeapFree(GetProcessHeap(), 0, shader_data);
This->baseShader.backend_data = NULL; This->baseShader.backend_data = NULL;
@ -4693,7 +4697,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
} else { } else {
struct glsl_vshader_private *shader_data; struct glsl_vshader_private *shader_data;
shader_data = This->baseShader.backend_data; shader_data = This->baseShader.backend_data;
if(!shader_data || shader_data->num_gl_shaders == 0) if (!shader_data || !shader_data->num_gl_shaders)
{ {
HeapFree(GetProcessHeap(), 0, shader_data); HeapFree(GetProcessHeap(), 0, shader_data);
This->baseShader.backend_data = NULL; This->baseShader.backend_data = NULL;

View File

@ -92,7 +92,7 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW
TRACE("(%p)->(%08x,%d,%d,%p)\n",This,Flags,Start,Count,PalEnt); TRACE("(%p)->(%08x,%d,%d,%p)\n",This,Flags,Start,Count,PalEnt);
if (Flags != 0) return WINED3DERR_INVALIDCALL; /* unchecked */ if (Flags) return WINED3DERR_INVALIDCALL; /* unchecked */
if (Start + Count > IWineD3DPaletteImpl_Size(This->Flags)) if (Start + Count > IWineD3DPaletteImpl_Size(This->Flags))
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -149,8 +149,8 @@ static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
#if 0 #if 0
/* Now, if we are in 'depth conversion mode', update the screen palette */ /* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */ /* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d->palette_convert != NULL) if (This->ddraw->d->palette_convert)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count); This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
#endif #endif
/* If the palette is attached to the render target, update all render targets */ /* If the palette is attached to the render target, update all render targets */

View File

@ -46,7 +46,7 @@ enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_qu
TRACE("(%p) : device %p\n", query, device); TRACE("(%p) : device %p\n", query, device);
if (query->context == NULL) if (!query->context)
{ {
TRACE("Query not started\n"); TRACE("Query not started\n");
return WINED3D_EVENT_QUERY_NOT_STARTED; return WINED3D_EVENT_QUERY_NOT_STARTED;
@ -259,7 +259,9 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
ULONG ref; ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref); TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
if (!ref)
{
/* Queries are specific to the GL context that created them. Not /* Queries are specific to the GL context that created them. Not
* deleting the query will obviously leak it, but that's still better * deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this * than potentially deleting a different query with the same id in this

View File

@ -139,7 +139,7 @@ HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
resource_free_private_data(iface, refguid); resource_free_private_data(iface, refguid);
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
if (NULL == data) return E_OUTOFMEMORY; if (!data) return E_OUTOFMEMORY;
data->tag = *refguid; data->tag = *refguid;
data->flags = Flags; data->flags = Flags;
@ -157,7 +157,8 @@ HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
else else
{ {
data->ptr.data = HeapAlloc(GetProcessHeap(), 0, SizeOfData); data->ptr.data = HeapAlloc(GetProcessHeap(), 0, SizeOfData);
if (NULL == data->ptr.data) { if (!data->ptr.data)
{
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
@ -176,7 +177,7 @@ HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID refguid, void
TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData); TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData);
data = resource_find_private_data(This, refguid); data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND; if (!data) return WINED3DERR_NOTFOUND;
if (*pSizeOfData < data->size) { if (*pSizeOfData < data->size) {
*pSizeOfData = data->size; *pSizeOfData = data->size;
@ -207,13 +208,15 @@ HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID refguid)
TRACE("(%p) : %s\n", This, debugstr_guid(refguid)); TRACE("(%p) : %s\n", This, debugstr_guid(refguid));
data = resource_find_private_data(This, refguid); data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND; if (!data) return WINED3DERR_NOTFOUND;
if (data->flags & WINED3DSPD_IUNKNOWN) if (data->flags & WINED3DSPD_IUNKNOWN)
{ {
if (data->ptr.object != NULL) if (data->ptr.object)
IUnknown_Release(data->ptr.object); IUnknown_Release(data->ptr.object);
} else { }
else
{
HeapFree(GetProcessHeap(), 0, data->ptr.data); HeapFree(GetProcessHeap(), 0, data->ptr.data);
} }
list_remove(&data->entry); list_remove(&data->entry);

View File

@ -378,7 +378,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct
case WINED3DSPR_MISCTYPE: case WINED3DSPR_MISCTYPE:
if (shader_type == WINED3D_SHADER_TYPE_PIXEL) if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
{ {
if (reg->idx == 0) reg_maps->vpos = 1; if (!reg->idx) reg_maps->vpos = 1;
else if (reg->idx == 1) reg_maps->usesfacing = 1; else if (reg->idx == 1) reg_maps->usesfacing = 1;
} }
break; break;
@ -721,7 +721,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
{ {
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader; IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader;
if (dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) if (dst_param.reg.type == WINED3DSPR_COLOROUT && !dst_param.reg.idx)
{ {
/* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
* COLOROUT 0. If we know this in advance, the ARB shader backend can skip * COLOROUT 0. If we know this in advance, the ARB shader backend can skip
@ -885,7 +885,7 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti
break; break;
case WINED3DDECLUSAGE_COLOR: case WINED3DDECLUSAGE_COLOR:
if (semantic->usage_idx == 0) TRACE("color"); if (!semantic->usage_idx) TRACE("color");
else TRACE("specular%u", (semantic->usage_idx - 1)); else TRACE("specular%u", (semantic->usage_idx - 1));
break; break;

View File

@ -2027,7 +2027,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if
op = WINED3DTOP_SELECTARG1; op = WINED3DTOP_SELECTARG1;
} }
if (isAlpha && This->stateBlock->textures[Stage] == NULL && arg1 == WINED3DTA_TEXTURE) { if (isAlpha && !This->stateBlock->textures[Stage] && arg1 == WINED3DTA_TEXTURE)
{
get_src_and_opr(WINED3DTA_DIFFUSE, isAlpha, &src1, &opr1); get_src_and_opr(WINED3DTA_DIFFUSE, isAlpha, &src1, &opr1);
} else { } else {
get_src_and_opr(arg1, isAlpha, &src1, &opr1); get_src_and_opr(arg1, isAlpha, &src1, &opr1);
@ -3099,7 +3100,7 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d
arg2 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG2]; arg2 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG2];
arg0 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG0]; arg0 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG0];
if (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && stage == 0 && stateblock->textures[0]) if (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && !stage && stateblock->textures[0])
{ {
UINT texture_dimensions = IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[0]); UINT texture_dimensions = IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[0]);
@ -3475,9 +3476,9 @@ static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) static void tex_bumpenvlscale(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);
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
if (stateblock->pixelShader && stage != 0 if (stateblock->pixelShader && stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
&& (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.luminanceparams & (1 << stage)))
{ {
/* The pixel shader has to know the luminance scale. Do a constants update if it /* The pixel shader has to know the luminance scale. Do a constants update if it
* isn't scheduled anyway * isn't scheduled anyway
@ -3563,7 +3564,8 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
if (!use_ps(stateblock) && sampler < stateblock->lowest_disabled_stage) if (!use_ps(stateblock) && sampler < stateblock->lowest_disabled_stage)
{ {
if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) { if (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && !sampler)
{
/* If color keying is enabled update the alpha test, it depends on the existence /* If color keying is enabled update the alpha test, it depends on the existence
* of a color key in stage 0 * of a color key in stage 0
*/ */
@ -3581,9 +3583,11 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
} }
else if (mapped_stage < gl_info->limits.textures) else if (mapped_stage < gl_info->limits.textures)
{ {
if(sampler < stateblock->lowest_disabled_stage) { if (sampler < stateblock->lowest_disabled_stage)
{
/* TODO: What should I do with pixel shaders here ??? */ /* TODO: What should I do with pixel shaders here ??? */
if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) { if (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && !sampler)
{
/* If color keying is enabled update the alpha test, it depends on the existence /* If color keying is enabled update the alpha test, it depends on the existence
* of a color key in stage 0 * of a color key in stage 0
*/ */
@ -3642,8 +3646,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 IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
&& (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage)))
if (stateblock->pixelShader && stage && (ps->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
@ -4837,7 +4842,8 @@ static void indexbuffer(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
if(stateblock->streamIsUP || stateblock->pIndexData == NULL ) { if (stateblock->streamIsUP || !stateblock->pIndexData)
{
GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0)); GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
} else { } else {
struct wined3d_buffer *ib = (struct wined3d_buffer *) stateblock->pIndexData; struct wined3d_buffer *ib = (struct wined3d_buffer *) stateblock->pIndexData;

View File

@ -1222,10 +1222,10 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
for (i = 0; i < MAX_TEXTURES; i++) { for (i = 0; i < MAX_TEXTURES; i++) {
TRACE("Setting up default texture states for texture Stage %d\n", i); TRACE("Setting up default texture states for texture Stage %d\n", i);
memcpy(&This->transforms[WINED3DTS_TEXTURE0 + i], identity, sizeof(identity)); memcpy(&This->transforms[WINED3DTS_TEXTURE0 + i], identity, sizeof(identity));
This->textureState[i][WINED3DTSS_COLOROP ] = (i==0)? WINED3DTOP_MODULATE : WINED3DTOP_DISABLE; This->textureState[i][WINED3DTSS_COLOROP ] = i ? WINED3DTOP_DISABLE : WINED3DTOP_MODULATE;
This->textureState[i][WINED3DTSS_COLORARG1 ] = WINED3DTA_TEXTURE; This->textureState[i][WINED3DTSS_COLORARG1 ] = WINED3DTA_TEXTURE;
This->textureState[i][WINED3DTSS_COLORARG2 ] = WINED3DTA_CURRENT; This->textureState[i][WINED3DTSS_COLORARG2 ] = WINED3DTA_CURRENT;
This->textureState[i][WINED3DTSS_ALPHAOP ] = (i==0)? WINED3DTOP_SELECTARG1 : WINED3DTOP_DISABLE; This->textureState[i][WINED3DTSS_ALPHAOP ] = i ? WINED3DTOP_DISABLE : WINED3DTOP_SELECTARG1;
This->textureState[i][WINED3DTSS_ALPHAARG1 ] = WINED3DTA_TEXTURE; This->textureState[i][WINED3DTSS_ALPHAARG1 ] = WINED3DTA_TEXTURE;
This->textureState[i][WINED3DTSS_ALPHAARG2 ] = WINED3DTA_CURRENT; This->textureState[i][WINED3DTSS_ALPHAARG2 ] = WINED3DTA_CURRENT;
This->textureState[i][WINED3DTSS_BUMPENVMAT00 ] = 0; This->textureState[i][WINED3DTSS_BUMPENVMAT00 ] = 0;
@ -1269,7 +1269,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */ /* check the return values, because the GetBackBuffer call isn't valid for ddraw */
hr = IWineD3DDevice_GetSwapChain(device, 0, &swapchain); hr = IWineD3DDevice_GetSwapChain(device, 0, &swapchain);
if( hr == WINED3D_OK && swapchain != NULL) { if (SUCCEEDED(hr) && swapchain)
{
WINED3DVIEWPORT vp; WINED3DVIEWPORT vp;
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer); hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);

View File

@ -826,7 +826,9 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
if (gl_info->supported[APPLE_CLIENT_STORAGE]) if (gl_info->supported[APPLE_CLIENT_STORAGE])
{ {
if(This->Flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED) || This->resource.allocatedMemory == NULL) { if (This->Flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED)
|| !This->resource.allocatedMemory)
{
/* In some cases we want to disable client storage. /* In some cases we want to disable client storage.
* SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches * SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches
* SFLAG_DIBSECTION: Dibsections may have read / write protections on the memory. Avoid issues... * SFLAG_DIBSECTION: Dibsections may have read / write protections on the memory. Avoid issues...
@ -1356,7 +1358,8 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
if(This->Flags & SFLAG_PBO) { if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB"); checkGLcall("glBindBufferARB");
if(mem != NULL) { if (mem)
{
ERR("mem not null for pbo -- unexpected\n"); ERR("mem not null for pbo -- unexpected\n");
mem = NULL; mem = NULL;
} }
@ -1604,9 +1607,8 @@ static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This)
GL_EXTCALL(glGenBuffersARB(1, &This->pbo)); GL_EXTCALL(glGenBuffersARB(1, &This->pbo));
error = glGetError(); error = glGetError();
if(This->pbo == 0 || error != GL_NO_ERROR) { if (!This->pbo || error != GL_NO_ERROR)
ERR("Failed to bind the PBO with error %s (%#x)\n", debug_glerror(error), error); ERR("Failed to bind the PBO with error %s (%#x)\n", debug_glerror(error), error);
}
TRACE("Attaching pbo=%#x to (%p)\n", This->pbo, This); TRACE("Attaching pbo=%#x to (%p)\n", This->pbo, This);
@ -1684,7 +1686,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
/* surface_load_location() does not check if the rectangle specifies /* surface_load_location() does not check if the rectangle specifies
* the full surface. Most callers don't need that, so do it here. */ * the full surface. Most callers don't need that, so do it here. */
if (pRect && pRect->top == 0 && pRect->left == 0 if (pRect && !pRect->top && !pRect->left
&& pRect->right == This->currentDesc.Width && pRect->right == This->currentDesc.Width
&& pRect->bottom == This->currentDesc.Height) && pRect->bottom == This->currentDesc.Height)
{ {
@ -1894,10 +1896,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
goto unlock_end; goto unlock_end;
} }
if(This->dirtyRect.left == 0 && if (!This->dirtyRect.left && !This->dirtyRect.top
This->dirtyRect.top == 0 && && This->dirtyRect.right == This->currentDesc.Width
This->dirtyRect.right == This->currentDesc.Width && && This->dirtyRect.bottom == This->currentDesc.Height)
This->dirtyRect.bottom == This->currentDesc.Height) { {
fullsurface = TRUE; fullsurface = TRUE;
} else { } else {
/* TODO: Proper partial rectangle tracking */ /* TODO: Proper partial rectangle tracking */
@ -2324,14 +2326,9 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
case CONVERT_PALETTED: case CONVERT_PALETTED:
case CONVERT_PALETTED_CK: case CONVERT_PALETTED_CK:
{ {
IWineD3DPaletteImpl* pal = This->palette;
BYTE table[256][4]; BYTE table[256][4];
unsigned int x, y; unsigned int x, y;
if( pal == NULL) {
/* TODO: If we are a sublevel, try to get the palette from level 0 */
}
d3dfmt_p8_init_palette(This, table, (convert == CONVERT_PALETTED_CK)); d3dfmt_p8_init_palette(This, table, (convert == CONVERT_PALETTED_CK));
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
@ -2656,7 +2653,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *M
/* LockRect and GetDC will re-create the dib section and allocated memory */ /* LockRect and GetDC will re-create the dib section and allocated memory */
This->resource.allocatedMemory = NULL; This->resource.allocatedMemory = NULL;
/* HeapMemory should be NULL already */ /* HeapMemory should be NULL already */
if(This->resource.heapMemory != NULL) ERR("User pointer surface has heap memory allocated\n"); if (This->resource.heapMemory)
ERR("User pointer surface has heap memory allocated.\n");
This->Flags &= ~SFLAG_USERPTR; This->Flags &= ~SFLAG_USERPTR;
if (This->Flags & SFLAG_CLIENT) if (This->Flags & SFLAG_CLIENT)
@ -2783,7 +2781,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS
/* Just overwrite the swapchain presentation interval. This is ok because only ddraw apps can call Flip, /* Just overwrite the swapchain presentation interval. This is ok because only ddraw apps can call Flip,
* and only d3d8 and d3d9 apps specify the presentation interval * and only d3d8 and d3d9 apps specify the presentation interval
*/ */
if((Flags & (WINEDDFLIP_NOVSYNC | WINEDDFLIP_INTERVAL2 | WINEDDFLIP_INTERVAL3 | WINEDDFLIP_INTERVAL4)) == 0) { if (!(Flags & (WINEDDFLIP_NOVSYNC | WINEDDFLIP_INTERVAL2 | WINEDDFLIP_INTERVAL3 | WINEDDFLIP_INTERVAL4)))
{
/* Most common case first to avoid wasting time on all the other cases */ /* Most common case first to avoid wasting time on all the other cases */
swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_ONE; swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_ONE;
} else if(Flags & WINEDDFLIP_NOVSYNC) { } else if(Flags & WINEDDFLIP_NOVSYNC) {
@ -3492,7 +3491,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
TRACE("Yes\n"); TRACE("Yes\n");
/* These flags are unimportant for the flag check, remove them */ /* These flags are unimportant for the flag check, remove them */
if((Flags & ~(WINEDDBLT_DONOTWAIT | WINEDDBLT_WAIT)) == 0) { if (!(Flags & ~(WINEDDBLT_DONOTWAIT | WINEDDBLT_WAIT)))
{
WINED3DSWAPEFFECT orig_swap = dstSwapchain->presentParms.SwapEffect; WINED3DSWAPEFFECT orig_swap = dstSwapchain->presentParms.SwapEffect;
/* The idea behind this is that a glReadPixels and a glDrawPixels call /* The idea behind this is that a glReadPixels and a glDrawPixels call

View File

@ -219,16 +219,16 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD
return WINED3D_OK; return WINED3D_OK;
} }
if(This->palette != NULL) if (This->palette)
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
This->palette->Flags &= ~WINEDDPCAPS_PRIMARYSURFACE; This->palette->Flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
This->palette = PalImpl; This->palette = PalImpl;
if(PalImpl != NULL) { if (PalImpl)
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) { {
(PalImpl)->Flags |= WINEDDPCAPS_PRIMARYSURFACE; if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
} PalImpl->Flags |= WINEDDPCAPS_PRIMARYSURFACE;
return IWineD3DSurface_RealizePalette(iface); return IWineD3DSurface_RealizePalette(iface);
} }
@ -240,7 +240,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey); TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
if ((Flags & WINEDDCKEY_COLORSPACE) != 0) { if (Flags & WINEDDCKEY_COLORSPACE)
{
FIXME(" colorkey value not supported (%08x) !\n", Flags); FIXME(" colorkey value not supported (%08x) !\n", Flags);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@ -359,7 +360,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface
TRACE("(%p): Not an overlay surface\n", This); TRACE("(%p): Not an overlay surface\n", This);
return WINEDDERR_NOTAOVERLAYSURFACE; return WINEDDERR_NOTAOVERLAYSURFACE;
} }
if(This->overlay_dest == NULL) {
if (!This->overlay_dest)
{
*X = 0; *Y = 0; *X = 0; *Y = 0;
hr = WINEDDERR_OVERLAYNOTVISIBLE; hr = WINEDDERR_OVERLAYNOTVISIBLE;
} else { } else {
@ -587,8 +590,8 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
break; break;
} }
ddc = GetDC(0); if (!(ddc = GetDC(0)))
if (ddc == 0) { {
HeapFree(GetProcessHeap(), 0, b_info); HeapFree(GetProcessHeap(), 0, b_info);
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
@ -1812,7 +1815,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DL
pLockedRect->Pitch = IWineD3DSurface_GetPitch(iface); pLockedRect->Pitch = IWineD3DSurface_GetPitch(iface);
if (NULL == pRect) if (!pRect)
{ {
pLockedRect->pBits = This->resource.allocatedMemory; pLockedRect->pBits = This->resource.allocatedMemory;
This->lockedRect.left = 0; This->lockedRect.left = 0;

View File

@ -453,10 +453,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
if (This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE if (This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE
&& gl_info->supported[SGI_VIDEO_SYNC]) && gl_info->supported[SGI_VIDEO_SYNC])
{ {
retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync)); if ((retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync))))
if(retval != 0) {
ERR("glXGetVideoSyncSGI failed(retval = %d\n", retval); ERR("glXGetVideoSyncSGI failed(retval = %d\n", retval);
}
switch(This->presentParms.PresentationInterval) { switch(This->presentParms.PresentationInterval) {
case WINED3DPRESENT_INTERVAL_DEFAULT: case WINED3DPRESENT_INTERVAL_DEFAULT:

View File

@ -60,9 +60,9 @@ ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface)
DWORD refCount; DWORD refCount;
refCount = InterlockedDecrement(&This->ref); refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, refCount); TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
if (refCount == 0) {
IWineD3DSwapChain_Destroy(iface); if (!refCount) IWineD3DSwapChain_Destroy(iface);
}
return refCount; return refCount;
} }

View File

@ -2800,7 +2800,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
aarg0 = (args[aop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG0] : ARG_UNUSED; aarg0 = (args[aop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG0] : ARG_UNUSED;
} }
if (i == 0 && stateblock->textures[0] && stateblock->renderState[WINED3DRS_COLORKEYENABLE]) if (!i && stateblock->textures[0] && stateblock->renderState[WINED3DRS_COLORKEYENABLE])
{ {
UINT texture_dimensions = IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[0]); UINT texture_dimensions = IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[0]);

View File

@ -129,7 +129,9 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
ULONG ref; ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref); TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref); ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
if (!ref)
{
resource_cleanup((IWineD3DResource *)iface); resource_cleanup((IWineD3DResource *)iface);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent); This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);

View File

@ -102,19 +102,19 @@ IWineD3D * WINAPI WineDirect3DCreate(UINT version, void *parent)
return (IWineD3D *)object; return (IWineD3D *)object;
} }
static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char* name, char* buffer, DWORD size) static DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
{ {
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0; if (appkey && !RegQueryValueExA(appkey, name, 0, NULL, (BYTE *)buffer, &size)) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0; if (defkey && !RegQueryValueExA(defkey, name, 0, NULL, (BYTE *)buffer, &size)) return 0;
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
} }
static inline DWORD get_config_key_dword(HKEY defkey, HKEY appkey, const char* name, DWORD *data) static DWORD get_config_key_dword(HKEY defkey, HKEY appkey, const char *name, DWORD *data)
{ {
DWORD type; DWORD type;
DWORD size = sizeof(DWORD); DWORD size = sizeof(DWORD);
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0; if (appkey && !RegQueryValueExA(appkey, name, 0, &type, (BYTE *)data, &size) && (type == REG_DWORD)) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0; if (defkey && !RegQueryValueExA(defkey, name, 0, &type, (BYTE *)data, &size) && (type == REG_DWORD)) return 0;
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
} }
@ -200,7 +200,7 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
} }
} }
if ( 0 != hkey || 0 != appkey ) if (hkey || appkey)
{ {
if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) ) if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) )
{ {

View File

@ -2805,7 +2805,7 @@ static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
{ {
case WINED3DSPR_RASTOUT: case WINED3DSPR_RASTOUT:
/* oFog & oPts */ /* oFog & oPts */
if (reg->idx != 0) return TRUE; if (reg->idx) return TRUE;
/* oPos */ /* oPos */
return FALSE; return FALSE;