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

Memory Fence before relasing lock
C++11: Thread pool for successive input reduction
Qt code sequence in multitread
vector::empty() function doesn't work correctly in release mode
On per-thread basis, the OS does not maintain virtual memory state?
MQTT-MQ data path load testing
Parallel Fibonacci example from “Parallel and Concurrent Programming” [duplicate]
Mutate a shared mutable variable in multiple threads
Getting Julia SharedArrays to play nicely with Sun Grid Engine
Haskell/GHC per thread memory costs
Client hangs after pthread_exit() in server thread in C
How to schedule a task in Restful web services [duplicate]
SFML Thread does not works for window
Restarting a GStreamer pipeline after X minutes has passed
Perl die (and stop the whole program) in a thread
Do processes have a stack, or are only the threads that actually have stack

Categories

HOME
ms-access
java
ibm-bluemix
arduino-uno
google-chrome-extension
pdf
deployment
omnet++
deezer
reserved
vmware
webstorm
sharepoint-designer
youtube-api-v3
datastax-java-driver
convolution
uber-api
swagger-ui
ios-charts
upload
pheatmap
gitpitch
spring-kafka
imacros
quickfix
ups
django-admin
database-replication
conemu
cloudhub
google-search-api
pass-by-reference
kudan
one-to-many
wpfdatagrid
tooltipster
newline
fabric8
pdb
typed.js
asset-pipeline
mpmediaquery
jmonkeyengine
git-merge
neuroscience
abstract-class
gzipstream
ruby-on-rails-3.1
core-plot
node-gyp
modelmapper
s
reactive-cocoa-5
qcombobox
long-polling
flickr-api
dotcover
scrollable
network-flow
apache-fop
strptime
blogengine.net
dotnetzip
android-cursor
mcafee
sonarlint-vs
messenger
phishing
google-web-starter-kit
react-native-listview
hill-climbing
dlna
rhino-servicebus
associative-array
netmq
xna-4.0
execute
libressl
quicklisp
p2
umbraco6
bigbluebutton
offloading
nstableviewcell
jscript.net
network-interface
android-nested-fragment
relocation
mdt
cctv
terminfo
article
typeof
sgen
marmalade
flexmojos
html4
plasma
quickdialog
bluepill
armcc
javaspaces
viewswitcher
recent-documents
locate
dbal
castle-monorail
compiler-specific
virtual-functions
uimenucontroller
phonon
sustainable-pace
scripting-languages
post-build
.net-1.0
uiq3





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