From 3eb63762c72ccd91717d4feb98128aa12cc1b126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 27 Aug 2020 19:28:03 +0200 Subject: [PATCH] Remove unnecessary `create_buffer_init` for uniforms --- wgpu/src/image.rs | 16 ++++++---------- wgpu/src/quad.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 3a08662a..814eefea 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -78,16 +78,12 @@ impl Pipeline { ], }); - let uniforms = Uniforms { - transform: Transformation::identity().into(), - }; - - let uniforms_buffer = - device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: uniforms.as_bytes(), - usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, - }); + let uniforms_buffer = device.create_buffer(&wgpu::BufferDescriptor { + label: None, + size: mem::size_of::() as u64, + usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, + mapped_at_creation: false, + }); let constant_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index a115fa73..0c54db15 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -34,12 +34,12 @@ impl Pipeline { }], }); - let constants_buffer = - device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: Uniforms::default().as_bytes(), - usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, - }); + let constants_buffer = device.create_buffer(&wgpu::BufferDescriptor { + label: None, + size: mem::size_of::() as u64, + usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, + mapped_at_creation: false, + }); let constants = device.create_bind_group(&wgpu::BindGroupDescriptor { label: None,