!fjjkgHFcwtkREywzfk:matrix.org

Naga Shader Translator

243 Members
v0.20.0!9 Servers

Load older messages


SenderMessageTime
30 Mar 2024
@jimb:mozilla.orgjimb But if Arena were published as a "general purpose" crate, I can imagine some energetic person showing up with a tagging scheme or something something branded lifetimes something something invariant subtyping 22:11:08
@jimb:mozilla.orgjimband that's just a distraction. There's no need for that in our context.22:11:24
@jimb:mozilla.orgjimbSo I think if we pull it out, there needs to be some messaging around what its scope is. It supports wgpu, period.22:11:57
@jimb:mozilla.orgjimb * So I think if we pull it out of Naga, there needs to be some messaging around what its scope is. It supports wgpu, period.22:12:07
@jimb:mozilla.orgjimbIt's so simple, if it doesn't suit your needs, write your own.22:12:25
@jimb:mozilla.orgjimb * "It's so simple, if it doesn't suit your needs, write your own." would be our message to outside users.22:12:39
@jimb:mozilla.orgjimb I guess the crate should be named wgpu_arena or something, so that we don't appear to be offering a competitive alternative to other arena-ish things on crates.io. 22:13:08
@jimb:mozilla.orgjimb The other wrinkle: Naga's Arenas store source location spans, too. 22:15:14
@jimb:mozilla.orgjimbNo, we don't really need the details tracked. We know that Naga's current analysis is conservative and non-standards-compliant, and we have it on our roadmap to be entirely replaced.22:30:06
@jimb:mozilla.orgjimb
In reply to @eddyb:matrix.org
also "unique" stuff is usually called "interner" tho I wouldn't be surprised if there's a few more names for that idea
I have no attachment to the name.
22:31:02
@crowlkats:matrix.orgcrowlkatshttps://github.com/gfx-rs/wgpu/pull/545923:04:52
31 Mar 2024
@lylythechosenone:matrix.orglylythechosenonegood point01:23:10
@imbris:matrix.orgimbris changed their profile picture.15:27:44
2 Apr 2024
@erichdongubler-mozilla:mozilla.orgErichDonGubler
In reply to @jimb:mozilla.org
But if Arena were published as a "general purpose" crate, I can imagine some energetic person showing up with a tagging scheme or something something branded lifetimes something something invariant subtyping
Hot take: use a newtype.
16:50:26
@jimb:mozilla.orgjimbIt doesn't work out quite the way you'd hope.16:51:03
@jimb:mozilla.orgjimb So you've got your function arenas, Function::expressions, and your global arena, Module::global_expressions. 16:51:38
@jimb:mozilla.orgjimb Both of them are indexed by Handle<Expression> 16:51:50
@jimb:mozilla.orgjimb You can say, okay, struct GlobalExpression(Expression); and then have Module::global_expressions be an Arena<GlobalExpression>. 16:52:42
@jimb:mozilla.orgjimb But the Expression variants inside that GlobalExpression still hold Handle<Expression> handles for their subexpressions. 16:53:19
@jimb:mozilla.orgjimb So as soon as you get any data out of the arena, it's not just that you've lost typing information - it's incorrectly typed, because Handle<Expression> is what you were using for Function::expressions. 16:54:00
@jimb:mozilla.orgjimb Okay, so, make Expression generic over a type H for subexpression handles. But now the type of Function::expressions is Arena<FunctionExpression>, where struct FunctionExpression(Expression<FunctionExpression>);. 16:55:52
@jimb:mozilla.orgjimband at this point you say, I have taken a wrong turn somewher16:56:24
@jimb:mozilla.orgjimb * and at this point you say, I have taken a wrong turn somewhere16:56:27
@jimb:mozilla.orgjimbor at least I do16:56:31
@jimb:mozilla.orgjimb * So as soon as you get any data out of the arena, you've lost typing information.16:57:28
@jimb:mozilla.orgjimb * So as soon as you get any data out of the arena, you've lost the newtype.16:57:40
@jimb:mozilla.orgjimb

Also:

use std::marker::PhantomData;

struct Handle<T>(usize, PhantomData<T>);

enum Expr<H> {
    Num(i32),
    Add(Handle<Expr<H>>, Handle<Expr<H>>),
}
17:00:21
@jimb:mozilla.orgjimb

I suppose I could fix this, but again, it feels like I made a wrong turn:

error[E0392]: parameter `H` is never used
 --> src/lib.rs:5:11
  |
5 | enum Expr<H> {
  |           ^ unused parameter
  |
  = help: consider removing `H`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `H` to be a const parameter, use `const H: usize` instead
17:00:53
@jimb:mozilla.orgjimbYou can feel your Haskell muscles warming up and it's a bad sign17:01:14
@erichdongubler-mozilla:mozilla.orgErichDonGubler* Hot take: use a newtype?17:51:25

Show newer messages


Back to Room ListRoom Version: 5