sky_pipeline.rs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. use wgpu::{include_wgsl, RenderPipeline};
  2. pub fn new(device: &wgpu::Device, config: &wgpu::SurfaceConfiguration) -> RenderPipeline {
  3. let sky_shader = device.create_shader_module(include_wgsl!("../shaders/sky.wgsl"));
  4. let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
  5. label: Some("Sky Render Pipeline Layout"),
  6. bind_group_layouts: &[],
  7. push_constant_ranges: &[],
  8. });
  9. let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
  10. label: Some("Sky Render Pipeline"),
  11. layout: Some(&render_pipeline_layout),
  12. vertex: wgpu::VertexState {
  13. module: &sky_shader,
  14. entry_point: "vs_main",
  15. buffers: &[],
  16. },
  17. primitive: wgpu::PrimitiveState {
  18. topology: wgpu::PrimitiveTopology::TriangleList,
  19. strip_index_format: None,
  20. front_face: wgpu::FrontFace::Ccw,
  21. conservative: false,
  22. cull_mode: None,
  23. unclipped_depth: false,
  24. polygon_mode: wgpu::PolygonMode::Fill,
  25. },
  26. depth_stencil: None,
  27. multisample: wgpu::MultisampleState {
  28. count: 1,
  29. mask: !0,
  30. alpha_to_coverage_enabled: false,
  31. },
  32. fragment: Some(wgpu::FragmentState {
  33. module: &sky_shader,
  34. entry_point: "fs_main",
  35. targets: &[Some(wgpu::ColorTargetState {
  36. format: config.format,
  37. blend: Some(wgpu::BlendState::REPLACE),
  38. write_mask: wgpu::ColorWrites::ALL,
  39. })],
  40. }),
  41. multiview: None,
  42. });
  43. return render_pipeline;
  44. }