From ce2129030bd17e0c1308869f7f4e5642ccc35ba1 Mon Sep 17 00:00:00 2001 From: Carsten Rudolph <18394207+crud89@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:26:03 +0100 Subject: [PATCH 1/2] Port over platform independent changes from PR #140. --- README.md | 129 +----------------- src/Backends/DirectX12/src/blas.cpp | 10 +- src/Backends/DirectX12/src/buffer.cpp | 28 ++-- src/Backends/DirectX12/src/frame_buffer.cpp | 6 +- src/Backends/DirectX12/src/render_pass.cpp | 2 +- .../DirectX12/src/render_pipeline.cpp | 2 +- src/Backends/DirectX12/src/swapchain.cpp | 4 +- src/Backends/DirectX12/src/tlas.cpp | 10 +- src/Backends/Vulkan/src/blas.cpp | 10 +- src/Backends/Vulkan/src/buffer.cpp | 28 ++-- src/Backends/Vulkan/src/frame_buffer.cpp | 6 +- src/Backends/Vulkan/src/render_pass.cpp | 6 +- src/Backends/Vulkan/src/render_pipeline.cpp | 10 +- src/Backends/Vulkan/src/shader_program.cpp | 2 +- src/Backends/Vulkan/src/swapchain.cpp | 6 +- src/Backends/Vulkan/src/tlas.cpp | 10 +- src/CMakeLists.txt | 12 +- src/CMakePresets.json | 40 +----- src/Core/include/litefx/containers.hpp | 3 + src/Core/include/litefx/exceptions.hpp | 4 +- src/Core/include/litefx/traits.hpp | 9 ++ src/Logging/include/litefx/logging.hpp | 13 +- src/Rendering/include/litefx/rendering.hpp | 1 - .../include/litefx/rendering_api.hpp | 2 +- src/Samples/BasicRendering/CMakeLists.txt | 2 +- src/Samples/BasicRendering/src/main.cpp | 3 +- src/Samples/Bindless/CMakeLists.txt | 2 +- src/Samples/Bindless/src/main.cpp | 3 +- src/Samples/Compute/CMakeLists.txt | 2 +- src/Samples/Compute/src/main.cpp | 3 +- src/Samples/Indirect/CMakeLists.txt | 2 +- src/Samples/Indirect/src/main.cpp | 3 +- src/Samples/MeshShader/CMakeLists.txt | 2 +- src/Samples/MeshShader/src/main.cpp | 3 +- src/Samples/Multisampling/CMakeLists.txt | 2 +- src/Samples/Multisampling/src/main.cpp | 3 +- src/Samples/Multithreading/CMakeLists.txt | 2 +- src/Samples/Multithreading/src/main.cpp | 3 +- src/Samples/PushConstants/CMakeLists.txt | 2 +- src/Samples/PushConstants/src/main.cpp | 3 +- src/Samples/RayQueries/CMakeLists.txt | 2 +- src/Samples/RayQueries/src/main.cpp | 3 +- src/Samples/RayTracing/CMakeLists.txt | 2 +- src/Samples/RayTracing/src/main.cpp | 3 +- src/Samples/RenderPasses/CMakeLists.txt | 2 +- src/Samples/RenderPasses/src/main.cpp | 3 +- src/Samples/Textures/CMakeLists.txt | 2 +- src/Samples/Textures/src/main.cpp | 3 +- src/Samples/UniformArrays/CMakeLists.txt | 2 +- src/Samples/UniformArrays/src/main.cpp | 3 +- src/cmake/Shaders.cmake | 1 + src/cmake/presets/compilers.json | 23 ++++ src/cmake/presets/platforms.json | 45 ++++++ 53 files changed, 227 insertions(+), 260 deletions(-) create mode 100644 src/cmake/presets/compilers.json create mode 100644 src/cmake/presets/platforms.json diff --git a/README.md b/README.md index ec991bf6b..4de7a6c10 100644 --- a/README.md +++ b/README.md @@ -56,130 +56,11 @@ LiteFX is written in modern C++23, following established design patterns to make - **CMake Integration**: you can use CMake to integrate the engine into your project. Furthermore, it exports scripts that allow you to integrate assets and shaders into your build process. It can be installed using *vcpkg*, making project setup quick and painless. - **Much More**: If you want to learn what else you can do, check out the [guides](https://litefx.crudolph.io/docs/md_docs_tutorials_project_setup.html) and [wiki](https://github.com/crud89/LiteFX/wiki). -## Installation - -If you just want to start using LiteFX, you can acquire binaries of the latest version from the [releases page](https://github.com/crud89/LiteFX/releases) and follow the [project setup](https://litefx.crudolph.io/docs/md_docs_tutorials_project_setup.html) and [quick start](https://litefx.crudolph.io/docs/md_docs_tutorials_quick_start.html) guides. - -### Using vcpkg - -If you are using vcpkg, you can use the [registry](https://github.com/crud89/LiteFX-Registry) to install the engine directly. - -### Manual Builds - -You can also build the sources on your own. Currently only MSVC and Clang builds under Windows are officially supported. However, the engine does use CMake and (besides the DirectX 12 backend) no Windows-specific features, so porting the Vulkan backend and engine architecture should be absolutely possible (pull requests are much appreciated!). - -#### Prerequisites - -In order for the project to be built, there are a few prerequisites that need to be present on your environment: - -- [C++23 compatible compiler](https://en.cppreference.com/w/cpp/compiler_support/23): At the moment only MSVC and Clang 18+ fully supports the required features. † -- [CMake](https://cmake.org/download/) (version 3.20 or higher). ‡ -- Optional: [LunarG Vulkan SDK](https://vulkan.lunarg.com/) 1.3.204.1 or later (required to build the Vulkan backend). -- Optional: Windows 10 SDK 10.0.19041.0 or later (required to build DirectX backend). - -† Note that at least Visual Studio 17.10 or later is required. - -‡ CMake 3.20 is part of Visual Studio 2022. When using other compilers, CMake needs to be installed manually. - -#### Cloning the Repository - -Create a new directory from where you want to build the sources. Then open your shell and clone the repository: - -```sh -git clone --recursive https://github.com/crud89/LiteFX.git . -``` - -#### Performing a Build - -There are multiple ways of creating a build from scratch. In general, all *CMake*-based build systems are supported. - -##### From Command Line - -Building from command line is the most straightforward way and is typically sufficient, if you only want to consume a fresh build. - -```sh -cmake src/ --preset windows-msvc-x64-release -cmake --build out/build/windows-msvc-x64-release/ --target install -``` - -##### Using Visual Studio - -From Visual Studio open the folder where you just checked out the contents of the repository. In the *Project Explorer* change the view to *CMake Targets*. Right click *LiteFX* and select *Install*. - -#### Build Customization - -You can customize the engine build, according to your specific needs. The most straightforward way is to use [*CMake presets*](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html). Create a file called *CMakeUserPresets.json* inside the *src/* directory and add the following content to it: - -```json -{ - "version": 2, - "cmakeMinimumRequired": { - "major": 3, - "minor": 20, - "patch": 0 - }, - "configurePresets": [ - { - "name": "win-x64-custom-preset", - "inherits": "windows-msvc-x64-release", - "cacheVariables": { - } - } - ] -} -``` - -Within the cache variables, you can override the build options, LiteFX exports. All customizable options have the `LITEFX_BUILD_` prefix and are described in detail below: - -- `LITEFX_BUILD_VULKAN_BACKEND` (default: `ON`): builds the Vulkan 🌋 backend (requires [LunarG Vulkan SDK](https://vulkan.lunarg.com/) 1.3.204.1 or later to be installed on your system). -- `LITEFX_BUILD_DX12_BACKEND` (default: `ON`): builds the DirectX 12 ❎ backend. -- `LITEFX_BUILD_DEFINE_BUILDERS` (default: `ON`): enables the [builder architecture](https://github.com/crud89/LiteFX/wiki/Builders) for backends. -- `LITEFX_BUILD_SUPPORT_DEBUG_MARKERS` (default: `OFF`): implements support for setting debug regions on device queues. -- `LITEFX_BUILD_WITH_GLM` (default: `ON`): adds [glm](https://glm.g-truc.net/0.9.9/index.html) converters to math types. † -- `LITEFX_BUILD_WITH_DIRECTX_MATH` (default: `ON`): adds [DirectX Math](https://github.com/microsoft/DirectXMath) converters to math types. † -- `LITEFX_BUILD_HLSL_SHADER_MODEL` (default: `6_5`): specifies the default HLSL shader model. -- `LITEFX_BUILD_EXAMPLES` (default: `ON`): builds the examples. Depending on which backends are built, some may be omitted. -- `LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER` (default: `ON`): enables code that attempts to load the latest version of the [PIX GPU capturer](https://devblogs.microsoft.com/pix/) in the DirectX 12 samples, if available (and if the command line argument `--load-pix=true` is specified). -- `LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER` (default: `OFF`): enables code in the samples, that loads the [RenderDoc](https://renderdoc.org/) runtime API, if the application is launched from within RenderDoc (and if the command line argument `--load-render-doc=true` is specified). -- `LITEFX_BUILD_TESTS` (default: `OFF`): builds tests for the project. - -For example, if you only want to build the Vulkan backend and samples and don't want to use DirectX Math, a preset would look like this: - -```json -{ - "version": 2, - "cmakeMinimumRequired": { - "major": 3, - "minor": 20, - "patch": 0 - }, - "configurePresets": [ - { - "name": "win-x64-vulkan-only", - "inherits": "windows-msvc-x64-release", - "cacheVariables": { - "LITEFX_BUILD_DX12_BACKEND": "OFF", - "LITEFX_BUILD_WITH_DIRECTX_MATH": "OFF" - } - } - ] -} -``` - -You can build using this preset from command line like so: - -```sh -cmake src/ --preset win-x64-vulkan-only -cmake --build out/build/win-x64-vulkan-only/ --target install --config Release -``` - -† Note that *glm* and *DirectX Math* are installed using *vcpkg* automatically. If one of those options gets disabled, no converters will be generated and the dependency will not be exported. Note that both can be used for DirectX 12 and Vulkan. - -#### Troubleshooting +## Getting Started -If you are having problems building the project, you may find answers [in the wiki](https://github.com/crud89/LiteFX/wiki/Troubleshooting). Otherwise, feel free to start a [discussion](https://github.com/crud89/LiteFX/discussions/categories/q-a) or open an [issue](https://github.com/crud89/LiteFX/issues). +If you just want to start using LiteFX, you can acquire binaries of the latest version from the [releases page](https://github.com/crud89/LiteFX/releases) and follow the [project setup](https://litefx.crudolph.io/docs/md_docs_tutorials_project_setup.html) and [quick start](https://litefx.crudolph.io/docs/md_docs_tutorials_quick_start.html) guides. If you want to perform a custom build, check out the [building guide](https://github.com/crud89/LiteFX/wiki/Building-Guide). For a collection of tutorials and more in-depth information on how to use the engine and work with the code base, take a look at the [documentation](https://litefx.crudolph.io/docs/) and the [project wiki](https://github.com/crud89/LiteFX/wiki). -### Dependencies +## Dependencies All dependencies are automatically installed using *vcpkg*, when performing a manual build. The engine core by itself only has one hard dependency: @@ -207,10 +88,6 @@ Furthermore, the samples also use some libraries for convenience. Those dependen - [glfw3](https://www.glfw.org/): Cross-platform window manager. - [stb](https://github.com/nothings/stb): Lightweight image loading and processing library. -## Getting Started - -For a [quick-start guide](https://litefx.crudolph.io/docs/md_docs_tutorials_project_setup.html), a collection of tutorials and more in-depth information on how to use the engine and work with the code base, take a look at the [documentation](https://litefx.crudolph.io/docs/) and the [project wiki](https://github.com/crud89/LiteFX/wiki). - ## Contribute If you are having trouble using the engine, found a bug or have suggestions, just drop an [issue](https://github.com/crud89/LiteFX/issues). Keep in mind that this project is developed in my free time and I might not be able to provide any advanced support. If you want to, feel free to provide improvements by creating a pull request. diff --git a/src/Backends/DirectX12/src/blas.cpp b/src/Backends/DirectX12/src/blas.cpp index 8c565d319..c051ab824 100644 --- a/src/Backends/DirectX12/src/blas.cpp +++ b/src/Backends/DirectX12/src/blas.cpp @@ -178,9 +178,9 @@ void DirectX12BottomLevelAccelerationStructure::build(const DirectX12CommandBuff if (buffer == nullptr) buffer = m_impl->m_buffer && m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Perform the build. commandBuffer.buildAccelerationStructure(*this, scratchBuffer, *buffer, offset); @@ -220,9 +220,9 @@ void DirectX12BottomLevelAccelerationStructure::update(const DirectX12CommandBuf if (buffer == nullptr) buffer = m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Perform the update. commandBuffer.updateAccelerationStructure(*this, scratchBuffer, *buffer, offset); @@ -257,7 +257,7 @@ void DirectX12BottomLevelAccelerationStructure::copy(const DirectX12CommandBuffe if (buffer == nullptr) buffer = destination.m_impl->m_buffer->size() >= requiredMemory ? destination.m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Store the buffer and the offset. destination.m_impl->m_offset = offset; diff --git a/src/Backends/DirectX12/src/buffer.cpp b/src/Backends/DirectX12/src/buffer.cpp index 31e5c32f1..c12693690 100644 --- a/src/Backends/DirectX12/src/buffer.cpp +++ b/src/Backends/DirectX12/src/buffer.cpp @@ -88,17 +88,20 @@ UInt64 DirectX12Buffer::virtualAddress() const noexcept void DirectX12Buffer::map(const void* const data, size_t size, UInt32 element) { + if (data == nullptr) [[unlikely]] + throw ArgumentNotInitializedException("data", "The data pointer must be initialized."); + if (element >= m_impl->m_elements) [[unlikely]] throw ArgumentOutOfRangeException("element", std::make_pair(0u, m_impl->m_elements), element, "The element {0} is out of range. The buffer only contains {1} elements.", element, m_impl->m_elements); + + if (this->size() - (element * this->alignedElementSize()) < size) [[unlikely]] + throw InvalidArgumentException("size", "The provided data size would overflow the buffer (buffer offset: 0x{1:X}; {2} bytes remaining but size was set to {0}).", size, element * this->alignedElementSize(), this->size() - (element * this->alignedElementSize())); D3D12_RANGE mappedRange = { }; char* buffer; raiseIfFailed(this->handle()->Map(0, &mappedRange, reinterpret_cast(&buffer)), "Unable to map buffer memory."); - auto result = ::memcpy_s(reinterpret_cast(buffer + (element * this->alignedElementSize())), this->size(), data, size); + std::memcpy(reinterpret_cast(buffer + (element * this->alignedElementSize())), data, size); this->handle()->Unmap(0, nullptr); - - if (result != 0) [[unlikely]] - throw RuntimeException("Error mapping buffer to device memory: {#X}.", result); } void DirectX12Buffer::map(Span data, size_t elementSize, UInt32 firstElement) @@ -108,20 +111,25 @@ void DirectX12Buffer::map(Span data, size_t elementSize, UInt void DirectX12Buffer::map(void* data, size_t size, UInt32 element, bool write) { + if (data == nullptr) [[unlikely]] + throw ArgumentNotInitializedException("data", "The data pointer must be initialized."); + if (element >= m_impl->m_elements) [[unlikely]] throw ArgumentOutOfRangeException("element", std::make_pair(0u, m_impl->m_elements), element, "The element {0} is out of range. The buffer only contains {1} elements.", element, m_impl->m_elements); + + if (this->size() - (element * this->alignedElementSize()) < size) [[unlikely]] + throw InvalidArgumentException("size", "The provided data size would overflow the buffer (buffer offset: 0x{1:X}; {2} bytes remaining but size was set to {0}).", size, element * this->alignedElementSize(), this->size() - (element * this->alignedElementSize())); D3D12_RANGE mappedRange = { }; char* buffer; raiseIfFailed(this->handle()->Map(0, &mappedRange, reinterpret_cast(&buffer)), "Unable to map buffer memory."); - auto result = write ? - ::memcpy_s(reinterpret_cast(buffer + (element * this->alignedElementSize())), this->size(), data, size) : - ::memcpy_s(data, size, reinterpret_cast(buffer + (element * this->alignedElementSize())), size); - this->handle()->Unmap(0, nullptr); + if (write) + std::memcpy(reinterpret_cast(buffer + (element * this->alignedElementSize())), data, size); + else + std::memcpy(data, reinterpret_cast(buffer + (element * this->alignedElementSize())), size); - if (result != 0) [[unlikely]] - throw RuntimeException("Error mapping buffer to device memory: {#X}.", result); + this->handle()->Unmap(0, nullptr); } void DirectX12Buffer::map(Span data, size_t elementSize, UInt32 firstElement, bool write) diff --git a/src/Backends/DirectX12/src/frame_buffer.cpp b/src/Backends/DirectX12/src/frame_buffer.cpp index 6eda8a1d6..cff49e7de 100644 --- a/src/Backends/DirectX12/src/frame_buffer.cpp +++ b/src/Backends/DirectX12/src/frame_buffer.cpp @@ -129,7 +129,7 @@ DirectX12FrameBuffer::~DirectX12FrameBuffer() noexcept = default; D3D12_CPU_DESCRIPTOR_HANDLE DirectX12FrameBuffer::descriptorHandle(UInt32 imageIndex) const { if (imageIndex >= m_impl->m_images.size()) [[unlikely]] - throw ArgumentOutOfRangeException("imageIndex", std::make_pair(0ull, (UInt64)m_impl->m_images.size()), imageIndex, "The frame buffer does not contain an image at index {0}.", imageIndex); + throw ArgumentOutOfRangeException("imageIndex", std::make_pair(0uz, m_impl->m_images.size()), imageIndex, "The frame buffer does not contain an image at index {0}.", imageIndex); return m_impl->m_renderTargetHandles.at(m_impl->m_images[imageIndex].get()); } @@ -170,7 +170,7 @@ size_t DirectX12FrameBuffer::getHeight() const noexcept void DirectX12FrameBuffer::mapRenderTarget(const RenderTarget& renderTarget, UInt32 index) { if (index >= m_impl->m_images.size()) [[unlikely]] - throw ArgumentOutOfRangeException("index", std::make_pair(0ull, (UInt64)m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); + throw ArgumentOutOfRangeException("index", std::make_pair(0uz, m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); if (m_impl->m_images[index]->format() != renderTarget.format()) [[unlikely]] LITEFX_WARNING(DIRECTX12_LOG, "The render target format {0} does not match the image format {1} for image {2}.", renderTarget.format(), m_impl->m_images[index]->format(), index); @@ -201,7 +201,7 @@ Enumerable DirectX12FrameBuffer::images() const noexcept const IDirectX12Image& DirectX12FrameBuffer::image(UInt32 index) const { if (index >= m_impl->m_images.size()) [[unlikely]] - throw ArgumentOutOfRangeException("index", std::make_pair(0ull, (UInt64)m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); + throw ArgumentOutOfRangeException("index", std::make_pair(0uz, m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); return *m_impl->m_images[index]; } diff --git a/src/Backends/DirectX12/src/render_pass.cpp b/src/Backends/DirectX12/src/render_pass.cpp index 0147530e5..99f66d739 100644 --- a/src/Backends/DirectX12/src/render_pass.cpp +++ b/src/Backends/DirectX12/src/render_pass.cpp @@ -310,7 +310,7 @@ const Array& DirectX12RenderPass::inputAttachments() const const RenderPassDependency& DirectX12RenderPass::inputAttachment(UInt32 location) const { if (location >= m_impl->m_inputAttachments.size()) [[unlikely]] - throw ArgumentOutOfRangeException("location", std::make_pair(0ull, (UInt64)m_impl->m_inputAttachments.size()), location, "The render pass does not contain an input attachment at location {0}.", location); + throw ArgumentOutOfRangeException("location", std::make_pair(0uz, m_impl->m_inputAttachments.size()), location, "The render pass does not contain an input attachment at location {0}.", location); return m_impl->m_inputAttachments[location]; } diff --git a/src/Backends/DirectX12/src/render_pipeline.cpp b/src/Backends/DirectX12/src/render_pipeline.cpp index da111c7b4..f29f6d474 100644 --- a/src/Backends/DirectX12/src/render_pipeline.cpp +++ b/src/Backends/DirectX12/src/render_pipeline.cpp @@ -171,7 +171,7 @@ class DirectX12RenderPipeline::DirectX12RenderPipelineImpl : public Implement(renderTarget.blendState().WriteMask); + targetBlendState.RenderTargetWriteMask = static_cast(renderTarget.blendState().ChannelWriteMask); targetBlendState.SrcBlend = DX12::getBlendFactor(renderTarget.blendState().SourceColor); targetBlendState.SrcBlendAlpha = DX12::getBlendFactor(renderTarget.blendState().SourceAlpha); targetBlendState.DestBlend = DX12::getBlendFactor(renderTarget.blendState().DestinationColor); diff --git a/src/Backends/DirectX12/src/swapchain.cpp b/src/Backends/DirectX12/src/swapchain.cpp index 8fc35ddbc..6a6d738c3 100644 --- a/src/Backends/DirectX12/src/swapchain.cpp +++ b/src/Backends/DirectX12/src/swapchain.cpp @@ -226,7 +226,7 @@ Enumerable> DirectX12SwapChain::timingEvents() const noex SharedPtr DirectX12SwapChain::timingEvent(UInt32 queryId) const { if (queryId >= m_impl->m_timingEvents.size()) - throw ArgumentOutOfRangeException("queryId", std::make_pair(0ull, (UInt64)m_impl->m_timingEvents.size()), queryId, "No timing event has been registered for query ID {0}.", queryId); + throw ArgumentOutOfRangeException("queryId", std::make_pair(0uz, m_impl->m_timingEvents.size()), queryId, "No timing event has been registered for query ID {0}.", queryId); return m_impl->m_timingEvents[queryId]; } @@ -276,7 +276,7 @@ bool DirectX12SwapChain::verticalSynchronization() const noexcept IDirectX12Image* DirectX12SwapChain::image(UInt32 backBuffer) const { if (backBuffer >= m_impl->m_presentImages.size()) [[unlikely]] - throw ArgumentOutOfRangeException("backBuffer", std::make_pair(0ull, (UInt64)m_impl->m_presentImages.size()), backBuffer, "The back buffer must be a valid index."); + throw ArgumentOutOfRangeException("backBuffer", std::make_pair(0uz, m_impl->m_presentImages.size()), backBuffer, "The back buffer must be a valid index."); return m_impl->m_presentImages[backBuffer].get(); } diff --git a/src/Backends/DirectX12/src/tlas.cpp b/src/Backends/DirectX12/src/tlas.cpp index 9f5645302..1c269e80f 100644 --- a/src/Backends/DirectX12/src/tlas.cpp +++ b/src/Backends/DirectX12/src/tlas.cpp @@ -142,9 +142,9 @@ void DirectX12TopLevelAccelerationStructure::build(const DirectX12CommandBuffer& if (buffer == nullptr) buffer = m_impl->m_buffer && m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Perform the build. commandBuffer.buildAccelerationStructure(*this, scratchBuffer, *buffer, offset); @@ -184,9 +184,9 @@ void DirectX12TopLevelAccelerationStructure::update(const DirectX12CommandBuffer if (buffer == nullptr) buffer = m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Perform the update. commandBuffer.updateAccelerationStructure(*this, scratchBuffer, *buffer, offset); @@ -221,7 +221,7 @@ void DirectX12TopLevelAccelerationStructure::copy(const DirectX12CommandBuffer& if (buffer == nullptr) buffer = destination.m_impl->m_buffer->size() >= requiredMemory ? destination.m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Store the buffer and the offset. destination.m_impl->m_offset = offset; diff --git a/src/Backends/Vulkan/src/blas.cpp b/src/Backends/Vulkan/src/blas.cpp index 3108f76b2..baf5c5598 100644 --- a/src/Backends/Vulkan/src/blas.cpp +++ b/src/Backends/Vulkan/src/blas.cpp @@ -169,9 +169,9 @@ void VulkanBottomLevelAccelerationStructure::build(const VulkanCommandBuffer& co if (buffer == nullptr) buffer = m_impl->m_buffer && m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // If the acceleration structure allows for compaction, create a query pool in order to query the compacted size later. if (LITEFX_FLAG_IS_SET(m_impl->m_flags, AccelerationStructureFlags::AllowCompaction)) @@ -235,9 +235,9 @@ void VulkanBottomLevelAccelerationStructure::update(const VulkanCommandBuffer& c if (buffer == nullptr) buffer = m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // If the acceleration structure allows for compaction, reset the query pool. if (LITEFX_FLAG_IS_SET(m_impl->m_flags, AccelerationStructureFlags::AllowCompaction)) @@ -288,7 +288,7 @@ void VulkanBottomLevelAccelerationStructure::copy(const VulkanCommandBuffer& com if (buffer == nullptr) buffer = destination.m_impl->m_buffer->size() >= requiredMemory[0] ? destination.m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory[0], 1, ResourceUsage::AllowWrite); else if (buffer->size() < offset + requiredMemory[0]) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory[0], "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory[0], "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Create or reset query pool on destination, if required. if (LITEFX_FLAG_IS_SET(destination.flags(), AccelerationStructureFlags::AllowCompaction)) diff --git a/src/Backends/Vulkan/src/buffer.cpp b/src/Backends/Vulkan/src/buffer.cpp index d0012b2bb..d61bf0b46 100644 --- a/src/Backends/Vulkan/src/buffer.cpp +++ b/src/Backends/Vulkan/src/buffer.cpp @@ -90,17 +90,20 @@ UInt64 VulkanBuffer::virtualAddress() const noexcept void VulkanBuffer::map(const void* const data, size_t size, UInt32 element) { + if (data == nullptr) [[unlikely]] + throw ArgumentNotInitializedException("data", "The data pointer must be initialized."); + if (element >= m_impl->m_elements) [[unlikely]] throw ArgumentOutOfRangeException("element", std::make_pair(0u, m_impl->m_elements), element, "The element {0} is out of range. The buffer only contains {1} elements.", element, m_impl->m_elements); + + if (this->size() - (element * this->alignedElementSize()) < size) [[unlikely]] + throw InvalidArgumentException("size", "The provided data size would overflow the buffer (buffer offset: 0x{1:X}; {2} bytes remaining but size was set to {0}).", size, element * this->alignedElementSize(), this->size() - (element * this->alignedElementSize())); char* buffer; // A pointer to the whole (aligned) buffer memory. raiseIfFailed(::vmaMapMemory(m_impl->m_allocator, m_impl->m_allocation, reinterpret_cast(&buffer)), "Unable to map buffer memory."); - auto result = ::memcpy_s(reinterpret_cast(buffer + (element * this->alignedElementSize())), this->size(), data, size); + std::memcpy(reinterpret_cast(buffer + (element * this->alignedElementSize())), data, size); ::vmaUnmapMemory(m_impl->m_allocator, m_impl->m_allocation); - - if (result != 0) [[unlikely]] - throw RuntimeException("Error mapping buffer to device memory: {#X}.", result); } void VulkanBuffer::map(Span data, size_t elementSize, UInt32 firstElement) @@ -110,19 +113,24 @@ void VulkanBuffer::map(Span data, size_t elementSize, UInt32 void VulkanBuffer::map(void* data, size_t size, UInt32 element, bool write) { + if (data == nullptr) [[unlikely]] + throw ArgumentNotInitializedException("data", "The data pointer must be initialized."); + if (element >= m_impl->m_elements) [[unlikely]] throw ArgumentOutOfRangeException("element", std::make_pair(0u, m_impl->m_elements), element, "The element {0} is out of range. The buffer only contains {1} elements.", element, m_impl->m_elements); + + if (this->size() - (element * this->alignedElementSize()) < size) [[unlikely]] + throw InvalidArgumentException("size", "The provided data size would overflow the buffer (buffer offset: 0x{1:X}; {2} bytes remaining but size was set to {0}).", size, element * this->alignedElementSize(), this->size() - (element * this->alignedElementSize())); char* buffer; // A pointer to the whole (aligned) buffer memory. raiseIfFailed(::vmaMapMemory(m_impl->m_allocator, m_impl->m_allocation, reinterpret_cast(&buffer)), "Unable to map buffer memory."); - auto result = write ? - ::memcpy_s(reinterpret_cast(buffer + (element * this->alignedElementSize())), this->size(), data, size) : - ::memcpy_s(data, size, reinterpret_cast(buffer + (element * this->alignedElementSize())), size); + + if (write) + std::memcpy(reinterpret_cast(buffer + (element * this->alignedElementSize())), data, size); + else + std::memcpy(data, reinterpret_cast(buffer + (element * this->alignedElementSize())), size); ::vmaUnmapMemory(m_impl->m_allocator, m_impl->m_allocation); - - if (result != 0) [[unlikely]] - throw RuntimeException("Error mapping buffer to device memory: {#X}.", result); } void VulkanBuffer::map(Span data, size_t elementSize, UInt32 firstElement, bool write) diff --git a/src/Backends/Vulkan/src/frame_buffer.cpp b/src/Backends/Vulkan/src/frame_buffer.cpp index cf821779d..9f80b1111 100644 --- a/src/Backends/Vulkan/src/frame_buffer.cpp +++ b/src/Backends/Vulkan/src/frame_buffer.cpp @@ -147,7 +147,7 @@ VulkanFrameBuffer::~VulkanFrameBuffer() noexcept = default; VkImageView VulkanFrameBuffer::imageView(UInt32 imageIndex) const { if (imageIndex >= m_impl->m_images.size()) [[unlikely]] - throw ArgumentOutOfRangeException("imageIndex", std::make_pair(0ull, (UInt64)m_impl->m_images.size()), imageIndex, "The frame buffer does not contain an image at index {0}.", imageIndex); + throw ArgumentOutOfRangeException("imageIndex", std::make_pair(0uz, m_impl->m_images.size()), imageIndex, "The frame buffer does not contain an image at index {0}.", imageIndex); return m_impl->m_renderTargetHandles.at(m_impl->m_images[imageIndex].get()); } @@ -188,7 +188,7 @@ size_t VulkanFrameBuffer::getHeight() const noexcept void VulkanFrameBuffer::mapRenderTarget(const RenderTarget& renderTarget, UInt32 index) { if (index >= m_impl->m_images.size()) [[unlikely]] - throw ArgumentOutOfRangeException("index", std::make_pair(0ull, (UInt64)m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); + throw ArgumentOutOfRangeException("index", std::make_pair(0uz, m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); if (m_impl->m_images[index]->format() != renderTarget.format()) [[unlikely]] LITEFX_WARNING(VULKAN_LOG, "The render target format {0} does not match the image format {1} for image {2}.", renderTarget.format(), m_impl->m_images[index]->format(), index); @@ -219,7 +219,7 @@ Enumerable VulkanFrameBuffer::images() const noexcept const IVulkanImage& VulkanFrameBuffer::image(UInt32 index) const { if (index >= m_impl->m_images.size()) - throw ArgumentOutOfRangeException("index", std::make_pair(0ull, (UInt64)m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); + throw ArgumentOutOfRangeException("index", std::make_pair(0uz, m_impl->m_images.size()), index, "The frame buffer does not contain an image at index {0}.", index); return *m_impl->m_images[index]; } diff --git a/src/Backends/Vulkan/src/render_pass.cpp b/src/Backends/Vulkan/src/render_pass.cpp index 5ea771105..e51e83a97 100644 --- a/src/Backends/Vulkan/src/render_pass.cpp +++ b/src/Backends/Vulkan/src/render_pass.cpp @@ -67,12 +67,12 @@ class VulkanRenderPass::VulkanRenderPassImpl : public Implement& VulkanRenderPass::inputAttachments() const no const RenderPassDependency& VulkanRenderPass::inputAttachment(UInt32 location) const { if (location >= m_impl->m_inputAttachments.size()) [[unlikely]] - throw ArgumentOutOfRangeException("location", std::make_pair(0ull, (UInt64)m_impl->m_inputAttachments.size()), location, "The render pass does not contain an input attachment at location {0}.", location); + throw ArgumentOutOfRangeException("location", std::make_pair(0uz, m_impl->m_inputAttachments.size()), location, "The render pass does not contain an input attachment at location {0}.", location); return m_impl->m_inputAttachments[location]; } diff --git a/src/Backends/Vulkan/src/render_pipeline.cpp b/src/Backends/Vulkan/src/render_pipeline.cpp index 113ad504a..3745f48d6 100644 --- a/src/Backends/Vulkan/src/render_pipeline.cpp +++ b/src/Backends/Vulkan/src/render_pipeline.cpp @@ -196,7 +196,7 @@ class VulkanRenderPipeline::VulkanRenderPipelineImpl : public Implement(renderTarget.blendState().WriteMask) + .colorWriteMask = static_cast(renderTarget.blendState().ChannelWriteMask) }); }); @@ -329,7 +329,13 @@ class VulkanRenderPipeline::VulkanRenderPipelineImpl : public ImplementdescriptorSet(set).allocate()); })); + auto range = descriptorSets | std::views::transform([this](UInt32 set) { return std::move(m_layout->descriptorSet(set).allocate()); }); + +#ifdef __cpp_lib_containers_ranges + bindings.append_range(std::move(range)); +#else + bindings.insert(std::end(bindings), std::begin(range), std::end(range)); +#endif // Listen to frame buffer events and update the bindings or remove the sets (on release). m_frameBufferResizeTokens[interfacePointer] = frameBuffer.resized.add(std::bind(&VulkanRenderPipelineImpl::onFrameBufferResize, this, std::placeholders::_1, std::placeholders::_2)); diff --git a/src/Backends/Vulkan/src/shader_program.cpp b/src/Backends/Vulkan/src/shader_program.cpp index 0287b82ff..2774af0a7 100644 --- a/src/Backends/Vulkan/src/shader_program.cpp +++ b/src/Backends/Vulkan/src/shader_program.cpp @@ -110,7 +110,7 @@ class VulkanShaderProgram::VulkanShaderProgramImpl : public Implement(nullptr))) [[unlikely]] throw InvalidArgumentException("modules", "At least one of the shader modules is not initialized."); // Check if there are combinations, that are not supported. diff --git a/src/Backends/Vulkan/src/swapchain.cpp b/src/Backends/Vulkan/src/swapchain.cpp index 6794d49fd..6b9a08b56 100644 --- a/src/Backends/Vulkan/src/swapchain.cpp +++ b/src/Backends/Vulkan/src/swapchain.cpp @@ -74,6 +74,8 @@ class VulkanSwapChain::VulkanSwapChainImpl : public Implement { // Get the number of images in the swap chain. VkSurfaceCapabilitiesKHR deviceCaps; ::vkGetPhysicalDeviceSurfaceCapabilitiesKHR(adapter, surface, &deviceCaps); + if (deviceCaps.maxImageCount == 0) // 0 means is unlimited. + deviceCaps.maxImageCount = std::numeric_limits::max(); UInt32 images = std::clamp(buffers, deviceCaps.minImageCount, deviceCaps.maxImageCount); // Create a swap chain. @@ -994,7 +996,7 @@ Enumerable> VulkanSwapChain::timingEvents() const noexcep SharedPtr VulkanSwapChain::timingEvent(UInt32 queryId) const { if (queryId >= m_impl->m_timingEvents.size()) - throw ArgumentOutOfRangeException("queryId", std::make_pair(0ull, (UInt64)m_impl->m_timingEvents.size()), queryId, "No timing event has been registered for query ID {0}.", queryId); + throw ArgumentOutOfRangeException("queryId", std::make_pair(0uz, m_impl->m_timingEvents.size()), queryId, "No timing event has been registered for query ID {0}.", queryId); return m_impl->m_timingEvents[queryId]; } @@ -1050,7 +1052,7 @@ bool VulkanSwapChain::verticalSynchronization() const noexcept IVulkanImage* VulkanSwapChain::image(UInt32 backBuffer) const { if (backBuffer >= m_impl->m_presentImages.size()) [[unlikely]] - throw ArgumentOutOfRangeException("backBuffer", std::make_pair(0ull, (UInt64)m_impl->m_presentImages.size()), backBuffer, "The back buffer must be a valid index."); + throw ArgumentOutOfRangeException("backBuffer", std::make_pair(0uz, m_impl->m_presentImages.size()), backBuffer, "The back buffer must be a valid index."); return m_impl->m_presentImages[backBuffer].get(); } diff --git a/src/Backends/Vulkan/src/tlas.cpp b/src/Backends/Vulkan/src/tlas.cpp index f4eba7b95..3fdcb26b3 100644 --- a/src/Backends/Vulkan/src/tlas.cpp +++ b/src/Backends/Vulkan/src/tlas.cpp @@ -111,9 +111,9 @@ void VulkanTopLevelAccelerationStructure::build(const VulkanCommandBuffer& comma if (buffer == nullptr) buffer = m_impl->m_buffer != nullptr && m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // If the acceleration structure allows for compaction, create a query pool in order to query the compacted size later. if (LITEFX_FLAG_IS_SET(m_impl->m_flags, AccelerationStructureFlags::AllowCompaction)) @@ -172,9 +172,9 @@ void VulkanTopLevelAccelerationStructure::update(const VulkanCommandBuffer& comm if (buffer == nullptr) buffer = m_impl->m_buffer->size() >= requiredMemory ? m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory, 1, ResourceUsage::AllowWrite); else if (maxSize < requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("maxSize", std::make_pair(0ull, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); + throw ArgumentOutOfRangeException("maxSize", std::make_pair(0_ui64, maxSize), requiredMemory, "The maximum available size is not sufficient to contain the acceleration structure."); else if (buffer->size() < offset + requiredMemory) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // If the acceleration structure allows for compaction, reset the query pool. if (LITEFX_FLAG_IS_SET(m_impl->m_flags, AccelerationStructureFlags::AllowCompaction)) @@ -220,7 +220,7 @@ void VulkanTopLevelAccelerationStructure::copy(const VulkanCommandBuffer& comman if (buffer == nullptr) buffer = destination.m_impl->m_buffer->size() >= requiredMemory[0] ? destination.m_impl->m_buffer : device.factory().createBuffer(BufferType::AccelerationStructure, ResourceHeap::Resource, requiredMemory[0], 1, ResourceUsage::AllowWrite); else if (buffer->size() < offset + requiredMemory[0]) [[unlikely]] - throw ArgumentOutOfRangeException("buffer", std::make_pair(0ull, (UInt64)buffer->size()), offset + requiredMemory[0], "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); + throw ArgumentOutOfRangeException("buffer", std::make_pair(0uz, buffer->size()), offset + requiredMemory[0], "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); // Create or reset query pool on destination, if required. if (LITEFX_FLAG_IS_SET(destination.flags(), AccelerationStructureFlags::AllowCompaction)) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b70650e79..663e354f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,12 +15,12 @@ ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") PROJECT(LiteFX LANGUAGES CXX) # Include configuration files. -INCLUDE("${CMAKE_SOURCE_DIR}/cmake/modules.cmake") -INCLUDE("${CMAKE_SOURCE_DIR}/cmake/version.cmake") -INCLUDE("${CMAKE_SOURCE_DIR}/cmake/options.cmake") -INCLUDE("${CMAKE_SOURCE_DIR}/cmake/config.cmake") -INCLUDE("${CMAKE_SOURCE_DIR}/cmake/shaders.cmake") -INCLUDE("${CMAKE_SOURCE_DIR}/cmake/assets.cmake") +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/Modules.cmake") +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/Version.cmake") +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/Options.cmake") +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/Config.cmake") +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/Shaders.cmake") +INCLUDE("${CMAKE_SOURCE_DIR}/cmake/Assets.cmake") # Include sub-projects. ADD_SUBDIRECTORY(Core) diff --git a/src/CMakePresets.json b/src/CMakePresets.json index 890f85946..2533001f2 100644 --- a/src/CMakePresets.json +++ b/src/CMakePresets.json @@ -1,43 +1,15 @@ { - "version": 2, + "version": 4, "cmakeMinimumRequired": { "major": 3, - "minor": 20, + "minor": 23, "patch": 0 }, + "include": [ + "cmake/presets/platforms.json", + "cmake/presets/compilers.json" + ], "configurePresets": [ - { - "name": "windows", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/../out/build/${presetName}", - "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/../out/install/${presetName}", - "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/modules/vcpkg/scripts/buildsystems/vcpkg.cmake", - "X_VCPKG_APPLOCAL_DEPS_INSTALL": "ON" - }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "hostOS": [ "Windows" ] - } - } - }, - { - "name": "msvc", - "hidden": true, - "cacheVariables": { - "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl" - } - }, - { - "name": "clang", - "hidden": true, - "cacheVariables": { - "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++" - } - }, { "name": "windows-msvc-x64-debug", "inherits": [ diff --git a/src/Core/include/litefx/containers.hpp b/src/Core/include/litefx/containers.hpp index 2ac12633d..8e7c865ef 100644 --- a/src/Core/include/litefx/containers.hpp +++ b/src/Core/include/litefx/containers.hpp @@ -591,6 +591,9 @@ namespace LiteFX { /// The type of the resource. template class Resource : public virtual IResource { + public: + using handle_type = THandle; + private: THandle m_handle; diff --git a/src/Core/include/litefx/exceptions.hpp b/src/Core/include/litefx/exceptions.hpp index db48dc6de..81cec9732 100644 --- a/src/Core/include/litefx/exceptions.hpp +++ b/src/Core/include/litefx/exceptions.hpp @@ -13,7 +13,7 @@ namespace LiteFX { /// /// The base class for exceptions thrown by the SDK. /// - class Exception : public std::exception { + class Exception : public std::runtime_error { private: std::source_location m_location; std::stacktrace m_trace; @@ -26,7 +26,7 @@ namespace LiteFX { /// The source location of the error. /// The stack trace leading to the error. explicit Exception(std::string message, const std::source_location& location, std::stacktrace trace) noexcept : - std::exception(message.c_str()), m_location(location), m_trace(trace) { } + std::runtime_error(message.c_str()), m_location(location), m_trace(trace) { } public: Exception(const Exception&) = default; diff --git a/src/Core/include/litefx/traits.hpp b/src/Core/include/litefx/traits.hpp index 974a287c5..1b9faa1e9 100644 --- a/src/Core/include/litefx/traits.hpp +++ b/src/Core/include/litefx/traits.hpp @@ -4,6 +4,15 @@ #include #include +#ifndef __cpp_size_t_suffix +// Implements C++23 P0330R8 for when compiler is missing support (MSVC only). +#pragma warning(suppress: 4455) // Ignore warning about reserved suffix, as this is guarded anyway. +inline constexpr std::size_t operator"" uz(unsigned long long int k) +{ + return static_cast(k); +} +#endif + /// /// Contains type traits and meta-programming features for compile-time evaluation. /// diff --git a/src/Logging/include/litefx/logging.hpp b/src/Logging/include/litefx/logging.hpp index 4603076dd..c262e81a9 100644 --- a/src/Logging/include/litefx/logging.hpp +++ b/src/Logging/include/litefx/logging.hpp @@ -188,14 +188,15 @@ namespace LiteFX::Logging { } #ifndef NDEBUG -#define LITEFX_TRACE(log, format, ...) LiteFX::Logging::Logger::get(log).trace(format, __VA_ARGS__) -#define LITEFX_DEBUG(log, format, ...) LiteFX::Logging::Logger::get(log).debug(format, __VA_ARGS__) +#define LITEFX_DETAILS_LOG_HELPER(...) __VA_ARGS__ +#define LITEFX_TRACE(log, format, ...) LiteFX::Logging::Logger::get(log).trace(format, ##__VA_ARGS__) +#define LITEFX_DEBUG(log, format, ...) LiteFX::Logging::Logger::get(log).debug(format, ##__VA_ARGS__) #else #define LITEFX_TRACE(log, format, ...) #define LITEFX_DEBUG(log, format, ...) #endif -#define LITEFX_INFO(log, format, ...) LiteFX::Logging::Logger::get(log).info(format, __VA_ARGS__) -#define LITEFX_WARNING(log, format, ...) LiteFX::Logging::Logger::get(log).warning(format, __VA_ARGS__) -#define LITEFX_ERROR(log, format, ...) LiteFX::Logging::Logger::get(log).error(format, __VA_ARGS__) -#define LITEFX_FATAL_ERROR(log, format, ...) LiteFX::Logging::Logger::get(log).fatal(format, __VA_ARGS__) \ No newline at end of file +#define LITEFX_INFO(log, format, ...) LiteFX::Logging::Logger::get(log).info(format, ##__VA_ARGS__) +#define LITEFX_WARNING(log, format, ...) LiteFX::Logging::Logger::get(log).warning(format, ##__VA_ARGS__) +#define LITEFX_ERROR(log, format, ...) LiteFX::Logging::Logger::get(log).error(format, ##__VA_ARGS__) +#define LITEFX_FATAL_ERROR(log, format, ...) LiteFX::Logging::Logger::get(log).fatal(format, ##__VA_ARGS__) \ No newline at end of file diff --git a/src/Rendering/include/litefx/rendering.hpp b/src/Rendering/include/litefx/rendering.hpp index 22fe01c7a..8c039c5ee 100644 --- a/src/Rendering/include/litefx/rendering.hpp +++ b/src/Rendering/include/litefx/rendering.hpp @@ -1263,7 +1263,6 @@ namespace LiteFX::Rendering { using shader_program_type = render_pipeline_type::shader_program_type; using input_assembler_type = render_pipeline_type::input_assembler_type; using rasterizer_type = render_pipeline_type::rasterizer_type; - using shader_program_type = render_pipeline_type::shader_program_type; public: virtual ~GraphicsDevice() noexcept = default; diff --git a/src/Rendering/include/litefx/rendering_api.hpp b/src/Rendering/include/litefx/rendering_api.hpp index 28829ecad..d237282d5 100644 --- a/src/Rendering/include/litefx/rendering_api.hpp +++ b/src/Rendering/include/litefx/rendering_api.hpp @@ -2577,7 +2577,7 @@ namespace LiteFX::Rendering { /// /// The channel write mask, determining which channels are written to (default: WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A). /// - WriteMask WriteMask{ WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A }; + WriteMask ChannelWriteMask{ WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A }; }; public: diff --git a/src/Samples/BasicRendering/CMakeLists.txt b/src/Samples/BasicRendering/CMakeLists.txt index cd5d043ea..09f8ac25a 100644 --- a/src/Samples/BasicRendering/CMakeLists.txt +++ b/src/Samples/BasicRendering/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/BasicRendering/src/main.cpp b/src/Samples/BasicRendering/src/main.cpp index 7cfb5c289..cbb1ee80f 100644 --- a/src/Samples/BasicRendering/src/main.cpp +++ b/src/Samples/BasicRendering/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/Bindless/CMakeLists.txt b/src/Samples/Bindless/CMakeLists.txt index a420efe8d..c31843a96 100644 --- a/src/Samples/Bindless/CMakeLists.txt +++ b/src/Samples/Bindless/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/Bindless/src/main.cpp b/src/Samples/Bindless/src/main.cpp index 673648b19..5f545fb14 100644 --- a/src/Samples/Bindless/src/main.cpp +++ b/src/Samples/Bindless/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/Compute/CMakeLists.txt b/src/Samples/Compute/CMakeLists.txt index 5eaf9f667..e5c66c5f1 100644 --- a/src/Samples/Compute/CMakeLists.txt +++ b/src/Samples/Compute/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/Compute/src/main.cpp b/src/Samples/Compute/src/main.cpp index 3ff165794..6f238c9f5 100644 --- a/src/Samples/Compute/src/main.cpp +++ b/src/Samples/Compute/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/Indirect/CMakeLists.txt b/src/Samples/Indirect/CMakeLists.txt index a8ed6c367..c99695a8e 100644 --- a/src/Samples/Indirect/CMakeLists.txt +++ b/src/Samples/Indirect/CMakeLists.txt @@ -24,7 +24,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/Indirect/src/main.cpp b/src/Samples/Indirect/src/main.cpp index aaafb02da..d9ea613ea 100644 --- a/src/Samples/Indirect/src/main.cpp +++ b/src/Samples/Indirect/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/MeshShader/CMakeLists.txt b/src/Samples/MeshShader/CMakeLists.txt index ac6360bf7..d17eb4411 100644 --- a/src/Samples/MeshShader/CMakeLists.txt +++ b/src/Samples/MeshShader/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/MeshShader/src/main.cpp b/src/Samples/MeshShader/src/main.cpp index 7a5f6b969..8f8ab5ce2 100644 --- a/src/Samples/MeshShader/src/main.cpp +++ b/src/Samples/MeshShader/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/Multisampling/CMakeLists.txt b/src/Samples/Multisampling/CMakeLists.txt index 8728fd300..91323b6b6 100644 --- a/src/Samples/Multisampling/CMakeLists.txt +++ b/src/Samples/Multisampling/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/Multisampling/src/main.cpp b/src/Samples/Multisampling/src/main.cpp index ce5ee1474..9e3c78973 100644 --- a/src/Samples/Multisampling/src/main.cpp +++ b/src/Samples/Multisampling/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/Multithreading/CMakeLists.txt b/src/Samples/Multithreading/CMakeLists.txt index 2cbdcd115..666c80bea 100644 --- a/src/Samples/Multithreading/CMakeLists.txt +++ b/src/Samples/Multithreading/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/Multithreading/src/main.cpp b/src/Samples/Multithreading/src/main.cpp index 997b43dcd..25185c146 100644 --- a/src/Samples/Multithreading/src/main.cpp +++ b/src/Samples/Multithreading/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/PushConstants/CMakeLists.txt b/src/Samples/PushConstants/CMakeLists.txt index b99ad61bf..40bc4cdf5 100644 --- a/src/Samples/PushConstants/CMakeLists.txt +++ b/src/Samples/PushConstants/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/PushConstants/src/main.cpp b/src/Samples/PushConstants/src/main.cpp index 06cb34bc1..ed1eee1be 100644 --- a/src/Samples/PushConstants/src/main.cpp +++ b/src/Samples/PushConstants/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/RayQueries/CMakeLists.txt b/src/Samples/RayQueries/CMakeLists.txt index a4031dd64..1cc9c090f 100644 --- a/src/Samples/RayQueries/CMakeLists.txt +++ b/src/Samples/RayQueries/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/RayQueries/src/main.cpp b/src/Samples/RayQueries/src/main.cpp index 62f8fc129..44057dd81 100644 --- a/src/Samples/RayQueries/src/main.cpp +++ b/src/Samples/RayQueries/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/RayTracing/CMakeLists.txt b/src/Samples/RayTracing/CMakeLists.txt index e497f8bb0..8cdeebe99 100644 --- a/src/Samples/RayTracing/CMakeLists.txt +++ b/src/Samples/RayTracing/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/RayTracing/src/main.cpp b/src/Samples/RayTracing/src/main.cpp index 94cde6b09..a19414c62 100644 --- a/src/Samples/RayTracing/src/main.cpp +++ b/src/Samples/RayTracing/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/RenderPasses/CMakeLists.txt b/src/Samples/RenderPasses/CMakeLists.txt index 18f1dae08..ee6b4da28 100644 --- a/src/Samples/RenderPasses/CMakeLists.txt +++ b/src/Samples/RenderPasses/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/RenderPasses/src/main.cpp b/src/Samples/RenderPasses/src/main.cpp index 080c6cca2..ecffc25d8 100644 --- a/src/Samples/RenderPasses/src/main.cpp +++ b/src/Samples/RenderPasses/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/Textures/CMakeLists.txt b/src/Samples/Textures/CMakeLists.txt index be4f5be8f..676a85a00 100644 --- a/src/Samples/Textures/CMakeLists.txt +++ b/src/Samples/Textures/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/Textures/src/main.cpp b/src/Samples/Textures/src/main.cpp index a7a2114f4..1e2e7c3b1 100644 --- a/src/Samples/Textures/src/main.cpp +++ b/src/Samples/Textures/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/Samples/UniformArrays/CMakeLists.txt b/src/Samples/UniformArrays/CMakeLists.txt index 91f27f39c..c4f2b12f5 100644 --- a/src/Samples/UniformArrays/CMakeLists.txt +++ b/src/Samples/UniformArrays/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF(NOT LITEFX_BUILD_WITH_GLM) # Resolve package dependencies. FIND_PACKAGE(glfw3 CONFIG REQUIRED) -FIND_PACKAGE(cli11 CONFIG REQUIRED) +FIND_PACKAGE(CLI11 CONFIG REQUIRED) FIND_PATH(RENDERDOC_INCLUDE_DIR "renderdoc_app.h") IF(NOT RENDERDOC_INCLUDE_DIR AND LITEFX_BUILD_EXAMPLES_RENDERDOC_LOADER) diff --git a/src/Samples/UniformArrays/src/main.cpp b/src/Samples/UniformArrays/src/main.cpp index 89e45998f..971c7cf79 100644 --- a/src/Samples/UniformArrays/src/main.cpp +++ b/src/Samples/UniformArrays/src/main.cpp @@ -10,9 +10,10 @@ #include #include #include -#include #ifdef LITEFX_BUILD_EXAMPLES_DX12_PIX_LOADER +#include + bool loadPixCapturer() { // Check if Pix has already been loaded. diff --git a/src/cmake/Shaders.cmake b/src/cmake/Shaders.cmake index 8a22e58bd..4ea3dc15a 100644 --- a/src/cmake/Shaders.cmake +++ b/src/cmake/Shaders.cmake @@ -398,6 +398,7 @@ FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/Auxiliary/pcksl.cxx" CONTENT [==[ #include #include #include +#include int main(int argc, char* argv[]) { if (argc < 2) diff --git a/src/cmake/presets/compilers.json b/src/cmake/presets/compilers.json new file mode 100644 index 000000000..3d636d846 --- /dev/null +++ b/src/cmake/presets/compilers.json @@ -0,0 +1,23 @@ +{ + "version": 4, + "include": [ + "platforms.json" + ], + "configurePresets": [ + { + "name": "msvc", + "hidden": true, + "inherits": "windows", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "cl" + } + }, + { + "name": "clang", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_COMPILER": "clang++" + } + } + ] +} \ No newline at end of file diff --git a/src/cmake/presets/platforms.json b/src/cmake/presets/platforms.json new file mode 100644 index 000000000..b083a2187 --- /dev/null +++ b/src/cmake/presets/platforms.json @@ -0,0 +1,45 @@ +{ + "version": 4, + "configurePresets": [ + { + "name": "windows", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "generator": "Ninja", + "binaryDir": "${sourceDir}/../out/build/${presetName}", + "installDir": "${sourceDir}/../out/install/${presetName}", + "toolchainFile": "${sourceDir}/Modules/vcpkg/scripts/buildsystems/vcpkg.cmake", + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ "Windows" ] + } + } + } + ], + "buildPresets": [ + { + "name": "windows", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + } + ], + "testPresets": [ + { + "name": "windows", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + } + ] +} \ No newline at end of file From 5ed7f87b1300b32726e2bdc733f69f2fce2b023c Mon Sep 17 00:00:00 2001 From: Carsten Rudolph <18394207+crud89@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:29:52 +0100 Subject: [PATCH 2/2] Dereference iterator using `std::addressof`. --- src/Backends/DirectX12/src/render_pass.cpp | 4 ++-- src/Backends/Vulkan/src/render_pass.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Backends/DirectX12/src/render_pass.cpp b/src/Backends/DirectX12/src/render_pass.cpp index 99f66d739..d825a0301 100644 --- a/src/Backends/DirectX12/src/render_pass.cpp +++ b/src/Backends/DirectX12/src/render_pass.cpp @@ -63,12 +63,12 @@ class DirectX12RenderPass::DirectX12RenderPassImpl : public Implement