Advertisement

Overlay in DX12?

Started by January 26, 2018 02:57 PM
4 comments, last by SoldierOfLight 7 years ago

Simple question. What is best practice for drawing overlay graphics in Directx 12? 

For now, all I want to do is to draw a semi-transparent rectangle in the upper left corner of my view.

Is there a shortcut, or do I need to set up more shaders, vertex buffers, constant buffers, root signatures etc. etc.? Since we are talking about DX12 I guess it's the later :/

Any small example project out there?

 

You don't want to use D3D12 for that. First, to display an overlay window on the desktop is kind of graphics API independent. DirectX is only here for you to draw with GPU acceleration to a surface attached to an hwnd. How you decide to compose it over the desktop is a completely unrelated story. 

 

D3D12 is not design as a D3D11 replacement, they work together. 99% of application only need the safe, secure and relatively easy D3D11. Only 1% of apps, with crazy memory requirement and obsess with crazy high performance on heavy rendering that cannot be achieve with D3D11 have a need for it.

Advertisement

Drawing overlay UI elements is would be no different that drawing any other object...A draw is a draw, ie. the API has not understanding of what you are drawing...all it sees are buffers, shaders, pipeline state etc... So yes you would have to all the setup required to render you overlay.

On 1/26/2018 at 6:16 PM, galop1n said:

You don't want to use D3D12 for that. First, to display an overlay window on the desktop is kind of graphics API independent. DirectX is only here for you to draw with GPU acceleration to a surface attached to an hwnd. How you decide to compose it over the desktop is a completely unrelated story. 

My first thought was naturally to draw normal System.Drawing.Graphics elements on top of the 3D rendering. This would be done right after presenting the swapchain and waiting for the GPU to catch up. Unfortunately it didn't work. Nothing gets drawn, at least not on top. If you have any method that works, please let me know. The area that I'm drawing onto is a SharpDX.Windows.Renderform (which inherits from System.Windows.Form.Form).

So I guess it's the long route of drawing more 3D polygons instead.

System.Drawing.Graphics is GDI, which cannot interop in that way with swapchains of type DXGI_SWAP_EFFECT_FLIP_[SEQUENTIAL/DISCARD], which are required for D3D12.

This topic is closed to new replies.

Advertisement