Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d3d11/d3d11_private.h | 30 ++---- dlls/d3d11/device.c | 187 ++++++++++++++++--------------------- dlls/d3d11/tests/d3d11.c | 140 +++++++++++---------------- 3 files changed, 146 insertions(+), 211 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 650b5c35871..458339a849f 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -517,34 +517,20 @@ struct d3d_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface) DECLSPEC_HIDD struct d3d_query *unsafe_impl_from_ID3D11Asynchronous(ID3D11Asynchronous *iface) DECLSPEC_HIDDEN;
/* ID3DDeviceContextState */ +struct d3d_device_state_entry +{ + struct wine_rb_entry entry; + struct wined3d_device *device; + struct wined3d_state *state; +}; + struct d3d_device_context_state { ID3DDeviceContextState ID3DDeviceContextState_iface; LONG refcount, private_refcount;
struct wined3d_private_store private_store; - struct - { - ID3D11VertexShader *shader; - ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; - ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; - ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; - } vs; - struct - { - ID3D11GeometryShader *shader; - ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; - ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; - ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; - } gs; - struct - { - ID3D11PixelShader *shader; - ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; - ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; - ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; - } ps; - + struct wine_rb_tree devices_states; GUID emulated_interface;
struct wined3d_device *wined3d_device; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 87bdd594d81..0d20df28d20 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -88,37 +88,24 @@ static ULONG STDMETHODCALLTYPE d3d_device_context_state_AddRef(ID3DDeviceContext return refcount; }
+static void d3d_device_context_state_free_entry(struct wine_rb_entry *entry, void *context) +{ + struct d3d_device_state_entry *ptr = WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry); + wined3d_device_decref(ptr->device); + wined3d_state_destroy(ptr->state); + heap_free(ptr); +} + static void d3d_device_context_state_private_release(struct d3d_device_context_state *state) { ULONG refcount = InterlockedDecrement(&state->private_refcount); - unsigned int i;
TRACE("%p decreasing private refcount to %u.\n", state, refcount);
if (!refcount) { wined3d_private_store_cleanup(&state->private_store); - if (state->vs.shader) ID3D11VertexShader_Release(state->vs.shader); - if (state->gs.shader) ID3D11GeometryShader_Release(state->gs.shader); - if (state->ps.shader) ID3D11PixelShader_Release(state->ps.shader); - for (i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i) - { - if (state->vs.samplers[i]) ID3D11SamplerState_Release(state->vs.samplers[i]); - if (state->gs.samplers[i]) ID3D11SamplerState_Release(state->gs.samplers[i]); - if (state->ps.samplers[i]) ID3D11SamplerState_Release(state->ps.samplers[i]); - } - for (i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i) - { - if (state->vs.srvs[i]) ID3D11ShaderResourceView_Release(state->vs.srvs[i]); - if (state->gs.srvs[i]) ID3D11ShaderResourceView_Release(state->gs.srvs[i]); - if (state->ps.srvs[i]) ID3D11ShaderResourceView_Release(state->ps.srvs[i]); - } - for (i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i) - { - if (state->vs.cbs[i]) ID3D11Buffer_Release(state->vs.cbs[i]); - if (state->gs.cbs[i]) ID3D11Buffer_Release(state->gs.cbs[i]); - if (state->ps.cbs[i]) ID3D11Buffer_Release(state->ps.cbs[i]); - } + wine_rb_destroy(&state->devices_states, d3d_device_context_state_free_entry, NULL); wined3d_device_decref(state->wined3d_device); heap_free(state); } @@ -194,6 +181,60 @@ static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl = /* ID3DDeviceContextState methods */ };
+static int wined3d_device_compare(const void *key, const struct wine_rb_entry *entry) +{ + const struct wined3d_device *device = key; + return (char *)device - (char *)WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry)->device; +} + +static HRESULT d3d_device_context_state_get_wined3d_state(struct d3d_device_context_state *state, + struct wined3d_device *wined3d_device, struct wined3d_state **wined3d_state) +{ + struct d3d_device_state_entry *ptr; + struct wine_rb_entry *entry; + HRESULT hr = S_OK; + + *wined3d_state = NULL; + + wined3d_mutex_lock(); + if ((entry = wine_rb_get(&state->devices_states, wined3d_device))) + ptr = WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry); + else if ((ptr = heap_alloc(sizeof(*ptr)))) + { + wined3d_device_incref(ptr->device = wined3d_device); + wined3d_state_create(wined3d_device, &ptr->state); + } + else hr = E_OUTOFMEMORY; + wined3d_mutex_unlock(); + + if (hr == S_OK) *wined3d_state = ptr->state; + return hr; +} + +static HRESULT d3d_device_context_state_set_wined3d_state(struct d3d_device_context_state *state, + struct wined3d_device *wined3d_device, struct wined3d_state *wined3d_state) +{ + struct d3d_device_state_entry *ptr; + struct wine_rb_entry *entry; + HRESULT hr = S_OK; + + wined3d_mutex_lock(); + if ((entry = wine_rb_get(&state->devices_states, wined3d_device))) + { + ptr = WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry); + assert(ptr->state == wined3d_state); + } + else if ((ptr = heap_alloc(sizeof(*ptr)))) + { + wined3d_device_incref(ptr->device = wined3d_device); + ptr->state = wined3d_state; + wine_rb_put(&state->devices_states, wined3d_device, &ptr->entry); + } + else hr = E_OUTOFMEMORY; + wined3d_mutex_unlock(); + return hr; +} + static void d3d_device_context_state_init(struct d3d_device_context_state *state, struct d3d_device *device, REFIID emulated_interface) { @@ -201,9 +242,7 @@ static void d3d_device_context_state_init(struct d3d_device_context_state *state state->refcount = state->private_refcount = 0;
wined3d_private_store_init(&state->private_store); - memset(&state->vs, 0, sizeof(state->vs)); - memset(&state->gs, 0, sizeof(state->gs)); - memset(&state->ps, 0, sizeof(state->ps)); + wine_rb_init(&state->devices_states, wined3d_device_compare);
state->emulated_interface = *emulated_interface; wined3d_device_incref(state->wined3d_device = device->wined3d_device); @@ -2722,73 +2761,13 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers1(ID3D iface, start_slot, buffer_count, buffers, first_constant, num_constants); }
-static void d3d11_immediate_context_capture_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state) -{ - wined3d_mutex_lock(); - - d3d11_immediate_context_VSGetShader(iface, &state->vs.shader, NULL, 0); - d3d11_immediate_context_VSGetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers); - d3d11_immediate_context_VSGetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs); - d3d11_immediate_context_VSGetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs); - - d3d11_immediate_context_GSGetShader(iface, &state->gs.shader, NULL, 0); - d3d11_immediate_context_GSGetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers); - d3d11_immediate_context_GSGetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs); - d3d11_immediate_context_GSGetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs); - - d3d11_immediate_context_PSGetShader(iface, &state->ps.shader, NULL, 0); - d3d11_immediate_context_PSGetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers); - d3d11_immediate_context_PSGetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs); - d3d11_immediate_context_PSGetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs); - - wined3d_mutex_unlock(); -} - -static void d3d11_immediate_context_restore_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state) -{ - wined3d_mutex_lock(); - - d3d11_immediate_context_VSSetShader(iface, state->vs.shader, NULL, 0); - d3d11_immediate_context_VSSetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers); - d3d11_immediate_context_VSSetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs); - d3d11_immediate_context_VSSetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs); - - d3d11_immediate_context_GSSetShader(iface, state->gs.shader, NULL, 0); - d3d11_immediate_context_GSSetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers); - d3d11_immediate_context_GSSetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs); - d3d11_immediate_context_GSSetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs); - - d3d11_immediate_context_PSSetShader(iface, state->ps.shader, NULL, 0); - d3d11_immediate_context_PSSetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers); - d3d11_immediate_context_PSSetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs); - d3d11_immediate_context_PSSetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs); - - wined3d_mutex_unlock(); -} - static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface, ID3DDeviceContextState *state, ID3DDeviceContextState **prev_state) { - struct d3d_device_context_state *state_impl; + struct wined3d_state *old_wined3d_state, *new_wined3d_state; + struct d3d_device_context_state *new_impl, *old_impl; struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + HRESULT hr;
FIXME("iface %p, state %p, prev_state %p semi-stub!\n", iface, state, prev_state);
@@ -2796,24 +2775,22 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3 if (!state) return;
wined3d_mutex_lock(); - if (prev_state) - { - *prev_state = NULL; - if ((state_impl = heap_alloc(sizeof(*state_impl)))) - { - d3d_device_context_state_init(state_impl, device, &device->state->emulated_interface); - d3d11_immediate_context_capture_state(iface, state_impl); - *prev_state = &state_impl->ID3DDeviceContextState_iface; - } - } + old_impl = device->state; + new_impl = device->state = impl_from_ID3DDeviceContextState(state); + d3d_device_context_state_private_addref(new_impl);
- if ((state_impl = impl_from_ID3DDeviceContextState(state))) - { - d3d11_immediate_context_restore_state(iface, state_impl); - device->state->emulated_interface = state_impl->emulated_interface; - if (d3d_device_is_d3d10_active(device)) - FIXME("D3D10 interface emulation not fully implemented yet!\n"); - } + if (FAILED(hr = d3d_device_context_state_get_wined3d_state(new_impl, device->wined3d_device, + &new_wined3d_state))) + ERR("Failed to get new wined3d state, hr %#x.", hr); + + wined3d_device_swap_state(device->wined3d_device, new_wined3d_state, &old_wined3d_state); + d3d_device_context_state_set_wined3d_state(old_impl, device->wined3d_device, old_wined3d_state); + + if (!prev_state) d3d_device_context_state_private_release(old_impl); + else ID3DDeviceContextState_AddRef(*prev_state = &old_impl->ID3DDeviceContextState_iface); + + if (d3d_device_is_d3d10_active(device)) + FIXME("D3D10 interface emulation not fully implemented yet!\n"); wined3d_mutex_unlock(); }
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 1505b3fddbc..2eff98fe8fc 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -7083,7 +7083,7 @@ static void test_device_context_state(void) ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &previous_context_state); ok(previous_context_state != NULL, "Failed to get previous context state\n"); refcount = get_refcount(vs); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
hr = ID3DDeviceContextState_SetPrivateData(context_state, &test_guid, sizeof(constant), &constant); ok(hr == S_OK, "Failed to set private data, hr %#x.\n", hr); @@ -7093,9 +7093,9 @@ static void test_device_context_state(void) data_size = sizeof(data); memset(data, 0xa5, sizeof(data)); hr = ID3DDeviceContextState_GetPrivateData(context_state, &test_guid, &data_size, data); - todo_wine ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr); - todo_wine ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant)); - todo_wine ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n"); + ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr); + ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant)); + ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n"); ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, NULL);
context_type = ID3D11DeviceContext1_GetType(context); @@ -7142,118 +7142,96 @@ static void test_device_context_state(void)
tmp_cb = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_HSGetConstantBuffers(context, 0, 1, &tmp_cb); - todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); - if (tmp_cb) ID3D11Buffer_Release(tmp_cb); + ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); tmp_sampler = (ID3D11SamplerState *)0xdeadbeef; ID3D11DeviceContext1_HSGetSamplers(context, 0, 1, &tmp_sampler); - todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); - if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler); + ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); tmp_hs = (ID3D11HullShader *)0xdeadbeef; ID3D11DeviceContext1_HSGetShader(context, &tmp_hs, NULL, NULL); - if (hs) todo_wine ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs); - if (tmp_hs) ID3D11HullShader_Release(tmp_hs); + if (hs) ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs); tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef; ID3D11DeviceContext1_HSGetShaderResources(context, 0, 1, &tmp_srv); - todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); - if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv); + ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_DSGetConstantBuffers(context, 0, 1, &tmp_cb); - todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); - if (tmp_cb) ID3D11Buffer_Release(tmp_cb); + ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); tmp_sampler = (ID3D11SamplerState *)0xdeadbeef; ID3D11DeviceContext1_DSGetSamplers(context, 0, 1, &tmp_sampler); - todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); - if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler); + ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); tmp_ds = (ID3D11DomainShader *)0xdeadbeef; ID3D11DeviceContext1_DSGetShader(context, &tmp_ds, NULL, NULL); - if (ds) todo_wine ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds); - if (tmp_ds) ID3D11DomainShader_Release(tmp_ds); + if (ds) ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds); tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef; ID3D11DeviceContext1_DSGetShaderResources(context, 0, 1, &tmp_srv); - todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); - if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv); + ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_CSGetConstantBuffers(context, 0, 1, &tmp_cb); - todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); - if (tmp_cb) ID3D11Buffer_Release(tmp_cb); + ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); tmp_sampler = (ID3D11SamplerState *)0xdeadbeef; ID3D11DeviceContext1_CSGetSamplers(context, 0, 1, &tmp_sampler); - todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); - if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler); + ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); tmp_cs = (ID3D11ComputeShader *)0xdeadbeef; ID3D11DeviceContext1_CSGetShader(context, &tmp_cs, NULL, NULL); - if (cs) todo_wine ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs); - if (tmp_cs) ID3D11ComputeShader_Release(tmp_cs); + if (cs) ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs); tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef; ID3D11DeviceContext1_CSGetShaderResources(context, 0, 1, &tmp_srv); - todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); - if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv); + ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef; ID3D11DeviceContext1_CSGetUnorderedAccessViews(context, 0, 1, &tmp_uav); - todo_wine ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav); - if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav); + ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav);
topo = 0xdeadbeef; ID3D11DeviceContext1_IAGetPrimitiveTopology(context, &topo); - todo_wine ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo); + ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo); tmp_il = (ID3D11InputLayout *)0xdeadbeef; ID3D11DeviceContext1_IAGetInputLayout(context, &tmp_il); - todo_wine ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il); - if (tmp_il) ID3D11InputLayout_Release(tmp_il); + ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il); tmp_ib = (ID3D11Buffer *)0xdeadbeef; format = 0xdeadbeef; offset = 0xdeadbeef; ID3D11DeviceContext1_IAGetIndexBuffer(context, &tmp_ib, &format, &offset); - todo_wine ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib); - if (tmp_ib) ID3D11Buffer_Release(tmp_ib); - todo_wine ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format); - todo_wine ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset); + ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib); + ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format); + ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset); tmp_vb = (ID3D11Buffer *)0xdeadbeef; stride = 0xdeadbeef; offset = 0xdeadbeef; ID3D11DeviceContext1_IAGetVertexBuffers(context, 0, 1, &tmp_vb, &stride, &offset); - todo_wine ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb); - if (tmp_vb) ID3D11Buffer_Release(tmp_vb); - todo_wine ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride); - todo_wine ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset); + ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb); + ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride); + ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset);
tmp_rtv = (ID3D11RenderTargetView *)0xdeadbeef; tmp_dsv = (ID3D11DepthStencilView *)0xdeadbeef; tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef; ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context, 1, &tmp_rtv, &tmp_dsv, 1, 1, &tmp_uav); - todo_wine ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv); - if (tmp_rtv) ID3D11RenderTargetView_Release(tmp_rtv); - todo_wine ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv); - if (tmp_dsv) ID3D11DepthStencilView_Release(tmp_dsv); - todo_wine ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav); - if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav); + ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv); + ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv); + ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav); tmp_bs = (ID3D11BlendState *)0xdeadbeef; memset(blend_factor, 0xcd, sizeof(blend_factor)); sample_mask = 0xdeadbeef; ID3D11DeviceContext1_OMGetBlendState(context, &tmp_bs, blend_factor, &sample_mask); - todo_wine ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs); - if (tmp_bs) ID3D11BlendState_Release(tmp_bs); - todo_wine ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)), + ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs); + ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)), "Got unexpected blend factor %f,%f,%f,%f.\n", blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]); - todo_wine ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask); + ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask); tmp_dss = (ID3D11DepthStencilState *)0xdeadbeef; stencil_ref = 0xdeadbeef; ID3D11DeviceContext1_OMGetDepthStencilState(context, &tmp_dss, &stencil_ref); - todo_wine ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss); - if (tmp_dss) ID3D11DepthStencilState_Release(tmp_dss); - todo_wine ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref); + ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss); + ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref);
tmp_rs = (ID3D11RasterizerState *)0xdeadbeef; ID3D11DeviceContext1_RSGetState(context, &tmp_rs); - todo_wine ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs); - if (tmp_rs) ID3D11RasterizerState_Release(tmp_rs); + ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs); memset(tmp_vp, 0xa5, sizeof(tmp_vp)); count = 2; ID3D11DeviceContext1_RSGetViewports(context, &count, tmp_vp); - todo_wine ok(count == 0, "Got unexpected viewport count %u.\n", count); + ok(count == 0, "Got unexpected viewport count %u.\n", count); memset(tmp_rect, 0xa5, sizeof(tmp_rect)); count = 2; ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect); @@ -7261,15 +7239,13 @@ static void test_device_context_state(void)
tmp_sob = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob); - todo_wine ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob); - if (tmp_sob) ID3D11Buffer_Release(tmp_sob); + ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob);
tmp_pred = (ID3D11Predicate *)0xdeadbeef; pred_value = 0xdeadbeef; ID3D11DeviceContext1_GetPredication(context, &tmp_pred, &pred_value); - todo_wine ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred); - if (tmp_pred) ID3D11Predicate_Release(tmp_pred); - todo_wine ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value); + ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred); + ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value);
/* updating the device context should also update the device context state */ hr = ID3D11Device1_CreateVertexShader(device, simple_vs, sizeof(simple_vs), NULL, &vs2); @@ -7277,14 +7253,13 @@ static void test_device_context_state(void) ID3D11DeviceContext1_VSSetShader(context, vs2, NULL, 0); ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &tmp_context_state); refcount = ID3DDeviceContextState_Release(tmp_context_state); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); - todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); tmp_vs = (ID3D11VertexShader *)0xdeadbeef; ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* context states may be used with other devices instances too */ d3d11_device2 = create_device(NULL); @@ -7305,17 +7280,16 @@ static void test_device_context_state(void) /* updating context2 vertex shader doesn't update other contexts using the same state */ ID3D11DeviceContext1_VSSetShader(context2, vs, NULL, 0); ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
ID3D11DeviceContext1_SwapDeviceContextState(context2, tmp_context_state, &context_state2); refcount = ID3DDeviceContextState_Release(tmp_context_state); ok(refcount == 0, "Got refcount %u, expected 1.\n", refcount); refcount = ID3DDeviceContextState_Release(context_state2); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); - todo_wine ok(context_state2 == context_state, "Got unexpected state pointer.\n"); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(context_state2 == context_state, "Got unexpected state pointer.\n");
/* swapping the default state on context2 effectively clears the vertex shader */ tmp_vs = (ID3D11VertexShader *)0xdeadbeef; @@ -7333,19 +7307,17 @@ static void test_device_context_state(void) ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount); tmp_vs = (ID3D11VertexShader *)0xdeadbeef; ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* even after swapping it again */ ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, NULL); tmp_vs = (ID3D11VertexShader *)0xdeadbeef; ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* swapping the initial state on context2 doesn't have side effect on context either */ ID3D11DeviceContext1_SwapDeviceContextState(context2, previous_context_state, NULL); @@ -7362,10 +7334,10 @@ static void test_device_context_state(void) refcount = ID3DDeviceContextState_Release(previous_context_state); ok(!refcount, "Got refcount %u, expected 0.\n", refcount); refcount = ID3DDeviceContextState_Release(tmp_context_state); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); refcount = ID3DDeviceContextState_Release(context_state); ok(!refcount, "Got refcount %u, expected 0.\n", refcount); - todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); + ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); refcount = get_refcount(vs); ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);