@@ -61,15 +61,15 @@ use bevy_render::{
6161 } ,
6262 render_resource:: {
6363 binding_types:: { sampler, texture_2d, uniform_buffer} ,
64- AddressMode , BindGroup , BindGroupEntries , BindGroupLayout , BindGroupLayoutEntries ,
65- CachedRenderPipelineId , ColorTargetState , ColorWrites , CompareFunction , DepthStencilState ,
66- DynamicUniformBuffer , FilterMode , FragmentState , LoadOp , Operations , PipelineCache ,
67- RenderPassColorAttachment , RenderPassDepthStencilAttachment , RenderPassDescriptor ,
68- RenderPipeline , RenderPipelineDescriptor , SamplerBindingType , SamplerDescriptor ,
69- ShaderStages , ShaderType , SpecializedRenderPipeline , SpecializedRenderPipelines ,
70- StencilFaceState , StencilOperation , StencilState , StoreOp , TextureDescriptor ,
71- TextureDimension , TextureFormat , TextureSampleType , TextureUsages , TextureView ,
72- VertexState ,
64+ AddressMode , BindGroup , BindGroupEntries , BindGroupLayoutDescriptor ,
65+ BindGroupLayoutEntries , CachedRenderPipelineId , ColorTargetState , ColorWrites ,
66+ CompareFunction , DepthStencilState , DynamicUniformBuffer , FilterMode , FragmentState ,
67+ LoadOp , Operations , PipelineCache , RenderPassColorAttachment ,
68+ RenderPassDepthStencilAttachment , RenderPassDescriptor , RenderPipeline ,
69+ RenderPipelineDescriptor , SamplerBindingType , SamplerDescriptor , ShaderStages , ShaderType ,
70+ SpecializedRenderPipeline , SpecializedRenderPipelines , StencilFaceState , StencilOperation ,
71+ StencilState , StoreOp , TextureDescriptor , TextureDimension , TextureFormat ,
72+ TextureSampleType , TextureUsages , TextureView , VertexState ,
7373 } ,
7474 renderer:: { RenderContext , RenderDevice , RenderQueue } ,
7575 texture:: { CachedTexture , GpuImage , TextureCache } ,
@@ -143,29 +143,29 @@ pub struct SmaaPipelines {
143143/// The pipeline data for phase 1 of SMAA: edge detection.
144144struct SmaaEdgeDetectionPipeline {
145145 /// The bind group layout common to all passes.
146- postprocess_bind_group_layout : BindGroupLayout ,
146+ postprocess_bind_group_layout : BindGroupLayoutDescriptor ,
147147 /// The bind group layout for data specific to this pass.
148- edge_detection_bind_group_layout : BindGroupLayout ,
148+ edge_detection_bind_group_layout : BindGroupLayoutDescriptor ,
149149 /// The shader asset handle.
150150 shader : Handle < Shader > ,
151151}
152152
153153/// The pipeline data for phase 2 of SMAA: blending weight calculation.
154154struct SmaaBlendingWeightCalculationPipeline {
155155 /// The bind group layout common to all passes.
156- postprocess_bind_group_layout : BindGroupLayout ,
156+ postprocess_bind_group_layout : BindGroupLayoutDescriptor ,
157157 /// The bind group layout for data specific to this pass.
158- blending_weight_calculation_bind_group_layout : BindGroupLayout ,
158+ blending_weight_calculation_bind_group_layout : BindGroupLayoutDescriptor ,
159159 /// The shader asset handle.
160160 shader : Handle < Shader > ,
161161}
162162
163163/// The pipeline data for phase 3 of SMAA: neighborhood blending.
164164struct SmaaNeighborhoodBlendingPipeline {
165165 /// The bind group layout common to all passes.
166- postprocess_bind_group_layout : BindGroupLayout ,
166+ postprocess_bind_group_layout : BindGroupLayoutDescriptor ,
167167 /// The bind group layout for data specific to this pass.
168- neighborhood_blending_bind_group_layout : BindGroupLayout ,
168+ neighborhood_blending_bind_group_layout : BindGroupLayoutDescriptor ,
169169 /// The shader asset handle.
170170 shader : Handle < Shader > ,
171171}
@@ -373,13 +373,9 @@ impl Plugin for SmaaPlugin {
373373 }
374374}
375375
376- pub fn init_smaa_pipelines (
377- mut commands : Commands ,
378- render_device : Res < RenderDevice > ,
379- asset_server : Res < AssetServer > ,
380- ) {
376+ pub fn init_smaa_pipelines ( mut commands : Commands , asset_server : Res < AssetServer > ) {
381377 // Create the postprocess bind group layout (all passes, bind group 0).
382- let postprocess_bind_group_layout = render_device . create_bind_group_layout (
378+ let postprocess_bind_group_layout = BindGroupLayoutDescriptor :: new (
383379 "SMAA postprocess bind group layout" ,
384380 & BindGroupLayoutEntries :: sequential (
385381 ShaderStages :: FRAGMENT ,
@@ -391,7 +387,7 @@ pub fn init_smaa_pipelines(
391387 ) ;
392388
393389 // Create the edge detection bind group layout (pass 1, bind group 1).
394- let edge_detection_bind_group_layout = render_device . create_bind_group_layout (
390+ let edge_detection_bind_group_layout = BindGroupLayoutDescriptor :: new (
395391 "SMAA edge detection bind group layout" ,
396392 & BindGroupLayoutEntries :: sequential (
397393 ShaderStages :: FRAGMENT ,
@@ -400,7 +396,7 @@ pub fn init_smaa_pipelines(
400396 ) ;
401397
402398 // Create the blending weight calculation bind group layout (pass 2, bind group 1).
403- let blending_weight_calculation_bind_group_layout = render_device . create_bind_group_layout (
399+ let blending_weight_calculation_bind_group_layout = BindGroupLayoutDescriptor :: new (
404400 "SMAA blending weight calculation bind group layout" ,
405401 & BindGroupLayoutEntries :: sequential (
406402 ShaderStages :: FRAGMENT ,
@@ -414,7 +410,7 @@ pub fn init_smaa_pipelines(
414410 ) ;
415411
416412 // Create the neighborhood blending bind group layout (pass 3, bind group 1).
417- let neighborhood_blending_bind_group_layout = render_device . create_bind_group_layout (
413+ let neighborhood_blending_bind_group_layout = BindGroupLayoutDescriptor :: new (
418414 "SMAA neighborhood blending bind group layout" ,
419415 & BindGroupLayoutEntries :: sequential (
420416 ShaderStages :: FRAGMENT ,
@@ -745,6 +741,7 @@ fn prepare_smaa_bind_groups(
745741 smaa_pipelines : Res < SmaaPipelines > ,
746742 smaa_luts : Res < SmaaLuts > ,
747743 images : Res < RenderAssets < GpuImage > > ,
744+ pipeline_cache : Res < PipelineCache > ,
748745 view_targets : Query < ( Entity , & SmaaTextures ) , ( With < ExtractedView > , With < Smaa > ) > ,
749746) {
750747 // Fetch the two lookup textures. These are bundled in this library.
@@ -771,16 +768,20 @@ fn prepare_smaa_bind_groups(
771768 commands. entity ( entity) . insert ( SmaaBindGroups {
772769 edge_detection_bind_group : render_device. create_bind_group (
773770 Some ( "SMAA edge detection bind group" ) ,
774- & smaa_pipelines
775- . edge_detection
776- . edge_detection_bind_group_layout ,
771+ & pipeline_cache. get_bind_group_layout (
772+ & smaa_pipelines
773+ . edge_detection
774+ . edge_detection_bind_group_layout ,
775+ ) ,
777776 & BindGroupEntries :: sequential ( ( & sampler, ) ) ,
778777 ) ,
779778 blending_weight_calculation_bind_group : render_device. create_bind_group (
780779 Some ( "SMAA blending weight calculation bind group" ) ,
781- & smaa_pipelines
782- . blending_weight_calculation
783- . blending_weight_calculation_bind_group_layout ,
780+ & pipeline_cache. get_bind_group_layout (
781+ & smaa_pipelines
782+ . blending_weight_calculation
783+ . blending_weight_calculation_bind_group_layout ,
784+ ) ,
784785 & BindGroupEntries :: sequential ( (
785786 & smaa_textures. edge_detection_color_texture . default_view ,
786787 & sampler,
@@ -790,9 +791,11 @@ fn prepare_smaa_bind_groups(
790791 ) ,
791792 neighborhood_blending_bind_group : render_device. create_bind_group (
792793 Some ( "SMAA neighborhood blending bind group" ) ,
793- & smaa_pipelines
794- . neighborhood_blending
795- . neighborhood_blending_bind_group_layout ,
794+ & pipeline_cache. get_bind_group_layout (
795+ & smaa_pipelines
796+ . neighborhood_blending
797+ . neighborhood_blending_bind_group_layout ,
798+ ) ,
796799 & BindGroupEntries :: sequential ( (
797800 & smaa_textures. blend_texture . default_view ,
798801 & sampler,
@@ -854,6 +857,7 @@ impl ViewNode for SmaaNode {
854857 // Stage 1: Edge detection pass.
855858 perform_edge_detection (
856859 render_context,
860+ pipeline_cache,
857861 smaa_pipelines,
858862 smaa_textures,
859863 view_smaa_bind_groups,
@@ -866,6 +870,7 @@ impl ViewNode for SmaaNode {
866870 // Stage 2: Blending weight calculation pass.
867871 perform_blending_weight_calculation (
868872 render_context,
873+ pipeline_cache,
869874 smaa_pipelines,
870875 smaa_textures,
871876 view_smaa_bind_groups,
@@ -878,6 +883,7 @@ impl ViewNode for SmaaNode {
878883 // Stage 3: Neighborhood blending pass.
879884 perform_neighborhood_blending (
880885 render_context,
886+ pipeline_cache,
881887 smaa_pipelines,
882888 view_smaa_bind_groups,
883889 smaa_info_uniform_buffer,
@@ -902,6 +908,7 @@ impl ViewNode for SmaaNode {
902908/// examine them.
903909fn perform_edge_detection (
904910 render_context : & mut RenderContext ,
911+ pipeline_cache : & PipelineCache ,
905912 smaa_pipelines : & SmaaPipelines ,
906913 smaa_textures : & SmaaTextures ,
907914 view_smaa_bind_groups : & SmaaBindGroups ,
@@ -913,7 +920,8 @@ fn perform_edge_detection(
913920 // Create the edge detection bind group.
914921 let postprocess_bind_group = render_context. render_device ( ) . create_bind_group (
915922 None ,
916- & smaa_pipelines. edge_detection . postprocess_bind_group_layout ,
923+ & pipeline_cache
924+ . get_bind_group_layout ( & smaa_pipelines. edge_detection . postprocess_bind_group_layout ) ,
917925 & BindGroupEntries :: sequential ( ( source, & * * smaa_info_uniform_buffer) ) ,
918926 ) ;
919927
@@ -956,6 +964,7 @@ fn perform_edge_detection(
956964/// pixels it doesn't need to examine.
957965fn perform_blending_weight_calculation (
958966 render_context : & mut RenderContext ,
967+ pipeline_cache : & PipelineCache ,
959968 smaa_pipelines : & SmaaPipelines ,
960969 smaa_textures : & SmaaTextures ,
961970 view_smaa_bind_groups : & SmaaBindGroups ,
@@ -967,9 +976,11 @@ fn perform_blending_weight_calculation(
967976 // Create the blending weight calculation bind group.
968977 let postprocess_bind_group = render_context. render_device ( ) . create_bind_group (
969978 None ,
970- & smaa_pipelines
971- . blending_weight_calculation
972- . postprocess_bind_group_layout ,
979+ & pipeline_cache. get_bind_group_layout (
980+ & smaa_pipelines
981+ . blending_weight_calculation
982+ . postprocess_bind_group_layout ,
983+ ) ,
973984 & BindGroupEntries :: sequential ( ( source, & * * smaa_info_uniform_buffer) ) ,
974985 ) ;
975986
@@ -1015,6 +1026,7 @@ fn perform_blending_weight_calculation(
10151026/// texture. It's the only phase that writes to the postprocessing destination.
10161027fn perform_neighborhood_blending (
10171028 render_context : & mut RenderContext ,
1029+ pipeline_cache : & PipelineCache ,
10181030 smaa_pipelines : & SmaaPipelines ,
10191031 view_smaa_bind_groups : & SmaaBindGroups ,
10201032 smaa_info_uniform_buffer : & SmaaInfoUniformBuffer ,
@@ -1025,9 +1037,11 @@ fn perform_neighborhood_blending(
10251037) {
10261038 let postprocess_bind_group = render_context. render_device ( ) . create_bind_group (
10271039 None ,
1028- & smaa_pipelines
1029- . neighborhood_blending
1030- . postprocess_bind_group_layout ,
1040+ & pipeline_cache. get_bind_group_layout (
1041+ & smaa_pipelines
1042+ . neighborhood_blending
1043+ . postprocess_bind_group_layout ,
1044+ ) ,
10311045 & BindGroupEntries :: sequential ( ( source, & * * smaa_info_uniform_buffer) ) ,
10321046 ) ;
10331047
0 commit comments