Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52294 Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3d11/d3d11_private.h | 4 ++-- dlls/d3d11/device.c | 38 ++++++++++++++++++++++++++++++++------ dlls/d3d11/state.c | 19 +++++++++++-------- dlls/d3d11/tests/d3d11.c | 7 +++++++ 4 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index b45ef8431bf..41272d08da8 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -467,12 +467,12 @@ struct d3d_rasterizer_state
struct wined3d_private_store private_store; struct wined3d_rasterizer_state *wined3d_state; - D3D11_RASTERIZER_DESC desc; + D3D11_RASTERIZER_DESC1 desc; struct wine_rb_entry entry; ID3D11Device2 *device; };
-HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC *desc, +HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC1 *desc, 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_ID3D10RasterizerState(ID3D10RasterizerState *iface) DECLSPEC_HIDDEN; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index c0191677e77..eb8a7e65ccd 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -3598,11 +3598,18 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device { struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_rasterizer_state *object; + D3D11_RASTERIZER_DESC1 desc1; HRESULT hr;
TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
- if (FAILED(hr = d3d_rasterizer_state_create(device, desc, &object))) + if (!desc) + return E_INVALIDARG; + + memcpy(&desc1, desc, sizeof(*desc)); + desc1.ForcedSampleCount = 0; + + if (FAILED(hr = d3d_rasterizer_state_create(device, &desc1, &object))) return hr;
*rasterizer_state = (ID3D11RasterizerState *)&object->ID3D11RasterizerState1_iface; @@ -4210,9 +4217,21 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState1(ID3D11Device2 *i static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState1(ID3D11Device2 *iface, const D3D11_RASTERIZER_DESC1 *desc, ID3D11RasterizerState1 **state) { - FIXME("iface %p, desc %p, state %p stub!\n", iface, desc, state); + struct d3d_device *device = impl_from_ID3D11Device2(iface); + struct d3d_rasterizer_state *object; + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, desc %p, state %p.\n", iface, desc, state); + + if (!desc) + return E_INVALIDARG; + + if (FAILED(hr = d3d_rasterizer_state_create(device, desc, &object))) + return hr; + + *state = &object->ID3D11RasterizerState1_iface; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeviceContextState(ID3D11Device2 *iface, UINT flags, @@ -6239,11 +6258,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device { struct d3d_device *device = impl_from_ID3D10Device(iface); struct d3d_rasterizer_state *object; + D3D11_RASTERIZER_DESC1 desc1; HRESULT hr;
TRACE("iface %p, desc %p, rasterizer_state %p.\n", iface, desc, rasterizer_state);
- if (FAILED(hr = d3d_rasterizer_state_create(device, (const D3D11_RASTERIZER_DESC *)desc, &object))) + if (!desc) + return E_INVALIDARG; + + memcpy(&desc1, desc, sizeof(*desc)); + desc1.ForcedSampleCount = 0; + + if (FAILED(hr = d3d_rasterizer_state_create(device, &desc1, &object))) return hr;
*rasterizer_state = &object->ID3D10RasterizerState_iface; @@ -6779,8 +6805,8 @@ static int d3d_depthstencil_state_compare(const void *key, const struct wine_rb_
static int d3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry) { - const D3D11_RASTERIZER_DESC *ka = key; - const D3D11_RASTERIZER_DESC *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_rasterizer_state, entry)->desc; + const D3D11_RASTERIZER_DESC1 *ka = key; + const D3D11_RASTERIZER_DESC1 *kb = &WINE_RB_ENTRY_VALUE(entry, const struct d3d_rasterizer_state, entry)->desc;
return memcmp(ka, kb, sizeof(*ka)); } diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 9aa841f0805..bb12a93dec5 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -958,7 +958,7 @@ static void STDMETHODCALLTYPE d3d11_rasterizer_state_GetDesc(ID3D11RasterizerSta
TRACE("iface %p, desc %p.\n", iface, desc);
- *desc = state->desc; + memcpy(desc, &state->desc, sizeof(*desc)); }
static void STDMETHODCALLTYPE d3d11_rasterizer_state_GetDesc1(ID3D11RasterizerState1 *iface, @@ -968,8 +968,7 @@ static void STDMETHODCALLTYPE d3d11_rasterizer_state_GetDesc1(ID3D11RasterizerSt
TRACE("iface %p, desc %p.\n", iface, desc);
- memcpy(desc, &state->desc, sizeof(state->desc)); - desc->ForcedSampleCount = 0; + *desc = state->desc; }
static const struct ID3D11RasterizerState1Vtbl d3d11_rasterizer_state_vtbl = @@ -1122,7 +1121,7 @@ static enum wined3d_cull wined3d_cull_from_d3d11(D3D11_CULL_MODE mode) }
static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device, - const D3D11_RASTERIZER_DESC *desc) + const D3D11_RASTERIZER_DESC1 *desc) { struct wined3d_rasterizer_state_desc wined3d_desc; HRESULT hr; @@ -1157,6 +1156,13 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str FIXME("Ignoring MultisampleEnable %#x.\n", desc->MultisampleEnable); }
+ if (desc->ForcedSampleCount) + { + static unsigned int once; + if (!once++) + FIXME("Ignoring ForcedSampleCount %#x.\n", desc->ForcedSampleCount); + } + /* We cannot fail after creating a wined3d_rasterizer_state object. It * would lead to double free. */ if (FAILED(hr = wined3d_rasterizer_state_create(device->wined3d_device, &wined3d_desc, @@ -1173,16 +1179,13 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str return S_OK; }
-HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC *desc, +HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC1 *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))) { diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index cd4905e2a82..298a2389555 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -5586,6 +5586,13 @@ static void test_create_rasterizer_state(void)
ID3D11RasterizerState1_Release(state_ex1);
+ memcpy(&desc1, &desc, sizeof(desc)); + desc1.ForcedSampleCount = 0; + hr = ID3D11Device1_CreateRasterizerState1(device1, &desc1, &state_ex1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ID3D11RasterizerState1_Release(state_ex1); + ID3D11Device1_Release(device1); }