Skip to content

Commit 70da2d1

Browse files
committed
pr-feedback
1 parent 9538520 commit 70da2d1

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

proposals/NNNN-SPIRV-variable-address-space.md

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,13 @@ In SPIR-V, function declarations contains the return and parameters types,
103103
including the storage classes.
104104
This means, depending on the call-site, and the value of `select`, the
105105
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.
111108

112-
This becomes impossible if `foo` is exported, or marked as `noinline`.
109+
## Proposed solution: using 2 HLSL address spaces
113110

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`
127113
address space.
128114

129115
## Implementing the solution
@@ -143,7 +129,6 @@ the `default` address space, allowing overload resolution for class methods:
143129
Clang will emit an `addrspacecast` we will have to handle, but that's a known
144130
issue in address-space overload resolution, and not new to this proposal.
145131

146-
147132
## Alternative design considered
148133

149134
### Force optimizations, and force inlining
@@ -161,12 +146,14 @@ generate valid SPIR-V.
161146
Since HLSL generates functions with the `always inline` attribute, this could
162147
have been a valid option. But it has a few flaws:
163148

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.
166155
- It makes reading the generated assembly harder.
167156

168-
The 3rd problem is a nice-to-have, but the first 2 are a complete stop.
169-
170157
### Move all variables to the function scope
171158

172159
HLSL static globals have a known initialization value at compile-time.

0 commit comments

Comments
 (0)