refactor: fully qual. size_of usage (#6401)

This commit is contained in:
Erich Gubler 2024-10-11 20:48:57 -04:00 committed by GitHub
parent 91447aefc9
commit 2b15a2b24b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use nanorand::{Rng, WyRand}; use nanorand::{Rng, WyRand};
use std::{borrow::Cow, mem}; use std::{borrow::Cow, mem::size_of};
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use winit::{ use winit::{
event::{ElementState, KeyEvent}, event::{ElementState, KeyEvent},
@ -164,7 +164,7 @@ impl crate::framework::Example for Example {
ty: wgpu::BindingType::Buffer { ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform, ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false, has_dynamic_offset: false,
min_binding_size: wgpu::BufferSize::new(mem::size_of::<Globals>() as _), min_binding_size: wgpu::BufferSize::new(size_of::<Globals>() as _),
}, },
count: None, count: None,
}, },
@ -195,7 +195,7 @@ impl crate::framework::Example for Example {
ty: wgpu::BindingType::Buffer { ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform, ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: true, has_dynamic_offset: true,
min_binding_size: wgpu::BufferSize::new(mem::size_of::<Bunny>() as _), min_binding_size: wgpu::BufferSize::new(size_of::<Bunny>() as _),
}, },
count: None, count: None,
}], }],
@ -337,7 +337,7 @@ impl crate::framework::Example for Example {
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding { resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
buffer: &local_buffer, buffer: &local_buffer,
offset: 0, offset: 0,
size: wgpu::BufferSize::new(mem::size_of::<Bunny>() as _), size: wgpu::BufferSize::new(size_of::<Bunny>() as _),
}), }),
}], }],
label: None, label: None,

View File

@ -1,5 +1,5 @@
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use std::mem; use std::mem::size_of;
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
#[repr(C)] #[repr(C)]
@ -70,7 +70,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
_queue: &wgpu::Queue, _queue: &wgpu::Queue,
) -> Self { ) -> Self {
// Create the vertex and index buffers // Create the vertex and index buffers
let vertex_size = mem::size_of::<Vertex>(); let vertex_size = size_of::<Vertex>();
let (vertex_data, index_data) = create_vertices(); let (vertex_data, index_data) = create_vertices();
let vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {