locked
using a directx device to render different scenes in different windows

    Question

  • I an writing in C++ and DirectX a visualization library for PC which opens multiple windows, each windows has its own scene and rendering loop, the user can update per window the data of the scene that he wants, so that the windows has a different update time. I can expect to have between 4 and 6 windows open at each given time.

    Currently I created windows which are handled each one in their own thread, have their own render loop and "their own device". 

    How expensive is to use multiple devices?

    Is there a better way to achieve what I am doing with one device? If so how this is theoretically done in terms of: ImmediateContext, swapchain, backbuffer, renderTargetView?

    Intuitively: Create one device with one immediate context, for each window create swapchain, backbuffer, endertargetView with the viewports, inputLayouts (and all other things at create stage) . Then per window render use the immediatecontext to set renderTargetsViews, viewports and anything which can be set in the immediate context. When each window thread do the render I will need to protect it with a critical section (from the first call to the device in the render function, to the last). I am very not sure about this, if is possible at all, and if is not too much expensive.

    thanks,

    Emanuel


    Emanuel Shalev

    Saturday, February 1, 2014 9:54 AM

All replies

  • I imagine there will be several problems with one device managing multiple windows, like resizing the windows. I just don't think it will work. Devices themselves are tied to a Window handle and I don't see anything in the class documentation to change the window its tied to. I think what most do here is have multiple areas in the same window.

    You can always make a method to create the windows with one device to see if it even works. If it doesn't just modify it to make separate devices for each window. Although not the most informed answer, I think you will find your answer before someone else responds.

    I think the size of the DirectX device depends on the context your using it in. I know there are applications that really need to go down to the bit level, but for a modern desktop program I don't think multiple devices should be an issue. These will all be pointers anyway.


    • Edited by Falchard Sunday, February 2, 2014 8:53 AM
    Sunday, February 2, 2014 8:49 AM