简体   繁体   中英

Direct2D, Directx11on12 example VSYNC ISSUE

i am following microsofts directx11on12 example to create a direct2d component and draw a circle and text...

so far i am able to draw circle and text... but my FPS is now capped at 60 fps.... earlier it was 400 fps...

so how to disable vsync in Direct2d...

i cant even set rendertarget present flags to D2D1_PRESENT_OPTIONS_IMMEDIATELY as i am creating a rendertarget like this...

// Query the desktop's dpi settings, which will be used to create
// D2D's render targets.
float dpiX;
float dpiY;
m_d2dFactory->GetDesktopDpi(&dpiX, &dpiY);
D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1(
    D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,
    D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
    dpiX,
    dpiY
);

for (int i = 0; i < MAX_BUFFERED_FRAMES; i++)
{
    // Create a wrapped 11On12 resource of this back buffer. Since we are 
    // rendering all D3D12 content first and then all D2D content, we specify 
    // the In resource state as RENDER_TARGET - because D3D12 will have last 
    // used it in this state - and the Out resource state as PRESENT. When 
    // ReleaseWrappedResources() is called on the 11On12 device, the resource 
    // will be transitioned to the PRESENT state.
    D3D11_RESOURCE_FLAGS d3d11Flags = { D3D11_BIND_RENDER_TARGET }; 
    hr = m_device11on12->CreateWrappedResource(
        backBufferRenderTarget[i],
        &d3d11Flags,
        D3D12_RESOURCE_STATE_RENDER_TARGET,
        D3D12_RESOURCE_STATE_PRESENT,
        IID_PPV_ARGS(&m_wrappedBackBuffers[i])
    );
    if (FAILED(hr))
    {
        return false;
    }

    // Create a render target for D2D to draw directly to this back buffer.
    IDXGISurface* surface;
    hr = m_wrappedBackBuffers[i]->QueryInterface(&surface);
    if (FAILED(hr))
    {
        return false;
    }

    hr = m_d2dDeviceContext->CreateBitmapFromDxgiSurface(
        surface,
        &bitmapProperties,
        &m_d2dRenderTargets[i]
    );
    if (FAILED(hr))
    {
        return false;
    }
}

so how to disable vertical sync on this example...

https://github.com/microsoft/DirectX-Graphics-Samples/tree/master/Samples/UWP/D3D1211On12

You have to change the first parameter of IDXGISwapChain::Present from 1 to 0. In your example it's in D3D1211On12.cpp on line 420

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM