Skip to content

Commit

Permalink
Track object usage (#399)
Browse files Browse the repository at this point in the history
* Track object usage wip

* doh

* better sys exit

* Wrap up implementation of diagnostics

* add tests

* last bit of test coverage

* create map to determine bpp for textures

* Refactor

* More refactoring

* tweak

* Remove old print_report

* Add docs

* Small refactor for codegen

* small tweaks

* Cleaner way to handle space between totals
  • Loading branch information
almarklein authored Nov 1, 2023
1 parent 624ecec commit 183f0c3
Show file tree
Hide file tree
Showing 9 changed files with 1,142 additions and 94 deletions.
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

0 comments on commit 183f0c3

Please sign in to comment.