小编jam*_*lor的帖子

金属从顶点函数写入缓冲区

我正在构建一个在Metal中渲染2D几何体的应用程序.

现在,顶点的位置从顶点函数内求解.我想要的是将解决的位置从相同的顶点函数内部写回缓冲区.

我的印象是这是可能的,尽管在我第一次尝试这样做时,即:

vertex VertexOut basic_vertex(device VertexIn *vertices [[ buffer(0) ]],
                              device VertexOut *solvedVertices [[ buffer(1) ]],
                              vid [[ vertex_id ]])
{
    VertexIn in vertices[vid];
    VertexOut out;
    out.position = ... // Solve the position of the vertex 

    solvedVertices[vid] = out // Write to the buffer later to be read by CPU

    return out;
}
Run Code Online (Sandbox Code Playgroud)

我遇到了这个编译时错误:

在此输入图像描述

好吧,所以我想到了一些解决方案 - 我可以解决第一个顶点位置 - 非光栅化 - 通过一个声明如下的顶点函数:

vertex void solve_vertex(device VertexIn *unsolved [[ buffer(0) ]],
                         device VertexOut *solved [[ buffer(1) ]],
                         vid [[ …
Run Code Online (Sandbox Code Playgroud)

metal

6
推荐指数
1
解决办法
1251
查看次数

标签 统计

metal ×1