简体   繁体   English

Direct2D、Directx11on12 示例 VSYNC ISSUE

[英]Direct2D, Directx11on12 example VSYNC ISSUE

i am following microsofts directx11on12 example to create a direct2d component and draw a circle and text...我正在按照微软的 directx11on12 示例创建一个 direct2d 组件并绘制一个圆圈和文本...

so far i am able to draw circle and text... but my FPS is now capped at 60 fps.... earlier it was 400 fps...到目前为止,我可以画圆圈和文字……但我的 FPS 现在上限为 60 fps……之前是 400 fps……

so how to disable vsync in Direct2d...那么如何在 Direct2d 中禁用 vsync ......

i cant even set rendertarget present flags to D2D1_PRESENT_OPTIONS_IMMEDIATELY as i am creating a rendertarget like this...我什至无法将渲染目标存在标志设置为 D2D1_PRESENT_OPTIONS_IMMEDIATELY,因为我正在创建这样的渲染目标......

// 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 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您必须将IDXGISwapChain::Present的第一个参数从 1 更改为 0。在您的示例中,它位于第 420 行的 D3D1211On12.cpp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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