using pipeline
This commit is contained in:
+39
-36
@@ -48,52 +48,51 @@ impl App {
|
|||||||
};
|
};
|
||||||
let swapchain = device.create_swap_chain(&surface, &swapchain_desc);
|
let swapchain = device.create_swap_chain(&surface, &swapchain_desc);
|
||||||
|
|
||||||
// Create pipeline
|
// Pipeline stuff
|
||||||
let vert_module = device.create_shader_module(&wgpu::include_spirv!(".bin\\shader.vert.spv"));
|
|
||||||
let frag_module = device.create_shader_module(&wgpu::include_spirv!(".bin\\shader.frag.spv"));
|
|
||||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some("Render Pipeline Layout"),
|
label: Some("Render Pipeline Layout"),
|
||||||
bind_group_layouts: &[],
|
bind_group_layouts: &[],
|
||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
let vert_state = wgpu::VertexState { //vert
|
||||||
|
module: &device.create_shader_module(&wgpu::include_spirv!(".bin\\shader.vert.spv")),
|
||||||
|
entry_point: "main",
|
||||||
|
buffers: &[],
|
||||||
|
};
|
||||||
|
let frag_state = wgpu::FragmentState { // frag
|
||||||
|
module: &device.create_shader_module(&wgpu::include_spirv!(".bin\\shader.frag.spv")),
|
||||||
|
entry_point: "main",
|
||||||
|
targets: &[wgpu::ColorTargetState {
|
||||||
|
format: swapchain_desc.format,
|
||||||
|
alpha_blend: wgpu::BlendState::REPLACE,
|
||||||
|
color_blend: wgpu::BlendState::REPLACE,
|
||||||
|
write_mask: wgpu::ColorWrite::ALL,
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
let prim_state = wgpu::PrimitiveState { // primitive
|
||||||
|
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||||
|
strip_index_format: None,
|
||||||
|
front_face: wgpu::FrontFace::Ccw,
|
||||||
|
cull_mode: wgpu::CullMode::Back,
|
||||||
|
polygon_mode: wgpu::PolygonMode::Fill,
|
||||||
|
};
|
||||||
|
let multisample_state = wgpu::MultisampleState { // multisample
|
||||||
|
count: 1,
|
||||||
|
mask: !0,
|
||||||
|
alpha_to_coverage_enabled: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create pipeline
|
||||||
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Render Pipeline"),
|
label: Some("Render Pipeline"),
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
// Vertex shader
|
vertex: vert_state,
|
||||||
vertex: wgpu::VertexState {
|
fragment: Some(frag_state),
|
||||||
module: &vert_module,
|
primitive: prim_state,
|
||||||
entry_point: "main",
|
|
||||||
buffers: &[],
|
|
||||||
},
|
|
||||||
// Fragment shader
|
|
||||||
fragment: Some(wgpu::FragmentState {
|
|
||||||
module: &frag_module,
|
|
||||||
entry_point: "main",
|
|
||||||
targets: &[wgpu::ColorTargetState {
|
|
||||||
format: swapchain_desc.format,
|
|
||||||
alpha_blend: wgpu::BlendState::REPLACE,
|
|
||||||
color_blend: wgpu::BlendState::REPLACE,
|
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
|
||||||
}],
|
|
||||||
}),
|
|
||||||
// Other
|
|
||||||
primitive: wgpu::PrimitiveState {
|
|
||||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
|
||||||
strip_index_format: None,
|
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
|
||||||
cull_mode: wgpu::CullMode::Back,
|
|
||||||
polygon_mode: wgpu::PolygonMode::Fill,
|
|
||||||
},
|
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState {
|
multisample: multisample_state,
|
||||||
count: 1,
|
|
||||||
mask: !0,
|
|
||||||
alpha_to_coverage_enabled: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Save values in app
|
// Save values in app
|
||||||
Self { surface, device, queue, swapchain_desc, swapchain, pipeline }
|
Self { surface, device, queue, swapchain_desc, swapchain, pipeline }
|
||||||
}
|
}
|
||||||
@@ -133,7 +132,8 @@ impl App {
|
|||||||
store: true,
|
store: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("Render Pass"),
|
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
label: Some("Render Pass"),
|
||||||
color_attachments: &[
|
color_attachments: &[
|
||||||
wgpu::RenderPassColorAttachmentDescriptor {
|
wgpu::RenderPassColorAttachmentDescriptor {
|
||||||
attachment: &frame.view,
|
attachment: &frame.view,
|
||||||
@@ -143,6 +143,9 @@ impl App {
|
|||||||
],
|
],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
render_pass.set_pipeline(&self.pipeline);
|
||||||
|
render_pass.draw(0..3, 0..1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit encoder (command buffer)
|
// Submit encoder (command buffer)
|
||||||
|
|||||||
Reference in New Issue
Block a user