Skip to content

Commit 94deca8

Browse files
authored
Use target_abi = "sim" instead of ios_simulator feature (#17702)
## Objective Get rid of a redundant Cargo feature flag. ## Solution Use the built-in `target_abi = "sim"` instead of a custom Cargo feature flag, which is set for the iOS (and visionOS and tvOS) simulator. This has been stable since Rust 1.78. In the future, some of this may become redundant if Wgpu implements proper supper for the iOS Simulator: gfx-rs/wgpu#7057 CC @mockersf who implemented [the original fix](#10178). ## Testing - Open mobile example in Xcode. - Launch the simulator. - See that no errors are emitted. - Remove the code cfg-guarded behind `target_abi = "sim"`. - See that an error now happens. (I haven't actually performed these steps on the latest `main`, because I'm hitting an unrelated error (EDIT: It was #17637). But tested it on 0.15.0). --- ## Migration Guide > If you're using a project that builds upon the mobile example, remove the `ios_simulator` feature from your `Cargo.toml` (Bevy now handles this internally).
1 parent 85b366a commit 94deca8

File tree

11 files changed

+7
-22
lines changed

11 files changed

+7
-22
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ meshlet = ["bevy_internal/meshlet"]
464464
# Enables processing meshes into meshlet meshes for bevy_pbr
465465
meshlet_processor = ["bevy_internal/meshlet_processor"]
466466

467-
# Enable support for the ios_simulator by downgrading some rendering capabilities
468-
ios_simulator = ["bevy_internal/ios_simulator"]
469-
470467
# Enable built in global state machines
471468
bevy_state = ["bevy_internal/bevy_state"]
472469

crates/bevy_internal/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,6 @@ bevy_ui_picking_backend = ["bevy_picking", "bevy_ui/bevy_ui_picking_backend"]
253253
# Provides a UI debug overlay
254254
bevy_ui_debug = ["bevy_ui?/bevy_ui_debug"]
255255

256-
# Enable support for the ios_simulator by downgrading some rendering capabilities
257-
ios_simulator = ["bevy_pbr?/ios_simulator", "bevy_render?/ios_simulator"]
258-
259256
# Enable built in global state machines
260257
bevy_state = ["dep:bevy_state"]
261258

crates/bevy_pbr/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ experimental_pbr_pcss = []
1818
pbr_specular_textures = []
1919
shader_format_glsl = ["bevy_render/shader_format_glsl"]
2020
trace = ["bevy_render/trace"]
21-
ios_simulator = ["bevy_render/ios_simulator"]
2221
# Enables the meshlet renderer for dense high-poly scenes (experimental)
2322
meshlet = ["dep:lz4_flex", "dep:range-alloc", "dep:half", "dep:bevy_tasks"]
2423
# Enables processing meshes into meshlet meshes

crates/bevy_pbr/src/render/light.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ pub fn prepare_lights(
10641064
// NOTE: iOS Simulator is missing CubeArray support so we use Cube instead.
10651065
// See https://github.com/bevyengine/bevy/pull/12052 - remove if support is added.
10661066
#[cfg(all(
1067-
not(feature = "ios_simulator"),
1067+
not(target_abi = "sim"),
10681068
any(
10691069
not(feature = "webgl"),
10701070
not(target_arch = "wasm32"),
@@ -1073,7 +1073,7 @@ pub fn prepare_lights(
10731073
))]
10741074
dimension: Some(TextureViewDimension::CubeArray),
10751075
#[cfg(any(
1076-
feature = "ios_simulator",
1076+
target_abi = "sim",
10771077
all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu"))
10781078
))]
10791079
dimension: Some(TextureViewDimension::Cube),

crates/bevy_pbr/src/render/mesh_view_bindings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn layout_entries(
216216
(
217217
2,
218218
#[cfg(all(
219-
not(feature = "ios_simulator"),
219+
not(target_abi = "sim"),
220220
any(
221221
not(feature = "webgl"),
222222
not(target_arch = "wasm32"),
@@ -225,7 +225,7 @@ fn layout_entries(
225225
))]
226226
texture_cube_array(TextureSampleType::Depth),
227227
#[cfg(any(
228-
feature = "ios_simulator",
228+
target_abi = "sim",
229229
all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu"))
230230
))]
231231
texture_cube(TextureSampleType::Depth),

crates/bevy_render/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ tracing-tracy = []
3333
ci_limits = []
3434
webgl = ["wgpu/webgl"]
3535
webgpu = ["wgpu/webgpu"]
36-
ios_simulator = []
3736
detailed_trace = []
3837

3938
[dependencies]

crates/bevy_render/src/render_resource/pipeline_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl ShaderCache {
251251
shader_defs.push("SIXTEEN_BYTE_ALIGNMENT".into());
252252
}
253253

254-
if cfg!(feature = "ios_simulator") {
254+
if cfg!(target_abi = "sim") {
255255
shader_defs.push("NO_CUBE_ARRAY_TEXTURES_SUPPORT".into());
256256
}
257257

crates/bevy_render/src/render_resource/uniform_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
278278
device: &RenderDevice,
279279
queue: &'a RenderQueue,
280280
) -> Option<DynamicUniformBufferWriter<'a, T>> {
281-
let alignment = if cfg!(feature = "ios_simulator") {
281+
let alignment = if cfg!(target_abi = "sim") {
282282
// On iOS simulator on silicon macs, metal validation check that the host OS alignment
283283
// is respected, but the device reports the correct value for iOS, which is smaller.
284284
// Use the larger value.
285-
// See https://github.com/bevyengine/bevy/pull/10178 - remove if it's not needed anymore.
285+
// See https://github.com/gfx-rs/wgpu/issues/7057 - remove if it's not needed anymore.
286286
AlignmentValue::new(256)
287287
} else {
288288
AlignmentValue::new(device.limits().min_uniform_buffer_offset_alignment as u64)

docs/cargo_features.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ The default feature set enables most of the expected features of a game engine,
7979
|gif|GIF image format support|
8080
|glam_assert|Enable assertions to check the validity of parameters passed to glam|
8181
|ico|ICO image format support|
82-
|ios_simulator|Enable support for the ios_simulator by downgrading some rendering capabilities|
8382
|jpeg|JPEG image format support|
8483
|meshlet|Enables the meshlet renderer for dense high-poly scenes (experimental)|
8584
|meshlet_processor|Enables processing meshes into meshlet meshes for bevy_pbr|

examples/mobile/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,5 @@ crate-type = ["staticlib", "cdylib"]
1414
[dependencies]
1515
bevy = { path = "../../" }
1616

17-
[target.aarch64-apple-ios-sim.dependencies]
18-
bevy = { path = "../../", features = ["ios_simulator"] }
19-
2017
[lints]
2118
workspace = true

0 commit comments

Comments
 (0)