@@ -103,27 +103,13 @@ In SPIR-V, function declarations contains the return and parameters types,
103
103
including the storage classes.
104
104
This means, depending on the call-site, and the value of ` select ` , the
105
105
return value and parameter would required either the ` Function ` or the
106
- ` Private ` storage class.
107
- As-is, this cannot be emitted in SPIR-V.
108
- One solution we might say have is force-inline everything, and propagate
109
- references down to the final load, removing temporaries, and thus removing
110
- incompatibilities.
106
+ ` Private ` storage class. When this selection depends on a runtime condition,
107
+ this cannot be lowered to SPIR-V as-is.
111
108
112
- This becomes impossible if ` foo ` is exported, or marked as ` noinline ` .
109
+ ## Proposed solution: using 2 HLSL address spaces
113
110
114
- Making address spaces explicit in HLSL, thus marking references with the
115
- appropriate address space solves those issues: the constraint is now surfacing
116
- in the language.
117
-
118
- This however opens another set of issues: overload resolution rules on the
119
- ` this ` pointer, and template deduction. But this is not a new issue:
120
- adding address spaces for resources already did started this debate. Hence I
121
- will consider those out-of-scope for this proposal.
122
-
123
- ## Proposed solution: using 2 HLSL address spaced
124
-
125
- Thread-local, global variables should be put in the ` hlsl_private ` address
126
- space. Thread-local function-local variables should be put in the ` default `
111
+ Thread-local, global variables will be put in the ` hlsl_private ` address
112
+ space. Thread-local function-local variables will be put in the ` default `
127
113
address space.
128
114
129
115
## Implementing the solution
@@ -143,7 +129,6 @@ the `default` address space, allowing overload resolution for class methods:
143
129
Clang will emit an ` addrspacecast ` we will have to handle, but that's a known
144
130
issue in address-space overload resolution, and not new to this proposal.
145
131
146
-
147
132
## Alternative design considered
148
133
149
134
### Force optimizations, and force inlining
@@ -161,12 +146,14 @@ generate valid SPIR-V.
161
146
Since HLSL generates functions with the ` always inline ` attribute, this could
162
147
have been a valid option. But it has a few flaws:
163
148
164
- - HLSL allows using ` noinline ` .
165
- - HLSL allows exporting functions to compile to a library.
149
+ - HLSL allows using ` noinline ` : we would have to ignore it.
150
+ - HLSL allows exporting functions to compile to a library: if we need to
151
+ inline to generate functions, we cannot emit libraries exposign such
152
+ functions.
153
+ - Runtime conditions causing address-space conflict would require code
154
+ duplication.
166
155
- It makes reading the generated assembly harder.
167
156
168
- The 3rd problem is a nice-to-have, but the first 2 are a complete stop.
169
-
170
157
### Move all variables to the function scope
171
158
172
159
HLSL static globals have a known initialization value at compile-time.
0 commit comments