Skip to content

Commit

Permalink
Fix iOS compilation issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored and dnfield committed Apr 27, 2022
1 parent 4ca5af4 commit 84eee26
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
7 changes: 6 additions & 1 deletion impeller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ config("impeller_public_config") {
include_dirs = [ ".." ]
}

is_host = is_mac || is_linux || is_win

group("impeller") {
public_deps = [
"aiks",
"archivist",
"base",
"compiler",
"display_list",
"entity",
"geometry",
"image",
"renderer",
]

if (is_host) {
public_deps += [ "compiler" ]
}
}

executable("impeller_unittests") {
Expand Down
10 changes: 5 additions & 5 deletions impeller/archivist/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import("../tools/impeller.gni")

impeller_component("archivist") {
# Only the umbrella header is public since all other TU's are implementation
# detail that will be compiled away in release modes.
# Because they are implementation details, they may expose dependency headers.
public = [ "archive.h" ]
public = [
"archivable.h",
"archive.h",
"archive_location.h",
]

sources = [
"archivable.cc",
Expand All @@ -20,7 +21,6 @@ impeller_component("archivist") {
"archive_database.cc",
"archive_database.h",
"archive_location.cc",
"archive_location.h",
"archive_statement.cc",
"archive_statement.h",
"archive_transaction.cc",
Expand Down
1 change: 1 addition & 0 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impeller_component("entity") {
deps = [ ":entity_shaders" ]

public_deps = [
"../archivist",
"../image",
"../renderer",
]
Expand Down
12 changes: 10 additions & 2 deletions impeller/renderer/backend/metal/allocator_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ static MTLResourceOptions ToMTLResourceOptions(StorageMode type) {
return MTLResourceStorageModePrivate;
case StorageMode::kDeviceTransient:
#if OS_IOS
return MTLResourceStorageModeMemoryless;
if (@available(iOS 10.0, *)) {
return MTLResourceStorageModeMemoryless;
} else {
return MTLResourceStorageModePrivate;
}
#else
return MTLResourceStorageModePrivate;
#endif
Expand All @@ -62,7 +66,11 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode) {
return MTLStorageModePrivate;
case StorageMode::kDeviceTransient:
#if OS_IOS
return MTLStorageModeMemoryless;
if (@available(iOS 10.0, *)) {
return MTLStorageModeMemoryless;
} else {
return MTLStorageModePrivate;
}
#else
return MTLStorageModePrivate;
#endif
Expand Down
11 changes: 10 additions & 1 deletion impeller/renderer/backend/metal/device_buffer_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@
::memmove(dest + offset, source + source_range.offset, source_range.length);
}

// |RequiresExplicitHostSynchronization| always returns false on iOS. But the
// compiler is mad that `didModifyRange:` appears in a TU meant for iOS. So,
// just compile it away.
//
// Making this call is never necessary on iOS because there is no
// MTLResourceStorageModeManaged mode. Only the MTLStorageModeShared mode is
// available.
#if !OS_IOS
if (Allocator::RequiresExplicitHostSynchronization(mode_)) {
[buffer_ didModifyRange:NSMakeRange(offset, source_range.length)];
}
#endif

return true;
}
Expand All @@ -97,7 +106,7 @@
if (label.empty()) {
return false;
}
if (@available(macOS 10.12, *)) {
if (@available(macOS 10.12, iOS 10.0, *)) {
[buffer_ addDebugMarker:@(label.c_str())
range:NSMakeRange(range.offset, range.length)];
}
Expand Down
12 changes: 6 additions & 6 deletions impeller/renderer/backend/metal/vertex_descriptor_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(float) / 2) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, *)) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatHalf;
} else {
return MTLVertexFormatInvalid;
Expand All @@ -60,7 +60,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
}
case ShaderType::kBoolean: {
if (input.bit_width == 8 * sizeof(bool) && input.vec_size == 1) {
if (@available(macOS 10.13, *)) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatChar;
} else {
return MTLVertexFormatInvalid;
Expand All @@ -72,7 +72,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(char)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, *)) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatChar;
} else {
return MTLVertexFormatInvalid;
Expand All @@ -91,7 +91,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(char)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, *)) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatUChar;
} else {
return MTLVertexFormatInvalid;
Expand All @@ -110,7 +110,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(short)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, *)) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatShort;
} else {
return MTLVertexFormatInvalid;
Expand All @@ -129,7 +129,7 @@ static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot& input) {
if (input.bit_width == 8 * sizeof(ushort)) {
switch (input.vec_size) {
case 1:
if (@available(macOS 10.13, *)) {
if (@available(macOS 10.13, iOS 11.0, *)) {
return MTLVertexFormatUShort;
} else {
return MTLVertexFormatInvalid;
Expand Down

0 comments on commit 84eee26

Please sign in to comment.