Metal: Add OOB coordinate rejection to image atomic functions

These should have been guarded but are not, creating
buffer out of bound access error on Apple devices.
This commit is contained in:
Clément Foucault 2025-01-31 16:17:58 +01:00
parent 636147053d
commit 651ae0e47c

View File

@ -666,30 +666,51 @@ void imageStoreFast(SamplerT texture, IntCoord coord, DataVec data)
IMAGE_FN AtomicT imageAtomicMin(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_min(coord, data);
}
IMAGE_FN AtomicT imageAtomicMax(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_max(coord, data);
}
IMAGE_FN AtomicT imageAtomicAdd(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_add(coord, data);
}
IMAGE_FN AtomicT imageAtomicAnd(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_and(coord, data);
}
IMAGE_FN AtomicT imageAtomicOr(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_or(coord, data);
}
IMAGE_FN AtomicT imageAtomicXor(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_xor(coord, data);
}
IMAGE_FN AtomicT imageAtomicExchange(SamplerT texture, IntCoord coord, AtomicT data)
{
if (any(UintCoord(coord) >= UintCoord(texture.size()))) {
return AtomicT(0);
}
return texture.atomic_exchange(coord, data);
}