如何在金属着色语言中定义结构字段类型?
How to define struct field type in Metal Shading Language?
不清楚如何定义struct字段的ref或ptr类型?
struct uint128_t {
uint64_t lo;
uint64_t hi;
device uint64_t& operator[](int i) {
return (i == 0) ? lo : hi;
}
...
}
Reference to type 'device uint64_t' (aka 'device unsigned long') could not bind to an lvalue of type 'uint64_t' (aka 'unsigned long')
您需要为函数本身指定地址 space。否则,你不能使用 address-space 特定的东西。
正确的定义如下:
struct uint128_t {
uint64_t lo;
uint64_t hi;
device uint64_t& operator[](int i) device {
return (i == 0) ? lo : hi;
}
};
不清楚如何定义struct字段的ref或ptr类型?
struct uint128_t {
uint64_t lo;
uint64_t hi;
device uint64_t& operator[](int i) {
return (i == 0) ? lo : hi;
}
...
}
Reference to type 'device uint64_t' (aka 'device unsigned long') could not bind to an lvalue of type 'uint64_t' (aka 'unsigned long')
您需要为函数本身指定地址 space。否则,你不能使用 address-space 特定的东西。
正确的定义如下:
struct uint128_t {
uint64_t lo;
uint64_t hi;
device uint64_t& operator[](int i) device {
return (i == 0) ? lo : hi;
}
};