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

Java Multi threading two producers and 1 Consumer Issue
local queue per thread without global queue
Functions and variable space with threading using clone
Jenkins running multiple batch files at once
Can a thread be assigned to multiple processes on windows?
How can i get Access to a QThread in a QTcpServer
Delphi7 How to make Com object wait until program initilisation is complete?
How does writing to common queue aid in resolving concurrency issues
Perl threads get iterations speed
cudaDeviceSynchronise spawns new thread, even when set to blocking
Delphi: how to deal with dynamically created threads
Share a logfile between multiple services (each service with multiple threads), how to?
Mixing threads, fork, and mutexes, what should I watch out for?
deploying CPU intensive web service on cloud
How to access thread and its components?
is #Autowired HttpSession thread safe in springmvc?

Categories

HOME
yii2
gerrit
openstack
google-play
comparison
dot
vmware
kalman-filter
ip
paradox
append
primary-key
python-unittest
metatrader4
wheelnav.js
postgres-xl
google-cloud-spanner
progressive-web-apps
custom-wordpress-pages
nas
realex-payments-api
blazemeter
trading
smb
cas
kannel
nhapi
applozic
c++-amp
microsoft-chart-controls
data-manipulation
calibre
vsts-build-task
hybridauth
mapdb
main
git-merge
theano.scan
leading-zero
texmaker
google-closure
user-accounts
azure-application-gateway
jedis
theming
snmptrapd
font-size
r-forge
windows-iot-core-10
dynamics-sl
yt-project
color-picker
nxt
sts-springsourcetoolsuite
ctest
django-debug-toolbar
essence
qgraphicsview
associative-array
hsv
r-tree
reactive-banana
endeca-workbench
metaclass
comobject
muse
responsive-images
twirl
typekit
oxwall
flask-cors
expected-exception
htmlcleaner
fmod
multiprocessor
page-layout
dbconnection
hungarian-algorithm
yui-compressor
ocunit
android-hardware
hamiltonian-cycle
coderush
doh
gcj
pyinotify
dmx512
wise
yagni
pascal-fc
procedural-music
putchar

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