Direct2D, пример Directx11 на 12 ПРОБЛЕМА VSYNC - PullRequest
1 голос
/ 08 ноября 2019

Я следую примеру Microsoft DirectX11on12, чтобы создать компонент direct2d и нарисовать круг и текст ...

Пока я могу рисовать круг и текст ... но мой FPS теперь ограничен 60fps .... раньше это было 400 fps ...

так как отключить vsync в Direct2d ...

я даже не могу установить флаги представления rendertarget равными D2D1_PRESENT_OPTIONS_IMMEDIATELY, когда я создаю цель rendertargetвот так ...

// 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;
    }
}

как отключить вертикальную синхронизацию в этом примере ...

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

1 Ответ

0 голосов
/ 09 ноября 2019

Вы должны изменить первый параметр IDXGISwapChain::Present с 1 на 0. В вашем примере он находится в D3D1211On12.cpp в строке 420

...