From 5dee917748bfe795081e5f32b5d9370e8bd45dfb Mon Sep 17 00:00:00 2001 From: Graham Dianaty Date: Sat, 1 Jul 2023 02:02:33 -0400 Subject: [PATCH 1/5] Add C++20 compliance. --- include/LLGL/Container/SmallVector.h | 21 +++++++++++-------- .../Direct3D11/D3D11CommandBuffer.cpp | 9 ++++---- .../Direct3D12/Shader/D3D12RootParameter.cpp | 3 +++ .../Direct3D12/Shader/D3D12RootParameter.h | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/LLGL/Container/SmallVector.h b/include/LLGL/Container/SmallVector.h index 7e7d66029a..a43edb010a 100644 --- a/include/LLGL/Container/SmallVector.h +++ b/include/LLGL/Container/SmallVector.h @@ -373,14 +373,17 @@ class LLGL_EXPORT SmallVector { if (size_ == cap_) realloc(GrowStrategy::Grow(size_ + 1)); - Allocator{}.construct(end(), value); + Allocator alloc; + std::allocator_traits::construct(alloc, end(), value); ++size_; } void push_back(value_type&& value) { reserve(size() + 1); - Allocator{}.construct(end(), std::forward(value)); + //Allocator{}.construct(end(), std::forward(value)); + Allocator alloc; + std::allocator_traits::construct(alloc, end(), std::forward(value)); ++size_; } @@ -646,7 +649,7 @@ class LLGL_EXPORT SmallVector { Allocator alloc; for (; from != to; ++from) - alloc.destroy(from); + std::allocator_traits::destroy(alloc, from); } template @@ -654,7 +657,7 @@ class LLGL_EXPORT SmallVector { Allocator alloc; for (; from != to; ++from) - alloc.construct(from, std::forward(args)...); + std::allocator_traits::construct(alloc, from, std::forward(args)...); } template @@ -662,7 +665,7 @@ class LLGL_EXPORT SmallVector { Allocator alloc; for (pointer p = pos; from != to; ++from, ++p) - alloc.construct(p, *from); + std::allocator_traits::construct(alloc, p, *from); } template @@ -730,8 +733,8 @@ class LLGL_EXPORT SmallVector for (; from != to; ++from, ++dst) { /* Copy element from current position 'from' to destination 'dst' and destroy the old one */ - alloc.construct(dst, *from); - alloc.destroy(from); + std::allocator_traits::construct(alloc, dst, *from); + std::allocator_traits::destroy(alloc, from); } } @@ -743,8 +746,8 @@ class LLGL_EXPORT SmallVector for (auto rfrom = reverse_iterator{ to }, rto = reverse_iterator{ from }; rfrom != rto; ++rfrom, ++rdst) { /* Copy element from current position 'from' to destination 'dst' and destroy the old one */ - alloc.construct(&(*rdst), *rfrom); - alloc.destroy(&(*rfrom)); + std::allocator_traits::construct(alloc, &(*rfrom)); + std::allocator_traits::destroy(alloc, &(*rfrom)); } } diff --git a/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp b/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp index f8afe6b6c3..703440ad34 100644 --- a/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp +++ b/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp @@ -125,6 +125,10 @@ void D3D11CommandBuffer::CopyBuffer( { auto& dstBufferD3D = LLGL_CAST(D3D11Buffer&, dstBuffer); auto& srcBufferD3D = LLGL_CAST(D3D11Buffer&, srcBuffer); + CD3D11_BOX box = CD3D11_BOX( + static_cast(srcOffset), 0, 0, + static_cast(srcOffset + size), 1, 1 + ); context_->CopySubresourceRegion( dstBufferD3D.GetNative(), // pDstResource @@ -134,10 +138,7 @@ void D3D11CommandBuffer::CopyBuffer( 0, // DstZ srcBufferD3D.GetNative(), // pSrcResource 0, // SrcSubresource - &CD3D11_BOX( // pSrcBox - static_cast(srcOffset), 0, 0, - static_cast(srcOffset + size), 1, 1 - ) + &box // pSrcBox ); } diff --git a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp index f2d7ee4336..3a28236614 100644 --- a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp +++ b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp @@ -13,6 +13,9 @@ namespace LLGL { +D3D12RootParameter::D3D12RootParameter() +{ +} D3D12RootParameter::D3D12RootParameter(D3D12_ROOT_PARAMETER* managedRootParam) : managedRootParam_ { managedRootParam } diff --git a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h index b6c757c824..68bba2988a 100644 --- a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h +++ b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h @@ -25,7 +25,7 @@ class D3D12RootParameter { public: - + D3D12RootParameter(); D3D12RootParameter(D3D12_ROOT_PARAMETER* managedRootParam); D3D12RootParameter(const D3D12RootParameter&) = default; From 1182966540b24193c1a664cfbfd63270eb593ac9 Mon Sep 17 00:00:00 2001 From: Graham Dianaty Date: Sat, 1 Jul 2023 02:09:14 -0400 Subject: [PATCH 2/5] Fix a mistake in SmallVector and clean up some extraneous code comments. --- include/LLGL/Container/SmallVector.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/LLGL/Container/SmallVector.h b/include/LLGL/Container/SmallVector.h index a43edb010a..18128a2bc2 100644 --- a/include/LLGL/Container/SmallVector.h +++ b/include/LLGL/Container/SmallVector.h @@ -381,7 +381,6 @@ class LLGL_EXPORT SmallVector void push_back(value_type&& value) { reserve(size() + 1); - //Allocator{}.construct(end(), std::forward(value)); Allocator alloc; std::allocator_traits::construct(alloc, end(), std::forward(value)); ++size_; @@ -746,7 +745,7 @@ class LLGL_EXPORT SmallVector for (auto rfrom = reverse_iterator{ to }, rto = reverse_iterator{ from }; rfrom != rto; ++rfrom, ++rdst) { /* Copy element from current position 'from' to destination 'dst' and destroy the old one */ - std::allocator_traits::construct(alloc, &(*rfrom)); + std::allocator_traits::construct(alloc, &(*rdst), *rfrom); std::allocator_traits::destroy(alloc, &(*rfrom)); } } From 352e0d4da19d9f73a7c480ce9f870db1c0396b2c Mon Sep 17 00:00:00 2001 From: Graham Dianaty Date: Sat, 1 Jul 2023 02:51:58 -0400 Subject: [PATCH 3/5] Update SpirvInstruction.h and SpirvInstructonInfo.h to use current SPIR-V include header pathing. --- sources/Renderer/SPIRV/SpirvInstruction.h | 2 +- sources/Renderer/SPIRV/SpirvInstructionInfo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/Renderer/SPIRV/SpirvInstruction.h b/sources/Renderer/SPIRV/SpirvInstruction.h index 2f02d24907..b14ac16b78 100644 --- a/sources/Renderer/SPIRV/SpirvInstruction.h +++ b/sources/Renderer/SPIRV/SpirvInstruction.h @@ -9,7 +9,7 @@ #define LLGL_SPIRV_INSTRUCTION_H -#include +#include #include diff --git a/sources/Renderer/SPIRV/SpirvInstructionInfo.h b/sources/Renderer/SPIRV/SpirvInstructionInfo.h index 44dd3f5368..63648df2f0 100644 --- a/sources/Renderer/SPIRV/SpirvInstructionInfo.h +++ b/sources/Renderer/SPIRV/SpirvInstructionInfo.h @@ -9,7 +9,7 @@ #define LLGL_SPIRV_INSTRUCTION_INFO_H -#include +#include #include From 9b87525af44d24c08b843c0f0a5baca59dfa5048 Mon Sep 17 00:00:00 2001 From: Graham Dianaty Date: Mon, 3 Jul 2023 15:31:02 -0400 Subject: [PATCH 4/5] Use of default constructor keyword for D3D12RootParameter. --- sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp | 4 ---- sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp index 3a28236614..68877c17bc 100644 --- a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp +++ b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.cpp @@ -13,10 +13,6 @@ namespace LLGL { -D3D12RootParameter::D3D12RootParameter() -{ -} - D3D12RootParameter::D3D12RootParameter(D3D12_ROOT_PARAMETER* managedRootParam) : managedRootParam_ { managedRootParam } { diff --git a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h index 68bba2988a..d1ceb365a5 100644 --- a/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h +++ b/sources/Renderer/Direct3D12/Shader/D3D12RootParameter.h @@ -25,7 +25,7 @@ class D3D12RootParameter { public: - D3D12RootParameter(); + D3D12RootParameter() = default; D3D12RootParameter(D3D12_ROOT_PARAMETER* managedRootParam); D3D12RootParameter(const D3D12RootParameter&) = default; From 266ae90f6b205ef5b3effca4790210ecb09483de Mon Sep 17 00:00:00 2001 From: Graham Dianaty Date: Mon, 3 Jul 2023 15:54:34 -0400 Subject: [PATCH 5/5] Fix bad include paths from the initial C++20 port that initially existed due to a bad local SDK configuration. --- sources/Renderer/SPIRV/SpirvInstruction.h | 2 +- sources/Renderer/SPIRV/SpirvInstructionInfo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/Renderer/SPIRV/SpirvInstruction.h b/sources/Renderer/SPIRV/SpirvInstruction.h index b14ac16b78..2f02d24907 100644 --- a/sources/Renderer/SPIRV/SpirvInstruction.h +++ b/sources/Renderer/SPIRV/SpirvInstruction.h @@ -9,7 +9,7 @@ #define LLGL_SPIRV_INSTRUCTION_H -#include +#include #include diff --git a/sources/Renderer/SPIRV/SpirvInstructionInfo.h b/sources/Renderer/SPIRV/SpirvInstructionInfo.h index 63648df2f0..44dd3f5368 100644 --- a/sources/Renderer/SPIRV/SpirvInstructionInfo.h +++ b/sources/Renderer/SPIRV/SpirvInstructionInfo.h @@ -9,7 +9,7 @@ #define LLGL_SPIRV_INSTRUCTION_INFO_H -#include +#include #include