Skip to content

Add test coverage for ConstantBuffer/ParameterBlock with interface-typed elements #10395

@jvepsalainen-nv

Description

@jvepsalainen-nv

Problem Description

ConstantBuffer<> and ParameterBlock<> with interface-typed elements lack test coverage for dynamic dispatch. This is the pattern used in material/light systems where polymorphic objects are passed as uniform data.

The only existing enabled test is array-existential-parameter.slang, which uses the old globalExistentialType API and only targets cpu/cuda without exercising dynamic dispatch.

Test Plan

The tests verify that the compiler correctly lays out existential tuples (RTTI + witness table ID + AnyValue) within constant buffer and parameter block memory, generates correct pack/unpack code, and produces working switch-based dynamic dispatch for method calls on interface-typed fields. Both the struct-wrapper pattern (working) and the direct interface element pattern (currently crashing) are covered.

Runtime compute tests use globalExistentialType __Dynamic to prevent compile-time specialization, ensuring the dynamic dispatch code path is exercised rather than being optimized away.

  • parameterblock-interface.slang: DISABLED, ParameterBlock<IFoo> direct crashes (Crash when using interface-typed global parameters with -conformance flags #10314)
  • constantbuffer-struct-interface-field.slang: runtime dispatch through ConstantBuffer<Params> where Params has an IFoo field, two concrete types
  • constantbuffer-struct-interface-array.slang: runtime dispatch through ConstantBuffer<Params> where Params has an IFoo[2] array with mixed types
  • parameterblock-struct-interface-field.slang: runtime dispatch through ParameterBlock with single IFoo field and IFoo[2] array
  • constantbuffer-interface-compilation.slang: compilation check across all 6 targets (spirv, hlsl, cuda, cpp, metal, wgsl)
  • constantbuffer-interface-dispatch-report.slang: verifies -report-dynamic-dispatch-sites for CB and PB with interface fields

Note: ConstantBuffer<IFoo> direct test was not added as the existing global-interface-param.slang already covers that pattern with broader target coverage.

Related Issues

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions