From 7b21ca6b1d0efe28dab8667d1f24596221486e6e Mon Sep 17 00:00:00 2001 From: Patedam Date: Wed, 29 Jul 2026 14:44:16 -0400 Subject: [PATCH] Adapting arena push to support format as debug tag Changed some d3d12 to work better with arenas --- .agent/workflows/build.md | 16 +++----- Juliet/include/Core/Common/String.h | 35 ++++++++++------- Juliet/include/Core/Container/Vector.h | 21 +++++----- Juliet/include/Core/Memory/MemoryArena.h | 39 ++++++++++++++----- Juliet/include/Core/Memory/MemoryArenaDebug.h | 29 +++++++------- Juliet/include/Core/Memory/Utils.h | 11 ------ Juliet/src/Core/Common/String.cpp | 2 +- Juliet/src/Core/HotReload/HotReload.cpp | 4 +- Juliet/src/Core/ImGui/ImGuiService.cpp | 2 +- Juliet/src/Core/Memory/MemoryArena.cpp | 5 ++- Juliet/src/Core/Memory/MemoryArenaDebug.cpp | 19 ++++++++- Juliet/src/Graphics/D3D12/D3D12Common.cpp | 16 ++++---- Juliet/src/Graphics/D3D12/D3D12Common.h | 1 - .../Graphics/D3D12/D3D12DescriptorHeap.cpp | 15 ++++--- .../src/Graphics/D3D12/D3D12DescriptorHeap.h | 5 +-- .../Graphics/D3D12/D3D12GraphicsDevice.cpp | 5 +-- Juliet/src/Graphics/D3D12/D3D12Utils.cpp | 15 +++++++ Juliet/src/Graphics/D3D12/D3D12Utils.h | 4 ++ 18 files changed, 141 insertions(+), 103 deletions(-) diff --git a/.agent/workflows/build.md b/.agent/workflows/build.md index d8f30f1..63fda5f 100644 --- a/.agent/workflows/build.md +++ b/.agent/workflows/build.md @@ -1,21 +1,15 @@ --- -description: Build the Juliet project using FastBuild +description: Build the Juliet projects --- // turbo-all - -This workflow builds the Juliet project and writes output to `misc\agent_output.log`. - +This workflow builds the Juliet project. 1. To build the default (clang-Debug): // turbo -`misc\agent_build.bat clang 2>&1 | tee misc\agent_output.log` - +`misc\build.bat clang` 2. To build a specific configuration (e.g., clang-Debug, msvc-Debug): // turbo -`misc\agent_build.bat clang-Debug 2>&1 | tee misc\agent_output.log` - +`misc\build.bat clang-Debug` 3. To see all available targets: // turbo -`misc\agent_build.bat -showtargets 2>&1 | tee misc\agent_output.log` - -4. Check build results by reading `misc\agent_output.log`. \ No newline at end of file +`misc\build.bat -showtargets` \ No newline at end of file diff --git a/Juliet/include/Core/Common/String.h b/Juliet/include/Core/Common/String.h index b84d519..21b1e6d 100644 --- a/Juliet/include/Core/Common/String.h +++ b/Juliet/include/Core/Common/String.h @@ -1,10 +1,22 @@ #pragma once -#include #include #include #include +#ifdef global +#undef global +#define RESTORE_GLOBAL +#endif + +#include +#include + +#ifdef RESTORE_GLOBAL +#define global static +#undef RESTORE_GLOBAL +#endif + namespace Juliet { struct Arena; @@ -42,20 +54,6 @@ namespace Juliet size_t Capacity; }; - struct StringListNode - { - StringListNode* Next; - String Content; - }; - - struct StringList - { - StringListNode* First; - StringListNode* Last; - size_t NodeCount; - size_t Size; - }; - constexpr uint32 kInvalidUTF8 = 0xFFFD; inline size_t StringLength(String str) @@ -156,6 +154,13 @@ namespace Juliet extern JULIET_API bool ConvertString(String from, String to, String src, StringBuffer& dst, bool nullTerminate); JULIET_API String StringCopy(NonNullPtr arena, String str); + + template + String Format(NonNullPtr arena, const char* formatStr, Args&&... args) + { + std::string result = std::vformat(formatStr, std::make_format_args(args...)); + return StringCopy(arena, WrapString(result.c_str())); + } } // namespace Juliet #ifdef UNIT_TEST diff --git a/Juliet/include/Core/Container/Vector.h b/Juliet/include/Core/Container/Vector.h index e93221b..094aae4 100644 --- a/Juliet/include/Core/Container/Vector.h +++ b/Juliet/include/Core/Container/Vector.h @@ -18,16 +18,12 @@ namespace Juliet Count = 0; Capacity = 0; Arena = arena; - ArenaPosAtCreation = ArenaPos(Arena); Reserve(ReserveSize); } void Destroy() { - Assert(ArenaPos(Arena) == ArenaPosAtCreation + sizeof(Type) * Capacity); - ArenaPopTo(Arena, ArenaPosAtCreation); - DataFirst = DataLast = Data = nullptr; Count = 0; Capacity = 0; @@ -37,6 +33,8 @@ namespace Juliet void Reserve(size_t newCapacity) { Assert(Arena); + Assert(newCapacity <= ReserveSize && "VectorArena capacity should be <= ReserveSize."); + if (Data == nullptr) { Data = ArenaPushArray(Arena, newCapacity JULIET_DEBUG_PARAM(Name)); @@ -44,7 +42,7 @@ namespace Juliet } else { - Assert(newCapacity <= Capacity && "VectorArena capacity exceeded! Reallocation is disabled."); + Unimplemented(); } } @@ -201,13 +199,12 @@ namespace Juliet [[nodiscard]] size_t Size() const { return Count; } - Arena* Arena = nullptr; - Type* DataFirst = nullptr; - Type* DataLast = nullptr; - Type* Data = nullptr; - size_t Count = 0; - size_t Capacity = 0; - index_t ArenaPosAtCreation = 0; + Arena* Arena = nullptr; + Type* DataFirst = nullptr; + Type* DataLast = nullptr; + Type* Data = nullptr; + size_t Count = 0; + size_t Capacity = 0; JULIET_DEBUG_ONLY(const char* Name = "VectorArena";) }; static_assert(std::is_standard_layout_v>, diff --git a/Juliet/include/Core/Memory/MemoryArena.h b/Juliet/include/Core/Memory/MemoryArena.h index ed67307..e67a9d6 100644 --- a/Juliet/include/Core/Memory/MemoryArena.h +++ b/Juliet/include/Core/Memory/MemoryArena.h @@ -6,6 +6,10 @@ #include #include +#if JULIET_DEBUG +#include +#endif + namespace Juliet { constexpr global uint64 g_Arena_Default_Reserve_Size = Megabytes(64); @@ -14,6 +18,7 @@ namespace Juliet #if JULIET_DEBUG struct ArenaDebugInfo; + JULIET_API String FormatDebugTagV(const char* formatStr, std::format_args args); #endif struct Arena @@ -58,30 +63,44 @@ namespace Juliet JULIET_DEBUG_ONLY(bool CanReserveMore : 1 = true;) }; - [[nodiscard]] JULIET_API Arena* ArenaAllocate(const ArenaParams& params JULIET_DEBUG_ONLY(, const char* name), + [[nodiscard]] JULIET_API Arena* ArenaAllocate(const ArenaParams& params JULIET_DEBUG_PARAM(const char* name), const std::source_location& loc = std::source_location::current()); JULIET_API void ArenaRelease(NonNullPtr arena); // Raw Push, can be used but templated helpers exists below [[nodiscard]] JULIET_API void* ArenaPush(NonNullPtr arena, size_t size, size_t align, - bool shouldBeZeroed JULIET_DEBUG_ONLY(, const char* tag)); + bool shouldBeZeroed JULIET_DEBUG_PARAM(const char* tag)); JULIET_API void ArenaPopTo(NonNullPtr arena, size_t position); JULIET_API void ArenaPop(NonNullPtr arena, size_t amount); JULIET_API void ArenaClear(NonNullPtr arena); [[nodiscard]] JULIET_API size_t ArenaPos(NonNullPtr arena); - template - [[nodiscard]] Type* ArenaPushStruct(NonNullPtr arena JULIET_DEBUG_PARAM(const char* tag = nullptr)) + template + [[nodiscard]] Type* ArenaPushStruct(NonNullPtr arena JULIET_DEBUG_PARAM(DebugArgs&&... debugArgs)) { - return static_cast( - ArenaPush(arena, sizeof(Type) * 1, AlignOf(Type), true JULIET_DEBUG_PARAM(tag ? tag : GetTypeName()))); + return static_cast(ArenaPush(arena, sizeof(Type) * 1, AlignOf(Type), true JULIET_DEBUG_PARAM( + [&]() -> const char* { + if constexpr (sizeof...(DebugArgs) > 0) + { + return Format(GetDebugInfoArena(), std::forward(debugArgs)...).Data; + } + return GetTypeName(); + }() + ))); } - template - [[nodiscard]] Type* ArenaPushArray(NonNullPtr arena, size_t count JULIET_DEBUG_PARAM(const char* tag = nullptr)) + template + [[nodiscard]] Type* ArenaPushArray(NonNullPtr arena, size_t count JULIET_DEBUG_PARAM(DebugArgs&&... debugArgs)) { - return static_cast(ArenaPush(arena, sizeof(Type) * count, Max(8ull, AlignOf(Type)), - true JULIET_DEBUG_PARAM(tag ? tag : GetTypeName()))); + return static_cast(ArenaPush(arena, sizeof(Type) * count, Max(8ull, AlignOf(Type)), true JULIET_DEBUG_PARAM( + [&]() -> const char* { + if constexpr (sizeof...(DebugArgs) > 0) + { + return Format(GetDebugInfoArena(), std::forward(debugArgs)...).Data; + } + return GetTypeName(); + }() + ))); } TempArena ArenaTempBegin(NonNullPtr arena); diff --git a/Juliet/include/Core/Memory/MemoryArenaDebug.h b/Juliet/include/Core/Memory/MemoryArenaDebug.h index c61e72c..c31d65c 100644 --- a/Juliet/include/Core/Memory/MemoryArenaDebug.h +++ b/Juliet/include/Core/Memory/MemoryArenaDebug.h @@ -1,9 +1,9 @@ #pragma once -#include #include -#include #include +#include +#include #if JULIET_DEBUG @@ -30,20 +30,23 @@ namespace Juliet ArenaAllocation* Next; }; + // Arena (Struct) - void DebugRegisterArena(NonNullPtr arena); - void DebugUnregisterArena(NonNullPtr arena); - void DebugArenaSetDebugName(NonNullPtr arena, const char* name); - bool IsDebugInfoArena(const Arena* arena); // To prevent recursion - void DebugArenaFreeBlock(Arena* block); // To clear all debug infos in a block - void DebugArenaRemoveAllocation(Arena* block, size_t oldOffset); - void DebugArenaPopTo(Arena* block, size_t newPosition); - void DebugArenaAddDebugInfo(Arena* block, size_t size, size_t offset, const char* tag); + void DebugRegisterArena(NonNullPtr arena); + void DebugUnregisterArena(NonNullPtr arena); + void DebugArenaSetDebugName(NonNullPtr arena, const char* name); + bool IsDebugInfoArena(const Arena* arena); // To prevent recursion + void DebugArenaFreeBlock(Arena* block); // To clear all debug infos in a block + void DebugArenaRemoveAllocation(Arena* block, size_t oldOffset); + void DebugArenaPopTo(Arena* block, size_t newPosition); + void DebugArenaAddDebugInfo(Arena* block, size_t size, size_t offset, const char* tag); // MemoryArena (Pool-based) - void DebugFreeArenaAllocations(MemoryBlock* blk); - void DebugArenaAddAllocation(MemoryBlock* blk, size_t size, size_t offset, String tag); - void DebugArenaRemoveLastAllocation(MemoryBlock* blk); + void DebugFreeArenaAllocations(MemoryBlock* blk); + void DebugArenaAddAllocation(MemoryBlock* blk, size_t size, size_t offset, String tag); + void DebugArenaRemoveLastAllocation(MemoryBlock* blk); + + JULIET_API Arena* GetDebugInfoArena(); } // namespace Juliet diff --git a/Juliet/include/Core/Memory/Utils.h b/Juliet/include/Core/Memory/Utils.h index d3f26c2..1711f24 100644 --- a/Juliet/include/Core/Memory/Utils.h +++ b/Juliet/include/Core/Memory/Utils.h @@ -37,12 +37,6 @@ namespace Juliet stackTop = stackTop->Next; } - template - struct SingleLinkedListNode - { - SingleLinkedListType* Next; - }; - // Double linked list template void Enqueue(QueueType& queue, QueueTypeNode* node) @@ -76,11 +70,6 @@ namespace Juliet size_t Size; \ }; -#define SLLQueuePush(f, l, n) SLLQueuePush_NZ(0, f, l, n, next) - -#define SLLQueuePush_NZ(nil, f, l, n, next) \ - (CheckNil(nil, f) ? ((f) = (l) = (n), SetNil(nil, (n)->next)) : ((l)->next = (n), (l) = (n), SetNil(nil, (n)->next))) - // TODO: homemade versions #define MemSet memset #define MemCopy memcpy diff --git a/Juliet/src/Core/Common/String.cpp b/Juliet/src/Core/Common/String.cpp index e20391d..7b22baa 100644 --- a/Juliet/src/Core/Common/String.cpp +++ b/Juliet/src/Core/Common/String.cpp @@ -493,7 +493,7 @@ namespace Juliet { String result; result.Size = str.Size; - result.Data = static_cast(ArenaPush(arena, str.Size + 1, alignof(char), true JULIET_DEBUG_ONLY(, "String"))); + result.Data = static_cast(ArenaPush(arena, str.Size + 1, alignof(char), true JULIET_DEBUG_PARAM("String"))); MemCopy(result.Data, str.Data, str.Size); result.Data[result.Size] = 0; return result; diff --git a/Juliet/src/Core/HotReload/HotReload.cpp b/Juliet/src/Core/HotReload/HotReload.cpp index 0ed5ef0..e0c409c 100644 --- a/Juliet/src/Core/HotReload/HotReload.cpp +++ b/Juliet/src/Core/HotReload/HotReload.cpp @@ -26,7 +26,7 @@ namespace Juliet basePathLength + StringLength(dllName) + 1; // Need +1 because snprintf needs 0 terminated strings code.DLLFullPath.Data = - static_cast(ArenaPush(code.Arena, dllFullPathLength, alignof(char), true JULIET_DEBUG_ONLY(, "DLL Path"))); + static_cast(ArenaPush(code.Arena, dllFullPathLength, alignof(char), true JULIET_DEBUG_PARAM("DLL Path"))); int writtenSize = snprintf(CStr(code.DLLFullPath), dllFullPathLength, "%s%s", CStr(basePath), CStr(dllName)); if (writtenSize < static_cast(dllFullPathLength) - 1) { @@ -40,7 +40,7 @@ namespace Juliet const size_t lockPathLength = basePathLength + StringLength(lockFilename) + 1; // Need +1 because snprintf needs 0 terminated strings code.LockFullPath.Data = - static_cast(ArenaPush(code.Arena, lockPathLength, alignof(char), true JULIET_DEBUG_ONLY(, "Lock File Path"))); + static_cast(ArenaPush(code.Arena, lockPathLength, alignof(char), true JULIET_DEBUG_PARAM("Lock File Path"))); writtenSize = snprintf(CStr(code.LockFullPath), lockPathLength, "%s%s", CStr(basePath), CStr(lockFilename)); if (writtenSize < static_cast(lockPathLength) - 1) { diff --git a/Juliet/src/Core/ImGui/ImGuiService.cpp b/Juliet/src/Core/ImGui/ImGuiService.cpp index 91ff177..bfd50e0 100644 --- a/Juliet/src/Core/ImGui/ImGuiService.cpp +++ b/Juliet/src/Core/ImGui/ImGuiService.cpp @@ -28,7 +28,7 @@ namespace Juliet::ImGuiService void* ImGuiAllocWrapper(size_t size, void* /*user_data*/) { - return ArenaPush(g_ImGuiArena, size, 8, false JULIET_DEBUG_ONLY(, "ImGuiAlloc")); + return ArenaPush(g_ImGuiArena, size, 8, false JULIET_DEBUG_PARAM("ImGuiAlloc")); } void ImGuiFreeWrapper(void* /*ptr*/, void* /*user_data*/) diff --git a/Juliet/src/Core/Memory/MemoryArena.cpp b/Juliet/src/Core/Memory/MemoryArena.cpp index 56ad9e4..aae91fb 100644 --- a/Juliet/src/Core/Memory/MemoryArena.cpp +++ b/Juliet/src/Core/Memory/MemoryArena.cpp @@ -153,6 +153,9 @@ namespace Juliet { result = reinterpret_cast(current) + positionPrePush; current->Position = positionPostPush; + + JULIET_DEBUG_ONLY(if (!IsDebugInfoArena(arena)) { DebugArenaAddDebugInfo(current, size, positionPrePush, tag); }) + if (sizeToZero != 0) { MemoryZero(result, sizeToZero); @@ -165,8 +168,6 @@ namespace Juliet Assert(false, "Fatal Allocation Failure - Unexpected allocation failure"); } - JULIET_DEBUG_ONLY(if (!IsDebugInfoArena(arena)) { DebugArenaAddDebugInfo(current, size, positionPrePush, tag); }) - return result; } diff --git a/Juliet/src/Core/Memory/MemoryArenaDebug.cpp b/Juliet/src/Core/Memory/MemoryArenaDebug.cpp index d50957b..0e00b8f 100644 --- a/Juliet/src/Core/Memory/MemoryArenaDebug.cpp +++ b/Juliet/src/Core/Memory/MemoryArenaDebug.cpp @@ -31,6 +31,15 @@ namespace Juliet return ArenaPushStruct(g_DebugInfoArena JULIET_DEBUG_PARAM("ArenaDebugInfo")); } + Arena* GetDebugInfoArena() + { + if (!g_DebugInfoArena) + { + g_DebugInfoArena = ArenaAllocate( + { .ReserveSize = Megabytes(16), .CommitSize = Kilobytes(64) } JULIET_DEBUG_ONLY(, "Debug Info Arena")); + } + return g_DebugInfoArena; + } static void FreeDebugInfo(ArenaDebugInfo* info) { if (info) @@ -138,7 +147,15 @@ namespace Juliet ArenaDebugInfo* info = AllocDebugInfo(); if (info) { - info->Tag = tag ? tag : "Untagged"; + if (tag) + { + String copiedTag = StringCopy(g_DebugInfoArena, WrapString(tag)); + info->Tag = copiedTag.Data; + } + else + { + info->Tag = "Untagged"; + } info->Size = size; info->Offset = offset; info->Next = block->FirstDebugInfo; diff --git a/Juliet/src/Graphics/D3D12/D3D12Common.cpp b/Juliet/src/Graphics/D3D12/D3D12Common.cpp index 26cab12..01e5806 100644 --- a/Juliet/src/Graphics/D3D12/D3D12Common.cpp +++ b/Juliet/src/Graphics/D3D12/D3D12Common.cpp @@ -6,6 +6,9 @@ #include // TODO: Convert the whole file to memory arenas +// Use the driver arena +// Use a linked list to support "free" descriptors +// Extend -> Push a new descriptor thats it... namespace Juliet::D3D12::Internal { namespace @@ -25,8 +28,8 @@ namespace Juliet::D3D12::Internal bool ExtendStagingDescriptorPool(NonNullPtr driver, D3D12StagingDescriptorPool& pool) { - D3D12DescriptorHeap* heap = Internal::CreateDescriptorHeap(driver, pool.Arena, pool.Heaps[0]->HeapType, - kStagingHeapDescriptorExpectedCount, true); + D3D12DescriptorHeap* heap = + Internal::CreateDescriptorHeap(driver, pool.Heaps[0]->HeapType, kStagingHeapDescriptorExpectedCount, true); if (!heap) { return false; @@ -49,17 +52,13 @@ namespace Juliet::D3D12::Internal D3D12StagingDescriptorPool* CreateStagingDescriptorPool(NonNullPtr driver, D3D12_DESCRIPTOR_HEAP_TYPE type) { - Arena* arena = ArenaAllocate({} JULIET_DEBUG_ONLY(, "Staging Descriptors")); - - D3D12DescriptorHeap* heap = CreateDescriptorHeap(driver, arena, type, kStagingHeapDescriptorExpectedCount, true); + D3D12DescriptorHeap* heap = CreateDescriptorHeap(driver, type, kStagingHeapDescriptorExpectedCount, true); if (!heap) { - ArenaRelease(arena); return nullptr; } - auto pool = static_cast(Calloc(1, sizeof(D3D12StagingDescriptorPool))); - pool->Arena = arena; + auto pool = static_cast(Calloc(1, sizeof(D3D12StagingDescriptorPool))); // First create the heaps pool->HeapCount = 1; @@ -118,7 +117,6 @@ namespace Juliet::D3D12::Internal Free(pool->Heaps); Free(pool->FreeDescriptors); - ArenaRelease(pool->Arena); Free(pool.Get()); } } // namespace Juliet::D3D12::Internal diff --git a/Juliet/src/Graphics/D3D12/D3D12Common.h b/Juliet/src/Graphics/D3D12/D3D12Common.h index afccec4..37f90d4 100644 --- a/Juliet/src/Graphics/D3D12/D3D12Common.h +++ b/Juliet/src/Graphics/D3D12/D3D12Common.h @@ -22,7 +22,6 @@ namespace Juliet::D3D12 struct D3D12StagingDescriptorPool { - Arena* Arena; Internal::D3D12DescriptorHeap** Heaps; uint32 HeapCount; diff --git a/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.cpp b/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.cpp index e1462d5..22ed1da 100644 --- a/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.cpp +++ b/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -12,13 +13,12 @@ namespace Juliet::D3D12::Internal { // Heap pool is just single linked list of free elements constexpr size_t kInitialCapacity = 4; - heapPool.Arena = ArenaAllocate({} JULIET_DEBUG_ONLY(, "Descriptor Heap Pool")); heapPool.FirstFreeDescriptorHeap = nullptr; // Pre allocate 4 for (uint32 i = 0; i < kInitialCapacity; ++i) { - D3D12DescriptorHeap* descriptorHeap = CreateDescriptorHeap(driver, heapPool.Arena, type, count, false); + D3D12DescriptorHeap* descriptorHeap = CreateDescriptorHeap(driver, type, count, false); descriptorHeap->Next = heapPool.FirstFreeDescriptorHeap; heapPool.FirstFreeDescriptorHeap = descriptorHeap; } @@ -33,18 +33,17 @@ namespace Juliet::D3D12::Internal DestroyDescriptorHeap(current); current = next; } - ArenaRelease(heapPool.Arena); } - D3D12DescriptorHeap* CreateDescriptorHeap(NonNullPtr driver, NonNullPtr arena, - D3D12_DESCRIPTOR_HEAP_TYPE type, uint32 count, bool isStaging) + D3D12DescriptorHeap* CreateDescriptorHeap(NonNullPtr driver, D3D12_DESCRIPTOR_HEAP_TYPE type, uint32 count, bool isStaging) { - D3D12DescriptorHeap* heap = ArenaPushStruct(arena.Get()); + D3D12DescriptorHeap* heap = ArenaPushStruct( + driver->DriverArena JULIET_DEBUG_PARAM("Descriptor Heap Type {}", CStr(GetDescriptorTypeNane(type)))); Assert(heap); heap->CurrentDescriptorIndex = 0; - heap->FreeIndices.Create(arena JULIET_DEBUG_PARAM("DescriptorHeap Free Indices")); + heap->FreeIndices.Create(driver->DriverArena JULIET_DEBUG_PARAM("DescriptorHeap Free Indices")); heap->FreeIndices.Resize(16); heap->CurrentFreeIndex = 0; @@ -148,7 +147,7 @@ namespace Juliet::D3D12::Internal } else { - result = CreateDescriptorHeap(d3d12Driver, pool.Arena, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, + result = CreateDescriptorHeap(d3d12Driver, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, GPUDriver::kSampler_HeapDescriptorCount, false); } diff --git a/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.h b/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.h index 4804c0b..d94443f 100644 --- a/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.h +++ b/Juliet/src/Graphics/D3D12/D3D12DescriptorHeap.h @@ -40,7 +40,6 @@ namespace Juliet::D3D12::Internal struct D3D12DescriptorHeapPool { - Arena* Arena; D3D12DescriptorHeap* FirstFreeDescriptorHeap; }; @@ -51,8 +50,8 @@ namespace Juliet::D3D12::Internal D3D12_DESCRIPTOR_HEAP_TYPE type, uint32 count); extern void DestroyDescriptorHeapPool(D3D12DescriptorHeapPool& pool); - extern D3D12DescriptorHeap* CreateDescriptorHeap(NonNullPtr driver, NonNullPtr arena, - D3D12_DESCRIPTOR_HEAP_TYPE type, uint32 count, bool isStaging); + extern D3D12DescriptorHeap* CreateDescriptorHeap(NonNullPtr driver, D3D12_DESCRIPTOR_HEAP_TYPE type, + uint32 count, bool isStaging); extern void DestroyDescriptorHeap(NonNullPtr heap); extern D3D12DescriptorHeap* AcquireSamplerHeapFromPool(NonNullPtr d3d12Driver); diff --git a/Juliet/src/Graphics/D3D12/D3D12GraphicsDevice.cpp b/Juliet/src/Graphics/D3D12/D3D12GraphicsDevice.cpp index 069cc3b..8e0da7f 100644 --- a/Juliet/src/Graphics/D3D12/D3D12GraphicsDevice.cpp +++ b/Juliet/src/Graphics/D3D12/D3D12GraphicsDevice.cpp @@ -1058,9 +1058,8 @@ namespace Juliet::D3D12 driver->GraphicsDevice = device; // Create Global Bindless Heap that stays alive for the driver whole lifetime - driver->BindlessDescriptorHeap = - Internal::CreateDescriptorHeap(driver, driver->DriverArena, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, - GPUDriver::kCBV_SRV_UAV_HeapDescriptorCount, false); + driver->BindlessDescriptorHeap = Internal::CreateDescriptorHeap(driver, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, + GPUDriver::kCBV_SRV_UAV_HeapDescriptorCount, false); return device; } diff --git a/Juliet/src/Graphics/D3D12/D3D12Utils.cpp b/Juliet/src/Graphics/D3D12/D3D12Utils.cpp index 2e39798..c9f2cf5 100644 --- a/Juliet/src/Graphics/D3D12/D3D12Utils.cpp +++ b/Juliet/src/Graphics/D3D12/D3D12Utils.cpp @@ -53,4 +53,19 @@ namespace Juliet::D3D12 Log(LogLevel::Error, LogCategory::Graphics, "%s! Error: %s" HRESULT_FMT, errorMessage, wszMsgBuff, result); } + +#if JULIET_DEBUG + String GetDescriptorTypeNane(D3D12_DESCRIPTOR_HEAP_TYPE type) + { + switch (type) + { + case D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV: return WrapString("D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV"); + case D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER: return WrapString("D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER"); + case D3D12_DESCRIPTOR_HEAP_TYPE_RTV: return WrapString("D3D12_DESCRIPTOR_HEAP_TYPE_RTV"); + case D3D12_DESCRIPTOR_HEAP_TYPE_DSV: return WrapString("D3D12_DESCRIPTOR_HEAP_TYPE_DSV"); + case D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES: return WrapString("Invalid"); + } + return WrapString("Invalid"); + } +#endif } // namespace Juliet::D3D12 diff --git a/Juliet/src/Graphics/D3D12/D3D12Utils.h b/Juliet/src/Graphics/D3D12/D3D12Utils.h index 6241859..ec33703 100644 --- a/Juliet/src/Graphics/D3D12/D3D12Utils.h +++ b/Juliet/src/Graphics/D3D12/D3D12Utils.h @@ -15,4 +15,8 @@ namespace Juliet::D3D12 struct D3D12Driver; extern void LogError(NonNullPtr D3D12Device, const char* errorMessage, HRESULT result); + +#if JULIET_DEBUG + String GetDescriptorTypeNane(D3D12_DESCRIPTOR_HEAP_TYPE type); +#endif } // namespace Juliet::D3D12