Swift 5中的金属顶点着色器警告

吉兹莫多

我从Apple的示例代码中获得了使用的直通顶点着色器:

vertex VertexIO vertexPassThrough(device packed_float4 *pPosition  [[ buffer(0) ]],
                                  device packed_float2 *pTexCoords [[ buffer(1) ]],
                                  uint                  vid        [[ vertex_id ]])
{
    VertexIO outVertex;

    outVertex.position = pPosition[vid];
    outVertex.textureCoord = pTexCoords[vid];

    return outVertex;
}

这在Swift 4 / Xcode 10 / iOS 12中起作用。现在,我在Swift 5 / Xcode 11 / iOS 13中收到以下警告:

writable resources in non-void vertex function
Trojanfoe

您需要确保着色器只能从这些缓冲区读取,因此您需要将声明更改为const device

vertex VertexIO vertexPassThrough(const device packed_float4 *pPosition  [[ buffer(0) ]],
                                  const device packed_float2 *pTexCoords [[ buffer(1) ]],
                                  uint                  vid        [[ vertex_id ]])
{
...
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章