@@ -8,9 +8,9 @@ use std::borrow::Cow;
8
8
use std:: collections:: HashMap ;
9
9
use wgpu:: util:: { BufferInitDescriptor , DeviceExt } ;
10
10
use 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 ,
14
14
} ;
15
15
16
16
pub struct PerPixelAdjustShaderRuntime {
@@ -53,18 +53,48 @@ impl PerPixelAdjustGraphicsPipeline {
53
53
let device = & context. device ;
54
54
let name = info. fragment_shader_name . to_owned ( ) ;
55
55
56
- // TODO workaround to naga removing `:`
57
56
let fragment_name = & name;
58
57
let fragment_name = & fragment_name[ ( fragment_name. find ( "::" ) . unwrap ( ) + 2 ) ..] ;
58
+ // TODO workaround to naga removing `:`
59
59
let fragment_name = fragment_name. replace ( ":" , "" ) ;
60
-
61
60
let shader_module = device. create_shader_module ( ShaderModuleDescriptor {
62
61
label : Some ( & format ! ( "PerPixelAdjust {} wgsl shader" , name) ) ,
63
62
source : ShaderSource :: Wgsl ( Cow :: Borrowed ( info. wgsl_shader ) ) ,
64
63
} ) ;
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
+
65
95
let pipeline = device. create_render_pipeline ( & RenderPipelineDescriptor {
66
96
label : Some ( & format ! ( "PerPixelAdjust {} Pipeline" , name) ) ,
67
- layout : None ,
97
+ layout : Some ( & pipeline_layout ) ,
68
98
vertex : VertexState {
69
99
module : & shader_module,
70
100
entry_point : Some ( FULLSCREEN_VERTEX_SHADER_NAME ) ,
0 commit comments