Skip to content

Commit

Permalink
merge merge
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm committed Oct 17, 2023
1 parent 14ff145 commit 6f98c9a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 44 deletions.
25 changes: 11 additions & 14 deletions crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use bevy_ecs::query::QueryItem;
use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroupDescriptor, BindGroupEntry, BindingResource, Operations, PipelineCache,
RenderPassDescriptor,
BindGroupEntry, BindingResource, Operations, PipelineCache, RenderPassDescriptor,
},
renderer::RenderContext,
};
Expand Down Expand Up @@ -94,18 +93,16 @@ impl ViewNode for CopyDeferredLightingIdNode {
return Ok(());
};

let bind_group = render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: Some("copy_deferred_lighting_id_bind_group"),
layout: &copy_deferred_lighting_id_pipeline.layout,
entries: &[BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(
&deferred_lighting_pass_id_texture.default_view,
),
}],
});
let bind_group = render_context.render_device().create_bind_group(
"copy_deferred_lighting_id_bind_group",
&copy_deferred_lighting_id_pipeline.layout,
&[BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(
&deferred_lighting_pass_id_texture.default_view,
),
}],
);

let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some("copy_deferred_lighting_id_pass"),
Expand Down
18 changes: 8 additions & 10 deletions crates/bevy_pbr/src/deferred/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,14 @@ impl ViewNode for DeferredOpaquePass3dPbrLightingNode {
return Ok(());
};

let bind_group_1 = render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: Some("deferred_lighting_layout_group_1"),
layout: &deferred_lighting_layout.bind_group_layout_1,
entries: &[BindGroupEntry {
binding: 0,
resource: deferred_lighting_pass_id_binding.clone(),
}],
});
let bind_group_1 = render_context.render_device().create_bind_group(
"deferred_lighting_layout_group_1",
&deferred_lighting_layout.bind_group_layout_1,
&[BindGroupEntry {
binding: 0,
resource: deferred_lighting_pass_id_binding.clone(),
}],
);

let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
label: Some("deferred_lighting_pass"),
Expand Down
26 changes: 15 additions & 11 deletions crates/bevy_pbr/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ use bevy_render::{
},
render_resource::{
BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroupLayoutEntry, BindingResource, BindingType, BlendState, BufferBindingType,
ColorTargetState, ColorWrites, CompareFunction, DepthBiasState, DepthStencilState,
DynamicUniformBuffer, FragmentState, FrontFace, MultisampleState, PipelineCache,
PolygonMode, PrimitiveState, PushConstantRange, RenderPipelineDescriptor, Shader,
ShaderRef, ShaderStages, ShaderType, SpecializedMeshPipeline, SpecializedMeshPipelineError,
SpecializedMeshPipelines, StencilFaceState, StencilState, TextureAspect, TextureFormat, TextureSampleType,
BindGroupLayoutEntry, BindingType, BufferBindingType, ColorTargetState, ColorWrites,
CompareFunction, DepthBiasState, DepthStencilState, DynamicUniformBuffer, FragmentState,
FrontFace, MultisampleState, PipelineCache, PolygonMode, PrimitiveState, PushConstantRange,
RenderPipelineDescriptor, Shader, ShaderRef, ShaderStages, ShaderType,
SpecializedMeshPipeline, SpecializedMeshPipelineError, SpecializedMeshPipelines,
StencilFaceState, StencilState, TextureAspect, TextureFormat, TextureSampleType,
TextureView, TextureViewDescriptor, TextureViewDimension, VertexState,
},
renderer::{RenderDevice, RenderQueue},
Expand Down Expand Up @@ -688,9 +688,9 @@ pub fn get_bind_group_layout_entries(

pub fn get_bindings<'a>(
prepass_textures: Option<&'a ViewPrepassTextures>,
fallback_images: &'a mut FallbackImagesMsaa,
fallback_images: &'a mut FallbackImageMsaa,
msaa: &'a Msaa,
) -> (&'a TextureView, &'a TextureView, &'a TextureView, &'a TextureView) {
) -> [TextureView; 4] {
let depth_desc = TextureViewDescriptor {
label: Some("prepass_depth"),
aspect: TextureAspect::DepthOnly,
Expand All @@ -701,6 +701,7 @@ pub fn get_bindings<'a>(
Some(texture) => texture.texture.create_view(&depth_desc),
None => fallback_images
.image_for_samplecount(msaa.samples(), CORE_3D_DEPTH_FORMAT)
.clone()
.texture
.create_view(&depth_desc),
};
Expand All @@ -712,12 +713,14 @@ pub fn get_bindings<'a>(
let normal_view = match prepass_textures.and_then(|x| x.normal.as_ref()) {
Some(texture) => &texture.default_view,
None => normal_motion_vectors_fallback,
};
}
.clone();

let motion_vectors_view = match prepass_textures.and_then(|x| x.motion_vectors.as_ref()) {
Some(texture) => &texture.default_view,
None => normal_motion_vectors_fallback,
};
}
.clone();

let deferred_fallback = &fallback_images
.image_for_samplecount(1, TextureFormat::Rgba32Uint)
Expand All @@ -727,8 +730,9 @@ pub fn get_bindings<'a>(
Some(texture) => &texture.default_view,
None => deferred_fallback,
}
.clone();

(depth_view, normal_view, motion_vectors_view, deferred_view)
[depth_view, normal_view, motion_vectors_view, deferred_view]
}

// Extract the render phases for the prepass
Expand Down
16 changes: 7 additions & 9 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,19 +1184,17 @@ pub fn prepare_mesh_view_bind_groups(
let lut_bindings = get_lut_bindings(&images, &tonemapping_luts, tonemapping);
entries = entries.extend_with_indices(((15, lut_bindings.0), (16, lut_bindings.1)));

let prepass_bindings;
// When using WebGL, we can't have a depth texture with multisampling
if cfg!(any(not(feature = "webgl"), not(target_arch = "wasm32"))) || msaa.samples() == 1
{
let prepass_bindings = prepass::get_bindings(
prepass_textures,
&mut fallback_images,
&msaa,
);
prepass_bindings =
prepass::get_bindings(prepass_textures, &mut fallback_images, &msaa);
entries = entries.extend_with_indices((
(17, prepass_bindings.0),
(18, prepass_bindings.1),
(19, prepass_bindings.2),
(20, prepass_bindings.3),
(17, &prepass_bindings[0]),
(18, &prepass_bindings[1]),
(19, &prepass_bindings[2]),
(20, &prepass_bindings[3]),
));
}

Expand Down

0 comments on commit 6f98c9a

Please sign in to comment.