Set higher warning level, check successful CPU allocation with an assert
Also fixes in documentation and other minor
diff --git a/premake/premake5.lua b/premake/premake5.lua
index 04bfb26..035da18 100644
--- a/premake/premake5.lua
+++ b/premake/premake5.lua
@@ -27,6 +27,11 @@
files { "../src/*.h", "../src/*.cpp" }
flags { "NoPCH", "FatalWarnings" }
characterset "Unicode"
+warnings "Extra"
+disablewarnings "4127" -- conditional expression is constant
+disablewarnings "4100" -- unreferenced formal parameter
+disablewarnings "4324" -- structure was padded due to alignment specifier
+disablewarnings "4189" -- local variable is initialized but not referenced
filter "configurations:Debug"
defines { "_DEBUG", "DEBUG" }
diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp
index 5e88331..c4d37b1 100644
--- a/src/D3D12MemAlloc.cpp
+++ b/src/D3D12MemAlloc.cpp
@@ -112,7 +112,9 @@
static void* Malloc(const ALLOCATION_CALLBACKS& allocs, size_t size, size_t alignment)
{
- return (*allocs.pAllocate)(size, alignment, allocs.pUserData);
+ void* const result = (*allocs.pAllocate)(size, alignment, allocs.pUserData);
+ D3D12MA_ASSERT(result);
+ return result;
}
static void Free(const ALLOCATION_CALLBACKS& allocs, void* memory)
{
diff --git a/src/D3D12MemAlloc.h b/src/D3D12MemAlloc.h
index c1be18a..b472a06 100644
--- a/src/D3D12MemAlloc.h
+++ b/src/D3D12MemAlloc.h
@@ -24,7 +24,7 @@
/** \mainpage D3D12 Memory Allocator
-<b>Version 2.0.0-development</b> (2020-04-07)
+<b>Version 2.0.0-development</b> (2020-05-25)
Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. \n
License: MIT
@@ -339,7 +339,6 @@
Near future: feature parity with [Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/), including:
- Alternative allocation algorithms: linear allocator, buddy allocator
-- JSON dump that can be visualized on a picture
- Support for priorities using `ID3D12Device1::SetResidencyPriority`
Later:
@@ -357,7 +356,17 @@
`UPLOAD`, `DEFAULT`, `READBACK`.
- Support for reserved (tiled) resources. We don't recommend using them.
- Support for `ID3D12Device::Evict` and `MakeResident`. We don't recommend using them.
-
+- Handling CPU memory allocation failures. When dynamically creating small C++
+ objects in CPU memory (not the GPU memory), allocation failures are not
+ handled gracefully, because that would complicate code significantly and
+ is usually not needed in desktop PC applications anyway.
+ Success of an allocation is just checked with an assert.
+- Code free of any compiler warnings - especially those that would require complicating the code
+ just to please the compiler complaining about unused parameters, variables, or expressions being
+ constant in Relese configuration, e.g. because they are only used inside an assert.
+- This is a C++ library.
+ Bindings or ports to any other programming languages are welcomed as external projects and
+ are not going to be included into this repository.
*/
// Define this macro to 0 to disable usage of DXGI 1.4 (needed for IDXGIAdapter3 and query for memory budget).
diff --git a/src/Tests.cpp b/src/Tests.cpp
index 6d19d62..bc7b4a9 100644
--- a/src/Tests.cpp
+++ b/src/Tests.cpp
@@ -131,7 +131,6 @@
const UINT BEGIN_INDEX = 10;
const UINT END_INDEX = 20;
- UINT frameIndex = 0;
for (UINT frameIndex = BEGIN_INDEX; frameIndex < END_INDEX; ++frameIndex)
{
ctx.allocator->SetCurrentFrameIndex(frameIndex);