Generate input types as ReadOnlyMemory<T>
このコミットが含まれているのは:
1 親
077504566e
コミット
a6b87b551c
8ファイル変更
+268
-51
検索条件に一致するファイルはありません
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
|
||||
namespace ComputeSharp.D2D1.__Internals;
|
||||
|
||||
@@ -77,14 +78,12 @@ public interface ID2D1Shader
|
||||
uint GetInputCount();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input type for the input at the input index.
|
||||
/// Gets the input types for the current shader.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the shader input to get the type for.</param>
|
||||
/// <returns>The type of input at the specified index.</returns>
|
||||
/// <remarks>The return value if the input is out of range is undefined.</remarks>
|
||||
/// <returns>The input types for the current shader.</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be used directly by user code")]
|
||||
uint GetInputType(uint index);
|
||||
ReadOnlyMemory<D2D1PixelShaderInputType> InputTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads the input descriptions for the shader, if any.
|
||||
|
||||
@@ -259,20 +259,16 @@ public static class D2D1PixelShader
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of a given input for a D2D1 pixel shader.
|
||||
/// Gets the input types for a D2D1 pixel shader.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to get the input type for.</typeparam>
|
||||
/// <param name="index">The index of the input to get the type for.</param>
|
||||
/// <returns>The type of the input of the target D2D1 pixel shader at the specified index.</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is not in range for the available inputs for the shader type.</exception>
|
||||
public static D2D1PixelShaderInputType GetInputType<T>(int index)
|
||||
/// <typeparam name="T">The type of D2D1 pixel shader to get the input types for.</typeparam>
|
||||
/// <returns>The input types of the target D2D1 pixel shader.</returns>
|
||||
public static ReadOnlyMemory<D2D1PixelShaderInputType> GetInputTypes<T>()
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, (int)shader.GetInputCount());
|
||||
|
||||
return (D2D1PixelShaderInputType)shader.GetInputType((uint)index);
|
||||
return shader.InputTypes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -175,10 +175,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
int inputCount = D2D1PixelShader.GetInputCount<T>();
|
||||
D2D1PixelShaderInputType* inputTypes = (D2D1PixelShaderInputType*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), sizeof(D2D1PixelShaderInputType) * inputCount);
|
||||
|
||||
for (int i = 0; i < inputCount; i++)
|
||||
{
|
||||
inputTypes[i] = D2D1PixelShader.GetInputType<T>(i);
|
||||
}
|
||||
D2D1PixelShader.GetInputTypes<T>().Span.CopyTo(new Span<D2D1PixelShaderInputType>(inputTypes, inputCount));
|
||||
|
||||
// Prepare the input descriptions
|
||||
ReadOnlyMemory<D2D1InputDescription> inputDescriptionsInfo = D2D1PixelShader.GetInputDescriptions<T>();
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする