基于金属着色语言规范中的一个例子:
Example:
struct Foo {
float4 a [[color(0)]];
int4 b [[color(1)]];
};
kernel void
my_kernel(imageblock<Foo, imageblock_layout_implicit> img_blk,
ushort2 lid [[thread_index_in_threadgroup]] …)
{
…
Foo f = img_blk.read(lid); float4 r = f.a;
…
f.a = r;
…
img_blk.write(f, lid);
}
作为图像块别名颜色附件的成员,我认为在“imgblk.write(.)”之后图像块将被写入相应的颜色附件。
我在苹果的例子中做了这个实验:正面加瓷砖遮阳,我尝试使用imageblock.write(..)写在瓷砖着色器的颜色附件上,但是我得到了非常奇怪的结果:
无论如何,感觉imageblock.write()在瓷砖着色器中不能正常工作。或者如何正确使用它?
发布于 2020-06-02 19:33:54
解决了,有几件事情导致了我得到的奇怪结果: 1.颜色格式为srgb 2。示例项目使用的numSamples为4 3。我没有指定imageblock_data_rate就完成了图像块写入。
在多采样的情况下,需要读取/写入每个示例的图像块。
https://stackoverflow.com/questions/62152169
复制相似问题