Henri Verbeet : wined3d: wined3d_device_get_sampler_state() never fails.

Alexandre Julliard julliard at winehq.org
Wed Sep 19 13:39:45 CDT 2012


Module: wine
Branch: master
Commit: 62670c7ba530ee894f8c1d8f58e3e5405d77b8f5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=62670c7ba530ee894f8c1d8f58e3e5405d77b8f5

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Sep 18 22:13:58 2012 +0200

wined3d: wined3d_device_get_sampler_state() never fails.

---

 dlls/d3d8/device.c        |    4 ++--
 dlls/d3d9/device.c        |    5 ++---
 dlls/ddraw/device.c       |   29 ++++++++---------------------
 dlls/wined3d/device.c     |   15 ++++++---------
 dlls/wined3d/wined3d.spec |    2 +-
 include/wine/wined3d.h    |    4 ++--
 6 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 2b7e7c0..5e21a38 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1785,7 +1785,7 @@ static HRESULT WINAPI d3d8_device_GetTextureStageState(IDirect3DDevice8 *iface,
 {
     struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
     const struct tss_lookup *l;
-    HRESULT hr;
+    HRESULT hr = D3D_OK;
 
     TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, Type, value);
 
@@ -1799,7 +1799,7 @@ static HRESULT WINAPI d3d8_device_GetTextureStageState(IDirect3DDevice8 *iface,
 
     wined3d_mutex_lock();
     if (l->sampler_state)
-        hr = wined3d_device_get_sampler_state(device->wined3d_device, stage, l->state, value);
+        *value = wined3d_device_get_sampler_state(device->wined3d_device, stage, l->state);
     else
         hr = wined3d_device_get_texture_stage_state(device->wined3d_device, stage, l->state, value);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index ea90e1a..2662f4e 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1794,15 +1794,14 @@ static HRESULT WINAPI d3d9_device_GetSamplerState(IDirect3DDevice9Ex *iface,
         DWORD sampler, D3DSAMPLERSTATETYPE state, DWORD *value)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    HRESULT hr;
 
     TRACE("iface %p, sampler %u, state %#x, value %p.\n", iface, sampler, state, value);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_sampler_state(device->wined3d_device, sampler, state, value);
+    *value = wined3d_device_get_sampler_state(device->wined3d_device, sampler, state);
     wined3d_mutex_unlock();
 
-    return hr;
+    return D3D_OK;
 }
 
 static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetSamplerState(IDirect3DDevice9Ex *iface,
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 908efa3..20b2510 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -2217,7 +2217,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
         D3DRENDERSTATETYPE state, DWORD *value)
 {
     struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
-    HRESULT hr;
+    HRESULT hr = D3D_OK;
 
     TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
 
@@ -2231,8 +2231,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
         {
             enum wined3d_texture_filter_type tex_mag;
 
-            hr = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MAG_FILTER, &tex_mag);
-
+            tex_mag = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MAG_FILTER);
             switch (tex_mag)
             {
                 case WINED3D_TEXF_POINT:
@@ -2253,16 +2252,8 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
             enum wined3d_texture_filter_type tex_min;
             enum wined3d_texture_filter_type tex_mip;
 
-            hr = wined3d_device_get_sampler_state(device->wined3d_device,
-                    0, WINED3D_SAMP_MIN_FILTER, &tex_min);
-            if (FAILED(hr))
-            {
-                wined3d_mutex_unlock();
-                return hr;
-            }
-            hr = wined3d_device_get_sampler_state(device->wined3d_device,
-                    0, WINED3D_SAMP_MIP_FILTER, &tex_mip);
-
+            tex_min = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MIN_FILTER);
+            tex_mip = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MIP_FILTER);
             switch (tex_min)
             {
                 case WINED3D_TEXF_POINT:
@@ -2311,12 +2302,10 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
 
         case D3DRENDERSTATE_TEXTUREADDRESS:
         case D3DRENDERSTATE_TEXTUREADDRESSU:
-            hr = wined3d_device_get_sampler_state(device->wined3d_device,
-                    0, WINED3D_SAMP_ADDRESS_U, value);
+            *value = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_ADDRESS_U);
             break;
         case D3DRENDERSTATE_TEXTUREADDRESSV:
-            hr = wined3d_device_get_sampler_state(device->wined3d_device,
-                    0, WINED3D_SAMP_ADDRESS_V, value);
+            *value = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_ADDRESS_V);
             break;
 
         case D3DRENDERSTATE_BORDERCOLOR:
