金属纹理格式 bgra8Unorm_srgb 在 Metal Family 2 GPU 上不可写
Metal texture format bgra8Unorm_srgb non-writable on Metal Family 2 GPU
我将带有 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 系列:支持,Metal GPUFamily macOS 2),根据 Apple 文档, MTLPixelFormat.BGRA8Unorm_sRGB
像素格式的纹理应该是可写的。
我做错了什么?
这是我用来创建纹理的(部分)代码:
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);
}
根据The Metal Feature Set Tables:
BGRA8Unorm_sRGBMTLGPUFamilyMac2处理器的纹理格式,具有以下能力:
- 过滤器
- 颜色
- MSAA
- 解决
- 混合
这意味着格式为 BGRA8Unorm_sRGB 的纹理无法通过您设备上的函数写入。
我将带有 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 系列:支持,Metal GPUFamily macOS 2),根据 Apple 文档, MTLPixelFormat.BGRA8Unorm_sRGB
像素格式的纹理应该是可写的。
我做错了什么?
这是我用来创建纹理的(部分)代码:
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);
}
根据The Metal Feature Set Tables: BGRA8Unorm_sRGBMTLGPUFamilyMac2处理器的纹理格式,具有以下能力:
- 过滤器
- 颜色
- MSAA
- 解决
- 混合
这意味着格式为 BGRA8Unorm_sRGB 的纹理无法通过您设备上的函数写入。