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

Proposed approach for handling GLSL Builtin Other #52

Open
torinmb opened this issue Apr 30, 2021 · 0 comments
Open

Proposed approach for handling GLSL Builtin Other #52

torinmb opened this issue Apr 30, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@torinmb
Copy link
Member

torinmb commented Apr 30, 2021

Note: keeping the value of 'mix' as an array allows us to have specific constraints that return a specific dim.
Alternatively, we could write out all the logic and return types with cases, but for readability, this approach could be helpful.

let arg = {
    'mix' : [(a, b, c) => (a.dim === b.dim && (c.dim === 1 || c.dim === a.dim))? a.dim: -1],
};

The goal is to generate this:

function mix(arg_0, arg_1, arg_2) {
    ensureSameDims('mix', arg_0, arg_1);
    if (arg_2.dim !== 1 && arg_2.dim !== arg_0.dim) {
        compileError(`'mix' third argument must be float or match dim of first args`);
    }
    ensureScalar('mix', arg_2);
    arg_0 = tryMakeNum('arg_0');
    arg_1 = tryMakeNum('arg_1');
    arg_2 = tryMakeNum('arg_2');
    return new makeVarWithDims('mix(arg_0, arg_1, arg_2);', arg_0.dim);
}
@torinmb torinmb added enhancement New feature or request question Further information is requested labels Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants