Skip to content

Commit

Permalink
destructure BindGroupDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm committed Sep 4, 2023
1 parent 6800f24 commit b35c654
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 295 deletions.
43 changes: 20 additions & 23 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +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: &BindGroupEntries::sequential((
// Read from main texture directly
view_target.main_texture_view(),
&bind_groups.sampler,
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 @@ -407,28 +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: &BindGroupEntries::sequential((
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: &BindGroupEntries::sequential((
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
23 changes: 10 additions & 13 deletions crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_render::{
extract_component::{ComponentUniforms, DynamicUniformIndex},
render_graph::{Node, NodeRunError, RenderGraphContext},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntries, BufferId, Operations, PipelineCache,
BindGroup, BindGroupEntries, BufferId, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, TextureViewId,
},
renderer::RenderContext,
Expand Down Expand Up @@ -77,18 +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: &BindGroupEntries::sequential((
view_target.source,
&sharpening_pipeline.sampler,
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
15 changes: 6 additions & 9 deletions crates/bevy_core_pipeline/src/fxaa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_ecs::query::QueryItem;
use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntries, FilterMode, Operations, PipelineCache,
BindGroup, BindGroupEntries, FilterMode, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId,
},
renderer::RenderContext,
Expand Down Expand Up @@ -60,14 +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: &BindGroupEntries::sequential((source, &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
16 changes: 5 additions & 11 deletions crates/bevy_core_pipeline/src/msaa_writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +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: &BindGroupEntries::sequential((
post_process.source,
&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
24 changes: 12 additions & 12 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, 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,
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,15 +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: &BindGroupEntries::sequential((
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
41 changes: 19 additions & 22 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, 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,
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,21 +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: &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 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
30 changes: 13 additions & 17 deletions crates/bevy_core_pipeline/src/tonemapping/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use bevy_render::{
render_asset::RenderAssets,
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntries, BufferId, LoadOp, Operations,
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor,
TextureViewId,
BindGroup, BindGroupEntries, BufferId, LoadOp, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId,
},
renderer::RenderContext,
texture::Image,
Expand Down Expand Up @@ -90,20 +89,17 @@ impl ViewNode for TonemappingNode {

let lut_bindings = get_lut_bindings(gpu_images, tonemapping_luts, tonemapping);

let bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: None,
layout: &tonemapping_pipeline.texture_bind_group,
entries: &BindGroupEntries::sequential((
view_uniforms,
source,
&sampler,
lut_bindings.0,
lut_bindings.1,
)),
});
let bind_group = render_context.render_device().create_bind_group(
None,
&tonemapping_pipeline.texture_bind_group,
&BindGroupEntries::sequential((
view_uniforms,
source,
&sampler,
lut_bindings.0,
lut_bindings.1,
)),
);

let (_, _, bind_group) =
cached_bind_group.insert((view_uniforms_id, source.id(), bind_group));
Expand Down
17 changes: 7 additions & 10 deletions crates/bevy_core_pipeline/src/upscaling/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use bevy_render::{
camera::{CameraOutputMode, ExtractedCamera},
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntries, LoadOp, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId,
BindGroup, BindGroupEntries, LoadOp, Operations, PipelineCache, RenderPassColorAttachment,
RenderPassDescriptor, SamplerDescriptor, TextureViewId,
},
renderer::RenderContext,
view::ViewTarget,
Expand Down Expand Up @@ -56,14 +56,11 @@ impl ViewNode for UpscalingNode {
.render_device()
.create_sampler(&SamplerDescriptor::default());

let bind_group =
render_context
.render_device()
.create_bind_group(&BindGroupDescriptor {
label: None,
layout: &blit_pipeline.texture_bind_group,
entries: &BindGroupEntries::sequential((upscaled_texture, &sampler)),
});
let bind_group = render_context.render_device().create_bind_group(
None,
&blit_pipeline.texture_bind_group,
&BindGroupEntries::sequential((upscaled_texture, &sampler)),
);

let (_, bind_group) = cached_bind_group.insert((upscaled_texture.id(), bind_group));
bind_group
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use bevy_render::{
render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets},
render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass},
render_resource::{
BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroup, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroupLayoutEntry, BindingType, Buffer, BufferBindingType, BufferInitDescriptor,
BufferUsages, Shader, ShaderStages, ShaderType, VertexAttribute, VertexBufferLayout,
VertexFormat, VertexStepMode,
Expand Down Expand Up @@ -424,14 +424,14 @@ fn prepare_line_gizmo_bind_group(
) {
if let Some(binding) = line_gizmo_uniforms.uniforms().binding() {
commands.insert_resource(LineGizmoUniformBindgroup {
bindgroup: render_device.create_bind_group(&BindGroupDescriptor {
entries: &[BindGroupEntry {
bindgroup: render_device.create_bind_group(
Some("LineGizmoUniform bindgroup"),
&line_gizmo_uniform_layout.layout,
&[BindGroupEntry {
binding: 0,
resource: binding,
}],
label: Some("LineGizmoUniform bindgroup"),
layout: &line_gizmo_uniform_layout.layout,
}),
),
});
}
}
Expand Down
Loading

0 comments on commit b35c654

Please sign in to comment.