|  | 
| 50 | 50 | 
 | 
| 51 | 51 | #import "metal_device_properties.h" | 
| 52 | 52 | 
 | 
|  | 53 | +#include "servers/rendering/renderer_rd/effects/metal_fx.h" | 
|  | 54 | + | 
| 53 | 55 | #import <Metal/Metal.h> | 
| 54 | 56 | #import <MetalFX/MetalFX.h> | 
| 55 | 57 | #import <spirv_cross.hpp> | 
|  | 
| 63 | 65 | #define MTLGPUFamilyApple9 (MTLGPUFamily)1009 | 
| 64 | 66 | #endif | 
| 65 | 67 | 
 | 
| 66 |  | -API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) | 
|  | 68 | +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), visionos(1.0)) | 
| 67 | 69 | MTLGPUFamily &operator--(MTLGPUFamily &p_family) { | 
| 68 | 70 | 	p_family = static_cast<MTLGPUFamily>(static_cast<int>(p_family) - 1); | 
| 69 | 71 | 	if (p_family < MTLGPUFamilyApple1) { | 
|  | 
| 126 | 128 | 
 | 
| 127 | 129 | 	if (@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) { | 
| 128 | 130 | 		features.metal_fx_spatial = [MTLFXSpatialScalerDescriptor supportsDevice:p_device]; | 
|  | 131 | +#ifdef METAL_MFXTEMPORAL_ENABLED | 
| 129 | 132 | 		features.metal_fx_temporal = [MTLFXTemporalScalerDescriptor supportsDevice:p_device]; | 
|  | 133 | +#else | 
|  | 134 | +		features.metal_fx_temporal = false; | 
|  | 135 | +#endif | 
| 130 | 136 | 	} | 
| 131 | 137 | 
 | 
| 132 | 138 | 	MTLCompileOptions *opts = [MTLCompileOptions new]; | 
|  | 
| 136 | 142 | 	features.mslVersion = SPIRV_CROSS_NAMESPACE::CompilerMSL::Options::make_msl_version(m_maj, m_min) | 
| 137 | 143 | 
 | 
| 138 | 144 | 	switch (features.mslVersionEnum) { | 
| 139 |  | -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000 || __TV_OS_VERSION_MAX_ALLOWED >= 180000 | 
|  | 145 | +#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 | 
| 140 | 146 | 		case MTLLanguageVersion3_2: | 
| 141 | 147 | 			setMSLVersion(3, 2); | 
| 142 | 148 | 			break; | 
|  | 
| 170 | 176 | 		case MTLLanguageVersion1_1: | 
| 171 | 177 | 			setMSLVersion(1, 1); | 
| 172 | 178 | 			break; | 
| 173 |  | -#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST | 
|  | 179 | +#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION | 
| 174 | 180 | 		case MTLLanguageVersion1_0: | 
| 175 | 181 | 			setMSLVersion(1, 0); | 
| 176 | 182 | 			break; | 
|  | 
| 324 | 330 | 
 | 
| 325 | 331 | 	limits.maxDrawIndexedIndexValue = std::numeric_limits<uint32_t>::max() - 1; | 
| 326 | 332 | 
 | 
|  | 333 | +#ifdef METAL_MFXTEMPORAL_ENABLED | 
| 327 | 334 | 	if (@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)) { | 
| 328 | 335 | 		limits.temporalScalerInputContentMinScale = (double)[MTLFXTemporalScalerDescriptor supportedInputContentMinScaleForDevice:p_device]; | 
| 329 | 336 | 		limits.temporalScalerInputContentMaxScale = (double)[MTLFXTemporalScalerDescriptor supportedInputContentMaxScaleForDevice:p_device]; | 
|  | 
| 332 | 339 | 		limits.temporalScalerInputContentMinScale = 1.0; | 
| 333 | 340 | 		limits.temporalScalerInputContentMaxScale = 3.0; | 
| 334 | 341 | 	} | 
|  | 342 | +#else | 
|  | 343 | +	// Defaults taken from macOS 14+ | 
|  | 344 | +	limits.temporalScalerInputContentMinScale = 1.0; | 
|  | 345 | +	limits.temporalScalerInputContentMaxScale = 3.0; | 
|  | 346 | +#endif | 
| 335 | 347 | } | 
| 336 | 348 | 
 | 
| 337 | 349 | MetalDeviceProperties::MetalDeviceProperties(id<MTLDevice> p_device) { | 
|  | 
0 commit comments