Introduce 'visionos' platform derived from 'apple_embedded'
This commit is contained in:
@ -50,6 +50,8 @@
|
||||
|
||||
#import "metal_device_properties.h"
|
||||
|
||||
#include "servers/rendering/renderer_rd/effects/metal_fx.h"
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
#import <MetalFX/MetalFX.h>
|
||||
#import <spirv_cross.hpp>
|
||||
@ -63,7 +65,7 @@
|
||||
#define MTLGPUFamilyApple9 (MTLGPUFamily)1009
|
||||
#endif
|
||||
|
||||
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), visionos(1.0))
|
||||
MTLGPUFamily &operator--(MTLGPUFamily &p_family) {
|
||||
p_family = static_cast<MTLGPUFamily>(static_cast<int>(p_family) - 1);
|
||||
if (p_family < MTLGPUFamilyApple1) {
|
||||
@ -126,7 +128,11 @@ void MetalDeviceProperties::init_features(id<MTLDevice> p_device) {
|
||||
|
||||
if (@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
|
||||
features.metal_fx_spatial = [MTLFXSpatialScalerDescriptor supportsDevice:p_device];
|
||||
#ifdef METAL_MFXTEMPORAL_ENABLED
|
||||
features.metal_fx_temporal = [MTLFXTemporalScalerDescriptor supportsDevice:p_device];
|
||||
#else
|
||||
features.metal_fx_temporal = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
MTLCompileOptions *opts = [MTLCompileOptions new];
|
||||
@ -136,7 +142,7 @@ void MetalDeviceProperties::init_features(id<MTLDevice> p_device) {
|
||||
features.mslVersion = SPIRV_CROSS_NAMESPACE::CompilerMSL::Options::make_msl_version(m_maj, m_min)
|
||||
|
||||
switch (features.mslVersionEnum) {
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000 || __TV_OS_VERSION_MAX_ALLOWED >= 180000
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000 || __TV_OS_VERSION_MAX_ALLOWED >= 180000 || __VISION_OS_VERSION_MAX_ALLOWED >= 20000
|
||||
case MTLLanguageVersion3_2:
|
||||
setMSLVersion(3, 2);
|
||||
break;
|
||||
@ -170,7 +176,7 @@ void MetalDeviceProperties::init_features(id<MTLDevice> p_device) {
|
||||
case MTLLanguageVersion1_1:
|
||||
setMSLVersion(1, 1);
|
||||
break;
|
||||
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
|
||||
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
|
||||
case MTLLanguageVersion1_0:
|
||||
setMSLVersion(1, 0);
|
||||
break;
|
||||
@ -324,6 +330,7 @@ void MetalDeviceProperties::init_limits(id<MTLDevice> p_device) {
|
||||
|
||||
limits.maxDrawIndexedIndexValue = std::numeric_limits<uint32_t>::max() - 1;
|
||||
|
||||
#ifdef METAL_MFXTEMPORAL_ENABLED
|
||||
if (@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)) {
|
||||
limits.temporalScalerInputContentMinScale = (double)[MTLFXTemporalScalerDescriptor supportedInputContentMinScaleForDevice:p_device];
|
||||
limits.temporalScalerInputContentMaxScale = (double)[MTLFXTemporalScalerDescriptor supportedInputContentMaxScaleForDevice:p_device];
|
||||
@ -332,6 +339,11 @@ void MetalDeviceProperties::init_limits(id<MTLDevice> p_device) {
|
||||
limits.temporalScalerInputContentMinScale = 1.0;
|
||||
limits.temporalScalerInputContentMaxScale = 3.0;
|
||||
}
|
||||
#else
|
||||
// Defaults taken from macOS 14+
|
||||
limits.temporalScalerInputContentMinScale = 1.0;
|
||||
limits.temporalScalerInputContentMaxScale = 3.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
MetalDeviceProperties::MetalDeviceProperties(id<MTLDevice> p_device) {
|
||||
|
||||
@ -114,6 +114,9 @@ bool PixelFormats::isSupportedOrSubstitutable(DataFormat p_format) {
|
||||
}
|
||||
|
||||
bool PixelFormats::isPVRTCFormat(MTLPixelFormat p_format) {
|
||||
#if defined(VISIONOS_ENABLED)
|
||||
return false;
|
||||
#else
|
||||
switch (p_format) {
|
||||
case MTLPixelFormatPVRTC_RGBA_2BPP:
|
||||
case MTLPixelFormatPVRTC_RGBA_2BPP_sRGB:
|
||||
@ -127,6 +130,7 @@ bool PixelFormats::isPVRTCFormat(MTLPixelFormat p_format) {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MTLFormatType PixelFormats::getFormatType(DataFormat p_format) {
|
||||
@ -668,11 +672,13 @@ void PixelFormats::initMTLPixelFormatCapabilities() {
|
||||
addMTLPixelFormatDesc(RGBA32Sint, Color128, RWC);
|
||||
addMTLPixelFormatDesc(RGBA32Float, Color128, All);
|
||||
|
||||
#if !defined(VISIONOS_ENABLED)
|
||||
// Compressed pixel formats
|
||||
addMTLPixelFormatDesc(PVRTC_RGBA_2BPP, PVRTC_RGBA_2BPP, RF);
|
||||
addMTLPixelFormatDescSRGB(PVRTC_RGBA_2BPP_sRGB, PVRTC_RGBA_2BPP, RF, PVRTC_RGBA_2BPP);
|
||||
addMTLPixelFormatDesc(PVRTC_RGBA_4BPP, PVRTC_RGBA_4BPP, RF);
|
||||
addMTLPixelFormatDescSRGB(PVRTC_RGBA_4BPP_sRGB, PVRTC_RGBA_4BPP, RF, PVRTC_RGBA_4BPP);
|
||||
#endif
|
||||
|
||||
addMTLPixelFormatDesc(ETC2_RGB8, ETC2_RGB8, RF);
|
||||
addMTLPixelFormatDescSRGB(ETC2_RGB8_sRGB, ETC2_RGB8, RF, ETC2_RGB8);
|
||||
|
||||
@ -290,7 +290,11 @@ RDD::TextureID RenderingDeviceDriverMetal::texture_create(const TextureFormat &p
|
||||
// Usage.
|
||||
|
||||
MTLResourceOptions options = 0;
|
||||
#if defined(VISIONOS_ENABLED)
|
||||
const bool supports_memoryless = true;
|
||||
#else
|
||||
const bool supports_memoryless = (*device_properties).features.highestFamily >= MTLGPUFamilyApple2 && (*device_properties).features.highestFamily < MTLGPUFamilyMac1;
|
||||
#endif
|
||||
if (supports_memoryless && p_format.usage_bits & TEXTURE_USAGE_TRANSIENT_BIT) {
|
||||
options = MTLResourceStorageModeMemoryless | MTLResourceHazardTrackingModeTracked;
|
||||
desc.storageMode = MTLStorageModeMemoryless;
|
||||
@ -2493,7 +2497,11 @@ RDD::ShaderID RenderingDeviceDriverMetal::shader_create_from_bytecode(const Vect
|
||||
cd->name = binary_data.shader_name;
|
||||
cd->stage = shader_data.stage;
|
||||
options.preserveInvariance = shader_data.is_position_invariant;
|
||||
#if defined(VISIONOS_ENABLED)
|
||||
options.mathMode = MTLMathModeFast;
|
||||
#else
|
||||
options.fastMathEnabled = YES;
|
||||
#endif
|
||||
MDLibrary *library = [MDLibrary newLibraryWithCacheEntry:cd
|
||||
device:device
|
||||
source:source
|
||||
|
||||
Reference in New Issue
Block a user