简体   繁体   中英

Read/Write same MTLTexture on iOS

The texture2d access::read_write qualifier seems only available on OSX. Is there a way to read/write the same texture inside a kernel (or other) metal function?

The reason is the written texture values may not be final and can be updated by other threads.

Thanks for the hint @warrenm. It works using an atomic buffer

device atomic_uint *buf [[ buffer(0) ]]

performing following steps:

  1. I initialize my atomic buffer in a separate kernel function that runs before the operation
  2. The next kernel computes a min value for a specific coordinate using atomic_fetch_min_explicit(buf[pos], val, memory_order_relaxed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM