Minor codegen improvements
このコミットが含まれているのは:
1 親
b55f6bd346
コミット
9801b500bb
4ファイル変更
+53
-54
検索条件に一致するファイルはありません
@@ -1,4 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
@@ -156,11 +157,6 @@ public unsafe abstract class Texture2D<T> : NativeObject, IGraphicsResource, Gra
|
||||
/// </summary>
|
||||
internal D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorHandle => this.d3D12ResourceDescriptorHandles.D3D12GpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current resource is in readonly state.
|
||||
/// </summary>
|
||||
protected bool IsInReadOnlyState => this.d3D12ResourceState != D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target memory area.
|
||||
/// </summary>
|
||||
@@ -546,6 +542,25 @@ public unsafe abstract class Texture2D<T> : NativeObject, IGraphicsResource, Gra
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> if the current resource is not in a readonly state.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void ThrowIfIsNotInReadOnlyState()
|
||||
{
|
||||
if (this.d3D12ResourceState == D3D12_RESOURCE_STATE_UNORDERED_ACCESS)
|
||||
{
|
||||
static void Throw()
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The texture is not currently in readonly mode. This API can only be used when creating a compute graph with " +
|
||||
"the ComputeContext type, and after having used ComputeContext.Transition() to change the state of the texture.");
|
||||
}
|
||||
|
||||
Throw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="GraphicsDeviceMismatchException"/> if the target device doesn't match the current one.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
@@ -166,11 +167,6 @@ public unsafe abstract class Texture3D<T> : NativeObject, IGraphicsResource, Gra
|
||||
/// </summary>
|
||||
internal D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorHandle => this.d3D12ResourceDescriptorHandles.D3D12GpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current resource is in readonly state.
|
||||
/// </summary>
|
||||
protected bool IsInReadOnlyState => this.d3D12ResourceState != D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target memory area.
|
||||
/// </summary>
|
||||
@@ -599,6 +595,25 @@ public unsafe abstract class Texture3D<T> : NativeObject, IGraphicsResource, Gra
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> if the current resource is not in a readonly state.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void ThrowIfIsNotInReadOnlyState()
|
||||
{
|
||||
if (this.d3D12ResourceState == D3D12_RESOURCE_STATE_UNORDERED_ACCESS)
|
||||
{
|
||||
static void Throw()
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The texture is not currently in readonly mode. This API can only be used when creating a compute graph with " +
|
||||
"the ComputeContext type, and after having used ComputeContext.Transition() to change the state of the texture.");
|
||||
}
|
||||
|
||||
Throw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="GraphicsDeviceMismatchException"/> if the target device doesn't match the current one.
|
||||
/// </summary>
|
||||
|
||||
@@ -31,20 +31,7 @@ partial class ReadWriteTexture2D<T, TPixel>
|
||||
GraphicsDevice.ThrowIfDisposed();
|
||||
|
||||
ThrowIfDisposed();
|
||||
|
||||
if (!IsInReadOnlyState)
|
||||
{
|
||||
static void Throw()
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The texture is not currently in readonly mode. This API can only be used when creating a compute graph with " +
|
||||
"the ComputeContext type, and after having used ComputeContext.Transition() to change the state of the texture.");
|
||||
}
|
||||
|
||||
Throw();
|
||||
}
|
||||
|
||||
GetWrapperAndReturnIfNotNull:
|
||||
ThrowIfIsNotInReadOnlyState();
|
||||
|
||||
ReadOnly? readOnlyWrapper = this.readOnlyWrapper;
|
||||
|
||||
@@ -53,19 +40,16 @@ partial class ReadWriteTexture2D<T, TPixel>
|
||||
return readOnlyWrapper;
|
||||
}
|
||||
|
||||
// The wrapper initialization is moved to a non inlined helper to keep the codegen of this
|
||||
// method as compact as possible. If the current wrapper is not initialized, a new one is
|
||||
// created, then code jumps back to the check. This allows the method to have a single exit
|
||||
// point, which further improves the final codegen.
|
||||
// The wrapper initialization is moved to a non inlined helper to keep the codegen of this method
|
||||
// as compact as possible. If the current wrapper is not initialized, control goes directly to the
|
||||
// helper that will initialize and return it, which translates to a single jump.
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
static void InitializeWrapper(ReadWriteTexture2D<T, TPixel> texture)
|
||||
static ReadOnly InitializeWrapper(ReadWriteTexture2D<T, TPixel> texture)
|
||||
{
|
||||
texture.readOnlyWrapper = new ReadOnly(texture);
|
||||
return texture.readOnlyWrapper = new(texture);
|
||||
}
|
||||
|
||||
InitializeWrapper(this);
|
||||
|
||||
goto GetWrapperAndReturnIfNotNull;
|
||||
return InitializeWrapper(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -31,20 +31,7 @@ partial class ReadWriteTexture3D<T, TPixel>
|
||||
GraphicsDevice.ThrowIfDisposed();
|
||||
|
||||
ThrowIfDisposed();
|
||||
|
||||
if (!IsInReadOnlyState)
|
||||
{
|
||||
static void Throw()
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"The texture is not currently in readonly mode. This API can only be used when creating a compute graph with " +
|
||||
"the ComputeContext type, and after having used ComputeContext.Transition() to change the state of the texture.");
|
||||
}
|
||||
|
||||
Throw();
|
||||
}
|
||||
|
||||
GetWrapperAndReturnIfNotNull:
|
||||
ThrowIfIsNotInReadOnlyState();
|
||||
|
||||
ReadOnly? readOnlyWrapper = this.readOnlyWrapper;
|
||||
|
||||
@@ -54,14 +41,12 @@ partial class ReadWriteTexture3D<T, TPixel>
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
static void InitializeWrapper(ReadWriteTexture3D<T, TPixel> texture)
|
||||
static ReadOnly InitializeWrapper(ReadWriteTexture3D<T, TPixel> texture)
|
||||
{
|
||||
texture.readOnlyWrapper = new ReadOnly(texture);
|
||||
return texture.readOnlyWrapper = new(texture);
|
||||
}
|
||||
|
||||
InitializeWrapper(this);
|
||||
|
||||
goto GetWrapperAndReturnIfNotNull;
|
||||
return InitializeWrapper(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする