mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 17:44:09 +01:00
Enforce copy buffer-texture row pitch alignment
This commit is contained in:
1 parent
3a6cdeec94
commit
321a5cee0f
7 files changed
+114
-46
No files matched your search
@@ -307,7 +307,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let hub = B::hub(self);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
|
||||
@@ -371,13 +370,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
};
|
||||
|
||||
let (context, sample_count) = {
|
||||
use hal::{adapter::PhysicalDevice as _, device::Device as _};
|
||||
use hal::device::Device as _;
|
||||
|
||||
let limits = adapter_guard[device.adapter_id.value]
|
||||
.raw
|
||||
.physical_device
|
||||
.limits();
|
||||
let samples_count_limit = limits.framebuffer_color_sample_counts;
|
||||
let samples_count_limit = device.hal_limits.framebuffer_color_sample_counts;
|
||||
let base_trackers = &cmb.trackers;
|
||||
|
||||
let mut extent = None;
|
||||
|
||||
@@ -199,14 +199,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.surface_desc()
|
||||
.bits as u32
|
||||
/ BITS_PER_BYTE;
|
||||
let buffer_width = source.layout.bytes_per_row / bytes_per_texel;
|
||||
assert_eq!(wgt::COPY_BYTES_PER_ROW_ALIGNMENT % bytes_per_texel, 0);
|
||||
assert_eq!(
|
||||
source.layout.bytes_per_row % bytes_per_texel,
|
||||
source.layout.bytes_per_row % wgt::COPY_BYTES_PER_ROW_ALIGNMENT,
|
||||
0,
|
||||
"Source bytes per row ({}) must be a multiple of bytes per texel ({})",
|
||||
"Source bytes per row ({}) must be a multiple of {}",
|
||||
source.layout.bytes_per_row,
|
||||
bytes_per_texel
|
||||
wgt::COPY_BYTES_PER_ROW_ALIGNMENT
|
||||
);
|
||||
let buffer_width = source.layout.bytes_per_row / bytes_per_texel;
|
||||
let region = hal::command::BufferImageCopy {
|
||||
buffer_offset: source.layout.offset,
|
||||
buffer_width,
|
||||
@@ -286,14 +287,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.surface_desc()
|
||||
.bits as u32
|
||||
/ BITS_PER_BYTE;
|
||||
let buffer_width = destination.layout.bytes_per_row / bytes_per_texel;
|
||||
assert_eq!(wgt::COPY_BYTES_PER_ROW_ALIGNMENT % bytes_per_texel, 0);
|
||||
assert_eq!(
|
||||
destination.layout.bytes_per_row % bytes_per_texel,
|
||||
destination.layout.bytes_per_row % wgt::COPY_BYTES_PER_ROW_ALIGNMENT,
|
||||
0,
|
||||
"Destination bytes per row ({}) must be a multiple of bytes per texel ({})",
|
||||
"Destination bytes per row ({}) must be a multiple of {}",
|
||||
destination.layout.bytes_per_row,
|
||||
bytes_per_texel
|
||||
wgt::COPY_BYTES_PER_ROW_ALIGNMENT
|
||||
);
|
||||
let buffer_width = destination.layout.bytes_per_row / bytes_per_texel;
|
||||
let region = hal::command::BufferImageCopy {
|
||||
buffer_offset: destination.layout.offset,
|
||||
buffer_width,
|
||||
|
||||
Reference in new issue
Block a user