Skip to content

Commit d63bf3a

Browse files
committed
devlog
1 parent 5c37fab commit d63bf3a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

DEVLOG.md

+49
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,54 @@
11
# devlog
22

3+
## Tue June 4, 2024
4+
5+
I'm working on "upgrading" pointer types in `naga`'s SPIR-V frontend. This really is the meat of the
6+
problem, I would say. I'm attempting to follow this process, roughly:
7+
8+
- in the frontend:
9+
* lookup the pointer's expression
10+
* lookup the type of that expression
11+
* get the id of the base type of that type (because the type is essentially `Pointer<T>`
12+
and we want the `T`)
13+
* lookup up the base type
14+
- then in the `Module`:
15+
* get that same base type in the types arena
16+
* replace that type with an atomic type
17+
18+
This works fine, so long as no other types are using that base type. Odds are that the base type is
19+
`u32` or `i32`, though, and that it _is_ indeed being used elsewhere, which fails to type check.
20+
This is expected because we're changing the type for everything that references it.
21+
22+
So, instead we can try it this way - it's all the same up to interacting with the module:
23+
24+
- then in the `Module`:
25+
* create a new atomic type with the base type of the type we were going to replace
26+
* get the pointer type from the types arena
27+
* replace the pointer's base type with the atomic type
28+
29+
This gives us a different error:
30+
31+
```
32+
WithSpan { inner: InvalidHandle(ForwardDependency(FwdDepError { subject: [3], subject_kind: "naga::Type", depends_on: [6], depends_on_kind: "naga::Type" })), spans: [] }
33+
```
34+
35+
which essentially means that type `[3]` depends on type `[6]` but obviously `3` < `6`, and this is a
36+
problem because the handles of the types imply when they were declared. So it's saying that `[3]`
37+
_cannot_ depend on `[6]` because when declaring `[3]` all symbols used in that declaration must also
38+
have been previously declared, and `[6]` is greater than `[3]` and therefore was not pre-declared.
39+
40+
So here we are. I've had a couple ideas, and none of them are great:
41+
42+
1. Modify all handles in the module and the frontend, incrementing all handles >= the pointer's handle,
43+
then inserting the atomic type using the pointers handle.
44+
This is error prone because I'm not sure where all the handles are, where they get copied, etc.
45+
But maybe I'm overestimating this solution.
46+
2. Change `Handle`'s type to include some extra bit of information to allow the comparison to check.
47+
This is bad for obvious reasons - `Handle` is small on purpose and something like this would probably
48+
blow out the performance characteristics. Also there are probably *many* handles being created and
49+
there may be memory concerns.
50+
3. Do something else like provision some handles up front to use later. Possibly any time a pointer is
51+
created, also create another placeholder handle.
352
## Mon June 3, 2024
453

554
### NLNet progress

0 commit comments

Comments
 (0)