-
Notifications
You must be signed in to change notification settings - Fork 429
Description
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 throughConstantBuffer<Params>where Params has an IFoo field, two concrete typesconstantbuffer-struct-interface-array.slang: runtime dispatch throughConstantBuffer<Params>where Params has anIFoo[2]array with mixed typesparameterblock-struct-interface-field.slang: runtime dispatch through ParameterBlock with single IFoo field andIFoo[2]arrayconstantbuffer-interface-compilation.slang: compilation check across all 6 targets (spirv, hlsl, cuda, cpp, metal, wgsl)constantbuffer-interface-dispatch-report.slang: verifies-report-dynamic-dispatch-sitesfor 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
- Crash when using interface-typed global parameters with -conformance flags #10314:
ConstantBuffer<IFoo>/ParameterBlock<IFoo>crash (blocks enabling the first two tests) - [CPU] Wrong codegen when passing struct with interface-typed field by value to a function #10394: Struct with interface field passed by value generates wrong codegen on CPU