From 25e3e2fe3a3f7b0dd7adf1f3438653e3f1619a8b Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Thu, 8 Sep 2022 09:58:12 -0700 Subject: [PATCH] Rename allocator feature enums. * FEATURE_DATA_RESOURCE_SUBALLOCATION_SUPPORT => FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT * FEATURE_RESOURCE_SUBALLOCATION_SUPPORT => ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT * IsResourceAccessAlwaysCoherent =>IsResourceAllocationWithinCoherent * FEATURE => ALLOCATOR_FEATURE --- src/gpgmm/d3d12/CapsD3D12.cpp | 6 ++--- src/gpgmm/d3d12/CapsD3D12.h | 4 ++-- src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 9 ++++---- src/gpgmm/d3d12/ResourceAllocatorD3D12.h | 22 +++++++++---------- src/include/min/gpgmm_d3d12.cpp | 2 +- src/include/min/gpgmm_d3d12.h | 6 ++--- .../end2end/D3D12ResourceAllocatorTests.cpp | 14 ++++++------ 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/gpgmm/d3d12/CapsD3D12.cpp b/src/gpgmm/d3d12/CapsD3D12.cpp index 3ec24d756..a8fd2ddd3 100644 --- a/src/gpgmm/d3d12/CapsD3D12.cpp +++ b/src/gpgmm/d3d12/CapsD3D12.cpp @@ -98,7 +98,7 @@ namespace gpgmm::d3d12 { // D3D12 has no feature to detect support and must be set manually. if (adapterDesc.VendorId == kIntel_VkVendor) { - caps->mIsResourceAccessAlwaysCoherent = true; + caps->mIsResourceAllocationWithinCoherent = true; } // Dump log for debugging purposes. @@ -138,8 +138,8 @@ namespace gpgmm::d3d12 { return mIsCreateHeapNotResidentSupported; } - bool Caps::IsResourceAccessAlwaysCoherent() const { - return mIsResourceAccessAlwaysCoherent; + bool Caps::IsResourceAllocationWithinCoherent() const { + return mIsResourceAllocationWithinCoherent; } bool Caps::IsAdapterUMA() const { diff --git a/src/gpgmm/d3d12/CapsD3D12.h b/src/gpgmm/d3d12/CapsD3D12.h index 0f3dd5d12..269e3dc90 100644 --- a/src/gpgmm/d3d12/CapsD3D12.h +++ b/src/gpgmm/d3d12/CapsD3D12.h @@ -36,7 +36,7 @@ namespace gpgmm::d3d12 { bool IsCreateHeapNotResidentSupported() const; // Allows a resource to be shared between multiple command queues. - bool IsResourceAccessAlwaysCoherent() const; + bool IsResourceAllocationWithinCoherent() const; // Specifies if the adapter uses a Unified Memory Architecture (UMA). bool IsAdapterUMA() const; @@ -54,7 +54,7 @@ namespace gpgmm::d3d12 { uint64_t mMaxResourceHeapSize = 0; D3D12_RESOURCE_HEAP_TIER mMaxResourceHeapTier; bool mIsCreateHeapNotResidentSupported = false; - bool mIsResourceAccessAlwaysCoherent = false; + bool mIsResourceAllocationWithinCoherent = false; bool mIsAdapterUMA = false; bool mIsAdapterCacheCoherentUMA = false; }; diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index cdb977084..c4769ad58 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -1352,16 +1352,17 @@ namespace gpgmm::d3d12 { return mResidencyManager != nullptr; } - HRESULT ResourceAllocator::CheckFeatureSupport(FEATURE feature, + HRESULT ResourceAllocator::CheckFeatureSupport(ALLOCATOR_FEATURE feature, void* pFeatureSupportData, uint32_t featureSupportDataSize) const { switch (feature) { - case FEATURE_RESOURCE_SUBALLOCATION_SUPPORT: { - FEATURE_DATA_RESOURCE_SUBALLOCATION_SUPPORT data = {}; + case ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT: { + FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT data = {}; if (featureSupportDataSize != sizeof(data)) { return E_INVALIDARG; } - data.IsResourceAccessAlwaysCoherent = mCaps->IsResourceAccessAlwaysCoherent(); + data.IsResourceAllocationWithinCoherent = + mCaps->IsResourceAllocationWithinCoherent(); memcpy(pFeatureSupportData, &data, featureSupportDataSize); return S_OK; } diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index 014755a7e..1fd7c9a40 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -364,33 +364,33 @@ namespace gpgmm::d3d12 { std::string DebugName; }; - /** \struct FEATURE_DATA_RESOURCE_SUBALLOCATION_SUPPORT + /** \struct FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT Details the resource allocator limitations, including if sharing resources between command queues is coherent. */ - struct FEATURE_DATA_RESOURCE_SUBALLOCATION_SUPPORT { - /** \brief Describes multi-queue resource access behavior. + struct FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT { + /** \brief Describes resource within coherency behavior between command-queues. For example, if two allocations belong to the same resource where each allocation is referenced with a different command-queue, will accessing one stomp over the other. D3D12 does not guarentee such behavior is safe but is it well-defined behavior based on the GPU vendor. */ - bool IsResourceAccessAlwaysCoherent; + bool IsResourceAllocationWithinCoherent; }; - /** \enum FEATURE + /** \enum ALLOCATOR_FEATURE Defines constants that specify a resource allocator feature to query about. When you want to query for the level to which an allocator supports a feature, pass one of these values to ResourceAllocator::CheckFeatureSupport. */ - enum FEATURE { - /** \brief Indicates a query for the level of support for sub-allocated resources. The - corresponding data structure for this value is FEATURE_DATA_RESOURCE_SUBALLOCATION_SUPPORT + enum ALLOCATOR_FEATURE { + /** \brief Indicates a query for the level of support for allocated resources. The + corresponding data structure for this value is FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT */ - FEATURE_RESOURCE_SUBALLOCATION_SUPPORT, + ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT, }; using RESOURCE_ALLOCATOR_INFO = MemoryAllocatorInfo; @@ -524,7 +524,7 @@ namespace gpgmm::d3d12 { /** \brief Gets information about the features that are supported by the resource allocator. - @param feature A constant from the FEATURE enumeration describing the feature(s) + @param feature A constant from the ALLOCATOR_FEATURE enumeration describing the feature(s) that you want to query for support. @param pFeatureSupportData A pointer to the data structure that corresponds to the value of the feature parameter. To determine the corresponding data structure for each constant, see @@ -536,7 +536,7 @@ namespace gpgmm::d3d12 { to pFeatureSupportData or if a size mismatch is detected for the featureSupportDataSize parameter. */ - HRESULT CheckFeatureSupport(FEATURE feature, + HRESULT CheckFeatureSupport(ALLOCATOR_FEATURE feature, void* pFeatureSupportData, uint32_t featureSupportDataSize) const; diff --git a/src/include/min/gpgmm_d3d12.cpp b/src/include/min/gpgmm_d3d12.cpp index ff0c41ba1..9b0c08554 100644 --- a/src/include/min/gpgmm_d3d12.cpp +++ b/src/include/min/gpgmm_d3d12.cpp @@ -329,7 +329,7 @@ namespace gpgmm::d3d12 { return mInfo; } - HRESULT ResourceAllocator::CheckFeatureSupport(FEATURE feature, + HRESULT ResourceAllocator::CheckFeatureSupport(ALLOCATOR_FEATURE feature, void* pFeatureSupportData, uint32_t featureSupportDataSize) const { return E_INVALIDARG; // Unsupported diff --git a/src/include/min/gpgmm_d3d12.h b/src/include/min/gpgmm_d3d12.h index 6a5757545..f7d9ace1b 100644 --- a/src/include/min/gpgmm_d3d12.h +++ b/src/include/min/gpgmm_d3d12.h @@ -273,8 +273,8 @@ namespace gpgmm::d3d12 { std::string DebugName; }; - enum FEATURE { - FEATURE_RESOURCE_SUBALLOCATION_SUPPORT, + enum ALLOCATOR_FEATURE { + ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT, }; using RESOURCE_ALLOCATOR_INFO = MemoryAllocatorInfo; @@ -302,7 +302,7 @@ namespace gpgmm::d3d12 { RESOURCE_ALLOCATOR_INFO GetInfo() const override; - HRESULT CheckFeatureSupport(FEATURE feature, + HRESULT CheckFeatureSupport(ALLOCATOR_FEATURE feature, void* pFeatureSupportData, uint32_t featureSupportDataSize) const; diff --git a/src/tests/end2end/D3D12ResourceAllocatorTests.cpp b/src/tests/end2end/D3D12ResourceAllocatorTests.cpp index 7542d933d..945b38e79 100644 --- a/src/tests/end2end/D3D12ResourceAllocatorTests.cpp +++ b/src/tests/end2end/D3D12ResourceAllocatorTests.cpp @@ -1520,7 +1520,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateTextureWithPadding) { EXPECT_EQ(allocationWithPadding->GetMethod(), gpgmm::AllocationMethod::kStandalone); } -TEST_F(D3D12ResourceAllocatorTests, CheckFeatureSupport) { +TEST_F(D3D12ResourceAllocatorTests, AllocatorFeatures) { ComPtr resourceAllocator; ASSERT_SUCCEEDED( ResourceAllocator::CreateAllocator(CreateBasicAllocatorDesc(), &resourceAllocator)); @@ -1532,20 +1532,20 @@ TEST_F(D3D12ResourceAllocatorTests, CheckFeatureSupport) { uint64_t bigItem; } WrongData = {}; - ASSERT_FAILED(resourceAllocator->CheckFeatureSupport(FEATURE_RESOURCE_SUBALLOCATION_SUPPORT, - &WrongData, sizeof(WrongData))); + ASSERT_FAILED(resourceAllocator->CheckFeatureSupport( + ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT, &WrongData, sizeof(WrongData))); } // Request information with no data. { - ASSERT_FAILED(resourceAllocator->CheckFeatureSupport(FEATURE_RESOURCE_SUBALLOCATION_SUPPORT, - nullptr, 0)); + ASSERT_FAILED(resourceAllocator->CheckFeatureSupport( + ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT, nullptr, 0)); } // Request information with valid data size. { - FEATURE_DATA_RESOURCE_SUBALLOCATION_SUPPORT data = {}; + FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT data = {}; ASSERT_SUCCEEDED(resourceAllocator->CheckFeatureSupport( - FEATURE_RESOURCE_SUBALLOCATION_SUPPORT, &data, sizeof(data))); + ALLOCATOR_FEATURE_RESOURCE_ALLOCATION_SUPPORT, &data, sizeof(data))); } }