Skip to content

Commit

Permalink
Merge branch 'main' into shadertoy-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Korijn authored Nov 6, 2023
2 parents 9ef738e + 6ce9ac9 commit 69b18a1
Show file tree
Hide file tree
Showing 16 changed files with 1,985 additions and 183 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ jobs:
pip install -U -r dev-requirements.txt
python download-wgpu-native.py
pip install -e .
- name: Test on repo
- name: Unit tests
run: |
pytest -v tests
- name: Memory tests
run: |
pytest -v tests_mem
# The release builds are done for the platforms that we want to build wheels for.
# We build wheels, test them, and then upload the wheel as an artifact.
Expand Down
39 changes: 39 additions & 0 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,45 @@ Utils

The wgpu library provides a few utilities. Note that most functions below need to be explictly imported.

Logger
------

Errors, warnings, and info messages (including messages generated by
wgpu-native) are logged using Python's default logging mechanics. The
wgpu logger instance is in ``wgpu.logger``, but can also be obtained
via:

.. code-block:: py
import logging
logger = logging.getLogger("wgpu")
Diagnostics
-----------

To print a full diagnostic report:

.. code-block:: py
wgpu.diagnostics.print_report()
To inspect (for example) the total buffer usage:

.. code-block:: py
>>> counts = wgpu.diagnostics.object_counts.get_dict()
>>> print(counts["Buffer"])
{'count': 3, 'resource_mem': 784}
.. autoclass:: wgpu._diagnostics.DiagnosticsRoot
:members:


.. autoclass:: wgpu._diagnostics.Diagnostics
:members:


Get default device
------------------
Expand Down
4 changes: 2 additions & 2 deletions examples/compute_noop.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
# import numpy as np
#
# numpy_data = np.frombuffer(data, np.int32)
# out = compute_with_buffers({0: numpy_data}, {1: numpy_data.nbytes}, compute_shader, n=n)
# out = compute_with_buffers({0: numpy_data}, {1: numpy_data.nbytes}, shader_source, n=n)
# result = np.frombuffer(out[1], dtype=np.int32)
# print(result)
# print(result.tolist())


# %% The long version using the wgpu API
Expand Down
Loading

0 comments on commit 69b18a1

Please sign in to comment.