Add tvOS support
This commit is contained in:
parent
59d5fcfc9b
commit
f223c5af9f
|
@ -37,7 +37,10 @@
|
|||
#define DAWN_PLATFORM_APPLE 1
|
||||
#define DAWN_PLATFORM_POSIX 1
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_OS_TV
|
||||
#define DAWN_PLATFORM_TVOS
|
||||
#define DAWN_PLATFORM_IOS
|
||||
#elif TARGET_OS_IPHONE
|
||||
#define DAWN_PLATFORM_IOS
|
||||
#elif TARGET_OS_MAC
|
||||
#define DAWN_PLATFORM_MACOS
|
||||
|
|
|
@ -355,9 +355,17 @@ if (DAWN_ENABLE_METAL)
|
|||
"metal/UtilsMetal.h"
|
||||
"metal/UtilsMetal.mm"
|
||||
)
|
||||
if (NOT IOS AND NOT TVOS)
|
||||
target_link_libraries(dawn_native PRIVATE
|
||||
"-framework Cocoa"
|
||||
)
|
||||
endif ()
|
||||
if (NOT TVOS)
|
||||
target_link_libraries(dawn_native PRIVATE
|
||||
"-framework IOKit"
|
||||
)
|
||||
endif ()
|
||||
target_link_libraries(dawn_native PRIVATE
|
||||
"-framework IOSurface"
|
||||
"-framework QuartzCore"
|
||||
"-framework Metal"
|
||||
|
|
|
@ -248,7 +248,7 @@ DAWN_NOINLINE bool IsGPUCounterSupported(id<MTLDevice> device,
|
|||
}
|
||||
}
|
||||
|
||||
if (@available(macOS 11.0, iOS 14.0, *)) {
|
||||
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
|
||||
// Check whether it can read GPU counters at the specified command boundary. Apple
|
||||
// family GPUs do not support sampling between different Metal commands, because
|
||||
// they defer fragment processing until after the GPU processes all the primitives
|
||||
|
@ -315,7 +315,7 @@ class Adapter : public AdapterBase {
|
|||
mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
|
||||
}
|
||||
#endif
|
||||
#if defined(DAWN_PLATFORM_IOS)
|
||||
#if defined(DAWN_PLATFORM_IOS) && !defined(DAWN_PLATFORM_TVOS)
|
||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) {
|
||||
mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2);
|
||||
}
|
||||
|
@ -404,6 +404,14 @@ class Adapter : public AdapterBase {
|
|||
ResultOrError<MTLGPUFamily> GetMTLGPUFamily() const {
|
||||
// https://developer.apple.com/documentation/metal/mtldevice/detecting_gpu_features_and_metal_software_versions?language=objc
|
||||
|
||||
#if defined(DAWN_PLATFORM_TVOS)
|
||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1]) {
|
||||
return MTLGPUFamily::Apple3;
|
||||
}
|
||||
if ([*mDevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily1_v1]) {
|
||||
return MTLGPUFamily::Apple2;
|
||||
}
|
||||
#else
|
||||
if (@available(macOS 10.15, iOS 10.13, *)) {
|
||||
if ([*mDevice supportsFamily:MTLGPUFamilyMac2]) {
|
||||
return MTLGPUFamily::Mac2;
|
||||
|
@ -433,6 +441,7 @@ class Adapter : public AdapterBase {
|
|||
return MTLGPUFamily::Apple1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
if (@available(macOS 10.14, *)) {
|
||||
|
|
|
@ -163,6 +163,8 @@ void Device::InitTogglesFromDriver() {
|
|||
haveStoreAndMSAAResolve =
|
||||
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
|
||||
}
|
||||
#elif defined(DAWN_PLATFORM_TVOS)
|
||||
haveStoreAndMSAAResolve = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1];
|
||||
#elif defined(DAWN_PLATFORM_IOS)
|
||||
haveStoreAndMSAAResolve = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2];
|
||||
#endif
|
||||
|
@ -170,14 +172,19 @@ void Device::InitTogglesFromDriver() {
|
|||
SetToggle(Toggle::EmulateStoreAndMSAAResolve, !haveStoreAndMSAAResolve);
|
||||
|
||||
bool haveSamplerCompare = true;
|
||||
#if defined(DAWN_PLATFORM_IOS)
|
||||
#if defined(DAWN_PLATFORM_TVOS)
|
||||
haveSamplerCompare = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1];
|
||||
#elif defined(DAWN_PLATFORM_IOS)
|
||||
haveSamplerCompare = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
|
||||
#endif
|
||||
// TODO(crbug.com/dawn/342): Investigate emulation -- possibly expensive.
|
||||
SetToggle(Toggle::MetalDisableSamplerCompare, !haveSamplerCompare);
|
||||
|
||||
bool haveBaseVertexBaseInstance = true;
|
||||
#if defined(DAWN_PLATFORM_IOS)
|
||||
#if defined(DAWN_PLATFORM_TVOS)
|
||||
haveBaseVertexBaseInstance =
|
||||
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1];
|
||||
#elif defined(DAWN_PLATFORM_IOS)
|
||||
haveBaseVertexBaseInstance =
|
||||
[*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
|
||||
#endif
|
||||
|
@ -201,7 +208,7 @@ void Device::InitTogglesFromDriver() {
|
|||
// TODO(crbug.com/dawn/847): Use MTLStorageModeShared instead of MTLStorageModePrivate when
|
||||
// creating MTLCounterSampleBuffer in QuerySet on Intel platforms, otherwise it fails to
|
||||
// create the buffer. Change to use MTLStorageModePrivate when the bug is fixed.
|
||||
if (@available(macOS 10.15, iOS 14.0, *)) {
|
||||
if (@available(macOS 10.15, iOS 14.0, tvOS 14.0, *)) {
|
||||
bool useSharedMode = gpu_info::IsIntel(vendorId);
|
||||
SetToggle(Toggle::MetalUseSharedModeForCounterSampleBuffer, useSharedMode);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ MaybeError QuerySet::Initialize() {
|
|||
break;
|
||||
}
|
||||
case wgpu::QueryType::PipelineStatistics:
|
||||
if (@available(macOS 10.15, iOS 14.0, *)) {
|
||||
if (@available(macOS 10.15, iOS 14.0, tvOS 14.0, *)) {
|
||||
DAWN_TRY_ASSIGN(mCounterSampleBuffer,
|
||||
CreateCounterSampleBuffer(device, MTLCommonCounterSetStatistic,
|
||||
GetQueryCount()));
|
||||
|
@ -95,7 +95,7 @@ MaybeError QuerySet::Initialize() {
|
|||
}
|
||||
break;
|
||||
case wgpu::QueryType::Timestamp:
|
||||
if (@available(macOS 10.15, iOS 14.0, *)) {
|
||||
if (@available(macOS 10.15, iOS 14.0, tvOS 14.0, *)) {
|
||||
DAWN_TRY_ASSIGN(mCounterSampleBuffer,
|
||||
CreateCounterSampleBuffer(device, MTLCommonCounterSetTimestamp,
|
||||
GetQueryCount()));
|
||||
|
@ -129,7 +129,7 @@ void QuerySet::DestroyImpl() {
|
|||
|
||||
// mCounterSampleBuffer isn't an NSRef because API_AVAILABLE doesn't work will with
|
||||
// templates.
|
||||
if (@available(macOS 10.15, iOS 14.0, *)) {
|
||||
if (@available(macOS 10.15, iOS 14.0, tvOS 14.0, *)) {
|
||||
[mCounterSampleBuffer release];
|
||||
mCounterSampleBuffer = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue