Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "any" and 'all' syntax to branch according to vector comparison result #34

Closed
Benualdo opened this issue Sep 12, 2020 · 2 comments
Closed
Assignees
Labels

Comments

@Benualdo
Copy link
Contributor

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.

@redorav redorav self-assigned this Sep 12, 2020
@redorav
Copy link
Owner

redorav commented Sep 12, 2020

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.

@redorav redorav closed this as completed Sep 12, 2020
@redorav
Copy link
Owner

redorav commented Sep 12, 2020

Fixed via 0b370de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants