mesa/src/vulkan/overlay-layer
Felix DeGrood b895c0ec05 vk/overlay-layer: fix regression in non-control pathway
Fixes regression introduced by prior commit. Prior commit fixed
the control pathway to starting overlay-layer but broke non-
control pathway. Now both pathways should be working.

Fixes: 06423b1792 ("defer log creation to swapchain creation")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12884
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34413>
2025-04-08 17:52:57 +00:00
..
mesa-overlay-control.py vk/overlay-layer: simplify print and make it more readable 2024-04-18 12:56:39 +00:00
meson.build build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
overlay.cpp vk/overlay-layer: fix regression in non-control pathway 2025-04-08 17:52:57 +00:00
overlay.frag
overlay.vert
overlay_params.c vk/overlay-layer: defer log creation to swapchain creation 2025-01-10 23:44:24 +00:00
overlay_params.h vk/overlay-layer: defer log creation to swapchain creation 2025-01-10 23:44:24 +00:00
README.rst docs: replace references to the deprecated VK_INSTANCE_LAYERS with the new VK_LOADER_LAYERS_ENABLE 2024-04-02 18:08:52 +00:00
TODO
VkLayer_MESA_overlay.json vulkan: bump layer api versions 2024-12-10 17:17:12 +00:00

A Vulkan layer to display information about the running application using an overlay.

Building
=======

The overlay layer will be built if :code:`overlay` is passed as a :code:`vulkan-layers` argument. For example:

.. code-block:: sh

  meson -Dvulkan-layers=device-select,overlay builddir/
  ninja -C builddir/
  sudo ninja -C builddir/ install

See `docs/install.rst <https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/docs/install.rst>`__ for more information.

Basic Usage
=======

Turn on the layer:

.. code-block:: sh

  VK_LOADER_LAYERS_ENABLE=VK_LAYER_MESA_overlay /path/to/my_vulkan_app


List the available statistics:

.. code-block:: sh

  VK_LOADER_LAYERS_ENABLE=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=help /path/to/my_vulkan_app


Turn on some statistics:

.. code-block:: sh

  VK_LOADER_LAYERS_ENABLE=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=submit,draw,pipeline_graphics /path/to/my_vulkan_app

Position the overlay:

.. code-block:: sh

  VK_LOADER_LAYERS_ENABLE=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=submit,draw,pipeline_graphics,position=top-right /path/to/my_vulkan_app

Logging Statistics
=======

Log statistics to a file:

.. code-block:: sh

  VK_LOADER_LAYERS_ENABLE=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=output_file=/tmp/output.txt /path/to/my_vulkan_app

Logging is enabled for the entire lifecycle of the process unless a control socket is specified (see below).

**Note:** some statistics (e.g. :code:`frame_timing` and :code:`gpu_timing`) log values for the entire sample interval instead of per-frame.
For these statistics, logging the :code:`frame` statistic allows one to compute per-frame statistics after capture.

Log statistics to a file, controlling when such statistics will start to be captured:

.. code-block:: sh

  VK_LOADER_LAYERS_ENABLE=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=output_file=/tmp/output.txt,control=mesa_overlay /path/to/my_vulkan_app

The command above will open a Unix socket with the abstract path :code:`mesa_overlay`. When a control socket is specified,
logging must be explicitly enabled through the control socket. :code:`mesa-overlay-control.py` provides a convenient CLI:

.. code-block:: sh

  mesa-overlay-control.py start-capture

.. code-block:: sh

  mesa-overlay-control.py stop-capture

Direct Socket Control
------

The Unix socket may be used directly if needed. Once a client connects to the socket, the overlay layer will immediately
send the following commands to the client:

.. code-block:: sh

  :MesaOverlayControlVersion=1;
  :DeviceName=<device name>;
  :MesaVersion=<mesa version>;

The client connected to the overlay layer can enable statistics capturing by sending the command:

.. code-block:: sh

  :capture=1;

And disable it by sending:

.. code-block:: sh

  :capture=0;

.. _docs/install.rst: ../../docs/install.rst