是否需要CPU-GPU同步,如果写入和阅读发生在MTLBuffer的不同存储页面上?
我正在使用金属中的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设使用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.