From: Józef Kucia jkucia@codeweavers.com
Fixes a race condition.
For bug 44557.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/swapchain.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 7a3f1ff95e90..9df40abc70ce 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -135,6 +135,8 @@ void * CDECL wined3d_swapchain_get_parent(const struct wined3d_swapchain *swapch
void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window) { + struct wined3d_device *device = swapchain->device; + if (!window) window = swapchain->device_window; if (window == swapchain->win_handle) @@ -142,6 +144,9 @@ void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWN
TRACE("Setting swapchain %p window from %p to %p.\n", swapchain, swapchain->win_handle, window); + + device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); + swapchain->win_handle = window; }
From: Józef Kucia jkucia@codeweavers.com
Core contexts are enabled by default since 0db4d1c251d293333e2721a78d6156008a90ff6f.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/directx.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index afb97184e396..9bc9c31e0a43 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1857,22 +1857,15 @@ static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_s return HW_VENDOR_NVIDIA; }
-static enum wined3d_d3d_level d3d_level_from_caps(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps, DWORD glsl_version) +static enum wined3d_d3d_level d3d_level_from_caps(const struct shader_caps *shader_caps, + const struct fragment_caps *fragment_caps) { if (shader_caps->vs_version >= 5) return WINED3D_D3D_LEVEL_11; if (shader_caps->vs_version == 4) return WINED3D_D3D_LEVEL_10; if (shader_caps->vs_version == 3) - { - /* wined3d with default settings at the moment doesn't expose SM4+ on - * Mesa drivers. */ - if (glsl_version >= MAKEDWORD_VERSION(4, 30)) - return WINED3D_D3D_LEVEL_11; - if (glsl_version >= MAKEDWORD_VERSION(1, 30)) - return WINED3D_D3D_LEVEL_10; return WINED3D_D3D_LEVEL_9_SM3; - } if (shader_caps->vs_version == 2) return WINED3D_D3D_LEVEL_9_SM2; if (shader_caps->vs_version == 1) @@ -2562,9 +2555,9 @@ static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shad * memory behind our backs if really needed. Note that the amount of video * memory can be overruled using a registry setting. */
- unsigned int i; - enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version); + enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps); enum wined3d_pci_device device; + unsigned int i;
for (i = 0; i < ARRAY_SIZE(card_vendor_table); ++i) {
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d12/tests/d3d12.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d12/tests/d3d12.c b/dlls/d3d12/tests/d3d12.c index c8f17f314ce1..37f5c5147814 100644 --- a/dlls/d3d12/tests/d3d12.c +++ b/dlls/d3d12/tests/d3d12.c @@ -70,11 +70,47 @@ static void set_viewport(D3D12_VIEWPORT *vp, float x, float y, vp->MaxDepth = max_depth; }
+static BOOL use_warp_adapter; +static unsigned int use_adapter_idx; + +static IDXGIAdapter *create_adapter(void) +{ + IDXGIFactory4 *factory; + IDXGIAdapter *adapter; + HRESULT hr; + + if (!use_warp_adapter && !use_adapter_idx) + return NULL; + + hr = CreateDXGIFactory2(0, &IID_IDXGIFactory4, (void **)&factory); + ok(hr == S_OK, "Failed to create factory, hr %#x.\n", hr); + + adapter = NULL; + if (use_warp_adapter) + { + hr = IDXGIFactory4_EnumWarpAdapter(factory, &IID_IDXGIAdapter, (void **)&adapter); + } + else + { + hr = IDXGIFactory4_EnumAdapters(factory, use_adapter_idx, &adapter); + } + IDXGIFactory4_Release(factory); + if (FAILED(hr)) + trace("Failed to get adapter, hr %#x.\n", hr); + return adapter; +} + static ID3D12Device *create_device(void) { + IDXGIAdapter *adapter; ID3D12Device *device; + HRESULT hr;
- if (FAILED(D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device))) + adapter = create_adapter(); + hr = D3D12CreateDevice((IUnknown *)adapter, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device); + if (adapter) + IDXGIAdapter_Release(adapter); + if (FAILED(hr)) return NULL;
return device; @@ -746,6 +782,18 @@ static void test_swapchain_draw(void)
START_TEST(d3d12) { + unsigned int argc, i; + char **argv; + + argc = winetest_get_mainargs(&argv); + for (i = 2; i < argc; ++i) + { + if (!strcmp(argv[i], "--warp")) + use_warp_adapter = TRUE; + else if (!strcmp(argv[i], "--adapter") && i + 1 < argc) + use_adapter_idx = atoi(argv[++i]); + } + test_interfaces(); test_draw(); test_swapchain_draw();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d12/tests/d3d12.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/dlls/d3d12/tests/d3d12.c b/dlls/d3d12/tests/d3d12.c index 37f5c5147814..51967a0c327f 100644 --- a/dlls/d3d12/tests/d3d12.c +++ b/dlls/d3d12/tests/d3d12.c @@ -116,6 +116,37 @@ static ID3D12Device *create_device(void) return device; }
+static void print_adapter_info(void) +{ + DXGI_ADAPTER_DESC adapter_desc; + IDXGIFactory4 *factory; + IDXGIAdapter *adapter; + ID3D12Device *device; + HRESULT hr; + LUID luid; + + if (!(device = create_device())) + return; + luid = ID3D12Device_GetAdapterLuid(device); + ID3D12Device_Release(device); + + hr = CreateDXGIFactory2(0, &IID_IDXGIFactory4, (void **)&factory); + ok(hr == S_OK, "Failed to create factory, hr %#x.\n", hr); + hr = IDXGIFactory4_EnumAdapterByLuid(factory, luid, &IID_IDXGIAdapter, (void **)&adapter); + todo_wine ok(hr == S_OK, "Failed to enum adapter by LUID, hr %#x.\n", hr); + IDXGIFactory4_Release(factory); + + if (FAILED(hr)) + return; + + hr = IDXGIAdapter_GetDesc(adapter, &adapter_desc); + ok(hr == S_OK, "Failed to get adapter desc, hr %#x.\n", hr); + IDXGIAdapter_Release(adapter); + + trace("Adapter: %s, %04x:%04x.\n", wine_dbgstr_w(adapter_desc.Description), + adapter_desc.VendorId, adapter_desc.DeviceId); +} + #define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) { @@ -794,6 +825,8 @@ START_TEST(d3d12) use_adapter_idx = atoi(argv[++i]); }
+ print_adapter_info(); + test_interfaces(); test_draw(); test_swapchain_draw();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d12/tests/d3d12.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d12/tests/d3d12.c b/dlls/d3d12/tests/d3d12.c index 51967a0c327f..a6d7219b9bbd 100644 --- a/dlls/d3d12/tests/d3d12.c +++ b/dlls/d3d12/tests/d3d12.c @@ -813,18 +813,28 @@ static void test_swapchain_draw(void)
START_TEST(d3d12) { + BOOL enable_debug_layer = FALSE; unsigned int argc, i; + ID3D12Debug *debug; char **argv;
argc = winetest_get_mainargs(&argv); for (i = 2; i < argc; ++i) { - if (!strcmp(argv[i], "--warp")) + if (!strcmp(argv[i], "--validate")) + enable_debug_layer = TRUE; + else if (!strcmp(argv[i], "--warp")) use_warp_adapter = TRUE; else if (!strcmp(argv[i], "--adapter") && i + 1 < argc) use_adapter_idx = atoi(argv[++i]); }
+ if (enable_debug_layer && SUCCEEDED(D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug))) + { + ID3D12Debug_EnableDebugLayer(debug); + ID3D12Debug_Release(debug); + } + print_adapter_info();
test_interfaces();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d12/tests/d3d12.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/d3d12/tests/d3d12.c b/dlls/d3d12/tests/d3d12.c index a6d7219b9bbd..99641be0f683 100644 --- a/dlls/d3d12/tests/d3d12.c +++ b/dlls/d3d12/tests/d3d12.c @@ -788,6 +788,9 @@ static void test_swapchain_draw(void) ok(hr == S_OK, "Failed to get swapchain buffer %u, hr %#x.\n", index, hr); ID3D12Device_CreateRenderTargetView(context.device, backbuffer, NULL, context.rtv);
+ transition_sub_resource_state(command_list, backbuffer, 0, + D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
For bug 45315.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/directx.c | 9 ++++++++- dlls/wined3d/wined3d_main.c | 4 ++-- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 9bc9c31e0a43..9642d7d03813 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2608,7 +2608,14 @@ static const struct fragment_pipeline *select_fragment_implementation(const stru
static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info) { - BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20); + BOOL glsl = wined3d_settings.use_glsl && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20); + if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] && !wined3d_settings.use_glsl) + { + ERR_(winediag)("Ignoring the UseGLSL registry key. " + "GLSL is the only supported shader backend on core profile contexts. " + "You need to explicitly set GL version to use legacy contexts.\n"); + glsl = TRUE; + }
if (glsl && gl_info->supported[ARB_VERTEX_SHADER] && gl_info->supported[ARB_FRAGMENT_SHADER]) return &glsl_shader_backend; diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index e322b4de0744..f8a84a17adb4 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -225,8 +225,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) if (!strcmp(buffer,"disabled")) { ERR_(winediag)("The GLSL shader backend has been disabled. You get to keep all the pieces if it breaks.\n"); - TRACE("Use of GL Shading Language disabled\n"); - wined3d_settings.glslRequested = FALSE; + TRACE("Use of GL Shading Language disabled.\n"); + wined3d_settings.use_glsl = FALSE; } } if (!get_config_key(hkey, appkey, "OffscreenRenderingMode", buffer, size) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 33bc463b94c3..d190f7ccfd68 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -385,7 +385,7 @@ struct wined3d_settings unsigned int cs_multithreaded; BOOL explicit_gl_version; DWORD max_gl_version; - BOOL glslRequested; + BOOL use_glsl; int offscreen_rendering_mode; unsigned short pci_vendor_id; unsigned short pci_device_id;
On 11 June 2018 at 12:05, Józef Kucia joseph.kucia@gmail.com wrote:
static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info) {
- BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
- BOOL glsl = wined3d_settings.use_glsl && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
- if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] && !wined3d_settings.use_glsl)
- {
ERR_(winediag)("Ignoring the UseGLSL registry key. "
"GLSL is the only supported shader backend on core profile contexts. "
"You need to explicitly set GL version to use legacy contexts.\n");
I think it's fair enough to warn people that disabling GLSL requires a compatibility context, but note that disabling GLSL isn't exactly supported there either.
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
For bug 45315.
Version 2: Change wording.
--- dlls/wined3d/directx.c | 9 ++++++++- dlls/wined3d/wined3d_main.c | 4 ++-- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 9bc9c31e0a43..baab2e9c1a31 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2608,7 +2608,14 @@ static const struct fragment_pipeline *select_fragment_implementation(const stru
static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info) { - BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20); + BOOL glsl = wined3d_settings.use_glsl && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20); + if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] && !wined3d_settings.use_glsl) + { + ERR_(winediag)("Ignoring the UseGLSL registry key. " + "GLSL is the only shader backend available on core profile contexts. " + "You need to explicitly set GL version to use legacy contexts.\n"); + glsl = TRUE; + }
if (glsl && gl_info->supported[ARB_VERTEX_SHADER] && gl_info->supported[ARB_FRAGMENT_SHADER]) return &glsl_shader_backend; diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index e322b4de0744..f8a84a17adb4 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -225,8 +225,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) if (!strcmp(buffer,"disabled")) { ERR_(winediag)("The GLSL shader backend has been disabled. You get to keep all the pieces if it breaks.\n"); - TRACE("Use of GL Shading Language disabled\n"); - wined3d_settings.glslRequested = FALSE; + TRACE("Use of GL Shading Language disabled.\n"); + wined3d_settings.use_glsl = FALSE; } } if (!get_config_key(hkey, appkey, "OffscreenRenderingMode", buffer, size) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 33bc463b94c3..d190f7ccfd68 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -385,7 +385,7 @@ struct wined3d_settings unsigned int cs_multithreaded; BOOL explicit_gl_version; DWORD max_gl_version; - BOOL glslRequested; + BOOL use_glsl; int offscreen_rendering_mode; unsigned short pci_vendor_id; unsigned short pci_device_id;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com