Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support VRR (Variable Refresh Rate) #905

Open
wants to merge 2 commits into
base: winappsdk/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions winrt/lib/drawing/CanvasDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.AlphaMode = ToDxgiAlphaMode(alphaMode);
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;

ComPtr<IDXGISwapChain1> swapChain;
ThrowIfCreateSurfaceFailed(
Expand Down
3 changes: 3 additions & 0 deletions winrt/lib/drawing/CanvasSwapChain.abi.idl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ namespace Microsoft.Graphics.Canvas
[overload("Present")]
HRESULT PresentWithSyncInterval([in] INT32 syncInterval);

[overload("Present")]
HRESULT PresentWithSyncIntervalAndPresentFlags([in] INT32 syncInterval, [in] INT32 presentFlags);

[overload("ResizeBuffers")]
HRESULT ResizeBuffersWithSize(
[in] Windows.Foundation.Size newSize);
Expand Down
11 changes: 8 additions & 3 deletions winrt/lib/drawing/CanvasSwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,15 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas

IFACEMETHODIMP CanvasSwapChain::Present()
{
return PresentWithSyncInterval(1);
return PresentWithSyncIntervalAndPresentFlags(1, 0);
}

IFACEMETHODIMP CanvasSwapChain::PresentWithSyncInterval(int32_t syncInterval)
{
return PresentWithSyncIntervalAndPresentFlags(syncInterval, 0);
}

IFACEMETHODIMP CanvasSwapChain::PresentWithSyncIntervalAndPresentFlags(int32_t syncInterval, int32_t presentFlags)
{
return ExceptionBoundary(
[&]
Expand All @@ -460,7 +465,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
auto& resource = GetResource();

DXGI_PRESENT_PARAMETERS presentParameters = { 0 };
ThrowIfFailed(resource->Present1(syncInterval, 0, &presentParameters));
ThrowIfFailed(resource->Present1(syncInterval, presentFlags, &presentParameters));
});
}

Expand Down Expand Up @@ -556,7 +561,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas
widthInPixels,
heightInPixels,
static_cast<DXGI_FORMAT>(newFormat),
0));
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING));

if (!m_isTransformMatrixSupported)
{
Expand Down
1 change: 1 addition & 0 deletions winrt/lib/drawing/CanvasSwapChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas

IFACEMETHOD(Present)() override;
IFACEMETHOD(PresentWithSyncInterval)(int32_t syncInterval) override;
IFACEMETHOD(PresentWithSyncIntervalAndPresentFlags)(int32_t syncInterval, int32_t presentFlags) override;

IFACEMETHOD(ResizeBuffersWithSize)(
Size newSize) override;
Expand Down