d3d9: Track the primary stateblock state locally.

In preparation for moving the primary stateblock to the client D3D device.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-09-25 23:05:40 -05:00 committed by Alexandre Julliard
parent 7360e7d488
commit 40dad5a0ec
4 changed files with 18 additions and 4 deletions

View File

@ -116,7 +116,7 @@ struct d3d9_device
UINT implicit_swapchain_count;
struct wined3d_swapchain **implicit_swapchains;
struct wined3d_stateblock *recording;
struct wined3d_stateblock *recording, *state, *update_state;
};
HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wined3d *wined3d,

View File

@ -605,6 +605,7 @@ static ULONG WINAPI DECLSPEC_HOTPATCH d3d9_device_Release(IDirect3DDevice9Ex *if
if (device->recording)
wined3d_stateblock_decref(device->recording);
wined3d_stateblock_decref(device->state);
wined3d_device_release_focus_window(device->wined3d_device);
wined3d_device_decref(device->wined3d_device);
@ -999,6 +1000,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
if (device->recording)
wined3d_stateblock_decref(device->recording);
device->recording = NULL;
device->update_state = device->state;
device->auto_mipmaps = 0;
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE,
!!swapchain_desc.enable_auto_depth_stencil);
@ -2360,7 +2362,7 @@ static HRESULT WINAPI d3d9_device_BeginStateBlock(IDirect3DDevice9Ex *iface)
wined3d_mutex_lock();
if (SUCCEEDED(hr = wined3d_device_begin_stateblock(device->wined3d_device, &stateblock)))
device->recording = stateblock;
device->update_state = device->recording = stateblock;
wined3d_mutex_unlock();
return hr;
@ -2385,6 +2387,7 @@ static HRESULT WINAPI d3d9_device_EndStateBlock(IDirect3DDevice9Ex *iface, IDire
}
wined3d_stateblock = device->recording;
device->recording = NULL;
device->update_state = device->state;
wined3d_mutex_unlock();
if (!(object = heap_alloc_zero(sizeof(*object))))
@ -4497,6 +4500,15 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
count = caps.NumberOfAdaptersInGroup;
if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, WINED3D_SBT_PRIMARY, &device->state)))
{
ERR("Failed to create the primary stateblock, hr %#x.\n", hr);
wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
device->update_state = device->state;
if (flags & D3DCREATE_MULTITHREADED)
wined3d_device_set_multithreaded(device->wined3d_device);

View File

@ -1573,11 +1573,12 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
stateblock->ref = 1;
stateblock->device = device;
wined3d_stateblock_state_init(&stateblock->stateblock_state, device, 0);
wined3d_stateblock_state_init(&stateblock->stateblock_state, device,
type == WINED3D_SBT_PRIMARY ? WINED3D_STATE_INIT_DEFAULT : 0);
stateblock->changed.store_stream_offset = 1;
if (type == WINED3D_SBT_RECORDED)
if (type == WINED3D_SBT_RECORDED || type == WINED3D_SBT_PRIMARY)
return WINED3D_OK;
TRACE("Updating changed flags appropriate for type %#x.\n", type);

View File

@ -774,6 +774,7 @@ enum wined3d_stateblock_type
WINED3D_SBT_PIXEL_STATE = 2,
WINED3D_SBT_VERTEX_STATE = 3,
WINED3D_SBT_RECORDED = 4, /* WineD3D private */
WINED3D_SBT_PRIMARY = 5, /* WineD3D private */
};
enum wined3d_decl_method