I have the following code:
(voxelCoord.x < 0 ||
voxelCoord.y < 0 || voxelCoord.z < 0 || voxelCoord.x > 1
|| voxelCoord.y > 1 || voxelCoord.z > 1)
However, I think it should be possible to optimize this. I think using min and max will set me back, is there a solution like clamp which will let me check if the boundaries are passed?
For instance; would
clamp(voxelCoord, float3(0), float3(1)) != voxelCoord
work?
any(voxelCoord < 0 || voxelCoord > 1)
Is more concise and compiles down to 2 less D3D-IL instructions than what you've written. Whether it is any more optimal after the driver's compiler has had a go at optimising them will depend on other factors (whether the hardware is vector-based or scalar-based for one).