Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

[D3D12] CopyTextureRegion with a fence?

This topic is 912 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 streaming in texture data on a background thread.  I have a 3x3 grid of textures that I load data into, and I use these textures to sample from when rendering the immediate area around the camera.  This grid of textures is updated as the camera moves, such that they represent the currently desired textures surrounding the camera.  As such, I re-use grid entries when the camera has moved sufficiently, and upload new data to the textures regularly.

 

Anyway, I update these textures with a call to UpdateSubresources, which ultimately calls CopyTextureRegion.  I wrap the call to UpdateSubresources in calls to ResourceBarrier to transition to/from pixel shader resources and copy destinations.  This all works fine when the camera is moving slowly.  But when I move fast, I see some of the old texture data get rendered, as if the CopyTextureRegion call hadn't completed before the texture was sampled.

 

I put in a fence, which calls ID3D12CommandQueue::Signal after the call to CopyTextureRegion (well, after the second ResourceBarrier transition), and I check its value before rendering with the intended new data, but it doesn't seem to have any effect.

 

I guess what I'm wondering is, can a fence be used to ensure the completetion of CopyTextureRegion?

Edited by Funkymunky

Share this post


Link to post
Share on other sites
Advertisement
How exactly are you command lists and command queues set up? Which command list are you calling CopyTextureRegion on? Which queue are you submitting the commands to? When do you call ExecuteCommandLists? Do you submit the copy command list from the streaming thread? Depending on how you use you queues, you may or may not need to tell the GPU to wait on your fence before executing a command list that utilizes the texture data that you just copied in.

Share this post


Link to post
Share on other sites

Well it turns out that I had a bug in how I updated the position that the stream used to calculate which texture index to access.  I flushed it out in the process of walking through the code to examine each of your questions.  So thanks!

Edited by Funkymunky

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!