@@ -8,9 +8,9 @@ use std::borrow::Cow;
88use std:: collections:: HashMap ;
99use wgpu:: util:: { BufferInitDescriptor , DeviceExt } ;
1010use wgpu:: {
11- BindGroupDescriptor , BindGroupEntry , BindingResource , Buffer , BufferBinding , BufferUsages , ColorTargetState , Face , FragmentState , FrontFace , LoadOp , Operations , PolygonMode , PrimitiveState ,
12- PrimitiveTopology , RenderPassColorAttachment , RenderPassDescriptor , RenderPipelineDescriptor , ShaderModuleDescriptor , ShaderSource , StoreOp , TextureDescriptor , TextureDimension , TextureFormat ,
13- TextureViewDescriptor , VertexState ,
11+ BindGroupDescriptor , BindGroupEntry , BindGroupLayoutDescriptor , BindGroupLayoutEntry , BindingResource , BindingType , Buffer , BufferBinding , BufferBindingType , BufferUsages , ColorTargetState , Face ,
12+ FragmentState , FrontFace , LoadOp , Operations , PipelineLayoutDescriptor , PolygonMode , PrimitiveState , PrimitiveTopology , RenderPassColorAttachment , RenderPassDescriptor , RenderPipelineDescriptor ,
13+ ShaderModuleDescriptor , ShaderSource , ShaderStages , StoreOp , TextureDescriptor , TextureDimension , TextureFormat , TextureSampleType , TextureViewDescriptor , TextureViewDimension , VertexState ,
1414} ;
1515
1616pub struct PerPixelAdjustShaderRuntime {
@@ -53,18 +53,48 @@ impl PerPixelAdjustGraphicsPipeline {
5353 let device = & context. device ;
5454 let name = info. fragment_shader_name . to_owned ( ) ;
5555
56- // TODO workaround to naga removing `:`
5756 let fragment_name = & name;
5857 let fragment_name = & fragment_name[ ( fragment_name. find ( "::" ) . unwrap ( ) + 2 ) ..] ;
58+ // TODO workaround to naga removing `:`
5959 let fragment_name = fragment_name. replace ( ":" , "" ) ;
60-
6160 let shader_module = device. create_shader_module ( ShaderModuleDescriptor {
6261 label : Some ( & format ! ( "PerPixelAdjust {} wgsl shader" , name) ) ,
6362 source : ShaderSource :: Wgsl ( Cow :: Borrowed ( info. wgsl_shader ) ) ,
6463 } ) ;
64+
65+ let pipeline_layout = device. create_pipeline_layout ( & PipelineLayoutDescriptor {
66+ label : Some ( & format ! ( "PerPixelAdjust {} PipelineLayout" , name) ) ,
67+ bind_group_layouts : & [ & device. create_bind_group_layout ( & BindGroupLayoutDescriptor {
68+ label : Some ( & format ! ( "PerPixelAdjust {} BindGroupLayout 0" , name) ) ,
69+ entries : & [
70+ BindGroupLayoutEntry {
71+ binding : 0 ,
72+ visibility : ShaderStages :: FRAGMENT ,
73+ ty : BindingType :: Buffer {
74+ ty : BufferBindingType :: Storage { read_only : true } ,
75+ has_dynamic_offset : false ,
76+ min_binding_size : None ,
77+ } ,
78+ count : None ,
79+ } ,
80+ BindGroupLayoutEntry {
81+ binding : 1 ,
82+ visibility : ShaderStages :: FRAGMENT ,
83+ ty : BindingType :: Texture {
84+ sample_type : TextureSampleType :: Float { filterable : false } ,
85+ view_dimension : TextureViewDimension :: D2 ,
86+ multisampled : false ,
87+ } ,
88+ count : None ,
89+ } ,
90+ ] ,
91+ } ) ] ,
92+ push_constant_ranges : & [ ] ,
93+ } ) ;
94+
6595 let pipeline = device. create_render_pipeline ( & RenderPipelineDescriptor {
6696 label : Some ( & format ! ( "PerPixelAdjust {} Pipeline" , name) ) ,
67- layout : None ,
97+ layout : Some ( & pipeline_layout ) ,
6898 vertex : VertexState {
6999 module : & shader_module,
70100 entry_point : Some ( FULLSCREEN_VERTEX_SHADER_NAME ) ,
0 commit comments