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

PyQt5 threads and signals emit two strings
restarting tcp boost asio io_service with uncompleted completion handlers
The distribution of processing threads on the processor cores
Size of Vector too high when running mutex threaded application
Love2D, Threads execution and input
Why does Dropbox use so many threads?
How to use pthreads in Android NDK
Poco::Net::TCPServer - Simple server with 100% cpu usage
HttpClient and stream issues
tkiner window is not showing an image
How to parallely `map(…)` on a custom, single-threaded iterator in Rust?
“Grouping” several async_work_group_copy() calls with a single event
Log4Net appender prematurely stopping on IIS Express Stop Site
Wildfly: Receiving shutdown event to prevent early shutdown of ManagedExecutorService
How to know spin lock or other locks like Mutex, Semaphore is already acquired in program but not released?
JavaFX - method returning before background thread completes

Categories

HOME
vim
pdf
bluetooth
deployment
single-sign-on
json.net
fft
yarn
graphql
angular-ui-bootstrap
podio
paradox
esper
adfs
modx-revolution
correlation
zend-framework3
dtrace
zebra-printers
ups
iron-router
carthage
dynamics-crm-online
telephony
transformation
evopdf
code-review
viewport
karma-jasmine
dbext
custom-wordpress-pages
jasonette
blazemeter
smb
apache-commons-io
xacml
stormpath
siesta-swift
atl
hexo
mixture-model
withings
occlusion
document.write
webdriver-manager
squib
texmaker
ibpy
netcdf4
reactive-cocoa-5
node-sass
azure-application-gateway
ionicons
boost-preprocessor
synchronous
mathematica-frontend
blackberry-10
dlna
livequery
spim
wso2cloud
execute
google-places
spidermonkey
content-length
embedded-code
emailrelay
tableau-online
ibaction
appfabric-cache
sankey-diagram
operation
unity5.2.3
streambase
inmobi
tween
jscript.net
gui-test-framework
titanium-modules
dml
hyprlinkr
transcoding
uv-mapping
ms-project-server-2010
dir
dotnetnuke-5
flash-builder4.5
django-nonrel
cassini-dev
wsdl-2.0
referrer
anonymous-methods
bitsharp
code-cleanup
whoosh
boost-filesystem
window-management
zpt
vdsp
infobox
xtype
netbeans-7.1
recent-documents
site.master
sudzc
nsviewanimation
meego
windows-live-messenger
ajax-forms
uiq3

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