summaryrefslogtreecommitdiff
path: root/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
AgeCommit message (Collapse)Author
2025-10-08[DirectX] Making sure we always parse, validate and verify Flags (#162171)joaosaffran
This PR makes a few changes to make sure that Root Signature Flags are always parsed validated and verified, this includes if you use a version that doesn't support flags. The logic already existed, this PR just makes sure it is always executed. Closes: [#161579](https://github.com/llvm/llvm-project/issues/161579) --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-10-06[DirectX] Fix Flags validation to prevent casting into enum (#161587)joaosaffran
This PR changes the validation logic for Root Descriptor and Descriptor Range flags to properly check if the `uint32_t` values are within range before casting into the enums.
2025-10-01[HLSL] Update Frontend to support version 1.2 of root signature (#160616)joaosaffran
This patch updates the frontend to support version 1.2 of root signatures, it adds parsing, metadata generation and a few tests. --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-09-26[DirectX] Updating DXContainer Yaml to represent Root Signature 1.2 (#159659)joaosaffran
This PR updates the YAML representation of DXContainer to support Root Signature 1.2, this also requires updating the write logic to support testing.
2025-09-26[DirectX] Adding missing descriptor table validations (#153276)joaosaffran
This patch adds 2 small validation to DirectX backend. First, it checks if registers in descriptor tables are not overflowing, meaning they don't try to bind registers over the maximum allowed value, this is checked both on the offset and on the number of descriptors inside the range; second, it checks if samplers are being mixed with other resource types. Closes: #153057, #153058 --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com> Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com> Co-authored-by: Joao Saffran <jderezende@microsoft.com>
2025-09-22[SemaHLSL] Correct descriptor range overflow validation (#159475)Finn Plummer
This pr corrects the validation behaviour to allow valid root signatures of the form: `DescriptorTable(CBV(b0, offset = 4294967294), CBV(b1))` which will append a range onto the location of `UINT_MAX`, which is valid. Resolves: https://github.com/llvm/llvm-project/issues/159478.
2025-09-11[DirectX] Removing dxbc StaticSampler from mcbxdc (#154631)joaosaffran
MC Static Samplers Representation currently depends on Object structures. This PR removes that dependency and in order to facilitate removing to_underlying usage in follow-up PRs.
2025-09-10[DirectX] Removing dxbc DescriptorRange from mcbxdc (#154629)joaosaffran
MC Descriptor Range Representation currently depend on Object structures. This PR removes that dependency and in order to facilitate removing to_underlying usage in follow-up PRs.
2025-09-09[Sema][Parse][HLSL] Implement front-end rootsignature validations (#156754)Finn Plummer
This pr implements the following validations: 1. Check that descriptor tables don't mix Sample and non-Sampler resources 2. Ensure that descriptor ranges don't append onto an unbounded range 3. Ensure that descriptor ranges don't overflow 4. Adds a missing validation to ensure that only a single `RootFlags` parameter is provided Resolves: https://github.com/llvm/llvm-project/issues/153868.
2025-08-08[HLSL][NFC] Fix range check in verifyRegisterSpace (#152615)Shafik Yaghmour
Static analysis flagged the second part of this range check as always true. RegisterSpace is uint32_t therefore the max value is 0xFFFFFFFF and so the first check is sufficient.
2025-08-05[HLSL][Sema] Use hlsl::BindingInfoBuilder instead of RangeInfo. NFC (#150634)Justin Bogner
Clean up some duplicated logic. We had two ways to do the same thing here, and BindingInfoBuilder is more flexible.
2025-07-11[HLSL][RootSignature] Retain `SourceLocation` of `RootElement` for ↵Finn Plummer
`SemaHLSL` diagnostics (#147115) At the moment, when we report diagnostics from `SemaHLSL` we only provide the source location of the root signature attr. This allows for significantly less helpful diagnostics (for eg. reporting resource range overlaps). This pr implements a way to retain the source location of a root element when it is parsed, so that we can output the `SourceLocation` of each root element that causes the overlap in the diagnostics during semantic analysis. This pr defines a wrapper struct `clang::hlsl::RootSignatureElement` in `SemaHLSL` that will contain the underlying `RootElement` and can hold any additional diagnostic information. This struct will be what is used in `HLSLRootSignatureParser` and in `SemaHLSL`. Then the diagnostic information will be stripped and the underlying element will be stored in the `RootSignatureDecl`. For the reporting of diagnostics, we can now use the retained `SourceLocation` of each `RootElement` when reporting the range overlap, and we can add a `note` diagnostic to highlight the other root element as well. - Defines `RootSignatureElement` in the `hlsl` namespace in `SemaHLSL` (defined in `SemaHLSL` because `Parse` has a dependency on `Sema`) - Updates parsing logic to construct `RootSignatureElement`s and retain the source loction in `ParseHLSLRootSignature` - Updates `SemaHLSL` when it constructs the `RootSignatureDecl` to take the new `RootSignatureElement` and store the underlying `RootElement` - Updates the current tests to ensure the new `note` diagnostic is produced and that the `SourceLocation` is seen - Slight update to the `RootSignatureValidations` api to ensure the caller sorts and owns the memory of the passed in `RangeInfo` - Adds a test to demonstrate the `SourceLocation` of both elements being correctly pointed out Resolves: https://github.com/llvm/llvm-project/issues/145819
2025-07-09[DirectX] Add missing verifications during `validate` of `DXILRootSignature` ↵Finn Plummer
(#147111) This pr resolves some discrepancies in verification during `validate` in `DXILRootSignature.cpp`. Note: we don't add a backend test for version 1.0 flag values because it treats the struct as though there is no flags value. However, this will be used when we use the verifications in the frontend. - Updates `verifyDescriptorFlag` to check for valid flags based on version, as reflected [here](https://github.com/llvm/wg-hlsl/pull/297) - Add test to demonstrate updated flag verifications - Adds `verifyNumDescriptors` to the validation of `DescriptorRange`s - Add a test to demonstrate `numDescriptors` verification - Updates a number of tests that mistakenly had an invalid `numDescriptors` specified Resolves: https://github.com/llvm/llvm-project/issues/147107
2025-07-08[NFC][HLSL] Move resource range logic from `SemaHLSL` to ↵Finn Plummer
`RootSignatureValidations` (#147117) This pr abstracts out the logic of detecting resource range overlap from `SemaHLSL` into the `RootSignatureValidations` library. For more context see linked issue. - Moves the validation logic from `SemaHLSL` to `RootSignatureValidations` - Updates `SemaHLSL` to use the new interface for the validations Resolves: https://github.com/llvm/llvm-project/issues/146393
2025-07-07[NFC][HLSL][DirectX] Move `DXILRootSignature` validations to ↵Finn Plummer
`RootSignatureValidations` library (#147110) Simple code movement of the verification logic in `validate` of the `DXILRootSignature` pass. Moving this code to the `RootSignatureValidations` library allows for the common verifications to be used in the frontend. - Moves all the `static` verification functions used in `DXILRootSignature` to the `RootSignatureValidations` library - Updates `DXILRootSignature` to use the moved functions Resolves: https://github.com/llvm/llvm-project/issues/145940
2025-07-04[NFC][HLSL][RootSignature] Split up `HLSLRootSignatureUtils` (#146124)Finn Plummer
This pr breaks-up `HLSLRootSignatureUtils` into separate orthogonal and meaningful libraries. This prevents it ending up as a dumping grounds of many different parts. - Creates a library `RootSignatureMetadata` to contain helper functions for interacting the root signatures in their metadata representation - Create a library `RootSignatureValidations` to contain helper functions that will validate various values of root signatures - Move the serialization of root signature elements to `HLSLRootSignature` Resolves: https://github.com/llvm/llvm-project/issues/145946