Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind group entries #9694

Merged
merged 35 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ff63eb8
BindGroupEntries
robtfm Sep 3, 2023
da60a77
fmt
robtfm Sep 3, 2023
a9fb779
ci
robtfm Sep 3, 2023
6800f24
tweak prepass get_bindings
robtfm Sep 3, 2023
b35c654
destructure BindGroupDescriptor
robtfm Sep 4, 2023
5d23b02
Merge remote-tracking branch 'upstream/main' into bind_group_entries
robtfm Sep 4, 2023
862ae47
fmt
robtfm Sep 4, 2023
a57ff80
fix comment
robtfm Sep 4, 2023
49e186a
no bevy_internals
robtfm Sep 4, 2023
90d5caa
no_run
robtfm Sep 4, 2023
b59a64d
ignore?
robtfm Sep 4, 2023
7b88136
doc tests are hard
robtfm Sep 5, 2023
c43e753
IntoLabel
robtfm Sep 5, 2023
56e4297
simpler
robtfm Sep 5, 2023
b8dbd66
re-add example comments
robtfm Sep 5, 2023
3e3c9f6
remove as_slice
robtfm Sep 5, 2023
22c1e67
indexes -> indices
robtfm Sep 5, 2023
793eeeb
importing * is plenty
robtfm Sep 5, 2023
1176372
fmt
robtfm Sep 5, 2023
b563313
Merge remote-tracking branch 'upstream/main' into bind_group_entries
robtfm Sep 13, 2023
3afbb44
use indices for mesh view bind group
robtfm Sep 20, 2023
c5a6681
Merge remote-tracking branch 'upstream/main' into bind_group_entries
robtfm Sep 29, 2023
14ff145
Merge remote-tracking branch 'upstream/main' into bind_group_entries
robtfm Oct 17, 2023
6f98c9a
merge merge
robtfm Oct 17, 2023
624df5f
Merge remote-tracking branch 'upstream/main' into bind_group_entries
robtfm Oct 17, 2023
b070027
merge that merged merge till its really merged
robtfm Oct 17, 2023
3c17ffc
add more IntoBinding impls
robtfm Oct 17, 2023
3875480
Update crates/bevy_render/src/render_resource/uniform_buffer.rs
robtfm Oct 17, 2023
3f0e121
bad comma
robtfm Oct 17, 2023
31bd9fc
add/use BindGroupEntries::single
robtfm Oct 17, 2023
9985276
remove errant clone
robtfm Oct 17, 2023
e958c26
ci
robtfm Oct 17, 2023
6a6a5a8
ci ci
robtfm Oct 17, 2023
358c0dc
Merge remote-tracking branch 'upstream/main' into bind_group_entries
robtfm Oct 21, 2023
d072729
fix merge
robtfm Oct 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 29 additions & 61 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use bevy_render::{
},
prelude::Color,
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner},
render_resource::*,
render_resource::{BindGroupEntries, *},
robtfm marked this conversation as resolved.
Show resolved Hide resolved
renderer::{RenderContext, RenderDevice},
texture::{CachedTexture, TextureCache},
view::ViewTarget,
Expand Down Expand Up @@ -172,30 +172,16 @@ impl ViewNode for BloomNode {

// First downsample pass
{
let downsampling_first_bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: Some("bloom_downsampling_first_bind_group"),
layout: &downsampling_pipeline_res.bind_group_layout,
entries: &[
BindGroupEntry {
binding: 0,
// Read from main texture directly
resource: BindingResource::TextureView(
view_target.main_texture_view(),
),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(&bind_groups.sampler),
},
BindGroupEntry {
binding: 2,
resource: uniforms.clone(),
},
],
});
let downsampling_first_bind_group = render_context.render_device().create_bind_group(
Some("bloom_downsampling_first_bind_group"),
&downsampling_pipeline_res.bind_group_layout,
&BindGroupEntries::sequential((
// Read from main texture directly
view_target.main_texture_view(),
&bind_groups.sampler,
uniforms.clone(),
)),
);

