Jump to content
  • Advertisement

DX12: Map/Unmap a suballocation

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.

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!