Commit b9a440d1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Create the backbuffer rendertarget view only after calling adapter_init_3d().

Otherwise we may not be able to acquire a context to create the view. In practice, this is only an issue for d3d9 and earlier in combination with the Vulkan backend. Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent e7fa4fd1
......@@ -1088,6 +1088,24 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str
if (device->d3d_initialized)
return WINED3DERR_INVALIDCALL;
device->swapchain_count = 1;
if (!(device->swapchains = heap_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Failed to allocate swapchain array.\n");
hr = E_OUTOFMEMORY;
goto err_out;
}
device->swapchains[0] = swapchain;
for (i = 0; i < ARRAY_SIZE(device->state.fb.render_targets); ++i)
if (device->state.fb.render_targets[i])
wined3d_rtv_bind_count_dec(device->state.fb.render_targets[i]);
memset(device->state.fb.render_targets, 0, sizeof(device->state.fb.render_targets));
if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device)))
goto err_out;
device->d3d_initialized = TRUE;
swapchain_desc = &swapchain->state.desc;
if (swapchain_desc->backbuffer_count && swapchain_desc->backbuffer_bind_flags & WINED3D_BIND_RENDER_TARGET)
{
......@@ -1104,27 +1122,11 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str
NULL, &wined3d_null_parent_ops, &device->back_buffer_view)))
{
ERR("Failed to create rendertarget view, hr %#x.\n", hr);
return hr;
}
}
device->swapchain_count = 1;
if (!(device->swapchains = heap_calloc(device->swapchain_count, sizeof(*device->swapchains))))
{
ERR("Failed to allocate swapchain array.\n");
hr = E_OUTOFMEMORY;
device->adapter->adapter_ops->adapter_uninit_3d(device);
device->d3d_initialized = FALSE;
goto err_out;
}
device->swapchains[0] = swapchain;
for (i = 0; i < ARRAY_SIZE(device->state.fb.render_targets); ++i)
if (device->state.fb.render_targets[i])
wined3d_rtv_bind_count_dec(device->state.fb.render_targets[i]);
memset(device->state.fb.render_targets, 0, sizeof(device->state.fb.render_targets));
if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device)))
goto err_out;
device->d3d_initialized = TRUE;
}
device_init_swapchain_state(device, swapchain);
......@@ -1147,11 +1149,6 @@ err_out:
heap_free(device->swapchains);
device->swapchains = NULL;
device->swapchain_count = 0;
if (device->back_buffer_view)
{
wined3d_rendertarget_view_decref(device->back_buffer_view);
device->back_buffer_view = NULL;
}
return hr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment