【问题标题】:Metal texture format bgra8Unorm_srgb non-writable on Metal Family 2 GPU金属纹理格式 bgra8Unorm_srgb 在 Metal Family 2 GPU 上不可写
【发布时间】:2022-01-02 14:39:44
【问题描述】:

我正在将带有MTLPixelFormat.bgra8Unorm_srgb 的纹理传递给计算着色器,该着色器具有该纹理的texture2d<float, access::write>。我收到以下错误:

  • validateComputeFunctionArguments:818: failed assertion Compute Function(rescaleTexture): Non-writeable texture format MTLPixelFormat.BGRA8Unorm_sRGB is being bound at index 1 to a shader argument with write access enabled.

我有一个“Metal Family 2 GPU”(Intel Iris Plus Graphics 640,Metal family: Supported, Metal GPUFamily macOS 2),根据 Apple 文档,纹理带有 @987654324 @pixel 格式应该是可写的。

我做错了什么?

这是我用来创建纹理的(部分)代码:

let desc = MTLTextureDescriptor.texture2DDescriptor(
    pixelFormat: MTLPixelFormat.bgra8Unorm_srgb,
    width: outputTextureWidth,
    height: outputTextureHeight,
    mipmapped: false)
desc.usage = [.shaderRead, .shaderWrite]
let tex = device.makeTexture(descriptor: desc)

这是(部分)着色器代码:

kernel void
rescaleTexture(texture2d<float, access::sample> source [[texture(0)]],
               texture2d<float, access::write> target [[texture(1)]],
               uint2 id [[thread_position_in_grid]])
{
    if (id.x >= target.get_width() || id.y >= target.get_height()) {
        return;
    }

    const float u = (float)id.x / (target.get_width () - 1);
    const float v = (float)id.y / (target.get_height () - 1);

    target.write (source.sample (sampler_linear_no_mipmap, float2 (u, v)), id);
}

【问题讨论】:

    标签: gpu shader intel metal


    【解决方案1】:

    根据The Metal Feature Set TablesMTLGPUFamilyMac2处理器的BGRA8Unorm_sRGB纹理格式,具有以下能力:

    • 过滤器
    • 颜色
    • MSAA
    • 解决
    • 混合

    这意味着 BGRA8Unorm_sRGB 格式的纹理无法被您设备上的函数写入。

    【讨论】:

    • 谢谢!我正在查看 MTLGPUFamilyApple2 而不是 MTLGPUFamilyMac2 的文档!
    • @akuz 不客气。
    猜你喜欢
    • 1970-01-01
    • 2019-02-14
    • 1970-01-01
    • 2016-07-08
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    • 1970-01-01
    • 2017-06-14
    相关资源
    最近更新 更多