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

How locking is implemented?
Usage of registers by the compiler in multithreaded program
Thread, QThread, how many per process is “reasonable”?
Perl Module ForkManager not working
Multiple thread in EF 5
How to know when CloseThreadPool() function completes?
When is a condition variable needed, isn't a mutex enough?
RichTextBox::Rtf Multi-threading
Passing data to tk gui
perl how to use is_running
If nodejs is multithreaded why should i use cluster module to utilize multicore cpu?
Writting hundrads of AVI files in different threads using OpenCV 2.2
how can I kill or pause a thread when it return to previous intent or home page
Guaranteeing Quartz.NET Triggers only fire events once even with many instances
Unexpected second AppDomain in ASP.NET website
Multithreading in LLVM

Categories

HOME
cakephp
clips
coq
blogger
omnet++
plot
alfresco
read-eval-print-loop
at-command
tizen-web-app
sharepoint-designer
umd
baqend
angular-ui-bootstrap
opengl-es-2.0
azure-storage-tables
uber-api
webrequest
cloudkit
session-variables
dax
systemc
tostring
undefined
zapier
tar
java-7
url-scheme
fifo
libuv
skia
microsoft-chart-controls
data-manipulation
android-nestedscrollview
normal-distribution
ios5
wixsharp
plsql-psp
occlusion
bootstrapper
ibpy
total-commander
hibernate-tools
alphabet
blacklist
objective-c-swift-bridge
jquery-filter
visual-c++-2008
httplistener
elements
underscore.js-templating
contact-list
testng-dataprovider
python-stackless
pagerank
uid
natvis
pervasive-sql
mutation-observers
django-unittest
fouc
coveralls
tarjans-algorithm
varargs
browser-bugs
sframe
riak-cs
proj4js
inmobi
fscommand
dia
modalpopup
javafx-webengine
socketexception
google-reader
marmalade
concurrent-collections
gnu-smalltalk
pushbackinputstream
first-responder
venn-diagram
viewswitcher
reddot
ohm
gwt-ext
hirefire
yetanotherforum
appender
calling-convention
digest-authentication
gamequery
rescale
firefox-5
substrings
ctp4
simpletest
sector
dbisam

Resources

Encrypt Message