Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cubemap-pcf
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Apr 10, 2024
2 parents bff3a11 + 11817f4 commit a83613e
Show file tree
Hide file tree
Showing 55 changed files with 2,641 additions and 1,039 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,17 @@ description = "A simple game menu"
category = "Games"
wasm = true

[[example]]
name = "loading_screen"
path = "examples/games/loading_screen.rs"
doc-scrape-examples = true

[package.metadata.example.loading_screen]
name = "Loading Screen"
description = "Demonstrates how to create a loading screen that waits for all assets to be loaded and render pipelines to be compiled."
category = "Games"
wasm = true

# Input
[[example]]
name = "char_input_events"
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use bevy_render::{
*,
},
renderer::RenderDevice,
texture::{BevyDefault, Image},
texture::{BevyDefault, GpuImage, Image},
view::{ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniforms},
Render, RenderApp, RenderSet,
};
Expand Down Expand Up @@ -236,7 +236,7 @@ fn prepare_skybox_bind_groups(
pipeline: Res<SkyboxPipeline>,
view_uniforms: Res<ViewUniforms>,
skybox_uniforms: Res<ComponentUniforms<SkyboxUniforms>>,
images: Res<RenderAssets<Image>>,
images: Res<RenderAssets<GpuImage>>,
render_device: Res<RenderDevice>,
views: Query<(Entity, &Skybox, &DynamicUniformIndex<SkyboxUniforms>)>,
) {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_render::render_resource::binding_types::{
sampler, texture_2d, texture_3d, uniform_buffer,
};
use bevy_render::renderer::RenderDevice;
use bevy_render::texture::{CompressedImageFormats, Image, ImageSampler, ImageType};
use bevy_render::texture::{CompressedImageFormats, GpuImage, Image, ImageSampler, ImageType};
use bevy_render::view::{ViewTarget, ViewUniform};
use bevy_render::{camera::Camera, texture::FallbackImage};
use bevy_render::{render_resource::*, Render, RenderApp, RenderSet};
Expand Down Expand Up @@ -319,7 +319,7 @@ pub enum DebandDither {
}

pub fn get_lut_bindings<'a>(
images: &'a RenderAssets<Image>,
images: &'a RenderAssets<GpuImage>,
tonemapping_luts: &'a TonemappingLuts,
tonemapping: &Tonemapping,
fallback_image: &'a FallbackImage,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bevy_render::{
RenderPassColorAttachment, RenderPassDescriptor, StoreOp, TextureViewId,
},
renderer::RenderContext,
texture::{FallbackImage, Image},
texture::{FallbackImage, GpuImage},
view::{ViewTarget, ViewUniformOffset, ViewUniforms},
};

