Add support for VK_KHR_unified_image_layouts
This commit is contained in:
@@ -323,6 +323,10 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
|
||||
target_layout = tmp_image
|
||||
? vk::ImageLayout::eGeneral
|
||||
: vk::ImageLayout::eVideoEncodeSrcKHR;
|
||||
#ifdef VK_KHR_unified_image_layouts
|
||||
if (std::get<vk::PhysicalDeviceUnifiedImageLayoutsFeaturesKHR>(vk.feat).unifiedImageLayoutsVideo)
|
||||
target_layout = vk::ImageLayout::eGeneral;
|
||||
#endif
|
||||
|
||||
// Decode picture buffer (DPB) images
|
||||
vk::VideoFormatPropertiesKHR reference_picture_format = select_video_format(
|
||||
@@ -749,6 +753,7 @@ void wivrn::video_encoder_vulkan::present_image(vk::Image y_cbcr, vk::SemaphoreS
|
||||
// VkImageMemoryBarrier2 spec (executed once between the queues).
|
||||
// When need_transfer is false (optimal cross-queue transfer, no QFOT)
|
||||
// the same barrier degenerates to a plain layout transition.
|
||||
// The transition may not even be needed, skipping the barrier entirely
|
||||
vk::ImageMemoryBarrier2 barrier{
|
||||
.dstStageMask = vk::PipelineStageFlagBits2KHR::eVideoEncodeKHR,
|
||||
.dstAccessMask = vk::AccessFlagBits2::eVideoEncodeReadKHR,
|
||||
@@ -763,10 +768,11 @@ void wivrn::video_encoder_vulkan::present_image(vk::Image y_cbcr, vk::SemaphoreS
|
||||
.baseArrayLayer = stream_idx,
|
||||
.layerCount = 1},
|
||||
};
|
||||
video_cmd_buf.pipelineBarrier2({
|
||||
.imageMemoryBarrierCount = 1,
|
||||
.pImageMemoryBarriers = &barrier,
|
||||
});
|
||||
if (barrier.oldLayout != barrier.newLayout or barrier.srcQueueFamilyIndex != barrier.dstQueueFamilyIndex)
|
||||
video_cmd_buf.pipelineBarrier2({
|
||||
.imageMemoryBarrierCount = 1,
|
||||
.pImageMemoryBarriers = &barrier,
|
||||
});
|
||||
|
||||
auto it = image_views.find(VkImage(y_cbcr));
|
||||
if (it != image_views.end())
|
||||
|
||||
@@ -281,6 +281,9 @@ wivrn::vk_bundle::vk_bundle() :
|
||||
#endif
|
||||
#ifdef VK_KHR_maintenance9
|
||||
VK_KHR_MAINTENANCE_9_EXTENSION_NAME,
|
||||
#endif
|
||||
#ifdef VK_KHR_unified_image_layouts
|
||||
VK_KHR_UNIFIED_IMAGE_LAYOUTS_EXTENSION_NAME,
|
||||
#endif
|
||||
};
|
||||
for (auto & ext: physical_device.enumerateDeviceExtensionProperties())
|
||||
@@ -329,6 +332,16 @@ wivrn::vk_bundle::vk_bundle() :
|
||||
if (has_device_ext(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME))
|
||||
std::get<vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>(feat).videoEncodeIntraRefresh = std::get<vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>(physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>()).videoEncodeIntraRefresh;
|
||||
#endif
|
||||
#ifdef VK_KHR_unified_image_layouts
|
||||
if (has_device_ext(VK_KHR_UNIFIED_IMAGE_LAYOUTS_EXTENSION_NAME))
|
||||
{
|
||||
const auto available = std::get<vk::PhysicalDeviceUnifiedImageLayoutsFeaturesKHR>(physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceUnifiedImageLayoutsFeaturesKHR>());
|
||||
auto & enabled = std::get<vk::PhysicalDeviceUnifiedImageLayoutsFeaturesKHR>(feat);
|
||||
enabled.unifiedImageLayouts = available.unifiedImageLayouts;
|
||||
enabled.unifiedImageLayoutsVideo = available.unifiedImageLayoutsVideo;
|
||||
U_LOG_D("GPU unified layout support: %d (video: %d)", enabled.unifiedImageLayouts, enabled.unifiedImageLayoutsVideo);
|
||||
}
|
||||
#endif
|
||||
|
||||
device = vk::raii::Device(
|
||||
physical_device,
|
||||
|
||||
@@ -91,6 +91,9 @@ struct vk_bundle
|
||||
#endif
|
||||
#ifdef VK_KHR_video_encode_intra_refresh
|
||||
vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR,
|
||||
#endif
|
||||
#ifdef VK_KHR_unified_image_layouts
|
||||
vk::PhysicalDeviceUnifiedImageLayoutsFeaturesKHR,
|
||||
#endif
|
||||
vk::PhysicalDeviceVulkan12Features,
|
||||
vk::PhysicalDeviceVulkan13Features>
|
||||
|
||||
Reference in New Issue
Block a user