@@ -31,8 +31,7 @@ use alloc::vec::Vec;
31
31
use bytemuck:: { Pod , Zeroable } ;
32
32
use core:: { fmt:: Debug , mem} ;
33
33
use vello_common:: { coarse:: WideTile , tile:: Tile } ;
34
- use vello_sparse_shaders:: shaders:: { clear_slots, render_strips} ;
35
- use vello_sparse_shaders:: types:: ReflectionMap ;
34
+ use vello_sparse_shaders:: { clear_slots, render_strips} ;
36
35
use web_sys:: wasm_bindgen:: { JsCast , JsValue } ;
37
36
use web_sys:: {
38
37
WebGl2RenderingContext , WebGlBuffer , WebGlFramebuffer , WebGlProgram , WebGlTexture ,
@@ -254,22 +253,19 @@ struct ClearSlotsConfig {
254
253
impl WebGlPrograms {
255
254
/// Creates programs and initializes resources.
256
255
fn new ( gl : WebGl2RenderingContext , slot_count : usize ) -> Self {
257
- let strip_glsl = render_strips ( ) ;
258
- let clear_glsl = clear_slots ( ) ;
259
-
260
- let strip_program =
261
- create_shader_program ( & gl, strip_glsl. vertex . source , strip_glsl. fragment . source ) ;
262
- let clear_program =
263
- create_shader_program ( & gl, clear_glsl. vertex . source , clear_glsl. fragment . source ) ;
264
-
265
- let strip_uniforms = get_strip_uniforms (
256
+ let strip_program = create_shader_program (
266
257
& gl,
267
- & strip_program,
268
- & strip_glsl. vertex . reflection_map ,
269
- & strip_glsl. fragment . reflection_map ,
258
+ render_strips:: VERTEX_SOURCE ,
259
+ render_strips:: FRAGMENT_SOURCE ,
270
260
) ;
271
- let clear_uniforms =
272
- get_clear_uniforms ( & gl, & clear_program, & clear_glsl. vertex . reflection_map ) ;
261
+ let clear_program = create_shader_program (
262
+ & gl,
263
+ clear_slots:: VERTEX_SOURCE ,
264
+ clear_slots:: FRAGMENT_SOURCE ,
265
+ ) ;
266
+
267
+ let strip_uniforms = get_strip_uniforms ( & gl, & strip_program) ;
268
+ let clear_uniforms = get_clear_uniforms ( & gl, & clear_program) ;
273
269
274
270
let resources = create_webgl_resources ( & gl, slot_count) ;
275
271
@@ -546,17 +542,12 @@ fn create_shader_program(
546
542
program
547
543
}
548
544
549
- /// Get the uniform locations for the strip program
550
- fn get_strip_uniforms (
551
- gl : & WebGl2RenderingContext ,
552
- program : & WebGlProgram ,
553
- vertex_reflection : & ReflectionMap < & ' static str > ,
554
- fragment_reflection : & ReflectionMap < & ' static str > ,
555
- ) -> StripUniforms {
556
- let config_vs_name = vertex_reflection. uniforms . get ( "config" ) . unwrap ( ) ;
545
+ /// Get the uniform locations for the `render_strips` program.
546
+ fn get_strip_uniforms ( gl : & WebGl2RenderingContext , program : & WebGlProgram ) -> StripUniforms {
547
+ let config_vs_name = render_strips:: vertex:: CONFIG ;
557
548
let config_vs_block_index = gl. get_uniform_block_index ( program, config_vs_name) ;
558
549
559
- let config_fs_name = fragment_reflection . uniforms . get ( "config" ) . unwrap ( ) ;
550
+ let config_fs_name = render_strips :: fragment :: CONFIG ;
560
551
let config_fs_block_index = gl. get_uniform_block_index ( program, config_fs_name) ;
561
552
562
553
debug_assert_ne ! (
@@ -575,14 +566,8 @@ fn get_strip_uniforms(
575
566
gl. uniform_block_binding ( program, config_fs_block_index, 0 ) ;
576
567
577
568
// Get texture uniform locations.
578
- let alphas_texture_name = fragment_reflection
579
- . texture_mapping
580
- . get ( "alphas_texture" )
581
- . unwrap ( ) ;
582
- let clip_input_texture_name = fragment_reflection
583
- . texture_mapping
584
- . get ( "clip_input_texture" )
585
- . unwrap ( ) ;
569
+ let alphas_texture_name = render_strips:: fragment:: ALPHAS_TEXTURE ;
570
+ let clip_input_texture_name = render_strips:: fragment:: CLIP_INPUT_TEXTURE ;
586
571
587
572
StripUniforms {
588
573
config_vs_block_index,
@@ -596,13 +581,9 @@ fn get_strip_uniforms(
596
581
}
597
582
}
598
583
599
- /// Get the uniform locations for the clear program.
600
- fn get_clear_uniforms (
601
- gl : & WebGl2RenderingContext ,
602
- program : & WebGlProgram ,
603
- vertex_reflection : & ReflectionMap < & ' static str > ,
604
- ) -> ClearUniforms {
605
- let config_name = vertex_reflection. uniforms . get ( "config" ) . unwrap ( ) ;
584
+ /// Get the uniform locations for the `clear_slots` program.
585
+ fn get_clear_uniforms ( gl : & WebGl2RenderingContext , program : & WebGlProgram ) -> ClearUniforms {
586
+ let config_name = clear_slots:: vertex:: CONFIG ;
606
587
let config_block_index = gl. get_uniform_block_index ( program, config_name) ;
607
588
608
589
debug_assert_ne ! (
0 commit comments