Expand Down Expand Up @@ -42,7 +42,7 @@ impl ViewNode for TonemappingNode {
) -> Result<(), NodeRunError> {
let pipeline_cache = world.resource::<PipelineCache>();
let tonemapping_pipeline = world.resource::<TonemappingPipeline>();
let gpu_images = world.get_resource::<RenderAssets<Image>>().unwrap();
let gpu_images = world.get_resource::<RenderAssets<GpuImage>>().unwrap();
let fallback_image = world.resource::<FallbackImage>();
let view_uniforms_resource = world.resource::<ViewUniforms>();
let view_uniforms = &view_uniforms_resource.uniforms;
Expand Down
32 changes: 13 additions & 19 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ use bevy_math::Vec3;
use bevy_reflect::TypePath;
use bevy_render::{
extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin},
render_asset::{
PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssetUsages, RenderAssets,
},
render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets},
render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass},
render_resource::{
binding_types::uniform_buffer, BindGroup, BindGroupEntries, BindGroupLayout,
Expand Down Expand Up @@ -129,7 +127,7 @@ impl Plugin for GizmoPlugin {
.register_type::<GizmoConfigStore>()
.add_plugins(UniformComponentPlugin::<LineGizmoUniform>::default())
.init_asset::<LineGizmo>()
.add_plugins(RenderAssetPlugin::<LineGizmo>::default())
.add_plugins(RenderAssetPlugin::<GpuLineGizmo>::default())
.init_resource::<LineGizmoHandles>()
// We insert the Resource GizmoConfigStore into the world implicitly here if it does not exist.
.init_gizmo_group::<DefaultGizmoConfigGroup>()
Expand Down Expand Up @@ -377,26 +375,22 @@ struct GpuLineGizmo {
joints: GizmoLineJoint,
}

impl RenderAsset for LineGizmo {
type PreparedAsset = GpuLineGizmo;
impl RenderAsset for GpuLineGizmo {
type SourceAsset = LineGizmo;
type Param = SRes<RenderDevice>;

fn asset_usage(&self) -> RenderAssetUsages {
RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD
}

fn prepare_asset(
self,
gizmo: Self::SourceAsset,
render_device: &mut SystemParamItem<Self::Param>,
) -> Result<Self::PreparedAsset, PrepareAssetError<Self>> {
let position_buffer_data = cast_slice(&self.positions);
) -> Result<Self, PrepareAssetError<Self::SourceAsset>> {
let position_buffer_data = cast_slice(&gizmo.positions);
let position_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor {
usage: BufferUsages::VERTEX,
label: Some("LineGizmo Position Buffer"),
contents: position_buffer_data,
});

let color_buffer_data = cast_slice(&self.colors);
let color_buffer_data = cast_slice(&gizmo.colors);
let color_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor {
usage: BufferUsages::VERTEX,
label: Some("LineGizmo Color Buffer"),
Expand All @@ -406,9 +400,9 @@ impl RenderAsset for LineGizmo {
Ok(GpuLineGizmo {
position_buffer,
color_buffer,
vertex_count: self.positions.len() as u32,
strip: self.strip,
joints: self.joints,
vertex_count: gizmo.positions.len() as u32,
strip: gizmo.strip,
joints: gizmo.joints,
})
}
}
Expand Down Expand Up @@ -468,7 +462,7 @@ impl<const I: usize, P: PhaseItem> RenderCommand<P> for SetLineGizmoBindGroup<I>

struct DrawLineGizmo;
impl<P: PhaseItem> RenderCommand<P> for DrawLineGizmo {
type Param = SRes<RenderAssets<LineGizmo>>;
type Param = SRes<RenderAssets<GpuLineGizmo>>;
type ViewQuery = ();
type ItemQuery = Read<Handle<LineGizmo>>;

Expand Down Expand Up @@ -514,7 +508,7 @@ impl<P: PhaseItem> RenderCommand<P> for DrawLineGizmo {

struct DrawLineJointGizmo;
impl<P: PhaseItem> RenderCommand<P> for DrawLineJointGizmo {
type Param = SRes<RenderAssets<LineGizmo>>;
type Param = SRes<RenderAssets<GpuLineGizmo>>;
type ViewQuery = ();
type ItemQuery = Read<Handle<LineGizmo>>;

Expand Down
11 changes: 6 additions & 5 deletions crates/bevy_gizmos/src/pipeline_2d.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
config::{GizmoLineJoint, GizmoLineStyle, GizmoMeshConfig},
line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, DrawLineGizmo,
DrawLineJointGizmo, GizmoRenderSystem, LineGizmo, LineGizmoUniformBindgroupLayout,
SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE, LINE_SHADER_HANDLE,
DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LineGizmo,
LineGizmoUniformBindgroupLayout, SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE,
LINE_SHADER_HANDLE,
};
use bevy_app::{App, Plugin};
use bevy_asset::Handle;
Expand Down Expand Up @@ -52,7 +53,7 @@ impl Plugin for LineGizmo2dPlugin {
Render,
(queue_line_gizmos_2d, queue_line_joint_gizmos_2d)
.in_set(GizmoRenderSystem::QueueLineGizmos2d)
.after(prepare_assets::<LineGizmo>),
.after(prepare_assets::<GpuLineGizmo>),
);
}

Expand Down Expand Up @@ -253,7 +254,7 @@ fn queue_line_gizmos_2d(
pipeline_cache: Res<PipelineCache>,
msaa: Res<Msaa>,
line_gizmos: Query<(Entity, &Handle<LineGizmo>, &GizmoMeshConfig)>,
line_gizmo_assets: Res<RenderAssets<LineGizmo>>,
line_gizmo_assets: Res<RenderAssets<GpuLineGizmo>>,
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent2d>,
Expand Down Expand Up @@ -306,7 +307,7 @@ fn queue_line_joint_gizmos_2d(
pipeline_cache: Res<PipelineCache>,
msaa: Res<Msaa>,
line_gizmos: Query<(Entity, &Handle<LineGizmo>, &GizmoMeshConfig)>,
line_gizmo_assets: Res<RenderAssets<LineGizmo>>,
line_gizmo_assets: Res<RenderAssets<GpuLineGizmo>>,
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent2d>,
Expand Down
11 changes: 6 additions & 5 deletions crates/bevy_gizmos/src/pipeline_3d.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
config::{GizmoLineJoint, GizmoLineStyle, GizmoMeshConfig},
line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, DrawLineGizmo,
DrawLineJointGizmo, GizmoRenderSystem, LineGizmo, LineGizmoUniformBindgroupLayout,
SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE, LINE_SHADER_HANDLE,
DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LineGizmo,
LineGizmoUniformBindgroupLayout, SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE,
LINE_SHADER_HANDLE,
};
use bevy_app::{App, Plugin};
use bevy_asset::Handle;
Expand Down Expand Up @@ -51,7 +52,7 @@ impl Plugin for LineGizmo3dPlugin {
Render,
(queue_line_gizmos_3d, queue_line_joint_gizmos_3d)
.in_set(GizmoRenderSystem::QueueLineGizmos3d)
.after(prepare_assets::<LineGizmo>),
.after(prepare_assets::<GpuLineGizmo>),
);
}

Expand Down Expand Up @@ -278,7 +279,7 @@ fn queue_line_gizmos_3d(
pipeline_cache: Res<PipelineCache>,
msaa: Res<Msaa>,
line_gizmos: Query<(Entity, &Handle<LineGizmo>, &GizmoMeshConfig)>,
line_gizmo_assets: Res<RenderAssets<LineGizmo>>,
line_gizmo_assets: Res<RenderAssets<GpuLineGizmo>>,
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent3d>,
Expand Down Expand Up @@ -361,7 +362,7 @@ fn queue_line_joint_gizmos_3d(
pipeline_cache: Res<PipelineCache>,
msaa: Res<Msaa>,
line_gizmos: Query<(Entity, &Handle<LineGizmo>, &GizmoMeshConfig)>,
line_gizmo_assets: Res<RenderAssets<LineGizmo>>,
line_gizmo_assets: Res<RenderAssets<GpuLineGizmo>>,
mut views: Query<(
&ExtractedView,
&mut SortedRenderPhase<Transparent3d>,
Expand Down
Loading

0 comments on commit a83613e

Please sign in to comment.