Skip to content

Proposed approach for handling GLSL Builtin Other #52

Open
@torinmb

Description

@torinmb

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);
}

Metadata

Metadata

Labels

enhancementNew feature or requestquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions