Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
8abb9aa
sketch idea
Vipitis Sep 26, 2025
0d22166
some hangup with buffer alignment -.-
Vipitis Sep 26, 2025
ac858b8
new errors :!
Vipitis Sep 26, 2025
b94ab8a
context in progress
Vipitis Sep 27, 2025
a42e6f2
more headache and shortcuts
Vipitis Sep 27, 2025
0618db6
first success!
Vipitis Sep 27, 2025
9e16b0c
use _internal
Vipitis Sep 28, 2025
237e269
ensure the call the base init
Vipitis Sep 28, 2025
3b5723f
dicts with key "type" ruin everything !!
Vipitis Sep 28, 2025
431b701
move data with .assign
Vipitis Sep 29, 2025
0cc6381
enable imgui demos
Vipitis Sep 29, 2025
d2cd796
BigInt in not reuqired
Vipitis Oct 8, 2025
158237f
fromEntries doesn't solve it just yet
Vipitis Oct 10, 2025
84fa6ac
revert cube changes
Vipitis Oct 16, 2025
07465da
sorta repair again
Vipitis Oct 16, 2025
75e29cc
use descriptor structs!
Vipitis Oct 16, 2025
87a3049
maybe fix recursion caching issue?
Vipitis Oct 16, 2025
b51cce2
compute examples work!
Vipitis Oct 16, 2025
4b7256e
broken again :/
Vipitis Oct 17, 2025
a87b6fa
use pyodide 0.29 dev branch
Vipitis Oct 19, 2025
18cce35
more descriuptors - seems to work
Vipitis Oct 19, 2025
c6bc69f
start codegen for js api
Vipitis Oct 19, 2025
e571682
codegen more methods
Vipitis Oct 20, 2025
3878f98
merge upstream main into browser
Vipitis Oct 23, 2025
f190c3c
implement async promises
Vipitis Oct 24, 2025
078cdc3
update async usage
Vipitis Oct 24, 2025
b24f4b9
fix additional arg
Vipitis Oct 25, 2025
2b3f37c
use codegen infra
Vipitis Oct 26, 2025
be7e04e
tweak more codegen cases
Vipitis Oct 26, 2025
28442a1
flags and enums need no conversion
Vipitis Oct 26, 2025
2595c28
add default and optional positional args
Vipitis Oct 26, 2025
fa69c9b
move custom implementations
Vipitis Oct 26, 2025
c0e3f0e
move mixins to the front
Vipitis Oct 26, 2025
a3c0af8
fix forward references
Vipitis Oct 26, 2025
ecbbf79
patch in methods via codegen
Vipitis Oct 27, 2025
81700e7
include all custom methods
Vipitis Oct 27, 2025
bd8e022
add in props
Vipitis Oct 27, 2025
9342acd
fix mixins
Vipitis Oct 27, 2025
90f50d4
adjust for new rendercanas
Vipitis Nov 1, 2025
4925779
unrename canvas id
Vipitis Nov 2, 2025
b5e0b5f
add serving script
Vipitis Nov 2, 2025
801db6c
improvements to serving script
Vipitis Nov 3, 2025
eb4dd37
use rendercanvas from pypi
Vipitis Nov 10, 2025
e36f34b
Merge remote-tracking branch 'upstream/main' into browser
Vipitis Nov 10, 2025
ab7921f
bump _version to from v1.4 to v1.4
Vipitis Nov 10, 2025
72bbaee
implement get_canvas_context
Vipitis Nov 10, 2025
e388660
add gallery from rendercanvas
Vipitis Nov 12, 2025
a6afdb3
add example titles
Vipitis Nov 12, 2025
8cb8a43
add flit just for docs
Vipitis Nov 12, 2025
dbe34c1
add example deps to doc deps
Vipitis Nov 12, 2025
24c82e0
add more titles
Vipitis Nov 12, 2025
5ffab1b
env in ci?
Vipitis Nov 12, 2025
a93b61d
make a pyodide build
Vipitis Nov 14, 2025
5543185
docs need build deps
Vipitis Nov 14, 2025
3823d4a
don't include cffi in pyodide build
Vipitis Nov 22, 2025
b75bc0a
enable all interactive examples in docs
Vipitis Nov 22, 2025
5ce893c
try downstream examples
Vipitis Jan 18, 2026
953940b
Merge branch 'main' into browser
Vipitis Jan 21, 2026
b60d33f
remove loop
Vipitis Jan 21, 2026
d59bb73
pygfx triangle works
Vipitis Jan 31, 2026
d65cb65
implement mapped buffer reading
Vipitis Feb 3, 2026
159b0d1
fix docs
Vipitis Feb 4, 2026
5845afe
pin rendercanvas for docs
Vipitis Feb 7, 2026
f97c177
default to primitive dict
Vipitis Feb 7, 2026
3815ea4
partial read_texture implementation
Vipitis Feb 8, 2026
7b872fc
dynamically load example deps
Vipitis Feb 8, 2026
fdbeeac
require fixed rendercanvas
Vipitis Feb 18, 2026
2b6a489
backport servering script improvements
Vipitis Feb 18, 2026
322b681
Merge branch 'main' into browser
Vipitis Feb 18, 2026
d02044e
maybe skip alignment
Vipitis Feb 18, 2026
1c76ae1
fixes for limits
Vipitis Feb 22, 2026
da44d24
only camelcase limit dicts
Vipitis Feb 22, 2026
ebd61a7
try pygfx improvements
Vipitis Mar 7, 2026
7b69dc5
Merge branch 'main' into browser
Vipitis Mar 7, 2026
89a3eba
fix args being too positional for js
Vipitis Mar 7, 2026
79e1aff
copy mapped_status tracking logic for api diff
Vipitis Mar 16, 2026
4871849
fix initial mapping size
Vipitis Mar 16, 2026
35f23e5
refactor to_js conversion
Vipitis Mar 21, 2026
0eeaad6
rework type hint logic
Vipitis Mar 22, 2026
b7108e2
undo round trip condition
Vipitis Mar 22, 2026
6c3d709
much simpler conversion
Vipitis Mar 22, 2026
3b17c00
cleanup _helpers
Vipitis Mar 22, 2026
80edfab
avoid wrapping kwargs in a descriptor
Vipitis Mar 24, 2026
c18c967
more simplifications
Vipitis Mar 24, 2026
5dbb970
simplify label constructors
Vipitis Apr 5, 2026
5c7a6c6
allow promises to error
Vipitis Apr 5, 2026
27eca50
fixes to style
Vipitis Apr 5, 2026
0621b41
fix some limit names
Vipitis May 9, 2026
d8315f5
just copy the same function
Vipitis May 9, 2026
6922936
Merge branch 'main' into browser
Vipitis May 17, 2026
0940622
fixes for fixed optional args
Vipitis May 17, 2026
8ce3766
make codegen take some args
Vipitis May 17, 2026
1f51fe9
fix new example header for docs
Vipitis May 17, 2026
43f4f7c
Merge branch 'main' into browser
Vipitis Jun 24, 2026
7c02ca3
make hatch happy?
Vipitis Jun 24, 2026
9dc3b9e
still needs to be done by hand -.-
Vipitis Jun 25, 2026
af45505
changes needed to use 16bit norm in the browser
Vipitis Jun 25, 2026
be6b4b8
Merge branch 'main' into browser
Vipitis Jun 25, 2026
530e0d8
preferred features works across platforms!
Vipitis Jun 25, 2026
80281b5
Merge branch 'main' into browser
Vipitis Jul 19, 2026
efe11be
fancier rendercanvas
Vipitis Jul 19, 2026
9bc7150
downstream doc tweaks
Vipitis Jul 19, 2026
fd34417
formatting
Vipitis Aug 1, 2026
e4b2392
better way to exclude native files
Vipitis Aug 14, 2026
2c6f887
try 314.0.6
Vipitis Sep 8, 2026
b0e0a7a
Merge branch 'main' into browser
Vipitis Sep 30, 2026
74b1899
add debug labels to imgui
Vipitis Oct 5, 2026
1e0cd60
only try to map unmapped buffers (but I don't think the rejection is …
Vipitis Oct 7, 2026
26e4dde
try a custom map_sync to better understand the race conditions betwee…
Vipitis Oct 8, 2026
87b6110
Merge branch 'browser' of https://github.com/Vipitis/wgpu-py into bro…
Vipitis Oct 10, 2026
d054da5
maybe find the issue
Vipitis Oct 11, 2026
2279b8a
wasn't imgui
Vipitis Oct 11, 2026
82d9653
better errors
Vipitis Oct 11, 2026
85bba9d
seems to can't use run_sync inside the sheduler loop-
Vipitis Oct 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import io

from .utils import print, PrintToFile
from . import apiwriter, apipatcher, wgpu_native_patcher, idlparser, hparser
from . import apiwriter, apipatcher, wgpu_native_patcher, idlparser, hparser, jswriter
from .files import file_cache


def main():
def main(do_api=True, do_wgpu_native=True, do_js=False):
"""Codegen entry point. This will populate the file cache with the
new code, but not write it to disk."""

log = io.StringIO()
with PrintToFile(log):
print("# Code generation report")
prepare()
update_api()
update_wgpu_native()
if do_api:
update_api()
if do_wgpu_native:
update_wgpu_native()
if do_js:
update_js()
file_cache.write("resources/codegen_report.md", log.getvalue())


Expand Down Expand Up @@ -63,3 +67,19 @@ def update_wgpu_native():
code1 = file_cache.read("backends/wgpu_native/_api.py")
code2 = wgpu_native_patcher.patch_wgpu_native_backend(code1)
file_cache.write("backends/wgpu_native/_api.py", code2)


def update_js():
"""
Writes? (maybe updates later) the JS webgpu backend API.
"""

print("## Writing backends/js_webgpu/_api.py")

code = jswriter.generate_js_webgpu_api()
# TODO: run the code against a patcher that adds hand written API diff methods

file_cache.write("backends/js_webgpu/_api.py", code)



13 changes: 12 additions & 1 deletion codegen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

import os
import sys
from argparse import ArgumentParser

parser = ArgumentParser(description="Run code generation and patching.")
parser.add_argument("--skip-api", action="store_false", dest="api", help="Skip API patching")
parser.add_argument("--skip-wgpu-native", action="store_false", dest="wgpu_native", help="Skip wgpu-native backend updates")
# TODO: this is highly confusing to be swawpped around, but I didn't want to break the existing functionality.
# maybe better to have a --skip a,b,c and --only e,f,g kinda CLI with all default?
parser.add_argument("--js", action="store_true", dest="js", help="Generate JS backend updates")


# Little trick to allow running this file as a script
Expand All @@ -15,5 +23,8 @@


if __name__ == "__main__":
main()
# maybe have args here to just run the js writer?
args = parser.parse_args()
main(do_api=args.api, do_wgpu_native=args.wgpu_native, do_js=args.js)
# TODO: we need to actually patch the codegen report if we skip patching some parts of it...
file_cache.write_changed_files_to_disk()
1 change: 1 addition & 0 deletions codegen/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FileCache:
"structs.py",
"backends/wgpu_native/_api.py",
"backends/wgpu_native/_mappings.py",
"backends/js_webgpu/_api.py", # TODO: maybe this file should be more like _mappings
"resources/codegen_report.md",
]

Expand Down
6 changes: 3 additions & 3 deletions codegen/idlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
identify and remove code paths that are no longer used.
"""

from typing import Literal

from typing import Dict, Literal
from codegen.utils import print
from codegen.files import read_file

Expand Down Expand Up @@ -145,7 +144,7 @@ def peek_line(self):

def parse(self, verbose=True):
self._interfaces = {}
self.classes = {}
self.classes:Dict[str, Interface] = {}
self.structs = {}
self.flags = {}
self.enums = {}
Expand Down Expand Up @@ -239,6 +238,7 @@ def resolve_type(self, typename) -> str:
"ImageData": "ArrayLike",
"VideoFrame": "ArrayLike",
"AllowSharedBufferSource": "ArrayLike",
"[AllowShared] Uint32Array": "ArrayLike",
"GPUPipelineConstantValue": "float",
"GPUExternalTexture": "object",
"undefined": "None",
Expand Down
Loading