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
6 changes: 3 additions & 3 deletions src/gpgmm/d3d12/CapsD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/CapsD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down
9 changes: 5 additions & 4 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 11 additions & 11 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/include/min/gpgmm_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/include/min/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions src/tests/end2end/D3D12ResourceAllocatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> resourceAllocator;
ASSERT_SUCCEEDED(
ResourceAllocator::CreateAllocator(CreateBasicAllocatorDesc(), &resourceAllocator));
Expand All @@ -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)));
}
}