Visitar URL original
List of issues to discuss with TC39, WASM, JS engine teams · Issue #747 · gpuweb/gpuweb · GitHub
Skip to content

List of issues to discuss with TC39, WASM, JS engine teams #747

Description

@kainino0x
  • mmap'ing ArrayBuffers into WASM heap. Moved to WebGPU mapping × WebAssembly "mmap" #6309
  • read-only ArrayBuffers and write-only(?) ArrayBuffers (that work with mmap), for buffer mapping
  • ArrayBuffers (non-Shared, same thread) that point at non-disjoint ranges of the same backing data
  • ArrayBuffers whose base addresses aren't maximally-aligned (e.g. Float64Array not valid at offset 0, valid at offset 4)
    • No one has asked for this yet, probably not very important
  • "bitflags" equivalent functionality (e.g. Java-style EnumSet 🥺)
  • Ability to make ArrayBuffers non-transferrable. It turns out this already exists as [[ArrayBufferDetachKey]]
  • SharedObjectTable a bit like SharedArrayBuffer but instead of containing bytes, they contain references to shallow-cloneable objects ([Serializable] IDL interface objects). This should allow for example for GPUTextures created on one worker to be instantly visible to other workers.

Please add more issues on this thread.

Activity

  1. kainino0x commented on May 4, 2020

    @kainino0x
    ContributorAuthor
    • Non-transferable ArrayBuffers (mapped ArrayBuffers shouldn't be transferable to other threads). (We can do this without JS changes by faking transfers, by making them actually copies instead.)
  2. Kangz commented on May 5, 2020

    @Kangz
    Contributor
    • SharedObjectTable a bit like SharedArrayBuffer but instead of containing bytes, they contain references to shallow-cloneable objects ([Serializable] IDL interface objects). This should allow for example for GPUTextures created on one worker to be instantly visible to other workers.
  3. kainino0x commented on May 5, 2020

    @kainino0x
    ContributorAuthor
    • Or (somewhat less ideal) synchronous receiveMessage() on MessagePort.

    #476

  4. sandersdan commented on May 7, 2020

    @sandersdan

    WebCodecs is also interested in read-only ArrayBuffers, for providing access to YUV planes in CPU memory that remain owned by decoders. Is there any previous work on this request?

  5. kainino0x commented on May 7, 2020

    @kainino0x
    ContributorAuthor

    A discussion on the internal-gpu mailing list can be found here:
    https://lists.w3.org/Archives/Member/internal-gpu/2020May/0001.html
    in which Ken discusses Java's past experience with read-only ArrayBuffers.
    I just forwarded it to you, @sandersdan.

    Other discussions I just found:

  6. kainino0x commented on Jun 11, 2020

    @kainino0x
    ContributorAuthor
    • Re-pointing an existing ArrayBuffer wrapper to a new backing store (to avoid garbage) (EDIT: ResizableArrayBuffer proposal would allow us to achieve this)
  7. kainino0x commented on Jun 30, 2020

    @kainino0x
    ContributorAuthor
    • Detachable SharedArrayBuffer, for mapping a buffer and then accessing the mapping from multiple threads
  8. Kangz commented on Jul 24, 2020

    @Kangz
  9. kainino0x commented on Jul 24, 2020

    @kainino0x
    Author
  10. kainino0x commented on May 4, 2021

    @kainino0x
    ContributorAuthor
    • SharedObjectTable a bit like SharedArrayBuffer but instead of containing bytes, they contain references to shallow-cloneable objects ([Serializable] IDL interface objects). This should allow for example for GPUTextures created on one worker to be instantly visible to other workers.

    It turns out that this (or synchronous receive-message) would also be extremely useful to WebAssembly for sending modules around for dynamic linking.

  11. Kangz commented on Aug 27, 2021

    @Kangz
    Contributor

    Another important thing to discuss with TC39 is adding a concept of non-transferrable ArrayBuffer. Right now this group agreed to make the result of GPUBuffer.getMappedRange non-transferrable so we can detach them on GPUBuffer.unmap but the JS spec doesn't have any way to express this at the moment.

    Contrary to the other TC39 topics in this issue, this one is important to figure out before WebGPU v1 as it is an important part of the WebGPU semantics (and not a future improvement).

  12. Kangz commented on Aug 27, 2021

    @Kangz
    Contributor

    This might also require a change to the HTML spec for structuredSerializeWithTransfer (an internal postMessage algorithm)

  13. kainino0x commented on Aug 27, 2021

    @kainino0x
    ContributorAuthor

    As mentioned above:

    • Non-transferable ArrayBuffers (mapped ArrayBuffers shouldn't be transferable to other threads). (We can do this without JS changes by faking transfers, by making them actually copies instead.)

    We might be able to make this work entirely within our spec instead of having to go change the behavior of ArrayBuffer. In more detail:

    If you tried to transfer a getMappedRange-created ArrayBuffer, it would appear to work entirely normally - old ArrayBuffer would get detached - except the underlying data would get copied into a new, run-of-the-mill ArrayBuffer, which means that any writes to the new ArrayBuffer would not appear in the GPUBuffer upon unmap().

  14. kainino0x commented on Aug 27, 2021

    @kainino0x
    ContributorAuthor

    Filed new issue #2072.

  15. pythonesque commented on Aug 27, 2021

    @pythonesque

    AFAIK, what you're describing is the behavior for non-transferable objects, though? Minus the fake detach, that is. I guess the point is that this wouldn't be an observable behavior change compared to the usual behavior (except in the context of WebGPU memory mapping, which isn't specified by TC39)?

  16. 11 remaining items

  17. modified the milestones: , on Aug 15, 2023
  18. modified the milestones: , Milestone 1 on Jul 2, 2024
  19. MikhailGorobets commented on Aug 19, 2024

    @MikhailGorobets

    Any updates?

  20. kainino0x commented on Aug 27, 2024

    @kainino0x
    ContributorAuthor

    @MikhailGorobets Not at this time. This issue tracks a bunch of things, what in particular are you interested in?

  21. MikhailGorobets commented on Aug 28, 2024

    @MikhailGorobets

    @kainino0x
    We are using Emscripten to compile C++ into WASM. Currently, we are facing an issue when using WGPUDevice in a multi-threaded environment (https://emscripten.org/docs/porting/pthreads.html). For example, when creating a WGPUSampler in a thread different from the one where the WGPUDevice was created, we receive an invalid pointer. The problem is descripted here

    ### Unsolved: Synchronous Object Transfer ### {#multithreading-transfer}

  22. kainino0x commented on Aug 28, 2024

    @kainino0x
    ContributorAuthor

    Thanks, good to know. There was some progress in investigating this direction but we have not had resources to work on it in a while. It will also of course require WebGPU to have multithreading in the first place, which is #354.

    In the meantime, there's also been a little bit of investigation into Emscripten having a way to proxy all WebGPU calls to a single thread so that neither of those will be necessary. This won't perform as well, but unfortunately we haven't prototyped it yet. See emscripten-core/emscripten#19645

  23. erights commented on Dec 23, 2024

    @erights

    Please see https://github.com/tc39/proposal-immutable-arraybuffer which proposes Immutable ArrayBuffers, is at Stage 2 of the tc39 process, has enthusiastic support from some implementations, and not (yet?) any serious objections. How applicable would this be to the concerns expressed above?

  24. kainino0x commented on Jan 3, 2025

    @kainino0x
    ContributorAuthor

    @erights Thank you for letting us know about that! We are indeed interested, but right now the proposal is not compatible with WebGPU. I've filed tc39/proposal-immutable-arraybuffer#25 where we can discuss that in more depth.

  25. modified the milestones: Milestone 1, Milestone 2 on Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiWebGPU API

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions