refactor: vertex_index_common: use size_of_val instead of magic number

This commit is contained in:
Erich Gubler 2024-06-18 15:53:56 -04:00
parent 764b15a556
commit 5c29ad548b

View File

@ -8,7 +8,6 @@ use std::{num::NonZeroU64, ops::Range};
use itertools::Itertools; use itertools::Itertools;
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder}; use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder};
use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters, TestingContext}; use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters, TestingContext};
use wgt::RenderBundleDescriptor; use wgt::RenderBundleDescriptor;
@ -379,7 +378,7 @@ async fn vertex_index_common(ctx: TestingContext) {
let expected = test.expectation(&ctx); let expected = test.expectation(&ctx);
let buffer_size = 4 * expected.len() as u64; let buffer_size = (std::mem::size_of_val(&expected[0]) * expected.len()) as u64;
let cpu_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { let cpu_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: None,
size: buffer_size, size: buffer_size,