let view = &bloom_texture.view(0);
let mut downsampling_first_pass =
Expand Down Expand Up @@ -418,46 +404,28 @@ fn prepare_bloom_bind_groups(

let mut downsampling_bind_groups = Vec::with_capacity(bind_group_count);
for mip in 1..bloom_texture.mip_count {
downsampling_bind_groups.push(render_device.create_bind_group(&BindGroupDescriptor {
label: Some("bloom_downsampling_bind_group"),
layout: &downsampling_pipeline.bind_group_layout,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(&bloom_texture.view(mip - 1)),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(sampler),
},
BindGroupEntry {
binding: 2,
resource: uniforms.binding().unwrap(),
},
],
}));
downsampling_bind_groups.push(render_device.create_bind_group(
Some("bloom_downsampling_bind_group"),
&downsampling_pipeline.bind_group_layout,
&BindGroupEntries::sequential((
&bloom_texture.view(mip - 1),
sampler,
uniforms.binding().unwrap(),
)),
));
}

let mut upsampling_bind_groups = Vec::with_capacity(bind_group_count);
for mip in (0..bloom_texture.mip_count).rev() {
upsampling_bind_groups.push(render_device.create_bind_group(&BindGroupDescriptor {
label: Some("bloom_upsampling_bind_group"),
layout: &upsampling_pipeline.bind_group_layout,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(&bloom_texture.view(mip)),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(sampler),
},
BindGroupEntry {
binding: 2,
resource: uniforms.binding().unwrap(),
},
],
}));
upsampling_bind_groups.push(render_device.create_bind_group(
Some("bloom_upsampling_bind_group"),
&upsampling_pipeline.bind_group_layout,
&BindGroupEntries::sequential((
&bloom_texture.view(mip),
sampler,
uniforms.binding().unwrap(),
)),
));
}

commands.entity(entity).insert(BloomBindGroups {
Expand Down
36 changes: 11 additions & 25 deletions crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use bevy_render::{
extract_component::{ComponentUniforms, DynamicUniformIndex},
render_graph::{Node, NodeRunError, RenderGraphContext},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, BufferId, Operations,
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, TextureViewId,
BindGroup, BindGroupEntries, BufferId, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, TextureViewId,
},
renderer::RenderContext,
view::{ExtractedView, ViewTarget},
Expand Down Expand Up @@ -77,29 +77,15 @@ impl Node for CASNode {
bind_group
}
cached_bind_group => {
let bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: Some("cas_bind_group"),
layout: &sharpening_pipeline.texture_bind_group,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(view_target.source),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(
&sharpening_pipeline.sampler,
),
},
BindGroupEntry {
binding: 2,
resource: uniforms,
},
],
});
let bind_group = render_context.render_device().create_bind_group(
Some("cas_bind_group"),
&sharpening_pipeline.texture_bind_group,
&BindGroupEntries::sequential((
view_target.source,
&sharpening_pipeline.sampler,
uniforms,
)),
);

let (_, _, bind_group) =
cached_bind_group.insert((uniforms_id, source.id(), bind_group));
Expand Down
27 changes: 7 additions & 20 deletions crates/bevy_core_pipeline/src/fxaa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use bevy_ecs::query::QueryItem;
use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, FilterMode, Operations,
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor,
TextureViewId,
BindGroup, BindGroupEntries, FilterMode, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId,
},
renderer::RenderContext,
view::ViewTarget,
Expand Down Expand Up @@ -61,23 +60,11 @@ impl ViewNode for FxaaNode {
..default()
});

let bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: None,
layout: &fxaa_pipeline.texture_bind_group,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(source),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(&sampler),
},
],
});
let bind_group = render_context.render_device().create_bind_group(
None,
&fxaa_pipeline.texture_bind_group,
&BindGroupEntries::sequential((source, &sampler)),
);

let (_, bind_group) = cached_bind_group.insert((source.id(), bind_group));
bind_group
Expand Down
23 changes: 6 additions & 17 deletions crates/bevy_core_pipeline/src/msaa_writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use bevy_ecs::prelude::*;
use bevy_render::{
camera::ExtractedCamera,
render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext},
render_resource::BindGroupEntries,
renderer::RenderContext,
view::{Msaa, ViewTarget},
Render, RenderSet,
Expand Down Expand Up @@ -90,23 +91,11 @@ impl Node for MsaaWritebackNode {
depth_stencil_attachment: None,
};

let bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: None,
layout: &blit_pipeline.texture_bind_group,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(post_process.source),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(&blit_pipeline.sampler),
},
],
});
let bind_group = render_context.render_device().create_bind_group(
None,
&blit_pipeline.texture_bind_group,
&BindGroupEntries::sequential((post_process.source, &blit_pipeline.sampler)),
);

