multithreading


DX11 Updating Shared Textures


I have a shared DX11 texture that is being used with 2 different devices in separate threads.
Thread1 (operating on device 1): Called every frame and updates the shared texture
Thread2(operating on device2): Consumes the shared texture by copying it to another texture. Frequency is much lesser than thread 1.
According to MSDN "If a shared texture is updated on one device ID3D11DeviceContext::Flush must be called on that device."
However calling flush on thread1 every frame is very expensive and we see a massive performance hit. We can't flush device 1 on thread 2, because a device context is not thread safe.
Is there a way to efficiently make the shared texture update when threads 2 needs to consume it?
Thanks for your help! MSDN is not very helpful when dealing with shared textures.
emphasized text
In order to synchronize the access to the shared resource between two threads (or interprocess) you can use IDXGIKeyedMutex. It is described here in details: https://msdn.microsoft.com/en-us/library/windows/desktop/ee913554(v=vs.85).aspx#dxgi_1.1_synchronized_shared_surfaces
You can check the sample code provided as well although they show only resource sharing between two DX10 devices. It is the same for DX11 devices.
The essential part is to QueryInterface the shared texture for IDXGIResource first and then for IDXGIKeyedMutex. After that you use the mutex for synchronization by using AcquireSync and ReleaseSync functions.

Related Links

Process Synchronization Logic
What does it mean by 'The thread that releases a semaphore need not be the same thread that acquired it'?
which language is best for multi thread programming
Matrix multiplication with threads and semaphore
How do I handle multi threading in Spring Boot while doing DB operations?
Tensorflow while_loop for training #2
Prevent mongodb from dying with 'state should be: open'
Python3.4 A quest about create mul-threads
Automapper exception: Missing type map configuration or unsupported mapping
MPI Send Recv deadlock
Is it safe to read values from a thread without synchronize?
How do I atomically replace a vector?
SAS - ERROR: A lock is not available
C - Pthread_cond_signal - Signal longest waiting thread
Parallelizing recursive branching computations in scala using futures
Lock-free programming: reordering and memory order semantics

Categories

HOME
bluetooth
gremlin
iterator
raspberry-pi
react-redux
fsm
echarts
directx
paradox
contact
slick-slider
event-handling
netflix
clearcase-ucm
workload-scheduler
finite-automata
solaris-10
scriptcs
jasonette
telerik-reporting
centos6.5
saas
atlassian-crucible
vision
lightswitch-2013
ecto
bosh
galsim
exuberant-ctags
column-family
asset-pipeline
y86
mpmediaquery
http-digest
xcode-extension
starteam
c11
twitch
lumberjack
user-controls
hp-ux
gulp-sourcemaps
isbn
convertapi
mu
np-complete
memory-alignment
pdfclown
mako
spring-cache
lync-client-sdk
eventkit
persist
hover-over
tform
xna-4.0
comobject
tarjans-algorithm
browser-bugs
myo
appfabric-cache
unity3d-gui
remobjects
p2
clicktag
java-metro-framework
device-manager
neolane
eol
uitouch
hippomocks
apc
opcache
back-stack
chronoforms
delphi-6
anonymous-methods
dsn
postgresql-performance
jquery-ui-layout
hirefire
paster
fixed-width
sef
zend-decorators
port-number
mediarss
dbisam
lzh

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile