mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git
synced 2024-11-21 19:50:05 +00:00
Merge branch 'master' into development
# Conflicts: # CMakeLists.txt # src/CMakeLists.txt # src/Doxyfile
This commit is contained in:
commit
6ab5325bd7
@ -6,6 +6,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
find_package(Doxygen)
|
||||
option(BUILD_DOCUMENTATION "Create and install the HTML-based API documentation (requires Doxygen)" OFF)
|
||||
option(BUILD_SHARED_LIBS "Build D3D12 Memory Allocator shared library" OFF)
|
||||
|
||||
if (DOXYGEN_FOUND AND BUILD_DOCUMENTATION)
|
||||
# set input and output files
|
||||
@ -29,4 +30,5 @@ option(D3D12MA_BUILD_SAMPLE "Build D3D12MemoryAllocator sample application" OFF)
|
||||
|
||||
message(STATUS "D3D12MA_BUILD_SAMPLE = ${D3D12MA_BUILD_SAMPLE}")
|
||||
|
||||
include_directories(include)
|
||||
add_subdirectory(src)
|
||||
|
@ -107,3 +107,4 @@ For more information see [NOTICES.txt](NOTICES.txt).
|
||||
# See also
|
||||
|
||||
- **[Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/)** - equivalent library for Vulkan. License: MIT.
|
||||
- **[TerraFX.Interop.D3D12MemoryAllocator](https://github.com/terrafx/terrafx.interop.d3d12memoryallocator)** - interop bindings for this library for C#, as used by [TerraFX](https://github.com/terrafx/terrafx). License: MIT.
|
||||
|
@ -118,12 +118,21 @@ If providing your own implementation, you need to implement a subset of std::ato
|
||||
#define D3D12MA_ATOMIC_UINT64 std::atomic<UINT64>
|
||||
#endif
|
||||
|
||||
#ifdef D3D12MA_EXPORTS
|
||||
#define D3D12MA_API __declspec(dllexport)
|
||||
#elif defined(D3D12MA_IMPORTS)
|
||||
#define D3D12MA_API __declspec(dllimport)
|
||||
#else
|
||||
#define D3D12MA_API
|
||||
#endif
|
||||
|
||||
namespace D3D12MA
|
||||
{
|
||||
class IUnknownImpl : public IUnknown
|
||||
class D3D12MA_API IUnknownImpl : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject);
|
||||
virtual ~IUnknownImpl() = default;
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef();
|
||||
virtual ULONG STDMETHODCALLTYPE Release();
|
||||
protected:
|
||||
@ -252,7 +261,7 @@ To retrieve this information, use methods of this class.
|
||||
The object also remembers `ID3D12Resource` and "owns" a reference to it,
|
||||
so it calls `%Release()` on the resource when destroyed.
|
||||
*/
|
||||
class Allocation : public IUnknownImpl
|
||||
class D3D12MA_API Allocation : public IUnknownImpl
|
||||
{
|
||||
public:
|
||||
/** \brief Returns offset in bytes from the start of memory heap.
|
||||
@ -469,7 +478,7 @@ pools - creating resources in default pool is sufficient.
|
||||
|
||||
To create custom pool, fill D3D12MA::POOL_DESC and call D3D12MA::Allocator::CreatePool.
|
||||
*/
|
||||
class Pool : public IUnknownImpl
|
||||
class D3D12MA_API Pool : public IUnknownImpl
|
||||
{
|
||||
public:
|
||||
/** \brief Returns copy of parameters of the pool.
|
||||
@ -657,7 +666,7 @@ Call method `Release()` to destroy it.
|
||||
It is recommended to create just one object of this type per `ID3D12Device` object,
|
||||
right after Direct3D 12 is initialized and keep it alive until before Direct3D device is destroyed.
|
||||
*/
|
||||
class Allocator : public IUnknownImpl
|
||||
class D3D12MA_API Allocator : public IUnknownImpl
|
||||
{
|
||||
public:
|
||||
/// Returns cached options retrieved from D3D12 device.
|
||||
@ -865,7 +874,7 @@ protected:
|
||||
virtual void ReleaseThis();
|
||||
|
||||
private:
|
||||
friend HRESULT CreateAllocator(const ALLOCATOR_DESC*, Allocator**);
|
||||
friend D3D12MA_API HRESULT CreateAllocator(const ALLOCATOR_DESC*, Allocator**);
|
||||
template<typename T> friend void D3D12MA_DELETE(const ALLOCATION_CALLBACKS&, T*);
|
||||
friend class Pool;
|
||||
|
||||
@ -937,7 +946,7 @@ To create this object, fill in D3D12MA::VIRTUAL_BLOCK_DESC and call CreateVirtua
|
||||
To destroy it, call its method `VirtualBlock::Release()`.
|
||||
You need to free all the allocations within this block or call Clear() before destroying it.
|
||||
*/
|
||||
class VirtualBlock : public IUnknownImpl
|
||||
class D3D12MA_API VirtualBlock : public IUnknownImpl
|
||||
{
|
||||
public:
|
||||
/** \brief Returns true if the block is empty - contains 0 allocations.
|
||||
@ -980,7 +989,7 @@ protected:
|
||||
virtual void ReleaseThis();
|
||||
|
||||
private:
|
||||
friend HRESULT CreateVirtualBlock(const VIRTUAL_BLOCK_DESC*, VirtualBlock**);
|
||||
friend D3D12MA_API HRESULT CreateVirtualBlock(const VIRTUAL_BLOCK_DESC*, VirtualBlock**);
|
||||
template<typename T> friend void D3D12MA_DELETE(const ALLOCATION_CALLBACKS&, T*);
|
||||
|
||||
VirtualBlockPimpl* m_Pimpl;
|
||||
@ -995,13 +1004,13 @@ private:
|
||||
|
||||
You normally only need to call it once and keep a single Allocator object for your `ID3D12Device`.
|
||||
*/
|
||||
HRESULT CreateAllocator(const ALLOCATOR_DESC* pDesc, Allocator** ppAllocator);
|
||||
D3D12MA_API HRESULT CreateAllocator(const ALLOCATOR_DESC* pDesc, Allocator** ppAllocator);
|
||||
|
||||
/** \brief Creates new D3D12MA::VirtualBlock object and returns it through `ppVirtualBlock`.
|
||||
|
||||
Note you don't need to create D3D12MA::Allocator to use virtual blocks.
|
||||
*/
|
||||
HRESULT CreateVirtualBlock(const VIRTUAL_BLOCK_DESC* pDesc, VirtualBlock** ppVirtualBlock);
|
||||
D3D12MA_API HRESULT CreateVirtualBlock(const VIRTUAL_BLOCK_DESC* pDesc, VirtualBlock** ppVirtualBlock);
|
||||
|
||||
} // namespace D3D12MA
|
||||
|
@ -1,5 +1,5 @@
|
||||
set(D3D12MA_LIBRARY_SOURCE_FILES
|
||||
D3D12MemAlloc.h
|
||||
../include/D3D12MemAlloc.h
|
||||
D3D12MemAlloc.cpp
|
||||
)
|
||||
set(CMAKE_DEBUG_POSTFIX d)
|
||||
@ -15,6 +15,8 @@ set_target_properties(
|
||||
# Use C++14
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
|
||||
OUTPUT_NAME "D3D12MA"
|
||||
)
|
||||
|
||||
target_link_libraries(D3D12MemoryAllocator PUBLIC
|
||||
@ -23,6 +25,16 @@ target_link_libraries(D3D12MemoryAllocator PUBLIC
|
||||
dxguid.lib
|
||||
)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(D3D12MemoryAllocator PRIVATE
|
||||
D3D12MA_EXPORTS
|
||||
)
|
||||
|
||||
target_compile_definitions(D3D12MemoryAllocator INTERFACE
|
||||
D3D12MA_IMPORTS
|
||||
)
|
||||
endif()
|
||||
|
||||
install(TARGETS D3D12MemoryAllocator DESTINATION lib)
|
||||
install(FILES D3D12MemAlloc.h DESTINATION include)
|
||||
|
||||
|
@ -5826,7 +5826,7 @@ void AllocatorPimpl::WriteBudgetToJson(JsonWriter& json, const Budget& budget)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Public but internal class IUnknownImpl implementation
|
||||
|
||||
HRESULT STDMETHODCALLTYPE IUnknownImpl::QueryInterface(REFIID riid, _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject)
|
||||
HRESULT STDMETHODCALLTYPE IUnknownImpl::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
if(ppvObject == NULL)
|
||||
return E_POINTER;
|
||||
|
@ -823,7 +823,7 @@ WARN_LOGFILE =
|
||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = "@CMAKE_SOURCE_DIR@/src/D3D12MemAlloc.h"
|
||||
INPUT = "@CMAKE_SOURCE_DIR@/include/D3D12MemAlloc.h"
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
|
@ -712,6 +712,37 @@ static void TestCustomPool_MinAllocationAlignment(const TestContext& ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void TestCustomPool_Committed(const TestContext& ctx)
|
||||
{
|
||||
wprintf(L"Test custom pool committed\n");
|
||||
|
||||
const UINT64 BUFFER_SIZE = 32;
|
||||
|
||||
D3D12MA::POOL_DESC poolDesc = {};
|
||||
poolDesc.HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
poolDesc.HeapFlags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
|
||||
|
||||
ComPtr<D3D12MA::Pool> pool;
|
||||
CHECK_HR( ctx.allocator->CreatePool(&poolDesc, &pool) );
|
||||
|
||||
D3D12MA::ALLOCATION_DESC allocDesc = {};
|
||||
allocDesc.CustomPool = pool.Get();
|
||||
allocDesc.Flags = D3D12MA::ALLOCATION_FLAG_COMMITTED;
|
||||
|
||||
D3D12_RESOURCE_DESC resDesc;
|
||||
FillResourceDescForBuffer(resDesc, BUFFER_SIZE);
|
||||
|
||||
ComPtr<D3D12MA::Allocation> alloc;
|
||||
CHECK_HR( ctx.allocator->CreateResource(&allocDesc, &resDesc,
|
||||
D3D12_RESOURCE_STATE_COMMON,
|
||||
NULL, // pOptimizedClearValue
|
||||
&alloc,
|
||||
IID_NULL, NULL) ); // riidResource, ppvResource
|
||||
CHECK_BOOL(alloc->GetHeap() == NULL);
|
||||
CHECK_BOOL(alloc->GetResource() != NULL);
|
||||
CHECK_BOOL(alloc->GetOffset() == 0);
|
||||
}
|
||||
|
||||
static HRESULT TestCustomHeap(const TestContext& ctx, const D3D12_HEAP_PROPERTIES& heapProps)
|
||||
{
|
||||
D3D12MA::Stats globalStatsBeg = {};
|
||||
@ -1515,6 +1546,7 @@ static void TestDevice4(const TestContext& ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
|
||||
static void TestDevice8(const TestContext& ctx)
|
||||
{
|
||||
wprintf(L"Test ID3D12Device8\n");
|
||||
@ -1549,6 +1581,7 @@ static void TestDevice8(const TestContext& ctx)
|
||||
&allocPtr1, IID_PPV_ARGS(&res1)));
|
||||
CHECK_BOOL(allocPtr1->GetHeap()!= NULL);
|
||||
}
|
||||
#endif // #ifdef __ID3D12Device8_INTERFACE_DEFINED__
|
||||
|
||||
static void TestGroupVirtual(const TestContext& ctx)
|
||||
{
|
||||
@ -1564,6 +1597,7 @@ static void TestGroupBasics(const TestContext& ctx)
|
||||
TestOtherComInterface(ctx);
|
||||
TestCustomPools(ctx);
|
||||
TestCustomPool_MinAllocationAlignment(ctx);
|
||||
TestCustomPool_Committed(ctx);
|
||||
TestCustomHeaps(ctx);
|
||||
TestStandardCustomCommittedPlaced(ctx);
|
||||
TestAliasingMemory(ctx);
|
||||
@ -1573,7 +1607,9 @@ static void TestGroupBasics(const TestContext& ctx)
|
||||
TestZeroInitialized(ctx);
|
||||
TestMultithreading(ctx);
|
||||
TestDevice4(ctx);
|
||||
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
|
||||
TestDevice8(ctx);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Test(const TestContext& ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user