How to use linear color attachment with NV extension in vulkan? | pressku.com

Trending 2 months ago

I person an OptiX ray tracer and a Vulkan renderer. In Vulkan, truthful acold I person only been displaying nan image nan ray tracer created. Now I want to adhd rendering successful nan Vulkan renderer.

For nan interop, I created a VkImage pinch linear tiling, specified that I tin constitute to nan image's buffer successful OptiX. This useful fine, but I cannot alteration nan linear tiling (I believe), arsenic different OptiX would astir apt constitute garbage (or alternatively Vulkan would construe garbage from nan OptiX buffer writing).

Currently I want to adhd drafting lines successful Vulkan, truthful my attack was: Use nan image shared betwixt OptiX and Vulkan arsenic a framebuffer and render lines to it pinch a caller graphics pipeline. However, this requires nan image to person usage VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT. This is prohibited erstwhile having a linear tiling image successful nan specs, nan validation layers show maine arsenic much.

Now location is this NVidia hold astir having a linear colour attachment: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_NV_linear_color_attachment.html So this looks for illustration a solution to me. But I can't get it to work.

My image's format is VK_FORMAT_R32G32B32A32_SFLOAT. I person queried support:

VkFormatProperties3 formatProperties3{}; formatProperties3.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3; VkFormatProperties2 formatProperties2{}; formatProperties2.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2; formatProperties2.pNext = &formatProperties3; vkGetPhysicalDeviceFormatProperties2(Device->PhysicalDevice, VK_FORMAT_R32G32B32A32_SFLOAT, &formatProperties2); if (formatProperties3.linearTilingFeatures & VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV) { // this is reached, truthful is supported }

I person besides group nan instrumentality characteristic erstwhile creating nan logical device:

physicalDeviceFeatures.pNext = &otherFeature; VkPhysicalDeviceLinearColorAttachmentFeaturesNV linearColorAttachmentFeature{}; linearColorAttachmentFeature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV; otherFeature.pNext = &linearColorAttachmentFeature; vkGetPhysicalDeviceFeatures2(Device->PhysicalDevice, &physicalDeviceFeatures); vkGetPhysicalDeviceFeatures2(physicalDevice, &physicalDeviceFeatures); VkDeviceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; // ... createInfo.pNext = &physicalDeviceFeatures; VkResult consequence = vkCreateDevice(physicalDevice, &createInfo, nullptr, &device);

From what I understand, this should already alteration utilizing a linear tiling image pinch colour attachment bit. However, erstwhile I create nan image view, I still get nan pursuing correction successful my validation layers:

Validation Layer(ERROR): Validation Error: [ VUID-VkImageViewCreateInfo-usage-02276 ] Object 0: grip = 0xf443490000000006, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x27cb6471 | vkCreateImageView(): pCreateInfo->format VK_FORMAT_R32G32B32A32_SFLOAT pinch tiling VK_IMAGE_TILING_LINEAR does not support usage that includes VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT. The Vulkan spec states: If usage contains VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, past nan image view's format features must incorporate VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT (https://vulkan.lunarg.com/doc/view/1.3.250.1/windows/1.3-extensions/vkspec.html#VUID-VkImageViewCreateInfo-usage-02276)

Therefore nan question: How to usage nan linear colour attachment hold for NVidia?

More
close