Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Plugin for CasPlugin {

#[derive(Resource)]
pub struct CasPipeline {
texture_bind_group: BindGroupLayout,
texture_bind_group: BindGroupLayoutDescriptor,
sampler: Sampler,
fullscreen_shader: FullscreenShader,
fragment_shader: Handle<Shader>,
Expand All @@ -169,7 +169,7 @@ pub fn init_cas_pipeline(
fullscreen_shader: Res<FullscreenShader>,
asset_server: Res<AssetServer>,
) {
let texture_bind_group = render_device.create_bind_group_layout(
let texture_bind_group = BindGroupLayoutDescriptor::new(
"sharpening_texture_bind_group_layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Node for CasNode {
cached_bind_group => {
let bind_group = render_context.render_device().create_bind_group(
"cas_bind_group",
&sharpening_pipeline.texture_bind_group,
&pipeline_cache.get_bind_group_layout(&sharpening_pipeline.texture_bind_group),
&BindGroupEntries::sequential((
view_target.source,
&sharpening_pipeline.sampler,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_anti_alias/src/fxaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Plugin for FxaaPlugin {

#[derive(Resource)]
pub struct FxaaPipeline {
texture_bind_group: BindGroupLayout,
texture_bind_group: BindGroupLayoutDescriptor,
sampler: Sampler,
fullscreen_shader: FullscreenShader,
fragment_shader: Handle<Shader>,
Expand All @@ -135,7 +135,7 @@ pub fn init_fxaa_pipeline(
fullscreen_shader: Res<FullscreenShader>,
asset_server: Res<AssetServer>,
) {
let texture_bind_group = render_device.create_bind_group_layout(
let texture_bind_group = BindGroupLayoutDescriptor::new(
"fxaa_texture_bind_group_layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_anti_alias/src/fxaa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ViewNode for FxaaNode {
cached_bind_group => {
let bind_group = render_context.render_device().create_bind_group(
None,
&fxaa_pipeline.texture_bind_group,
&pipeline_cache.get_bind_group_layout(&fxaa_pipeline.texture_bind_group),
&BindGroupEntries::sequential((source, &fxaa_pipeline.sampler)),
);

Expand Down
94 changes: 54 additions & 40 deletions crates/bevy_anti_alias/src/smaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ use bevy_render::{
},
render_resource::{
binding_types::{sampler, texture_2d, uniform_buffer},
AddressMode, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries,
CachedRenderPipelineId, ColorTargetState, ColorWrites, CompareFunction, DepthStencilState,
DynamicUniformBuffer, FilterMode, FragmentState, LoadOp, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor,
RenderPipeline, RenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor,
ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines,
StencilFaceState, StencilOperation, StencilState, StoreOp, TextureDescriptor,
TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView,
VertexState,
AddressMode, BindGroup, BindGroupEntries, BindGroupLayoutDescriptor,
BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites,
CompareFunction, DepthStencilState, DynamicUniformBuffer, FilterMode, FragmentState,
LoadOp, Operations, PipelineCache, RenderPassColorAttachment,
RenderPassDepthStencilAttachment, RenderPassDescriptor, RenderPipeline,
RenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor, ShaderStages, ShaderType,
SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilOperation,
StencilState, StoreOp, TextureDescriptor, TextureDimension, TextureFormat,
TextureSampleType, TextureUsages, TextureView, VertexState,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
texture::{CachedTexture, GpuImage, TextureCache},
Expand Down Expand Up @@ -143,29 +143,29 @@ pub struct SmaaPipelines {
/// The pipeline data for phase 1 of SMAA: edge detection.
struct SmaaEdgeDetectionPipeline {
/// The bind group layout common to all passes.
postprocess_bind_group_layout: BindGroupLayout,
postprocess_bind_group_layout: BindGroupLayoutDescriptor,
/// The bind group layout for data specific to this pass.
edge_detection_bind_group_layout: BindGroupLayout,
edge_detection_bind_group_layout: BindGroupLayoutDescriptor,
/// The shader asset handle.
shader: Handle<Shader>,
}

/// The pipeline data for phase 2 of SMAA: blending weight calculation.
struct SmaaBlendingWeightCalculationPipeline {
/// The bind group layout common to all passes.
postprocess_bind_group_layout: BindGroupLayout,
postprocess_bind_group_layout: BindGroupLayoutDescriptor,
/// The bind group layout for data specific to this pass.
blending_weight_calculation_bind_group_layout: BindGroupLayout,
blending_weight_calculation_bind_group_layout: BindGroupLayoutDescriptor,
/// The shader asset handle.
shader: Handle<Shader>,
}

/// The pipeline data for phase 3 of SMAA: neighborhood blending.
struct SmaaNeighborhoodBlendingPipeline {
/// The bind group layout common to all passes.
postprocess_bind_group_layout: BindGroupLayout,
postprocess_bind_group_layout: BindGroupLayoutDescriptor,
/// The bind group layout for data specific to this pass.
neighborhood_blending_bind_group_layout: BindGroupLayout,
neighborhood_blending_bind_group_layout: BindGroupLayoutDescriptor,
/// The shader asset handle.
shader: Handle<Shader>,
}
Expand Down Expand Up @@ -356,13 +356,9 @@ impl Plugin for SmaaPlugin {
}
}

pub fn init_smaa_pipelines(
mut commands: Commands,
render_device: Res<RenderDevice>,
asset_server: Res<AssetServer>,
) {
pub fn init_smaa_pipelines(mut commands: Commands, asset_server: Res<AssetServer>) {
// Create the postprocess bind group layout (all passes, bind group 0).
let postprocess_bind_group_layout = render_device.create_bind_group_layout(
let postprocess_bind_group_layout = BindGroupLayoutDescriptor::new(
"SMAA postprocess bind group layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand All @@ -374,7 +370,7 @@ pub fn init_smaa_pipelines(
);

// Create the edge detection bind group layout (pass 1, bind group 1).
let edge_detection_bind_group_layout = render_device.create_bind_group_layout(
let edge_detection_bind_group_layout = BindGroupLayoutDescriptor::new(
"SMAA edge detection bind group layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand All @@ -383,7 +379,7 @@ pub fn init_smaa_pipelines(
);

// Create the blending weight calculation bind group layout (pass 2, bind group 1).
let blending_weight_calculation_bind_group_layout = render_device.create_bind_group_layout(
let blending_weight_calculation_bind_group_layout = BindGroupLayoutDescriptor::new(
"SMAA blending weight calculation bind group layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand All @@ -397,7 +393,7 @@ pub fn init_smaa_pipelines(
);

// Create the neighborhood blending bind group layout (pass 3, bind group 1).
let neighborhood_blending_bind_group_layout = render_device.create_bind_group_layout(
let neighborhood_blending_bind_group_layout = BindGroupLayoutDescriptor::new(
"SMAA neighborhood blending bind group layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand Down Expand Up @@ -728,6 +724,7 @@ fn prepare_smaa_bind_groups(
smaa_pipelines: Res<SmaaPipelines>,
smaa_luts: Res<SmaaLuts>,
images: Res<RenderAssets<GpuImage>>,
pipeline_cache: Res<PipelineCache>,
view_targets: Query<(Entity, &SmaaTextures), (With<ExtractedView>, With<Smaa>)>,
) {
// Fetch the two lookup textures. These are bundled in this library.
Expand All @@ -754,16 +751,20 @@ fn prepare_smaa_bind_groups(
commands.entity(entity).insert(SmaaBindGroups {
edge_detection_bind_group: render_device.create_bind_group(
Some("SMAA edge detection bind group"),
&smaa_pipelines
.edge_detection
.edge_detection_bind_group_layout,
&pipeline_cache.get_bind_group_layout(
&smaa_pipelines
.edge_detection
.edge_detection_bind_group_layout,
),
&BindGroupEntries::sequential((&sampler,)),
),
blending_weight_calculation_bind_group: render_device.create_bind_group(
Some("SMAA blending weight calculation bind group"),
&smaa_pipelines
.blending_weight_calculation
.blending_weight_calculation_bind_group_layout,
&pipeline_cache.get_bind_group_layout(
&smaa_pipelines
.blending_weight_calculation
.blending_weight_calculation_bind_group_layout,
),
&BindGroupEntries::sequential((
&smaa_textures.edge_detection_color_texture.default_view,
&sampler,
Expand All @@ -773,9 +774,11 @@ fn prepare_smaa_bind_groups(
),
neighborhood_blending_bind_group: render_device.create_bind_group(
Some("SMAA neighborhood blending bind group"),
&smaa_pipelines
.neighborhood_blending
.neighborhood_blending_bind_group_layout,
&pipeline_cache.get_bind_group_layout(
&smaa_pipelines
.neighborhood_blending
.neighborhood_blending_bind_group_layout,
),
&BindGroupEntries::sequential((
&smaa_textures.blend_texture.default_view,
&sampler,
Expand Down Expand Up @@ -837,6 +840,7 @@ impl ViewNode for SmaaNode {
// Stage 1: Edge detection pass.
perform_edge_detection(
render_context,
pipeline_cache,
smaa_pipelines,
smaa_textures,
view_smaa_bind_groups,
Expand All @@ -849,6 +853,7 @@ impl ViewNode for SmaaNode {
// Stage 2: Blending weight calculation pass.
perform_blending_weight_calculation(
render_context,
pipeline_cache,
smaa_pipelines,
smaa_textures,
view_smaa_bind_groups,
Expand All @@ -861,6 +866,7 @@ impl ViewNode for SmaaNode {
// Stage 3: Neighborhood blending pass.
perform_neighborhood_blending(
render_context,
pipeline_cache,
smaa_pipelines,
view_smaa_bind_groups,
smaa_info_uniform_buffer,
Expand All @@ -885,6 +891,7 @@ impl ViewNode for SmaaNode {
/// examine them.
fn perform_edge_detection(
render_context: &mut RenderContext,
pipeline_cache: &PipelineCache,
smaa_pipelines: &SmaaPipelines,
smaa_textures: &SmaaTextures,
view_smaa_bind_groups: &SmaaBindGroups,
Expand All @@ -896,7 +903,8 @@ fn perform_edge_detection(
// Create the edge detection bind group.
let postprocess_bind_group = render_context.render_device().create_bind_group(
None,
&smaa_pipelines.edge_detection.postprocess_bind_group_layout,
&pipeline_cache
.get_bind_group_layout(&smaa_pipelines.edge_detection.postprocess_bind_group_layout),
&BindGroupEntries::sequential((source, &**smaa_info_uniform_buffer)),
);

Expand Down Expand Up @@ -939,6 +947,7 @@ fn perform_edge_detection(
/// pixels it doesn't need to examine.
fn perform_blending_weight_calculation(
render_context: &mut RenderContext,
pipeline_cache: &PipelineCache,
smaa_pipelines: &SmaaPipelines,
smaa_textures: &SmaaTextures,
view_smaa_bind_groups: &SmaaBindGroups,
Expand All @@ -950,9 +959,11 @@ fn perform_blending_weight_calculation(
// Create the blending weight calculation bind group.
let postprocess_bind_group = render_context.render_device().create_bind_group(
None,
&smaa_pipelines
.blending_weight_calculation
.postprocess_bind_group_layout,
&pipeline_cache.get_bind_group_layout(
&smaa_pipelines
.blending_weight_calculation
.postprocess_bind_group_layout,
),
&BindGroupEntries::sequential((source, &**smaa_info_uniform_buffer)),
);

Expand Down Expand Up @@ -998,6 +1009,7 @@ fn perform_blending_weight_calculation(
/// texture. It's the only phase that writes to the postprocessing destination.
fn perform_neighborhood_blending(
render_context: &mut RenderContext,
pipeline_cache: &PipelineCache,
smaa_pipelines: &SmaaPipelines,
view_smaa_bind_groups: &SmaaBindGroups,
smaa_info_uniform_buffer: &SmaaInfoUniformBuffer,
Expand All @@ -1008,9 +1020,11 @@ fn perform_neighborhood_blending(
) {
let postprocess_bind_group = render_context.render_device().create_bind_group(
None,
&smaa_pipelines
.neighborhood_blending
.postprocess_bind_group_layout,
&pipeline_cache.get_bind_group_layout(
&smaa_pipelines
.neighborhood_blending
.postprocess_bind_group_layout,
),
&BindGroupEntries::sequential((source, &**smaa_info_uniform_buffer)),
);

Expand Down
18 changes: 9 additions & 9 deletions crates/bevy_anti_alias/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner},
render_resource::{
binding_types::{sampler, texture_2d, texture_depth_2d},
BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId,
ColorTargetState, ColorWrites, FilterMode, FragmentState, Operations, PipelineCache,
RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler,
SamplerBindingType, SamplerDescriptor, ShaderStages, SpecializedRenderPipeline,
SpecializedRenderPipelines, TextureDescriptor, TextureDimension, TextureFormat,
TextureSampleType, TextureUsages,
BindGroupEntries, BindGroupLayoutDescriptor, BindGroupLayoutEntries,
CachedRenderPipelineId, ColorTargetState, ColorWrites, FilterMode, FragmentState,
Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor,
RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderStages,
SpecializedRenderPipeline, SpecializedRenderPipelines, TextureDescriptor, TextureDimension,
TextureFormat, TextureSampleType, TextureUsages,
},
renderer::{RenderContext, RenderDevice},
sync_component::SyncComponentPlugin,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl ViewNode for TemporalAntiAliasNode {

let taa_bind_group = render_context.render_device().create_bind_group(
"taa_bind_group",
&pipelines.taa_bind_group_layout,
&pipeline_cache.get_bind_group_layout(&pipelines.taa_bind_group_layout),
&BindGroupEntries::sequential((
view_target.source,
&taa_history_textures.read.default_view,
Expand Down Expand Up @@ -236,7 +236,7 @@ impl ViewNode for TemporalAntiAliasNode {

#[derive(Resource)]
struct TaaPipeline {
taa_bind_group_layout: BindGroupLayout,
taa_bind_group_layout: BindGroupLayoutDescriptor,
nearest_sampler: Sampler,
linear_sampler: Sampler,
fullscreen_shader: FullscreenShader,
Expand All @@ -262,7 +262,7 @@ fn init_taa_pipeline(
..SamplerDescriptor::default()
});

let taa_bind_group_layout = render_device.create_bind_group_layout(
let taa_bind_group_layout = BindGroupLayoutDescriptor::new(
"taa_bind_group_layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand Down
7 changes: 4 additions & 3 deletions crates/bevy_core_pipeline/src/blit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Plugin for BlitPlugin {

#[derive(Resource)]
pub struct BlitPipeline {
pub layout: BindGroupLayout,
pub layout: BindGroupLayoutDescriptor,
pub sampler: Sampler,
pub fullscreen_shader: FullscreenShader,
pub fragment_shader: Handle<Shader>,
Expand All @@ -45,7 +45,7 @@ pub fn init_blit_pipeline(
fullscreen_shader: Res<FullscreenShader>,
asset_server: Res<AssetServer>,
) {
let layout = render_device.create_bind_group_layout(
let layout = BindGroupLayoutDescriptor::new(
"blit_bind_group_layout",
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
Expand All @@ -71,10 +71,11 @@ impl BlitPipeline {
&self,
render_device: &RenderDevice,
src_texture: &TextureView,
pipeline_cache: &PipelineCache,
) -> BindGroup {
render_device.create_bind_group(
None,
&self.layout,
&pipeline_cache.get_bind_group_layout(&self.layout),
&BindGroupEntries::sequential((src_texture, &self.sampler)),
)
}
Expand Down
Loading
Loading