Add "any" and 'all' syntax to branch according to vector comparison result
Benualdo opened this issue · 2 comments
Hi,
I would found it very useful to add the 'any'/'all' HLSL syntax to branch according to vector comparison result.
ie.
void CommandList::setViewport(const uint4 & _viewport)
{
if ( any( _viewport != m_viewport ) )
{
bindViewport(_viewport);
m_viewport = _viewport;
}
}
Operators like intN operator != could return boolN to make it even clearer to use.
Thanks,
Benoît.
I've gone and implemented this functionality with vector instructions and added unit tests. I'll wait for you to reply on the pull request in case you still want to put forward the unimplemented functionality or would rather I do it. Let me know.
In terms of implementing boolN I thought about it from the very beginning but hlsl is a bit weird in how it treats bools (they can be implicitly converted to ints, floats or whatever you need) and it's a can of worms I'd rather not open unless necessary. To be honest in many years of shader programming I have never used the boolN type explicitly, it has always either collapsed to a bool through any/all or stored in float/int by adding, dot product, etc.