vkd3d: Use VK_KHR_create_renderpass2
We need this before implementing TIER_2 variable rate shading. Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
parent
e89dd8cf87
commit
65b13f6cd6
|
@ -2074,12 +2074,14 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
const D3D12_RECT *rects)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
|
||||
VkAttachmentDescription attachment_desc;
|
||||
VkAttachmentReference attachment_ref;
|
||||
VkSubpassDependency dependencies[2];
|
||||
VkSubpassDescription subpass_desc;
|
||||
VkAttachmentDescription2KHR attachment_desc;
|
||||
VkAttachmentReference2KHR attachment_ref;
|
||||
VkSubpassBeginInfoKHR subpass_begin_info;
|
||||
VkSubpassDependency2KHR dependencies[2];
|
||||
VkSubpassDescription2KHR subpass_desc;
|
||||
VkSubpassEndInfoKHR subpass_end_info;
|
||||
VkRenderPassCreateInfo2KHR pass_info;
|
||||
VkRenderPassBeginInfo begin_info;
|
||||
VkRenderPassCreateInfo pass_info;
|
||||
VkFramebuffer vk_framebuffer;
|
||||
VkRenderPass vk_render_pass;
|
||||
VkPipelineStageFlags stages;
|
||||
|
@ -2088,6 +2090,8 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
bool clear_op;
|
||||
VkResult vr;
|
||||
|
||||
attachment_desc.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
|
||||
attachment_desc.pNext = NULL;
|
||||
attachment_desc.flags = 0;
|
||||
attachment_desc.format = view->format->vk_format;
|
||||
attachment_desc.samples = vk_samples_from_dxgi_sample_desc(&resource->desc.SampleDesc);
|
||||
|
@ -2098,11 +2102,17 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
attachment_desc.initialLayout = resource->common_layout;
|
||||
attachment_desc.finalLayout = resource->common_layout;
|
||||
|
||||
attachment_ref.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
|
||||
attachment_ref.pNext = NULL;
|
||||
attachment_ref.attachment = 0;
|
||||
attachment_ref.layout = view->info.texture.vk_layout;
|
||||
attachment_ref.aspectMask = 0; /* input attachment aspect mask */
|
||||
|
||||
subpass_desc.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR;
|
||||
subpass_desc.pNext = NULL;
|
||||
subpass_desc.flags = 0;
|
||||
subpass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpass_desc.viewMask = 0;
|
||||
subpass_desc.inputAttachmentCount = 0;
|
||||
subpass_desc.pInputAttachments = NULL;
|
||||
subpass_desc.colorAttachmentCount = 0;
|
||||
|
@ -2149,6 +2159,8 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
subpass_desc.pColorAttachments = &attachment_ref;
|
||||
}
|
||||
|
||||
dependencies[0].sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
|
||||
dependencies[0].pNext = NULL;
|
||||
dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependencies[0].dstSubpass = 0;
|
||||
dependencies[0].srcStageMask = stages;
|
||||
|
@ -2156,7 +2168,10 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
dependencies[0].srcAccessMask = 0;
|
||||
dependencies[0].dstAccessMask = access;
|
||||
dependencies[0].dependencyFlags = 0;
|
||||
dependencies[0].viewOffset = 0;
|
||||
|
||||
dependencies[1].sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
|
||||
dependencies[1].pNext = NULL;
|
||||
dependencies[1].srcSubpass = 0;
|
||||
dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependencies[1].srcStageMask = stages;
|
||||
|
@ -2164,8 +2179,9 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
dependencies[1].srcAccessMask = access;
|
||||
dependencies[1].dstAccessMask = 0;
|
||||
dependencies[1].dependencyFlags = 0;
|
||||
dependencies[1].viewOffset = 0;
|
||||
|
||||
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR;
|
||||
pass_info.pNext = NULL;
|
||||
pass_info.flags = 0;
|
||||
pass_info.attachmentCount = 1;
|
||||
|
@ -2174,8 +2190,10 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
pass_info.pSubpasses = &subpass_desc;
|
||||
pass_info.dependencyCount = ARRAY_SIZE(dependencies);
|
||||
pass_info.pDependencies = dependencies;
|
||||
pass_info.correlatedViewMaskCount = 0;
|
||||
pass_info.pCorrelatedViewMasks = NULL;
|
||||
|
||||
if ((vr = VK_CALL(vkCreateRenderPass(list->device->vk_device, &pass_info, NULL, &vk_render_pass))) < 0)
|
||||
if ((vr = VK_CALL(vkCreateRenderPass2KHR(list->device->vk_device, &pass_info, NULL, &vk_render_pass))) < 0)
|
||||
{
|
||||
WARN("Failed to create Vulkan render pass, vr %d.\n", vr);
|
||||
return;
|
||||
|
@ -2198,6 +2216,10 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
return;
|
||||
}
|
||||
|
||||
subpass_begin_info.sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR;
|
||||
subpass_begin_info.pNext = NULL;
|
||||
subpass_begin_info.contents = VK_SUBPASS_CONTENTS_INLINE;
|
||||
|
||||
begin_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||
begin_info.pNext = NULL;
|
||||
begin_info.renderPass = vk_render_pass;
|
||||
|
@ -2209,8 +2231,8 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
begin_info.clearValueCount = clear_op ? 1 : 0;
|
||||
begin_info.pClearValues = clear_op ? clear_value : NULL;
|
||||
|
||||
VK_CALL(vkCmdBeginRenderPass(list->vk_command_buffer,
|
||||
&begin_info, VK_SUBPASS_CONTENTS_INLINE));
|
||||
VK_CALL(vkCmdBeginRenderPass2KHR(list->vk_command_buffer,
|
||||
&begin_info, &subpass_begin_info));
|
||||
|
||||
if (!clear_op)
|
||||
{
|
||||
|
@ -2218,7 +2240,10 @@ static void d3d12_command_list_clear_attachment_pass(struct d3d12_command_list *
|
|||
clear_aspects, clear_value, rect_count, rects);
|
||||
}
|
||||
|
||||
VK_CALL(vkCmdEndRenderPass(list->vk_command_buffer));
|
||||
subpass_end_info.sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR;
|
||||
subpass_end_info.pNext = NULL;
|
||||
|
||||
VK_CALL(vkCmdEndRenderPass2KHR(list->vk_command_buffer, &subpass_end_info));
|
||||
}
|
||||
|
||||
static void d3d12_command_list_clear_attachment_deferred(struct d3d12_command_list *list, unsigned int attachment_idx,
|
||||
|
@ -3022,7 +3047,13 @@ static void d3d12_command_list_end_current_render_pass(struct d3d12_command_list
|
|||
}
|
||||
|
||||
if (list->current_render_pass)
|
||||
VK_CALL(vkCmdEndRenderPass(list->vk_command_buffer));
|
||||
{
|
||||
VkSubpassEndInfoKHR subpass_end_info;
|
||||
subpass_end_info.sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR;
|
||||
subpass_end_info.pNext = NULL;
|
||||
|
||||
VK_CALL(vkCmdEndRenderPass2KHR(list->vk_command_buffer, &subpass_end_info));
|
||||
}
|
||||
|
||||
/* Don't emit barriers for temporary suspendion of the render pass */
|
||||
if (!suspend && (list->current_render_pass || list->render_pass_suspended))
|
||||
|
@ -4773,7 +4804,8 @@ static bool d3d12_command_list_begin_render_pass(struct d3d12_command_list *list
|
|||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
|
||||
struct d3d12_graphics_pipeline_state *graphics;
|
||||
struct VkRenderPassBeginInfo begin_desc;
|
||||
VkSubpassBeginInfoKHR subpass_begin_info;
|
||||
VkRenderPassBeginInfo begin_desc;
|
||||
VkRenderPass vk_render_pass;
|
||||
|
||||
if (!d3d12_command_list_update_graphics_pipeline(list))
|
||||
|
@ -4813,7 +4845,12 @@ static bool d3d12_command_list_begin_render_pass(struct d3d12_command_list *list
|
|||
&begin_desc.renderArea.extent.width, &begin_desc.renderArea.extent.height, NULL);
|
||||
begin_desc.clearValueCount = 0;
|
||||
begin_desc.pClearValues = NULL;
|
||||
VK_CALL(vkCmdBeginRenderPass(list->vk_command_buffer, &begin_desc, VK_SUBPASS_CONTENTS_INLINE));
|
||||
|
||||
subpass_begin_info.sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR;
|
||||
subpass_begin_info.pNext = NULL;
|
||||
subpass_begin_info.contents = VK_SUBPASS_CONTENTS_INLINE;
|
||||
|
||||
VK_CALL(vkCmdBeginRenderPass2KHR(list->vk_command_buffer, &begin_desc, &subpass_begin_info));
|
||||
|
||||
list->current_render_pass = vk_render_pass;
|
||||
|
||||
|
@ -5191,9 +5228,11 @@ static void d3d12_command_list_copy_image(struct d3d12_command_list *list,
|
|||
VkPipelineStageFlags src_stages, dst_stages;
|
||||
struct vkd3d_copy_image_info pipeline_info;
|
||||
VkImageMemoryBarrier vk_image_barriers[2];
|
||||
VkSubpassBeginInfoKHR subpass_begin_info;
|
||||
VkWriteDescriptorSet vk_descriptor_write;
|
||||
struct vkd3d_copy_image_args push_args;
|
||||
struct vkd3d_view *dst_view, *src_view;
|
||||
VkSubpassEndInfoKHR subpass_end_info;
|
||||
VkAccessFlags src_access, dst_access;
|
||||
VkImageLayout src_layout, dst_layout;
|
||||
bool dst_is_depth_stencil, use_copy;
|
||||
|
@ -5357,6 +5396,13 @@ static void d3d12_command_list_copy_image(struct d3d12_command_list *list,
|
|||
begin_info.renderArea.extent.width = extent.width;
|
||||
begin_info.renderArea.extent.height = extent.height;
|
||||
|
||||
subpass_begin_info.sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR;
|
||||
subpass_begin_info.pNext = NULL;
|
||||
subpass_begin_info.contents = VK_SUBPASS_CONTENTS_INLINE;
|
||||
|
||||
subpass_end_info.sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR;
|
||||
subpass_end_info.pNext = NULL;
|
||||
|
||||
viewport.x = (float)region->dstOffset.x;
|
||||
viewport.y = (float)region->dstOffset.y;
|
||||
viewport.width = (float)region->extent.width;
|
||||
|
@ -5399,7 +5445,7 @@ static void d3d12_command_list_copy_image(struct d3d12_command_list *list,
|
|||
|
||||
VK_CALL(vkUpdateDescriptorSets(list->device->vk_device, 1, &vk_descriptor_write, 0, NULL));
|
||||
|
||||
VK_CALL(vkCmdBeginRenderPass(list->vk_command_buffer, &begin_info, VK_SUBPASS_CONTENTS_INLINE));
|
||||
VK_CALL(vkCmdBeginRenderPass2KHR(list->vk_command_buffer, &begin_info, &subpass_begin_info));
|
||||
VK_CALL(vkCmdBindPipeline(list->vk_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_info.vk_pipeline));
|
||||
VK_CALL(vkCmdSetViewport(list->vk_command_buffer, 0, 1, &viewport));
|
||||
VK_CALL(vkCmdSetScissor(list->vk_command_buffer, 0, 1, &scissor));
|
||||
|
@ -5408,7 +5454,7 @@ static void d3d12_command_list_copy_image(struct d3d12_command_list *list,
|
|||
VK_CALL(vkCmdPushConstants(list->vk_command_buffer, pipeline_info.vk_pipeline_layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(push_args), &push_args));
|
||||
VK_CALL(vkCmdDraw(list->vk_command_buffer, 3, region->dstSubresource.layerCount, 0, 0));
|
||||
VK_CALL(vkCmdEndRenderPass(list->vk_command_buffer));
|
||||
VK_CALL(vkCmdEndRenderPass2KHR(list->vk_command_buffer, &subpass_end_info));
|
||||
|
||||
cleanup:
|
||||
if (dst_view)
|
||||
|
|
|
@ -1661,6 +1661,12 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device,
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (!vulkan_info->KHR_create_renderpass2)
|
||||
{
|
||||
ERR("KHR_create_renderpass2 is not supported by this implementation. This is required for correct operation.\n");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (vulkan_info->KHR_fragment_shading_rate)
|
||||
physical_device_info->additional_shading_rates_supported = d3d12_device_determine_additional_shading_rates_supported(device);
|
||||
|
||||
|
|
|
@ -141,10 +141,10 @@ static VkResult vkd3d_meta_create_render_pass(struct d3d12_device *device, VkSam
|
|||
const struct vkd3d_format *format, VkRenderPass *vk_render_pass)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
VkAttachmentDescription attachment_info;
|
||||
VkAttachmentReference attachment_ref;
|
||||
VkSubpassDescription subpass_info;
|
||||
VkRenderPassCreateInfo pass_info;
|
||||
VkAttachmentDescription2KHR attachment_desc;
|
||||
VkAttachmentReference2KHR attachment_ref;
|
||||
VkSubpassDescription2KHR subpass_desc;
|
||||
VkRenderPassCreateInfo2KHR pass_info;
|
||||
bool has_depth_target;
|
||||
VkImageLayout layout;
|
||||
VkResult vr;
|
||||
|
@ -157,41 +157,51 @@ static VkResult vkd3d_meta_create_render_pass(struct d3d12_device *device, VkSam
|
|||
? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
|
||||
: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
attachment_info.flags = 0;
|
||||
attachment_info.format = format->vk_format;
|
||||
attachment_info.samples = samples;
|
||||
attachment_info.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
attachment_info.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachment_info.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
attachment_info.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachment_info.initialLayout = layout;
|
||||
attachment_info.finalLayout = layout;
|
||||
attachment_desc.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
|
||||
attachment_desc.pNext = NULL;
|
||||
attachment_desc.flags = 0;
|
||||
attachment_desc.format = format->vk_format;
|
||||
attachment_desc.samples = samples;
|
||||
attachment_desc.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
attachment_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachment_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
attachment_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachment_desc.initialLayout = layout;
|
||||
attachment_desc.finalLayout = layout;
|
||||
|
||||
attachment_ref.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
|
||||
attachment_ref.pNext = NULL;
|
||||
attachment_ref.attachment = 0;
|
||||
attachment_ref.layout = layout;
|
||||
attachment_ref.aspectMask = 0; /* input attachment aspect mask */
|
||||
|
||||
subpass_info.flags = 0;
|
||||
subpass_info.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpass_info.inputAttachmentCount = 0;
|
||||
subpass_info.pInputAttachments = NULL;
|
||||
subpass_info.colorAttachmentCount = has_depth_target ? 0 : 1;
|
||||
subpass_info.pColorAttachments = has_depth_target ? NULL : &attachment_ref;
|
||||
subpass_info.pResolveAttachments = NULL;
|
||||
subpass_info.pDepthStencilAttachment = has_depth_target ? &attachment_ref : NULL;
|
||||
subpass_info.preserveAttachmentCount = 0;
|
||||
subpass_info.pPreserveAttachments = NULL;
|
||||
subpass_desc.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR;
|
||||
subpass_desc.pNext = NULL;
|
||||
subpass_desc.flags = 0;
|
||||
subpass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpass_desc.viewMask = 0;
|
||||
subpass_desc.inputAttachmentCount = 0;
|
||||
subpass_desc.pInputAttachments = NULL;
|
||||
subpass_desc.colorAttachmentCount = has_depth_target ? 0 : 1;
|
||||
subpass_desc.pColorAttachments = has_depth_target ? NULL : &attachment_ref;
|
||||
subpass_desc.pResolveAttachments = NULL;
|
||||
subpass_desc.pDepthStencilAttachment = has_depth_target ? &attachment_ref : NULL;
|
||||
subpass_desc.preserveAttachmentCount = 0;
|
||||
subpass_desc.pPreserveAttachments = NULL;
|
||||
|
||||
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR;
|
||||
pass_info.pNext = NULL;
|
||||
pass_info.flags = 0;
|
||||
pass_info.attachmentCount = 1;
|
||||
pass_info.pAttachments = &attachment_info;
|
||||
pass_info.pAttachments = &attachment_desc;
|
||||
pass_info.subpassCount = 1;
|
||||
pass_info.pSubpasses = &subpass_info;
|
||||
pass_info.pSubpasses = &subpass_desc;
|
||||
pass_info.dependencyCount = 0;
|
||||
pass_info.pDependencies = NULL;
|
||||
pass_info.correlatedViewMaskCount = 0;
|
||||
pass_info.pCorrelatedViewMasks = NULL;
|
||||
|
||||
if ((vr = VK_CALL(vkCreateRenderPass(device->vk_device, &pass_info, NULL, vk_render_pass))) < 0)
|
||||
if ((vr = VK_CALL(vkCreateRenderPass2KHR(device->vk_device, &pass_info, NULL, vk_render_pass))) < 0)
|
||||
ERR("Failed to create render pass, vr %d.\n", vr);
|
||||
|
||||
return vr;
|
||||
|
@ -627,22 +637,14 @@ static VkResult vkd3d_meta_create_swapchain_render_pass(struct d3d12_device *dev
|
|||
const struct vkd3d_swapchain_pipeline_key *key, VkRenderPass *render_pass)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
VkRenderPassCreateInfo render_pass_info;
|
||||
VkAttachmentDescription attachment_desc;
|
||||
VkAttachmentReference attachment_ref;
|
||||
VkSubpassDescription subpass_desc;
|
||||
VkSubpassDependency subpass_dep;
|
||||
|
||||
render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
render_pass_info.pNext = NULL;
|
||||
render_pass_info.flags = 0;
|
||||
render_pass_info.attachmentCount = 1;
|
||||
render_pass_info.pAttachments = &attachment_desc;
|
||||
render_pass_info.subpassCount = 1;
|
||||
render_pass_info.pSubpasses = &subpass_desc;
|
||||
render_pass_info.dependencyCount = 1;
|
||||
render_pass_info.pDependencies = &subpass_dep;
|
||||
VkRenderPassCreateInfo2KHR render_pass_info;
|
||||
VkAttachmentDescription2KHR attachment_desc;
|
||||
VkAttachmentReference2KHR attachment_ref;
|
||||
VkSubpassDescription2KHR subpass_desc;
|
||||
VkSubpassDependency2KHR subpass_dep;
|
||||
|
||||
attachment_desc.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
|
||||
attachment_desc.pNext = NULL;
|
||||
attachment_desc.loadOp = key->load_op;
|
||||
attachment_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachment_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
|
@ -653,14 +655,28 @@ static VkResult vkd3d_meta_create_swapchain_render_pass(struct d3d12_device *dev
|
|||
attachment_desc.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
attachment_desc.flags = 0;
|
||||
|
||||
attachment_ref.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
|
||||
attachment_ref.pNext = NULL;
|
||||
attachment_ref.attachment = 0;
|
||||
attachment_ref.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
attachment_ref.aspectMask = 0; /* input attachment aspect mask */
|
||||
|
||||
memset(&subpass_desc, 0, sizeof(subpass_desc));
|
||||
subpass_desc.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR;
|
||||
subpass_desc.pNext = NULL;
|
||||
subpass_desc.flags = 0;
|
||||
subpass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpass_desc.viewMask = 0;
|
||||
subpass_desc.inputAttachmentCount = 0;
|
||||
subpass_desc.pInputAttachments = NULL;
|
||||
subpass_desc.colorAttachmentCount = 1;
|
||||
subpass_desc.pColorAttachments = &attachment_ref;
|
||||
subpass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpass_desc.pResolveAttachments = NULL;
|
||||
subpass_desc.pDepthStencilAttachment = NULL;
|
||||
subpass_desc.preserveAttachmentCount = 0;
|
||||
subpass_desc.pPreserveAttachments = NULL;
|
||||
|
||||
subpass_dep.sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
|
||||
subpass_dep.pNext = NULL;
|
||||
subpass_dep.srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
subpass_dep.dstSubpass = 0;
|
||||
subpass_dep.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
|
@ -668,8 +684,21 @@ static VkResult vkd3d_meta_create_swapchain_render_pass(struct d3d12_device *dev
|
|||
subpass_dep.srcAccessMask = 0;
|
||||
subpass_dep.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
subpass_dep.dependencyFlags = 0;
|
||||
subpass_dep.viewOffset = 0;
|
||||
|
||||
return VK_CALL(vkCreateRenderPass(device->vk_device, &render_pass_info, NULL, render_pass));
|
||||
render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR;
|
||||
render_pass_info.pNext = NULL;
|
||||
render_pass_info.flags = 0;
|
||||
render_pass_info.attachmentCount = 1;
|
||||
render_pass_info.pAttachments = &attachment_desc;
|
||||
render_pass_info.subpassCount = 1;
|
||||
render_pass_info.pSubpasses = &subpass_desc;
|
||||
render_pass_info.dependencyCount = 1;
|
||||
render_pass_info.pDependencies = &subpass_dep;
|
||||
render_pass_info.correlatedViewMaskCount = 0;
|
||||
render_pass_info.pCorrelatedViewMasks = NULL;
|
||||
|
||||
return VK_CALL(vkCreateRenderPass2KHR(device->vk_device, &render_pass_info, NULL, render_pass));
|
||||
}
|
||||
|
||||
static HRESULT vkd3d_meta_create_swapchain_pipeline(struct vkd3d_meta_ops *meta_ops,
|
||||
|
|
|
@ -1352,14 +1352,14 @@ static VkImageLayout vkd3d_render_pass_get_depth_stencil_layout(const struct vkd
|
|||
static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pass_cache *cache,
|
||||
struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
|
||||
{
|
||||
VkAttachmentReference attachment_references[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1];
|
||||
VkAttachmentDescription attachments[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1];
|
||||
VkAttachmentReference2KHR attachment_references[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1];
|
||||
VkAttachmentDescription2KHR attachments[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1];
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
struct vkd3d_render_pass_entry *entry;
|
||||
unsigned int index, attachment_index;
|
||||
VkSubpassDependency dependencies[2];
|
||||
VkSubpassDescription sub_pass_desc;
|
||||
VkRenderPassCreateInfo pass_info;
|
||||
VkSubpassDependency2KHR dependencies[2];
|
||||
VkSubpassDescription2KHR sub_pass_desc;
|
||||
VkRenderPassCreateInfo2KHR pass_info;
|
||||
VkPipelineStageFlags stages;
|
||||
bool have_depth_stencil;
|
||||
unsigned int rt_count;
|
||||
|
@ -1386,11 +1386,16 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
{
|
||||
if (!key->vk_formats[index])
|
||||
{
|
||||
attachment_references[index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
|
||||
attachment_references[index].pNext = NULL;
|
||||
attachment_references[index].attachment = VK_ATTACHMENT_UNUSED;
|
||||
attachment_references[index].layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
attachment_references[index].aspectMask = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
attachments[attachment_index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
|
||||
attachments[attachment_index].pNext = NULL;
|
||||
attachments[attachment_index].flags = 0;
|
||||
attachments[attachment_index].format = key->vk_formats[index];
|
||||
attachments[attachment_index].samples = key->sample_count;
|
||||
|
@ -1401,8 +1406,11 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
attachments[attachment_index].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
attachments[attachment_index].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
attachment_references[index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
|
||||
attachment_references[index].pNext = NULL;
|
||||
attachment_references[index].attachment = attachment_index;
|
||||
attachment_references[index].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
attachment_references[index].aspectMask = 0;
|
||||
|
||||
stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
++attachment_index;
|
||||
|
@ -1412,6 +1420,8 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
{
|
||||
VkImageLayout depth_layout = vkd3d_render_pass_get_depth_stencil_layout(key);
|
||||
|
||||
attachments[attachment_index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
|
||||
attachments[attachment_index].pNext = NULL;
|
||||
attachments[attachment_index].flags = 0;
|
||||
attachments[attachment_index].format = key->vk_formats[index];
|
||||
attachments[attachment_index].samples = key->sample_count;
|
||||
|
@ -1422,14 +1432,19 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
attachments[attachment_index].initialLayout = depth_layout;
|
||||
attachments[attachment_index].finalLayout = depth_layout;
|
||||
|
||||
attachment_references[index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
|
||||
attachment_references[index].pNext = NULL;
|
||||
attachment_references[index].attachment = attachment_index;
|
||||
attachment_references[index].layout = depth_layout;
|
||||
attachment_references[index].aspectMask = 0;
|
||||
|
||||
stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
||||
attachment_index++;
|
||||
}
|
||||
|
||||
/* HACK: Stage masks should technically not be 0 */
|
||||
dependencies[0].sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
|
||||
dependencies[0].pNext = NULL;
|
||||
dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependencies[0].dstSubpass = 0;
|
||||
dependencies[0].srcStageMask = stages;
|
||||
|
@ -1437,7 +1452,10 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
dependencies[0].srcAccessMask = 0;
|
||||
dependencies[0].dstAccessMask = 0;
|
||||
dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
dependencies[0].viewOffset = 0;
|
||||
|
||||
dependencies[1].sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
|
||||
dependencies[1].pNext = NULL;
|
||||
dependencies[1].srcSubpass = 0;
|
||||
dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependencies[1].srcStageMask = stages;
|
||||
|
@ -1445,29 +1463,31 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
dependencies[1].srcAccessMask = 0;
|
||||
dependencies[1].dstAccessMask = 0;
|
||||
dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
dependencies[1].viewOffset = 0;
|
||||
|
||||
sub_pass_desc.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR;
|
||||
sub_pass_desc.pNext = NULL;
|
||||
sub_pass_desc.flags = 0;
|
||||
sub_pass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
sub_pass_desc.viewMask = 0;
|
||||
sub_pass_desc.inputAttachmentCount = 0;
|
||||
sub_pass_desc.pInputAttachments = NULL;
|
||||
sub_pass_desc.colorAttachmentCount = rt_count;
|
||||
sub_pass_desc.pColorAttachments = attachment_references;
|
||||
sub_pass_desc.pResolveAttachments = NULL;
|
||||
if (have_depth_stencil)
|
||||
sub_pass_desc.pDepthStencilAttachment = &attachment_references[rt_count];
|
||||
else
|
||||
sub_pass_desc.pDepthStencilAttachment = NULL;
|
||||
sub_pass_desc.pDepthStencilAttachment = have_depth_stencil
|
||||
? &attachment_references[rt_count]
|
||||
: NULL;
|
||||
sub_pass_desc.preserveAttachmentCount = 0;
|
||||
sub_pass_desc.pPreserveAttachments = NULL;
|
||||
|
||||
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR;
|
||||
pass_info.pNext = NULL;
|
||||
pass_info.flags = 0;
|
||||
pass_info.attachmentCount = attachment_index;
|
||||
pass_info.pAttachments = attachments;
|
||||
pass_info.subpassCount = 1;
|
||||
pass_info.pSubpasses = &sub_pass_desc;
|
||||
|
||||
if (stages)
|
||||
{
|
||||
pass_info.dependencyCount = ARRAY_SIZE(dependencies);
|
||||
|
@ -1478,8 +1498,10 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
|
|||
pass_info.dependencyCount = 0;
|
||||
pass_info.pDependencies = NULL;
|
||||
}
|
||||
pass_info.correlatedViewMaskCount = 0;
|
||||
pass_info.pCorrelatedViewMasks = NULL;
|
||||
|
||||
if ((vr = VK_CALL(vkCreateRenderPass(device->vk_device, &pass_info, NULL, vk_render_pass))) >= 0)
|
||||
if ((vr = VK_CALL(vkCreateRenderPass2KHR(device->vk_device, &pass_info, NULL, vk_render_pass))) >= 0)
|
||||
{
|
||||
entry->vk_render_pass = *vk_render_pass;
|
||||
++cache->render_pass_count;
|
||||
|
|
|
@ -975,6 +975,8 @@ static VkResult d3d12_swapchain_record_swapchain_blit(struct d3d12_swapchain *sw
|
|||
VkCommandBuffer vk_cmd_buffer, unsigned int dst_index, unsigned int src_index)
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = d3d12_swapchain_procs(swapchain);
|
||||
VkSubpassBeginInfoKHR subpass_begin_info;
|
||||
VkSubpassEndInfoKHR subpass_end_info;
|
||||
VkCommandBufferBeginInfo begin_info;
|
||||
VkRenderPassBeginInfo rp_info;
|
||||
VkClearValue clear_value;
|
||||
|
@ -1004,6 +1006,13 @@ static VkResult d3d12_swapchain_record_swapchain_blit(struct d3d12_swapchain *sw
|
|||
rp_info.renderArea.extent.width = swapchain->vk_swapchain_width;
|
||||
rp_info.renderArea.extent.height = swapchain->vk_swapchain_height;
|
||||
|
||||
subpass_begin_info.sType = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR;
|
||||
subpass_begin_info.pNext = NULL;
|
||||
subpass_begin_info.contents = VK_SUBPASS_CONTENTS_INLINE;
|
||||
|
||||
subpass_end_info.sType = VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR;
|
||||
subpass_end_info.pNext = NULL;
|
||||
|
||||
if (swapchain->desc.Scaling == DXGI_SCALING_NONE)
|
||||
{
|
||||
rp_info.clearValueCount = 1;
|
||||
|
@ -1019,7 +1028,7 @@ static VkResult d3d12_swapchain_record_swapchain_blit(struct d3d12_swapchain *sw
|
|||
viewport.minDepth = 0.0f;
|
||||
viewport.maxDepth = 1.0f;
|
||||
|
||||
VK_CALL(vkCmdBeginRenderPass(vk_cmd_buffer, &rp_info, VK_SUBPASS_CONTENTS_INLINE));
|
||||
VK_CALL(vkCmdBeginRenderPass2KHR(vk_cmd_buffer, &rp_info, &subpass_begin_info));
|
||||
if (swapchain->desc.Scaling == DXGI_SCALING_NONE)
|
||||
{
|
||||
viewport.width = (float)swapchain->desc.Width;
|
||||
|
@ -1039,7 +1048,7 @@ static VkResult d3d12_swapchain_record_swapchain_blit(struct d3d12_swapchain *sw
|
|||
swapchain->pipeline.vk_pipeline_layout, 0, 1, &swapchain->descriptors.sets[src_index],
|
||||
0, NULL));
|
||||
VK_CALL(vkCmdDraw(vk_cmd_buffer, 3, 1, 0, 0));
|
||||
VK_CALL(vkCmdEndRenderPass(vk_cmd_buffer));
|
||||
VK_CALL(vkCmdEndRenderPass2KHR(vk_cmd_buffer, &subpass_end_info));
|
||||
|
||||
if ((vr = vk_procs->vkEndCommandBuffer(vk_cmd_buffer)) < 0)
|
||||
WARN("Failed to end command buffer, vr %d.\n", vr);
|
||||
|
|
|
@ -218,6 +218,12 @@ VK_DEVICE_EXT_PFN(vkCmdCopyAccelerationStructureKHR)
|
|||
VK_INSTANCE_PFN(vkGetPhysicalDeviceFragmentShadingRatesKHR)
|
||||
VK_DEVICE_EXT_PFN(vkCmdSetFragmentShadingRateKHR)
|
||||
|
||||
/* VK_KHR_create_renderpass2 */
|
||||
VK_DEVICE_EXT_PFN(vkCmdBeginRenderPass2KHR)
|
||||
VK_DEVICE_EXT_PFN(vkCmdEndRenderPass2KHR)
|
||||
VK_DEVICE_EXT_PFN(vkCmdNextSubpass2KHR)
|
||||
VK_DEVICE_EXT_PFN(vkCreateRenderPass2KHR)
|
||||
|
||||
/* VK_EXT_calibrated_timestamps */
|
||||
VK_DEVICE_EXT_PFN(vkGetCalibratedTimestampsEXT)
|
||||
VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)
|
||||
|
|
Loading…
Reference in New Issue