Skip to content

Commit

Permalink
Rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Dec 28, 2023
1 parent 7c46e4c commit f3222fe
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 46 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_pbr/src/deferred/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ impl ViewNode for DeferredOpaquePass3dPbrLightingNode {

let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some("deferred_lighting_pass"),
color_attachments: &[Some(
target.get_color_attachment(Operations { load, store: true }),
)],
color_attachments: &[Some(target.get_color_attachment(Operations {
load,
store: StoreOp::Store,
}))],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &deferred_lighting_id_depth_texture.texture.default_view,
depth_ops: Some(Operations {
Expand Down
16 changes: 10 additions & 6 deletions crates/bevy_pbr/src/meshlet/material_draw_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
LoadOp, Operations, PipelineCache, RenderPassDepthStencilAttachment, RenderPassDescriptor,
StoreOp,
},
renderer::RenderContext,
view::{ViewTarget, ViewUniformOffset},
Expand All @@ -28,7 +29,7 @@ pub mod draw_3d_graph {
#[derive(Default)]
pub struct MeshletMainOpaquePass3dNode;
impl ViewNode for MeshletMainOpaquePass3dNode {
type ViewQuery = (
type ViewData = (
&'static ExtractedCamera,
&'static Camera3d,
&'static ViewTarget,
Expand Down Expand Up @@ -56,7 +57,7 @@ impl ViewNode for MeshletMainOpaquePass3dNode {
meshlet_view_materials,
meshlet_view_bind_groups,
meshlet_view_resources,
): QueryItem<Self::ViewQuery>,
): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let (Some(gpu_scene), Some(pipeline_cache)) = (
Expand All @@ -78,17 +79,20 @@ impl ViewNode for MeshletMainOpaquePass3dNode {

let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some(draw_3d_graph::node::MESHLET_MAIN_OPAQUE_PASS_3D),
color_attachments: &[Some(
target.get_color_attachment(Operations { load, store: true }),
)],
color_attachments: &[Some(target.get_color_attachment(Operations {
load,
store: StoreOp::Store,
}))],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &meshlet_view_resources.material_depth.default_view,
depth_ops: Some(Operations {
load: LoadOp::Load,
store: false,
store: StoreOp::Discard,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
if let Some(viewport) = camera.viewport.as_ref() {
render_pass.set_camera_viewport(viewport);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/meshlet/meshlet_bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ struct DrawIndexedIndirect {
#ifdef MESHLET_CULLING_PASS
@group(0) @binding(4) var<storage, read> meshlet_previous_thread_ids: array<u32>;
@group(0) @binding(5) var<storage, read> meshlet_previous_occlusion: array<u32>;
@group(0) @binding(6) var<storage, write> meshlet_occlusion: array<u32>;
@group(0) @binding(6) var<storage, read_write> meshlet_occlusion: array<u32>;
@group(0) @binding(7) var<storage, read> meshlet_bounding_spheres: array<MeshletBoundingSphere>;
@group(0) @binding(8) var<storage, read_write> draw_command_buffer: DrawIndexedIndirect;
@group(0) @binding(9) var<storage, write> draw_index_buffer: array<u32>;
@group(0) @binding(9) var<storage, read_write> draw_index_buffer: array<u32>;
@group(0) @binding(10) var<uniform> view: View;
#ifdef MESHLET_SECOND_CULLING_PASS
@group(0) @binding(11) var depth_pyramid: texture_2d<f32>;
Expand Down
28 changes: 19 additions & 9 deletions crates/bevy_pbr/src/meshlet/visibility_buffer_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
ComputePassDescriptor, IndexFormat, LoadOp, Operations, RenderPassColorAttachment,
RenderPassDepthStencilAttachment, RenderPassDescriptor,
RenderPassDepthStencilAttachment, RenderPassDescriptor, StoreOp,
},
renderer::RenderContext,
view::{ViewDepthTexture, ViewUniformOffset},
Expand All @@ -25,7 +25,7 @@ pub mod draw_3d_graph {
#[derive(Default)]
pub struct MeshletVisibilityBufferPassNode;
impl ViewNode for MeshletVisibilityBufferPassNode {
type ViewQuery = (
type ViewData = (
&'static ExtractedCamera,
&'static Camera3d,
&'static ViewDepthTexture,
Expand All @@ -38,7 +38,7 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(camera, camera_3d, depth, view_offset, meshlet_view_bind_groups, meshlet_view_resources): QueryItem<Self::ViewQuery>,
(camera, camera_3d, depth, view_offset, meshlet_view_bind_groups, meshlet_view_resources): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let Some((
Expand Down Expand Up @@ -70,6 +70,7 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
let command_encoder = render_context.command_encoder();
let mut cull_pass = command_encoder.begin_compute_pass(&ComputePassDescriptor {
label: Some("meshlet_culling_first_pass"),
timestamp_writes: None,
});
cull_pass.set_bind_group(
0,
Expand All @@ -88,10 +89,12 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
view: &depth.view,
depth_ops: Some(Operations {
load: depth_load,
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
if let Some(viewport) = camera.viewport.as_ref() {
draw_pass.set_camera_viewport(viewport);
Expand Down Expand Up @@ -127,10 +130,12 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK.into()),
store: true,
store: StoreOp::Store,
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};
let mut downsample_pass = render_context.begin_tracked_render_pass(downsample_pass);
downsample_pass.set_bind_group(0, &meshlet_view_bind_groups.downsample_depth[i], &[]);
Expand All @@ -143,6 +148,7 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
let command_encoder = render_context.command_encoder();
let mut cull_pass = command_encoder.begin_compute_pass(&ComputePassDescriptor {
label: Some("meshlet_culling_second_pass"),
timestamp_writes: None,
});
cull_pass.set_bind_group(
0,
Expand All @@ -162,26 +168,28 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK.into()),
store: true,
store: StoreOp::Store,
},
}),
Some(RenderPassColorAttachment {
view: &meshlet_view_resources.material_depth_color.default_view,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK.into()),
store: true,
store: StoreOp::Store,
},
}),
],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
view: &depth.view,
depth_ops: Some(Operations {
load: LoadOp::Load,
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
if let Some(viewport) = camera.viewport.as_ref() {
draw_pass.set_camera_viewport(viewport);
Expand Down Expand Up @@ -214,10 +222,12 @@ impl ViewNode for MeshletVisibilityBufferPassNode {
view: &meshlet_view_resources.material_depth.default_view,
depth_ops: Some(Operations {
load: LoadOp::Clear(0.0),
store: true,
store: StoreOp::Store,
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
if let Some(viewport) = camera.viewport.as_ref() {
copy_pass.set_camera_viewport(viewport);
Expand Down
35 changes: 18 additions & 17 deletions crates/bevy_render/src/render_resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ pub use uniform_buffer::*;

// TODO: decide where re-exports should go
pub use wgpu::{
util::BufferInitDescriptor, AdapterInfo as WgpuAdapterInfo, AddressMode, BindGroupDescriptor,
BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType,
BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress, BufferAsyncError,
BufferBinding, BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState,
ColorWrites, CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass,
ComputePassDescriptor, ComputePipelineDescriptor as RawComputePipelineDescriptor,
DepthBiasState, DepthStencilState, Extent3d, Face, Features as WgpuFeatures, FilterMode,
FragmentState as RawFragmentState, FrontFace, ImageCopyBuffer, ImageCopyBufferBase,
ImageCopyTexture, ImageCopyTextureBase, ImageDataLayout, ImageSubresourceRange, IndexFormat,
Limits as WgpuLimits, LoadOp, Maintain, MapMode, MultisampleState, Operations, Origin3d,
PipelineLayout, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology,
PushConstantRange, RenderPassColorAttachment, RenderPassDepthStencilAttachment,
RenderPassDescriptor, RenderPipelineDescriptor as RawRenderPipelineDescriptor,
SamplerBindingType, SamplerDescriptor, ShaderModule, ShaderModuleDescriptor, ShaderSource,
ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess, StoreOp,
TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType,
TextureUsages, TextureViewDescriptor, TextureViewDimension, VertexAttribute,
util::{BufferInitDescriptor, DrawIndexedIndirect},
AdapterInfo as WgpuAdapterInfo, AddressMode, BindGroupDescriptor, BindGroupEntry,
BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendComponent,
BlendFactor, BlendOperation, BlendState, BufferAddress, BufferAsyncError, BufferBinding,
BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState, ColorWrites,
CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, ComputePassDescriptor,
ComputePipelineDescriptor as RawComputePipelineDescriptor, DepthBiasState, DepthStencilState,
Extent3d, Face, Features as WgpuFeatures, FilterMode, FragmentState as RawFragmentState,
FrontFace, ImageCopyBuffer, ImageCopyBufferBase, ImageCopyTexture, ImageCopyTextureBase,
ImageDataLayout, ImageSubresourceRange, IndexFormat, Limits as WgpuLimits, LoadOp, Maintain,
MapMode, MultisampleState, Operations, Origin3d, PipelineLayout, PipelineLayoutDescriptor,
PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, RenderPassColorAttachment,
RenderPassDepthStencilAttachment, RenderPassDescriptor,
RenderPipelineDescriptor as RawRenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor,
ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStages, StencilFaceState,
StencilOperation, StencilState, StorageTextureAccess, StoreOp, TextureAspect,
TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages,
TextureViewDescriptor, TextureViewDimension, VertexAttribute,
VertexBufferLayout as RawVertexBufferLayout, VertexFormat, VertexState as RawVertexState,
VertexStepMode,
};
Expand Down
18 changes: 9 additions & 9 deletions examples/3d/meshlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ impl Default for CameraController {
enabled: true,
initialized: false,
sensitivity: 1.0,
key_forward: KeyCode::W,
key_back: KeyCode::S,
key_left: KeyCode::A,
key_right: KeyCode::D,
key_up: KeyCode::E,
key_down: KeyCode::Q,
key_forward: KeyCode::KeyW,
key_back: KeyCode::KeyS,
key_left: KeyCode::KeyA,
key_right: KeyCode::KeyD,
key_up: KeyCode::KeyE,
key_down: KeyCode::KeyQ,
key_run: KeyCode::ShiftLeft,
mouse_key_enable_mouse: MouseButton::Left,
keyboard_key_enable_mouse: KeyCode::M,
keyboard_key_enable_mouse: KeyCode::KeyM,
walk_speed: 5.0,
run_speed: 15.0,
friction: 0.5,
Expand All @@ -161,8 +161,8 @@ fn camera_controller(
time: Res<Time>,
mut windows: Query<&mut Window>,
mut mouse_events: EventReader<MouseMotion>,
mouse_button_input: Res<Input<MouseButton>>,
key_input: Res<Input<KeyCode>>,
mouse_button_input: Res<ButtonInput<MouseButton>>,
key_input: Res<ButtonInput<KeyCode>>,
mut move_toggled: Local<bool>,
mut query: Query<(&mut Transform, &mut CameraController), With<Camera>>,
) {
Expand Down

0 comments on commit f3222fe

Please sign in to comment.