Commit 48b13fe2 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Implement d3d11_device_CreateSamplerState().

parent 702e536c
......@@ -1442,9 +1442,55 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface,
const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state)
{
FIXME("iface %p, desc %p, sampler_state %p stub!\n", iface, desc, sampler_state);
struct d3d_device *device = impl_from_ID3D11Device(iface);
D3D11_SAMPLER_DESC normalized_desc;
struct d3d_sampler_state *object;
struct wine_rb_entry *entry;
HRESULT hr;
return E_NOTIMPL;
TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
if (!desc)
return E_INVALIDARG;
normalized_desc = *desc;
if (!D3D11_DECODE_IS_ANISOTROPIC_FILTER(normalized_desc.Filter))
normalized_desc.MaxAnisotropy = 0;
if (!D3D11_DECODE_IS_COMPARISON_FILTER(normalized_desc.Filter))
normalized_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
if (normalized_desc.AddressU != D3D11_TEXTURE_ADDRESS_BORDER
&& normalized_desc.AddressV != D3D11_TEXTURE_ADDRESS_BORDER
&& normalized_desc.AddressW != D3D11_TEXTURE_ADDRESS_BORDER)
memset(&normalized_desc.BorderColor, 0, sizeof(normalized_desc.BorderColor));
wined3d_mutex_lock();
if ((entry = wine_rb_get(&device->sampler_states, &normalized_desc)))
{
object = WINE_RB_ENTRY_VALUE(entry, struct d3d_sampler_state, entry);
TRACE("Returning existing sampler state %p.\n", object);
*sampler_state = &object->ID3D11SamplerState_iface;
ID3D11SamplerState_AddRef(*sampler_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_sampler_state_init(object, device, &normalized_desc)))
{
WARN("Failed to initialize sampler state, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created sampler state %p.\n", object);
*sampler_state = &object->ID3D11SamplerState_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface,
......@@ -3540,44 +3586,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device1 *
const D3D10_SAMPLER_DESC *desc, ID3D10SamplerState **sampler_state)
{
struct d3d_device *device = impl_from_ID3D10Device(iface);
struct d3d_sampler_state *object;
struct wine_rb_entry *entry;
ID3D11SamplerState *d3d11_sampler_state;
HRESULT hr;
TRACE("iface %p, desc %p, sampler_state %p.\n", iface, desc, sampler_state);
if (!desc)
return E_INVALIDARG;
wined3d_mutex_lock();
if ((entry = wine_rb_get(&device->sampler_states, desc)))
{
object = WINE_RB_ENTRY_VALUE(entry, struct d3d_sampler_state, entry);
TRACE("Returning existing sampler state %p.\n", object);
*sampler_state = &object->ID3D10SamplerState_iface;
ID3D10SamplerState_AddRef(*sampler_state);
wined3d_mutex_unlock();
return S_OK;
}
wined3d_mutex_unlock();
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
if (FAILED(hr = d3d_sampler_state_init(object, device, (const D3D11_SAMPLER_DESC *)desc)))
{
WARN("Failed to initialize sampler state, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
if (FAILED(hr = d3d11_device_CreateSamplerState(&device->ID3D11Device_iface,
(const D3D11_SAMPLER_DESC *)desc, &d3d11_sampler_state)))
return hr;
}
TRACE("Created sampler state %p.\n", object);
*sampler_state = &object->ID3D10SamplerState_iface;
return S_OK;
hr = ID3D11SamplerState_QueryInterface(d3d11_sampler_state, &IID_ID3D10SamplerState, (void **)sampler_state);
ID3D11SamplerState_Release(d3d11_sampler_state);
return hr;
}
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateQuery(ID3D10Device1 *iface,
......
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