Jason Leach Jason Leach - 1 year ago 129
iOS Question

What are Apple's Metal (Metal Shader Language) texture coordinates?

In iOS or OS/X what texture coordinates are used in Metal Shader Language kernel function? For example, given an

uint2 gid[[thread_position_in_grid]]
between 0..1 (x and y are floats) or 0..
(x and y are integers).

Thanks in Advance

Answer Source

thread_position_in_grid is an index (an integer) in the grid that takes values in the ranges you specify in dispatchThreadgroups:threadsPerThreadgroup:. It's up to you to decide how many thread groups you want, and how many threads per group.

In the following sample code you can see that threadsPerGroup.width * numThreadgroups.width == inputImage.width and threadsPerGroup.height * numThreadgroups.height == inputImage.height. In this case, a position in the grid will thus be a non-normalized (integer) pixel coordinate.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download