Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I just wonder, if it's possible to initialize and use DX11 or DX9 for offscreen rendering only - meaning with no attached window. My intention is to do some GPU benchmarking before opening actual window. In this benchmarking some test scene is rendered, but should not be visible. (Actually depending on the benchmark score different windows are opened)

share|improve this question
2  
With D3D11 you need to provide a window handle when creating the swap chain, see here. But maybe there's a way to hide this window? –  Laurent Couvidou Mar 22 '13 at 8:40
    
yeah, I know, that DX11 requires window handle for swapchain - but if you render offscreen only do you really need any swapchain? Is there some way to initialize and render without swapchain - I thought swapchain is just for screen rendering... –  GPUquant Mar 22 '13 at 10:04
    
Right now I am trying to use 1x1px window which is hidden. But it's not nice solution I'd say. –  GPUquant Mar 22 '13 at 10:05

1 Answer 1

up vote 4 down vote accepted

Yes. You can initialize the Direct3D device using D3D11CreateDevice, which requires no window. You simply do not create a swap chain at all. You can still create offscreen render targets and draw to them in the usual way. Instead of calling Present on the swap chain, you can call ID3D11DeviceContext::Flush to kick the GPU with the work you've queued up.

If you later want to create a window, you can destroy the device and recreate it with D3D11CreateDeviceAndSwapChain, or you can create a swap chain and attach it to the existing device with IDXGIFactory::CreateSwapChain. (The IDXGIFactory is a separate COM object that needs to be created with CreateDXGIFactory first.)

share|improve this answer
    
+1 Calling Flush instead of presenting the swap chain, this is neat! –  Laurent Couvidou Mar 22 '13 at 22:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.