gpt4 book ai didi

ios - 关键字 "device"在Metal Shading Language中是什么意思

转载 作者:行者123 更新时间:2023-11-28 23:58:19 25 4
gpt4 key购买 nike

关键字“device”在 Metal Shading Language 中的含义是什么?如:

kernel void add_alps_2d_kernel(const device int *vector1 [[buffer(1)]],
device int vector2 [[buffer(2)]],
uint id [[ thread_position_in_grid ]]) {

}

最佳答案

根据language spec doc

Arguments to Metal graphics and kernel functions declared in a program that are pointers must be declared with the Metal device, threadgroup, threadgroup_imageblock, or constant address space attribute.

此外:

The device address space name refers to buffer memory objects allocated from the device memory pool that are both readable and writeable.

所以它是一个内存规范,指示指针所在的位置。请注意,在地址空间属性之前使用 const 表示它是只读的。您还可以在 Working with memory in Metal 中找到更多信息。

关于ios - 关键字 "device"在Metal Shading Language中是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50490040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com