summaryrefslogtreecommitdiffstats
path: root/source/core/slang-process-util.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-10-03 12:52:26 -0700
committerGitHub <noreply@github.com>2025-10-03 19:52:26 +0000
commit6a2cf239a89340ed2985d04609499e8c4a2d8f89 (patch)
treec80f3c8dc7e89762aeab0ee7830d1ad728665460 /source/core/slang-process-util.cpp
parentcc8f6a241edb47c43c5698ee33abed4fe57d4566 (diff)
Fix legalization crash when processing metal parameter blocks. (#8591)
Closes #7606. When Slang compile for a bindful target, we will run the resource type legalization pass to hoist resource typed struct fields outside of the struct type and define them as global parameters and passing them around via dedicated function parameters. When we compile for a bindless target, we don't run this pass. However, Metal is a hybrid bindful and bindless target. We need to run type legalization for the constant buffer, but skip type legalization for parameter block. The previous attempt to support this behavior is to hack the type legalization pass to return `LegalVal::simple` when it sees a `ParameterBlock<T>`. However, whenever the code is accessing `parameterBlock.someNestedField`, the type of the nested field may get a `LegalType::tuple`, and now we will run into inconsistent scenarios where we have a `LegalVal::simple` on the operand val, and but the legalization logic is expecting that val to be a `LegalType::tuple`. This breaks a lot of assumptions and invariants in the type legalization pass, resulting unstable/fragile behavior. To systematically solve this problem, this change generalizes the existing legalize buffer element type pass to translate `ParameterBlock<Texture2D>` (and similar cases) to `ParameterBlock<Texture2D.Handle>`. So that such parameter block will always be legalized to `LegalType:::simple` during type legalization, and we will never run into any inconsistent cases. This allowed us to get rid of the hacky logic in the type legalization pass to try to workaround the inconsistencies.
Diffstat (limited to 'source/core/slang-process-util.cpp')
0 files changed, 0 insertions, 0 deletions