Skip to content

Commit 3666712

Browse files
committed
rebased onto main
fixed GPU* in docs type aliased GpuCommandEncoder renamed GpuContext::command_encoder to GpuContext::gpu_command_encoder
1 parent 1cc0598 commit 3666712

File tree

18 files changed

+55
-46
lines changed

18 files changed

+55
-46
lines changed

crates/bevy_core_pipeline/src/bloom/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl Node for BloomNode {
232232
{
233233
let view = &BloomTextures::texture_view(&textures.texture_a, 0);
234234
let mut prefilter_pass =
235-
TrackedRenderPass::new(gpu_context.command_encoder.begin_render_pass(
235+
TrackedRenderPass::new(gpu_context.gpu_command_encoder.begin_render_pass(
236236
&RenderPassDescriptor {
237237
label: Some("bloom_prefilter_pass"),
238238
color_attachments: &[Some(RenderPassColorAttachment {
@@ -258,7 +258,7 @@ impl Node for BloomNode {
258258
for mip in 1..textures.mip_count {
259259
let view = &BloomTextures::texture_view(&textures.texture_a, mip);
260260
let mut downsampling_pass =
261-
TrackedRenderPass::new(gpu_context.command_encoder.begin_render_pass(
261+
TrackedRenderPass::new(gpu_context.gpu_command_encoder.begin_render_pass(
262262
&RenderPassDescriptor {
263263
label: Some("bloom_downsampling_pass"),
264264
color_attachments: &[Some(RenderPassColorAttachment {
@@ -284,7 +284,7 @@ impl Node for BloomNode {
284284
for mip in (1..textures.mip_count).rev() {
285285
let view = &BloomTextures::texture_view(&textures.texture_b, mip - 1);
286286
let mut upsampling_pass =
287-
TrackedRenderPass::new(gpu_context.command_encoder.begin_render_pass(
287+
TrackedRenderPass::new(gpu_context.gpu_command_encoder.begin_render_pass(
288288
&RenderPassDescriptor {
289289
label: Some("bloom_upsampling_pass"),
290290
color_attachments: &[Some(RenderPassColorAttachment {
@@ -309,7 +309,7 @@ impl Node for BloomNode {
309309

310310
{
311311
let mut upsampling_final_pass =
312-
TrackedRenderPass::new(gpu_context.command_encoder.begin_render_pass(
312+
TrackedRenderPass::new(gpu_context.gpu_command_encoder.begin_render_pass(
313313
&RenderPassDescriptor {
314314
label: Some("bloom_upsampling_final_pass"),
315315
color_attachments: &[Some(view_target.get_unsampled_color_attachment(

crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Node for MainPass2dNode {
102102
};
103103

104104
gpu_context
105-
.command_encoder
105+
.gpu_command_encoder
106106
.begin_render_pass(&pass_descriptor);
107107
}
108108

crates/bevy_core_pipeline/src/core_3d/main_pass_3d_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Node for MainPass3dNode {
189189
};
190190

191191
gpu_context
192-
.command_encoder
192+
.gpu_command_encoder
193193
.begin_render_pass(&pass_descriptor);
194194
}
195195

crates/bevy_core_pipeline/src/fxaa/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Node for FxaaNode {
117117
};
118118

119119
let mut render_pass = gpu_context
120-
.command_encoder
120+
.gpu_command_encoder
121121
.begin_render_pass(&pass_descriptor);
122122

123123
render_pass.set_pipeline(pipeline);

crates/bevy_core_pipeline/src/tonemapping/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl Node for TonemappingNode {
111111
};
112112

113113
let mut render_pass = gpu_context
114-
.command_encoder
114+
.gpu_command_encoder
115115
.begin_render_pass(&pass_descriptor);
116116

117117
render_pass.set_pipeline(pipeline);

crates/bevy_core_pipeline/src/upscaling/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl Node for UpscalingNode {
107107
};
108108

109109
let mut render_pass = gpu_context
110-
.command_encoder
110+
.gpu_command_encoder
111111
.begin_render_pass(&pass_descriptor);
112112

113113
render_pass.set_pipeline(pipeline);

crates/bevy_internal/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ pub mod pbr {
136136
#[cfg(feature = "bevy_render")]
137137
pub mod render {
138138
//! Cameras, meshes, textures, shaders, and pipelines.
139-
//! Use [`GPUDevice::features`](crate::render::renderer::GpuDevice::features),
140-
//! [`GPUDevice::limits`](crate::render::renderer::GpuDevice::limits), and the
141-
//! [`RenderAdapterInfo`](crate::render::renderer::RenderAdapterInfo) resource to
139+
//! Use [`GpuDevice::features`](crate::render::renderer::GpuDevice::features),
140+
//! [`GpuDevice::limits`](crate::render::renderer::GpuDevice::limits), and the
141+
//! [`GpuAdapterInfo`](crate::render::renderer::GpuAdapterInfo) resource to
142142
//! get runtime information about the actual adapter, backend, features, and limits.
143143
pub use bevy_render::*;
144144
}

crates/bevy_render/src/camera/camera_driver_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl Node for CameraDriverNode {
9898
};
9999

100100
gpu_context
101-
.command_encoder
101+
.gpu_command_encoder
102102
.begin_render_pass(&pass_descriptor);
103103
}
104104

crates/bevy_render/src/render_phase/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
mod draw;
22
mod draw_state;
33

4-
use bevy_ecs::entity::Entity;
54
pub use draw::*;
65
pub use draw_state::*;
7-
use wgpu::RenderPassDescriptor;
86

9-
use crate::camera::Viewport;
10-
use crate::renderer::RenderContext;
11-
use bevy_ecs::prelude::{Component, Query};
12-
use bevy_ecs::world::World;
7+
use crate::{camera::Viewport, renderer::GpuContext};
8+
use bevy_ecs::{
9+
entity::Entity,
10+
prelude::{Component, Query},
11+
world::World,
12+
};
13+
use wgpu::RenderPassDescriptor;
1314

1415
/// A resource to collect and sort draw requests for specific [`PhaseItems`](PhaseItem).
1516
#[derive(Component)]
@@ -38,13 +39,13 @@ impl<I: PhaseItem> RenderPhase<I> {
3839
pub fn render(
3940
&self,
4041
world: &World,
41-
render_context: &mut RenderContext,
42+
gpu_context: &mut GpuContext,
4243
view: Entity,
4344
viewport: Option<&Viewport>,
4445
pass_descriptor: RenderPassDescriptor,
4546
) {
46-
let render_pass = render_context
47-
.command_encoder
47+
let render_pass = gpu_context
48+
.gpu_command_encoder
4849
.begin_render_pass(&pass_descriptor);
4950
let mut render_pass = TrackedRenderPass::new(render_pass);
5051

crates/bevy_render/src/render_resource/bind_group.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ render_resource_wrapper!(ErasedBindGroup, wgpu::BindGroup);
1919
/// This makes them accessible in the pipeline (shaders) as uniforms.
2020
///
2121
/// May be converted from and dereferences to a wgpu [`BindGroup`](wgpu::BindGroup).
22-
/// Can be created via [`GPUDevice::create_bind_group`](crate::renderer::GpuDevice::create_bind_group).
22+
/// Can be created via [`GpuDevice::create_bind_group`](crate::renderer::GpuDevice::create_bind_group).
2323
#[derive(Clone, Debug)]
2424
pub struct BindGroup {
2525
id: BindGroupId,

crates/bevy_render/src/render_resource/buffer_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use wgpu::BufferUsages;
1616
/// so this helper type is a good choice for them.
1717
///
1818
/// The contained data is stored in system RAM. Calling [`reserve`](crate::render_resource::BufferVec::reserve)
19-
/// allocates VRAM from the [`GPUDevice`](crate::renderer::GpuDevice).
19+
/// allocates VRAM from the [`GpuDevice`](crate::renderer::GpuDevice).
2020
/// [`write_buffer`](crate::render_resource::BufferVec::write_buffer) queues copying of the data
2121
/// from system RAM to VRAM.
2222
///
@@ -89,7 +89,7 @@ impl<T: Pod> BufferVec<T> {
8989
self.label.as_deref()
9090
}
9191

92-
/// Creates a [`Buffer`](crate::render_resource::Buffer) on the [`GPUDevice`](crate::renderer::GpuDevice) with size
92+
/// Creates a [`Buffer`](crate::render_resource::Buffer) on the [`GpuDevice`](crate::renderer::GpuDevice) with size
9393
/// at least `std::mem::size_of::<T>() * capacity`, unless a such a buffer already exists.
9494
///
9595
/// If a [`Buffer`](crate::render_resource::Buffer) exists, but is too small, references to it will be discarded,

crates/bevy_render/src/render_resource/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ pub use wgpu::{
2929
BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType,
3030
BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress, BufferBinding,
3131
BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState, ColorWrites,
32-
CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, ComputePassDescriptor,
32+
CommandEncoderDescriptor, CompareFunction, ComputePass, ComputePassDescriptor,
3333
ComputePipelineDescriptor as RawComputePipelineDescriptor, DepthBiasState, DepthStencilState,
3434
Extent3d, Face, Features as WgpuFeatures, FilterMode, FragmentState as RawFragmentState,
3535
FrontFace, ImageCopyBuffer, ImageCopyBufferBase, ImageCopyTexture, ImageCopyTextureBase,
3636
ImageDataLayout, ImageSubresourceRange, IndexFormat, Limits as WgpuLimits, LoadOp, MapMode,
3737
MultisampleState, Operations, Origin3d, PipelineLayout, PipelineLayoutDescriptor, PolygonMode,
38-
PrimitiveState, PrimitiveTopology, RenderPassColorAttachment, RenderPassDepthStencilAttachment,
39-
RenderPassDescriptor, RenderPipelineDescriptor as RawRenderPipelineDescriptor,
40-
SamplerBindingType, SamplerDescriptor, ShaderModule, ShaderModuleDescriptor, ShaderSource,
41-
ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess,
42-
TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType,
43-
TextureUsages, TextureViewDescriptor, TextureViewDimension, VertexAttribute,
44-
VertexBufferLayout as RawVertexBufferLayout, VertexFormat, VertexState as RawVertexState,
45-
VertexStepMode,
38+
PrimitiveState, PrimitiveTopology, RenderPass, RenderPassColorAttachment,
39+
RenderPassDepthStencilAttachment, RenderPassDescriptor,
40+
RenderPipelineDescriptor as RawRenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor,
41+
ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStages, StencilFaceState,
42+
StencilOperation, StencilState, StorageTextureAccess, TextureAspect, TextureDescriptor,
43+
TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureViewDescriptor,
44+
TextureViewDimension, VertexAttribute, VertexBufferLayout as RawVertexBufferLayout,
45+
VertexFormat, VertexState as RawVertexState, VertexStepMode,
4646
};
4747

4848
pub mod encase {

crates/bevy_render/src/render_resource/pipeline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ render_resource_wrapper!(ErasedRenderPipeline, wgpu::RenderPipeline);
1616
/// A [`RenderPipeline`] represents a graphics pipeline and its stages (shaders), bindings and vertex buffers.
1717
///
1818
/// May be converted from and dereferences to a wgpu [`RenderPipeline`](wgpu::RenderPipeline).
19-
/// Can be created via [`GPUDevice::create_render_pipeline`](crate::renderer::GpuDevice::create_render_pipeline).
19+
/// Can be created via [`GpuDevice::create_render_pipeline`](crate::renderer::GpuDevice::create_render_pipeline).
2020
#[derive(Clone, Debug)]
2121
pub struct RenderPipeline {
2222
id: RenderPipelineId,
@@ -54,7 +54,7 @@ render_resource_wrapper!(ErasedComputePipeline, wgpu::ComputePipeline);
5454
/// A [`ComputePipeline`] represents a compute pipeline and its single shader stage.
5555
///
5656
/// May be converted from and dereferences to a wgpu [`ComputePipeline`](wgpu::ComputePipeline).
57-
/// Can be created via [`GPUDevice::create_compute_pipeline`](crate::renderer::GpuDevice::create_compute_pipeline).
57+
/// Can be created via [`GpuDevice::create_compute_pipeline`](crate::renderer::GpuDevice::create_compute_pipeline).
5858
#[derive(Clone, Debug)]
5959
pub struct ComputePipeline {
6060
id: ComputePipelineId,

crates/bevy_render/src/render_resource/storage_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<T: ShaderType + WriteInto> StorageBuffer<T> {
101101
self.label.as_deref()
102102
}
103103

104-
/// Queues writing of data from system RAM to VRAM using the [`GPUDevice`](crate::renderer::GpuDevice)
104+
/// Queues writing of data from system RAM to VRAM using the [`GpuDevice`](crate::renderer::GpuDevice)
105105
/// and the provided [`GPUQueue`](crate::renderer::GpuQueue).
106106
///
107107
/// If there is no GPU-side buffer allocated to hold the data currently stored, or if a GPU-side buffer previously

crates/bevy_render/src/render_resource/texture.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ render_resource_wrapper!(ErasedTexture, wgpu::Texture);
99
/// A GPU-accessible texture.
1010
///
1111
/// May be converted from and dereferences to a wgpu [`Texture`](wgpu::Texture).
12-
/// Can be created via [`GPUDevice::create_texture`](crate::renderer::GpuDevice::create_texture).
12+
/// Can be created via [`GpuDevice::create_texture`](crate::renderer::GpuDevice::create_texture).
1313
#[derive(Clone, Debug)]
1414
pub struct Texture {
1515
id: TextureId,
@@ -135,7 +135,7 @@ render_resource_wrapper!(ErasedSampler, wgpu::Sampler);
135135
/// They define image filters (including anisotropy) and address (wrapping) modes, among other things.
136136
///
137137
/// May be converted from and dereferences to a wgpu [`Sampler`](wgpu::Sampler).
138-
/// Can be created via [`GPUDevice::create_sampler`](crate::renderer::GpuDevice::create_sampler).
138+
/// Can be created via [`GpuDevice::create_sampler`](crate::renderer::GpuDevice::create_sampler).
139139
#[derive(Clone, Debug)]
140140
pub struct Sampler {
141141
id: SamplerId,

crates/bevy_render/src/renderer/graph_runner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ impl RenderGraphRunner {
5858
queue: &wgpu::Queue,
5959
world: &World,
6060
) -> Result<(), RenderGraphRunnerError> {
61-
let command_encoder =
61+
let gpu_command_encoder =
6262
gpu_device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
6363
let mut gpu_context = GpuContext {
6464
gpu_device,
65-
command_encoder,
65+
gpu_command_encoder,
6666
};
6767

6868
Self::run_graph(graph, None, &mut gpu_context, world, &[])?;
6969
{
7070
#[cfg(feature = "trace")]
7171
let _span = info_span!("submit_graph_commands").entered();
72-
queue.submit(vec![gpu_context.command_encoder.finish()]);
72+
queue.submit(vec![gpu_context.gpu_command_encoder.finish()]);
7373
}
7474
Ok(())
7575
}

crates/bevy_render/src/renderer/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ pub struct GpuInstance(pub Instance);
102102
#[derive(Resource, Clone, Deref, DerefMut)]
103103
pub struct GpuAdapterInfo(pub AdapterInfo);
104104

105+
/// Encodes a series of GPU operations.
106+
///
107+
/// A command encoder can record [`RenderPass`](crate::render_resource::RenderPass)es,
108+
/// [`ComputePass`](crate::render_resource::ComputePass)es, and transfer operations between
109+
/// driver-managed resources like [`Buffer`](crate::render_resource::Buffer)s and
110+
/// [`Texture`](crate::render_resource::Texture)s.
111+
pub type GpuCommandEncoder = CommandEncoder;
112+
105113
const GPU_NOT_FOUND_ERROR_MESSAGE: &str = if cfg!(target_os = "linux") {
106114
"Unable to find a GPU! Make sure you have installed required drivers! For extra information, see: https://github.com/bevyengine/bevy/blob/latest/docs/linux_dependencies.md"
107115
} else {
@@ -273,9 +281,9 @@ pub async fn initialize_renderer(
273281

274282
/// The context with all information required to interact with the GPU.
275283
///
276-
/// The [`GpuDevice`] is used to create render resources and the
277-
/// the [`CommandEncoder`] is used to record a series of GPU operations.
284+
/// The [`GpuDevice`] is used to create gpu resources (buffers, bind groups, pipelines, etc.) and
285+
/// the [`GpuCommandEncoder`] is used to record a series of GPU operations.
278286
pub struct GpuContext {
279287
pub gpu_device: GpuDevice,
280-
pub command_encoder: CommandEncoder,
288+
pub gpu_command_encoder: GpuCommandEncoder,
281289
}

examples/shader/compute_shader_game_of_life.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl render_graph::Node for GameOfLifeNode {
215215
let pipeline = world.resource::<GameOfLifePipeline>();
216216

217217
let mut pass = gpu_context
218-
.command_encoder
218+
.gpu_command_encoder
219219
.begin_compute_pass(&ComputePassDescriptor::default());
220220

221221
pass.set_bind_group(0, texture_bind_group, &[]);

0 commit comments

Comments
 (0)