Hello Caroline, I want to print some information in shader.metal file on my console. I find I can not use “print” command in shader.metal and I also try to use std :: count like C ++ with import , but failure. So would u please tell me if I want to print information in shader.metal how should I do?
Because shaders happen on the GPU, there is no print command. You’d have to use the GPU frame capture and examine what’s happening on a particular frame.
Chapter 6, Textures, introduces you to this on page 167 of the pdf.
Chapter 23, Debugging and Profiling takes you through this frame capture in more detail, and shows you how to find out the values that your shaders have produced. In this way, you can find out whether your shader is working correctly.
As to your C++, Metal shading language is a cut-down version of C++, and may not support what you’re trying to do.
You can see what’s supported in the Metal Shading Language specification: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
Thank you Caroline for your help