An Producer-Consumer based sample application where frames are generated by a Direct3D 9 producer, and rendered into a Direct3D 11 consumer (scene). This application utilizes Direct3DDevice9::CreateTexture
and ID3D11Device::OpenSharedResource
to share texture memory between Direct3D 9 and 11.
-
If you don't have it already - install CMake and Visual Studio 2017
- VS 2017 Community Edition is fine - just make sure to install C/C++ development tools
-
Run the gen_vs2017.bat script.
Note: if you're building for x86 you will need to modify gen_vs2017.bat to specify the correct generator for CMake
-
Open the build/d3d-9211.sln solution in Visual Studio
-
Build the ALL_BUILD project
-
Run the d3d-9211.exe application
The scene dimensions can be specified as a command line argument: (--size=1920x1080 for example). By default it will choose a resolution that can fit on screen.
The Direct3D 9 producer will render the scene with transparency - the background color/pattern can be controlled using the context-menu within the window.
The application uses a queue of frames to synchronize texture access between D3D 9 and 11. The producer will render to offscreen shared textures, then place them on a queue for consumption. The consumer will read a shared texture from the queue and render it within a D3D11 scene. It will then place the texture back into a pool so the producer can re-use an allocated texture.
The interaction with the queue and pool prevents a texture from being used by both D3D9 and 11 concurrently.