mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Use expect instead of unwrap on image format block size
This commit is contained in:
parent
bb117da352
commit
84915dc289
|
@ -17,7 +17,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::{hash_map::Entry, HashMap, HashSet},
|
collections::{hash_map::Entry, HashMap, HashSet},
|
||||||
num::{NonZeroU32, NonZeroU64},
|
num::NonZeroU64,
|
||||||
sync::atomic::{AtomicU64, Ordering},
|
sync::atomic::{AtomicU64, Ordering},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -277,6 +277,9 @@ impl Engine {
|
||||||
}
|
}
|
||||||
Command::UploadImage(image_proxy, bytes) => {
|
Command::UploadImage(image_proxy, bytes) => {
|
||||||
let format = image_proxy.format.to_wgpu();
|
let format = image_proxy.format.to_wgpu();
|
||||||
|
let block_size = format
|
||||||
|
.block_size(None)
|
||||||
|
.expect("ImageFormat must have a valid block size");
|
||||||
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
size: wgpu::Extent3d {
|
size: wgpu::Extent3d {
|
||||||
|
@ -311,9 +314,7 @@ impl Engine {
|
||||||
bytes,
|
bytes,
|
||||||
wgpu::ImageDataLayout {
|
wgpu::ImageDataLayout {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
bytes_per_row: Some(
|
bytes_per_row: Some(image_proxy.width * block_size),
|
||||||
image_proxy.width * format.block_size(None).unwrap(),
|
|
||||||
),
|
|
||||||
rows_per_image: None,
|
rows_per_image: None,
|
||||||
},
|
},
|
||||||
wgpu::Extent3d {
|
wgpu::Extent3d {
|
||||||
|
@ -328,6 +329,9 @@ impl Engine {
|
||||||
Command::WriteImage(proxy, [x, y, width, height], data) => {
|
Command::WriteImage(proxy, [x, y, width, height], data) => {
|
||||||
if let Ok((texture, _)) = self.bind_map.get_or_create_image(*proxy, device) {
|
if let Ok((texture, _)) = self.bind_map.get_or_create_image(*proxy, device) {
|
||||||
let format = proxy.format.to_wgpu();
|
let format = proxy.format.to_wgpu();
|
||||||
|
let block_size = format
|
||||||
|
.block_size(None)
|
||||||
|
.expect("ImageFormat must have a valid block size");
|
||||||
queue.write_texture(
|
queue.write_texture(
|
||||||
wgpu::ImageCopyTexture {
|
wgpu::ImageCopyTexture {
|
||||||
texture,
|
texture,
|
||||||
|
@ -338,7 +342,7 @@ impl Engine {
|
||||||
&data[..],
|
&data[..],
|
||||||
wgpu::ImageDataLayout {
|
wgpu::ImageDataLayout {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
bytes_per_row: Some(*width * format.block_size(None).unwrap()),
|
bytes_per_row: Some(*width * block_size),
|
||||||
rows_per_image: None,
|
rows_per_image: None,
|
||||||
},
|
},
|
||||||
wgpu::Extent3d {
|
wgpu::Extent3d {
|
||||||
|
|
Loading…
Reference in a new issue