mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Reverted combining of set_bind_group between different passes.
This commit is contained in:
parent
a0347195c0
commit
9588bb3243
4 changed files with 60 additions and 69 deletions
|
@ -1,50 +0,0 @@
|
|||
use bevy_render2::{pipeline::BindGroupDescriptorId, render_resource::BindGroupId};
|
||||
use bevy_utils::tracing::trace;
|
||||
use crate::resources::WgpuResourceRefs;
|
||||
|
||||
pub enum Pass<'a, 'b> {
|
||||
Render(&'b mut wgpu::RenderPass<'a>),
|
||||
Compute(&'b mut wgpu::ComputePass<'a>),
|
||||
}
|
||||
|
||||
pub fn set_bind_group<'a, 'b>(
|
||||
pass: Pass<'a, 'b>,
|
||||
wgpu_resources: &WgpuResourceRefs<'a>,
|
||||
index: u32,
|
||||
bind_group_descriptor_id: BindGroupDescriptorId,
|
||||
bind_group: BindGroupId,
|
||||
dynamic_uniform_indices: Option<&[u32]>,
|
||||
) {
|
||||
if let Some(bind_group_info) = wgpu_resources
|
||||
.bind_groups
|
||||
.get(&bind_group_descriptor_id)
|
||||
{
|
||||
if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) {
|
||||
const EMPTY: &[u32] = &[];
|
||||
let dynamic_uniform_indices =
|
||||
if let Some(dynamic_uniform_indices) = dynamic_uniform_indices {
|
||||
dynamic_uniform_indices
|
||||
} else {
|
||||
EMPTY
|
||||
};
|
||||
wgpu_resources
|
||||
.used_bind_group_sender
|
||||
.send(bind_group)
|
||||
.unwrap();
|
||||
|
||||
trace!(
|
||||
"set bind group {:?} {:?}: {:?}",
|
||||
bind_group_descriptor_id,
|
||||
dynamic_uniform_indices,
|
||||
bind_group
|
||||
);
|
||||
|
||||
match pass {
|
||||
Pass::Render(render_pass) =>
|
||||
render_pass.set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices),
|
||||
Pass::Compute(compute_pass) =>
|
||||
compute_pass.set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
use crate::{WgpuRenderContext, bind_group::{self, Pass}, resources::WgpuResourceRefs};
|
||||
use crate::{resources::WgpuResourceRefs, WgpuRenderContext};
|
||||
use bevy_render2::{
|
||||
pass::ComputePass,
|
||||
pipeline::{BindGroupDescriptorId, ComputePipelineDescriptor, PipelineId},
|
||||
render_resource::BindGroupId,
|
||||
renderer::RenderContext,
|
||||
};
|
||||
use bevy_utils::tracing::trace;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WgpuComputePass<'a> {
|
||||
|
@ -26,14 +27,34 @@ impl<'a> ComputePass for WgpuComputePass<'a> {
|
|||
bind_group: BindGroupId,
|
||||
dynamic_uniform_indices: Option<&[u32]>,
|
||||
) {
|
||||
bind_group::set_bind_group(
|
||||
Pass::Compute(&mut self.compute_pass),
|
||||
&self.wgpu_resources,
|
||||
index,
|
||||
bind_group_descriptor_id,
|
||||
bind_group,
|
||||
dynamic_uniform_indices,
|
||||
)
|
||||
if let Some(bind_group_info) = self
|
||||
.wgpu_resources
|
||||
.bind_groups
|
||||
.get(&bind_group_descriptor_id)
|
||||
{
|
||||
if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) {
|
||||
const EMPTY: &[u32] = &[];
|
||||
let dynamic_uniform_indices =
|
||||
if let Some(dynamic_uniform_indices) = dynamic_uniform_indices {
|
||||
dynamic_uniform_indices
|
||||
} else {
|
||||
EMPTY
|
||||
};
|
||||
self.wgpu_resources
|
||||
.used_bind_group_sender
|
||||
.send(bind_group)
|
||||
.unwrap();
|
||||
|
||||
trace!(
|
||||
"set bind group {:?} {:?}: {:?}",
|
||||
bind_group_descriptor_id,
|
||||
dynamic_uniform_indices,
|
||||
bind_group
|
||||
);
|
||||
self.compute_pass
|
||||
.set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_pipeline(&mut self, pipeline: PipelineId) {
|
||||
|
|
|
@ -8,7 +8,6 @@ mod render_resource_context;
|
|||
mod renderer;
|
||||
mod resources;
|
||||
mod type_converter;
|
||||
mod bind_group;
|
||||
|
||||
pub use compute_pass::*;
|
||||
pub use render_context::*;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::{WgpuRenderContext, bind_group::{self, Pass}, resources::WgpuResourceRefs, type_converter::WgpuInto};
|
||||
use crate::{resources::WgpuResourceRefs, type_converter::WgpuInto, WgpuRenderContext};
|
||||
use bevy_render2::{
|
||||
pass::RenderPass,
|
||||
pipeline::{BindGroupDescriptorId, IndexFormat, RenderPipelineDescriptor, PipelineId},
|
||||
render_resource::{BindGroupId, BufferId},
|
||||
renderer::RenderContext,
|
||||
};
|
||||
use bevy_utils::tracing::trace;
|
||||
use std::ops::Range;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -61,14 +62,34 @@ impl<'a> RenderPass for WgpuRenderPass<'a> {
|
|||
bind_group: BindGroupId,
|
||||
dynamic_uniform_indices: Option<&[u32]>,
|
||||
) {
|
||||
bind_group::set_bind_group(
|
||||
Pass::Render(&mut self.render_pass),
|
||||
&self.wgpu_resources,
|
||||
index,
|
||||
bind_group_descriptor_id,
|
||||
bind_group,
|
||||
dynamic_uniform_indices,
|
||||
)
|
||||
if let Some(bind_group_info) = self
|
||||
.wgpu_resources
|
||||
.bind_groups
|
||||
.get(&bind_group_descriptor_id)
|
||||
{
|
||||
if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) {
|
||||
const EMPTY: &[u32] = &[];
|
||||
let dynamic_uniform_indices =
|
||||
if let Some(dynamic_uniform_indices) = dynamic_uniform_indices {
|
||||
dynamic_uniform_indices
|
||||
} else {
|
||||
EMPTY
|
||||
};
|
||||
self.wgpu_resources
|
||||
.used_bind_group_sender
|
||||
.send(bind_group)
|
||||
.unwrap();
|
||||
|
||||
trace!(
|
||||
"set bind group {:?} {:?}: {:?}",
|
||||
bind_group_descriptor_id,
|
||||
dynamic_uniform_indices,
|
||||
bind_group
|
||||
);
|
||||
self.render_pass
|
||||
.set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_pipeline(&mut self, pipeline: PipelineId) {
|
||||
|
|
Loading…
Reference in a new issue