Commit b68d2577 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent fd7c1cbf
......@@ -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.
* If we're reading from current
*/
if(stage == 0) {
ret = GL_PRIMARY_COLOR;
} else {
ret = GL_REG_0_ATI;
}
ret = stage ? GL_REG_0_ATI : GL_PRIMARY_COLOR;
break;
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 */
for(stage = 0; stage < MAX_TEXTURES; stage++) {
if(op[stage].cop == WINED3DTOP_DISABLE) {
if(stage == 0) {
for (stage = 0; stage < MAX_TEXTURES; ++stage)
{
if (op[stage].cop == WINED3DTOP_DISABLE)
{
if (!stage)
{
/* Handle complete texture disabling gracefully */
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, 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) {
case WINED3DTOP_DISABLE:
/* 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,
GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
}
......
......@@ -277,7 +277,8 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
ENTER_GL();
/* Generate a texture name if we don't already have one */
if (gl_tex->name == 0) {
if (!gl_tex->name)
{
*set_surface_desc = TRUE;
glGenTextures(1, &gl_tex->name);
checkGLcall("glGenTextures");
......@@ -319,7 +320,8 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
}
/* Bind the texture */
if (gl_tex->name != 0) {
if (gl_tex->name)
{
glBindTexture(textureDimensions, gl_tex->name);
checkGLcall("glBindTexture");
if (isNewTexture) {
......
......@@ -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)
{
return This->modified_areas != 0;
return !!This->modified_areas;
}
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++)
{
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;
}
......@@ -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 (stride_this_run == 0 && This->conversion_map)
if (!stride_this_run && This->conversion_map)
{
/* Sanity test */
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.
* This is also needed to prevent Map from returning garbage on
* 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");
return WINED3D_OK;
......
......@@ -63,12 +63,9 @@ static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
else return ref;
if (!ref) HeapFree(GetProcessHeap(), 0, This);
return ref;
}
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;
if (warned++ < 10 || rgn == NULL)
if (warned++ < 10 || !rgn)
FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags);
return WINED3D_OK;
......
......@@ -375,7 +375,9 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
if (!ref)
{
unsigned int 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(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(testcode), testcode));
if(glGetError() != 0) {
if (glGetError())
{
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)));
ret = TRUE;
......@@ -2719,22 +2722,24 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
if(GL_EXTCALL(wglGetExtensionsStringARB))
WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc));
if (NULL == WGL_Extensions) {
if (!WGL_Extensions)
{
ERR(" WGL_Extensions returns NULL\n");
} else {
}
else
{
TRACE_(d3d_caps)("WGL_Extensions reported:\n");
while (*WGL_Extensions != 0x00) {
while (*WGL_Extensions)
{
const char *Start;
char ThisExtn[256];
while (isspace(*WGL_Extensions)) WGL_Extensions++;
Start = WGL_Extensions;
while (!isspace(*WGL_Extensions) && *WGL_Extensions != 0x00) {
WGL_Extensions++;
}
while (!isspace(*WGL_Extensions) && *WGL_Extensions) ++WGL_Extensions;
len = WGL_Extensions - Start;
if (len == 0 || len >= sizeof(ThisExtn))
if (!len || len >= sizeof(ThisExtn))
continue;
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));
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);
if (NULL == pMode ||
Adapter >= IWineD3D_GetAdapterCount(iface)) {
if (!pMode || Adapter >= IWineD3D_GetAdapterCount(iface))
return WINED3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
int bpp = 0;
......
......@@ -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 */
if (idxData != NULL) {
if (idxData)
{
/* Indexed so work out the number of strides to skip */
if (idxSize == 2)
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
......@@ -284,7 +284,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
}
/* Normal -------------------------------- */
if (normal != NULL) {
if (normal)
{
const void *ptrToCoords = normal + SkipnStrides * si->elements[WINED3D_FFP_NORMAL].stride;
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 */
if (idxData == NULL) {
++SkipnStrides;
}
if (!idxData) ++SkipnStrides;
}
glEnd();
......@@ -450,9 +449,10 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
/* Start drawing in GL */
glBegin(glPrimitiveType);
for (vx_index = 0; vx_index < numberOfVertices; ++vx_index) {
if (idxData != NULL) {
for (vx_index = 0; vx_index < numberOfVertices; ++vx_index)
{
if (idxData)
{
/* Indexed so work out the number of strides to skip */
if (idxSize == 2)
SkipnStrides = pIdxBufS[startIdx + vx_index] + stateblock->loadBaseVertexIndex;
......@@ -487,7 +487,8 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
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.
* 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);
/* 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 */
if(((stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INSTANCEDATA) || (stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INDEXEDDATA)) && stateblock->streamSource[i]) {
/* D3D9 could set streamFreq 0 with (INSTANCEDATA or INDEXEDDATA) and then it is handled as 1. See d3d9/tests/visual.c-> stream_test() */
if(stateblock->streamFreq[i] == 0){
numInstances = 1;
} else {
numInstances = stateblock->streamFreq[i]; /* use the specified number of instances from the first matched stream. See d3d9/tests/visual.c-> stream_test() */
}
break; /* break, because only the first suitable value is interesting */
if (stateblock->streamSource[i] && ((stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INSTANCEDATA)
|| (stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INDEXEDDATA)))
{
/* Use the specified number of instances from the first matched
* stream. A streamFreq of 0 (with INSTANCEDATA or INDEXEDDATA)
* is handled as 1. See d3d9/tests/visual.c-> stream_test(). */
numInstances = stateblock->streamFreq[i] ? stateblock->streamFreq[i] : 1;
break;
}
}
......
......@@ -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));
is_spam = FALSE;
for(i = 0; i < sizeof(spam) / sizeof(spam[0]); i++) {
if(strcmp(infoLog, spam[i]) == 0) {
for (i = 0; i < sizeof(spam) / sizeof(*spam); ++i)
{
if (!strcmp(infoLog, spam[i]))
{
is_spam = TRUE;
break;
}
......@@ -1374,7 +1376,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
}
else
{
if (reg->idx == 0) strcpy(register_name, "gl_Color");
if (!reg->idx) strcpy(register_name, "gl_Color");
else strcpy(register_name, "gl_SecondaryColor");
break;
}
......@@ -1442,7 +1444,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
break;
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]");
break;
......@@ -1452,7 +1454,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
break;
case WINED3DSPR_MISCTYPE:
if (reg->idx == 0)
if (!reg->idx)
{
/* 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))
{
if (semantic_idx == 0)
if (!semantic_idx)
shader_addline(buffer, "IN[%u]%s = vec4(gl_Color)%s;\n",
This->input_reg_map[i], reg_mask, reg_mask);
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 (semantic_idx == 0)
if (!semantic_idx)
shader_addline(buffer, "gl_FrontColor%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
reg_mask, i, reg_mask);
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
* (cache coherency etc)
*/
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;
for (i = 0; i < shader_data->num_gl_shaders; ++i)
{
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;
}
}
......@@ -4674,7 +4678,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
if(pshader) {
struct glsl_pshader_private *shader_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);
This->baseShader.backend_data = NULL;
......@@ -4693,7 +4697,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
} else {
struct glsl_vshader_private *shader_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);
This->baseShader.backend_data = NULL;
......
......@@ -92,7 +92,7 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW
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))
return WINED3DERR_INVALIDCALL;
......@@ -149,8 +149,8 @@ static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
#if 0
/* 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. */
if (This->ddraw->d->palette_convert != NULL)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
if (This->ddraw->d->palette_convert)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
#endif
/* If the palette is attached to the render target, update all render targets */
......
......@@ -46,7 +46,7 @@ enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_qu
TRACE("(%p) : device %p\n", query, device);
if (query->context == NULL)
if (!query->context)
{
TRACE("Query not started\n");
return WINED3D_EVENT_QUERY_NOT_STARTED;
......@@ -259,7 +259,9 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
if (!ref)
{
/* Queries are specific to the GL context that created them. Not
* deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this
......
......@@ -139,7 +139,7 @@ HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
resource_free_private_data(iface, refguid);
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
if (NULL == data) return E_OUTOFMEMORY;
if (!data) return E_OUTOFMEMORY;
data->tag = *refguid;
data->flags = Flags;
......@@ -157,7 +157,8 @@ HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
else
{
data->ptr.data = HeapAlloc(GetProcessHeap(), 0, SizeOfData);
if (NULL == data->ptr.data) {
if (!data->ptr.data)
{
HeapFree(GetProcessHeap(), 0, data);
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);
data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND;
if (!data) return WINED3DERR_NOTFOUND;
if (*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));
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->ptr.object != NULL)
if (data->ptr.object)
IUnknown_Release(data->ptr.object);
} else {
}
else
{
HeapFree(GetProcessHeap(), 0, data->ptr.data);
}
list_remove(&data->entry);
......
......@@ -378,7 +378,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct
case WINED3DSPR_MISCTYPE:
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;
}
break;
......@@ -721,7 +721,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
{
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
* 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;
case WINED3DDECLUSAGE_COLOR:
if (semantic->usage_idx == 0) TRACE("color");
if (!semantic->usage_idx) TRACE("color");
else TRACE("specular%u", (semantic->usage_idx - 1));
break;
......
......@@ -2027,7 +2027,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if
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);
} else {
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];
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]);
......@@ -3475,9 +3476,9 @@ static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
if (stateblock->pixelShader && stage != 0
&& (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.luminanceparams & (1 << stage)))
if (stateblock->pixelShader && stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
{
/* The pixel shader has to know the luminance scale. Do a constants update if it
* 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(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
* 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)
{
if(sampler < stateblock->lowest_disabled_stage) {
if (sampler < stateblock->lowest_disabled_stage)
{
/* 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
* 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)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
if (stateblock->pixelShader && stage != 0
&& (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage)))
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
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
* anyway
......@@ -4837,7 +4842,8 @@ static void indexbuffer(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
{
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));
} else {
struct wined3d_buffer *ib = (struct wined3d_buffer *) stateblock->pIndexData;
......
......@@ -1222,10 +1222,10 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
for (i = 0; i < MAX_TEXTURES; i++) {
TRACE("Setting up default texture states for texture Stage %d\n", i);
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_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_ALPHAARG2 ] = WINED3DTA_CURRENT;
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 */
hr = IWineD3DDevice_GetSwapChain(device, 0, &swapchain);
if( hr == WINED3D_OK && swapchain != NULL) {
if (SUCCEEDED(hr) && swapchain)
{
WINED3DVIEWPORT vp;
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
......
......@@ -826,7 +826,9 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
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.
* 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...
......@@ -1356,7 +1358,8 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB");
if(mem != NULL) {
if (mem)
{
ERR("mem not null for pbo -- unexpected\n");
mem = NULL;
}
......@@ -1604,9 +1607,8 @@ static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This)
GL_EXTCALL(glGenBuffersARB(1, &This->pbo));
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);
}
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
* 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->bottom == This->currentDesc.Height)
{
......@@ -1894,10 +1896,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
goto unlock_end;
}
if(This->dirtyRect.left == 0 &&
This->dirtyRect.top == 0 &&
This->dirtyRect.right == This->currentDesc.Width &&
This->dirtyRect.bottom == This->currentDesc.Height) {
if (!This->dirtyRect.left && !This->dirtyRect.top
&& This->dirtyRect.right == This->currentDesc.Width
&& This->dirtyRect.bottom == This->currentDesc.Height)
{
fullsurface = TRUE;
} else {
/* 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_CK:
{
IWineD3DPaletteImpl* pal = This->palette;
BYTE table[256][4];
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));
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 */
This->resource.allocatedMemory = NULL;
/* 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;
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,
* 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 */
swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_ONE;
} else if(Flags & WINEDDFLIP_NOVSYNC) {
......@@ -3492,7 +3491,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
TRACE("Yes\n");
/* 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;
/* The idea behind this is that a glReadPixels and a glDrawPixels call
......
......@@ -219,16 +219,16 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD
return WINED3D_OK;
}
if(This->palette != NULL)
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET)
if (This->palette)
if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
This->palette->Flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
This->palette = PalImpl;
if(PalImpl != NULL) {
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
(PalImpl)->Flags |= WINEDDPCAPS_PRIMARYSURFACE;
}
if (PalImpl)
{
if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
PalImpl->Flags |= WINEDDPCAPS_PRIMARYSURFACE;
return IWineD3DSurface_RealizePalette(iface);
}
......@@ -240,7 +240,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
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);
return WINED3DERR_INVALIDCALL;
}
......@@ -359,7 +360,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface
TRACE("(%p): Not an overlay surface\n", This);
return WINEDDERR_NOTAOVERLAYSURFACE;
}
if(This->overlay_dest == NULL) {
if (!This->overlay_dest)
{
*X = 0; *Y = 0;
hr = WINEDDERR_OVERLAYNOTVISIBLE;
} else {
......@@ -587,8 +590,8 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
break;
}
ddc = GetDC(0);
if (ddc == 0) {
if (!(ddc = GetDC(0)))
{
HeapFree(GetProcessHeap(), 0, b_info);
return HRESULT_FROM_WIN32(GetLastError());
}
......@@ -1812,7 +1815,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DL
pLockedRect->Pitch = IWineD3DSurface_GetPitch(iface);
if (NULL == pRect)
if (!pRect)
{
pLockedRect->pBits = This->resource.allocatedMemory;
This->lockedRect.left = 0;
......
......@@ -453,10 +453,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
if (This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE
&& gl_info->supported[SGI_VIDEO_SYNC])
{
retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync));
if(retval != 0) {
if ((retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync))))
ERR("glXGetVideoSyncSGI failed(retval = %d\n", retval);
}
switch(This->presentParms.PresentationInterval) {
case WINED3DPRESENT_INTERVAL_DEFAULT:
......
......@@ -60,9 +60,9 @@ ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface)
DWORD refCount;
refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
if (refCount == 0) {
IWineD3DSwapChain_Destroy(iface);
}
if (!refCount) IWineD3DSwapChain_Destroy(iface);
return refCount;
}
......
......@@ -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;
}
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]);
......
......@@ -129,7 +129,9 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
if (!ref)
{
resource_cleanup((IWineD3DResource *)iface);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
......
......@@ -102,19 +102,19 @@ IWineD3D * WINAPI WineDirect3DCreate(UINT version, void *parent)
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 (0 != defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE) buffer, &size )) return 0;
if (appkey && !RegQueryValueExA(appkey, name, 0, NULL, (BYTE *)buffer, &size)) return 0;
if (defkey && !RegQueryValueExA(defkey, name, 0, NULL, (BYTE *)buffer, &size)) return 0;
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 size = sizeof(DWORD);
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, 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 (defkey && !RegQueryValueExA(defkey, name, 0, &type, (BYTE *)data, &size) && (type == REG_DWORD)) return 0;
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) )
{
......
......@@ -2805,7 +2805,7 @@ static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
{
case WINED3DSPR_RASTOUT:
/* oFog & oPts */
if (reg->idx != 0) return TRUE;
if (reg->idx) return TRUE;
/* oPos */
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment