CrossGL / crosstl

Translates native shader languages into CrossGL universal shader language and vice versa.
https://crossgl.net
Apache License 2.0
36 stars 39 forks source link

enh(translator): Add support for bitwise AND #202

Closed MashyBasker closed 1 month ago

MashyBasker commented 1 month ago

PR Description

This PR aims to add support for Bitwise AND in the translator frontend.

Related Issue

Fixes #106

shader Sample

shader main {
    struct VSInput {
        vec2 texCoord @ TEXCOORD0;
    };

    struct VSOutput {
        vec4 color @ COLOR;
    };

    sampler2D iChannel0;

    vertex {
        VSOutput main(VSInput input) {
            VSOutput output;
            // Use bitwise AND on texture coordinates (for testing purposes)
            output.color = vec4(float(int(input.texCoord.x * 100.0) & 15), 
                                float(int(input.texCoord.y * 100.0) & 15), 
                                0.0, 1.0);
            return output;
        }
    }

    fragment {
        vec4 main(VSOutput input) @ gl_FragColor {
            // Simple fragment shader to display the result of the AND operation
            return vec4(input.color.rgb, 1.0);
        }
    }
}

Checklist

samthakur587 commented 1 month ago

hii @MashyBasker the changes looking good to me can you add test for codegen also for bitwise and

MashyBasker commented 1 month ago

Updated the PR with the requested changes @samthakur587