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

wined3d: Just return the buffer from wined3d_device_get_index_buffer().

parent a3e28f6c
...@@ -2367,9 +2367,8 @@ static HRESULT WINAPI d3d8_device_GetIndices(IDirect3DDevice8 *iface, ...@@ -2367,9 +2367,8 @@ static HRESULT WINAPI d3d8_device_GetIndices(IDirect3DDevice8 *iface,
IDirect3DIndexBuffer8 **buffer, UINT *base_vertex_index) IDirect3DIndexBuffer8 **buffer, UINT *base_vertex_index)
{ {
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_buffer *wined3d_buffer = NULL; struct wined3d_buffer *wined3d_buffer;
struct d3d8_indexbuffer *buffer_impl; struct d3d8_indexbuffer *buffer_impl;
HRESULT hr;
TRACE("iface %p, buffer %p, base_vertex_index %p.\n", iface, buffer, base_vertex_index); 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, ...@@ -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 */ /* The case from UINT to INT is safe because d3d8 will never set negative values */
wined3d_mutex_lock(); wined3d_mutex_lock();
*base_vertex_index = wined3d_device_get_base_vertex_index(device->wined3d_device); *base_vertex_index = wined3d_device_get_base_vertex_index(device->wined3d_device);
hr = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_buffer); if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device)))
if (SUCCEEDED(hr) && wined3d_buffer)
{ {
buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
*buffer = &buffer_impl->IDirect3DIndexBuffer8_iface; *buffer = &buffer_impl->IDirect3DIndexBuffer8_iface;
IDirect3DIndexBuffer8_AddRef(*buffer); IDirect3DIndexBuffer8_AddRef(*buffer);
wined3d_buffer_decref(wined3d_buffer);
} }
else else
{ {
if (FAILED(hr))
ERR("Failed to get wined3d index buffer, hr %#x.\n", hr);
*buffer = NULL; *buffer = NULL;
} }
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return D3D_OK;
} }
static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface, static HRESULT WINAPI d3d8_device_CreatePixelShader(IDirect3DDevice8 *iface,
......
...@@ -2539,9 +2539,8 @@ static HRESULT WINAPI d3d9_device_SetIndices(IDirect3DDevice9Ex *iface, IDirect3 ...@@ -2539,9 +2539,8 @@ static HRESULT WINAPI d3d9_device_SetIndices(IDirect3DDevice9Ex *iface, IDirect3
static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **buffer) static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **buffer)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_buffer *retIndexData = NULL; struct wined3d_buffer *wined3d_buffer;
struct d3d9_indexbuffer *buffer_impl; struct d3d9_indexbuffer *buffer_impl;
HRESULT hr;
TRACE("iface %p, buffer %p.\n", iface, buffer); TRACE("iface %p, buffer %p.\n", iface, buffer);
...@@ -2549,23 +2548,19 @@ static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3 ...@@ -2549,23 +2548,19 @@ static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_get_index_buffer(device->wined3d_device, &retIndexData); if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device)))
if (SUCCEEDED(hr) && retIndexData)
{ {
buffer_impl = wined3d_buffer_get_parent(retIndexData); buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
*buffer = &buffer_impl->IDirect3DIndexBuffer9_iface; *buffer = &buffer_impl->IDirect3DIndexBuffer9_iface;
IDirect3DIndexBuffer9_AddRef(*buffer); IDirect3DIndexBuffer9_AddRef(*buffer);
wined3d_buffer_decref(retIndexData);
} }
else else
{ {
if (FAILED(hr))
FIXME("Call to GetIndices failed\n");
*buffer = NULL; *buffer = NULL;
} }
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return D3D_OK;
} }
static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface, static HRESULT WINAPI d3d9_device_CreatePixelShader(IDirect3DDevice9Ex *iface,
......
...@@ -2256,18 +2256,11 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, ...@@ -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); TRACE("device %p.\n", device);
*buffer = device->stateBlock->state.index_buffer;
if (*buffer)
wined3d_buffer_incref(*buffer);
TRACE("Returning %p.\n", *buffer);
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 */ /* Method to offer d3d9 a simple way to set the base vertex index without messing with the index buffer */
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
@ cdecl wined3d_device_get_display_mode(ptr long ptr ptr) @ cdecl wined3d_device_get_display_mode(ptr long ptr ptr)
@ cdecl wined3d_device_get_front_buffer_data(ptr long ptr) @ cdecl wined3d_device_get_front_buffer_data(ptr long ptr)
@ cdecl wined3d_device_get_gamma_ramp(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(ptr long ptr)
@ cdecl wined3d_device_get_light_enable(ptr long ptr) @ cdecl wined3d_device_get_light_enable(ptr long ptr)
@ cdecl wined3d_device_get_material(ptr ptr) @ cdecl wined3d_device_get_material(ptr ptr)
......
...@@ -2125,8 +2125,7 @@ HRESULT __cdecl wined3d_device_get_front_buffer_data(const struct wined3d_device ...@@ -2125,8 +2125,7 @@ HRESULT __cdecl wined3d_device_get_front_buffer_data(const struct wined3d_device
UINT swapchain_idx, struct wined3d_surface *dst_surface); UINT swapchain_idx, struct wined3d_surface *dst_surface);
void __cdecl wined3d_device_get_gamma_ramp(const struct wined3d_device *device, void __cdecl wined3d_device_get_gamma_ramp(const struct wined3d_device *device,
UINT swapchain_idx, struct wined3d_gamma_ramp *ramp); UINT swapchain_idx, struct wined3d_gamma_ramp *ramp);
HRESULT __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device, struct wined3d_buffer * __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device);
struct wined3d_buffer **index_buffer);
HRESULT __cdecl wined3d_device_get_light(const struct wined3d_device *device, HRESULT __cdecl wined3d_device_get_light(const struct wined3d_device *device,
UINT light_idx, struct wined3d_light *light); UINT light_idx, struct wined3d_light *light);
HRESULT __cdecl wined3d_device_get_light_enable(const struct wined3d_device *device, UINT light_idx, BOOL *enable); HRESULT __cdecl wined3d_device_get_light_enable(const struct wined3d_device *device, UINT light_idx, BOOL *enable);
......
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