MVKSampler: Support LoD bias.
Metal actually supports this, but this is a hidden property of the `MTLSamplerDescriptor`. It's not part of the public API. Guard our use of it appropriately.
This commit is contained in:
parent
8d1303a57a
commit
f5d7190554
@ -21,6 +21,7 @@ Released TBD
|
||||
- Add `MVK_USE_METAL_PRIVATE_API` build setting to allow **MoltenVK** to be built with access to _Metal_ private API calls.
|
||||
- Add support for `VkPhysicalDeviceFeatures::wideLines` feature when `MVK_USE_METAL_PRIVATE_API` is enabled in a **MoltenVK** build.
|
||||
- Add support for the `VkPhysicalDeviceFeatures::logicOp` feature when `MVK_USE_METAL_PRIVATE_API` is enabled in a **MoltenVK** build.
|
||||
- Add support for the `VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias` feature when `MVK_USE_METAL_PRIVATE_API` is enabled in a **MoltenVK** build.
|
||||
- Fix potential crash when using multi-planar images.
|
||||
- Ensure buffers available for buffer addresses in push constants.
|
||||
- Support `libMoltenVK.dylib` for _iOS Simulator_ architecture.
|
||||
|
@ -366,7 +366,7 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
|
||||
portabilityFeatures->multisampleArrayImage = _metalFeatures.multisampleArrayTextures;
|
||||
portabilityFeatures->mutableComparisonSamplers = _metalFeatures.depthSampleCompare;
|
||||
portabilityFeatures->pointPolygons = false;
|
||||
portabilityFeatures->samplerMipLodBias = false;
|
||||
portabilityFeatures->samplerMipLodBias = getMVKConfig().useMetalPrivateAPI;
|
||||
portabilityFeatures->separateStencilMaskRef = true;
|
||||
portabilityFeatures->shaderSampleRateInterpolationFunctions = _metalFeatures.pullModelInterpolation;
|
||||
portabilityFeatures->tessellationIsolines = false;
|
||||
@ -2523,6 +2523,10 @@ void MVKPhysicalDevice::initLimits() {
|
||||
|
||||
_properties.limits.maxImageDimension3D = _metalFeatures.maxTextureLayers;
|
||||
_properties.limits.maxImageArrayLayers = _metalFeatures.maxTextureLayers;
|
||||
// Max sum of API and shader values. Bias not publicly supported in API, but can be applied in the shader directly.
|
||||
// The lack of API value is covered by VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias.
|
||||
// Metal does not specify a limit for the shader value, so choose something reasonable.
|
||||
_properties.limits.maxSamplerLodBias = getMVKConfig().useMetalPrivateAPI ? 16 : 4;
|
||||
_properties.limits.maxSamplerAnisotropy = 16;
|
||||
|
||||
_properties.limits.maxVertexInputAttributes = 31;
|
||||
@ -2799,11 +2803,6 @@ void MVKPhysicalDevice::initLimits() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Max sum of API and shader values. Bias not supported in API, but can be applied in shader directly.
|
||||
// The lack of API value is covered by VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias.
|
||||
// Metal does not specify limit for shader value, so choose something reasonable.
|
||||
_properties.limits.maxSamplerLodBias = 4;
|
||||
|
||||
_properties.limits.minTexelOffset = -8;
|
||||
_properties.limits.maxTexelOffset = 7;
|
||||
_properties.limits.minTexelGatherOffset = _properties.limits.minTexelOffset;
|
||||
|
@ -2198,6 +2198,11 @@ MTLSamplerDescriptor* MVKSampler::newMTLSamplerDescriptor(const VkSamplerCreateI
|
||||
mtlSampDesc.mipFilter = (pCreateInfo->unnormalizedCoordinates
|
||||
? MTLSamplerMipFilterNotMipmapped
|
||||
: mvkMTLSamplerMipFilterFromVkSamplerMipmapMode(pCreateInfo->mipmapMode));
|
||||
#if MVK_USE_METAL_PRIVATE_API
|
||||
if (getMVKConfig().useMetalPrivateAPI) {
|
||||
mtlSampDesc.lodBiasMVK = pCreateInfo->mipLodBias;
|
||||
}
|
||||
#endif
|
||||
mtlSampDesc.lodMinClamp = pCreateInfo->minLod;
|
||||
mtlSampDesc.lodMaxClamp = pCreateInfo->maxLod;
|
||||
mtlSampDesc.maxAnisotropy = (pCreateInfo->anisotropyEnable
|
||||
|
@ -41,4 +41,13 @@
|
||||
*/
|
||||
@property(nonatomic, readwrite) /*MTLSamplerBorderColor*/ NSUInteger borderColorMVK;
|
||||
|
||||
/**
|
||||
* Replacement for the lodBias property.
|
||||
*
|
||||
* This property allows support under all OS versions. Delegates to the lodBias
|
||||
* property if it is available. otherwise, returns 0 when read and
|
||||
* does nothing when set.
|
||||
*/
|
||||
@property(nonatomic, readwrite) float lodBiasMVK;
|
||||
|
||||
@end
|
||||
|
@ -21,6 +21,15 @@
|
||||
#include "MVKCommonEnvironment.h"
|
||||
|
||||
|
||||
#if MVK_USE_METAL_PRIVATE_API
|
||||
/** Additional methods not necessarily declared in <Metal/MTLSampler.h>. */
|
||||
@interface MTLSamplerDescriptor ()
|
||||
|
||||
@property(nonatomic, readwrite) float lodBias;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
@implementation MTLSamplerDescriptor (MoltenVK)
|
||||
|
||||
-(MTLCompareFunction) compareFunctionMVK {
|
||||
@ -45,4 +54,15 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MVK_USE_METAL_PRIVATE_API
|
||||
-(float) lodBiasMVK {
|
||||
if ( [self respondsToSelector: @selector(lodBias)] ) { return self.lodBias; }
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
-(void) setLodBiasMVK: (float) bias {
|
||||
if ( [self respondsToSelector: @selector(setLodBias:)] ) { self.lodBias = bias; }
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -329,6 +329,7 @@ included in any of the `make` command-line build commands [mentioned above](#com
|
||||
Functionality added with `MVK_USE_METAL_PRIVATE_API` enabled includes:
|
||||
- `VkPhysicalDeviceFeatures::wideLines`
|
||||
- `VkPhysicalDeviceFeatures::logicOp`
|
||||
- `VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias`
|
||||
|
||||
|
||||
<a name="demos"></a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user