| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- use wgpu::{include_wgsl, BlendState, ColorTargetState, RenderPipeline, RenderPipelineDescriptor, SurfaceConfiguration};
- use crate::object;
- pub fn new(device: &wgpu::Device, config: &SurfaceConfiguration,camera_bind_group_layout: &wgpu::BindGroupLayout, diffuse_bind_group_layout: &wgpu::BindGroupLayout, visu_bind_group_layout: &wgpu::BindGroupLayout)-> RenderPipeline{
- let wireframe_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor{
- label: Some("Wireframe Pipeline Layout"),
- bind_group_layouts: &[
- &camera_bind_group_layout,
- &diffuse_bind_group_layout,
- &visu_bind_group_layout,
- ],
- push_constant_ranges: &[]
- });
- let shader_module = device.create_shader_module(include_wgsl!("../shaders/plane_shader.wgsl"));
- let wireframe_pipeline = device.create_render_pipeline(&RenderPipelineDescriptor{
- label: Some("Wireframe Pipeline"),
- layout: Some(&wireframe_layout),
- vertex: wgpu::VertexState {
- module: &shader_module,
- entry_point: "vs_main".into(),
- buffers: &[
- object::Vertex::desc(),
- ],
- },
- primitive: wgpu::PrimitiveState{
- topology: wgpu::PrimitiveTopology::TriangleList,
- strip_index_format: None,
- front_face: wgpu::FrontFace::Ccw,
- cull_mode: None,
- unclipped_depth: false,
- polygon_mode: wgpu::PolygonMode::Line, //Or wgpu::PolygonMode::Fill
- conservative: false
- },
- depth_stencil: None,
- multisample: wgpu::MultisampleState{
- count: 1,
- mask: !0,
- alpha_to_coverage_enabled: false,
- },
- fragment: Some(wgpu::FragmentState{
- module: &shader_module,
- entry_point: "fs_main",
- targets: &[Some(ColorTargetState{
- format: config.format,
- blend: Some(BlendState::REPLACE),
- write_mask: wgpu::ColorWrites::ALL
- })]
- }),
- multiview: None
- });
- return wireframe_pipeline
- }
|