Fix dynamic resolution when v-sync is enabled
このコミットが含まれているのは:
1 親
6c21561e6d
コミット
62a3129046
2ファイル変更
+26
-3
検索条件に一致するファイルはありません
@@ -230,6 +230,7 @@ partial class SwapChainManager<TOwner>
|
||||
// resuming after a pause correctly renders the first frame at the right time.
|
||||
if (OnUpdate(renderStopwatch.Elapsed, parameter))
|
||||
{
|
||||
OnWaitForPresent();
|
||||
OnPresent();
|
||||
}
|
||||
|
||||
@@ -247,6 +248,7 @@ partial class SwapChainManager<TOwner>
|
||||
|
||||
if (OnUpdate(renderStopwatch.Elapsed, parameter))
|
||||
{
|
||||
OnWaitForPresent();
|
||||
OnPresent();
|
||||
}
|
||||
}
|
||||
@@ -272,6 +274,7 @@ partial class SwapChainManager<TOwner>
|
||||
|
||||
if (OnUpdate(renderStopwatch.Elapsed, parameter))
|
||||
{
|
||||
OnWaitForPresent();
|
||||
OnPresent();
|
||||
}
|
||||
|
||||
@@ -290,6 +293,18 @@ partial class SwapChainManager<TOwner>
|
||||
|
||||
if (OnUpdate(renderStopwatch.Elapsed, parameter))
|
||||
{
|
||||
frameStopwatch.Stop();
|
||||
|
||||
// The time spent waiting for present isn't included in the frame time, as when v-sync is
|
||||
// enabled it corresponds to the time spent waiting for the v-blank. If it was included,
|
||||
// then the actual framerate would never exceed the target one, meaning that if dynamic
|
||||
// resolution is enabled, the resolution scale could only keep decreasing without ever
|
||||
// being able to be increased again, as the framerate would never exceed the target.
|
||||
// Simply not counting the time spent waiting for that works around the issue.
|
||||
OnWaitForPresent();
|
||||
|
||||
frameStopwatch.Start();
|
||||
|
||||
OnPresent();
|
||||
|
||||
// Evaluate the dynamic resolution frame time step
|
||||
@@ -361,6 +376,11 @@ partial class SwapChainManager<TOwner>
|
||||
return this.shaderRunner!.TryExecute(this.texture!, time, parameter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits for the panel to be ready to present a new frame for the current application.
|
||||
/// </summary>
|
||||
private unsafe partial void OnWaitForPresent();
|
||||
|
||||
/// <summary>
|
||||
/// Presents the last rendered frame for the current application.
|
||||
/// </summary>
|
||||
|
||||
@@ -389,12 +389,15 @@ internal sealed unsafe partial class SwapChainManager<TOwner> : NativeObject
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
private unsafe partial void OnWaitForPresent()
|
||||
{
|
||||
_ = Win32.WaitForSingleObjectEx(frameLatencyWaitableObject, Win32.INFINITE, true);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
private unsafe partial void OnPresent()
|
||||
{
|
||||
// Wait for the swap chain to be ready for presenting
|
||||
_ = Win32.WaitForSingleObjectEx(frameLatencyWaitableObject, Win32.INFINITE, true);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
// Get the underlying ID3D12Resource pointer for the texture
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする