@@ -55,6 +55,7 @@ fn WgslIrNagaCompatPlanner::derived_module_view(
5555 builder.import_event(event)
5656 }
5757 builder.append_remaining()
58+ builder.import_entry_points()
5859 builder.view
5960}
6061
@@ -79,14 +80,28 @@ fn WgslIrNagaDerivedModuleBuilder::import_event(
7980 }
8081 FullModule | AliasModule => {
8182 self.import_event_symbols_by_kind(symbols, None , Type )
82- self.import_event_symbols_by_kind (symbols, None , Constant )
83+ self.import_full_module_constant_event_symbols (symbols)
8384 self.import_event_symbols_by_kind(symbols, None , Override )
8485 self.import_event_symbols_by_kind(symbols, None , GlobalVariable )
8586 self.import_event_symbols_by_kind(symbols, None , Function )
8687 }
8788 }
8889}
8990
91+ ///|
92+ fn WgslIrNagaDerivedModuleBuilder ::import_full_module_constant_event_symbols(
93+ self : WgslIrNagaDerivedModuleBuilder ,
94+ symbols : Array [WgslIrImportArenaSymbol ],
95+ ) -> Unit {
96+ for symbol in symbols {
97+ if symbol.kind() == Constant {
98+ self.import_named_non_generated_constant_if_present(
99+ symbol.generated_symbol_name(),
100+ )
101+ }
102+ }
103+ }
104+
90105///|
91106fn WgslIrNagaDerivedModuleBuilder ::import_event_symbols_by_kind(
92107 self : WgslIrNagaDerivedModuleBuilder ,
@@ -163,6 +178,9 @@ fn WgslIrNagaDerivedModuleBuilder::append_remaining(
163178 self.import_type(index)
164179 }
165180 for index in 0..<self.planner.shader_module.constants.items.length() {
181+ if self.planner.shader_module.constants.items[index].generated_import {
182+ continue
183+ }
166184 self.import_constant(index)
167185 }
168186 for index in 0..<self.planner.shader_module.overrides.items.length() {
@@ -214,6 +232,26 @@ fn WgslIrNagaDerivedModuleBuilder::import_named_constant_if_present(
214232 }
215233}
216234
235+ ///|
236+ fn WgslIrNagaDerivedModuleBuilder ::import_named_non_generated_constant_if_present(
237+ self : WgslIrNagaDerivedModuleBuilder ,
238+ name : String ,
239+ ) -> Unit {
240+ for index in 0..<self.planner.shader_module.constants.items.length() {
241+ if self.seen_constants.contains(index) {
242+ continue
243+ }
244+ match self.planner.shader_module.constants.items[index] {
245+ { name: Some (constant_name), generated_import: false , .. } if constant_name ==
246+ name => {
247+ self.import_constant(index)
248+ return
249+ }
250+ _ => ()
251+ }
252+ }
253+ }
254+
217255///|
218256fn WgslIrNagaDerivedModuleBuilder ::import_named_override_if_present(
219257 self : WgslIrNagaDerivedModuleBuilder ,
@@ -351,6 +389,7 @@ fn WgslIrNagaDerivedModuleBuilder::import_constant(
351389 self.import_type_handle(constant.ty)
352390 self.seen_constants.add(index)
353391 self.view.constants.push(index)
392+ self.import_global_expression(constant.init)
354393 }
355394 None => ()
356395 }
@@ -490,6 +529,76 @@ fn WgslIrNagaDerivedModuleBuilder::import_function_inner(
490529 visiting.pop() |> ignore
491530}
492531
532+ ///|
533+ fn WgslIrNagaDerivedModuleBuilder ::import_entry_points(
534+ self : WgslIrNagaDerivedModuleBuilder ,
535+ ) -> Unit {
536+ for index in 0..<self.planner.shader_module.entry_points.length() {
537+ match self.planner.filter {
538+ Some (filter) => if !filter.contains_entry_point(index) { continue }
539+ None => ()
540+ }
541+ self.import_entry_point(self.planner.shader_module.entry_points[index])
542+ }
543+ }
544+
545+ ///|
546+ fn WgslIrNagaDerivedModuleBuilder ::import_entry_point(
547+ self : WgslIrNagaDerivedModuleBuilder ,
548+ entry_point : EntryPoint ,
549+ ) -> Unit {
550+ let visiting : Array [Int ] = []
551+ for argument in entry_point.function.arguments {
552+ self.import_type_handle(argument.ty)
553+ }
554+ match entry_point.function.result {
555+ Some (result) => self.import_type_handle(result.ty)
556+ None => ()
557+ }
558+ for local_var in entry_point.function.local_variables.items {
559+ self.import_type_handle(local_var.ty)
560+ }
561+ match entry_point.workgroup_size_overrides {
562+ Some (overrides) =>
563+ for item in overrides {
564+ match item {
565+ Some (expr) => self.import_global_expression(expr)
566+ None => ()
567+ }
568+ }
569+ None => ()
570+ }
571+ match entry_point.mesh_info {
572+ Some (mesh_info) => {
573+ match mesh_info.max_vertices_override {
574+ Some (expr) => self.import_global_expression(expr)
575+ None => ()
576+ }
577+ match mesh_info.max_primitives_override {
578+ Some (expr) => self.import_global_expression(expr)
579+ None => ()
580+ }
581+ self.import_type_handle(mesh_info.vertex_output_type)
582+ self.import_type_handle(mesh_info.primitive_output_type)
583+ self.import_global(mesh_info.output_variable.index())
584+ }
585+ None => ()
586+ }
587+ match entry_point.task_payload {
588+ Some (handle) => self.import_global(handle.index())
589+ None => ()
590+ }
591+ match entry_point.incoming_ray_payload {
592+ Some (handle) => self.import_global(handle.index())
593+ None => ()
594+ }
595+ self.import_function_block(
596+ entry_point.function,
597+ entry_point.function.body,
598+ visiting,
599+ )
600+ }
601+
493602///|
494603fn WgslIrNagaDerivedModuleBuilder ::import_global_expression(
495604 self : WgslIrNagaDerivedModuleBuilder ,
0 commit comments