Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_render/src/render_resource/pipeline.rs
9374 views
1
use crate::renderer::WgpuWrapper;
2
use bevy_utils::define_atomic_id;
3
use core::ops::Deref;
4
5
define_atomic_id!(RenderPipelineId);
6
7
/// A [`RenderPipeline`] represents a graphics pipeline and its stages (shaders), bindings and vertex buffers.
8
///
9
/// May be converted from and dereferences to a wgpu [`RenderPipeline`](wgpu::RenderPipeline).
10
/// Can be created via [`RenderDevice::create_render_pipeline`](crate::renderer::RenderDevice::create_render_pipeline).
11
#[derive(Clone, Debug)]
12
pub struct RenderPipeline {
13
id: RenderPipelineId,
14
value: WgpuWrapper<wgpu::RenderPipeline>,
15
}
16
17
impl RenderPipeline {
18
#[inline]
19
pub fn id(&self) -> RenderPipelineId {
20
self.id
21
}
22
}
23
24
impl From<wgpu::RenderPipeline> for RenderPipeline {
25
fn from(value: wgpu::RenderPipeline) -> Self {
26
RenderPipeline {
27
id: RenderPipelineId::new(),
28
value: WgpuWrapper::new(value),
29
}
30
}
31
}
32
33
impl Deref for RenderPipeline {
34
type Target = wgpu::RenderPipeline;
35
36
#[inline]
37
fn deref(&self) -> &Self::Target {
38
&self.value
39
}
40
}
41
42
define_atomic_id!(ComputePipelineId);
43
44
/// A [`ComputePipeline`] represents a compute pipeline and its single shader stage.
45
///
46
/// May be converted from and dereferences to a wgpu [`ComputePipeline`](wgpu::ComputePipeline).
47
/// Can be created via [`RenderDevice::create_compute_pipeline`](crate::renderer::RenderDevice::create_compute_pipeline).
48
#[derive(Clone, Debug)]
49
pub struct ComputePipeline {
50
id: ComputePipelineId,
51
value: WgpuWrapper<wgpu::ComputePipeline>,
52
}
53
54
impl ComputePipeline {
55
/// Returns the [`ComputePipelineId`].
56
#[inline]
57
pub fn id(&self) -> ComputePipelineId {
58
self.id
59
}
60
}
61
62
impl From<wgpu::ComputePipeline> for ComputePipeline {
63
fn from(value: wgpu::ComputePipeline) -> Self {
64
ComputePipeline {
65
id: ComputePipelineId::new(),
66
value: WgpuWrapper::new(value),
67
}
68
}
69
}
70
71
impl Deref for ComputePipeline {
72
type Target = wgpu::ComputePipeline;
73
74
#[inline]
75
fn deref(&self) -> &Self::Target {
76
&self.value
77
}
78
}
79
80