@@ -2332,7 +2321,6 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
 
         case D3DRENDERSTATE_ZBIAS:
             *value = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS);
-            hr = D3D_OK;
             break;
 
         default:
@@ -2344,7 +2332,6 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
                 break;
             }
             *value = wined3d_device_get_render_state(device->wined3d_device, state);
-            hr = D3D_OK;
     }
     wined3d_mutex_unlock();
 
@@ -4584,8 +4571,8 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface,
         DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value)
 {
     struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
-    HRESULT hr;
     const struct tss_lookup *l;
+    HRESULT hr = D3D_OK;
 
     TRACE("iface %p, stage %u, state %#x, value %p.\n",
             iface, stage, state, value);
@@ -4605,7 +4592,7 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface,
 
     if (l->sampler_state)
     {
-        hr = wined3d_device_get_sampler_state(device->wined3d_device, stage, l->state, value);
+        *value = wined3d_device_get_sampler_state(device->wined3d_device, stage, l->state);
 
         switch (state)
         {
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 596206c..69518b4 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2363,11 +2363,11 @@ void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device,
     device_invalidate_state(device, STATE_SAMPLER(sampler_idx));
 }
 
-HRESULT CDECL wined3d_device_get_sampler_state(const struct wined3d_device *device,
-        UINT sampler_idx, enum wined3d_sampler_state state, DWORD *value)
+DWORD CDECL wined3d_device_get_sampler_state(const struct wined3d_device *device,
+        UINT sampler_idx, enum wined3d_sampler_state state)
 {
-    TRACE("device %p, sampler_idx %u, state %s, value %p.\n",
-            device, sampler_idx, debug_d3dsamplerstate(state), value);
+    TRACE("device %p, sampler_idx %u, state %s.\n",
+            device, sampler_idx, debug_d3dsamplerstate(state));
 
     if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
         sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
@@ -2376,13 +2376,10 @@ HRESULT CDECL wined3d_device_get_sampler_state(const struct wined3d_device *devi
             / sizeof(*device->stateBlock->state.sampler_states))
     {
         WARN("Invalid sampler %u.\n", sampler_idx);
-        return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
+        return 0; /* Windows accepts overflowing this array ... we do not. */
     }
 
-    *value = device->stateBlock->state.sampler_states[sampler_idx][state];
-    TRACE("Returning %#x.\n", *value);
-
-    return WINED3D_OK;
+    return device->stateBlock->state.sampler_states[sampler_idx][state];
 }
 
 HRESULT CDECL wined3d_device_set_scissor_rect(struct wined3d_device *device, const RECT *rect)
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 7aea714..c50dd29 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -77,7 +77,7 @@
 @ cdecl wined3d_device_get_raster_status(ptr long ptr)
 @ cdecl wined3d_device_get_render_state(ptr long)
 @ cdecl wined3d_device_get_render_target(ptr long ptr)
-@ cdecl wined3d_device_get_sampler_state(ptr long long ptr)
+@ cdecl wined3d_device_get_sampler_state(ptr long long)
 @ cdecl wined3d_device_get_scissor_rect(ptr ptr)
 @ cdecl wined3d_device_get_software_vertex_processing(ptr)
 @ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 57b6a1b..b44cc42 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2145,8 +2145,8 @@ HRESULT __cdecl wined3d_device_get_raster_status(const struct wined3d_device *de
 DWORD __cdecl wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state state);
 HRESULT __cdecl wined3d_device_get_render_target(const struct wined3d_device *device,
         UINT render_target_idx, struct wined3d_surface **render_target);
-HRESULT __cdecl wined3d_device_get_sampler_state(const struct wined3d_device *device,
-        UINT sampler_idx, enum wined3d_sampler_state state, DWORD *value);
+DWORD __cdecl wined3d_device_get_sampler_state(const struct wined3d_device *device,
+        UINT sampler_idx, enum wined3d_sampler_state state);
 HRESULT __cdecl wined3d_device_get_scissor_rect(const struct wined3d_device *device, RECT *rect);
 BOOL __cdecl wined3d_device_get_software_vertex_processing(const struct wined3d_device *device);
 HRESULT __cdecl wined3d_device_get_stream_source(const struct wined3d_device *device,




More information about the wine-cvs mailing list