cbaggers / varjo

Lisp to GLSL Language Translator
BSD 2-Clause "Simplified" License
223 stars 23 forks source link

harmless but duplicate functions in glsl. One func for each call to passing ssbo as a struct #218

Open cbaggers opened 6 years ago

cbaggers commented 6 years ago

This test exposes the issue

(5am:def-test ssbo-8 (:suite ubo-ssbo-tests)
  (glsl-contains-n-p 1 "BLAH.*();"
    (compile-vert ((vert pos-col)
                  &uniform (the-data some-data :ssbo :std-140))
       :450 nil
     (labels ((blah ((x some-data))
                (with-slots (ints) x
                  (setf (aref ints 1) 10)))
              (ham ((x some-data))
                (blah x)))
       (ham the-data)
       (blah the-data)
       (v! 1 2 3 4)))))

the glsl that results is

"// vertex-stage
#version 450

layout(location = 0)  in vec3 fk_vert_position;
layout(location = 1)  in vec4 fk_vert_color;

layout(std140) buffer _SSBO_THE_DATA
{
    int[1000] INTS;
} THE_DATA;

int HAM0();
int BLAH1();
int BLAH0();

int BLAH0()
{
    return THE_DATA.INTS[1] = 10;
}

int BLAH1()
{
    return THE_DATA.INTS[1] = 10;
}

int HAM0()
{
    return BLAH0();
}

void main()
{
    HAM0();
    BLAH1();
    vec4 g_GEXPR0_1183 = vec4(float(1),float(2),float(3),float(4));
    gl_Position = g_GEXPR0_1183;
    return;
}
"
cbaggers commented 6 years ago

result from a fix to another issue. will track this there

cbaggers commented 6 years ago

Turns out the duplicate func thing is already happening on master so this fine to have as a new ticket

cbaggers commented 6 years ago

See the fix/ssbo-arg-issue branch for tests that fail on this behaviour