treeform / shady

Nim to GPU shader language compiler and supporting utilities.
MIT License
147 stars 10 forks source link

vec costructor arguments are not added to glsl #12

Open arkanoid87 opened 1 year ago

arkanoid87 commented 1 year ago
var
    pixelSize: uint32 = 2
    icols: uint32 = 1024
    irows: uint32 = 1024
    ocols = icols * pixelSize
    orows = irows * pixelSize
    inputShape: UVec2 = uvec2(icols, irows)
    outputShape: UVec2 = uvec2(ocols, orows)

generates just

uvec2 outputShape = uvec2(ocols, orows);

that causes error

error C1503: undefined variable "ocols"

the only way I've found so far to pass vec2 vars to glsl via shady is using int literals as arguments

treeform commented 1 year ago

Is this in the outer scope? Outer scope is odd in that it only brings in vars that are mentioned.

It needs to do a better job at walking outputShape and finding all symbols it uses.

arkanoid87 commented 1 year ago

yes, it's global scope

I have not yet wrapped anything as I've been following the pattern used in examples so far (and I am already dribbling the conversion limitations)

I'll try refactoring and cleaning up global scope