From 2ff5f2f90bea54fc55129a105f25072d0420c897 Mon Sep 17 00:00:00 2001 From: Johanness Date: Sun, 24 May 2026 21:45:38 +0300 Subject: [PATCH] Probe RGBA16F v210 output --- V210ComputeDecoder.cpp | 24 +++++++++++++++++++++--- shaders/v210_decode.comp | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/V210ComputeDecoder.cpp b/V210ComputeDecoder.cpp index 6429099..dcf2868 100644 --- a/V210ComputeDecoder.cpp +++ b/V210ComputeDecoder.cpp @@ -7,6 +7,9 @@ namespace { + constexpr VkFormat V210_OUTPUT_FORMAT = + VK_FORMAT_R16G16B16A16_SFLOAT; + std::vector readFile(const std::string& path) { std::ifstream file(path, std::ios::ate | std::ios::binary); @@ -222,6 +225,21 @@ void V210ComputeDecoder::createFeedResources( feed.srcHeight = srcHeight; feed.srcStride = srcStride; + VkFormatProperties formatProperties{}; + vkGetPhysicalDeviceFormatProperties( + physicalDevice, + V210_OUTPUT_FORMAT, + &formatProperties); + const VkFormatFeatureFlags requiredFeatures = + VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT | + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; + if ((formatProperties.optimalTilingFeatures & requiredFeatures) != + requiredFeatures) + { + throw std::runtime_error( + "VK_FORMAT_R16G16B16A16_SFLOAT cannot be used for v210 output"); + } + VkDeviceSize v210Size = static_cast(srcStride) * srcHeight; createBuffer( @@ -251,7 +269,7 @@ void V210ComputeDecoder::createFeedResources( physicalDevice, dstWidth, dstHeight, - VK_FORMAT_R8G8B8A8_UNORM, + V210_OUTPUT_FORMAT, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, @@ -264,7 +282,7 @@ void V210ComputeDecoder::createFeedResources( commandPool, graphicsQueue, feed.image, - VK_FORMAT_R8G8B8A8_UNORM, + V210_OUTPUT_FORMAT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); @@ -272,7 +290,7 @@ void V210ComputeDecoder::createFeedResources( viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; viewInfo.image = feed.image; viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - viewInfo.format = VK_FORMAT_R8G8B8A8_UNORM; + viewInfo.format = V210_OUTPUT_FORMAT; viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; viewInfo.subresourceRange.baseMipLevel = 0; diff --git a/shaders/v210_decode.comp b/shaders/v210_decode.comp index 66d8a73..67b185d 100644 --- a/shaders/v210_decode.comp +++ b/shaders/v210_decode.comp @@ -6,7 +6,7 @@ layout(binding = 0) readonly buffer V210Data { uint data[]; } v210; -layout(binding = 1, rgba8) uniform writeonly image2D dstImage; +layout(binding = 1, rgba16f) uniform writeonly image2D dstImage; layout(push_constant) uniform PushConstants { uint srcWidth;