MVKDevice: Correct some more features and limits.

Actually turn on the `layeredRendering` feature for A12 on iOS. This
should actually allow clients to take advantage of that on A12 devices.

Turn on the `variableMultisampleRate` and `inheritedQueries` features.
`variableMultisampleRate` means that pipelines with no attachments may
have different sample counts. Since no-attachment pipelines are
emulated, we don't have that limitation anyway. If and when Metal gains
real support for no-attachment pipelines, we may have to revisit this.

`inheritedQueries` means that queries may apply to secondary command
buffers as well as primary commands. Secondary command buffers are also
emulated, and should by virtue of being inlined into the primary's
`MTLCommandBuffer` inherit any query-related state.

Use the `maxBufferLength` property of `MTLDevice` when available to get
the true maximum buffer size. (This is one of the "secret" properties in
earlier versions of Metal. It finally became a public, supported API in
Metal 2.1.)

Limit the number of dual-source blending color attachments to 1. This is
a documented limitation of Metal 1.2. I don't know if Metal 2 or 2.1
have lifted this restriction.

Indicate that this implementation uses the standard sample locations.
For Metal, these are actually documented in "Using Programmable Sample
Positions," which discusses setting custom sample locations. The default
sample locations given there are all consistent with the standard
locations documented in the Vulkan spec.
This commit is contained in:
Chip Davis 2019-01-25 00:54:00 -06:00
parent 601acf6884
commit 34c7f6c09c

View File

@ -694,6 +694,10 @@ void MVKPhysicalDevice::initMetalFeatures() {
_metalFeatures.arrayOfSamplers = true;
}
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1] ) {
_metalFeatures.layeredRendering = true;
}
#endif
#if MVK_MACOS
@ -731,6 +735,10 @@ void MVKPhysicalDevice::initMetalFeatures() {
#endif
if ( [_mtlDevice respondsToSelector: @selector(maxBufferLength)] ) {
_metalFeatures.maxMTLBufferSize = _mtlDevice.maxBufferLength;
}
for (uint32_t sc = VK_SAMPLE_COUNT_1_BIT; sc <= VK_SAMPLE_COUNT_64_BIT; sc <<= 1) {
if ([_mtlDevice supportsTextureSampleCount: mvkSampleCountFromVkSampleCountFlagBits((VkSampleCountFlagBits)sc)]) {
_metalFeatures.supportedSampleCounts |= sc;
@ -761,6 +769,8 @@ void MVKPhysicalDevice::initFeatures() {
_features.shaderClipDistance = true;
_features.shaderInt16 = true;
_features.multiDrawIndirect = true;
_features.variableMultisampleRate = true;
_features.inheritedQueries = true;
_features.shaderSampledImageArrayDynamicIndexing = _metalFeatures.arrayOfTextures;
_features.shaderStorageImageArrayDynamicIndexing = _metalFeatures.arrayOfTextures;
@ -873,8 +883,8 @@ void MVKPhysicalDevice::initFeatures() {
// VkBool32 sparseResidency8Samples;
// VkBool32 sparseResidency16Samples;
// VkBool32 sparseResidencyAliased;
// VkBool32 variableMultisampleRate;
// VkBool32 inheritedQueries;
// VkBool32 variableMultisampleRate; // done
// VkBool32 inheritedQueries; // done
//} VkPhysicalDeviceFeatures;
/** Initializes the physical device properties of this instance. */
@ -900,7 +910,16 @@ void MVKPhysicalDevice::initProperties() {
#endif
_properties.limits.maxFragmentOutputAttachments = _properties.limits.maxColorAttachments;
_properties.limits.maxFragmentDualSrcAttachments = _properties.limits.maxFragmentOutputAttachments;
#if MVK_IOS
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v4] ) {
_properties.limits.maxFragmentDualSrcAttachments = 1;
} else {
_properties.limits.maxFragmentDualSrcAttachments = 0;
}
#endif
#if MVK_MACOS
_properties.limits.maxFragmentDualSrcAttachments = 1;
#endif
_properties.limits.framebufferColorSampleCounts = _metalFeatures.supportedSampleCounts;
_properties.limits.framebufferDepthSampleCounts = _metalFeatures.supportedSampleCounts;
@ -917,15 +936,11 @@ void MVKPhysicalDevice::initProperties() {
_properties.limits.maxImageDimensionCube = _metalFeatures.maxTextureDimension;
_properties.limits.maxFramebufferWidth = _metalFeatures.maxTextureDimension;
_properties.limits.maxFramebufferHeight = _metalFeatures.maxTextureDimension;
#if MVK_IOS
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1] ) {
if ( _metalFeatures.layeredRendering ) {
_properties.limits.maxFramebufferLayers = 256;
} else {
_properties.limits.maxFramebufferLayers = 1;
}
#else
_properties.limits.maxFramebufferLayers = 256;
#endif
_properties.limits.maxViewportDimensions[0] = _metalFeatures.maxTextureDimension;
_properties.limits.maxViewportDimensions[1] = _metalFeatures.maxTextureDimension;
@ -1016,7 +1031,7 @@ void MVKPhysicalDevice::initProperties() {
_properties.limits.lineWidthRange[1] = 1;
_properties.limits.pointSizeGranularity = 1;
_properties.limits.standardSampleLocations = VK_FALSE;
_properties.limits.standardSampleLocations = VK_TRUE;
_properties.limits.strictLines = VK_FALSE;
VkExtent3D wgSize = mvkVkExtent3DFromMTLSize(_mtlDevice.maxThreadsPerThreadgroup);