Clean up depth format selection code
@SaschaWillems がすでに取り組んでいます。
2025年11月12日 から。
評価
この issue はまだ評価されていません。
説明
All samples that do depth buffering have code like this:
void createDepthResources()
{
vk::Format depthFormat = findDepthFormat();
createImage(swapChainExtent.width, swapChainExtent.height, depthFormat, vk::ImageTiling::eOptimal, vk::ImageUsageFlagBits::eDepthStencilAttachment, vk::MemoryPropertyFlagBits::eDeviceLocal, depthImage, depthImageMemory);
depthImageView = createImageView(depthImage, depthFormat, vk::ImageAspectFlagBits::eDepth);
}
vk::Format findSupportedFormat(const std::vector<vk::Format> &candidates, vk::ImageTiling tiling, vk::FormatFeatureFlags features) const
{
for (const auto format : candidates)
{
vk::FormatProperties props = physicalDevice.getFormatProperties(format);
if (tiling == vk::ImageTiling::eLinear && (props.linearTilingFeatures & features) == features)
{
return format;
}
if (tiling == vk::ImageTiling::eOptimal && (props.optimalTilingFeatures & features) == features)
{
return format;
}
}
throw std::runtime_error("failed to find supported format!");
}
[[nodiscard]] vk::Format findDepthFormat() const
{
return findSupportedFormat(
{vk::Format::eD32Sfloat, vk::Format::eD32SfloatS8Uint, vk::Format::eD24UnormS8Uint},
vk::ImageTiling::eOptimal,
vk::FormatFeatureFlagBits::eDepthStencilAttachment);
}
....
// Somewhere in a function A
vk::Format depthFormat = findDepthFormat();
....
// Somewhere in a function B
vk::Format depthFormat = findDepthFormat();
findDepthFormatis often called multiple times of just querying once and then storing it.findSupportedFormatis only ever used infindDepthFormatfindDepthFormatis declared after the calling function(s)createDepthResources
There is potential here to simplify code and make it easier to follow.
- 主要言語
- C++
- スター
- 424
- フォーク
- 127
- 平均マージ
- 2日 22時間
- マージ済み PR(30日)
- 7
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
KhronosGroup/Vulkan-Tutorial のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
KhronosGroup/Vulkan-Tutorial#519 · 担当者 1 名 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
KhronosGroup/Vulkan-Tutorial#511 · 担当者 1 名 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
KhronosGroup/Vulkan-Tutorial#508 · 担当者 1 名 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
KhronosGroup/Vulkan-Tutorial#499 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
KhronosGroup/Vulkan-Tutorial#498 ·
KhronosGroup/Vulkan-Tutorial の issue をすべて見る
似ている issue
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
QuantStack/git2cpp#187 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
AXERA-TECH/ax-llm#77 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
games-on-whales/wolf#509 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100