mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-12 06:52:38 +00:00
Require mapped buffers to be aligned
This commit is contained in:
parent
d90beda4e7
commit
0929425477
@ -22,10 +22,7 @@ use hal::{
|
||||
window::{PresentationSurface as _, Surface as _},
|
||||
};
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
use wgt::{
|
||||
BufferAddress, BufferSize, InputStepMode, TextureDimension, TextureFormat,
|
||||
BIND_BUFFER_ALIGNMENT,
|
||||
};
|
||||
use wgt::{BufferAddress, BufferSize, InputStepMode, TextureDimension, TextureFormat};
|
||||
|
||||
use std::{
|
||||
collections::hash_map::Entry, ffi, iter, marker::PhantomData, mem, ops::Range, ptr, slice,
|
||||
@ -670,6 +667,14 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
|
||||
log::info!("Create buffer {:?} with ID {:?}", desc, id_in);
|
||||
|
||||
if desc.mapped_at_creation {
|
||||
assert_eq!(
|
||||
desc.size % wgt::COPY_BUFFER_ALIGNMENT,
|
||||
0,
|
||||
"Buffers that are mapped at creation have to be aligned to COPY_BUFFER_ALIGNMENT"
|
||||
);
|
||||
}
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let device = &device_guard[device_id];
|
||||
let mut buffer = device.create_buffer(device_id, desc, gfx_memory::Kind::General);
|
||||
@ -1535,7 +1540,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
bb.offset % BIND_BUFFER_ALIGNMENT,
|
||||
bb.offset % wgt::BIND_BUFFER_ALIGNMENT,
|
||||
0,
|
||||
"Buffer offset {} must be a multiple of BIND_BUFFER_ALIGNMENT",
|
||||
bb.offset
|
||||
@ -2792,6 +2797,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
HostMap::Write => (wgt::BufferUsage::MAP_WRITE, resource::BufferUse::MAP_WRITE),
|
||||
};
|
||||
|
||||
assert_eq!(range.start % wgt::COPY_BUFFER_ALIGNMENT, 0);
|
||||
assert_eq!(range.end % wgt::COPY_BUFFER_ALIGNMENT, 0);
|
||||
|
||||
let (device_id, ref_count) = {
|
||||
let (mut buffer_guard, _) = hub.buffers.write(&mut token);
|
||||
let buffer = &mut buffer_guard[buffer_id];
|
||||
|
@ -188,7 +188,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
data_size % wgt::COPY_BUFFER_ALIGNMENT,
|
||||
0,
|
||||
"Buffer write size {} must be a multiple of {}",
|
||||
buffer_offset,
|
||||
data_size,
|
||||
wgt::COPY_BUFFER_ALIGNMENT,
|
||||
);
|
||||
assert_eq!(
|
||||
|
Loading…
Reference in New Issue
Block a user