Skip to content

Commit

Permalink
feat(shader)!: make ProgrammableStage::entry_point optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Apr 18, 2024
1 parent 1a37b65 commit 6bae1ac
Show file tree
Hide file tree
Showing 43 changed files with 129 additions and 113 deletions.
8 changes: 4 additions & 4 deletions deno_webgpu/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<'a> From<GpuVertexBufferLayout> for wgpu_core::pipeline::VertexBufferLayout
#[serde(rename_all = "camelCase")]
struct GpuVertexState {
module: ResourceId,
entry_point: String,
entry_point: Option<String>,
constants: HashMap<String, f64>,
buffers: Vec<Option<GpuVertexBufferLayout>>,
}
Expand Down Expand Up @@ -308,7 +308,7 @@ impl From<GpuMultisampleState> for wgpu_types::MultisampleState {
struct GpuFragmentState {
targets: Vec<Option<wgpu_types::ColorTargetState>>,
module: u32,
entry_point: String,
entry_point: Option<String>,
constants: HashMap<String, f64>,
}

Expand Down Expand Up @@ -358,7 +358,7 @@ pub fn op_webgpu_create_render_pipeline(
Some(wgpu_core::pipeline::FragmentState {
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
module: fragment_shader_module_resource.1,
entry_point: Some(Cow::from(fragment.entry_point)),
entry_point: fragment.entry_point.map(Cow::from),
constants: Cow::Owned(fragment.constants),
// Required to be true for WebGPU
zero_initialize_workgroup_memory: true,
Expand All @@ -383,7 +383,7 @@ pub fn op_webgpu_create_render_pipeline(
vertex: wgpu_core::pipeline::VertexState {
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
module: vertex_shader_module_resource.1,
entry_point: Some(Cow::Owned(args.vertex.entry_point)),
entry_point: args.vertex.entry_point.map(Cow::from),
constants: Cow::Owned(args.vertex.constants),
// Required to be true for WebGPU
zero_initialize_workgroup_memory: true,
Expand Down
6 changes: 3 additions & 3 deletions examples/src/boids/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl crate::framework::Example for Example {
layout: Some(&render_pipeline_layout),
vertex: wgpu::VertexState {
module: &draw_shader,
entry_point: "main_vs",
entry_point: Some("main_vs"),
compilation_options: Default::default(),
buffers: &[
wgpu::VertexBufferLayout {
Expand All @@ -148,7 +148,7 @@ impl crate::framework::Example for Example {
},
fragment: Some(wgpu::FragmentState {
module: &draw_shader,
entry_point: "main_fs",
entry_point: Some("main_fs"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand All @@ -164,7 +164,7 @@ impl crate::framework::Example for Example {
label: Some("Compute pipeline"),
layout: Some(&compute_pipeline_layout),
module: &compute_shader,
entry_point: "main",
entry_point: Some("main"),
compilation_options: Default::default(),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/src/bunnymark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(wgpu::ColorTargetState {
format: config.view_formats[0],
Expand Down
16 changes: 8 additions & 8 deletions examples/src/conservative_raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout_empty),
vertex: wgpu::VertexState {
module: &shader_triangle_and_lines,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader_triangle_and_lines,
entry_point: "fs_main_red",
entry_point: Some("fs_main_red"),
compilation_options: Default::default(),
targets: &[Some(RENDER_TARGET_FORMAT.into())],
}),
Expand All @@ -121,13 +121,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout_empty),
vertex: wgpu::VertexState {
module: &shader_triangle_and_lines,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader_triangle_and_lines,
entry_point: "fs_main_blue",
entry_point: Some("fs_main_blue"),
compilation_options: Default::default(),
targets: &[Some(RENDER_TARGET_FORMAT.into())],
}),
Expand All @@ -147,13 +147,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout_empty),
vertex: wgpu::VertexState {
module: &shader_triangle_and_lines,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader_triangle_and_lines,
entry_point: "fs_main_white",
entry_point: Some("fs_main_white"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down Expand Up @@ -210,13 +210,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down
8 changes: 4 additions & 4 deletions examples/src/cube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &vertex_buffers,
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand All @@ -271,13 +271,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &vertex_buffers,
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_wire",
entry_point: Some("fs_wire"),
compilation_options: Default::default(),
targets: &[Some(wgpu::ColorTargetState {
format: config.view_formats[0],
Expand Down
2 changes: 1 addition & 1 deletion examples/src/hello_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn execute_gpu_inner(
label: None,
layout: None,
module: &cs_module,
entry_point: "main",
entry_point: Some("main"),
compilation_options: Default::default(),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/src/hello_synchronization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ async fn execute(
label: None,
layout: Some(&pipeline_layout),
module: &shaders_module,
entry_point: "patient_main",
entry_point: Some("patient_main"),
compilation_options: Default::default(),
});
let hasty_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),
module: &shaders_module,
entry_point: "hasty_main",
entry_point: Some("hasty_main"),
compilation_options: Default::default(),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/src/hello_triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
buffers: &[],
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(swapchain_format.into())],
}),
Expand Down
2 changes: 1 addition & 1 deletion examples/src/hello_workgroups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn run() {
label: None,
layout: Some(&pipeline_layout),
module: &shader,
entry_point: "main",
entry_point: Some("main"),
compilation_options: Default::default(),
});

Expand Down
8 changes: 4 additions & 4 deletions examples/src/mipmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ impl Example {
layout: None,
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(TEXTURE_FORMAT.into())],
}),
Expand Down Expand Up @@ -291,13 +291,13 @@ impl crate::framework::Example for Example {
layout: None,
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down
4 changes: 2 additions & 2 deletions examples/src/msaa_line/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Example {
layout: Some(pipeline_layout),
vertex: wgpu::VertexState {
module: shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
Expand All @@ -63,7 +63,7 @@ impl Example {
},
fragment: Some(wgpu::FragmentState {
module: shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down
4 changes: 2 additions & 2 deletions examples/src/render_to_texture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ async fn run(_path: Option<String>) {
layout: None,
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(wgpu::TextureFormat::Rgba8UnormSrgb.into())],
}),
Expand Down
2 changes: 1 addition & 1 deletion examples/src/repeated_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl WgpuContext {
label: None,
layout: Some(&pipeline_layout),
module: &shader,
entry_point: "main",
entry_point: Some("main"),
compilation_options: Default::default(),
});

Expand Down
8 changes: 4 additions & 4 deletions examples/src/shadow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_bake",
entry_point: Some("vs_bake"),
compilation_options: Default::default(),
buffers: &[vb_desc.clone()],
},
Expand Down Expand Up @@ -632,17 +632,17 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &[vb_desc],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: if supports_storage_resources {
entry_point: Some(if supports_storage_resources {
"fs_main"
} else {
"fs_main_without_storage"
},
}),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down
8 changes: 4 additions & 4 deletions examples/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_sky",
entry_point: Some("vs_sky"),
compilation_options: Default::default(),
buffers: &[],
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_sky",
entry_point: Some("fs_sky"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand All @@ -227,7 +227,7 @@ impl crate::framework::Example for Example {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_entity",
entry_point: Some("vs_entity"),
compilation_options: Default::default(),
buffers: &[wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
Expand All @@ -237,7 +237,7 @@ impl crate::framework::Example for Example {
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_entity",
entry_point: Some("fs_entity"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down
4 changes: 2 additions & 2 deletions examples/src/srgb_blend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",
entry_point: Some("vs_main"),
compilation_options: Default::default(),
buffers: &vertex_buffers,
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: "fs_main",
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(wgpu::ColorTargetState {
format: config.view_formats[0],
Expand Down
Loading

0 comments on commit 6bae1ac

Please sign in to comment.