Commit 31a2f58
authored
[SPIR-V] Fix usage of indices in subfunctions (microsoft#7242)
The parameters tagged with indices are linked to a builtin. Because
their layout is different between HLSL and SPIR-V, there is a common
mechanism to handle those 'stage I/O variables'.
Usually, a local variable with the correct HLSL layout is created, and
when required, the value is copied in and copied out in the entrypoint
wrapper. Then, a function-scoped pointer is passed to sub-functions.
The issue is that `indices` marks an array which is also shared across
invocations. Meaning we cannot simple copy-in/copy-out. We are only
allowed to write to the indices touched by the shader.
This required pushing the handling to the assignment expression
handling: when a value is assigned to such builtin, the layout
transformation is done, and the builtin written to.
Issue was how to find back the Builtin from an assignment: the code
assumed the ParmDecl of the entrypoint was the only way to access this
variable, but nothing prevents the user to pass this indice array to
another function.
The simple solution is to move this out of the generic map, and have a
new field which stored the SpirvVariable we created, and allow any HLSL
function to access this as soon as the HLSLIndices attribute is found.
Fixes microsoft#7009
---------
Signed-off-by: Nathan Gauër <[email protected]>1 parent d8aad78 commit 31a2f58
4 files changed
Lines changed: 108 additions & 12 deletions
File tree
- tools/clang
- lib/SPIRV
- test/CodeGenSPIRV
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
863 | | - | |
| 863 | + | |
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
| |||
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
874 | | - | |
| 874 | + | |
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
562 | 567 | | |
563 | 568 | | |
564 | 569 | | |
| |||
1014 | 1019 | | |
1015 | 1020 | | |
1016 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1017 | 1041 | | |
1018 | 1042 | | |
1019 | 1043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8133 | 8133 | | |
8134 | 8134 | | |
8135 | 8135 | | |
8136 | | - | |
8137 | | - | |
8138 | | - | |
| 8136 | + | |
| 8137 | + | |
8139 | 8138 | | |
8140 | | - | |
8141 | | - | |
8142 | | - | |
8143 | | - | |
8144 | 8139 | | |
8145 | | - | |
8146 | | - | |
| 8140 | + | |
| 8141 | + | |
| 8142 | + | |
| 8143 | + | |
| 8144 | + | |
| 8145 | + | |
| 8146 | + | |
| 8147 | + | |
| 8148 | + | |
| 8149 | + | |
| 8150 | + | |
8147 | 8151 | | |
8148 | 8152 | | |
8149 | 8153 | | |
| |||
8190 | 8194 | | |
8191 | 8195 | | |
8192 | 8196 | | |
8193 | | - | |
| 8197 | + | |
| 8198 | + | |
| 8199 | + | |
| 8200 | + | |
8194 | 8201 | | |
8195 | 8202 | | |
8196 | 8203 | | |
| |||
Lines changed: 65 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
0 commit comments