Merge pull request #934 from tmm1/tvos-fixups

tvOS fixups
This commit is contained in:
Bill Hollings 2020-06-29 13:43:10 -04:00 committed by GitHub
commit d79926a579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 9 deletions

View File

@ -443,7 +443,7 @@ static inline VkExtent3D mvkVkExtent3DFromMTLSize(MTLSize mtlSize) {
#define MVK_VK_MEMORY_TYPE_METAL_PRIVATE (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) #define MVK_VK_MEMORY_TYPE_METAL_PRIVATE (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
/** Macro indicating the Vulkan memory type bits corresponding to Metal shared memory (host visible and coherent). */ /** Macro indicating the Vulkan memory type bits corresponding to Metal shared memory (host visible and coherent). */
#define MVK_VK_MEMORY_TYPE_METAL_SHARED (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) #define MVK_VK_MEMORY_TYPE_METAL_SHARED (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT)
/** Macro indicating the Vulkan memory type bits corresponding to Metal managed memory (host visible and non-coherent). */ /** Macro indicating the Vulkan memory type bits corresponding to Metal managed memory (host visible and non-coherent). */
#define MVK_VK_MEMORY_TYPE_METAL_MANAGED (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT) #define MVK_VK_MEMORY_TYPE_METAL_MANAGED (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT)

View File

@ -52,7 +52,7 @@ VkResult MVKBuffer::getMemoryRequirements(VkMemoryRequirements* pMemoryRequireme
pMemoryRequirements->alignment = _byteAlignment; pMemoryRequirements->alignment = _byteAlignment;
} }
pMemoryRequirements->memoryTypeBits = _device->getPhysicalDevice()->getAllMemoryTypes(); pMemoryRequirements->memoryTypeBits = _device->getPhysicalDevice()->getAllMemoryTypes();
#if MVK_IOS #if MVK_IOS_OR_TVOS
// Memoryless storage is not allowed for buffers // Memoryless storage is not allowed for buffers
mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getLazilyAllocatedMemoryTypes()); mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getLazilyAllocatedMemoryTypes());
#endif #endif

View File

