gpt4 book ai didi

c++ - Direct2D、Directx11on12 示例 VSYNC 问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:30:40 25 4
gpt4 key购买 nike

我正在按照 Microsoft directx11on12 示例创建一个 direct2d 组件并绘制一个圆圈和文本...

到目前为止,我能够绘制圆圈和文字......但我的 FPS 现在上限为 60 fps......之前是 400 fps......

那么如何在 Direct2d 中禁用 vsync ...

我什至无法将 rendertarget present 标志设置为 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

最佳答案

您必须将 IDXGISwapChain::Present 的第一个参数从 1 更改为 0。在您的示例中,它位于第 420 行的 D3D1211On12.cpp 中

关于c++ - Direct2D、Directx11on12 示例 VSYNC 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58762884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com