lotsopa / Savvy

A Generic and Flexible Shader Cross Compiler Library/Tool
MIT License
33 stars 2 forks source link

Using functions as parameters to other functions breaks the parsing #5

Open moradin opened 9 years ago

moradin commented 9 years ago

The simplest shader I could find to illustrate this is:

vec3 SampleTexture( Texture2D texture, float param  )
{
    vec3 result = lerp(Func(texture), Func(texture), param );
    return result;
}

struct VS_INPUT
{
    float4 pos : POSITION0 ;
};

struct VS_OUTPUT
{
    float4 pos : SV_Position ;
};

float4 ps_main ( VS_OUTPUT i ) : SV_Target0
{
    return float4(0,0,0,0);
}

after the first Func() is parsed correctly the second one will be parsed as a declaration which leaves the parser in some weird, probably invalid state and the parsing of the VS_INPUT will result in the following code:

struct VS_INPUT
{
    POSITION0;
};
lotsopa commented 9 years ago

It is very possible that the parser is not reset correctly after the function. I'll look into that.