[all-commits] [llvm/llvm-project] e6ee2c: [HLSL][RootSignature] Implement validation of reso...

Finn Plummer via All-commits all-commits at lists.llvm.org
Fri Jun 20 14:55:19 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e6ee2c7c7b36825331b39e221725780167457e6d
      https://github.com/llvm/llvm-project/commit/e6ee2c7c7b36825331b39e221725780167457e6d
  Author: Finn Plummer <finn.c.plum at gmail.com>
  Date:   2025-06-20 (Fri, 20 Jun 2025)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/SemaHLSL.h
    M clang/lib/Sema/SemaHLSL.cpp
    A clang/test/SemaHLSL/RootSignature-resource-ranges-err.hlsl
    A clang/test/SemaHLSL/RootSignature-resource-ranges.hlsl
    M llvm/include/llvm/Frontend/HLSL/HLSLRootSignatureUtils.h
    M llvm/lib/Frontend/HLSL/HLSLRootSignatureUtils.cpp

  Log Message:
  -----------
  [HLSL][RootSignature] Implement validation of resource ranges for `RootDescriptors` (#140962)

As was established
[previously](https://github.com/llvm/llvm-project/pull/140957), we
created a structure to model a resource range and to detect an overlap
in a given set of these.

However, a resource range only overlaps with another resource range if
they have:
- equivalent ResourceClass (SRV, UAV, CBuffer, Sampler)
- equivalent resource name-space
- overlapping shader visibility

For instance, the following don't overlap even though they have the same
register range:
- `CBV(b0)` and `SRV(t0)` (different resource class)
- `CBV(b0, space = 0)` and `CBV(b0, space = 1)` (different space)
- `CBV(b0, visibility = Pixel)` and `CBV(b0, visibility = Domain)`
(non-overlapping visibility)

The first two clauses are naturally modelled by grouping all the
`RangeInfo`s that have the equivalent `ResourceClass` and `Space` values
together and check if there is any overlap on a `ResourceRange` for all
these `RangeInfo`s. However, `Visibility` is not quite as easily mapped
(`Visibility = All` would overlap with any other visibility). So we will
instead need to track a `ResourceRange` for each of the `Visibility`
types in a group. Then we can determine when inserting a range of the
same group if it would overlap with any overlapping visibilities.

The collection of `RangeInfo` for `RootDescriptor`s, sorting of the
`RangeInfo`s into the groups and finally the insertion of each point
into their respective `ResourceRange`s are implemented. Furthermore, we
integrate this into `SemaHLSL` to provide a diagnostic for each entry
function that uses the invalid root signature.

- Implements collection of `RangeInfo` for `RootDescriptors`
- Implements resource range validation in `SemaHLSL`
- Add diagnostic testing of error production in
`RootSignature-resource-ranges-err.hlsl`
- Add testing to ensure no errors are raised in valid root signatures
`RootSignature-resource-ranges.hlsl`

Part 2 of https://github.com/llvm/llvm-project/issues/129942

A final pr will be produced to integrate the analysis of
`DescriptorTable`, `StaticSampler` and `RootConstants` by defining how
to construct the `RangeInfo` from their elements respectively.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list