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
9 changes: 5 additions & 4 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,11 @@ namespace gpgmm { namespace d3d12 {
ResidencyManager::CreateResidencyManager(residencyDesc, &residencyManager));
}

*resourceAllocatorOut =
new ResourceAllocator(newDescriptor, residencyManager, std::move(caps));

GPGMM_TRACE_EVENT_OBJECT_SNAPSHOT(*resourceAllocatorOut, newDescriptor);
if (resourceAllocatorOut != nullptr) {
*resourceAllocatorOut =
new ResourceAllocator(newDescriptor, residencyManager, std::move(caps));
GPGMM_TRACE_EVENT_OBJECT_SNAPSHOT(*resourceAllocatorOut, newDescriptor);
}

if (residencyManagerOut != nullptr) {
*residencyManagerOut = residencyManager.Detach();
Expand Down
8 changes: 3 additions & 5 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,10 @@ namespace gpgmm { namespace d3d12 {
@param descriptor A reference to ALLOCATOR_DESC structure that describes the allocator.
@param[out] resourceAllocatorOut Pointer to a memory block that recieves a pointer to the
resource allocator. Pass NULL to test if allocator creation would succeed, but not actually
create the allocator. If NULL is passed and allocator creating would succeed, S_FALSE is
returned.
create the allocator.
@param[out] residencyManagerOut Pointer to a memory block that recieves a pointer to the
residency manager. Pass NULL to test if residency manager creation would succeed, but not
actually create the residency manager. If NULL is passed and residency manager creation
would succeed, S_FALSE is returned.
residency manager. If NULL is passed, the allocator will be created without using
residency for resources.
*/
static HRESULT CreateAllocator(const ALLOCATOR_DESC& descriptor,
ResourceAllocator** resourceAllocatorOut,
Expand Down
3 changes: 3 additions & 0 deletions src/tests/D3D12Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#define ASSERT_FAILED(expr) ASSERT_TRUE(FAILED(expr))
#define ASSERT_SUCCEEDED(expr) ASSERT_TRUE(SUCCEEDED(expr))

#define EXPECT_FAILED(expr) EXPECT_TRUE(FAILED(expr))
#define EXPECT_SUCCEEDED(expr) EXPECT_TRUE(SUCCEEDED(expr))

namespace gpgmm { namespace d3d12 {

struct ALLOCATOR_DESC;
Expand Down
13 changes: 8 additions & 5 deletions src/tests/end2end/D3D12ResourceAllocatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateAllocator) {
// Creating an invalid allocator should always fail.
{
ComPtr<ResourceAllocator> resourceAllocator;
ASSERT_FAILED(ResourceAllocator::CreateAllocator({}, &resourceAllocator));
EXPECT_FAILED(ResourceAllocator::CreateAllocator({}, &resourceAllocator));
EXPECT_EQ(resourceAllocator, nullptr);
}

Expand All @@ -51,24 +51,27 @@ TEST_F(D3D12ResourceAllocatorTests, CreateAllocator) {
desc.Device = nullptr;

ComPtr<ResourceAllocator> resourceAllocator;
ASSERT_FAILED(ResourceAllocator::CreateAllocator(desc, &resourceAllocator));
EXPECT_FAILED(ResourceAllocator::CreateAllocator(desc, &resourceAllocator));
EXPECT_EQ(resourceAllocator, nullptr);
}

// Creating a NULL allocator should always succeed.
EXPECT_SUCCEEDED(ResourceAllocator::CreateAllocator(CreateBasicAllocatorDesc(), nullptr));

// Creating an allocator without an adapter should always fail.
{
ALLOCATOR_DESC desc = CreateBasicAllocatorDesc();
desc.Adapter = nullptr;

ComPtr<ResourceAllocator> resourceAllocator;
ASSERT_FAILED(ResourceAllocator::CreateAllocator(desc, &resourceAllocator));
EXPECT_FAILED(ResourceAllocator::CreateAllocator(desc, &resourceAllocator));
EXPECT_EQ(resourceAllocator, nullptr);
}

// Creating a new allocator using the defaults should always succeed.
{
ComPtr<ResourceAllocator> resourceAllocator;
ASSERT_SUCCEEDED(
EXPECT_SUCCEEDED(
ResourceAllocator::CreateAllocator(CreateBasicAllocatorDesc(), &resourceAllocator));
EXPECT_NE(resourceAllocator, nullptr);
}
Expand All @@ -81,7 +84,7 @@ TEST_F(D3D12ResourceAllocatorTests, CreateAllocator) {
desc.MaxResourceHeapSize = kDefaultBufferSize / 2;

ComPtr<ResourceAllocator> resourceAllocator;
ASSERT_FAILED(ResourceAllocator::CreateAllocator(desc, &resourceAllocator));
EXPECT_FAILED(ResourceAllocator::CreateAllocator(desc, &resourceAllocator));
EXPECT_EQ(resourceAllocator, nullptr);
}
}
Expand Down