Skip to content

Commit 1ebdb0a

Browse files
WIP: feat(shader)!: make ProgrammableStage::entry_point optional
TODO: break out shader stage conversion (`shader_stage_from_stage_bit`)
1 parent 55bc503 commit 1ebdb0a

File tree

51 files changed

+263
-147
lines changed

Some content is hidden

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

51 files changed

+263
-147
lines changed

deno_webgpu/pipeline.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub enum GPUPipelineLayoutOrGPUAutoLayoutMode {
7474
#[serde(rename_all = "camelCase")]
7575
pub struct GpuProgrammableStage {
7676
module: ResourceId,
77-
entry_point: String,
77+
entry_point: Option<String>,
7878
// constants: HashMap<String, GPUPipelineConstantValue>
7979
}
8080

@@ -110,7 +110,7 @@ pub fn op_webgpu_create_compute_pipeline(
110110
layout: pipeline_layout,
111111
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
112112
module: compute_shader_module_resource.1,
113-
entry_point: Cow::from(compute.entry_point),
113+
entry_point: compute.entry_point.map(Cow::from),
114114
// TODO(lucacasonato): support args.compute.constants
115115
},
116116
};
@@ -278,7 +278,7 @@ impl<'a> From<GpuVertexBufferLayout> for wgpu_core::pipeline::VertexBufferLayout
278278
#[serde(rename_all = "camelCase")]
279279
struct GpuVertexState {
280280
module: ResourceId,
281-
entry_point: String,
281+
entry_point: Option<String>,
282282
buffers: Vec<Option<GpuVertexBufferLayout>>,
283283
}
284284

