ios - Metal Shader 顶点属性 - 无法将属性从 MTLAttributeFormatUInt 转换为 float1
问题描述
我有一个看起来像这样的着色器:
struct VertexIn {
float a_customIdx [[attribute(0)]];
...
};
vertex vec4 vertex_func(VertexIn v_in [[stage_in]], ...) {...}
在我的缓冲区中,我实际上传递了一个uint32_t
for a_customIdx
,所以在我的缓冲区中,MTLVertexAttributeDescriptor
我将其类型指定为MTLAttributeFormatUInt
。当我创建RenderPipelineState
我得到错误:
cannot convert attribute from MTLAttributeFormatUInt to float1
如果我使用 . 我会得到相同的错误MTLAttributeFormatInt
,但可以成功转换MTLAttributeFormatUShort
.
为什么这不是一个有效的操作?根据format 的文档,“将任何 MTLVertexFormat 转换为 float 或 half 是有效的”。
我知道有多种方法可以解决这个问题,但我很好奇为什么这是无效的——也许我在这里遗漏了一些关于对齐和字节大小的东西。
解决方案
推荐阅读
- laravel - 在字符串 laravel 5.8 上调用成员函数 all()
- javascript - 链接和按钮未对齐
- android - 如何从 alertdialog 更改 mainactivity 中的可见性编辑文本
- python-3.x - 从 numpy 数组中删除列表并只有数组
- log4j - 如何在大型项目中配置 log4j 2
- routing - 如何让 Next JS 动态路由与 RelayJS 一起使用
- clojure - 保证某个未知值在序列中的惯用方法是什么?
- java - java.lang.UnsupportedClassVersionError:如何使用较新版本的 Java Runtime 运行代码
- powerbi - DAX 等价于 SQL 语句
- ruby-on-rails - 如何指定转换表名称。全球化