Advertisement

DX12: Map/Unmap a suballocation

Started by July 31, 2017 04:52 AM
2 comments, last by mark_braga 7 years, 6 months ago

I am working on a resource manager for a DX12 framework. I have it setup with a buddy allocator system like the vulkan memory allocator by AMD. But there is one issue - map and unmap. Lets say I have an upload buffer and I make two suballocations from the upload buffer for two constant buffers. I map the upload buffer at the specific offsets, do a memcpy and unmap with the appropriate write range.


mapBuffer(triangleCBV);
memcpy(triangleCBV->address, triData);
unmapBuffer(triangleCBV, triangleCBVOffset);

mapBuffer(rectCBV);
memcpy(rectCBV->address, rectData);
unmapBuffer(rectCBV, rectCBVOffset);
  
  

The second map does nothing. I only see the triangle and the rect never seems to get the cbv data. The data is just a float4 for color.

What you described sounds like it should work, so I'm not sure what the issue is. 

Is there any particular reason why you're mapping and unmapping for each sub-allocation instead of just mapping the entire resource once and offsetting as necessary to write to the sub-buffers?

Advertisement

Because the backing resource is not created as persistently mapped. I am trying to keep the number of persistent mapped resources to a minimum.

This topic is closed to new replies.

Advertisement