Skip to content

Commit 6bae1ac

Browse files
feat(shader)!: make ProgrammableStage::entry_point optional
1 parent 1a37b65 commit 6bae1ac

File tree

43 files changed

+129
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+129
-113
lines changed

deno_webgpu/pipeline.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'a> From<GpuVertexBufferLayout> for wgpu_core::pipeline::VertexBufferLayout
280280
#[serde(rename_all = "camelCase")]
281281
struct GpuVertexState {
282282
module: ResourceId,
283-
entry_point: String,
283+
entry_point: Option<String>,
284284
constants: HashMap<String, f64>,
285285
buffers: Vec<Option<GpuVertexBufferLayout>>,
286286
}
@@ -308,7 +308,7 @@ impl From<GpuMultisampleState> for wgpu_types::MultisampleState {
308308
struct GpuFragmentState {
309309
targets: Vec<Option<wgpu_types::ColorTargetState>>,
310310
module: u32,
311-
entry_point: String,
311+
entry_point: Option<String>,
312312
constants: HashMap<String, f64>,
313313
}
314314

@@ -358,7 +358,7 @@ pub fn op_webgpu_create_render_pipeline(
358358
Some(wgpu_core::pipeline::FragmentState {
359359
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
360360
module: fragment_shader_module_resource.1,
361-
entry_point: Some(Cow::from(fragment.entry_point)),
361+
entry_point: fragment.entry_point.map(Cow::from),
362362
constants: Cow::Owned(fragment.constants),
363363
// Required to be true for WebGPU
364364
zero_initialize_workgroup_memory: true,
@@ -383,7 +383,7 @@ pub fn op_webgpu_create_render_pipeline(
383383
vertex: wgpu_core::pipeline::VertexState {
384384
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
385385
module: vertex_shader_module_resource.1,
386-
entry_point: Some(Cow::Owned(args.vertex.entry_point)),
386+
entry_point: args.vertex.entry_point.map(Cow::from),
387387
constants: Cow::Owned(args.vertex.constants),
388388
// Required to be true for WebGPU
389389
zero_initialize_workgroup_memory: true,

examples/src/boids/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl crate::framework::Example for Example {
131131
layout: Some(&render_pipeline_layout),
132132
vertex: wgpu::VertexState {
133133
module: &draw_shader,
134-
entry_point: "main_vs",
134+
entry_point: Some("main_vs"),
135135
compilation_options: Default::default(),
136136
buffers: &[
137137
wgpu::VertexBufferLayout {
@@ -148,7 +148,7 @@ impl crate::framework::Example for Example {
148148
},
149149
fragment: Some(wgpu::FragmentState {
150150
module: &draw_shader,
151-
entry_point: "main_fs",
151+
entry_point: Some("main_fs"),
152152
compilation_options: Default::default(),
153153
targets: &[Some(config.view_formats[0].into())],
154154
}),
@@ -164,7 +164,7 @@ impl crate::framework::Example for Example {
164164
label: Some("Compute pipeline"),
165165
layout: Some(&compute_pipeline_layout),
166166
module: &compute_shader,
167-
entry_point: "main",
167+
entry_point: Some("main"),
168168
compilation_options: Default::default(),
169169
});
170170

examples/src/bunnymark/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ impl crate::framework::Example for Example {
202202
layout: Some(&pipeline_layout),
203203
vertex: wgpu::VertexState {
204204
module: &shader,
205-
entry_point: "vs_main",
205+
entry_point: Some("vs_main"),
206206
compilation_options: Default::default(),
207207
buffers: &[],
208208
},
209209
fragment: Some(wgpu::FragmentState {
210210
module: &shader,
211-
entry_point: "fs_main",
211+
entry_point: Some("fs_main"),
212212
compilation_options: Default::default(),
213213
targets: &[Some(wgpu::ColorTargetState {
214214
format: config.view_formats[0],

examples/src/conservative_raster/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ impl crate::framework::Example for Example {
9696
layout: Some(&pipeline_layout_empty),
9797
vertex: wgpu::VertexState {
9898
module: &shader_triangle_and_lines,
99-
entry_point: "vs_main",
99+
entry_point: Some("vs_main"),
100100
compilation_options: Default::default(),
101101
buffers: &[],
102102
},
103103
fragment: Some(wgpu::FragmentState {
104104
module: &shader_triangle_and_lines,
105-
entry_point: "fs_main_red",
105+
entry_point: Some("fs_main_red"),
106106
compilation_options: Default::default(),
107107
targets: &[Some(RENDER_TARGET_FORMAT.into())],
108108
}),
@@ -121,13 +121,13 @@ impl crate::framework::Example for Example {
121121
layout: Some(&pipeline_layout_empty),
122122
vertex: wgpu::VertexState {
123123
module: &shader_triangle_and_lines,
124-
entry_point: "vs_main",
124+
entry_point: Some("vs_main"),
125125
compilation_options: Default::default(),
126126
buffers: &[],
127127
},
128128
fragment: Some(wgpu::FragmentState {
129129
module: &shader_triangle_and_lines,
130-
entry_point: "fs_main_blue",
130+
entry_point: Some("fs_main_blue"),
131131
compilation_options: Default::default(),
132132
targets: &[Some(RENDER_TARGET_FORMAT.into())],
133133
}),
@@ -147,13 +147,13 @@ impl crate::framework::Example for Example {
147147
layout: Some(&pipeline_layout_empty),
148148
vertex: wgpu::VertexState {
149149
module: &shader_triangle_and_lines,
150-
entry_point: "vs_main",
150+
entry_point: Some("vs_main"),
151151
compilation_options: Default::default(),
152152
buffers: &[],
153153
},
154154
fragment: Some(wgpu::FragmentState {
155155
module: &shader_triangle_and_lines,
156-
entry_point: "fs_main_white",
156+
entry_point: Some("fs_main_white"),
157157
compilation_options: Default::default(),
158158
targets: &[Some(config.view_formats[0].into())],
159159
}),
@@ -210,13 +210,13 @@ impl crate::framework::Example for Example {
210210
layout: Some(&pipeline_layout),
211211
vertex: wgpu::VertexState {
212212
module: &shader,
213-
entry_point: "vs_main",
213+
entry_point: Some("vs_main"),
214214
compilation_options: Default::default(),
215215
buffers: &[],
216216
},
217217
fragment: Some(wgpu::FragmentState {
218218
module: &shader,
219-
entry_point: "fs_main",
219+
entry_point: Some("fs_main"),
220220
compilation_options: Default::default(),
221221
targets: &[Some(config.view_formats[0].into())],
222222
}),

examples/src/cube/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ impl crate::framework::Example for Example {
243243
layout: Some(&pipeline_layout),
244244
vertex: wgpu::VertexState {
245245
module: &shader,
246-
entry_point: "vs_main",
246+
entry_point: Some("vs_main"),
247247
compilation_options: Default::default(),
248248
buffers: &vertex_buffers,
249249
},
250250
fragment: Some(wgpu::FragmentState {
251251
module: &shader,
252-
entry_point: "fs_main",
252+
entry_point: Some("fs_main"),
253253
compilation_options: Default::default(),
254254
targets: &[Some(config.view_formats[0].into())],
255255
}),
@@ -271,13 +271,13 @@ impl crate::framework::Example for Example {
271271
layout: Some(&pipeline_layout),
272272
vertex: wgpu::VertexState {
273273
module: &shader,
274-
entry_point: "vs_main",
274+
entry_point: Some("vs_main"),
275275
compilation_options: Default::default(),
276276
buffers: &vertex_buffers,
277277
},
278278
fragment: Some(wgpu::FragmentState {
279279
module: &shader,
280-
entry_point: "fs_wire",
280+
entry_point: Some("fs_wire"),
281281
compilation_options: Default::default(),
282282
targets: &[Some(wgpu::ColorTargetState {
283283
format: config.view_formats[0],

examples/src/hello_compute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async fn execute_gpu_inner(
108108
label: None,
109109
layout: None,
110110
module: &cs_module,
111-
entry_point: "main",
111+
entry_point: Some("main"),
112112
compilation_options: Default::default(),
113113
});
114114

examples/src/hello_synchronization/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ async fn execute(
102102
label: None,
103103
layout: Some(&pipeline_layout),
104104
module: &shaders_module,
105-
entry_point: "patient_main",
105+
entry_point: Some("patient_main"),
106106
compilation_options: Default::default(),
107107
});
108108
let hasty_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
109109
label: None,
110110
layout: Some(&pipeline_layout),
111111
module: &shaders_module,
112-
entry_point: "hasty_main",
112+
entry_point: Some("hasty_main"),
113113
compilation_options: Default::default(),
114114
});
115115

examples/src/hello_triangle/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
5858
layout: Some(&pipeline_layout),
5959
vertex: wgpu::VertexState {
6060
module: &shader,
61-
entry_point: "vs_main",
61+
entry_point: Some("vs_main"),
6262
buffers: &[],
6363
compilation_options: Default::default(),
6464
},
6565
fragment: Some(wgpu::FragmentState {
6666
module: &shader,
67-
entry_point: "fs_main",
67+
entry_point: Some("fs_main"),
6868
compilation_options: Default::default(),
6969
targets: &[Some(swapchain_format.into())],
7070
}),

examples/src/hello_workgroups/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async fn run() {
109109
label: None,
110110
layout: Some(&pipeline_layout),
111111
module: &shader,
112-
entry_point: "main",
112+
entry_point: Some("main"),
113113
compilation_options: Default::default(),
114114
});
115115

examples/src/mipmap/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ impl Example {
9292
layout: None,
9393
vertex: wgpu::VertexState {
9494
module: &shader,
95-
entry_point: "vs_main",
95+
entry_point: Some("vs_main"),
9696
compilation_options: Default::default(),
9797
buffers: &[],
9898
},
9999
fragment: Some(wgpu::FragmentState {
100100
module: &shader,
101-
entry_point: "fs_main",
101+
entry_point: Some("fs_main"),
102102
compilation_options: Default::default(),
103103
targets: &[Some(TEXTURE_FORMAT.into())],
104104
}),
@@ -291,13 +291,13 @@ impl crate::framework::Example for Example {
291291
layout: None,
292292
vertex: wgpu::VertexState {
293293
module: &shader,
294-
entry_point: "vs_main",
294+
entry_point: Some("vs_main"),
295295
compilation_options: Default::default(),
296296
buffers: &[],
297297
},
298298
fragment: Some(wgpu::FragmentState {
299299
module: &shader,
300-
entry_point: "fs_main",
300+
entry_point: Some("fs_main"),
301301
compilation_options: Default::default(),
302302
targets: &[Some(config.view_formats[0].into())],
303303
}),

0 commit comments

Comments
 (0)