Adjust max chunk size to fix error limit check from DX12 for large resources that are CPU accessible. (#22680)

Adjust max chunk size to fix error limit check from DX12 for large
resources that are CPU accessible.

### Description
Current agility SDK restricts CPU visible buffers to 0xFFFF0000 bytes or
slightly smaller than 4GiB. Verified restriction is still in latest
Agility SDK 1.614.1.


### Motivation and Context
Allocation of Resources 4GiB or larger fail in DX12 verification layer.

---------

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
This commit is contained in:
Christian Larson 2024-11-03 18:08:12 -08:00 committed by GitHub
parent 120cb5a804
commit ac6fe48375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -125,8 +125,8 @@ namespace Dml
// No chunks were able to accommodate the allocation - create a new chunk and return that instead
// At least double the capacity of the pool
const size_t newChunkSize = std::max({ m_totalCapacity, c_minChunkSize, sizeInBytes });
// At least double the capacity of the pool, limit to c_maxChunkSize so DX12 does not reject size
const size_t newChunkSize = std::min(std::max({ m_totalCapacity, c_minChunkSize, sizeInBytes }), c_maxChunkSize);
m_chunks.push_back(CreateChunk(m_device.Get(), newChunkSize));
m_totalCapacity += newChunkSize;

View file

@ -32,6 +32,7 @@ namespace Dml
private:
static constexpr size_t c_minChunkSize = 1024 * 1024; // 1MB
static constexpr size_t c_allocationAlignment = 512; // In bytes; as per D3D12 requirement for buffers
static constexpr size_t c_maxChunkSize = 0xFFFF0000; // ~4 GiB limitation for DX12 CPU-visible resource
// A suballoction from a chunk
struct Allocation