ios - Metal 纹理格式

标签 ios metal

我在 Swift 中声明了一个 Metal 纹理,格式为 .bgra8Unorm。现在在 Metal 计算 kernel 中,我使用 half 数据类型访问它(我相信 Apple 示例就是这样做的)。

texture2d<half, access::sample> inTexture [[ texture(0) ]]

是否会以这种方式(通过采样器)访问 bgra8Unorm 纹理和/或将其写回自动将 half 值打包和解包为 8 位整数?当我向纹理写入一个负的 half 值时会发生什么?

最佳答案

Yes .当写入具有规范化无符号整数分量的纹理时,值被有效地限制在 [0, 1],然后按格式的最大值(在本例中为 255)缩放。

关于ios - Metal 纹理格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41140695/

相关文章:

ios - 如何最好地删除所有 UIViewcontroller 并转到单个 UIViewController?

ios - 导入动态创建的 Swift 类

ios - 您能否以编程方式检测 MPMoviePlayerController currentPlaybackTime 中的更改

ios - UIKit-[UIApplication sendAction :to:from:forEvent:] crash

ios - 在 Swift 的 UITableView 部分获取行的 [NSIndexPath] 数组

ios - 场景套件: Use multiple SCNView instances side by side

ios - 调整Apple的RayTracing Shader以获得更多反射

ios - 类型 'MTLBuffer' 的值没有成员 'didModifyRange'

iOS Metal Swift newComputePipelineStateWithFunction 不工作错误

ios - 使用 MTKView 显示 JPEG 图片