@ -41,7 +41,7 @@
using namespace std; using namespace std;
#if MVK_IOS #if MVK_IOS_OR_TVOS
# include <UIKit/UIKit.h> # include <UIKit/UIKit.h>
# define MVKViewClass UIView # define MVKViewClass UIView
#endif #endif
@ -425,7 +425,7 @@ VkResult MVKPhysicalDevice::getImageFormatProperties(VkFormat format,
} }
// Metal does not allow compressed or depth/stencil formats on 3D textures // Metal does not allow compressed or depth/stencil formats on 3D textures
if (mvkFmt == kMVKFormatDepthStencil if (mvkFmt == kMVKFormatDepthStencil
#if MVK_IOS #if MVK_IOS_OR_TVOS
|| mvkFmt == kMVKFormatCompressed || mvkFmt == kMVKFormatCompressed
#endif #endif
) { ) {
@ -643,7 +643,7 @@ VkResult MVKPhysicalDevice::getSurfaceFormats(MVKSurface* surface,
colorSpaces.push_back(VK_COLOR_SPACE_HDR10_HLG_EXT); colorSpaces.push_back(VK_COLOR_SPACE_HDR10_HLG_EXT);
} }
#endif #endif
#if MVK_IOS #if MVK_IOS_OR_TVOS
// iOS 8 doesn't support anything but sRGB. // iOS 8 doesn't support anything but sRGB.
if (mvkOSVersionIsAtLeast(9.0)) { if (mvkOSVersionIsAtLeast(9.0)) {
colorSpaces.push_back(VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT); colorSpaces.push_back(VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT);
@ -945,6 +945,7 @@ void MVKPhysicalDevice::initMetalFeatures() {
_metalFeatures.mtlCopyBufferAlignment = 1; _metalFeatures.mtlCopyBufferAlignment = 1;
_metalFeatures.texelBuffers = true; _metalFeatures.texelBuffers = true;
_metalFeatures.maxTextureDimension = (8 * KIBI); _metalFeatures.maxTextureDimension = (8 * KIBI);
_metalFeatures.dynamicMTLBufferSize = (4 * KIBI);
if (supportsMTLFeatureSet(tvOS_GPUFamily1_v2)) { if (supportsMTLFeatureSet(tvOS_GPUFamily1_v2)) {
_metalFeatures.mslVersionEnum = MTLLanguageVersion1_2; _metalFeatures.mslVersionEnum = MTLLanguageVersion1_2;
@ -959,6 +960,8 @@ void MVKPhysicalDevice::initMetalFeatures() {
if (supportsMTLFeatureSet(tvOS_GPUFamily1_v4)) { if (supportsMTLFeatureSet(tvOS_GPUFamily1_v4)) {
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_1; _metalFeatures.mslVersionEnum = MTLLanguageVersion2_1;
_metalFeatures.events = true;
_metalFeatures.textureBuffers = true;
} }
if (supportsMTLFeatureSet(tvOS_GPUFamily2_v1)) { if (supportsMTLFeatureSet(tvOS_GPUFamily2_v1)) {
@ -1407,7 +1410,7 @@ void MVKPhysicalDevice::initProperties() {
#if MVK_MACOS #if MVK_MACOS
_properties.limits.maxUniformBufferRange = (64 * KIBI); _properties.limits.maxUniformBufferRange = (64 * KIBI);
#endif #endif
#if MVK_IOS #if MVK_IOS_OR_TVOS
_properties.limits.maxUniformBufferRange = (uint32_t)_metalFeatures.maxMTLBufferSize; _properties.limits.maxUniformBufferRange = (uint32_t)_metalFeatures.maxMTLBufferSize;
#endif #endif
_properties.limits.maxStorageBufferRange = (uint32_t)_metalFeatures.maxMTLBufferSize; _properties.limits.maxStorageBufferRange = (uint32_t)_metalFeatures.maxMTLBufferSize;
@ -1500,6 +1503,18 @@ void MVKPhysicalDevice::initProperties() {
_texelBuffAlignProperties.uniformTexelBufferOffsetSingleTexelAlignment = VK_FALSE; _texelBuffAlignProperties.uniformTexelBufferOffsetSingleTexelAlignment = VK_FALSE;
} }
#if MVK_TVOS
_properties.limits.maxFragmentInputComponents = 60;
if (supportsMTLFeatureSet(tvOS_GPUFamily2_v1)) {
_properties.limits.optimalBufferCopyOffsetAlignment = 16;
} else {
_properties.limits.optimalBufferCopyOffsetAlignment = 64;
}
_properties.limits.maxTessellationGenerationLevel = 16;
_properties.limits.maxTessellationPatchSize = 32;
#endif
#if MVK_IOS #if MVK_IOS
_properties.limits.maxFragmentInputComponents = 60; _properties.limits.maxFragmentInputComponents = 60;
@ -1576,6 +1591,13 @@ void MVKPhysicalDevice::initProperties() {
if ( [_mtlDevice respondsToSelector: @selector(maxThreadgroupMemoryLength)] ) { if ( [_mtlDevice respondsToSelector: @selector(maxThreadgroupMemoryLength)] ) {
_properties.limits.maxComputeSharedMemorySize = (uint32_t)_mtlDevice.maxThreadgroupMemoryLength; _properties.limits.maxComputeSharedMemorySize = (uint32_t)_mtlDevice.maxThreadgroupMemoryLength;
} else { } else {
#if MVK_TVOS
if (supportsMTLFeatureSet(tvOS_GPUFamily2_v1)) {
_properties.limits.maxComputeSharedMemorySize = (16 * KIBI);
} else {
_properties.limits.maxComputeSharedMemorySize = ((16 * KIBI) - 32);
}
#endif
#if MVK_IOS #if MVK_IOS
if (supportsMTLFeatureSet(iOS_GPUFamily4_v1)) { if (supportsMTLFeatureSet(iOS_GPUFamily4_v1)) {
_properties.limits.maxComputeSharedMemorySize = (32 * KIBI); _properties.limits.maxComputeSharedMemorySize = (32 * KIBI);
@ -1903,7 +1925,7 @@ uint32_t MVKPhysicalDevice::getHighestMTLFeatureSet() {
// On newer OS's, combine highest Metal version with highest GPU family // On newer OS's, combine highest Metal version with highest GPU family
// (Mac & Apple GPU lists should be mutex on platform) // (Mac & Apple GPU lists should be mutex on platform)
uint32_t mtlVer = 0; uint32_t mtlVer = 0;
#if MVK_IOS #if MVK_IOS_OR_TVOS
if (mvkOSVersionIsAtLeast(13.0)) { mtlVer = 0x30000; } if (mvkOSVersionIsAtLeast(13.0)) { mtlVer = 0x30000; }
#endif #endif
#if MVK_MACOS #if MVK_MACOS
@ -2061,6 +2083,13 @@ void MVKPhysicalDevice::initMemoryProperties() {
typeIdx++; typeIdx++;
} }
#endif #endif
#if MVK_TVOS
if (supportsMTLFeatureSet(tvOS_GPUFamily1_v2)) {
memlessBit = 1 << typeIdx;
setMemoryType(typeIdx, mainHeapIdx, MVK_VK_MEMORY_TYPE_METAL_MEMORYLESS);
typeIdx++;
}
#endif
_memoryProperties.memoryTypeCount = typeIdx; _memoryProperties.memoryTypeCount = typeIdx;
@ -2097,7 +2126,7 @@ uint64_t MVKPhysicalDevice::getRecommendedMaxWorkingSetSize() {
return _mtlDevice.recommendedMaxWorkingSetSize; return _mtlDevice.recommendedMaxWorkingSetSize;
} }
#endif #endif
#if MVK_IOS #if MVK_IOS_OR_TVOS
// GPU and CPU use shared memory. Estimate the current free memory in the system. // GPU and CPU use shared memory. Estimate the current free memory in the system.
uint64_t freeMem = mvkGetAvailableMemorySize(); uint64_t freeMem = mvkGetAvailableMemorySize();
if (freeMem) { return freeMem; } if (freeMem) { return freeMem; }

View File

@ -583,7 +583,7 @@ VkResult MVKImage::getMemoryRequirements(VkMemoryRequirements* pMemoryRequiremen
mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getHostCoherentMemoryTypes()); mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getHostCoherentMemoryTypes());
} }
#endif #endif
#if MVK_IOS #if MVK_IOS_OR_TVOS
// Only transient attachments may use memoryless storage // Only transient attachments may use memoryless storage
if (!mvkAreAllFlagsEnabled(_usage, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) ) { if (!mvkAreAllFlagsEnabled(_usage, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) ) {
mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getLazilyAllocatedMemoryTypes()); mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getLazilyAllocatedMemoryTypes());