Commit 6cb23836 authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

dxgi: Factor out d3d12_swapchain_create_image_resources().

parent 237062d0
...@@ -1513,45 +1513,13 @@ static HRESULT d3d12_swapchain_create_command_buffers(struct d3d12_swapchain *sw ...@@ -1513,45 +1513,13 @@ static HRESULT d3d12_swapchain_create_command_buffers(struct d3d12_swapchain *sw
return S_OK; return S_OK;
} }
static HRESULT d3d12_swapchain_create_buffers(struct d3d12_swapchain *swapchain) static HRESULT d3d12_swapchain_create_image_resources(struct d3d12_swapchain *swapchain)
{ {
const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs;
struct vkd3d_image_resource_create_info resource_info; struct vkd3d_image_resource_create_info resource_info;
VkSwapchainKHR vk_swapchain = swapchain->vk_swapchain;
ID3D12CommandQueue *queue = swapchain->command_queue;
VkDevice vk_device = swapchain->vk_device;
ID3D12Device *device = swapchain->device; ID3D12Device *device = swapchain->device;
uint32_t image_count, queue_family_index;
unsigned int i; unsigned int i;
VkResult vr;
HRESULT hr; HRESULT hr;
if ((vr = vk_funcs->p_vkGetSwapchainImagesKHR(vk_device, vk_swapchain, &image_count, NULL)) < 0)
{
WARN("Failed to get Vulkan swapchain images, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
if (image_count > ARRAY_SIZE(swapchain->vk_swapchain_images))
{
FIXME("Unsupported Vulkan swapchain image count %u.\n", image_count);
return E_FAIL;
}
swapchain->buffer_count = image_count;
if ((vr = vk_funcs->p_vkGetSwapchainImagesKHR(vk_device, vk_swapchain,
&image_count, swapchain->vk_swapchain_images)) < 0)
{
WARN("Failed to get Vulkan swapchain images, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
queue_family_index = vkd3d_get_vk_queue_family_index(queue);
if (FAILED(hr = d3d12_swapchain_create_user_buffers(swapchain)))
return hr;
if (FAILED(hr = d3d12_swapchain_create_command_buffers(swapchain, queue_family_index)))
return hr;
if (swapchain->buffers[0]) if (swapchain->buffers[0])
return S_OK; return S_OK;
...@@ -1588,6 +1556,45 @@ static HRESULT d3d12_swapchain_create_buffers(struct d3d12_swapchain *swapchain) ...@@ -1588,6 +1556,45 @@ static HRESULT d3d12_swapchain_create_buffers(struct d3d12_swapchain *swapchain)
return S_OK; return S_OK;
} }
static HRESULT d3d12_swapchain_create_buffers(struct d3d12_swapchain *swapchain)
{
const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs;
VkSwapchainKHR vk_swapchain = swapchain->vk_swapchain;
ID3D12CommandQueue *queue = swapchain->command_queue;
VkDevice vk_device = swapchain->vk_device;
uint32_t image_count, queue_family_index;
VkResult vr;
HRESULT hr;
if ((vr = vk_funcs->p_vkGetSwapchainImagesKHR(vk_device, vk_swapchain, &image_count, NULL)) < 0)
{
WARN("Failed to get Vulkan swapchain images, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
if (image_count > ARRAY_SIZE(swapchain->vk_swapchain_images))
{
FIXME("Unsupported Vulkan swapchain image count %u.\n", image_count);
return E_FAIL;
}
swapchain->buffer_count = image_count;
if ((vr = vk_funcs->p_vkGetSwapchainImagesKHR(vk_device, vk_swapchain,
&image_count, swapchain->vk_swapchain_images)) < 0)
{
WARN("Failed to get Vulkan swapchain images, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
queue_family_index = vkd3d_get_vk_queue_family_index(queue);
if (FAILED(hr = d3d12_swapchain_create_user_buffers(swapchain)))
return hr;
if (FAILED(hr = d3d12_swapchain_create_command_buffers(swapchain, queue_family_index)))
return hr;
return d3d12_swapchain_create_image_resources(swapchain);
}
static VkResult d3d12_swapchain_acquire_next_vulkan_image(struct d3d12_swapchain *swapchain) static VkResult d3d12_swapchain_acquire_next_vulkan_image(struct d3d12_swapchain *swapchain)
{ {
const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs; const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs;
......
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