首页 > 解决方案 > 在金属的内核函数中水平翻转纹理

问题描述

我只需要使用金属中的核函数水平翻转纹理。这是我的内核。

kernel void compute(
                    texture2d<float,access::read> des [[texture(0)]],
                    texture2d<float, access::write> src [[texture(1)]],
                    uint2 gid [[thread_position_in_grid]])
{


    float4 flipColor = src.read(uint2(gid.x,1536 - gid.y));

    des.write(flipColor, gid);
}

这里源纹理是我需要翻转的纹理。我正在从源纹理读取并写入目标纹理。但它不能正常工作。(赋予透明质感)

原因是什么?请给个建议好吗?

标签: swiftmetalmetalkit

解决方案


推荐阅读