diff options
Diffstat (limited to 'client/src/scene_render.rs')
-rw-r--r-- | client/src/scene_render.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/client/src/scene_render.rs b/client/src/scene_render.rs index 366b956..b2cd915 100644 --- a/client/src/scene_render.rs +++ b/client/src/scene_render.rs @@ -4,7 +4,7 @@ use wgpu::{ BindGroup, BindGroupDescriptor, BindGroupLayoutDescriptor, BlendState, Color, ColorTargetState, ColorWrites, CommandEncoder, Device, FragmentState, FrontFace, IndexFormat, LoadOp, MultisampleState, Operations, PipelineCompilationOptions, PipelineLayoutDescriptor, - PolygonMode, PrimitiveState, PrimitiveTopology, RenderPassColorAttachment, + PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, ShaderStages, StoreOp, TextureFormat, TextureView, VertexAttribute, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, include_wgsl, @@ -33,7 +33,10 @@ impl ScenePipeline { let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor { label: None, bind_group_layouts: &[&bind_group_layout], - push_constant_ranges: &[], + push_constant_ranges: &[PushConstantRange { + range: 0..(12 * 4), + stages: ShaderStages::VERTEX, + }], }); let pipeline = device.create_render_pipeline(&RenderPipelineDescriptor { label: None, @@ -53,19 +56,12 @@ impl ScenePipeline { entry_point: Some("vs_main"), buffers: &[VertexBufferLayout { step_mode: VertexStepMode::Vertex, - array_stride: 2 * 4 * 3, - attributes: &[ - VertexAttribute { - format: VertexFormat::Float32x3, - offset: 0, - shader_location: 0, - }, - VertexAttribute { - format: VertexFormat::Float32x3, - offset: 3 * 4, - shader_location: 1, - }, - ], + array_stride: 4, + attributes: &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(|i| VertexAttribute { + format: VertexFormat::Float32, + offset: 0, + shader_location: i, + }), }], compilation_options: PipelineCompilationOptions::default(), }, @@ -111,13 +107,13 @@ impl ScenePipeline { })], ..Default::default() }); - rpass.set_bind_group(0, &self.bind_group, &[]); - rpass.set_pipeline(&self.pipeline); for ob in scene.objects.values() { if let Some(prefab) = prefabs.get(&ob.res) { for (affine, part) in &prefab.0 { let affine = affine.to_cols_array().map(|v| v.to_le_bytes()); + rpass.set_bind_group(0, &self.bind_group, &[]); + rpass.set_pipeline(&self.pipeline); rpass.set_push_constants(ShaderStages::VERTEX, 0, affine.as_flattened()); rpass.set_index_buffer(part.index.slice(..), IndexFormat::Uint16); rpass.set_vertex_buffer(0, part.position[0].slice(..)); |