HLSL compiler optimizes strange?
问题 I am not an expert in HLSL compilers and how they work with branches but I have read different opinions about this issue. So to be concrete: In C/C++ it would make perfect sense to implement something like: if (factor == 0) { // Simple calculation in special case of factor=0 } else if (factor == 1) { // Simple calculation in special case of factor=1 } else { // Much more complex calculation in general case of arbitrary factor } in situations where most of the time factor is 0 or 1. Is the