Skip to content

Commit

Permalink
fix parsing of MAX values
Browse files Browse the repository at this point in the history
  • Loading branch information
Vipitis committed Feb 23, 2025
1 parent b7b52b4 commit 6e67484
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion wgpu/backends/wgpu_native/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,6 @@ def _create_texture_screen(self):
libf.wgpuSurfaceGetCurrentTexture(surface_id, surface_texture)
status = surface_texture.status
texture_id = surface_texture.texture
print(status)
if status == lib.WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal:
break # success
elif status == lib.WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal:
Expand Down
5 changes: 4 additions & 1 deletion wgpu/backends/wgpu_native/_ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def _get_wgpu_header(*filenames):
# Just removing them, plus a few extra lines, seems to do the trick.
lines2 = []
for line in lines1:
if line.startswith("#define ") and len(line.split()) > 2 and "0x" in line:
if line.startswith("#define ") and len(line.split()) > 2 and ("0x" in line or "_MAX" in line):
# pattern to find: #define WGPU_CONSTANT (0x1234)
line = line.replace("SIZE_MAX", hex((1 << ffi.sizeof("size_t") * 8)-1))
line = line.replace("UINT32_MAX", hex((1 << ffi.sizeof("uint32_t") * 8)-1)).replace("UINT64_MAX", hex((1 << ffi.sizeof("uint64_t") * 8)-1))
line = line.replace("(", "").replace(")", "")
elif line.startswith("#"):
continue
Expand Down

0 comments on commit 6e67484

Please sign in to comment.