Commit 2f03ad1a authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Just return the declaration from wined3d_device_get_vertex_declaration().

parent 01918d05
......@@ -2153,33 +2153,24 @@ static HRESULT WINAPI d3d8_device_GetVertexShader(IDirect3DDevice8 *iface, DWORD
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
struct wined3d_vertex_declaration *wined3d_declaration;
struct d3d8_vertex_declaration *d3d8_declaration;
HRESULT hr;
TRACE("iface %p, shader %p.\n", iface, shader);
wined3d_mutex_lock();
if (FAILED(hr = wined3d_device_get_vertex_declaration(device->wined3d_device, &wined3d_declaration)))
if ((wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
{
wined3d_mutex_unlock();
WARN("Failed to get wined3d vertex declaration, hr %#x.\n", hr);
return hr;
d3d8_declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
*shader = d3d8_declaration->shader_handle;
}
if (!wined3d_declaration)
else
{
wined3d_mutex_unlock();
*shader = 0;
return D3D_OK;
}
d3d8_declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
wined3d_vertex_declaration_decref(wined3d_declaration);
wined3d_mutex_unlock();
*shader = d3d8_declaration->shader_handle;
TRACE("Returning %#x.\n", *shader);
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d8_device_DeleteVertexShader(IDirect3DDevice8 *iface, DWORD shader)
......
......@@ -2088,22 +2088,19 @@ static HRESULT WINAPI d3d9_device_GetVertexDeclaration(IDirect3DDevice9Ex *iface
IDirect3DVertexDeclaration9 **declaration)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_vertex_declaration *wined3d_declaration = NULL;
struct wined3d_vertex_declaration *wined3d_declaration;
struct d3d9_vertex_declaration *declaration_impl;
HRESULT hr;
TRACE("iface %p, declaration %p.\n", iface, declaration);
if (!declaration) return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
hr = wined3d_device_get_vertex_declaration(device->wined3d_device, &wined3d_declaration);
if (SUCCEEDED(hr) && wined3d_declaration)
if ((wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
{
declaration_impl = wined3d_vertex_declaration_get_parent(wined3d_declaration);
*declaration = &declaration_impl->IDirect3DVertexDeclaration9_iface;
IDirect3DVertexDeclaration9_AddRef(*declaration);
wined3d_vertex_declaration_decref(wined3d_declaration);
}
else
{
......@@ -2112,7 +2109,7 @@ static HRESULT WINAPI d3d9_device_GetVertexDeclaration(IDirect3DDevice9Ex *iface
wined3d_mutex_unlock();
TRACE("Returning %p.\n", *declaration);
return hr;
return D3D_OK;
}
static struct wined3d_vertex_declaration *device_get_fvf_declaration(struct d3d9_device *device, DWORD fvf)
......@@ -2215,24 +2212,14 @@ static HRESULT WINAPI d3d9_device_GetFVF(IDirect3DDevice9Ex *iface, DWORD *fvf)
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_vertex_declaration *wined3d_declaration;
struct d3d9_vertex_declaration *d3d9_declaration;
HRESULT hr;
TRACE("iface %p, fvf %p.\n", iface, fvf);
wined3d_mutex_lock();
if (FAILED(hr = wined3d_device_get_vertex_declaration(device->wined3d_device, &wined3d_declaration)))
{
wined3d_mutex_unlock();
WARN("Failed to get vertex declaration, hr %#x.\n", hr);
*fvf = 0;
return hr;
}
if (wined3d_declaration)
if ((wined3d_declaration = wined3d_device_get_vertex_declaration(device->wined3d_device)))
{
d3d9_declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
*fvf = d3d9_declaration->fvf;
wined3d_vertex_declaration_decref(wined3d_declaration);
}
else
{
......@@ -2242,7 +2229,7 @@ static HRESULT WINAPI d3d9_device_GetFVF(IDirect3DDevice9Ex *iface, DWORD *fvf)
TRACE("Returning FVF %#x.\n", *fvf);
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d9_device_CreateVertexShader(IDirect3DDevice9Ex *iface,
......
......@@ -2442,16 +2442,11 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
device_invalidate_state(device, STATE_VDECL);
}
HRESULT CDECL wined3d_device_get_vertex_declaration(const struct wined3d_device *device,
struct wined3d_vertex_declaration **declaration)
struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(const struct wined3d_device *device)
{
TRACE("device %p, declaration %p.\n", device, declaration);
*declaration = device->stateBlock->state.vertex_declaration;
if (*declaration)
wined3d_vertex_declaration_incref(*declaration);
TRACE("device %p.\n", device);
return WINED3D_OK;
return device->stateBlock->state.vertex_declaration;
}
HRESULT CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
......
......@@ -88,7 +88,7 @@
@ cdecl wined3d_device_get_texture(ptr long ptr)
@ cdecl wined3d_device_get_texture_stage_state(ptr long long ptr)
@ cdecl wined3d_device_get_transform(ptr long ptr)
@ cdecl wined3d_device_get_vertex_declaration(ptr ptr)
@ cdecl wined3d_device_get_vertex_declaration(ptr)
@ cdecl wined3d_device_get_vertex_shader(ptr)
@ cdecl wined3d_device_get_viewport(ptr ptr)
@ cdecl wined3d_device_get_vs_consts_b(ptr long ptr long)
......
......@@ -2164,8 +2164,7 @@ HRESULT __cdecl wined3d_device_get_texture_stage_state(const struct wined3d_devi
UINT stage, enum wined3d_texture_stage_state state, DWORD *value);
void __cdecl wined3d_device_get_transform(const struct wined3d_device *device,
enum wined3d_transform_state state, struct wined3d_matrix *matrix);
HRESULT __cdecl wined3d_device_get_vertex_declaration(const struct wined3d_device *device,
struct wined3d_vertex_declaration **declaration);
struct wined3d_vertex_declaration * __cdecl wined3d_device_get_vertex_declaration(const struct wined3d_device *device);
struct wined3d_shader * __cdecl wined3d_device_get_vertex_shader(const struct wined3d_device *device);
void __cdecl wined3d_device_get_viewport(const struct wined3d_device *device, struct wined3d_viewport *viewport);
HRESULT __cdecl wined3d_device_get_vs_consts_b(const struct wined3d_device *device,
......
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