6 comments

  • genxy2 hours ago
    &gt; facet is a library for Rust which provides run-time reflection. By annotating your struct with #[derive(facet::Facet)], you get a SHAPE associated type which can be inspected at runtime.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;facet-rs&#x2F;facet" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;facet-rs&#x2F;facet</a><p>&gt; The core crates give types a SHAPE associated constant with their kind, layout, fields, documentation, attributes, and type-specific operations. facet-reflect builds, reads, and mutates values through those shapes while preserving their invariants.<p>&gt; Serialization and integration crates build on that reflection layer: JSON, TOML, YAML, MessagePack, Postcard, ASN.1, XDR, CSV, XML, URL-encoded forms, SQLite, Axum, schema generation, structural diffing, and more.<p>Side by side comparison with SERDE <a href="https:&#x2F;&#x2F;facet.rs&#x2F;guide&#x2F;serde&#x2F;" rel="nofollow">https:&#x2F;&#x2F;facet.rs&#x2F;guide&#x2F;serde&#x2F;</a>
  • scoopr1 hour ago
    Nice, always good to have some extra checking.<p>While most of the time you want the memcpy semantics, but I wonder if naga could be used to compute a facet SHAPE from the shader. Maybe it could be used to &quot;serialise&quot; the cpu format to gpu format, without them needing to be padding&#x2F;repr-compatible (or even field-reorder-compatible!).<p>Another option of course would be to parse the struct with naga and just always generate the rust counterpart, then it should always be compatible and up-to-date, but then you have codegen in your build step.
  • flohofwoe4 hours ago
    FWIW, there&#x27;s a WebGPU extension which &#x27;harmonizes&#x27; uniform buffer struct layout with other address spaces, but currently it&#x27;s only implemented in Chromium-based browsers:<p>Ticket: <a href="https:&#x2F;&#x2F;github.com&#x2F;gpuweb&#x2F;gpuweb&#x2F;issues&#x2F;4973" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gpuweb&#x2F;gpuweb&#x2F;issues&#x2F;4973</a><p>Caniuse: <a href="https:&#x2F;&#x2F;caniuse.com&#x2F;?search=uniform_buffer_standard_layout" rel="nofollow">https:&#x2F;&#x2F;caniuse.com&#x2F;?search=uniform_buffer_standard_layout</a><p>The std140-style layout restrictions are basically a leftover when GPUs used vec4 &quot;register tables&quot; for uniform data.
    • mkeeter2 hours ago
      Nice, I&#x27;ll keep an eye on that!<p>Right now, I&#x27;m targeting everything (native &#x2F; Firefox &#x2F; Chrome &#x2F; Safari), so minimizing use of extensions; this also means I get to run head-long into fun cross-platform behavior differences [1][2][3]<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;gfx-rs&#x2F;wgpu&#x2F;issues&#x2F;8785" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gfx-rs&#x2F;wgpu&#x2F;issues&#x2F;8785</a><p>[2] <a href="https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1870699" rel="nofollow">https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=1870699</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;mkeeter&#x2F;halfspace&#x2F;issues&#x2F;1#issuecomment-3593059692" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mkeeter&#x2F;halfspace&#x2F;issues&#x2F;1#issuecomment-3...</a>
  • brinepot4 hours ago
    Spent too much time debugging alignment issues with Vulkan buffers. WebGPU having good tools like Facet from the start is a huge win.
  • jauntywundrkind4 hours ago
    This is so good. And it&#x27;s so absurd how programming languages so frequently treat types as a compile time check. Still. After so so long.<p>It&#x27;s great having tools like Facet around to add runtime type information in. I wish TypeScript was seeing progress but there&#x27;s seemingly no progress or traction in 5 years+, just some early experiments which died out.
  • 77rushi774 hours ago
    [dead]