mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Fix alignment on ios simulator (#10178)
# Objective - Fix #10165 - On iOS simulator on apple silicon Macs, shader validation is going through the host, but device limits are reported for the device. They sometimes differ, and cause the validation to crash on something that should work ``` -[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5775: failed assertion `Draw Errors Validation Fragment Function(fragment_): the offset into the buffer _naga_oil_mod_MJSXM6K7OBRHEOR2NVSXG2C7OZUWK527MJUW4ZDJNZTXG_memberfog that is bound at buffer index 6 must be a multiple of 256 but was set to 448. ``` ## Solution - Add a custom flag when building for the simulator and override the buffer alignment
This commit is contained in:
parent
9cfada3f22
commit
c3627248f5
3 changed files with 16 additions and 3 deletions
|
@ -277,8 +277,16 @@ impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
|
|||
device: &RenderDevice,
|
||||
queue: &'a RenderQueue,
|
||||
) -> Option<DynamicUniformBufferWriter<'a, T>> {
|
||||
let alignment =
|
||||
AlignmentValue::new(device.limits().min_uniform_buffer_offset_alignment as u64);
|
||||
let alignment = if cfg!(ios_simulator) {
|
||||
// On iOS simulator on silicon macs, metal validation check that the host OS alignment
|
||||
// is respected, but the device reports the correct value for iOS, which is smaller.
|
||||
// Use the larger value.
|
||||
// See https://github.com/bevyengine/bevy/pull/10178 - remove if it's not needed anymore.
|
||||
AlignmentValue::new(256)
|
||||
} else {
|
||||
AlignmentValue::new(device.limits().min_uniform_buffer_offset_alignment as u64)
|
||||
};
|
||||
|
||||
let mut capacity = self.buffer.as_deref().map(wgpu::Buffer::size).unwrap_or(0);
|
||||
let size = alignment
|
||||
.round_up(T::min_size().get())
|
||||
|
|
5
examples/mobile/.cargo/config.toml
Normal file
5
examples/mobile/.cargo/config.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Flag to notify the compiler we're building for the iOS simulator from an Apple silicon mac
|
||||
# This needs some workarounds for now
|
||||
# See https://github.com/bevyengine/bevy/pull/10178 - remove if it's not needed anymore.
|
||||
[target.aarch64-apple-ios-sim]
|
||||
rustflags = ["--cfg=ios_simulator"]
|
|
@ -48,7 +48,7 @@ for arch in $ARCHS; do
|
|||
# Hardware iOS targets
|
||||
cargo rustc --crate-type staticlib --lib $RELFLAG --target aarch64-apple-ios
|
||||
else
|
||||
# M1 iOS simulator -- currently in Nightly only and requires to build `libstd`
|
||||
# M1 iOS simulator
|
||||
cargo rustc --crate-type staticlib --lib $RELFLAG --target aarch64-apple-ios-sim
|
||||
fi
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue