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

Difference between process & thread execution in CPU
Race condition during RxAndroid subscriber unit test
What happens with CPU context when Goroutines are switching?
OpenGL on Mac OS X in a second thread
Is it safe to modify an Arc<Mutex<T>> from both a Rust thread and a foreign thread?
How to create threads in haskell? [closed]
firmware development on single core vs multi core processor
C++11 thread safe singleton using lambda and call_once: main function (g++, clang++, Ubuntu 14.04)
Cucumber test scenarios running in parallel?
Using GLUT after fork on OSX Sierra [duplicate]
Thread with WriteProcessMemory
Erlang - map each “erlang process” to new kernel thread
Tensorflow multithreading image loading
Delphi - Omnithreadlibrary, death of main thread in console application
Akka Stream Graph parallelisation
Thread vs Thread?

Categories

HOME
fluentd
mockito
heroku
single-sign-on
kde
hashmap
electron
react-router
android-4.4-kitkat
dxl
datastax-java-driver
azure-media-services
constraint-programming
portia
synchronization
basic
dacpac
kibana-4
vault
rascal
gz
fortumo
flask-wtforms
try-catch
workload-scheduler
tostring
samoa
django-cms
immutable.js
amazonsellercentral
functional-testing
graphicsmagick
captiveportal
smb
kendo-datasource
flink-streaming
stormpath
bosh
phonegap
google-sites-2016
perlin-noise
lxd
phpfreechat
accelerate-framework
scaffold
hot-module-replacement
vapor
preconditions
no-www
executenonquery
angular-resource
celery-task
pebble-watch
aurelia-validation
setter
kbuild
font-size
dtexec
spring-mongodb
yt-project
nested-sets
spring-android
markojs
ptrace
lemon
ionic
system32
unity5.2.3
streambase
c++03
jsonpickle
nstableviewcell
phalanger
mechanize-ruby
typo3-neos
flexmojos
gnu-smalltalk
ftps
flash-builder4.5
jplaton
yui-compressor
cassini-dev
robotics-studio
delphi-6
jspinclude
code-cleanup
cufon
stage
genshi
coercion
infrastructure
sproutcore-2
database-management
backcolor

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile