<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/155299>155299</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [ObjectYAML][RootSignature] Fix handling of `StaticSamplersOffset` and `RootParameterOffset`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          inbelic
      </td>
    </tr>
</table>

<pre>
    There are a couple inconsistencies in behaviour of how we handle `StaticSamplersOffset` with respect to DXC and `RootParameterOffset`.

The static sampler offset of the output object is generated in two ways: 

1. through codegen in [`DXILRootSignature`](https://github.com/llvm/llvm-project/blob/6a5cb5afdc835074bcb25fe7506566ae850459a0/llvm/lib/Target/DirectX/DXILRootSignature.cpp#L137): the behaviour is to compute the offset if there are `StaticSampler`s. Otherwise, set it to `0`.
2. with `yaml2obj`: the behaviour is to ignore the given `StaticSamplersOffset` and compute the offset if there are any samplers. Otherwise, set it to the specified value from yaml.

If we consider 1, this is inconsistent with DXC behaviour, which computes and outputs the offset to the first static sampler in the `RTS0` regardless of if there are any.

1 is easily fixed with [this](https://gist.github.com/inbelic/94156ed030f0b1389b3a96170b77ea3e) (and updating many test cases).

I am not sure of any practical situation that 2 is beneficial (perhaps to create an invalid object for testing), since there is only one correct value for it to be. This is similar to `RootParameterOffset` which allows us to specify any offset even though it has [exactly one valid value](https://github.com/llvm/llvm-project/blob/6a5cb5afdc835074bcb25fe7506566ae850459a0/llvm/lib/Target/DirectX/DXILRootSignature.cpp#L132-L135).

This issue would propose to remove those two parameters from the yaml representation and let them always be computed.

Otherwise, we can just apply the fix for 1 and update all the broken round-trip and unit `obj2yaml/yaml2obj` tests to specify the correct offsets.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUlkFv2zgQhX8NfRnUoGhTsg4-pA0MFMiiiyaH7nEkjSRm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