[PATCH v2 3/6] wined3d: Introduce new wined3d_state_create/destroy exports.
Rémi Bernon
rbernon at codeweavers.com
Thu Feb 18 12:42:15 CST 2021
And use them to create wined3d_device state.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/wined3d/device.c | 9 ++++-----
dlls/wined3d/stateblock.c | 23 +++++++++++++++++++++++
dlls/wined3d/wined3d.spec | 3 +++
include/wine/wined3d.h | 4 ++++
4 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5aec094c854..51f74ca1f64 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -251,7 +251,7 @@ void wined3d_device_cleanup(struct wined3d_device *device)
wine_rb_destroy(&device->depth_stencil_states, device_leftover_depth_stencil_state, NULL);
wine_rb_destroy(&device->so_descs, device_free_so_desc, NULL);
- heap_free(device->state);
+ wined3d_state_destroy(device->state);
device->state = NULL;
wined3d_decref(device->wined3d);
device->wined3d = NULL;
@@ -6005,12 +6005,11 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
return hr;
}
- if (!(state = heap_alloc_zero(sizeof(*state))))
+ if (FAILED(hr = wined3d_state_create(device, &state)))
{
- hr = E_OUTOFMEMORY;
+ ERR("Failed to create device state, hr %#x.\n", hr);
goto err;
}
- state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->state = state;
device->max_frame_latency = 3;
@@ -6026,7 +6025,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
return WINED3D_OK;
err:
- if (state) heap_free(state);
+ if (state) wined3d_state_destroy(state);
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
heap_free(device->multistate_funcs[i]);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 46588fa4246..b6bcadaa051 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1869,6 +1869,29 @@ void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_
state_init_default(state, d3d_info);
}
+HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state)
+{
+ struct wined3d_state *object;
+
+ TRACE("device %p, state %p.\n", device, state);
+
+ *state = NULL;
+ if (!(object = heap_alloc_zero(sizeof(*object))))
+ return E_OUTOFMEMORY;
+ state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+
+ *state = object;
+ return S_OK;
+}
+
+void __cdecl wined3d_state_destroy(struct wined3d_state *state)
+{
+ TRACE("state %p.\n", state);
+
+ state_cleanup(state);
+ heap_free(state);
+}
+
static void stateblock_state_init_default(struct wined3d_stateblock_state *state,
const struct wined3d_d3d_info *d3d_info)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 44008119a8d..9d305bfc426 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -164,6 +164,9 @@
@ cdecl wined3d_device_update_texture(ptr ptr ptr)
@ cdecl wined3d_device_validate_device(ptr ptr)
+@ cdecl wined3d_state_create(ptr ptr)
+@ cdecl wined3d_state_destroy(ptr)
+
@ cdecl wined3d_output_find_closest_matching_mode(ptr ptr)
@ cdecl wined3d_output_get_adapter(ptr)
@ cdecl wined3d_output_get_desc(ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 96cb6fc1d86..8de7792e742 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2214,6 +2214,7 @@ struct wined3d_blend_state;
struct wined3d_buffer;
struct wined3d_depth_stencil_state;
struct wined3d_device;
+struct wined3d_state;
struct wined3d_output;
struct wined3d_palette;
struct wined3d_query;
@@ -2544,6 +2545,9 @@ HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
+HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state);
+void __cdecl wined3d_state_destroy(struct wined3d_state *state);
+
HRESULT __cdecl wined3d_output_find_closest_matching_mode(const struct wined3d_output *output,
struct wined3d_display_mode *mode);
struct wined3d_adapter * __cdecl wined3d_output_get_adapter(const struct wined3d_output *output);
--
2.30.0
More information about the wine-devel
mailing list