diff --git a/src/modules/graphics/metal/Graphics.h b/src/modules/graphics/metal/Graphics.h index d735349ce..a949aa250 100644 --- a/src/modules/graphics/metal/Graphics.h +++ b/src/modules/graphics/metal/Graphics.h @@ -137,6 +137,8 @@ class Graphics final : public love::graphics::Graphics id getCachedSampler(const SamplerState &s); + bool isDepthCompareSamplerSupported() const; + StreamBuffer *getUniformBuffer() const { return uniformBuffer; } Buffer *getDefaultAttributesBuffer() const { return defaultAttributesBuffer; } diff --git a/src/modules/graphics/metal/Graphics.mm b/src/modules/graphics/metal/Graphics.mm index 0f960652b..a89c6d5fe 100644 --- a/src/modules/graphics/metal/Graphics.mm +++ b/src/modules/graphics/metal/Graphics.mm @@ -810,7 +810,7 @@ static bool isClampOne(SamplerState::WrapMode w) desc.lodMinClamp = s.minLod; desc.lodMaxClamp = s.maxLod; - // TODO: This isn't supported on some older iOS devices... + // This isn't supported on some older iOS devices. Texture code checks for support. if (s.depthSampleMode.hasValue) desc.compareFunction = getMTLCompareFunction(s.depthSampleMode.value); @@ -822,6 +822,11 @@ static bool isClampOne(SamplerState::WrapMode w) return sampler; }} +bool Graphics::isDepthCompareSamplerSupported() const +{ + return families.mac[1] || families.macCatalyst[1] || families.apple[3]; +} + id Graphics::getCachedDepthStencilState(const DepthState &depth, const StencilState &stencil) { uint64 key = (depth.compare << 0) | ((uint32)depth.write << 8) diff --git a/src/modules/graphics/metal/Texture.mm b/src/modules/graphics/metal/Texture.mm index d9b07f67e..ee84998e1 100644 --- a/src/modules/graphics/metal/Texture.mm +++ b/src/modules/graphics/metal/Texture.mm @@ -339,6 +339,9 @@ static MTLTextureType getMTLTextureType(TextureType type, int msaa) void Texture::setSamplerState(const SamplerState &s) { @autoreleasepool { + if (s.depthSampleMode.hasValue && !Graphics::getInstance()->isDepthCompareSamplerSupported()) + throw love::Exception("Depth comparison sampling in shaders is not supported on this system."); + // Base class does common validation and assigns samplerState. love::graphics::Texture::setSamplerState(s);