let mut render_pass = render_context
.command_encoder()
Expand Down
41 changes: 16 additions & 25 deletions crates/bevy_core_pipeline/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use bevy_render::{
extract_component::{ExtractComponent, ExtractComponentPlugin},
render_asset::RenderAssets,
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroupLayoutEntry, BindingResource, BindingType, BlendState, BufferBindingType,
CachedRenderPipelineId, ColorTargetState, ColorWrites, CompareFunction, DepthBiasState,
DepthStencilState, FragmentState, MultisampleState, PipelineCache, PrimitiveState,
RenderPipelineDescriptor, SamplerBindingType, Shader, ShaderStages, ShaderType,
SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState,
TextureFormat, TextureSampleType, TextureViewDimension, VertexState,
BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroupLayoutEntry, BindingType, BlendState, BufferBindingType, CachedRenderPipelineId,
ColorTargetState, ColorWrites, CompareFunction, DepthBiasState, DepthStencilState,
FragmentState, MultisampleState, PipelineCache, PrimitiveState, RenderPipelineDescriptor,
SamplerBindingType, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline,
SpecializedRenderPipelines, StencilFaceState, StencilState, TextureFormat,
TextureSampleType, TextureViewDimension, VertexState,
},
renderer::RenderDevice,
texture::{BevyDefault, Image},
Expand Down Expand Up @@ -221,24 +221,15 @@ fn prepare_skybox_bind_groups(
if let (Some(skybox), Some(view_uniforms)) =
(images.get(&skybox.0), view_uniforms.uniforms.binding())
{
let bind_group = render_device.create_bind_group(&BindGroupDescriptor {
label: Some("skybox_bind_group"),
layout: &pipeline.bind_group_layout,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(&skybox.texture_view),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::Sampler(&skybox.sampler),
},
BindGroupEntry {
binding: 2,
resource: view_uniforms,
},
],
});
let bind_group = render_device.create_bind_group(
Some("skybox_bind_group"),
&pipeline.bind_group_layout,
&BindGroupEntries::sequential((
&skybox.texture_view,
&skybox.sampler,
view_uniforms,
)),
);

commands.entity(entity).insert(SkyboxBindGroup(bind_group));
}
Expand Down
65 changes: 19 additions & 46 deletions crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ use bevy_render::{
prelude::{Camera, Projection},
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner},
render_resource::{
BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroupLayoutEntry, BindingResource, BindingType, CachedRenderPipelineId,
ColorTargetState, ColorWrites, Extent3d, FilterMode, FragmentState, MultisampleState,
Operations, PipelineCache, PrimitiveState, RenderPassColorAttachment, RenderPassDescriptor,
RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader,
ShaderStages, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureDescriptor,
TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureViewDimension,
BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry,
BindingType, CachedRenderPipelineId, ColorTargetState, ColorWrites, Extent3d, FilterMode,
FragmentState, MultisampleState, Operations, PipelineCache, PrimitiveState,
RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler,
SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, SpecializedRenderPipeline,
SpecializedRenderPipelines, TextureDescriptor, TextureDimension, TextureFormat,
TextureSampleType, TextureUsages, TextureViewDimension,
},
renderer::{RenderContext, RenderDevice},
texture::{BevyDefault, CachedTexture, TextureCache},
Expand Down Expand Up @@ -198,45 +198,18 @@ impl ViewNode for TAANode {
};
let view_target = view_target.post_process_write();

let taa_bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: Some("taa_bind_group"),
layout: &pipelines.taa_bind_group_layout,
entries: &[
BindGroupEntry {
binding: 0,
resource: BindingResource::TextureView(view_target.source),
},
BindGroupEntry {
binding: 1,
resource: BindingResource::TextureView(
&taa_history_textures.read.default_view,
),
},
BindGroupEntry {
binding: 2,
resource: BindingResource::TextureView(
&prepass_motion_vectors_texture.default_view,
),
},
BindGroupEntry {
binding: 3,
resource: BindingResource::TextureView(
&prepass_depth_texture.default_view,
),
},
BindGroupEntry {
binding: 4,
resource: BindingResource::Sampler(&pipelines.nearest_sampler),
},
BindGroupEntry {
binding: 5,
resource: BindingResource::Sampler(&pipelines.linear_sampler),
},
],
});
let taa_bind_group = render_context.render_device().create_bind_group(
Some("taa_bind_group"),
&pipelines.taa_bind_group_layout,
&BindGroupEntries::sequential((
view_target.source,
&taa_history_textures.read.default_view,
&prepass_motion_vectors_texture.default_view,
&prepass_depth_texture.default_view,
&pipelines.nearest_sampler,
&pipelines.linear_sampler,
)),
);

{
let mut taa_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
Expand Down
Loading