1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/// Internal namespace.
mod private
{
use crate::*;
/// A builder for creating a `web_sys::GpuProgrammableStage`.
#[ derive( Clone ) ]
pub struct ProgrammableStage< 'a >
{
/// The required shader module containing the shader code for this stage.
///
/// This is the compiled representation of the WGSL shader.
module : &'a web_sys::GpuShaderModule,
/// An optional name of the entry point function within the shader module.
///
/// If not specified, the WebGPU implementation will typically look for a
/// default entry point, like "main".
///
/// Defaults to `None`.
entry_point : Option< &'a str >,
}
impl< 'a > ProgrammableStage< 'a >
{
/// Creates a new `ProgrammableStage` builder with a required shader module.
pub fn new( module : &'a web_sys::GpuShaderModule ) -> Self
{
let entry_point = None;
ProgrammableStage
{
module,
entry_point
}
}
/// Sets the entry point function name for the shader stage.
pub fn entry_point( mut self, entry : &'a str ) -> Self
{
self.entry_point = Some( entry );
self
}
}
impl From< ProgrammableStage< '_ > > for web_sys::GpuProgrammableStage
{
fn from( value: ProgrammableStage< '_ > ) -> Self
{
let state = web_sys::GpuProgrammableStage::new( &value.module );
if let Some( v ) = value.entry_point { state.set_entry_point( v ); }
state
}
}
}
crate::mod_interface!
{
exposed use
{
ProgrammableStage
};
}