VPP  0.7
A high-level modern C++ API for Vulkan
Public Member Functions | List of all members
vpp::Shader Class Reference

Base class for shader interfaces. More...

#include <vppLangIntInOut.hpp>

Inheritance diagram for vpp::Shader:
vpp::ComputeShader vpp::FragmentShader vpp::GeometryShader vpp::TessControlShader vpp::TessEvalShader vpp::VertexShader

Public Member Functions

void DebugCodeDump ()
 Enables diagnostic dump of intermediate SPIR-V code for this shader. More...
 
template<class ValueT >
void DebugProbe (const ValueT &value, const IVec2 &coords, const VkExtent3D &extent)
 Adds a debug probe to dump an expression value during shader execution. More...
 

Detailed Description

Base class for shader interfaces.

This base class provides some utility functions common to all shader interfaces.

Member Function Documentation

◆ DebugCodeDump()

void vpp::Shader::DebugCodeDump ( )

Enables diagnostic dump of intermediate SPIR-V code for this shader.

Use anywhere in the shader code to enable the SPIR-V code dump. The code is written to currently registered DebugReporter. Also you must have called the DebugReporter constructor with DebugReporter::SHADERS flag, to globally enable shader compilation output.

SPIR-V code is useful to diagnose problems in VPP itself. For typical operation you will not need this function.

◆ DebugProbe()

template<class ValueT >
void vpp::Shader::DebugProbe ( const ValueT &  value,
const IVec2 coords,
const VkExtent3D &  extent 
)

Adds a debug probe to dump an expression value during shader execution.

Debug probes are useful tool to examine values computed inside shaders. It is a counterpart of well-known printf method of debugging plain C/C++ code in situations when proper debugger is unavailable. The difference is that DebugProbe creates a temporary image rather than text dump, where the values are being written to. You can view the image in any rendering debugger, e.g. RenderDoc.

The first argument is the value to dump. The type can be either scalar (Float, Int, UInt) or 4-element vector of these (Vec4, IVec4, UVec4). If you do not need to dump all 4 components, just supply zeros to remaining elements.

The second argument is 2-dimensional coordinate vector (IVec2). It specifies where the value will be located in the debug image. The meaning depends on your shader. If it is a shader operating on some image, natural choice are the coordinates within the image. But this is completely arbitrary, the interpretation of these coords is up to you.

The third argument is the size of the debug image. Here specify maximum expected coordinate values, as the VkExtent3D type.

Example:

pShader->DebugProbe (
val, IVec2 ( currentX, currentY ),
VkExtent3D { width, height } );

In order to view the debug image, launch your program withing an rendering debugger (RenderDoc is recommended) and capture some frame or frames.

You can declare multiple debug probes. Each one will generate its own storage image.


The documentation for this class was generated from the following file: