Simplify rendering pipeline, reduce gpu memory usage, remove duplicated data

This commit is contained in:
Pēteris Pakalns 2024-03-12 18:19:14 +02:00 committed by Héctor Ramón Jiménez
parent c69090f74b
commit 883b9170b4
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 40 additions and 110 deletions

View file

@ -5,9 +5,9 @@ use wgpu::{
BindingResource, BindingType, BlendState, Buffer, BufferBindingType, ColorTargetState,
ColorWrites, DepthStencilState, Device, FilterMode, FragmentState, MultisampleState,
PipelineCompilationOptions, PipelineLayout, PipelineLayoutDescriptor, PrimitiveState,
RenderPipeline, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor,
ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStages, TextureFormat,
TextureSampleType, TextureView, TextureViewDimension, VertexFormat, VertexState,
PrimitiveTopology, RenderPipeline, RenderPipelineDescriptor, Sampler, SamplerBindingType,
SamplerDescriptor, ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStages,
TextureFormat, TextureSampleType, TextureView, TextureViewDimension, VertexFormat, VertexState,
};
use std::borrow::Cow;
@ -56,7 +56,7 @@ impl Cache {
let vertex_buffer_layout = wgpu::VertexBufferLayout {
array_stride: mem::size_of::<GlyphToRender>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
step_mode: wgpu::VertexStepMode::Instance,
attributes: &[
wgpu::VertexAttribute {
format: VertexFormat::Sint32x2,
@ -232,7 +232,10 @@ impl Cache {
})],
compilation_options: PipelineCompilationOptions::default(),
}),
primitive: PrimitiveState::default(),
primitive: PrimitiveState {
topology: PrimitiveTopology::TriangleStrip,
..PrimitiveState::default()
},
depth_stencil: depth_stencil.clone(),
multisample,
multiview: None,