Skip to content

Commit 45aea92

Browse files
VulkanTypeConversions: added GraphicsPipelineDesc_To_VkPipelineRenderingCreateInfo function
1 parent 942b512 commit 45aea92

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,4 +2210,34 @@ VkComponentMapping TextureComponentMappingToVkComponentMapping(const TextureComp
22102210
};
22112211
}
22122212

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

0 commit comments

Comments
 (0)