Skip to content

Commit 64ba26d

Browse files
VulkanTypeConversions: added GraphicsPipelineDesc_To_VkPipelineRenderingCreateInfo function
1 parent 942b512 commit 64ba26d

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -123,4 +123,7 @@ void GetAllowedStagesAndAccessMask(BIND_FLAGS Flags, VkPipelineStageFlags& Stage
123123
VkComponentSwizzle TextureComponentSwizzleToVkComponentSwizzle(TEXTURE_COMPONENT_SWIZZLE Swizzle);
124124
VkComponentMapping TextureComponentMappingToVkComponentMapping(const TextureComponentMapping& Mapping);
125125

126+
VkPipelineRenderingCreateInfoKHR GraphicsPipelineDesc_To_VkPipelineRenderingCreateInfo(const GraphicsPipelineDesc& PipelineDesc,
127+
std::vector<VkFormat>& ColorAttachmentFormats);
128+
126129
} // namespace Diligent

Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -2059,6 +2059,25 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t
20592059
return Features;
20602060
}
20612061

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+
20622081
SPARSE_TEXTURE_FLAGS VkSparseImageFormatFlagsToSparseTextureFlags(VkSparseImageFormatFlags Flags)
20632082
{
20642083
SPARSE_TEXTURE_FLAGS Result = SPARSE_TEXTURE_FLAG_NONE;
@@ -2210,4 +2229,35 @@ VkComponentMapping TextureComponentMappingToVkComponentMapping(const TextureComp
22102229
};
22112230
}
22122231

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+
22132263
} // namespace Diligent

0 commit comments

Comments
 (0)