user187676
user187676

Reputation:

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.

Upvotes: 3

Views: 1572

Answers (1)

user187676
user187676

Reputation:

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)

Upvotes: 1

Related Questions