When writing to out of bounds Coords for an unsampled image handle what happens? Say the image_mem_handle has width = w and height = h. And you attempt to write to w + 5 and h - 10(safe). So the width is out of bounds, but the height is not. Would that become a write or skipped? As its linearised position is in the segment.
My question boils down to if it is safe to write to an out-of-bounds coordinate or not. As I believe for CUDA surfaces, an attempt to write to a logical out-of-bounds location would result in no write (skip). So I wonder if I need to have explicit bounds checking for writing, or if I could write and rely on logical bounds checking, similarly to surfaces(if I have understood them correctly)
I want to read a value using clamp to edge and write back to that same position (to a different image_mem_handle) so I wonder if I need to explicitly clamp or not in that case?
Hi Jorgen.
Thanks for your question.
The current Bindless Images specification does not guarantee anything about writing to unsampled images with out-of-bounds coordinates. Doing this should be considered undefined behavior. Although I can see that the specification does not explicitly state this, which should be amended in future revisions of the specification.
This means that users have to check for out-of-bounds coordinates in cases where this may be a possibility.
Our current implementation for reading and writing to unsampled images for the CUDA backend uses clamp
, meaning that attempting to write to an unsampled image with an out-of-bounds coordinate should result in writing to the pixel closest to the out-of-bounds coordinate at the edge of the image.
However, this is not something that the specification guarantees, and due to the current experimental nature of the extension, this may change in the future.
Currently, the result of reading or writing out-of-bounds coordinates to unsampled images should be considered as undefined behavior, and the user should explicitly check for that in cases where this may occur.
1 Like