Jump to content
  • Advertisement
mark_braga

DX12: Map/Unmap a suballocation

This topic is 488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by mark_braga

Share this post


Link to post
Share on other sites
Advertisement

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!