diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..66e33f34 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.cache/ +/build/ +clang-toolchain.cmake +CMakeUserPresets.json +recent_gltf.txt +recent_skybox.txt +/triplets/ diff --git a/README.md b/README.md index e52f4312..c72ae2d6 100644 --- a/README.md +++ b/README.md @@ -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", @@ -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") ``` @@ -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. \ No newline at end of file +[^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. diff --git a/impl/MainApp.cpp b/impl/MainApp.cpp index 78660967..1570137a 100644 --- a/impl/MainApp.cpp +++ b/impl/MainApp.cpp @@ -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(); +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( @@ -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 @@ -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, diff --git a/impl/vulkan/Frame.cpp b/impl/vulkan/Frame.cpp index 74437c09..db05c032 100644 --- a/impl/vulkan/Frame.cpp +++ b/impl/vulkan/Frame.cpp @@ -524,12 +524,23 @@ auto vk_gltf_viewer::vulkan::Frame::createFramebuffers() const -> 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 }; } @@ -1010,4 +1021,4 @@ auto vk_gltf_viewer::vulkan::Frame::recordSwapchainExtentDependentImageLayoutTra sceneWeightedBlendedAttachmentGroup.getColorAttachment(1).resolveImage, vku::fullSubresourceRange(), }, }); -} \ No newline at end of file +} diff --git a/impl/vulkan/pipeline/BrdfmapComputer.cpp b/impl/vulkan/pipeline/BrdfmapComputer.cpp index f66dea6c..a70bf5a6 100644 --- a/impl/vulkan/pipeline/BrdfmapComputer.cpp +++ b/impl/vulkan/pipeline/BrdfmapComputer.cpp @@ -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); -} \ No newline at end of file +} diff --git a/interface/vulkan/SharedData.cppm b/interface/vulkan/SharedData.cppm index 2d4b831c..cc1f1912 100644 --- a/interface/vulkan/SharedData.cppm +++ b/interface/vulkan/SharedData.cppm @@ -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) + }; +} + }; }