Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.cache/
/build/
clang-toolchain.cmake
CMakeUserPresets.json
recent_gltf.txt
recent_skybox.txt
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Add the following CMake user preset file in your project directory. I'll assume
"inherits": "default",
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/clang-18",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also change clang-18 to clang?

"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++ -lc++abi",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/triplets",
Expand Down Expand Up @@ -326,4 +326,4 @@ This project is **licensed under the GPL-v3 License**. See the [LICENSE](LICENSE

[^1]: I like this term because it's hilarious for several reasons, but it's no joke! It has the **significantly faster glTF model loading speed than the other the viewers** I've tested. See [Performance Comparison](https://github.com/stripe2933/vk-gltf-viewer/blob/master/docs/performance-comparison.md) page for details.
[^2]: Applied for standard glTF 2.0 asset only. Asset with material related extensions may require additional draw calls for pipeline changing.
[^3]: On Apple GPU platform prior to the MoltenVK 1.2.11 (which enables the Metal Argument Buffer by default), [`maxPerStageDescriptorUpdateAfterBindStorageImages` is 8](https://vulkan.gpuinfo.org/displaycoreproperty.php?platform=macos&name=maxPerStageDescriptorUpdateAfterBindStorageImages&core=1.2). It limited the cubemap resoluton and prefilteredmap roughnesslevels. Instead, it can use `VK_AMD_shader_image_load_store_lod` extension to replace the descriptor indexing based cubemap mipmapping and prefilteredmap generation.
[^3]: On Apple GPU platform prior to the MoltenVK 1.2.11 (which enables the Metal Argument Buffer by default), [`maxPerStageDescriptorUpdateAfterBindStorageImages` is 8](https://vulkan.gpuinfo.org/displaycoreproperty.php?platform=macos&name=maxPerStageDescriptorUpdateAfterBindStorageImages&core=1.2). It limited the cubemap resoluton and prefilteredmap roughnesslevels. Instead, it can use `VK_AMD_shader_image_load_store_lod` extension to replace the descriptor indexing based cubemap mipmapping and prefilteredmap generation.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line has been changed?

15 changes: 10 additions & 5 deletions impl/MainApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ constexpr std::uint32_t FRAMES_IN_FLIGHT = 2;
vk_gltf_viewer::MainApp::MainApp() {
const vulkan::pipeline::BrdfmapComputer brdfmapComputer { gpu.device };

const vk::raii::DescriptorPool descriptorPool {
gpu.device,
brdfmapComputer.descriptorSetLayout.getPoolSize().getDescriptorPoolCreateInfo(),
};

vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo = brdfmapComputer.descriptorSetLayout.getPoolSize().getDescriptorPoolCreateInfo();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not be work. vku::PoolSizes::getDescriptorPoolCreateInfo returns both vk::DescriptorPoolCreateInfo and std::vector<vk::DescriptorPoolSize> via vku::RefHolder (former references the latter), but store it into vk::DescriptorPoolCreateInfo will destroy the pool size vector.

You should pass vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet to the method by parameter and use the struct directly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks :)

descriptorPoolCreateInfo.flags |= vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet;

const vk::raii::DescriptorPool descriptorPool {
gpu.device,
descriptorPoolCreateInfo,
};


const auto [brdfmapSet] = allocateDescriptorSets(*gpu.device, *descriptorPool, std::tie(brdfmapComputer.descriptorSetLayout));
gpu.device.updateDescriptorSets(
Expand Down Expand Up @@ -173,7 +178,7 @@ vk_gltf_viewer::MainApp::MainApp() {
#elif __APPLE__
"/Library/Fonts/Arial Unicode.ttf",
#elif __linux__
"/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf",
"/usr/share/fonts/noto/NotoSansMono-Medium.ttf",
#else
#error "Type your own font file in here!"
#endif
Expand Down
24 changes: 17 additions & 7 deletions impl/vulkan/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,25 @@ auto vk_gltf_viewer::vulkan::Frame::createFramebuffers() const -> std::vector<vk
| std::ranges::to<std::vector>();
}


auto vk_gltf_viewer::vulkan::Frame::createDescriptorPool() const -> decltype(descriptorPool) {
return {
gpu.device,
(2 * getPoolSizes(sharedData.jumpFloodComputer.descriptorSetLayout, sharedData.outlineRenderer.descriptorSetLayout)
+ sharedData.weightedBlendedCompositionRenderer.descriptorSetLayout.getPoolSize())
.getDescriptorPoolCreateInfo(),
};

auto poolCreateInfo =

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

(2 * getPoolSizes(sharedData.jumpFloodComputer.descriptorSetLayout, sharedData.outlineRenderer.descriptorSetLayout)
+ sharedData.weightedBlendedCompositionRenderer.descriptorSetLayout.getPoolSize())
.getDescriptorPoolCreateInfo();

auto& createInfo = poolCreateInfo.get();
createInfo.flags |= vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet;

return {
gpu.device,
poolCreateInfo
};

}


auto vk_gltf_viewer::vulkan::Frame::recordScenePrepassCommands(vk::CommandBuffer cb) const -> void {
boost::container::static_vector<vk::ImageMemoryBarrier, 3> memoryBarriers;

Expand Down Expand Up @@ -1007,4 +1017,4 @@ auto vk_gltf_viewer::vulkan::Frame::recordSwapchainExtentDependentImageLayoutTra
sceneWeightedBlendedAttachmentGroup.getColorAttachment(1).resolveImage, vku::fullSubresourceRange(),
},
});
}
}
3 changes: 2 additions & 1 deletion impl/vulkan/pipeline/BrdfmapComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import :vulkan.pipeline.BrdfmapComputer;

