mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git
synced 2024-11-25 05:20:04 +00:00
Fixes in usage of Map/Unmap to fix D3D Debug Layer EXECUTION WARNING #930: MAP_INVALID_NULLRANGE
This commit is contained in:
parent
4c905740fe
commit
2eb11e7ef8
@ -82,6 +82,8 @@ inline constexpr T AlignUp(T val, T align)
|
||||
|
||||
static const float PI = 3.14159265358979323846264338327950288419716939937510582f;
|
||||
|
||||
static const D3D12_RANGE EMPTY_RANGE = {0, 0};
|
||||
|
||||
struct vec2
|
||||
{
|
||||
float x, y;
|
||||
|
@ -282,7 +282,7 @@ inline UINT64 UpdateSubresources(
|
||||
}
|
||||
|
||||
BYTE* pData;
|
||||
HRESULT hr = pIntermediate->Map(0, NULL, reinterpret_cast<void**>(&pData));
|
||||
HRESULT hr = pIntermediate->Map(0, &EMPTY_RANGE, reinterpret_cast<void**>(&pData));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return 0;
|
||||
@ -704,8 +704,7 @@ void InitD3D() // initializes direct3d 12
|
||||
cbvDesc.SizeInBytes = AlignUp<UINT>(sizeof(ConstantBuffer0_PS), 256);
|
||||
g_Device->CreateConstantBufferView(&cbvDesc, g_MainDescriptorHeap[i]->GetCPUDescriptorHandleForHeapStart());
|
||||
|
||||
D3D12_RANGE readRange{0, 0};
|
||||
CHECK_HR( g_ConstantBufferUploadHeap[i]->Map(0, &readRange, &g_ConstantBufferAddress[i]) );
|
||||
CHECK_HR( g_ConstantBufferUploadHeap[i]->Map(0, &EMPTY_RANGE, &g_ConstantBufferAddress[i]) );
|
||||
}
|
||||
|
||||
// create input layout
|
||||
@ -1019,9 +1018,7 @@ void InitD3D() // initializes direct3d 12
|
||||
IID_PPV_ARGS(&g_CbPerObjectUploadHeaps[i])) );
|
||||
g_CbPerObjectUploadHeaps[i]->SetName(L"Constant Buffer Upload Resource Heap");
|
||||
|
||||
D3D12_RANGE readRange{0, 0}; // We do not intend to read from this resource on the CPU. (so end is less than or equal to begin)
|
||||
// map the resource heap to get a gpu virtual address to the beginning of the heap
|
||||
CHECK_HR( g_CbPerObjectUploadHeaps[i]->Map(0, &readRange, &g_CbPerObjectAddress[i]) );
|
||||
CHECK_HR( g_CbPerObjectUploadHeaps[i]->Map(0, &EMPTY_RANGE, &g_CbPerObjectAddress[i]) );
|
||||
}
|
||||
|
||||
// # TEXTURE
|
||||
|
@ -677,7 +677,7 @@ static void TestMapping(const TestContext& ctx)
|
||||
resources[i].allocation.reset(alloc);
|
||||
|
||||
void* mappedPtr = NULL;
|
||||
CHECK_HR( resources[i].resource->Map(0, NULL, &mappedPtr) );
|
||||
CHECK_HR( resources[i].resource->Map(0, &EMPTY_RANGE, &mappedPtr) );
|
||||
|
||||
FillData(mappedPtr, bufSize, i);
|
||||
|
||||
@ -849,7 +849,7 @@ static void TestTransfer(const TestContext& ctx)
|
||||
for(UINT i = 0; i < count; ++i)
|
||||
{
|
||||
void* mappedPtr = nullptr;
|
||||
CHECK_HR( resourcesUpload[i].resource->Map(0, NULL, &mappedPtr) );
|
||||
CHECK_HR( resourcesUpload[i].resource->Map(0, &EMPTY_RANGE, &mappedPtr) );
|
||||
|
||||
FillData(mappedPtr, bufSize, i);
|
||||
|
||||
@ -894,8 +894,7 @@ static void TestTransfer(const TestContext& ctx)
|
||||
// Unmap every 3rd resource, leave others mapped.
|
||||
if((i % 3) != 0)
|
||||
{
|
||||
const D3D12_RANGE writtenRange = {0, 0};
|
||||
resourcesReadback[i].resource->Unmap(0, &writtenRange);
|
||||
resourcesReadback[i].resource->Unmap(0, &EMPTY_RANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -927,7 +926,7 @@ static void TestZeroInitialized(const TestContext& ctx)
|
||||
|
||||
{
|
||||
void* mappedPtr = nullptr;
|
||||
CHECK_HR( bufUpload.resource->Map(0, NULL, &mappedPtr) );
|
||||
CHECK_HR( bufUpload.resource->Map(0, &EMPTY_RANGE, &mappedPtr) );
|
||||
FillData(mappedPtr, bufSize, 5236245);
|
||||
bufUpload.resource->Unmap(0, NULL);
|
||||
}
|
||||
@ -959,10 +958,11 @@ static void TestZeroInitialized(const TestContext& ctx)
|
||||
|
||||
bool isZero = false;
|
||||
{
|
||||
const D3D12_RANGE readRange{0, bufSize}; // I could pass pReadRange = NULL but it generates D3D Debug layer warning: EXECUTION WARNING #930: MAP_INVALID_NULLRANGE
|
||||
void* mappedPtr = nullptr;
|
||||
CHECK_HR( bufReadback.resource->Map(0, NULL, &mappedPtr) );
|
||||
CHECK_HR( bufReadback.resource->Map(0, &readRange, &mappedPtr) );
|
||||
isZero = ValidateDataZero(mappedPtr, bufSize);
|
||||
bufReadback.resource->Unmap(0, NULL);
|
||||
bufReadback.resource->Unmap(0, &EMPTY_RANGE);
|
||||
}
|
||||
|
||||
wprintf(L"Should be zero: %u, is zero: %u\n", shouldBeZero ? 1 : 0, isZero ? 1 : 0);
|
||||
@ -1087,7 +1087,7 @@ static void TestMultithreading(const TestContext& ctx)
|
||||
res.allocation.reset(alloc);
|
||||
|
||||
void* mappedPtr = nullptr;
|
||||
CHECK_HR( res.resource->Map(0, NULL, &mappedPtr) );
|
||||
CHECK_HR( res.resource->Map(0, &EMPTY_RANGE, &mappedPtr) );
|
||||
|
||||
FillData(mappedPtr, res.size, res.dataSeed);
|
||||
|
||||
@ -1159,8 +1159,7 @@ static void TestMultithreading(const TestContext& ctx)
|
||||
// Unmap some of them, leave others mapped.
|
||||
if((resIndex % 3) == 1)
|
||||
{
|
||||
D3D12_RANGE writtenRange = {0, 0};
|
||||
resources[resIndex].resource->Unmap(0, &writtenRange);
|
||||
resources[resIndex].resource->Unmap(0, &EMPTY_RANGE);
|
||||
}
|
||||
|
||||
resources.pop_back();
|
||||
|
Loading…
Reference in New Issue
Block a user