@@ -305,7 +305,7 @@ impl From<GpuMultisampleState> for wgpu_types::MultisampleState {
305305
struct GpuFragmentState {
306306
targets: Vec<Option<wgpu_types::ColorTargetState>>,
307307
module: u32,
308-
entry_point: String,
308+
entry_point: Option<String>,
309309
// TODO(lucacasonato): constants
310310
}
311311

@@ -355,7 +355,7 @@ pub fn op_webgpu_create_render_pipeline(
355355
Some(wgpu_core::pipeline::FragmentState {
356356
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
357357
module: fragment_shader_module_resource.1,
358-
entry_point: Cow::from(fragment.entry_point),
358+
entry_point: fragment.entry_point.map(Cow::from),
359359
},
360360
targets: Cow::from(fragment.targets),
361361
})
@@ -377,7 +377,7 @@ pub fn op_webgpu_create_render_pipeline(
377377
vertex: wgpu_core::pipeline::VertexState {
378378
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
379379
module: vertex_shader_module_resource.1,
380-
entry_point: Cow::Owned(args.vertex.entry_point),
380+
entry_point: args.vertex.entry_point.map(Cow::from),
381381
},
382382
buffers: Cow::Owned(vertex_buffers),
383383
},

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
buffers: &[
136136
wgpu::VertexBufferLayout {
137137
array_stride: 4 * 4,
@@ -147,7 +147,7 @@ impl crate::framework::Example for Example {
147147
},
148148
fragment: Some(wgpu::FragmentState {
149149
module: &draw_shader,
150-
entry_point: "main_fs",
150+
entry_point: Some("main_fs"),
151151
targets: &[Some(config.view_formats[0].into())],
152152
}),
153153
primitive: wgpu::PrimitiveState::default(),
@@ -162,7 +162,7 @@ impl crate::framework::Example for Example {
162162
label: Some("Compute pipeline"),
163163
layout: Some(&compute_pipeline_layout),
164164
module: &compute_shader,
165-
entry_point: "main",
165+
entry_point: Some("main"),
166166
});
167167

168168
// buffer for the three 2d triangle vertices of each instance

examples/src/bunnymark/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ 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
buffers: &[],
207207
},
208208
fragment: Some(wgpu::FragmentState {
209209
module: &shader,
210-
entry_point: "fs_main",
210+
entry_point: Some("fs_main"),
211211
targets: &[Some(wgpu::ColorTargetState {
212212
format: config.view_formats[0],
213213
blend: Some(wgpu::BlendState::ALPHA_BLENDING),

examples/src/conservative_raster/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ 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
buffers: &[],
101101
},
102102
fragment: Some(wgpu::FragmentState {
103103
module: &shader_triangle_and_lines,
104-
entry_point: "fs_main_red",
104+
entry_point: Some("fs_main_red"),
105105
targets: &[Some(RENDER_TARGET_FORMAT.into())],
106106
}),
107107
primitive: wgpu::PrimitiveState {
@@ -119,12 +119,12 @@ impl crate::framework::Example for Example {
119119
layout: Some(&pipeline_layout_empty),
120120
vertex: wgpu::VertexState {
121121
module: &shader_triangle_and_lines,
122-
entry_point: "vs_main",
122+
entry_point: Some("vs_main"),
123123
buffers: &[],
124124
},
125125
fragment: Some(wgpu::FragmentState {
126126
module: &shader_triangle_and_lines,
127-
entry_point: "fs_main_blue",
127+
entry_point: Some("fs_main_blue"),
128128
targets: &[Some(RENDER_TARGET_FORMAT.into())],
129129
}),
130130
primitive: wgpu::PrimitiveState::default(),
@@ -143,12 +143,12 @@ impl crate::framework::Example for Example {
143143
layout: Some(&pipeline_layout_empty),
144144
vertex: wgpu::VertexState {
145145
module: &shader_triangle_and_lines,
146-
entry_point: "vs_main",
146+
entry_point: Some("vs_main"),
147147
buffers: &[],
148148
},
149149
fragment: Some(wgpu::FragmentState {
150150
module: &shader_triangle_and_lines,
151-
entry_point: "fs_main_white",
151+
entry_point: Some("fs_main_white"),
152152
targets: &[Some(config.view_formats[0].into())],
153153
}),
154154
primitive: wgpu::PrimitiveState {
@@ -204,12 +204,12 @@ impl crate::framework::Example for Example {
204204
layout: Some(&pipeline_layout),
205205
vertex: wgpu::VertexState {
206206
module: &shader,
207-
entry_point: "vs_main",
207+
entry_point: Some("vs_main"),
208208
buffers: &[],
209209
},
210210
fragment: Some(wgpu::FragmentState {
211211
module: &shader,
212-
entry_point: "fs_main",
212+
entry_point: Some("fs_main"),
213213
targets: &[Some(config.view_formats[0].into())],
214214
}),
215215
primitive: wgpu::PrimitiveState::default(),

examples/src/cube/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ 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
buffers: &vertex_buffers,
248248
},
249249
fragment: Some(wgpu::FragmentState {
250250
module: &shader,
251-
entry_point: "fs_main",
251+
entry_point: Some("fs_main"),
252252
targets: &[Some(config.view_formats[0].into())],
253253
}),
254254
primitive: wgpu::PrimitiveState {
@@ -269,12 +269,12 @@ impl crate::framework::Example for Example {
269269
layout: Some(&pipeline_layout),
270270
vertex: wgpu::VertexState {
271271
module: &shader,
272-
entry_point: "vs_main",
272+
entry_point: Some("vs_main"),
273273
buffers: &vertex_buffers,
274274
},
275275
fragment: Some(wgpu::FragmentState {
276276
module: &shader,
277-
entry_point: "fs_wire",
277+
entry_point: Some("fs_wire"),
278278
targets: &[Some(wgpu::ColorTargetState {
279279
format: config.view_formats[0],
280280
blend: Some(wgpu::BlendState {

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
});
113113

114114
// Instantiates the bind group, once again specifying the binding of buffers.

examples/src/hello_synchronization/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ 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
});
107107
let hasty_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
108108
label: None,
109109
layout: Some(&pipeline_layout),
110110
module: &shaders_module,
111-
entry_point: "hasty_main",
111+
entry_point: Some("hasty_main"),
112112
});
113113

114114
//----------------------------------------------------------

examples/src/hello_triangle/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ 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
},
6464
fragment: Some(wgpu::FragmentState {
6565
module: &shader,
66-
entry_point: "fs_main",
66+
entry_point: Some("fs_main"),
6767
targets: &[Some(swapchain_format.into())],
6868
}),
6969
primitive: wgpu::PrimitiveState::default(),

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
});
114114

115115
//----------------------------------------------------------

examples/src/mipmap/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ impl Example {
9292
layout: None,
9393
vertex: wgpu::VertexState {
9494
module: &shader,
95-
entry_point: "vs_main",
95+
entry_point: Some("vs_main"),
9696
buffers: &[],
9797
},
9898
fragment: Some(wgpu::FragmentState {
9999
module: &shader,
100-
entry_point: "fs_main",
100+
entry_point: Some("fs_main"),
101101
targets: &[Some(TEXTURE_FORMAT.into())],
102102
}),
103103
primitive: wgpu::PrimitiveState {
@@ -289,12 +289,12 @@ impl crate::framework::Example for Example {
289289
layout: None,
290290
vertex: wgpu::VertexState {
291291
module: &shader,
292-
entry_point: "vs_main",
292+
entry_point: Some("vs_main"),
293293
buffers: &[],
294294
},
295295
fragment: Some(wgpu::FragmentState {
296296
module: &shader,
297-
entry_point: "fs_main",
297+
entry_point: Some("fs_main"),
298298
targets: &[Some(config.view_formats[0].into())],
299299
}),
300300
primitive: wgpu::PrimitiveState {

0 commit comments

Comments
 (0)