import std;

#define COMPILED_SHADER_DIR "shader"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it already defined by CMakeLists.txt?

target_link_shaders(vk-gltf-viewer

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it already defined by CMakeLists.txt?

target_link_shaders(vk-gltf-viewer

yeah sorry for not being careful temporarily put it there because i was getting error there while calling binary as ./build/vk-gltf-viewer

vk_gltf_viewer::vulkan::pipeline::BrdfmapComputer::DescriptorSetLayout::DescriptorSetLayout(
const vk::raii::Device &device
) : vku::DescriptorSetLayout<vk::DescriptorType::eStorageImage> {
Expand Down Expand Up @@ -47,4 +48,4 @@ auto vk_gltf_viewer::vulkan::pipeline::BrdfmapComputer::compute(
commandBuffer.bindPipeline(vk::PipelineBindPoint::eCompute, *pipeline);
commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eCompute, *pipelineLayout, 0, descriptorSet, {});
commandBuffer.dispatch(imageSize.width / 16, imageSize.height / 16, 1);
}
}
20 changes: 14 additions & 6 deletions interface/vulkan/SharedData.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,20 @@ namespace vk_gltf_viewer::vulkan {
}
}

[[nodiscard]] auto createTextureDescriptorPool() const -> vk::raii::DescriptorPool {
return { gpu.device, getPoolSizes(assetDescriptorSetLayout).getDescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eUpdateAfterBind) };
}

[[nodiscard]] auto createDescriptorPool() const -> vk::raii::DescriptorPool {
return { gpu.device, getPoolSizes(imageBasedLightingDescriptorSetLayout, sceneDescriptorSetLayout, skyboxDescriptorSetLayout).getDescriptorPoolCreateInfo() };
}

[[nodiscard]] auto createTextureDescriptorPool() const -> vk::raii::DescriptorPool {
return { gpu.device,
getPoolSizes(assetDescriptorSetLayout).getDescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eUpdateAfterBind | vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet)
};
}

[[nodiscard]] auto createDescriptorPool() const -> vk::raii::DescriptorPool {
return { gpu.device,
getPoolSizes(imageBasedLightingDescriptorSetLayout, sceneDescriptorSetLayout, skyboxDescriptorSetLayout)
.getDescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet)
};
}

};
}