Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track object usage #399

Merged
merged 16 commits into from
Nov 1, 2023
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
Loading
Loading