I declare a metal texture in Swift with format .bgra8Unorm
. Now in the metal compute kernel
I access it using the half
data type (I believe an Apple example did it this way).
texture2d<half, access::sample> inTexture [[ texture(0) ]]
Will accessing a bgra8Unorm
texture this way (via a sampler) and/or writing it back automatically pack and unpack half
values to and from 8 bit integers? What happens when I write a negative half
value to the texture?
Yes . When writing to a texture with normalized unsigned integer components, the values are effectively clamped to [0, 1], then scaled by the maximum value of the format (255, in this case).
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.