Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working inside linux #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.cache/
/build/
clang-toolchain.cmake
CMakeUserPresets.json
recent_gltf.txt
recent_skybox.txt
/triplets/
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ Add the following CMake user preset file in your project directory. I'll assume
"name": "linux-clang-18",
"inherits": "default",
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18",
"CMAKE_C_COMPILER": "/usr/bin/clang",
"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 All @@ -222,8 +222,8 @@ Add the following CMake user preset file in your project directory. I'll assume

`clang-toolchain.cmake`
```cmake
set(CMAKE_C_COMPILER /usr/bin/clang-18)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-18)
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ -lc++abi")
```
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
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?

17 changes: 11 additions & 6 deletions impl/MainApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ import :vulkan.pipeline.CubemapToneMappingRenderer;
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
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
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 @@ -202,7 +207,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 Expand Up @@ -679,7 +684,7 @@ vk::raii::SwapchainKHR vk_gltf_viewer::MainApp::createSwapchain(vk::SwapchainKHR
// memory used by presentable images.
//
// Therefore, if maxImageCount is zero, it is set to the UINT_MAX and minImageCount + 1 will be used.
std::min(surfaceCapabilities.minImageCount + 1, surfaceCapabilities.maxImageCount == 0 ? ~0U : surfaceCapabilities.maxImageCount),
std::min(surfaceCapabilities.minImageCount + 1, surfaceCapabilities.maxImageCount == 0 ? ~0U : surfaceCapabilities.maxImageCount),
vk::Format::eB8G8R8A8Srgb,
vk::ColorSpaceKHR::eSrgbNonlinear,
swapchainExtent,
Expand Down
19 changes: 15 additions & 4 deletions impl/vulkan/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,23 @@ 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) {


auto poolSizes = 2 * getPoolSizes(
sharedData.jumpFloodComputer.descriptorSetLayout,
sharedData.outlineRenderer.descriptorSetLayout
) + sharedData.weightedBlendedCompositionRenderer.descriptorSetLayout.getPoolSize();


auto poolCreateInfo = poolSizes.getDescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet);

return {
gpu.device,
(2 * getPoolSizes(sharedData.jumpFloodComputer.descriptorSetLayout, sharedData.outlineRenderer.descriptorSetLayout)
+ sharedData.weightedBlendedCompositionRenderer.descriptorSetLayout.getPoolSize())
.getDescriptorPoolCreateInfo(),
poolCreateInfo
};
}

Expand Down Expand Up @@ -1010,4 +1021,4 @@ auto vk_gltf_viewer::vulkan::Frame::recordSwapchainExtentDependentImageLayoutTra
sceneWeightedBlendedAttachmentGroup.getColorAttachment(1).resolveImage, vku::fullSubresourceRange(),
},
});
}
}
2 changes: 1 addition & 1 deletion impl/vulkan/pipeline/BrdfmapComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,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)
};
}

};
}