Jump to content
  • Advertisement
Sign in to follow this  
Reitano

Partial update of textures in DirectX 11

This topic is 2116 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

Hi

In DirectX 9, when locking surfaces, it is possible to specify a rectangular region instead of the entire surface. The API then keeps track of the locked rects and takes that into account when transferring the new data from system to video memory and for auto-generating mip maps. That is my assumption at least.

 

In DirectX 11, you can only lock (map) an entire surface (subresource). What is the suggested approach for partially updating surfaces in this case ? Via a staging resource and CopySubresourceRegion ? Or UpdateSubresource ? Does the API then generates the mip maps for the dirty part of the texture or the whole one ?

 

My use case is the CPU update of clipmaps.

Thanks,

Stefano

Share this post


Link to post
Share on other sites
Advertisement

You can still get the same functionality using ID3D11DeviceContext::UpdateSubresource, but ID3D11DeviceContext::Map is faster, and it even allows you to update non-rectangular regions with your own copy algorithm (use Map with the D3D11_MAP_WRITE flag for this), or even to do blending on the CPU using the texture as destination (D3D11_MAP_READ_WRITE), though I don't think anyone really does blending this way.

Share this post


Link to post
Share on other sites

tonembug, it is my understanding that ID3D11DeviceContext::Map does not work with default textures but only with dynamic ones although I have to test that. Also, that function gives access to the whole resource and cannot give hints to the DirectX API about what regions of the texture were actually modified. For auto-generated mipmaps, the API would have to generate the mip chain of the whole texture any time it's unmapped. That is an unacceptable cost for minimal updates.

ID3D11DeviceContext::UpdateSubresource seems a good candidate for clipmapping in DirectX 11. Or perhaps CopySubresourceRegion even if it's less straightforward.

Do you know any GPU debugging tool that shows the actual copies done by the run-time ? I kinda wish these operations were more transparent to the user and not to have to take all these guesses about resource management.

Share this post


Link to post
Share on other sites

You should use a staging resource and CopySubresourceRegion. In the past the IHV's have recommend this approach for updating dynamic textures in general, since UpdateSubresourceRegion can go through slow paths in the driver and DYNAMIC resources have restrictions. The driver will not generate mipmaps for you, if you need this to happen then you should create the texture with D3D11_RESOURCE_MISC_GENERATE_MIPS and call GenerateMips after updating the texture.

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.

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!