directx - Texture streaming in DirectX11, Immutable vs Dynamic -


we have case need stream textures graphics card (in game case: terrains, in case image different input sources cameras/capture cards/videos)

of course in camera case, receive data in separate thread, still need upload data gpu display.

i know 2 models it.

  • use dynamic resource: create dynamic texture has same size , format input image, when receive new image set flag tells need upload, , use map in device context upload texture data (with eventual double buffer of course).

    advantage have single memory location, hence don't have memory fragmentation on time.

    drawback need upload in immediate context, upload had in render loop.

  • use immutable , load/discard in case upload in image receiving thread, creating new resource, push data , discard old resource.

    advantage should have stall free upload (no need immediate context, can still run command list while texture uploading), resource can used simple trigger once available (to swap srv).

    drawback can fragment memory on time (by allocating , freeing resources in constant manner (30 fps standard camera example).

    also have deal throttling (but part not big deal).

so there missed in techniques, or there better way handle this?

these 2 main methods of updating textures d3d11.

however, assumption first method not result in memory usage patterns identical second case dependent on driver, , not true. use d3d11_map_write_discard if overwriting whole image (which sounds doing), meaning current contents of buffer become undefined. however, true cpu's point-of-view. retained gpu, if potentially used in pending draw operation. (maybe all?) drivers allocate new storage write location of mapped texture in case, otherwise command buffer processing need stall. same holds if not use discard flag. instead, when map command processed in command buffer, resource's buffer updated value returned map in d3d11_mapped_subresource.

also, not true must update dynamic textures in immediate context. if update them in deferred context, must use d3d11_map_discard flag. means update texture on worker thread, if overwriting entire texture.

the bottom line that, since cpu/gpu system on pc not unified memory system, there synchronization issues updating gpu resources coming cpu.


Popular posts from this blog