Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/d3d11/device.c | 3 ++- dlls/wined3d/cs.c | 6 +++--- dlls/wined3d/device.c | 29 +--------------------------- dlls/wined3d/stateblock.c | 35 +++++++++++++++++++++++++++++++--- dlls/wined3d/wined3d.spec | 2 +- dlls/wined3d/wined3d_private.h | 2 +- include/wine/wined3d.h | 3 ++- 7 files changed, 42 insertions(+), 38 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 414560be72a..16a1027beb9 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -295,7 +295,8 @@ static struct wined3d_state *d3d_device_context_state_get_wined3d_state(struct d if ((entry = d3d_device_context_state_get_entry(state, device))) return entry->wined3d_state;
- if (FAILED(wined3d_state_create(device->wined3d_device, &wined3d_state))) + if (FAILED(wined3d_state_create(device->wined3d_device, + (enum wined3d_feature_level *)&device->feature_level, 1, &wined3d_state))) return NULL;
if (!d3d_device_context_state_add_entry(state, device, wined3d_state)) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 69f6a437e97..886a76284ff 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -3008,7 +3008,8 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) FreeLibraryAndExitThread(wined3d_module, 0); }
-struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device, enum wined3d_feature_level feature_level) +struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device, + const enum wined3d_feature_level *levels, unsigned int level_count) { const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; struct wined3d_cs *cs; @@ -3016,12 +3017,11 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device, enum wined3d if (!(cs = heap_alloc_zero(sizeof(*cs)))) return NULL;
- if (!(cs->c.state = heap_alloc_zero(sizeof(*cs->c.state)))) + if (FAILED(wined3d_state_create(device, levels, level_count, &cs->c.state))) { heap_free(cs); return NULL; } - state_init(cs->c.state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT, feature_level);
cs->c.ops = &wined3d_cs_st_ops; cs->c.device = device; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 42d97b2eb85..ca179c753ab 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5976,27 +5976,6 @@ static int wined3d_depth_stencil_state_compare(const void *key, const struct win return memcmp(&state->desc, key, sizeof(state->desc)); }
-static BOOL wined3d_select_feature_level(const struct wined3d_adapter *adapter, - const enum wined3d_feature_level *levels, unsigned int level_count, - enum wined3d_feature_level *selected_level) -{ - const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info; - unsigned int i; - - for (i = 0; i < level_count; ++i) - { - if (levels[i] && d3d_info->feature_level >= levels[i]) - { - *selected_level = levels[i]; - return TRUE; - } - } - - FIXME_(winediag)("None of the requested D3D feature levels is supported on this GPU " - "with the current shader backend.\n"); - return FALSE; -} - HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d, unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count, @@ -6005,15 +5984,9 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx]; const struct wined3d_fragment_pipe_ops *fragment_pipeline; const struct wined3d_vertex_pipe_ops *vertex_pipeline; - enum wined3d_feature_level feature_level; unsigned int i; HRESULT hr;
- if (!wined3d_select_feature_level(adapter, levels, level_count, &feature_level)) - return E_FAIL; - - TRACE("Device feature level %s.\n", wined3d_debug_feature_level(feature_level)); - device->ref = 1; device->wined3d = wined3d; wined3d_incref(device->wined3d); @@ -6058,7 +6031,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
device->max_frame_latency = 3;
- if (!(device->cs = wined3d_cs_create(device, feature_level))) + if (!(device->cs = wined3d_cs_create(device, levels, level_count))) { WARN("Failed to create command stream.\n"); hr = E_FAIL; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 2cef5a6498a..1f1ba262336 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -27,6 +27,7 @@ #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); +WINE_DECLARE_DEBUG_CHANNEL(winediag);
static const DWORD pixel_states_render[] = { @@ -1887,15 +1888,43 @@ 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) +static bool wined3d_select_feature_level(const struct wined3d_adapter *adapter, + const enum wined3d_feature_level *levels, unsigned int level_count, + enum wined3d_feature_level *selected_level) { + const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info; + unsigned int i; + + for (i = 0; i < level_count; ++i) + { + if (levels[i] && d3d_info->feature_level >= levels[i]) + { + *selected_level = levels[i]; + return true; + } + } + + FIXME_(winediag)("None of the requested D3D feature levels is supported on this GPU " + "with the current shader backend.\n"); + return false; +} + +HRESULT CDECL wined3d_state_create(struct wined3d_device *device, + const enum wined3d_feature_level *levels, unsigned int level_count, struct wined3d_state **state) +{ + enum wined3d_feature_level feature_level; struct wined3d_state *object;
- TRACE("device %p, state %p.\n", device, state); + TRACE("device %p, levels %p, level_count %u, state %p.\n", device, levels, level_count, state); + + if (!wined3d_select_feature_level(device->adapter, levels, level_count, &feature_level)) + return E_FAIL; + + TRACE("Selected feature level %s.\n", wined3d_debug_feature_level(feature_level));
if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY; - state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT, device->cs->c.state->feature_level); + state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT, feature_level);
*state = object; return S_OK; diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index c91f488a7b4..3fe3e0cfd89 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -245,7 +245,7 @@ @ cdecl wined3d_shader_resource_view_get_parent(ptr) @ cdecl wined3d_shader_resource_view_incref(ptr)
-@ cdecl wined3d_state_create(ptr ptr) +@ cdecl wined3d_state_create(ptr ptr long ptr) @ cdecl wined3d_state_destroy(ptr) @ cdecl wined3d_state_get_feature_level(ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index e934d0f4b87..a8947f444cd 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4717,7 +4717,7 @@ struct wined3d_cs };
struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device, - enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN; + const enum wined3d_feature_level *levels, unsigned int level_count) DECLSPEC_HIDDEN; void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN; void wined3d_cs_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 77c6c223b7b..3c091263742 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2745,7 +2745,8 @@ void __cdecl wined3d_shader_resource_view_generate_mipmaps(struct wined3d_shader void * __cdecl wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view); ULONG __cdecl wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view);
-HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state); +HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, + const enum wined3d_feature_level *levels, unsigned int level_count, struct wined3d_state **state); void __cdecl wined3d_state_destroy(struct wined3d_state *state); enum wined3d_feature_level __cdecl wined3d_state_get_feature_level(const struct wined3d_state *state);