[PATCH 3/3] wined3d: Just return the buffer from wined3d_device_get_index_buffer().
Henri Verbeet
hverbeet at codeweavers.com
Thu Sep 6 04:25:03 CDT 2012
---
dlls/d3d8/device.c | 11 +++--------
dlls/d3d9/device.c | 13 ++++---------
dlls/wined3d/device.c | 13 +++----------
dlls/wined3d/wined3d.spec | 2 +-
include/wine/wined3d.h | 3 +--
5 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 49436da..36b8a7e 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2367,9 +2367,8 @@ static HRESULT WINAPI d3d8_device_GetIndices(IDirect3DDevice8 *iface,
IDirect3DIndexBuffer8 **buffer, UINT *base_vertex_index)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
- struct wined3d_buffer *wined3d_buffer = NULL;
+ struct wined3d_buffer *wined3d_buffer;
struct d3d8_indexbuffer *buffer_impl;
- HRESULT hr;
TRACE("iface %p, buffer %p, base_vertex_index %p.\n", iface, buffer, base_vertex_index);
@@ -2379,23 +2378,19 @@ static HRESULT WINAPI d3d8_device_GetIndices(IDirect3DDevice8 *iface,
/* The case from UINT to INT is safe because d3d8 will never set negative values */
wined3d_mutex_lock();
*base_vertex_index = wined3d_device_get_base_vertex_index(device->wined3d_device);
- hr = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_buffer);
- if (SUCCEEDED(hr) && wined3d_buffer)
+ if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device)))
{
buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
*buffer = &buffer_impl->IDirect3DIndexBuffer8_iface;
IDirect3DIndexBuffer8_AddRef(*buffer);
- wined3d_buffer_decref(wined3d_buffer);
}
else
{
- if (FAILED(hr))
- ERR("Failed to get wined3d index buffer, hr %#x.\n", hr);
*buffer = NULL;
}
wined3d_mutex_unlock();
- return hr;
+ return D3D_OK;
}
static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface,
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 523c9ac..0399ba3 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2539,9 +2539,8 @@ static HRESULT WINAPI d3d9_device_SetIndices(IDirect3DDevice9Ex *iface, IDirect3
static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **buffer)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
- struct wined3d_buffer *retIndexData = NULL;
+ struct wined3d_buffer *wined3d_buffer;
struct d3d9_indexbuffer *buffer_impl;
- HRESULT hr;
TRACE("iface %p, buffer %p.\n", iface, buffer);
@@ -2549,23 +2548,19 @@ static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- hr = wined3d_device_get_index_buffer(device->wined3d_device, &retIndexData);
- if (SUCCEEDED(hr) && retIndexData)
+ if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device)))
{
- buffer_impl = wined3d_buffer_get_parent(retIndexData);
+ buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
*buffer = &buffer_impl->IDirect3DIndexBuffer9_iface;
IDirect3DIndexBuffer9_AddRef(*buffer);
- wined3d_buffer_decref(retIndexData);
}
else
{
- if (FAILED(hr))
- FIXME("Call to GetIndices failed\n");
*buffer = NULL;
}
wined3d_mutex_unlock();
- return hr;
+ return D3D_OK;
}
static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 2d6563f..7a57195 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2256,18 +2256,11 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
}
}
-HRESULT CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device, struct wined3d_buffer **buffer)
+struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device)
{
- TRACE("device %p, buffer %p.\n", device, buffer);
-
- *buffer = device->stateBlock->state.index_buffer;
-
- if (*buffer)
- wined3d_buffer_incref(*buffer);
-
- TRACE("Returning %p.\n", *buffer);
+ TRACE("device %p.\n", device);
- return WINED3D_OK;
+ return device->stateBlock->state.index_buffer;
}
/* Method to offer d3d9 a simple way to set the base vertex index without messing with the index buffer */
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index aa0c186..c211e4a 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -64,7 +64,7 @@
@ cdecl wined3d_device_get_display_mode(ptr long ptr ptr)
@ cdecl wined3d_device_get_front_buffer_data(ptr long ptr)
@ cdecl wined3d_device_get_gamma_ramp(ptr long ptr)
-@ cdecl wined3d_device_get_index_buffer(ptr ptr)
+@ cdecl wined3d_device_get_index_buffer(ptr)
@ cdecl wined3d_device_get_light(ptr long ptr)
@ cdecl wined3d_device_get_light_enable(ptr long ptr)
@ cdecl wined3d_device_get_material(ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 28a6719..afb007c 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2125,8 +2125,7 @@ HRESULT __cdecl wined3d_device_get_front_buffer_data(const struct wined3d_device
UINT swapchain_idx, struct wined3d_surface *dst_surface);
void __cdecl wined3d_device_get_gamma_ramp(const struct wined3d_device *device,
UINT swapchain_idx, struct wined3d_gamma_ramp *ramp);
-HRESULT __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device,
- struct wined3d_buffer **index_buffer);
+struct wined3d_buffer * __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_light(const struct wined3d_device *device,
UINT light_idx, struct wined3d_light *light);
HRESULT __cdecl wined3d_device_get_light_enable(const struct wined3d_device *device, UINT light_idx, BOOL *enable);
--
1.7.8.6
More information about the wine-patches
mailing list