From 3449c79d139c841b33d19551a67b7976d47e533d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 27 Jul 2016 23:33:42 +0200 Subject: [PATCH] d3d11: Add support for FrontCounterClockwise. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d11/d3d11_private.h | 1 + dlls/d3d11/device.c | 6 +++--- dlls/d3d11/state.c | 20 +++++++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index cdada4265ee..e9837cc678b 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -419,6 +419,7 @@ struct d3d_rasterizer_state LONG refcount; struct wined3d_private_store private_store; + struct wined3d_rasterizer_state *wined3d_state; D3D11_RASTERIZER_DESC desc; struct wine_rb_entry entry; ID3D11Device *device; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 7f819db8089..41a0319fd54 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -834,6 +834,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon wined3d_mutex_lock(); if (!(device->rasterizer_state = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state))) { + wined3d_device_set_rasterizer_state(device->wined3d_device, NULL); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, WINED3D_FILL_SOLID); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE); @@ -843,12 +844,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon return; } + wined3d_device_set_rasterizer_state(device->wined3d_device, device->rasterizer_state->wined3d_state); + desc = &device->rasterizer_state->desc; wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode); - /* glFrontFace() */ - if (desc->FrontCounterClockwise) - FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise); /* OpenGL style depth bias. */ if (desc->DepthBias || desc->SlopeScaledDepthBias) FIXME("Ignoring depth bias.\n"); diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 68ad1bdcdd7..d702d98c35a 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -664,9 +664,10 @@ static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_Release(ID3D11RasterizerSt struct d3d_device *device = impl_from_ID3D11Device(state->device); wined3d_mutex_lock(); wine_rb_remove(&device->rasterizer_states, &state->desc); - ID3D11Device_Release(state->device); + wined3d_rasterizer_state_decref(state->wined3d_state); wined3d_private_store_cleanup(&state->private_store); wined3d_mutex_unlock(); + ID3D11Device_Release(state->device); HeapFree(GetProcessHeap(), 0, state); } @@ -849,6 +850,9 @@ static const struct ID3D10RasterizerStateVtbl d3d10_rasterizer_state_vtbl = HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device, const D3D11_RASTERIZER_DESC *desc) { + struct wined3d_rasterizer_state_desc wined3d_desc; + HRESULT hr; + state->ID3D11RasterizerState_iface.lpVtbl = &d3d11_rasterizer_state_vtbl; state->ID3D10RasterizerState_iface.lpVtbl = &d3d10_rasterizer_state_vtbl; state->refcount = 1; @@ -856,17 +860,27 @@ HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d wined3d_private_store_init(&state->private_store); state->desc = *desc; + wined3d_desc.front_ccw = desc->FrontCounterClockwise; + if (FAILED(hr = wined3d_rasterizer_state_create(device->wined3d_device, + &wined3d_desc, &state->wined3d_state))) + { + WARN("Failed to create wined3d rasterizer state, hr %#x.\n", hr); + wined3d_private_store_cleanup(&state->private_store); + wined3d_mutex_unlock(); + return hr; + } + if (wine_rb_put(&device->rasterizer_states, desc, &state->entry) == -1) { ERR("Failed to insert rasterizer state entry.\n"); wined3d_private_store_cleanup(&state->private_store); + wined3d_rasterizer_state_decref(state->wined3d_state); wined3d_mutex_unlock(); return E_FAIL; } wined3d_mutex_unlock(); - state->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(state->device); + ID3D11Device_AddRef(state->device = &device->ID3D11Device_iface); return S_OK; }