Skip to content

Commit 681e74a

Browse files
committed
WIP15: manual pipeline layout, fixing errors when bindings got DCE'd
1 parent a82ca9f commit 681e74a

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl PerPixelAdjust {
190190
#wgpu_executor.shader_runtime.run_per_pixel_adjust(&::wgpu_executor::shader_runtime::Shaders {
191191
wgsl_shader: crate::WGSL_SHADER,
192192
fragment_shader_name: super::#entry_point_name,
193-
}, #gpu_image, &()).await
193+
}, #gpu_image, &1u32).await
194194
}
195195
};
196196

node-graph/wgpu-executor/src/shader_runtime/per_pixel_adjust_runtime.rs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use std::borrow::Cow;
88
use std::collections::HashMap;
99
use wgpu::util::{BufferInitDescriptor, DeviceExt};
1010
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,
1414
};
1515

1616
pub 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

Comments
 (0)