diff --git a/src/dawn_native/metal/BackendMTL.mm b/src/dawn_native/metal/BackendMTL.mm index a52536e890..646a387bac 100644 --- a/src/dawn_native/metal/BackendMTL.mm +++ b/src/dawn_native/metal/BackendMTL.mm @@ -28,7 +28,6 @@ namespace dawn_native { namespace metal { namespace { -#if defined(DAWN_PLATFORM_MACOS) struct PCIIDs { uint32_t vendorId; uint32_t deviceId; @@ -39,6 +38,7 @@ namespace dawn_native { namespace metal { uint32_t vendorId; }; +#if defined(DAWN_PLATFORM_MACOS) const Vendor kVendors[] = {{"AMD", kVendorID_AMD}, {"Radeon", kVendorID_AMD}, {"Intel", kVendorID_Intel}, @@ -158,7 +158,8 @@ namespace dawn_native { namespace metal { #elif defined(DAWN_PLATFORM_IOS) MaybeError GetDevicePCIInfo(id device, PCIIDs* ids) { DAWN_UNUSED(device); - *ids = PCIIDs(0, 0); + *ids = PCIIDs{0, 0}; + return {}; } bool IsMetalSupported() { @@ -183,11 +184,17 @@ namespace dawn_native { namespace metal { mPCIInfo.deviceId = ids.deviceId; }; +#if defined(DAWN_PLATFORM_IOS) + mDeviceType = DeviceType::IntegratedGPU; +#elif defined(DAWN_PLATFORM_MACOS) if ([device isLowPower]) { mDeviceType = DeviceType::IntegratedGPU; } else { mDeviceType = DeviceType::DiscreteGPU; } +#else +# error "Unsupported Apple platform." +#endif InitializeSupportedExtensions(); } @@ -201,9 +208,11 @@ namespace dawn_native { namespace metal { return {new Device(this, mDevice, descriptor)}; } void InitializeSupportedExtensions() { +#if defined(DAWN_PLATFORM_MACOS) if ([mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) { mSupportedExtensions.EnableExtension(Extension::TextureCompressionBC); } +#endif } id mDevice = nil; @@ -221,6 +230,7 @@ namespace dawn_native { namespace metal { std::vector> adapters; if (@available(macOS 10.11, *)) { +#if defined(DAWN_PLATFORM_MACOS) NSArray>* devices = MTLCopyAllDevices(); for (id device in devices) { @@ -228,10 +238,13 @@ namespace dawn_native { namespace metal { } [devices release]; +#endif } else if (@available(iOS 8.0, *)) { +#if defined(DAWN_PLATFORM_IOS) // iOS only has a single device so MTLCopyAllDevices doesn't exist there. adapters.push_back( std::make_unique(GetInstance(), MTLCreateSystemDefaultDevice())); +#endif } else { UNREACHABLE(); } diff --git a/src/dawn_native/metal/DeviceMTL.mm b/src/dawn_native/metal/DeviceMTL.mm index 04e9d5f347..bacc529ab0 100644 --- a/src/dawn_native/metal/DeviceMTL.mm +++ b/src/dawn_native/metal/DeviceMTL.mm @@ -76,11 +76,13 @@ namespace dawn_native { namespace metal { } void Device::InitTogglesFromDriver() { +#if defined(DAWN_PLATFORM_MACOS) if (@available(macOS 10.12, *)) { bool emulateStoreAndMSAAResolve = ![mMtlDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2]; SetToggle(Toggle::EmulateStoreAndMSAAResolve, emulateStoreAndMSAAResolve); } +#endif // TODO(jiawei.shao@intel.com): check iOS feature sets diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index ffe56a8185..12bbc73fe7 100644 --- a/src/dawn_native/metal/TextureMTL.mm +++ b/src/dawn_native/metal/TextureMTL.mm @@ -214,6 +214,7 @@ namespace dawn_native { namespace metal { case dawn::TextureFormat::Depth24PlusStencil8: return MTLPixelFormatDepth32Float_Stencil8; +#if defined(DAWN_PLATFORM_MACOS) case dawn::TextureFormat::BC1RGBAUnorm: return MTLPixelFormatBC1_RGBA; case dawn::TextureFormat::BC1RGBAUnormSrgb: @@ -242,6 +243,7 @@ namespace dawn_native { namespace metal { return MTLPixelFormatBC7_RGBAUnorm; case dawn::TextureFormat::BC7RGBAUnormSrgb: return MTLPixelFormatBC7_RGBAUnorm_sRGB; +#endif default: UNREACHABLE();