printf¶
Description¶
Print a message to the debug output.
Signature¶
void printf<each T>( NativeString format, const T args);
Generic Parameters¶
T¶
The variadic type pack parameter for the arguments to be printed.
Parameters¶
format : NativeString¶
The format string.
args : T¶
(optional) The arguments to be printed.
Remarks¶
The function maps to printf for HLSL, CPU and CUDA targets, and maps to OpDebugPrintf for SPIR-V target, and maps to debugPrintfEXT for GLSL target. Depending on the target and execution environment, the function may have no effect.
Example¶
void test(int x, float y)
{
printf("hello world!\n");
printf(R"(x = "%d", y = "%f")", x, y);
}
Availability and Requirements¶
Defined for the following targets:
hlsl¶
Available in all stages.
glsl¶
Available in all stages.
cpp¶
Available in all stages.
cuda¶
Available in all stages.
spirv¶
Available in all stages.
Requires capability: SPV_KHR_non_semantic_info.
llvm¶
Available in all stages.
slangvm¶
Available in all stages.