MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / load_custom_shader

Method load_custom_shader

native/shared/src/renderer/mod.rs:13058–13123  ·  view source on GitHub ↗
(&mut self, wgsl_source: &str)

Source from the content-addressed store, hash-verified

13056 }
13057
13058 pub fn load_custom_shader(&mut self, wgsl_source: &str) -> usize {
13059 let shader_module = self.device.create_shader_module(wgpu::ShaderModuleDescriptor {
13060 label: Some("custom_shader"),
13061 source: wgpu::ShaderSource::Wgsl(wgsl_source.into()),
13062 });
13063
13064 // Create layout matching the default 3D pipeline
13065 let bind_group_layout = self.device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
13066 label: Some("custom_shader_bgl"),
13067 entries: &[wgpu::BindGroupLayoutEntry {
13068 binding: 0,
13069 visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
13070 ty: wgpu::BindingType::Buffer {
13071 ty: wgpu::BufferBindingType::Uniform,
13072 has_dynamic_offset: false,
13073 min_binding_size: None,
13074 },
13075 count: None,
13076 }],
13077 });
13078 let pipeline_layout = self.device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
13079 label: Some("custom_pipeline_layout"),
13080 bind_group_layouts: &[Some(&bind_group_layout)],
13081 immediate_size: 0,
13082 });
13083
13084 let pipeline = self.device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
13085 label: Some("custom_pipeline"),
13086 layout: Some(&pipeline_layout),
13087 vertex: wgpu::VertexState {
13088 module: &shader_module,
13089 entry_point: Some("vs_main_3d"),
13090 buffers: &[Vertex3D::desc()],
13091 compilation_options: Default::default(),
13092 },
13093 fragment: Some(wgpu::FragmentState {
13094 module: &shader_module,
13095 entry_point: Some("fs_main_3d"),
13096 targets: &[Some(wgpu::ColorTargetState {
13097 format: self.surface_config.format,
13098 blend: Some(wgpu::BlendState::ALPHA_BLENDING),
13099 write_mask: wgpu::ColorWrites::ALL,
13100 })],
13101 compilation_options: Default::default(),
13102 }),
13103 primitive: wgpu::PrimitiveState {
13104 topology: wgpu::PrimitiveTopology::TriangleList,
13105 front_face: wgpu::FrontFace::Ccw,
13106 cull_mode: Some(wgpu::Face::Back),
13107 ..Default::default()
13108 },
13109 depth_stencil: Some(wgpu::DepthStencilState {
13110 format: wgpu::TextureFormat::Depth32Float,
13111 depth_write_enabled: Some(true),
13112 depth_compare: Some(wgpu::CompareFunction::Less),
13113 stencil: wgpu::StencilState::default(),
13114 bias: wgpu::DepthBiasState::default(),
13115 }),

Callers 6

bloom_load_shaderFunction · 0.80
bloom_load_shaderFunction · 0.80
bloom_load_shaderFunction · 0.80
bloom_load_shaderFunction · 0.80
bloom_load_shaderFunction · 0.80
bloom_load_shaderFunction · 0.80

Calls 2

descFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected