【问题标题】:Interpolation of 3d textures in Metal kernel functions not working on Radeon gpu金属内核函数中的 3d 纹理插值不适用于 Radeon gpu
【发布时间】:2016-11-24 21:18:42
【问题描述】:

我最近购买了配备 Radeon 445 gpu 的 2016 年末 MacBook Pro,现在我遇到了在 iOS 和配备 Nvidia gpu 的 El Capitan 上运行良好的内核功能。似乎 3D 纹理没有在 Z 轴上插值,即使我这样指定我的采样器:

constexpr sampler s = sampler(coord::normalized,
                              address::repeat,
                              filter::linear);

问题在这张图片中非常明显:

我尝试使用以下方法强制 Intel Iris 图形(集成):

NSArray *devices = MTLCopyAllDevices();
device = devices[1];

代替

device = MTLCreateSystemDefaultDevice();

但这根本没有给我一个上下文,即使

device = devices[0];

工作得很好。

我尝试在内核中从半数切换到浮点数,但没有任何不同的结果。

更新:正如 Ken 下面建议的那样,在 cpu 上创建采样器状态并将其作为制服传递似乎可以解决问题:

MTLSamplerDescriptor *samplerDescriptor = [MTLSamplerDescriptor new];
samplerDescriptor.minFilter = MTLSamplerMinMagFilterLinear;
samplerDescriptor.magFilter = MTLSamplerMinMagFilterLinear;
samplerDescriptor.sAddressMode = MTLSamplerAddressModeRepeat;
samplerDescriptor.tAddressMode = MTLSamplerAddressModeRepeat;
samplerDescriptor.rAddressMode = MTLSamplerAddressModeRepeat;
id<MTLSamplerState> sampler = [device newSamplerStateWithDescriptor:samplerDescriptor];
[commandEncoder setSamplerState:sampler atIndex:0];

在着色器中:

sampler s [[sampler(0)]]

我仍然非常有兴趣了解 constexpr 采样器在 3 维的 Radeon 硬件上失败的原因和时间。

【问题讨论】:

  • 如果您还没有尝试,请尝试:分别指定 min_filtermag_filter 和(也许)mip_filter,而不是 filter。试试bicubic 而不是linear 看看它是否重要。尝试创建一个 MTLSamplerState 对象并通过 API 传递它,而不是在着色器代码中定义的采样器。
  • 按照您的建议在 CPU 上创建 MTLSamplerState 可以解决问题。谢谢!知道为什么,或者这是一个已知的错误吗?
  • bicubic 没有定义我想,至少我不能访问它。
  • 我很高兴能解决这个问题。我不知道为什么,而且我以前没有遇到过这个问题。这只是黑暗中的一个镜头。关于bicubic,我是从 Metal Shader Language 规范中得到的,但也没有尝试过。

标签: ios macos metal


【解决方案1】:

显然,创建一个 MTLSamplerState 对象并通过 API 传递它而不是在着色器代码中定义的采样器可以解决这个问题。

【讨论】:

  • 我可以确认,但我无法在 RG8Uint 纹理上进行插值,即使传递采样器状态对象也是如此。解决方法现在使用 RG16float。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 2013-05-07
  • 2018-04-25
  • 2013-08-29
  • 2017-03-13
相关资源
最近更新 更多