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

What's the correct way to process a file with multiple threads?
multithreaded generation of all numbers in range in random order
How does the Operating System determine how much stack space should be allotted to each thread?
Level of Parallelism present in multiple threads per core
Working with Cocoa and a worker thread
Can I make it granted EJB #asynchronous method's thread starts after caller thread ends?
Why do download managers work faster than the default browser downloaders?
join() threads without holding the main thread in python
Perl DBD::SQLite - begin_work outside while loop blocks threads?
Fast thread-safe read optimised Map[Long, _]
Java: Running transaction in multithreaded environment
dispatch_queue and core data
python 2.7 thread not running correctly
Python PyQT/PySide QThread limiting
Message loop issue using SetParent to embed window into external process
Using global variables in a function called by threaded subroutines

Categories

HOME
sendgrid
coq
openstack
mfc
react-virtualized
relative-path
include
yarn
paw-app
v8
win32gui
angular-ui-bootstrap
ebean
serverspec
acquia
fortumo
iolanguage
fatal-error
apache-metamodel
lldb
facebook-instant-articles
php-openssl
wijmo
spark-jobserver
user-interaction
traffic
filezilla
saas
nat
bluestacks
iframe-resizer
grails-3.1
atl
mmenu
mpmediaquery
hockeyapp
code-search-engine
document.write
ws-security
hp-ux
sfdc
ncalc
gulp-sourcemaps
angular-resource
jquery-nestable
worksheet
boost-multi-index
ionicons
recursive-datastructures
r-forge
qtwebview
python-cryptography
or-tools
pintos
rotativa
mongocsharpdriver
jwplayer7
master-slave
bgp
captivenetwork
tform
cyclomatic-complexity
metaclass
ruby-2.2
wireshark-dissector
spidermonkey
nsight
unity5.2.3
sonarqube5.1.2
dia
website-monitoring
typekit
fpml
mesa
tld
rebol3
valueconverter
cdc
spring-io
coverflow
random-seed
drools-planner
anonymous-methods
ticoredatasync
bubble-chart
assembly-loading
coredump
horizontal-accordion
appender
celltable
forums
castle-monorail
photoshop-cs4
avatar
msdev
grid-system
paul-graham

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile