d3d11: Introduce d3d_rasterizer_state_create() helper function.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
10ae9eb3d9
commit
8b2d71443e
|
@ -446,8 +446,8 @@ struct d3d_rasterizer_state
|
||||||
ID3D11Device *device;
|
ID3D11Device *device;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device,
|
HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC *desc,
|
||||||
const D3D11_RASTERIZER_DESC *desc) DECLSPEC_HIDDEN;
|
struct d3d_rasterizer_state **state) DECLSPEC_HIDDEN;
|
||||||
struct d3d_rasterizer_state *unsafe_impl_from_ID3D11RasterizerState(ID3D11RasterizerState *iface) DECLSPEC_HIDDEN;
|
struct d3d_rasterizer_state *unsafe_impl_from_ID3D11RasterizerState(ID3D11RasterizerState *iface) DECLSPEC_HIDDEN;
|
||||||
struct d3d_rasterizer_state *unsafe_impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface) DECLSPEC_HIDDEN;
|
struct d3d_rasterizer_state *unsafe_impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
|
@ -3035,39 +3035,13 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device
|
||||||
{
|
{
|
||||||
struct d3d_device *device = impl_from_ID3D11Device(iface);
|
struct d3d_device *device = impl_from_ID3D11Device(iface);
|
||||||
struct d3d_rasterizer_state *object;
|
struct d3d_rasterizer_state *object;
|
||||||
struct wine_rb_entry *entry;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
|
TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
|
||||||
|
|
||||||
if (!desc)
|
if (FAILED(hr = d3d_rasterizer_state_create(device, desc, &object)))
|
||||||
return E_INVALIDARG;
|
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
|
||||||
if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
|
|
||||||
{
|
|
||||||
object = WINE_RB_ENTRY_VALUE(entry, struct d3d_rasterizer_state, entry);
|
|
||||||
|
|
||||||
TRACE("Returning existing rasterizer state %p.\n", object);
|
|
||||||
*rasterizer_state = &object->ID3D11RasterizerState_iface;
|
|
||||||
ID3D11RasterizerState_AddRef(*rasterizer_state);
|
|
||||||
wined3d_mutex_unlock();
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
wined3d_mutex_unlock();
|
|
||||||
|
|
||||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
|
|
||||||
if (FAILED(hr = d3d_rasterizer_state_init(object, device, desc)))
|
|
||||||
{
|
|
||||||
WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
|
|
||||||
HeapFree(GetProcessHeap(), 0, object);
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("Created rasterizer state %p.\n", object);
|
|
||||||
*rasterizer_state = &object->ID3D11RasterizerState_iface;
|
*rasterizer_state = &object->ID3D11RasterizerState_iface;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -5339,19 +5313,17 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device
|
||||||
const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
|
const D3D10_RASTERIZER_DESC *desc, ID3D10RasterizerState **rasterizer_state)
|
||||||
{
|
{
|
||||||
struct d3d_device *device = impl_from_ID3D10Device(iface);
|
struct d3d_device *device = impl_from_ID3D10Device(iface);
|
||||||
ID3D11RasterizerState *d3d11_rasterizer_state;
|
struct d3d_rasterizer_state *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
|
TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
|
||||||
|
|
||||||
if (FAILED(hr = d3d11_device_CreateRasterizerState(&device->ID3D11Device_iface,
|
if (FAILED(hr = d3d_rasterizer_state_create(device, (const D3D11_RASTERIZER_DESC *)desc, &object)))
|
||||||
(const D3D11_RASTERIZER_DESC *)desc, &d3d11_rasterizer_state)))
|
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
hr = ID3D11RasterizerState_QueryInterface(d3d11_rasterizer_state,
|
*rasterizer_state = &object->ID3D10RasterizerState_iface;
|
||||||
&IID_ID3D10RasterizerState, (void **)rasterizer_state);
|
|
||||||
ID3D11RasterizerState_Release(d3d11_rasterizer_state);
|
return S_OK;
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
|
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *iface,
|
||||||
|
|
|
@ -1033,7 +1033,7 @@ static const struct wined3d_parent_ops d3d_rasterizer_state_wined3d_parent_ops =
|
||||||
d3d_rasterizer_state_wined3d_object_destroyed,
|
d3d_rasterizer_state_wined3d_object_destroyed,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device,
|
static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device,
|
||||||
const D3D11_RASTERIZER_DESC *desc)
|
const D3D11_RASTERIZER_DESC *desc)
|
||||||
{
|
{
|
||||||
struct wined3d_rasterizer_state_desc wined3d_desc;
|
struct wined3d_rasterizer_state_desc wined3d_desc;
|
||||||
|
@ -1074,6 +1074,46 @@ HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC *desc,
|
||||||
|
struct d3d_rasterizer_state **state)
|
||||||
|
{
|
||||||
|
struct d3d_rasterizer_state *object;
|
||||||
|
struct wine_rb_entry *entry;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (!desc)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
wined3d_mutex_lock();
|
||||||
|
if ((entry = wine_rb_get(&device->rasterizer_states, desc)))
|
||||||
|
{
|
||||||
|
object = WINE_RB_ENTRY_VALUE(entry, struct d3d_rasterizer_state, entry);
|
||||||
|
|
||||||
|
TRACE("Returning existing rasterizer state %p.\n", object);
|
||||||
|
ID3D11RasterizerState_AddRef(&object->ID3D11RasterizerState_iface);
|
||||||
|
*state = object;
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
if (FAILED(hr = d3d_rasterizer_state_init(object, device, desc)))
|
||||||
|
{
|
||||||
|
WARN("Failed to initialize rasterizer state, hr %#x.\n", hr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Created rasterizer state %p.\n", object);
|
||||||
|
*state = object;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct d3d_rasterizer_state *unsafe_impl_from_ID3D11RasterizerState(ID3D11RasterizerState *iface)
|
struct d3d_rasterizer_state *unsafe_impl_from_ID3D11RasterizerState(ID3D11RasterizerState *iface)
|
||||||
{
|
{
|
||||||
if (!iface)
|
if (!iface)
|
||||||
|
|
Loading…
Reference in New Issue