GPUPrinting struct

Stores state used for executing print commands generated by GPU shaders.

Public functions

auto loadStrings(slang::ProgramLayout* slangReflection) -> void
auto processGPUPrintCommands(const void* data, size_t dataSize) -> void

Function documentation

void GPUPrinting::loadStrings(slang::ProgramLayout* slangReflection)

Load any string literals used by a Slang program.

The slangReflection should be the layout and reflection object for a Slang shader program that might need to produce printed output. This function will load any strings referenced by the program into its database for mapping string hashes back to the original strings.

void GPUPrinting::processGPUPrintCommands(const void* data, size_t dataSize)

Process a buffer of GPU printing commands and write output to stdout.

This function attempts to read print commands from the buffer pointed to by data and execute them to produce output.

The buffer pointed at by data (of size dataSize) should be allocated in host-visible memory.

Before executing GPU work, the first four bytes pointed to by data should have been cleared to zero.

If GPU work has attempted to write more data than the buffer can fit, a warning will be printed to stderr, and printing commands that could not fit completely in the buffer will be skipped.