Browse Source
Fixes [CMP-6807](https://youtrack.jetbrains.com/issue/CMP-6807/Add-iOS-target-to-our-own-benchmarks)pull/4977/merge v1.8.0+dev1981
Nikita Lipsky
2 days ago
committed by
GitHub
43 changed files with 801 additions and 175 deletions
@ -0,0 +1,98 @@
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl |
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack |
||||
|
||||
plugins { |
||||
kotlin("multiplatform") |
||||
id("org.jetbrains.kotlin.plugin.compose") |
||||
id("org.jetbrains.compose") |
||||
} |
||||
|
||||
version = "1.0-SNAPSHOT" |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
google() |
||||
mavenCentral() |
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") |
||||
} |
||||
|
||||
kotlin { |
||||
jvm("desktop") |
||||
|
||||
listOf( |
||||
iosX64(), |
||||
iosArm64(), |
||||
iosSimulatorArm64() |
||||
).forEach { iosTarget -> |
||||
iosTarget.binaries.framework { |
||||
baseName = "benchmarks" |
||||
isStatic = true |
||||
} |
||||
} |
||||
|
||||
listOf( |
||||
macosX64(), |
||||
macosArm64() |
||||
).forEach { macosTarget -> |
||||
macosTarget.binaries { |
||||
executable { |
||||
entryPoint = "main" |
||||
} |
||||
} |
||||
} |
||||
|
||||
@OptIn(ExperimentalWasmDsl::class) |
||||
wasmJs { |
||||
binaries.executable() |
||||
browser () |
||||
} |
||||
|
||||
sourceSets { |
||||
val commonMain by getting { |
||||
dependencies { |
||||
implementation(compose.ui) |
||||
implementation(compose.foundation) |
||||
implementation(compose.material) |
||||
implementation(compose.runtime) |
||||
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) |
||||
implementation(compose.components.resources) |
||||
} |
||||
} |
||||
|
||||
val desktopMain by getting { |
||||
dependencies { |
||||
implementation(compose.desktop.currentOs) |
||||
runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.7.1") |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
compose.desktop { |
||||
application { |
||||
mainClass = "Main_desktopKt" |
||||
} |
||||
} |
||||
|
||||
val runArguments: String? by project |
||||
|
||||
// Handle runArguments property |
||||
gradle.taskGraph.whenReady { |
||||
tasks.named<JavaExec>("run") { |
||||
args(runArguments?.split(" ") ?: listOf<String>()) |
||||
} |
||||
tasks.forEach { t -> |
||||
if ((t is Exec) && t.name.startsWith("runReleaseExecutableMacos")) { |
||||
t.args(runArguments?.split(" ") ?: listOf<String>()) |
||||
} |
||||
} |
||||
tasks.named<KotlinWebpack>("wasmJsBrowserProductionRun") { |
||||
val args = runArguments?.split(" ") |
||||
?.mapIndexed { index, arg -> "arg$index=$arg" } |
||||
?.joinToString("&") ?: "" |
||||
|
||||
devServerProperty = devServerProperty.get().copy( |
||||
open = "http://localhost:8080?$args" |
||||
) |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
import kotlinx.cinterop.ExperimentalForeignApi |
||||
import kotlinx.cinterop.objcPtr |
||||
import org.jetbrains.skia.BackendRenderTarget |
||||
import org.jetbrains.skia.ColorSpace |
||||
import org.jetbrains.skia.DirectContext |
||||
import org.jetbrains.skia.PixelGeometry |
||||
import org.jetbrains.skia.Surface |
||||
import org.jetbrains.skia.SurfaceColorFormat |
||||
import org.jetbrains.skia.SurfaceOrigin |
||||
import org.jetbrains.skia.SurfaceProps |
||||
import platform.Metal.MTLCreateSystemDefaultDevice |
||||
import platform.Metal.MTLPixelFormatBGRA8Unorm |
||||
import platform.Metal.MTLTextureDescriptor |
||||
import platform.Metal.MTLTextureType2D |
||||
import platform.Metal.MTLTextureUsageRenderTarget |
||||
import platform.Metal.MTLTextureUsageShaderRead |
||||
import platform.Metal.MTLTextureUsageShaderWrite |
||||
import kotlin.coroutines.resume |
||||
import kotlin.coroutines.suspendCoroutine |
||||
|
||||
@OptIn(ExperimentalForeignApi::class) |
||||
fun graphicsContext() = object : GraphicsContext { |
||||
private val device = MTLCreateSystemDefaultDevice() ?: throw IllegalStateException("Can't create MTLDevice") |
||||
private val commandQueue = device.newCommandQueue() ?: throw IllegalStateException("Can't create MTLCommandQueue") |
||||
private val directContext = DirectContext.makeMetal(device.objcPtr(), commandQueue.objcPtr()) |
||||
private var cachedSurface: Surface? = null |
||||
|
||||
override fun surface(width: Int, height: Int): Surface { |
||||
val oldSurface = cachedSurface |
||||
|
||||
if (oldSurface != null && oldSurface.width == width && oldSurface.height == height) { |
||||
return oldSurface |
||||
} |
||||
|
||||
val descriptor = MTLTextureDescriptor() |
||||
descriptor.width = width.toULong() |
||||
descriptor.height = height.toULong() |
||||
descriptor.usage = MTLTextureUsageShaderRead or MTLTextureUsageShaderWrite or MTLTextureUsageRenderTarget |
||||
descriptor.textureType = MTLTextureType2D |
||||
descriptor.pixelFormat = MTLPixelFormatBGRA8Unorm |
||||
descriptor.mipmapLevelCount = 1UL |
||||
|
||||
val texture = device.newTextureWithDescriptor(descriptor) ?: throw IllegalStateException("Can't create MTLTexture") |
||||
|
||||
val renderTarget = BackendRenderTarget.makeMetal(width, height, texture.objcPtr()) |
||||
|
||||
return Surface.makeFromBackendRenderTarget( |
||||
directContext, |
||||
renderTarget, |
||||
SurfaceOrigin.TOP_LEFT, |
||||
SurfaceColorFormat.BGRA_8888, |
||||
ColorSpace.sRGB, |
||||
SurfaceProps(pixelGeometry = PixelGeometry.UNKNOWN) |
||||
).also { |
||||
cachedSurface = it |
||||
} ?: throw IllegalStateException("Can't create Surface") |
||||
} |
||||
|
||||
override suspend fun awaitGPUCompletion() { |
||||
val commandBuffer = commandQueue.commandBuffer() ?: return |
||||
|
||||
suspendCoroutine { continuation -> |
||||
commandBuffer.addCompletedHandler { |
||||
continuation.resume(Unit) |
||||
} |
||||
|
||||
commandBuffer.commit() |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
/* |
||||
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
import kotlinx.coroutines.runBlocking |
||||
|
||||
fun main(args : List<String>) { |
||||
Args.parseArgs(args.toTypedArray()) |
||||
runBlocking { runBenchmarks(graphicsContext = graphicsContext()) } |
||||
} |
@ -0,0 +1,10 @@
|
||||
/* |
||||
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
import kotlinx.coroutines.runBlocking |
||||
|
||||
fun main(args : Array<String>) { |
||||
Args.parseArgs(args) |
||||
runBlocking { runBenchmarks(graphicsContext = graphicsContext()) } |
||||
} |
@ -1,101 +1,15 @@
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack |
||||
|
||||
plugins { |
||||
kotlin("multiplatform") |
||||
id("org.jetbrains.kotlin.plugin.compose") |
||||
id("org.jetbrains.compose") |
||||
// this is necessary to avoid the plugins to be loaded multiple times |
||||
// in each subproject's classloader |
||||
kotlin("multiplatform") apply false |
||||
kotlin("plugin.compose") apply false |
||||
id("org.jetbrains.compose") apply false |
||||
} |
||||
|
||||
version = "1.0-SNAPSHOT" |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
allprojects { |
||||
repositories { |
||||
google() |
||||
mavenCentral() |
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") |
||||
} |
||||
|
||||
kotlin { |
||||
jvm("desktop") |
||||
macosX64 { |
||||
binaries { |
||||
executable { |
||||
entryPoint = "main" |
||||
} |
||||
} |
||||
} |
||||
macosArm64 { |
||||
binaries { |
||||
executable { |
||||
entryPoint = "main" |
||||
} |
||||
} |
||||
} |
||||
|
||||
wasmJs { |
||||
binaries.executable() |
||||
browser () |
||||
} |
||||
|
||||
sourceSets { |
||||
val commonMain by getting { |
||||
dependencies { |
||||
implementation(compose.ui) |
||||
implementation(compose.foundation) |
||||
implementation(compose.material) |
||||
implementation(compose.runtime) |
||||
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) |
||||
implementation(compose.components.resources) |
||||
} |
||||
} |
||||
|
||||
val desktopMain by getting { |
||||
dependencies { |
||||
implementation(compose.desktop.currentOs) |
||||
runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.7.1") |
||||
} |
||||
} |
||||
|
||||
val nativeMain by creating { |
||||
dependsOn(commonMain) |
||||
} |
||||
val macosMain by creating { |
||||
dependsOn(nativeMain) |
||||
} |
||||
val macosX64Main by getting { |
||||
dependsOn(macosMain) |
||||
} |
||||
val macosArm64Main by getting { |
||||
dependsOn(macosMain) |
||||
} |
||||
} |
||||
} |
||||
|
||||
compose.desktop { |
||||
application { |
||||
mainClass = "Main_desktopKt" |
||||
} |
||||
} |
||||
|
||||
val runArguments: String? by project |
||||
|
||||
// Handle runArguments property |
||||
gradle.taskGraph.whenReady { |
||||
tasks.named<JavaExec>("run") { |
||||
args(runArguments?.split(" ") ?: listOf<String>()) |
||||
} |
||||
tasks.forEach { t -> |
||||
if ((t is Exec) && t.name.startsWith("runReleaseExecutableMacos")) { |
||||
t.args(runArguments?.split(" ") ?: listOf<String>()) |
||||
} |
||||
} |
||||
tasks.named<KotlinWebpack>("wasmJsBrowserProductionRun") { |
||||
val args = runArguments?.split(" ") |
||||
?.mapIndexed { index, arg -> "arg$index=$arg" } |
||||
?.joinToString("&") ?: "" |
||||
|
||||
devServerProperty = devServerProperty.get().copy( |
||||
open = "http://localhost:8080?$args" |
||||
) |
||||
} |
||||
} |
||||
|
@ -0,0 +1,3 @@
|
||||
TEAM_ID= |
||||
BUNDLE_ID=org.jetbrains.benchmarks |
||||
APP_NAME=ComposeBenchmarks |
@ -0,0 +1,382 @@
|
||||
// !$*UTF8*$! |
||||
{ |
||||
archiveVersion = 1; |
||||
classes = { |
||||
}; |
||||
objectVersion = 50; |
||||
objects = { |
||||
|
||||
/* Begin PBXBuildFile section */ |
||||
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; |
||||
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; |
||||
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; |
||||
7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; |
||||
/* End PBXBuildFile section */ |
||||
|
||||
/* Begin PBXFileReference section */ |
||||
058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; |
||||
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; |
||||
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; }; |
||||
7555FF7B242A565900829871 /* ComposeBenchmarks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ComposeBenchmarks.app; sourceTree = BUILT_PRODUCTS_DIR; }; |
||||
7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; |
||||
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; |
||||
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; |
||||
/* End PBXFileReference section */ |
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */ |
||||
F85CB1118929364A9C6EFABC /* Frameworks */ = { |
||||
isa = PBXFrameworksBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
files = ( |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 0; |
||||
}; |
||||
/* End PBXFrameworksBuildPhase section */ |
||||
|
||||
/* Begin PBXGroup section */ |
||||
058557D7273AAEEB004C7B11 /* Preview Content */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, |
||||
); |
||||
path = "Preview Content"; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
7555FF72242A565900829871 = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
AB1DB47929225F7C00F7AF9C /* Configuration */, |
||||
7555FF7D242A565900829871 /* iosApp */, |
||||
7555FF7C242A565900829871 /* Products */, |
||||
); |
||||
sourceTree = "<group>"; |
||||
}; |
||||
7555FF7C242A565900829871 /* Products */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
7555FF7B242A565900829871 /* ComposeBenchmarks.app */, |
||||
); |
||||
name = Products; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
7555FF7D242A565900829871 /* iosApp */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
058557BA273AAA24004C7B11 /* Assets.xcassets */, |
||||
7555FF82242A565900829871 /* ContentView.swift */, |
||||
7555FF8C242A565B00829871 /* Info.plist */, |
||||
2152FB032600AC8F00CF470E /* iOSApp.swift */, |
||||
058557D7273AAEEB004C7B11 /* Preview Content */, |
||||
); |
||||
path = iosApp; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
AB1DB47929225F7C00F7AF9C /* Configuration */ = { |
||||
isa = PBXGroup; |
||||
children = ( |
||||
AB3632DC29227652001CCB65 /* Config.xcconfig */, |
||||
); |
||||
path = Configuration; |
||||
sourceTree = "<group>"; |
||||
}; |
||||
/* End PBXGroup section */ |
||||
|
||||
/* Begin PBXNativeTarget section */ |
||||
7555FF7A242A565900829871 /* iosApp */ = { |
||||
isa = PBXNativeTarget; |
||||
buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; |
||||
buildPhases = ( |
||||
05E104082A8AADF800D11C3D /* Compile Kotlin */, |
||||
7555FF77242A565900829871 /* Sources */, |
||||
7555FF79242A565900829871 /* Resources */, |
||||
F85CB1118929364A9C6EFABC /* Frameworks */, |
||||
); |
||||
buildRules = ( |
||||
); |
||||
dependencies = ( |
||||
); |
||||
name = iosApp; |
||||
productName = iosApp; |
||||
productReference = 7555FF7B242A565900829871 /* ComposeBenchmarks.app */; |
||||
productType = "com.apple.product-type.application"; |
||||
}; |
||||
/* End PBXNativeTarget section */ |
||||
|
||||
/* Begin PBXProject section */ |
||||
7555FF73242A565900829871 /* Project object */ = { |
||||
isa = PBXProject; |
||||
attributes = { |
||||
LastSwiftUpdateCheck = 1130; |
||||
LastUpgradeCheck = 1130; |
||||
ORGANIZATIONNAME = orgName; |
||||
TargetAttributes = { |
||||
7555FF7A242A565900829871 = { |
||||
CreatedOnToolsVersion = 11.3.1; |
||||
}; |
||||
}; |
||||
}; |
||||
buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; |
||||
compatibilityVersion = "Xcode 9.3"; |
||||
developmentRegion = en; |
||||
hasScannedForEncodings = 0; |
||||
knownRegions = ( |
||||
en, |
||||
Base, |
||||
); |
||||
mainGroup = 7555FF72242A565900829871; |
||||
productRefGroup = 7555FF7C242A565900829871 /* Products */; |
||||
projectDirPath = ""; |
||||
projectRoot = ""; |
||||
targets = ( |
||||
7555FF7A242A565900829871 /* iosApp */, |
||||
); |
||||
}; |
||||
/* End PBXProject section */ |
||||
|
||||
/* Begin PBXResourcesBuildPhase section */ |
||||
7555FF79242A565900829871 /* Resources */ = { |
||||
isa = PBXResourcesBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
files = ( |
||||
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, |
||||
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 0; |
||||
}; |
||||
/* End PBXResourcesBuildPhase section */ |
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */ |
||||
05E104082A8AADF800D11C3D /* Compile Kotlin */ = { |
||||
isa = PBXShellScriptBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
files = ( |
||||
); |
||||
inputFileListPaths = ( |
||||
); |
||||
inputPaths = ( |
||||
); |
||||
name = "Compile Kotlin"; |
||||
outputFileListPaths = ( |
||||
); |
||||
outputPaths = ( |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 0; |
||||
shellPath = /bin/sh; |
||||
shellScript = "cd \"$SRCROOT/..\"\n./gradlew :benchmarks:embedAndSignAppleFrameworkForXcode\n"; |
||||
}; |
||||
/* End PBXShellScriptBuildPhase section */ |
||||
|
||||
/* Begin PBXSourcesBuildPhase section */ |
||||
7555FF77242A565900829871 /* Sources */ = { |
||||
isa = PBXSourcesBuildPhase; |
||||
buildActionMask = 2147483647; |
||||
files = ( |
||||
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, |
||||
7555FF83242A565900829871 /* ContentView.swift in Sources */, |
||||
); |
||||
runOnlyForDeploymentPostprocessing = 0; |
||||
}; |
||||
/* End PBXSourcesBuildPhase section */ |
||||
|
||||
/* Begin XCBuildConfiguration section */ |
||||
7555FFA3242A565B00829871 /* Debug */ = { |
||||
isa = XCBuildConfiguration; |
||||
baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; |
||||
buildSettings = { |
||||
ALWAYS_SEARCH_USER_PATHS = NO; |
||||
CLANG_ANALYZER_NONNULL = YES; |
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; |
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; |
||||
CLANG_CXX_LIBRARY = "libc++"; |
||||
CLANG_ENABLE_MODULES = YES; |
||||
CLANG_ENABLE_OBJC_ARC = YES; |
||||
CLANG_ENABLE_OBJC_WEAK = YES; |
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; |
||||
CLANG_WARN_BOOL_CONVERSION = YES; |
||||
CLANG_WARN_COMMA = YES; |
||||
CLANG_WARN_CONSTANT_CONVERSION = YES; |
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; |
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; |
||||
CLANG_WARN_EMPTY_BODY = YES; |
||||
CLANG_WARN_ENUM_CONVERSION = YES; |
||||
CLANG_WARN_INFINITE_RECURSION = YES; |
||||
CLANG_WARN_INT_CONVERSION = YES; |
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; |
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; |
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; |
||||
CLANG_WARN_STRICT_PROTOTYPES = YES; |
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES; |
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; |
||||
CLANG_WARN_UNREACHABLE_CODE = YES; |
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
||||
COPY_PHASE_STRIP = NO; |
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
||||
ENABLE_STRICT_OBJC_MSGSEND = YES; |
||||
ENABLE_TESTABILITY = YES; |
||||
GCC_C_LANGUAGE_STANDARD = gnu11; |
||||
GCC_DYNAMIC_NO_PIC = NO; |
||||
GCC_NO_COMMON_BLOCKS = YES; |
||||
GCC_OPTIMIZATION_LEVEL = 0; |
||||
GCC_PREPROCESSOR_DEFINITIONS = ( |
||||
"DEBUG=1", |
||||
"$(inherited)", |
||||
); |
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; |
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; |
||||
GCC_WARN_UNDECLARED_SELECTOR = YES; |
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
||||
GCC_WARN_UNUSED_FUNCTION = YES; |
||||
GCC_WARN_UNUSED_VARIABLE = YES; |
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1; |
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; |
||||
MTL_FAST_MATH = YES; |
||||
ONLY_ACTIVE_ARCH = YES; |
||||
SDKROOT = iphoneos; |
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; |
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; |
||||
}; |
||||
name = Debug; |
||||
}; |
||||
7555FFA4242A565B00829871 /* Release */ = { |
||||
isa = XCBuildConfiguration; |
||||
baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; |
||||
buildSettings = { |
||||
ALWAYS_SEARCH_USER_PATHS = NO; |
||||
CLANG_ANALYZER_NONNULL = YES; |
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; |
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; |
||||
CLANG_CXX_LIBRARY = "libc++"; |
||||
CLANG_ENABLE_MODULES = YES; |
||||
CLANG_ENABLE_OBJC_ARC = YES; |
||||
CLANG_ENABLE_OBJC_WEAK = YES; |
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; |
||||
CLANG_WARN_BOOL_CONVERSION = YES; |
||||
CLANG_WARN_COMMA = YES; |
||||
CLANG_WARN_CONSTANT_CONVERSION = YES; |
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; |
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; |
||||
CLANG_WARN_EMPTY_BODY = YES; |
||||
CLANG_WARN_ENUM_CONVERSION = YES; |
||||
CLANG_WARN_INFINITE_RECURSION = YES; |
||||
CLANG_WARN_INT_CONVERSION = YES; |
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; |
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; |
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; |
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; |
||||
CLANG_WARN_STRICT_PROTOTYPES = YES; |
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES; |
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; |
||||
CLANG_WARN_UNREACHABLE_CODE = YES; |
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
||||
COPY_PHASE_STRIP = NO; |
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
||||
ENABLE_NS_ASSERTIONS = NO; |
||||
ENABLE_STRICT_OBJC_MSGSEND = YES; |
||||
GCC_C_LANGUAGE_STANDARD = gnu11; |
||||
GCC_NO_COMMON_BLOCKS = YES; |
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; |
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; |
||||
GCC_WARN_UNDECLARED_SELECTOR = YES; |
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
||||
GCC_WARN_UNUSED_FUNCTION = YES; |
||||
GCC_WARN_UNUSED_VARIABLE = YES; |
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1; |
||||
MTL_ENABLE_DEBUG_INFO = NO; |
||||
MTL_FAST_MATH = YES; |
||||
SDKROOT = iphoneos; |
||||
SWIFT_COMPILATION_MODE = wholemodule; |
||||
SWIFT_OPTIMIZATION_LEVEL = "-O"; |
||||
VALIDATE_PRODUCT = YES; |
||||
}; |
||||
name = Release; |
||||
}; |
||||
7555FFA6242A565B00829871 /* Debug */ = { |
||||
isa = XCBuildConfiguration; |
||||
buildSettings = { |
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
||||
CODE_SIGN_IDENTITY = "Apple Development"; |
||||
CODE_SIGN_STYLE = Automatic; |
||||
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; |
||||
DEVELOPMENT_TEAM = "${TEAM_ID}"; |
||||
ENABLE_PREVIEWS = YES; |
||||
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../benchmarks/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n"; |
||||
INFOPLIST_FILE = iosApp/Info.plist; |
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1; |
||||
LD_RUNPATH_SEARCH_PATHS = ( |
||||
"$(inherited)", |
||||
"@executable_path/Frameworks", |
||||
); |
||||
OTHER_LDFLAGS = ( |
||||
"$(inherited)", |
||||
"-framework", |
||||
"benchmarks\n", |
||||
); |
||||
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; |
||||
PRODUCT_NAME = "${APP_NAME}"; |
||||
PROVISIONING_PROFILE_SPECIFIER = ""; |
||||
SWIFT_VERSION = 5.0; |
||||
TARGETED_DEVICE_FAMILY = "1,2"; |
||||
}; |
||||
name = Debug; |
||||
}; |
||||
7555FFA7242A565B00829871 /* Release */ = { |
||||
isa = XCBuildConfiguration; |
||||
buildSettings = { |
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
||||
CODE_SIGN_IDENTITY = "Apple Development"; |
||||
CODE_SIGN_STYLE = Automatic; |
||||
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; |
||||
DEVELOPMENT_TEAM = "${TEAM_ID}"; |
||||
ENABLE_PREVIEWS = YES; |
||||
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../benchmarks/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n"; |
||||
INFOPLIST_FILE = iosApp/Info.plist; |
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1; |
||||
LD_RUNPATH_SEARCH_PATHS = ( |
||||
"$(inherited)", |
||||
"@executable_path/Frameworks", |
||||
); |
||||
OTHER_LDFLAGS = ( |
||||
"$(inherited)", |
||||
"-framework", |
||||
"benchmarks\n", |
||||
); |
||||
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; |
||||
PRODUCT_NAME = "${APP_NAME}"; |
||||
PROVISIONING_PROFILE_SPECIFIER = ""; |
||||
SWIFT_VERSION = 5.0; |
||||
TARGETED_DEVICE_FAMILY = "1,2"; |
||||
}; |
||||
name = Release; |
||||
}; |
||||
/* End XCBuildConfiguration section */ |
||||
|
||||
/* Begin XCConfigurationList section */ |
||||
7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { |
||||
isa = XCConfigurationList; |
||||
buildConfigurations = ( |
||||
7555FFA3242A565B00829871 /* Debug */, |
||||
7555FFA4242A565B00829871 /* Release */, |
||||
); |
||||
defaultConfigurationIsVisible = 0; |
||||
defaultConfigurationName = Release; |
||||
}; |
||||
7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { |
||||
isa = XCConfigurationList; |
||||
buildConfigurations = ( |
||||
7555FFA6242A565B00829871 /* Debug */, |
||||
7555FFA7242A565B00829871 /* Release */, |
||||
); |
||||
defaultConfigurationIsVisible = 0; |
||||
defaultConfigurationName = Release; |
||||
}; |
||||
/* End XCConfigurationList section */ |
||||
}; |
||||
rootObject = 7555FF73242A565900829871 /* Project object */; |
||||
} |
@ -0,0 +1,11 @@
|
||||
{ |
||||
"colors" : [ |
||||
{ |
||||
"idiom" : "universal" |
||||
} |
||||
], |
||||
"info" : { |
||||
"author" : "xcode", |
||||
"version" : 1 |
||||
} |
||||
} |
@ -0,0 +1,98 @@
|
||||
{ |
||||
"images" : [ |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "2x", |
||||
"size" : "20x20" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "3x", |
||||
"size" : "20x20" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "2x", |
||||
"size" : "29x29" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "3x", |
||||
"size" : "29x29" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "2x", |
||||
"size" : "40x40" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "3x", |
||||
"size" : "40x40" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "2x", |
||||
"size" : "60x60" |
||||
}, |
||||
{ |
||||
"idiom" : "iphone", |
||||
"scale" : "3x", |
||||
"size" : "60x60" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "1x", |
||||
"size" : "20x20" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "2x", |
||||
"size" : "20x20" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "1x", |
||||
"size" : "29x29" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "2x", |
||||
"size" : "29x29" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "1x", |
||||
"size" : "40x40" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "2x", |
||||
"size" : "40x40" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "1x", |
||||
"size" : "76x76" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "2x", |
||||
"size" : "76x76" |
||||
}, |
||||
{ |
||||
"idiom" : "ipad", |
||||
"scale" : "2x", |
||||
"size" : "83.5x83.5" |
||||
}, |
||||
{ |
||||
"idiom" : "ios-marketing", |
||||
"scale" : "1x", |
||||
"size" : "1024x1024" |
||||
} |
||||
], |
||||
"info" : { |
||||
"author" : "xcode", |
||||
"version" : 1 |
||||
} |
||||
} |
@ -0,0 +1,6 @@
|
||||
{ |
||||
"info" : { |
||||
"author" : "xcode", |
||||
"version" : 1 |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
import UIKit |
||||
import SwiftUI |
||||
|
||||
struct ContentView: View { |
||||
var body: some View { |
||||
VStack { |
||||
Text("Hello, world!") |
||||
} |
||||
.padding() |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>$(DEVELOPMENT_LANGUAGE)</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>$(EXECUTABLE_NAME)</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>$(PRODUCT_NAME)</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>1.0</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>1</string> |
||||
<key>LSRequiresIPhoneOS</key> |
||||
<true/> |
||||
<key>CADisableMinimumFrameDurationOnPhone</key> |
||||
<true/> |
||||
<key>UIApplicationSceneManifest</key> |
||||
<dict> |
||||
<key>UIApplicationSupportsMultipleScenes</key> |
||||
<false/> |
||||
</dict> |
||||
<key>UILaunchScreen</key> |
||||
<dict/> |
||||
<key>UIRequiredDeviceCapabilities</key> |
||||
<array> |
||||
<string>armv7</string> |
||||
</array> |
||||
<key>UISupportedInterfaceOrientations</key> |
||||
<array> |
||||
<string>UIInterfaceOrientationPortrait</string> |
||||
<string>UIInterfaceOrientationLandscapeLeft</string> |
||||
<string>UIInterfaceOrientationLandscapeRight</string> |
||||
</array> |
||||
<key>UISupportedInterfaceOrientations~ipad</key> |
||||
<array> |
||||
<string>UIInterfaceOrientationPortrait</string> |
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string> |
||||
<string>UIInterfaceOrientationLandscapeLeft</string> |
||||
<string>UIInterfaceOrientationLandscapeRight</string> |
||||
</array> |
||||
</dict> |
||||
</plist> |
@ -0,0 +1,6 @@
|
||||
{ |
||||
"info" : { |
||||
"author" : "xcode", |
||||
"version" : 1 |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
import SwiftUI |
||||
import benchmarks |
||||
|
||||
@main |
||||
struct iOSApp: App { |
||||
init() { |
||||
Main_iosKt.main(args: ProcessInfo.processInfo.arguments) |
||||
} |
||||
|
||||
var body: some Scene { |
||||
WindowGroup { |
||||
ContentView() |
||||
} |
||||
} |
||||
} |
@ -1,68 +0,0 @@
|
||||
import kotlinx.cinterop.ExperimentalForeignApi |
||||
import kotlinx.cinterop.objcPtr |
||||
import kotlinx.coroutines.runBlocking |
||||
import org.jetbrains.skia.* |
||||
import platform.Metal.* |
||||
import kotlin.coroutines.resume |
||||
import kotlin.coroutines.suspendCoroutine |
||||
|
||||
/* |
||||
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
@OptIn(ExperimentalForeignApi::class) |
||||
fun main(args : Array<String>) { |
||||
Args.parseArgs(args) |
||||
val graphicsContext = object : GraphicsContext { |
||||
private val device = MTLCreateSystemDefaultDevice() ?: throw IllegalStateException("Can't create MTLDevice") |
||||
private val commandQueue = device.newCommandQueue() ?: throw IllegalStateException("Can't create MTLCommandQueue") |
||||
private val directContext = DirectContext.makeMetal(device.objcPtr(), commandQueue.objcPtr()) |
||||
private var cachedSurface: Surface? = null |
||||
|
||||
override fun surface(width: Int, height: Int): Surface { |
||||
val oldSurface = cachedSurface |
||||
|
||||
if (oldSurface != null && oldSurface.width == width && oldSurface.height == height) { |
||||
return oldSurface |
||||
} |
||||
|
||||
val descriptor = MTLTextureDescriptor() |
||||
descriptor.width = width.toULong() |
||||
descriptor.height = height.toULong() |
||||
descriptor.usage = MTLTextureUsageShaderRead or MTLTextureUsageShaderWrite or MTLTextureUsageRenderTarget |
||||
descriptor.textureType = MTLTextureType2D |
||||
descriptor.pixelFormat = MTLPixelFormatBGRA8Unorm |
||||
descriptor.mipmapLevelCount = 1UL |
||||
|
||||
val texture = device.newTextureWithDescriptor(descriptor) ?: throw IllegalStateException("Can't create MTLTexture") |
||||
|
||||
val renderTarget = BackendRenderTarget.makeMetal(width, height, texture.objcPtr()) |
||||
|
||||
return Surface.makeFromBackendRenderTarget( |
||||
directContext, |
||||
renderTarget, |
||||
SurfaceOrigin.TOP_LEFT, |
||||
SurfaceColorFormat.BGRA_8888, |
||||
ColorSpace.sRGB, |
||||
SurfaceProps(pixelGeometry = PixelGeometry.UNKNOWN) |
||||
).also { |
||||
cachedSurface = it |
||||
} ?: throw IllegalStateException("Can't create Surface") |
||||
} |
||||
|
||||
override suspend fun awaitGPUCompletion() { |
||||
val commandBuffer = commandQueue.commandBuffer() ?: return |
||||
|
||||
suspendCoroutine { continuation -> |
||||
commandBuffer.addCompletedHandler { |
||||
continuation.resume(Unit) |
||||
} |
||||
|
||||
commandBuffer.commit() |
||||
} |
||||
} |
||||
} |
||||
|
||||
runBlocking { runBenchmarks(graphicsContext = graphicsContext)} |
||||
} |
Loading…
Reference in new issue