Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace gpgmm::d3d12 {
};

/** \brief Callback function used to create a ID3D12Pageable.
*/
*/
using CreateHeapFn = HRESULT (*)(void* context, ID3D12Pageable** ppPageableOut);

GPGMM_INTERFACE IResidencyManager;
Expand Down Expand Up @@ -215,7 +215,7 @@ namespace gpgmm::d3d12 {
\endcode

Example Callback Context Class:

\code
class CallbackContext {
public:
Expand Down Expand Up @@ -261,9 +261,10 @@ namespace gpgmm::d3d12 {

\return S_OK if heap was added, else error.
*/
virtual HRESULT Add(IHeap* pHeap) = 0;
virtual HRESULT Add(IHeap * pHeap) = 0;

/** \brief Resets a residency list to its initial state as if a new residenct list was created.
/** \brief Resets a residency list to its initial state as if a new residenct list was
created.

\return Returns S_OK if successful.
*/
Expand Down Expand Up @@ -435,15 +436,15 @@ namespace gpgmm::d3d12 {

@param pHeap A pointer to the heap being locked.
*/
virtual HRESULT LockHeap(IHeap* pHeap) = 0;
virtual HRESULT LockHeap(IHeap * pHeap) = 0;

/** \brief Unlocks the specified heap.

Unlocking a heap allows the residency manager will evict it when over budget.

@param pHeap A pointer to the heap being unlocked.
*/
virtual HRESULT UnlockHeap(IHeap* pHeap) = 0;
virtual HRESULT UnlockHeap(IHeap * pHeap) = 0;

/** \brief Execute command lists using residency managed heaps.

Expand All @@ -456,10 +457,9 @@ namespace gpgmm::d3d12 {
@param ppResidencyLists The array of ResidencyList residency lists to make resident.
@param count The size of commandLists and residencyLists arrays.
*/
virtual HRESULT ExecuteCommandLists(ID3D12CommandQueue* const pQueue,
ID3D12CommandList* const* ppCommandLists,
IResidencyList* const* ppResidencyLists,
uint32_t count) = 0;
virtual HRESULT ExecuteCommandLists(
ID3D12CommandQueue* const pQueue, ID3D12CommandList* const* ppCommandLists,
IResidencyList* const* ppResidencyLists, uint32_t count) = 0;

/** \brief Sets video memory reservation.

Expand All @@ -473,8 +473,7 @@ namespace gpgmm::d3d12 {
return the current reservation.
*/
virtual HRESULT SetVideoMemoryReservation(
const DXGI_MEMORY_SEGMENT_GROUP& memorySegmentGroup,
uint64_t availableForReservation,
const DXGI_MEMORY_SEGMENT_GROUP& memorySegmentGroup, uint64_t availableForReservation,
uint64_t* pCurrentReservationOut = nullptr) = 0;

/** \brief Get the current budget and memory usage.
Expand Down Expand Up @@ -528,7 +527,7 @@ namespace gpgmm::d3d12 {
uint64_t OffsetFromResource;

/** \brief Method used to allocate memory for the resource.
*/
*/
AllocationMethod Method;

/** \brief Debug name associated with the resource allocation.
Expand Down Expand Up @@ -645,7 +644,7 @@ namespace gpgmm::d3d12 {
for large static resources. Otherwise, this is mostly used for debugging and testing
purposes.
*/
ALLOCATOR_FLAG_ALWAYS_COMMITED = 0x1,
ALLOCATOR_FLAG_ALWAYS_COMMITTED = 0x1,

/** \brief Creates resource within budget.

Expand Down Expand Up @@ -759,7 +758,7 @@ namespace gpgmm::d3d12 {
A dedicated allocation allocates exactly what is needed for the resource and nothing more.

Internally, dedicated allocations are "placed resources" which allows the heap to be
recycled by GPGMM. Otherwise, ALLOCATOR_FLAG_ALWAYS_COMMITED is equivelent to a "dedicated
recycled by GPGMM. Otherwise, ALLOCATOR_FLAG_ALWAYS_COMMITTED is equivelent to a "dedicated
allocation" but without heaps being recycled by GPGMM.

Dedicated allocation allocates/deallocates in O(1) time using O(N * pageSize) space.
Expand Down Expand Up @@ -1179,8 +1178,7 @@ namespace gpgmm::d3d12 {
to pFeatureSupportData or if a size mismatch is detected for the featureSupportDataSize
parameter.
*/
virtual HRESULT CheckFeatureSupport(ALLOCATOR_FEATURE feature,
void* pFeatureSupportData,
virtual HRESULT CheckFeatureSupport(ALLOCATOR_FEATURE feature, void* pFeatureSupportData,
uint32_t featureSupportDataSize) const = 0;
};

Expand Down
5 changes: 2 additions & 3 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ namespace gpgmm::d3d12 {
mResidencyManager(pResidencyManager),
mCaps(std::move(caps)),
mResourceHeapTier(descriptor.ResourceHeapTier),
mIsAlwaysCommitted(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_COMMITED),
mIsAlwaysCommitted(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_COMMITTED),
mIsHeapAlwaysCreatedInBudget(descriptor.Flags & ALLOCATOR_FLAG_ALWAYS_IN_BUDGET),
mFlushEventBuffersOnDestruct(descriptor.RecordOptions.EventScope &
EVENT_RECORD_SCOPE_PER_INSTANCE),
Expand Down Expand Up @@ -1489,8 +1489,7 @@ namespace gpgmm::d3d12 {
}

// static
HRESULT ImportResourceCallbackContext::GetHeap(void* pContext,
ID3D12Pageable** ppPageableOut) {
HRESULT ImportResourceCallbackContext::GetHeap(void* pContext, ID3D12Pageable** ppPageableOut) {
return static_cast<ImportResourceCallbackContext*>(pContext)->GetHeap(ppPageableOut);
}

Expand Down
6 changes: 3 additions & 3 deletions src/tests/end2end/D3D12ResourceAllocatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferSubAllocated) {
// No sub-allocation algorithm.
{
ALLOCATOR_DESC newAllocatorDesc = allocatorDesc;
newAllocatorDesc.Flags |= ALLOCATOR_FLAG_ALWAYS_COMMITED;
newAllocatorDesc.Flags |= ALLOCATOR_FLAG_ALWAYS_COMMITTED;

ComPtr<IResourceAllocator> resourceAllocator;
ASSERT_SUCCEEDED(CreateResourceAllocator(newAllocatorDesc, &resourceAllocator, nullptr));
Expand Down Expand Up @@ -869,7 +869,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferInvalid) {

TEST_F(D3D12ResourceAllocatorTests, CreateBufferAlwaysCommitted) {
ALLOCATOR_DESC desc = CreateBasicAllocatorDesc();
desc.Flags = ALLOCATOR_FLAG_ALWAYS_COMMITED;
desc.Flags = ALLOCATOR_FLAG_ALWAYS_COMMITTED;

ComPtr<IResourceAllocator> resourceAllocator;
ASSERT_SUCCEEDED(CreateResourceAllocator(desc, &resourceAllocator, nullptr));
Expand Down Expand Up @@ -1637,7 +1637,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferWithLimitedFragmentation) {

// Repeat standalone buffer creation, but using a committed resource.
{
allocatorDesc.Flags |= ALLOCATOR_FLAG_ALWAYS_COMMITED;
allocatorDesc.Flags |= ALLOCATOR_FLAG_ALWAYS_COMMITTED;

ComPtr<IResourceAllocator> commitedAllocator;
ASSERT_SUCCEEDED(CreateResourceAllocator(allocatorDesc, &commitedAllocator, nullptr));
Expand Down