|
1 | 1 | /* |
2 | | - * Copyright 2019-2024 Diligent Graphics LLC |
| 2 | + * Copyright 2019-2025 Diligent Graphics LLC |
3 | 3 | * Copyright 2015-2019 Egor Yusov |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -2059,6 +2059,25 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t |
2059 | 2059 | return Features; |
2060 | 2060 | } |
2061 | 2061 |
|
| 2062 | +VulkanDeviceFeatures PhysicalDeviceFeaturesToVulkanDeviceFeatures(const VulkanUtilities::VulkanPhysicalDevice::ExtensionFeatures& ExtFeatures, |
| 2063 | + DEVICE_FEATURE_STATE OptionalState) |
| 2064 | +{ |
| 2065 | + VERIFY_EXPR(OptionalState != DEVICE_FEATURE_STATE_DISABLED); |
| 2066 | + |
| 2067 | + VulkanDeviceFeatures VkFeatures; |
| 2068 | + |
| 2069 | +#define INIT_FEATURE(FeatureName, Supported) \ |
| 2070 | + VkFeatures.FeatureName = (Supported) ? OptionalState : DEVICE_FEATURE_STATE_DISABLED |
| 2071 | + |
| 2072 | + INIT_FEATURE(DynamicRendering, ExtFeatures.DynamicRendering.dynamicRendering != VK_FALSE); |
| 2073 | + |
| 2074 | +#undef INIT_FEATURE |
| 2075 | + |
| 2076 | + ASSERT_SIZEOF(VulkanDeviceFeatures, 1, "Did you add a new feature to VulkanDeviceFeatures? Please handle its status here (if necessary)."); |
| 2077 | + |
| 2078 | + return VkFeatures; |
| 2079 | +} |
| 2080 | + |
2062 | 2081 | SPARSE_TEXTURE_FLAGS VkSparseImageFormatFlagsToSparseTextureFlags(VkSparseImageFormatFlags Flags) |
2063 | 2082 | { |
2064 | 2083 | SPARSE_TEXTURE_FLAGS Result = SPARSE_TEXTURE_FLAG_NONE; |
@@ -2210,4 +2229,35 @@ VkComponentMapping TextureComponentMappingToVkComponentMapping(const TextureComp |
2210 | 2229 | }; |
2211 | 2230 | } |
2212 | 2231 |
|
| 2232 | +VkPipelineRenderingCreateInfoKHR GraphicsPipelineDesc_To_VkPipelineRenderingCreateInfo(const GraphicsPipelineDesc& PipelineDesc, |
| 2233 | + std::vector<VkFormat>& ColorAttachmentFormats) |
| 2234 | +{ |
| 2235 | + VkPipelineRenderingCreateInfoKHR PipelineRenderingCI{}; |
| 2236 | + PipelineRenderingCI.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR; |
| 2237 | + PipelineRenderingCI.pNext = nullptr; |
| 2238 | + PipelineRenderingCI.viewMask = (1u << PipelineDesc.NumViewports) - 1u; |
| 2239 | + |
| 2240 | + PipelineRenderingCI.colorAttachmentCount = PipelineDesc.NumRenderTargets; |
| 2241 | + ColorAttachmentFormats.resize(PipelineDesc.NumRenderTargets); |
| 2242 | + for (Uint32 rt = 0; rt < PipelineDesc.NumRenderTargets; ++rt) |
| 2243 | + { |
| 2244 | + TEXTURE_FORMAT RTVFormat = PipelineDesc.RTVFormats[rt]; |
| 2245 | + ColorAttachmentFormats[rt] = TexFormatToVkFormat(RTVFormat); |
| 2246 | + } |
| 2247 | + PipelineRenderingCI.pColorAttachmentFormats = ColorAttachmentFormats.data(); |
| 2248 | + |
| 2249 | + TEXTURE_FORMAT DSVFormat = PipelineDesc.DSVFormat; |
| 2250 | + if (DSVFormat != TEX_FORMAT_UNKNOWN) |
| 2251 | + { |
| 2252 | + PipelineRenderingCI.depthAttachmentFormat = TexFormatToVkFormat(DSVFormat); |
| 2253 | + const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs(DSVFormat); |
| 2254 | + if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH_STENCIL) |
| 2255 | + { |
| 2256 | + PipelineRenderingCI.stencilAttachmentFormat = PipelineRenderingCI.depthAttachmentFormat; |
| 2257 | + } |
| 2258 | + } |
| 2259 | + |
| 2260 | + return PipelineRenderingCI; |
| 2261 | +} |
| 2262 | + |
2213 | 2263 | } // namespace Diligent |
0 commit comments