【发布时间】:2017-05-24 08:02:11
【问题描述】:
TL;DR:Metal 似乎无法检测到我的顶点着色器返回的内容
我有这两个用 MSL 写的函数:
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 "链接失败:片段输入 vPos 不是 在顶点着色器输出中找到" [...]
我检查并重新检查了代码,但无法理解问题所在。
有什么想法吗?谢谢!
【问题讨论】:
标签: metal metalanguage