[PATCH v2 2/6] d3d9: Track the primary stateblock state locally.
Zebediah Figura
z.figura12 at gmail.com
Wed Sep 25 23:05:40 CDT 2019
In preparation for moving the primary stateblock to the client D3D device.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/d3d9/d3d9_private.h | 2 +-
dlls/d3d9/device.c | 14 +++++++++++++-
dlls/wined3d/stateblock.c | 5 +++--
include/wine/wined3d.h | 1 +
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 7c3d77c8a25..03e2aa7f8a0 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -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,
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 953bf4c5419..3e3d5c70500 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -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);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 80e58114c10..1a20e86d3f0 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -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);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index ee28ab1bb94..dcf622ea4fe 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -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
--
2.23.0
More information about the wine-devel
mailing list