diff --git a/all-is-cubes-gpu/src/in_wgpu/pipelines.rs b/all-is-cubes-gpu/src/in_wgpu/pipelines.rs index b89bed473..3f7e10ba0 100644 --- a/all-is-cubes-gpu/src/in_wgpu/pipelines.rs +++ b/all-is-cubes-gpu/src/in_wgpu/pipelines.rs @@ -176,7 +176,7 @@ impl Pipelines { unclipped_depth: false, conservative: false, }; - let vertex_buffers = &[WgpuBlockVertex::desc(), WgpuInstanceData::desc()]; + let vertex_buffers = &[WgpuBlockVertex::LAYOUT, WgpuInstanceData::LAYOUT]; let multisample = fb.linear_scene_multisample_state(); @@ -317,7 +317,7 @@ impl Pipelines { module: shaders.blocks_and_lines.get(), entry_point: Some("lines_vertex"), compilation_options: wgpu::PipelineCompilationOptions::default(), - buffers: &[WgpuLinesVertex::desc()], + buffers: &[WgpuLinesVertex::LAYOUT], }, fragment: Some(wgpu::FragmentState { module: shaders.blocks_and_lines.get(), diff --git a/all-is-cubes-gpu/src/in_wgpu/shader_testing.rs b/all-is-cubes-gpu/src/in_wgpu/shader_testing.rs index dd5632d60..36a563cb5 100644 --- a/all-is-cubes-gpu/src/in_wgpu/shader_testing.rs +++ b/all-is-cubes-gpu/src/in_wgpu/shader_testing.rs @@ -98,7 +98,7 @@ where module: &shader, entry_point: Some("block_vertex_main"), compilation_options: wgpu::PipelineCompilationOptions::default(), - buffers: &[WgpuBlockVertex::desc(), WgpuInstanceData::desc()], + buffers: &[WgpuBlockVertex::LAYOUT, WgpuInstanceData::LAYOUT], }, fragment: Some(wgpu::FragmentState { module: &shader, diff --git a/all-is-cubes-gpu/src/in_wgpu/vertex.rs b/all-is-cubes-gpu/src/in_wgpu/vertex.rs index ef6a7ef97..0145adb19 100644 --- a/all-is-cubes-gpu/src/in_wgpu/vertex.rs +++ b/all-is-cubes-gpu/src/in_wgpu/vertex.rs @@ -74,21 +74,17 @@ pub(crate) struct WgpuBlockVertex { } impl WgpuBlockVertex { - const ATTRIBUTE_LAYOUT: &'static [wgpu::VertexAttribute] = &wgpu::vertex_attr_array![ - 0 => Uint32, // cube_packed - 1 => Uint32x2, // position_in_cube_and_normal_packed - 2 => Float32x4, // color_or_texture - 3 => Uint32x3, // clamp_min_max - // location numbers must not clash with WgpuInstanceData - ]; - - pub fn desc() -> wgpu::VertexBufferLayout<'static> { - wgpu::VertexBufferLayout { - array_stride: size_of::() as wgpu::BufferAddress, - step_mode: wgpu::VertexStepMode::Vertex, - attributes: Self::ATTRIBUTE_LAYOUT, - } - } + pub const LAYOUT: wgpu::VertexBufferLayout<'static> = wgpu::VertexBufferLayout { + array_stride: size_of::() as wgpu::BufferAddress, + step_mode: wgpu::VertexStepMode::Vertex, + attributes: &wgpu::vertex_attr_array![ + 0 => Uint32, // cube_packed + 1 => Uint32x2, // position_in_cube_and_normal_packed + 2 => Float32x4, // color_or_texture + 3 => Uint32x3, // clamp_min_max + // location numbers must not clash with WgpuInstanceData + ], + }; } impl From> for WgpuBlockVertex { @@ -188,18 +184,16 @@ pub(crate) struct WgpuInstanceData { } impl WgpuInstanceData { - const ATTRIBUTE_LAYOUT: &'static [wgpu::VertexAttribute] = &wgpu::vertex_attr_array![ - // location numbers must start after WgpuBlockVertex ends - 6 => Float32x3, - ]; - - pub fn desc() -> wgpu::VertexBufferLayout<'static> { - wgpu::VertexBufferLayout { - array_stride: size_of::() as wgpu::BufferAddress, - step_mode: wgpu::VertexStepMode::Instance, - attributes: Self::ATTRIBUTE_LAYOUT, - } - } + pub const LAYOUT: wgpu::VertexBufferLayout<'static> = wgpu::VertexBufferLayout { + array_stride: size_of::() as wgpu::BufferAddress, + step_mode: wgpu::VertexStepMode::Instance, + attributes: const { + &wgpu::vertex_attr_array![ + // location numbers must start after WgpuBlockVertex ends + 6 => Float32x3, + ] + }, + }; pub fn new(translation: GridVector) -> Self { Self { @@ -217,18 +211,14 @@ pub(crate) struct WgpuLinesVertex { } impl WgpuLinesVertex { - const ATTRIBUTE_LAYOUT: &'static [wgpu::VertexAttribute] = &wgpu::vertex_attr_array![ - 0 => Float32x3, - 1 => Float32x4, - ]; - - pub fn desc() -> wgpu::VertexBufferLayout<'static> { - wgpu::VertexBufferLayout { - array_stride: size_of::() as wgpu::BufferAddress, - step_mode: wgpu::VertexStepMode::Vertex, - attributes: Self::ATTRIBUTE_LAYOUT, - } - } + pub const LAYOUT: wgpu::VertexBufferLayout<'static> = wgpu::VertexBufferLayout { + array_stride: size_of::() as wgpu::BufferAddress, + step_mode: wgpu::VertexStepMode::Vertex, + attributes: &wgpu::vertex_attr_array![ + 0 => Float32x3, + 1 => Float32x4, + ], + }; } impl DebugLineVertex for WgpuLinesVertex {