是否需要CPU-GPU同步,如果写入和阅读发生在MTLBuffer的不同存储页面上?

发布于 2025-02-12 09:31:11 字数 465 浏览 1 评论 0原文

我正在使用金属中的mtlbuffer,通过将几个内存页面(使用vm_allocate)与

device.makebuffer(bytesnocopy:length:genthent:option:delectlocator:)分配。

我用CPU编写缓冲区,而GPU仅读取它。我知道通常需要在CPU和GPU之间同步。

但是,我对MTLBuffer写入(由CPU)中的位置有更多的了解,并在我的情况下(由GPU)读取(在我的情况下,写入与读取(在给定的时间间隔)中不同。

我的问题:即使编写和读取的相关数据在不同的内存页面上(但在同一mtlbuffer中),我是否需要在CPU和GPU之间进行同步?直觉上,我想不认为,但是mtlbuffer有点不透明,我真的不知道GPU实际上/对mtlbuffer的处理/需求是什么样的。

附加信息:这是iOS的问题,共享了mtlstoragemode。

非常感谢您的帮助!

I am using an MTLBuffer in Metal that I created by allocating several memory pages (using vm_allocate) with

device.makeBuffer(bytesNoCopy:length:options:deallocator:).

I write the buffer with CPU and the GPU only reads it. I know that generally I need to synchronise between CPU and GPU.

However, I have more knowledge about where in the MTLBuffer write (by CPU) and read (by GPU) happens and in my case writing is into different memory pages than the read (in a given time interval).

My question: Do I need to sync between CPU and GPU even if the relevant data that is written and read are on different memory pages (but in the same MTLBuffer)? Intuitively, I would think not, but then MTLBuffer is a bit opaque and I don't really know what kind of processing/requirement the GPU actually does/has with the MTLBuffer.

Additional info: This is a question for iOS and MTLStorageMode is shared.

Thank you very much for help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九歌凝 2025-02-19 09:31:11

假设使用mtlstoragemodemaned创建缓冲区,则可以使用该函数

Assuming the buffer was created with MTLStorageModeManaged, you can use the function didModifyRange to sync CPU to GPU for only a portion (a page for example) of the buffer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文