Sergio0694/ComputeSharp

Invalid diagnostic for shader types with explicit descriptor implementation

Sergio0694 opened this issue · 0 comments

Description

The descriptor interface check is incorrect for shader types, as it's trying to compare the unbounded generic interface type against the actual interface implemented by the shader type, which will be a constructed generic type for the shader type itself as type argument.

Reproduction Steps

internal readonly partial struct HelloWorld : ID2D1PixelShader, ID2D1PixelShaderDescriptor<HelloWorld>
{
    static ref readonly Guid ID2D1PixelShaderDescriptor<HelloWorld>.EffectId => throw new NotImplementedException();

    static string? ID2D1PixelShaderDescriptor<HelloWorld>.EffectDisplayName => throw new NotImplementedException();

    static string? ID2D1PixelShaderDescriptor<HelloWorld>.EffectDescription => throw new NotImplementedException();

    static string? ID2D1PixelShaderDescriptor<HelloWorld>.EffectCategory => throw new NotImplementedException();

    static string? ID2D1PixelShaderDescriptor<HelloWorld>.EffectAuthor => throw new NotImplementedException();

    static int ID2D1PixelShaderDescriptor<HelloWorld>.ConstantBufferSize => throw new NotImplementedException();

    static int ID2D1PixelShaderDescriptor<HelloWorld>.InputCount => throw new NotImplementedException();

    static int ID2D1PixelShaderDescriptor<HelloWorld>.ResourceTextureCount => throw new NotImplementedException();

    static ReadOnlyMemory<D2D1PixelShaderInputType> ID2D1PixelShaderDescriptor<HelloWorld>.InputTypes => throw new NotImplementedException();

    static ReadOnlyMemory<D2D1InputDescription> ID2D1PixelShaderDescriptor<HelloWorld>.InputDescriptions => throw new NotImplementedException();

    static ReadOnlyMemory<D2D1ResourceTextureDescription> ID2D1PixelShaderDescriptor<HelloWorld>.ResourceTextureDescriptions => throw new NotImplementedException();

    static D2D1PixelOptions ID2D1PixelShaderDescriptor<HelloWorld>.PixelOptions => throw new NotImplementedException();

    static D2D1BufferPrecision ID2D1PixelShaderDescriptor<HelloWorld>.BufferPrecision => throw new NotImplementedException();

    static D2D1ChannelDepth ID2D1PixelShaderDescriptor<HelloWorld>.ChannelDepth => throw new NotImplementedException();

    static D2D1ShaderProfile ID2D1PixelShaderDescriptor<HelloWorld>.ShaderProfile => throw new NotImplementedException();

    static D2D1CompileOptions ID2D1PixelShaderDescriptor<HelloWorld>.CompileOptions => throw new NotImplementedException();

    static string ID2D1PixelShaderDescriptor<HelloWorld>.HlslSource => throw new NotImplementedException();

    static ReadOnlyMemory<byte> ID2D1PixelShaderDescriptor<HelloWorld>.HlslBytecode => throw new NotImplementedException();

    static HelloWorld ID2D1PixelShaderDescriptor<HelloWorld>.CreateFromConstantBuffer(ReadOnlySpan<byte> buffer)
    {
        throw new NotImplementedException();
    }

    static void ID2D1PixelShaderDescriptor<HelloWorld>.LoadConstantBuffer<TLoader>(in HelloWorld shader, ref TLoader loader)
    {
        throw new NotImplementedException();
    }

    public float4 Execute()
    {
        return 0;
    }
}

Equivalent steps for a DX12 compute shader as well.

Expected Behavior

No warning should be produced.

Actual Behavior

Either CMPSD2D0065 or CMPS0053 is produced on the shader type.