1

私はUp and Running with Metal, Part 2を進めており、利用可能な最高の言語機能を使用してすべてのコードを書き直す方法を学ぼうとしています。これらの機能の 1 つは C++ コンストラクターです。Cg と GLSL に欠けていたシェーダーで使用できることを非常に嬉しく思います。

このコードはデバイス上で問題なく動作しますが、次の警告が表示されます。

'vertex_main' には C リンケージが指定されていますが、C と互換性のないユーザー定義型 'ColoredVertex' を返します

それは問題ですか?Cリンケージが指定されている理由がわかりません。また、問題がなければ、バグを報告するとともに、警告を無効にする方法もわかりません。これは私がやりたいことです。

using namespace metal;

struct ColoredVertex {
    const float4 position [[position]];
    const half4 color;

    ColoredVertex(const float4 position, const half4 color)
    : position(position), color(color) {}
};

vertex ColoredVertex vertex_main(
    constant float4 *position [[buffer(0)]],
    constant float4 *color [[buffer(1)]],
    uint vid [[vertex_id]]
) {return ColoredVertex(position[vid], half4(color[vid]));}

fragment half4 fragment_main(ColoredVertex vert [[stage_in]]) {
    return vert.color;
}
4

1 に答える 1