Results 1 to 3 of 3

Thread: [D3D] swapchains and displaymodes

  1. #1

    [D3D] swapchains and displaymodes

    Hi everyone.

    I have a few questions concerning Swapchains, because i want to implement them in my engine.

    1. changing a swapchain's displaymode

    Normally, when you want to change the displaymode in your game, You release your video-resources, call Device.Reset with new presentation parameters and restore your video-resources again. When using multiple swapchains, this isn't very efficient when you only need to change ONE swapchain.

    So i thought it might be okay to release the swapchain you wish the displaymode to be changed, and recreate it with new presentation parameters. Is this a good way of doing this??

    If so, is it possible to release all swapchains a device has, and recreate them with new presentation parameters, without having to free/restore other video resources?? This seems more efficient to me than the Device.reset method, also when you only have one swapchain.

    2. swapchains v.s full-screen rendering

    What happens when you create a fullscreen swapchain?? Of course, rendering to the other swapchains is ridiculous, but is this a valid action?? :?

    And what about multiple full-screen swapchains?? :twisted:

    thank you!
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    [D3D] swapchains and displaymodes

    1. When you are creating D3dDevice - it automatically creates default swapchain. I'm not sure is it possible to have two swapchains for single monitor, when one of SC is fullscreen... Seems you have to try it by yourself.

    2. The whole idea to have multiple swapchains is to enable easy way to present to two monitors [in fullscreen mode] which are connected to the same videocard (dual-head).
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    [D3D] swapchains and displaymodes

    I just managed to make a swapchain test app.

    It seems that it's impossible to create a fullscreen swapchain on one monitor.
    CreateAdditionalSwapChain will fail. So question 2 is completely impossible.

    Removing all swapchains cann't be done either because:
    [pascal]
    Device.GetSwapChain(0,SwapChain);
    SwapChain := nil;
    [/pascal]
    will simply not destroy the defaut swapchain, but only the reference to it.

    I've been trying to make the backbuffer resize when the window is resized. No succes so far:

    [pascal]
    function MsgProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
    var d3dpp: TD3DPresentParameters;
    mode: TD3DDisplayMode;
    begin
    case uMsg of
    WM_KEYDOWN:
    begin
    if wParam = VK_ESCAPE then
    SendMessage(Hwnd,WM_CLOSE,0,0);
    end;

    WM_SIZE:
    begin
    //ACCES VIOLATION on the following line (at adress #00000000)
    g_pD3D.GetAdapterDisplayMode(D3DADAPTER_DEFAULT,mo de);

    // Set up the structure used to create the D3DDevice
    FillChar(d3dpp, SizeOf(d3dpp), 0);
    d3dpp.Windowed := true;
    d3dpp.SwapEffect := D3DSWAPEFFECT_COPY;
    d3dpp.BackBufferWidth := (lparam and $0000ffff);
    d3dpp.BackBufferHeight := (lparam and $ffff0000 shr 16);
    d3dpp.BackBufferFormat := mode.Format;

    //if the first window is resized
    if hwnd = hWindow then
    begin
    pSwap1 := nil;
    g_pd3dDevice.CreateAdditionalSwapChain(d3dpp,pSwap 1);
    end;
    //if the second window is resized
    if hwnd = hWindow2 then
    begin
    pSwap2 := nil;
    g_pd3dDevice.CreateAdditionalSwapChain(d3dpp,pSwap 2);
    end;
    end;

    WM_DESTROY:
    begin
    Cleanup;
    PostQuitMessage(0);
    Result:= 0;
    Exit;
    end;
    end;

    Result:= DefWindowProc(hWnd, uMsg, wParam, lParam);
    end;
    [/pascal]

    Does anyone know what i'm doing wrong?? Is g_pD3D out of scope or something. :?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •