TL;DR: メタルは、頂点シェーダーが返すものを検出していないようです
MSL で記述された次の 2 つの関数があります。
vertex float4 base_image_rect(constant float4 *pos [[buffer(0)]],
uint vid [[vertex_id]]) {
return pos[vid];
}
fragment float4 fragment_image_display(float4 vPos [[stage_in]],
texture2d<float, access::sample> imageToRender [[texture(0)]],
sampler imageSampler [[sampler(0)]]) {
return imageToRender.sample(imageSampler, float2(vPos.x, vPos.y));
}
このコードを使用して、それらでレンダー パイプラインの状態を作成しようとすると、次のようになります。
// Make image display render pipeline state
let imageDisplayStateDescriptor = MTLRenderPipelineDescriptor()
imageDisplayStateDescriptor.colorAttachments[0].pixelFormat = view.colorPixelFormat
imageDisplayStateDescriptor.vertexFunction = library.makeFunction(name: "base_image_rect")
imageDisplayStateDescriptor.fragmentFunction = library.makeFunction(name: "fragment_image_display")
displayImagePipelineState = try! device.makeRenderPipelineState(descriptor: imageDisplayStateDescriptor)
パイプライン状態の作成時にエラーがあります:
致命的なエラー: 「試してください!」式で予期せずエラーが発生しました: エラー Domain=CompilerError Code=1 "Link failed: fragment input vPos was not found in vertex shader outputs " [...]
コードを確認して再確認しましたが、何が問題なのか理解できません。
何か案は?ありがとうございました!