Centralize function pointer accessors in T4 templates
このコミットが含まれているのは:
1 親
2c9fda857b
コミット
f5f094e632
6ファイル変更
+721
-131
検索条件に一致するファイルはありません
@@ -24,9 +24,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Intrinsics\Hlsl.Void.g.cs">
|
||||
<DependentUpon>Hlsl.Void.tt</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Hlsl.Void.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Intrinsics\Hlsl.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -137,8 +137,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Intrinsics\Hlsl.Void.tt">
|
||||
<LastGenOutput>Hlsl.Void.g.cs</LastGenOutput>
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Hlsl.Void.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Intrinsics\Hlsl.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Shaders\Interop\Effects\PixelShaderEffect.Properties.g.cs">
|
||||
<Compile Update="Shaders\Interop\Effects\PixelShaderEffect.Properties.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>PixelShaderEffect.Properties.tt</DependentUpon>
|
||||
</None>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Shaders\Interop\Effects\PixelShaderEffect.Properties.tt">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -21,19 +22,51 @@ unsafe partial struct PixelShaderEffect
|
||||
private delegate int PropertySetBindingDelegate(IUnknown* effect, byte* data, uint dataSize);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="PropertyGetFunctionDelegate"/> instance wrapping <see cref="GetConstantBuffer"/>.
|
||||
/// A cached <see cref="PropertyGetFunctionDelegate"/> instance wrapping <see cref="GetConstantBufferImpl"/>.
|
||||
/// </summary>
|
||||
private static readonly PropertyGetFunctionDelegate GetConstantBufferWrapper = GetConstantBuffer;
|
||||
private static readonly PropertyGetFunctionDelegate GetConstantBufferWrapper = GetConstantBufferImpl;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="PropertySetBindingDelegate"/> instance wrapping <see cref="SetConstantBuffer"/>.
|
||||
/// A cached <see cref="PropertySetBindingDelegate"/> instance wrapping <see cref="SetConstantBufferImpl"/>.
|
||||
/// </summary>
|
||||
private static readonly PropertySetBindingDelegate SetConstantBufferWrapper = SetConstantBuffer;
|
||||
private static readonly PropertySetBindingDelegate SetConstantBufferWrapper = SetConstantBufferImpl;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the get accessor for the constant buffer.
|
||||
/// </summary>
|
||||
public static delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, int> GetConstantBuffer
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return &GetConstantBufferImpl;
|
||||
#else
|
||||
return (delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, int>)(void*)Marshal.GetFunctionPointerForDelegate(GetConstantBufferWrapper);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set accessor for the constant buffer.
|
||||
/// </summary>
|
||||
public static delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, int> SetConstantBuffer
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return &SetConstantBufferImpl;
|
||||
#else
|
||||
return (delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, int>)(void*)Marshal.GetFunctionPointerForDelegate(SetConstantBufferWrapper);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int GetConstantBuffer(IUnknown* effect, byte* data, uint dataSize, uint* actualSize)
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
private static int GetConstantBufferImpl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)effect;
|
||||
|
||||
@@ -54,8 +87,8 @@ unsafe partial struct PixelShaderEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int SetConstantBuffer(IUnknown* effect, byte* data, uint dataSize)
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
private static int SetConstantBufferImpl(IUnknown* effect, byte* data, uint dataSize)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)effect;
|
||||
|
||||
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -1,6 +1,10 @@
|
||||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ output extension=".g.cs"#>
|
||||
using System.Runtime.CompilerServices;
|
||||
#if !NET6_OR_GREATER
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
@@ -20,37 +24,75 @@ for (int i = 0; i < 16; i++)
|
||||
/// <summary>
|
||||
/// A cached <see cref="PropertyGetFunctionDelegate"/> instance wrapping <see cref="GetResourceTextureManager<#=i#>"/>.
|
||||
/// </summary>
|
||||
private static readonly PropertyGetFunctionDelegate GetResourceTextureManager<#=i#>Wrapper = GetResourceTextureManager<#=i#>;
|
||||
private static readonly PropertyGetFunctionDelegate GetResourceTextureManager<#=i#>Wrapper = GetResourceTextureManager<#=i#>Impl;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="PropertySetBindingDelegate"/> instance wrapping <see cref="SetResourceTextureManager<#=i#>"/>.
|
||||
/// </summary>
|
||||
private static readonly PropertySetBindingDelegate SetResourceTextureManager<#=i#>Wrapper = SetResourceTextureManager<#=i#>;
|
||||
private static readonly PropertySetBindingDelegate SetResourceTextureManager<#=i#>Wrapper = SetResourceTextureManager<#=i#>Impl;
|
||||
<#
|
||||
if (i < 15) WriteLine("");
|
||||
}
|
||||
#>
|
||||
#endif
|
||||
|
||||
<#
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
#>
|
||||
/// <summary>
|
||||
/// Gets the get accessor for the resource manager at index <#=i#>.
|
||||
/// </summary>
|
||||
public static delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, int> GetResourceTextureManager<#=i#>
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return &GetResourceTextureManager<#=i#>Impl;
|
||||
#else
|
||||
return (delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, int>)(void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager<#=i#>Wrapper);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the set accessor for the resource manager at index <#=i#>.
|
||||
/// </summary>
|
||||
public static delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, int> SetResourceTextureManager<#=i#>
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return &SetResourceTextureManager<#=i#>Impl;
|
||||
#else
|
||||
return (delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, int>)(void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager<#=i#>Wrapper);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
#>
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int GetResourceTextureManager<#=i#>(IUnknown* effect, byte* data, uint dataSize, uint* actualSize)
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
private static int GetResourceTextureManager<#=i#>Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize)
|
||||
{
|
||||
return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(<#=i#>, data, dataSize, actualSize);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly]
|
||||
private static int SetResourceTextureManager<#=i#>(IUnknown* effect, byte* data, uint dataSize)
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
private static int SetResourceTextureManager<#=i#>Impl(IUnknown* effect, byte* data, uint dataSize)
|
||||
{
|
||||
return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(<#=i#>, data, dataSize);
|
||||
}
|
||||
<#
|
||||
if (i < 15) WriteLine("");
|
||||
}
|
||||
#>
|
||||
}
|
||||
+14
@@ -3,6 +3,8 @@
|
||||
|
||||
using System;
|
||||
|
||||
#pragma warning disable CS0649
|
||||
|
||||
namespace ComputeSharp.NetStandard.System.Runtime.InteropServices; // This cannot be in System.Runtime.InteropServices, or Roslyn will recognize it
|
||||
|
||||
/// <summary>
|
||||
@@ -14,4 +16,16 @@ namespace ComputeSharp.NetStandard.System.Runtime.InteropServices; // This canno
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
|
||||
internal sealed class UnmanagedCallersOnlyAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Optional. If omitted, the runtime will use the default platform calling convention.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Supplied types must be from the official "System.Runtime.CompilerServices" namespace and be of the form "CallConvXXX".
|
||||
/// </remarks>
|
||||
public Type[]? CallConvs;
|
||||
|
||||
/// <summary>
|
||||
/// Optional. If omitted, no named export is emitted during compilation.
|
||||
/// </summary>
|
||||
public string? EntryPoint;
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする