Skip to content

Commit 2bed042

Browse files
VulkanTypeConversions: added GraphicsPipelineDesc_To_VkPipelineRenderingCreateInfo function
1 parent 942b512 commit 2bed042

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-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: 32 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");
@@ -2210,4 +2210,35 @@ VkComponentMapping TextureComponentMappingToVkComponentMapping(const TextureComp
22102210
};
22112211
}
22122212

2213+
VkPipelineRenderingCreateInfoKHR GraphicsPipelineDesc_To_VkPipelineRenderingCreateInfo(const GraphicsPipelineDesc& PipelineDesc,
2214+
std::vector<VkFormat>& ColorAttachmentFormats)
2215+
{
2216+
VkPipelineRenderingCreateInfoKHR PipelineRenderingCI{};
2217+
PipelineRenderingCI.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR;
2218+
PipelineRenderingCI.pNext = nullptr;
2219+
PipelineRenderingCI.viewMask = (1u << PipelineDesc.NumViewports) - 1u;
2220+
2221+
PipelineRenderingCI.colorAttachmentCount = PipelineDesc.NumRenderTargets;
2222+
ColorAttachmentFormats.resize(PipelineDesc.NumRenderTargets);
2223+
for (Uint32 rt = 0; rt < PipelineDesc.NumRenderTargets; ++rt)
2224+
{
2225+
TEXTURE_FORMAT RTVFormat = PipelineDesc.RTVFormats[rt];
2226+
ColorAttachmentFormats[rt] = TexFormatToVkFormat(RTVFormat);
2227+
}
2228+
PipelineRenderingCI.pColorAttachmentFormats = ColorAttachmentFormats.data();
2229+
2230+
TEXTURE_FORMAT DSVFormat = PipelineDesc.DSVFormat;
2231+
if (DSVFormat != TEX_FORMAT_UNKNOWN)
2232+
{
2233+
PipelineRenderingCI.depthAttachmentFormat = TexFormatToVkFormat(DSVFormat);
2234+
const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs(DSVFormat);
2235+
if (FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH_STENCIL)
2236+
{
2237+
PipelineRenderingCI.stencilAttachmentFormat = PipelineRenderingCI.depthAttachmentFormat;
2238+
}
2239+
}
2240+
2241+
return PipelineRenderingCI;
2242+
}
2243+
22132244
} // namespace Diligent

0 commit comments

Comments
 (0)