diff options
author | 2023-09-24 15:10:19 +0200 | |
---|---|---|
committer | 2023-09-24 15:10:19 +0200 | |
commit | 3f467d121229142177ef1b2f417fe87c7bf7fdf2 (patch) | |
tree | f7c98f9009dca79b7d164801a8badb0fab1f7089 /wgpu/src/quad.rs | |
parent | bc9bb28b1ccd1248d63ccdfef2f57d7aa837abbb (diff) | |
download | iced-3f467d121229142177ef1b2f417fe87c7bf7fdf2.tar.gz iced-3f467d121229142177ef1b2f417fe87c7bf7fdf2.tar.bz2 iced-3f467d121229142177ef1b2f417fe87c7bf7fdf2.zip |
Compute vertex position in shader
Diffstat (limited to 'wgpu/src/quad.rs')
-rw-r--r-- | wgpu/src/quad.rs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index 37d0c623..4bcf9a66 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -9,7 +9,6 @@ use crate::graphics::color; use crate::graphics::{self, Transformation}; use bytemuck::{Pod, Zeroable}; -use wgpu::util::DeviceExt; use std::mem; @@ -23,8 +22,6 @@ pub struct Pipeline { solid: solid::Pipeline, gradient: gradient::Pipeline, constant_layout: wgpu::BindGroupLayout, - vertices: wgpu::Buffer, - indices: wgpu::Buffer, layers: Vec<Layer>, prepare_layer: usize, } @@ -48,23 +45,7 @@ impl Pipeline { }], }); - let vertices = - device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: Some("iced_wgpu::quad vertex buffer"), - contents: bytemuck::cast_slice(&VERTICES), - usage: wgpu::BufferUsages::VERTEX, - }); - - let indices = - device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: Some("iced_wgpu::quad index buffer"), - contents: bytemuck::cast_slice(&INDICES), - usage: wgpu::BufferUsages::INDEX, - }); - Self { - vertices, - indices, solid: solid::Pipeline::new(device, format, &constant_layout), gradient: gradient::Pipeline::new(device, format, &constant_layout), layers: Vec::new(), @@ -105,11 +86,6 @@ impl Pipeline { bounds.width, bounds.height, ); - render_pass.set_index_buffer( - self.indices.slice(..), - wgpu::IndexFormat::Uint16, - ); - render_pass.set_vertex_buffer(0, self.vertices.slice(..)); let mut solid_offset = 0; let mut gradient_offset = 0; @@ -312,43 +288,6 @@ fn color_target_state( } #[repr(C)] -#[derive(Clone, Copy, bytemuck::Zeroable, bytemuck::Pod)] -pub struct Vertex { - _position: [f32; 2], -} - -impl Vertex { - fn buffer_layout<'a>() -> wgpu::VertexBufferLayout<'a> { - wgpu::VertexBufferLayout { - array_stride: mem::size_of::<Self>() as u64, - step_mode: wgpu::VertexStepMode::Vertex, - attributes: &[wgpu::VertexAttribute { - shader_location: 0, - format: wgpu::VertexFormat::Float32x2, - offset: 0, - }], - } - } -} - -const INDICES: [u16; 6] = [0, 1, 2, 0, 2, 3]; - -const VERTICES: [Vertex; 4] = [ - Vertex { - _position: [0.0, 0.0], - }, - Vertex { - _position: [1.0, 0.0], - }, - Vertex { - _position: [1.0, 1.0], - }, - Vertex { - _position: [0.0, 1.0], - }, -]; - -#[repr(C)] #[derive(Debug, Clone, Copy, bytemuck::Zeroable, bytemuck::Pod)] struct Uniforms { transform: [f32; 16], |