[PATCH] wined3d: Make wined3d_device_set_texture() infallible.

Zebediah Figura z.figura12 at gmail.com
Fri Mar 22 09:47:06 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d8/device.c     |  5 ++---
 dlls/d3d9/device.c     |  7 +++----
 dlls/ddraw/device.c    |  8 ++++----
 dlls/wined3d/device.c  | 10 +++++-----
 include/wine/wined3d.h |  2 +-
 5 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index bee813323d..9a706c888e 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2105,18 +2105,17 @@ static HRESULT WINAPI d3d8_device_SetTexture(IDirect3DDevice8 *iface, DWORD stag
 {
     struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
     struct d3d8_texture *texture_impl;
-    HRESULT hr;
 
     TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
 
     texture_impl = unsafe_impl_from_IDirect3DBaseTexture8(texture);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture(device->wined3d_device, stage,
+    wined3d_device_set_texture(device->wined3d_device, stage,
             texture_impl ? texture_impl->wined3d_texture : NULL);
     wined3d_mutex_unlock();
 
-    return hr;
+    return D3D_OK;
 }
 
 static const struct tss_lookup
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index f0fa3f234d..e2e4e75a05 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2459,16 +2459,15 @@ static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD st
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
     struct d3d9_texture *texture_impl;
-    HRESULT hr;
 
     TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
 
     texture_impl = unsafe_impl_from_IDirect3DBaseTexture9(texture);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture(device->wined3d_device, stage,
+    wined3d_device_set_texture(device->wined3d_device, stage,
             texture_impl ? texture_impl->wined3d_texture : NULL);
-    if (SUCCEEDED(hr) && !device->recording)
+    if (!device->recording)
     {
         unsigned int i = stage < 16 || (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3)
                 ? stage < 16 ? stage : stage - D3DVERTEXTEXTURESAMPLER0 + 16 : ~0u;
@@ -2483,7 +2482,7 @@ static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD st
     }
     wined3d_mutex_unlock();
 
-    return hr;
+    return D3D_OK;
 }
 
 static const enum wined3d_texture_stage_state tss_lookup[] =
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index c9b7dc93e4..119cd8db7c 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -2760,7 +2760,8 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
 
             if (value == 0)
             {
-                hr = wined3d_device_set_texture(device->wined3d_device, 0, NULL);
+                wined3d_device_set_texture(device->wined3d_device, 0, NULL);
+                hr = D3D_OK;
                 break;
             }
 
@@ -4814,7 +4815,6 @@ static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface,
     struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
     struct ddraw_surface *surf = unsafe_impl_from_IDirectDrawSurface7(texture);
     struct wined3d_texture *wined3d_texture = NULL;
-    HRESULT hr;
 
     TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
 
@@ -4822,10 +4822,10 @@ static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface,
         wined3d_texture = surf->wined3d_texture;
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture(device->wined3d_device, stage, wined3d_texture);
+    wined3d_device_set_texture(device->wined3d_device, stage, wined3d_texture);
     wined3d_mutex_unlock();
 
-    return hr;
+    return D3D_OK;
 }
 
 static HRESULT WINAPI d3d_device7_SetTexture_FPUSetup(IDirect3DDevice7 *iface,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 789559ac09..20cd1203cb 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3533,7 +3533,7 @@ DWORD CDECL wined3d_device_get_texture_stage_state(const struct wined3d_device *
     return device->state.texture_states[stage][state];
 }
 
-HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
+void CDECL wined3d_device_set_texture(struct wined3d_device *device,
         UINT stage, struct wined3d_texture *texture)
 {
     struct wined3d_texture *prev;
@@ -3547,7 +3547,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
     if (stage >= ARRAY_SIZE(device->state.textures))
     {
         WARN("Ignoring invalid stage %u.\n", stage);
-        return WINED3D_OK;
+        return;
     }
 
     if (texture)
@@ -3559,7 +3559,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
     if (device->recording)
     {
         device->recording->changed.textures |= 1u << stage;
-        return WINED3D_OK;
+        return;
     }
 
     prev = device->state.textures[stage];
@@ -3568,7 +3568,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
     if (texture == prev)
     {
         TRACE("App is setting the same texture again, nothing to do.\n");
-        return WINED3D_OK;
+        return;
     }
 
     TRACE("Setting new texture to %p.\n", texture);
@@ -3580,7 +3580,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
     if (prev)
         wined3d_texture_decref(prev);
 
-    return WINED3D_OK;
+    return;
 }
 
 struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_device *device, UINT stage)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 7ca55a1922..f718b24d2e 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2458,7 +2458,7 @@ void __cdecl wined3d_device_set_stream_output(struct wined3d_device *device, UIN
 HRESULT __cdecl wined3d_device_set_stream_source(struct wined3d_device *device,
         UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride);
 HRESULT __cdecl wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider);
-HRESULT __cdecl wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture);
+void __cdecl wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture);
 void __cdecl wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         UINT stage, enum wined3d_texture_stage_state state, DWORD value);
 void __cdecl wined3d_device_set_transform(struct wined3d_device *device,
-- 
2.20.1




More information about the wine-devel mailing list