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

Swift iOS9 - dispatch_group - need code to execute in specific order
How to make the main (calling) thread wait for a child thread to complete execution?
Read/Write custom objects on multiple threads
Why and how weak semaphores provide starvation-freedom in two process scenario?
How to use clang thread annotations with a RAII style try-lock?
How to ensure mutual exclusion?
How can we run different task in different thread in gradle
JavaFX pie Charts ObservableList (Chart GUI update not accurate when passed on Thread)
Openmp what openmp does if the omp for is nested in omp parallel
Multithreading in Go. Can somebody explain these answers to me?
Benefits of user-level threads
How goroutine scheduling works
F# parallel design pattern
How To Prevent Perl Thread Printouts from Intercepting?
Extreme slowdown, OpenMP probably see unexisting race conditions?
How to use multithreading to write downloaded data in one file in a mulithread download application

Categories

HOME
hive
vbscript
server
mediawiki
layout
view
platform-builder
xmpp
framework7
jsp-tags
adb
cmd
sharepoint-designer
rubygems
youtube-api-v3
sqlite3
win32gui
yum
medical
primary-key
metatrader4
row
remote-access
dtrace
decimal
dynamics-crm-online
jqwidget
lldb
swingx
kudan
jndi
claims-based-identity
spark-jobserver
poltergeist
web-api-testing
atlassian-crucible
windows-server-2000
flink-streaming
tinymce-4
google-rich-snippets
google-api-nodejs-client
bower-install
service-discovery
galen
thin
angular2-meteor
babel-core
pango
dandelion
togetherjs
pdfclown
nbconvert
sonarlint-vs
watchconnectivity
azure-sdk
rotativa
android-textview
underscore.js-templating
thrust
etsy
nessus
php-internals
associative-array
ios8-today-widget
separator
spim
wso2cloud
thredds
citrus-pay
cisco-ios
bridge.net
modalpopup
navigationservice
mysql-error-1062
undefined-reference
uv-mapping
c18
sitemesh
runtime.exec
limejs
jquery-knob
mt
frameset
venn-diagram
automount
newtonscript
bubble-chart
amazon-appstore
semantic-diff
libc++
subgurim-maps
invite
table-footer
perfect-hash
exchange-server-2003
grid-system

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