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, ...@@ -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 ...@@ -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 ...@@ -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);
} }
......
...@@ -277,7 +277,8 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac ...@@ -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 ...@@ -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) {
......
...@@ -78,7 +78,7 @@ static inline void buffer_clear_dirty_areas(struct wined3d_buffer *This) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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;
......
...@@ -63,12 +63,9 @@ static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface) ...@@ -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 ...@@ -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;
......
...@@ -375,7 +375,9 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) { ...@@ -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 ...@@ -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) ...@@ -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 ...@@ -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 ...@@ -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;
......
...@@ -221,8 +221,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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;
} }
} }
......
...@@ -232,8 +232,10 @@ static void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLhandleA ...@@ -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 * ...@@ -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 * ...@@ -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 * ...@@ -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 ...@@ -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 ...@@ -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, ...@@ -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) { ...@@ -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) { ...@@ -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;
......
...@@ -92,7 +92,7 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW ...@@ -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, ...@@ -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 */
......
...@@ -46,7 +46,7 @@ enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_qu ...@@ -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) { ...@@ -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
......
...@@ -139,7 +139,7 @@ HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid, ...@@ -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, ...@@ -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 ...@@ -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) ...@@ -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);
......
...@@ -378,7 +378,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct ...@@ -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 ...@@ -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 ...@@ -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;
......
...@@ -2027,7 +2027,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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;
......
...@@ -1222,10 +1222,10 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat ...@@ -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 ...@@ -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);
......
...@@ -826,7 +826,9 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win ...@@ -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 ...@@ -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) ...@@ -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 ...@@ -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) { ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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, ...@@ -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
......
...@@ -219,16 +219,16 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD ...@@ -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 ...@@ -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 ...@@ -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) ...@@ -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 ...@@ -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;
......
...@@ -453,10 +453,8 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO ...@@ -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:
......
...@@ -60,9 +60,9 @@ ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) ...@@ -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;
} }
......
...@@ -2800,7 +2800,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting ...@@ -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]);
......
...@@ -129,7 +129,9 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) { ...@@ -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);
......
...@@ -102,19 +102,19 @@ IWineD3D * WINAPI WineDirect3DCreate(UINT version, void *parent) ...@@ -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) ...@@ -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) )
{ {
......
...@@ -2805,7 +2805,7 @@ static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg) ...@@ -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;
......
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