Can anyone explain me what are noops in shader? I read about this term multiple times and I assume, that it is some kind of useless operations? And how to find and fix them? How operation like it looks like?
The term “noop” stands for “no operation”. It gets used to refer to two different cases in code. It’s an operation that literally does nothing and is removed by the shader compiler so has no affect on the GPU, and it can be an operation that does nothing but still takes some fixed time and is used to force the GPU to spin idle.
A example of a noop that is ignored and has no affect on the final compiled shader would be something like this:
float bar = _Bar; // noop
float4 baz = foo * bar;
That compiles to exactly the same compiled shader as:
float4 baz = foo * _Bar;
As for an example of a noop that causes the GPU to spin, those are usually added by the shader compiler to account for cases where there’s known latency. Basically situations where some internal function doesn’t return a value immediately. A good example of this is sampling a texture usually takes a few cycles to return a value. It’s possible to do other unrelated math while the GPU is fetching the texture, filtering, and eventually returning the color value. And GPUs will generally try to put texture sampling as early as possible so that that latency can be hidden. But in the cases where a shader has nothing else to do, sometimes a compiler will put in a few noops to make sure the texture sample has returned. Usually this is all hidden and you don’t ever see those in the actual compiled shaders.