Commit 20025850 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

dxgi: Factor out d3d12_swapchain_record_swapchain_blit().

parent 995139bc
......@@ -1308,56 +1308,21 @@ static void vk_cmd_image_barrier(const struct dxgi_vk_funcs *vk_funcs, VkCommand
src_stage_mask, dst_stage_mask, 0, 0, NULL, 0, NULL, 1, &barrier);
}
static HRESULT d3d12_swapchain_prepare_command_buffers(struct d3d12_swapchain *swapchain,
uint32_t queue_family_index, VkImage vk_swapchain_images[DXGI_MAX_SWAP_CHAIN_BUFFERS])
static VkResult d3d12_swapchain_record_swapchain_blit(struct d3d12_swapchain *swapchain,
VkCommandBuffer vk_cmd_buffer, VkImage vk_dst_image, VkImage vk_src_image)
{
const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs;
VkDevice vk_device = swapchain->vk_device;
VkCommandBufferAllocateInfo allocate_info;
VkSemaphoreCreateInfo semaphore_info;
VkCommandBufferBeginInfo begin_info;
VkCommandPoolCreateInfo pool_info;
VkImageBlit blit;
VkFilter filter;
unsigned int i;
VkResult vr;
pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
pool_info.pNext = NULL;
pool_info.flags = 0;
pool_info.queueFamilyIndex = queue_family_index;
if ((vr = vk_funcs->p_vkCreateCommandPool(vk_device, &pool_info,
NULL, &swapchain->vk_cmd_pool)) < 0)
{
WARN("Failed to create command pool, vr %d.\n", vr);
swapchain->vk_cmd_pool = VK_NULL_HANDLE;
return hresult_from_vk_result(vr);
}
allocate_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocate_info.pNext = NULL;
allocate_info.commandPool = swapchain->vk_cmd_pool;
allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocate_info.commandBufferCount = swapchain->buffer_count;
if ((vr = vk_funcs->p_vkAllocateCommandBuffers(vk_device, &allocate_info,
swapchain->vk_cmd_buffers)) < 0)
{
WARN("Failed to allocate command buffers, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
if (swapchain->desc.Width != swapchain->vk_swapchain_width
|| swapchain->desc.Height != swapchain->vk_swapchain_height)
filter = VK_FILTER_LINEAR;
else
filter = VK_FILTER_NEAREST;
for (i = 0; i < swapchain->buffer_count; ++i)
{
VkCommandBuffer vk_cmd_buffer = swapchain->vk_cmd_buffers[i];
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
begin_info.pNext = NULL;
begin_info.flags = 0;
......@@ -1366,14 +1331,13 @@ static HRESULT d3d12_swapchain_prepare_command_buffers(struct d3d12_swapchain *s
if ((vr = vk_funcs->p_vkBeginCommandBuffer(vk_cmd_buffer, &begin_info)) < 0)
{
WARN("Failed to begin command buffer, vr %d.\n", vr);
return hresult_from_vk_result(vr);
return vr;
}
vk_cmd_image_barrier(vk_funcs, vk_cmd_buffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
0, VK_ACCESS_TRANSFER_WRITE_BIT,
VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
vk_swapchain_images[i]);
VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, vk_dst_image);
blit.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
blit.srcSubresource.mipLevel = 0;
......@@ -1394,21 +1358,65 @@ static HRESULT d3d12_swapchain_prepare_command_buffers(struct d3d12_swapchain *s
blit.dstOffsets[1].z = 1;
vk_funcs->p_vkCmdBlitImage(vk_cmd_buffer,
swapchain->vk_images[i], VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
vk_swapchain_images[i], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
vk_src_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
vk_dst_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1, &blit, filter);
vk_cmd_image_barrier(vk_funcs, vk_cmd_buffer,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT, 0,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
vk_swapchain_images[i]);
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, vk_dst_image);
if ((vr = vk_funcs->p_vkEndCommandBuffer(vk_cmd_buffer)) < 0)
{
WARN("Failed to end command buffer, vr %d.\n", vr);
return vr;
}
static HRESULT d3d12_swapchain_prepare_command_buffers(struct d3d12_swapchain *swapchain,
uint32_t queue_family_index, VkImage vk_swapchain_images[DXGI_MAX_SWAP_CHAIN_BUFFERS])
{
const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs;
VkDevice vk_device = swapchain->vk_device;
VkCommandBufferAllocateInfo allocate_info;
VkSemaphoreCreateInfo semaphore_info;
VkCommandPoolCreateInfo pool_info;
unsigned int i;
VkResult vr;
pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
pool_info.pNext = NULL;
pool_info.flags = 0;
pool_info.queueFamilyIndex = queue_family_index;
if ((vr = vk_funcs->p_vkCreateCommandPool(vk_device, &pool_info,
NULL, &swapchain->vk_cmd_pool)) < 0)
{
WARN("Failed to create command pool, vr %d.\n", vr);
swapchain->vk_cmd_pool = VK_NULL_HANDLE;
return hresult_from_vk_result(vr);
}
allocate_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocate_info.pNext = NULL;
allocate_info.commandPool = swapchain->vk_cmd_pool;
allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocate_info.commandBufferCount = swapchain->buffer_count;
if ((vr = vk_funcs->p_vkAllocateCommandBuffers(vk_device, &allocate_info,
swapchain->vk_cmd_buffers)) < 0)
{
WARN("Failed to allocate command buffers, vr %d.\n", vr);
return hresult_from_vk_result(vr);
}
for (i = 0; i < swapchain->buffer_count; ++i)
{
VkCommandBuffer vk_cmd_buffer = swapchain->vk_cmd_buffers[i];
if ((vr = d3d12_swapchain_record_swapchain_blit(swapchain, vk_cmd_buffer,
vk_swapchain_images[i], swapchain->vk_images[i])) < 0)
return hresult_from_vk_result(vr);
}
for (i = 0; i < swapchain->buffer_count; ++i)
......
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