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

Trying to load a huge file and do some work with it while still reading the file
how to make two mapper functions run parallel?
Need to Multithread this script and log the results of each [duplicate]
Many threads and critical region
A queue ahead of the queue
PyQt: How to send a stop signal into a thread where an object is running a conditioned while loop?
Delphi thread not receiving messages
Infinite threaded function in class constructor
Matlab - real-time read and buffer serial data while playing previous buffer using dsp.audioplayer /soundsc
How long is std::async running?
How can i run a set of thread groups together
Pause main thread while second thread runs
Operating Systems Efficiency [closed]
How to run Scalaz Tasks in parallel
Sync item list between perl scripts, across servers
Why does GPUImage use semaphores and processing queues instead of a thread with a runloop?

Categories

HOME
pandas
vim
reflection
kde
tesseract
kalman-filter
amortized-analysis
ebean
slick-slider
floating-action-button
zend-framework3
dynamics-crm-online
clearcase-ucm
uitypeeditor
propel
jprofiler
autocad-plugin
graphicsmagick
mmap
rundeck
crosstab
fish
phpfox
entitlements
xacml
opentype
vision
data-manipulation
oracle-fusion-middleware
scorm2004
jspresso
gtrendsr
catch-all
webtest
commit
gammu
catalog
wixsharp
xcode-extension
multilingual
libvpx
sharefile
webix-treetable
jna
ansible-playbook
particles.js
checkboxlist
wptoolkit
executenonquery
flickr-api
youcompleteme
apache-fop
theming
return-value
idisposable
svmlight
statsd
magma
windows-mobile-6.5
flow-control
topbeat
root-framework
cubes
plottable.js
storekit
gstreamer-0.10
connect-by
lttng
historian
r-tree
muse
ionic
responsive-images
iiviewdeckcontroller
oberon
pretty-print
python-green
facebook-graph-api-v2.4
markers
expected-exception
undefined-reference
android-2.2-froyo
java.nio.file
ivyde
jsctypes
web2py-modules
ruby-datamapper
ftps
flash-builder4.5
ora-00911
rabl
android-screen-support
angularjs-controller
simba
hamiltonian-cycle
trusted
punbb
subgurim-maps
inotifycollectionchanged
pyinotify
h.323
web-application-design
preference
boost-smart-ptr
pascal-fc
signal-handling

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App