Merge pull request #331 from Sergio0694/dev/shader-panel-tweaks

Minor tweaks to shader panel backend
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2022-08-03 16:24:08 -07:00
コミット 1bd11e681f
3ファイル変更
+16 -13

検索条件に一致するファイルはありません

+6
ファイルの表示
@@ -90,6 +90,12 @@ public sealed partial class AnimatedComputeShaderPanel : SwapChainPanel, IDispos
/// <inheritdoc/>
public void Dispose()
{
// Also request the render loop to stop before disposing. This ensures that in case there's
// a render thread already ongoing that is using a custom frame request queue, it might have
// the ability to stop rendering immediately and safely, instead of causing the panel to remain
// alive and then just throwing an exception the next time a frame is requested in case the
// device ot other resources have also been disposed.
this.swapChainManager.StopRenderLoop();
this.swapChainManager.Dispose();
}
}
+9 -12
ファイルの表示
@@ -29,10 +29,13 @@ partial class SwapChainManager<TOwner>
{
Guard.IsNotNull(shaderRunner);
using var _0 = GetReferenceTrackingLease();
using (await this.setupSemaphore.LockAsync())
{
// Here and in the calls below, only get a reference tracking lease when starting a render thread.
// This avoids crashes when the panel has been disposed but some code (eg. event handlers) still
// ends up calling into any of the APIs in this file, which is not intended but should not crash.
using var _0 = GetReferenceTrackingLease();
this.renderCancellationTokenSource?.Cancel();
await this.renderSemaphore.WaitAsync();
@@ -71,13 +74,13 @@ partial class SwapChainManager<TOwner>
/// <param name="isDynamicResolutionEnabled">Whether or not to use dynamic resolution.</param>
public async void QueueDynamicResolutionModeChange(bool isDynamicResolutionEnabled)
{
using var _0 = GetReferenceTrackingLease();
using (await this.setupSemaphore.LockAsync())
{
// If there is a render thread currently running, stop it and restart it
if (this.renderCancellationTokenSource?.IsCancellationRequested == false)
{
using var _0 = GetReferenceTrackingLease();
this.renderCancellationTokenSource?.Cancel();
await this.renderSemaphore.WaitAsync();
@@ -105,14 +108,14 @@ partial class SwapChainManager<TOwner>
/// <param name="isVerticalSyncEnabled">Whether or not to use vertical sync.</param>
public async void QueueVerticalSyncModeChange(bool isVerticalSyncEnabled)
{
using var _0 = GetReferenceTrackingLease();
using (await this.setupSemaphore.LockAsync())
{
// The v-sync option can be toggled on the fly when not using dynamic resolution
if (this.renderCancellationTokenSource?.IsCancellationRequested == false &&
this.isDynamicResolutionEnabled)
{
using var _0 = GetReferenceTrackingLease();
this.renderCancellationTokenSource?.Cancel();
await this.renderSemaphore.WaitAsync();
@@ -140,8 +143,6 @@ partial class SwapChainManager<TOwner>
/// <param name="height">The height of the render resolution.</param>
public void QueueResize(double width, double height)
{
using var _0 = GetReferenceTrackingLease();
this.width = (float)width;
this.height = (float)height;
@@ -155,8 +156,6 @@ partial class SwapChainManager<TOwner>
/// <param name="compositionScaleY">The composition scale on the Y axis</param>
public void QueueCompositionScaleChange(double compositionScaleX, double compositionScaleY)
{
using var _0 = GetReferenceTrackingLease();
this.compositionScaleX = (float)compositionScaleX;
this.compositionScaleY = (float)compositionScaleY;
@@ -169,8 +168,6 @@ partial class SwapChainManager<TOwner>
/// <param name="resolutionScale">The resolution scale factor to use.</param>
public void QueueResolutionScaleChange(double resolutionScale)
{
using var _0 = GetReferenceTrackingLease();
this.resolutionScale = (float)resolutionScale;
this.isResizePending = true;
+1 -1
ファイルの表示
@@ -118,7 +118,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
/// when the device is collected. But, due to the fact that could happen at any time, a list is required to guarantee
/// the additional references added by the native objects in the pipeline model can be released immediately.
/// </remarks>
private List<PipelineData> cachedPipelineData;
private readonly List<PipelineData> cachedPipelineData;
/// <summary>
/// Raised whenever the device is lost.