Enable shaders to inherit shader interfaces

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-29 12:58:19 +02:00
1 親 3bf77618e4
コミット 459517a181
3ファイル変更
+66 -2

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

+1 -1
ファイルの表示
@@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator
/// <returns>Whether or not <paramref name="typeSymbol"/> implements <paramref name="d2D1PixelShaderSymbol"/>.</returns>
private static bool IsD2D1PixelShaderType(INamedTypeSymbol typeSymbol, INamedTypeSymbol d2D1PixelShaderSymbol)
{
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.Interfaces)
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
{
if (interfaceSymbol.Name == nameof(ID2D1PixelShader) &&
SymbolEqualityComparer.Default.Equals(interfaceSymbol, d2D1PixelShaderSymbol))
+1 -1
ファイルの表示
@@ -23,7 +23,7 @@ partial class IShaderGenerator
INamedTypeSymbol iComputeShaderSymbol,
INamedTypeSymbol iPixelShaderSymbol)
{
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.Interfaces)
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
{
if (interfaceSymbol.Name == nameof(IComputeShader) &&
SymbolEqualityComparer.Default.Equals(interfaceSymbol, iComputeShaderSymbol))
+64
ファイルの表示
@@ -272,6 +272,70 @@ namespace ComputeSharp.Tests
this.buffer[ThreadIds.X] *= this.number;
}
}
[TestMethod]
public void ComputeShaderWithInheritedShaderInterface()
{
_ = ReflectionServices.GetShaderInfo<ComputeShaderWithInheritedShaderInterfaceShader>();
}
public interface IMyBaseShader : IComputeShader
{
public int A { get; }
public void B();
}
[AutoConstructor]
internal readonly partial struct ComputeShaderWithInheritedShaderInterfaceShader : IMyBaseShader
{
int IMyBaseShader.A { get; }
void IMyBaseShader.B()
{
}
public readonly ReadWriteBuffer<float> buffer;
public readonly float number;
/// <inheritdoc/>
public void Execute()
{
this.buffer[ThreadIds.X] *= this.number;
}
}
[TestMethod]
public void PixelShaderWithInheritedShaderInterface()
{
_ = ReflectionServices.GetShaderInfo<PixelShaderWithInheritedShaderInterfaceShader, float4>();
}
public interface IMyBaseShader<T> : IPixelShader<T>
where T : unmanaged
{
public int A { get; }
public void B();
}
[AutoConstructor]
internal readonly partial struct PixelShaderWithInheritedShaderInterfaceShader : IMyBaseShader<float4>
{
int IMyBaseShader<float4>.A { get; }
void IMyBaseShader<float4>.B()
{
}
public readonly float number;
/// <inheritdoc/>
public float4 Execute()
{
return default;
}
}
}
}