mripard / sunxi-mali

GNU General Public License v2.0
100 stars 54 forks source link

Can't compile vertex shader of version 100. #49

Closed ghost closed 6 years ago

ghost commented 6 years ago

The both error messages are empty (my program gets SDL and GL errors). It was working on amdgpu just fine.

    const char* skyCubeVsSrc=
        "#version 140\n"
        "in vec3 coord3d;\n"
        "out vec2 uv1;\n"
        "out vec2 uv2;\n"
        "out vec2 uv3;\n"
        "out vec2 uv4;\n"
        "out vec2 uv5;\n"
        "out vec2 uv6;\n"
        "out vec2 uv7;\n"
        "out vec2 uv8;\n"
        "out vec2 thetagamma;\n"
        "out float cloudline;\n"
        "out float z;\n"
        "uniform mat4 mvp;\n"
        "uniform vec3 sun;\n"
        "uniform float shift;\n"
        "float vecos(vec3 a, vec3 b) {\n"
            "return dot(a, b)/sqrt(dot(a, a)*dot(b, b));\n"
        "}\n"
        "void main(void) {\n"
            "vec3 n=coord3d/sqrt(dot(coord3d,coord3d));\n"
            "z=sqrt(sqrt(max(n.z, 0.01)));\n"
            "uv1=n.xy/z/2;\n"
            "uv2=uv1/2+shift;\n"
            "uv3=uv2/2+shift*2;\n"
            "uv4=uv3/2+shift*2;\n"
            "uv5=uv4/2+shift*3;\n"
            "uv6=uv5/2+shift*3;\n"
            "uv7=uv6/2+shift*5;\n"
            "uv8=uv7/2+shift*5;\n"
            "vec3 up=vec3(0.0,0.0,1.0);\n"
            "thetagamma=vec2(vecos(n, up), vecos(n, sun));\n"
            "cloudline=max(thetagamma.x,0.0)*0.25;\n"//control that to move the clouds higher
            "cloudline=cloudline*cloudline;\n"
            "gl_Position = mvp*vec4(n, 1.0);\n"
        "}";
    const char* skyCubeFsSrc=
        "#version 140\n"
        "in vec2 uv1;\n"
        "in vec2 uv2;\n"
        "in vec2 uv3;\n"
        "in vec2 uv4;\n"
        "in vec2 uv5;\n"
        "in vec2 uv6;\n"
        "in vec2 uv7;\n"
        "in vec2 uv8;\n"
        "in vec2 thetagamma;\n"
        "in float cloudline;\n"
        "in float z;\n"
        "uniform sampler2D hosekwilkie;\n"
        "uniform sampler2D scale8;\n"
        "void main() {\n"
            "mediump vec3 hosekwilkietex=texture2D(hosekwilkie, thetagamma).xyz;\n"
            "float scale1tex=texture2D(scale8, uv1, z).x;\n"
            "float scale2tex=texture2D(scale8, uv2, z).x;\n"
            "float scale3tex=texture2D(scale8, uv3, z).x;\n"
            "float scale4tex=texture2D(scale8, uv4, z).x;\n"
            "float scale5tex=texture2D(scale8, uv5, z).x;\n"
            "float scale6tex=texture2D(scale8, uv6, z).x;\n"
            "float scale7tex=texture2D(scale8, uv7, z).x;\n"
            "float scale8tex=texture2D(scale8, uv8, z).x;\n"
            "float clouds=min(max(scale1tex+scale2tex+scale3tex+scale4tex+scale5tex+scale6tex+scale7tex+scale8tex-4.0,0.0),4.0);\n"
            "vec3 resultColor=hosekwilkietex*hosekwilkietex+clouds*cloudline;\n"
            "gl_FragColor = vec4(sqrt(resultColor/(resultColor+1.0)),1.0);\n"
        "}";
ghost commented 6 years ago

That one doesn't work, too.

    const char* skyCubeVsSrc=
        "#version 110\n"
        "attribute vec3 coord3d;\n"
        "varying vec2 uv1;\n"
        "varying vec2 uv2;\n"
        "varying vec2 uv3;\n"
        "varying vec2 uv4;\n"
        "varying vec2 uv5;\n"
        "varying vec2 uv6;\n"
        "varying vec2 uv7;\n"
        "varying vec2 uv8;\n"
        "varying vec2 thetagamma;\n"
        "varying float cloudline;\n"
        "varying float z;\n"
        "uniform mat4 mvp;\n"
        "uniform vec3 sun;\n"
        "uniform float shift;\n"
        "float vecos(vec3 a, vec3 b) {\n"
            "return dot(a, b)/sqrt(dot(a, a)*dot(b, b));\n"
        "}\n"
        "void main(void) {\n"
            "vec3 n=coord3d/sqrt(dot(coord3d,coord3d));\n"
            "z=sqrt(sqrt(max(n.z, 0.01)));\n"
            "uv1=n.xy/z/2.0;\n"
            "uv2=uv1/2.0+shift;\n"
            "uv3=uv2/2.0+shift*2.0;\n"
            "uv4=uv3/2.0+shift*2.0;\n"
            "uv5=uv4/2.0+shift*3.0;\n"
            "uv6=uv5/2.0+shift*3.0;\n"
            "uv7=uv6/2.0+shift*5.0;\n"
            "uv8=uv7/2.0+shift*5.0;\n"
            "vec3 up=vec3(0.0,0.0,1.0);\n"
            "thetagamma=vec2(vecos(n, up), vecos(n, sun));\n"
            "cloudline=max(thetagamma.x,0.0)*0.25;\n"//control that to move the clouds higher
            "cloudline=cloudline*cloudline;\n"
            "gl_Position = mvp*vec4(n, 1.0);\n"
        "}";
    const char* skyCubeFsSrc=
        "#version 110\n"
        "varying vec2 uv1;\n"
        "varying vec2 uv2;\n"
        "varying vec2 uv3;\n"
        "varying vec2 uv4;\n"
        "varying vec2 uv5;\n"
        "varying vec2 uv6;\n"
        "varying vec2 uv7;\n"
        "varying vec2 uv8;\n"
        "varying vec2 thetagamma;\n"
        "varying float cloudline;\n"
        "varying float z;\n"
        "uniform sampler2D hosekwilkie;\n"
        "uniform sampler2D scale8;\n"
        "void main() {\n"
            "vec3 hosekwilkietex=texture2D(hosekwilkie, thetagamma).xyz;\n"
            "float scale1tex=texture2D(scale8, uv1, z).x;\n"
            "float scale2tex=texture2D(scale8, uv2, z).x;\n"
            "float scale3tex=texture2D(scale8, uv3, z).x;\n"
            "float scale4tex=texture2D(scale8, uv4, z).x;\n"
            "float scale5tex=texture2D(scale8, uv5, z).x;\n"
            "float scale6tex=texture2D(scale8, uv6, z).x;\n"
            "float scale7tex=texture2D(scale8, uv7, z).x;\n"
            "float scale8tex=texture2D(scale8, uv8, z).x;\n"
            "float clouds=min(max(scale1tex+scale2tex+scale3tex+scale4tex+scale5tex+scale6tex+scale7tex+scale8tex-4.0,0.0),4.0);\n"
            "vec3 resultColor=hosekwilkietex*hosekwilkietex+clouds*cloudline;\n"
            "gl_FragColor = vec4(sqrt(resultColor/(resultColor+1.0)),1.0);\n"
        "}";
ghost commented 6 years ago

Neither that work.

    const char* skyCubeVsSrc=
        "#version 100\n"
        "attribute lowp vec3 coord3d;\n"
        "varying lowp vec2 uv1;\n"
        "varying lowp vec2 uv2;\n"
        "varying lowp vec2 uv3;\n"
        "varying lowp vec2 uv4;\n"
        "varying lowp vec2 uv5;\n"
        "varying lowp vec2 uv6;\n"
        "varying lowp vec2 uv7;\n"
        "varying lowp vec2 uv8;\n"
        "varying lowp vec2 thetagamma;\n"
        "varying lowp float cloudline;\n"
        "varying lowp float z;\n"
        "uniform lowp mat4 mvp;\n"
        "uniform lowp vec3 sun;\n"
        "uniform lowp float shift;\n"
        "lowp float vecos(vec3 a, vec3 b) {\n"
            "return dot(a, b)/sqrt(dot(a, a)*dot(b, b));\n"
        "}\n"
        "void main(void) {\n"
            "lowp vec3 n=coord3d/sqrt(dot(coord3d,coord3d));\n"
            "z=sqrt(sqrt(max(n.z, 0.01)));\n"
            "uv1=n.xy/z/2.0;\n"
            "uv2=uv1/2.0+shift;\n"
            "uv3=uv2/2.0+shift*2.0;\n"
            "uv4=uv3/2.0+shift*2.0;\n"
            "uv5=uv4/2.0+shift*3.0;\n"
            "uv6=uv5/2.0+shift*3.0;\n"
            "uv7=uv6/2.0+shift*5.0;\n"
            "uv8=uv7/2.0+shift*5.0;\n"
            "lowp vec3 up=vec3(0.0,0.0,1.0);\n"
            "thetagamma=vec2(vecos(n, up), vecos(n, sun));\n"
            "cloudline=max(thetagamma.x,0.0)*0.25;\n"//control that to move the clouds higher
            "cloudline=cloudline*cloudline;\n"
            "gl_Position = mvp*vec4(n, 1.0);\n"
        "}";
    const char* skyCubeFsSrc=
        "#version 100\n"
        "varying lowp vec2 uv1;\n"
        "varying lowp vec2 uv2;\n"
        "varying lowp vec2 uv3;\n"
        "varying lowp vec2 uv4;\n"
        "varying lowp vec2 uv5;\n"
        "varying lowp vec2 uv6;\n"
        "varying lowp vec2 uv7;\n"
        "varying lowp vec2 uv8;\n"
        "varying lowp vec2 thetagamma;\n"
        "varying lowp float cloudline;\n"
        "varying lowp float z;\n"
        "uniform sampler2D hosekwilkie;\n"
        "uniform sampler2D scale8;\n"
        "void main() {\n"
            "lowp vec3 hosekwilkietex=texture2D(hosekwilkie, thetagamma).xyz;\n"
            "lowp float scale1tex=texture2D(scale8, uv1, z).x;\n"
            "lowp float scale2tex=texture2D(scale8, uv2, z).x;\n"
            "lowp float scale3tex=texture2D(scale8, uv3, z).x;\n"
            "lowp float scale4tex=texture2D(scale8, uv4, z).x;\n"
            "lowp float scale5tex=texture2D(scale8, uv5, z).x;\n"
            "lowp float scale6tex=texture2D(scale8, uv6, z).x;\n"
            "lowp float scale7tex=texture2D(scale8, uv7, z).x;\n"
            "lowp float scale8tex=texture2D(scale8, uv8, z).x;\n"
            "lowp float clouds=min(max(scale1tex+scale2tex+scale3tex+scale4tex+scale5tex+scale6tex+scale7tex+scale8tex-4.0,0.0),4.0);\n"
            "lowp vec3 resultColor=hosekwilkietex*hosekwilkietex+clouds*cloudline;\n"
            "gl_FragColor = vec4(sqrt(resultColor/(resultColor+1.0)),1.0);\n"
        "}";
hor63 commented 6 years ago

What is exactly the error message?

You may download the ARM Mali offline shader compiler. That should produce the same compile results, provided you feed it with the correct version of the target MALIblob version (R6 P2?), and comprehensive error messages in your case.


From: bckpkol notifications@github.com Sent: Tuesday, September 4, 2018 10:24 AM To: mripard/sunxi-mali Cc: Subscribed Subject: Re: [mripard/sunxi-mali] Can't compile vertex shader of version 140. (#49)

That doesn't work, too.

const char* skyCubeVsSrc=
    "#version 110\n"
    "attribute vec3 coord3d;\n"
    "varying vec2 uv1;\n"
    "varying vec2 uv2;\n"
    "varying vec2 uv3;\n"
    "varying vec2 uv4;\n"
    "varying vec2 uv5;\n"
    "varying vec2 uv6;\n"
    "varying vec2 uv7;\n"
    "varying vec2 uv8;\n"
    "varying vec2 thetagamma;\n"
    "varying float cloudline;\n"
            "varying float z;\n"
    "uniform mat4 mvp;\n"
    "uniform vec3 sun;\n"
    "uniform float shift;\n"
    "float vecos(vec3 a, vec3 b) {\n"
        "return dot(a, b)/sqrt(dot(a, a)*dot(b, b));\n"
    "}\n"
    "void main(void) {\n"
        "vec3 n=coord3d/sqrt(dot(coord3d,coord3d));\n"
                "z=sqrt(sqrt(max(n.z, 0.01)));\n"
        "uv1=n.xy/z/2.0;\n"
        "uv2=uv1/2.0+shift;\n"
        "uv3=uv2/2.0+shift*2.0;\n"
        "uv4=uv3/2.0+shift*2.0;\n"
        "uv5=uv4/2.0+shift*3.0;\n"
        "uv6=uv5/2.0+shift*3.0;\n"
        "uv7=uv6/2.0+shift*5.0;\n"
        "uv8=uv7/2.0+shift*5.0;\n"
        "vec3 up=vec3(0.0,0.0,1.0);\n"
        "thetagamma=vec2(vecos(n, up), vecos(n, sun));\n"
        "cloudline=max(thetagamma.x,0.0)*0.25;\n"//control that to move the clouds higher
        "cloudline=cloudline*cloudline;\n"
        "gl_Position = mvp*vec4(n, 1.0);\n"
    "}";
const char* skyCubeFsSrc=
    "#version 110\n"
    "varying vec2 uv1;\n"
    "varying vec2 uv2;\n"
    "varying vec2 uv3;\n"
    "varying vec2 uv4;\n"
    "varying vec2 uv5;\n"
    "varying vec2 uv6;\n"
    "varying vec2 uv7;\n"
    "varying vec2 uv8;\n"
    "varying vec2 thetagamma;\n"
    "varying float cloudline;\n"
            "varying float z;\n"
    "uniform sampler2D hosekwilkie;\n"
    "uniform sampler2D scale8;\n"
    "void main() {\n"
        "vec3 hosekwilkietex=texture2D(hosekwilkie, thetagamma).xyz;\n"
        "float scale1tex=texture2D(scale8, uv1, z).x;\n"
        "float scale2tex=texture2D(scale8, uv2, z).x;\n"
        "float scale3tex=texture2D(scale8, uv3, z).x;\n"
        "float scale4tex=texture2D(scale8, uv4, z).x;\n"
        "float scale5tex=texture2D(scale8, uv5, z).x;\n"
        "float scale6tex=texture2D(scale8, uv6, z).x;\n"
        "float scale7tex=texture2D(scale8, uv7, z).x;\n"
        "float scale8tex=texture2D(scale8, uv8, z).x;\n"
        "float clouds=min(max(scale1tex+scale2tex+scale3tex+scale4tex+scale5tex+scale6tex+scale7tex+scale8tex-4.0,0.0),4.0);\n"
        "vec3 resultColor=hosekwilkietex*hosekwilkietex+clouds*cloudline;\n"
        "gl_FragColor = vec4(sqrt(resultColor/(resultColor+1.0)),1.0);\n"
    "}";

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmripard%2Fsunxi-mali%2Fissues%2F49%23issuecomment-418317190&data=02%7C01%7C%7C56afe1bbe8da4805a6f408d612508d6c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716534509594504&sdata=2rvx0Zx9ticBqFVEsYFT4b7WwNyCc5Ed1NRfPOBq3bw%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAPbi3cfL_y3miQ4ejTagvJRVSvRCXfsiks5uXlTJgaJpZM4WXtCs&data=02%7C01%7C%7C56afe1bbe8da4805a6f408d612508d6c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716534509594504&sdata=4Q%2FMpPNWxQLKzr76%2BfJ4K3khIIVLuWxTBTLyTMr0nzk%3D&reserved=0.

ghost commented 6 years ago

The error message is empty. Maybe I'm receiving it the wrong way. But on amdgpu, it displays errors just fine. It may be truncated though.

ghost commented 6 years ago

SDLarch modified code for shader build.

GLuint GLPipeline::compileShader(unsigned type, unsigned count, const char **source) {
    if(video_status) return 0;
    GLuint shader = glCreateShader(type);
    glShaderSource(shader, count, source, NULL);
    glCompileShader(shader);

    GLint status;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);

    if (status == GL_FALSE) {
        char buffer[4096];
        glGetShaderInfoLog(shader, sizeof(buffer), NULL, buffer);
        SDL_LogCritical(SDL_LOG_CATEGORY_ERROR, "Can't compile %s shader:", type == GL_VERTEX_SHADER ? "vertex" : "fragment");
        throw buffer;
        return 0;
    }

    return shader;
}
ghost commented 6 years ago

I didn't mentioned. After running the code some apps begin to segfault.

ghost commented 6 years ago

The offline compiler tells me that the compilation is succeeded.

ghost commented 6 years ago

Finally, the error: valgrind: m_transtab.c:2459 (vgPlain_init_tt_tc): Assertion 'sizeof(TTEntryC) <= 88' failed. I didn't mentioned, I have outdated dev SDL installed. Edit: it's valgrind's bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=838203

ghost commented 6 years ago

And more - official armbian SDL reports the same error I've seen two months ago. It's 'undefined reference to wl_egl_window_resize'. With every program.

hor63 commented 6 years ago

It's 'undefined reference to wl_egl_window_resize'.

Mmmh, are you maybe running the FBDEV or Wayland mali.so against an X-Window application?


From: bckpkol notifications@github.com Sent: Tuesday, September 4, 2018 1:34 PM To: mripard/sunxi-mali Cc: Kai Horstmann; Comment Subject: Re: [mripard/sunxi-mali] Can't compile vertex shader of version 100. (#49)

And more - official armbian SDL reports the same error I've seen two months ago. It's 'undefined reference to wl_egl_window_resize'.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/mripard/sunxi-mali/issues/49#issuecomment-418368758, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APbi3f9JUtgo2gUOhM48skFg_bQhhQ4Fks5uXoFPgaJpZM4WXtCs.

ghost commented 6 years ago

Maybe.

ghost commented 6 years ago

No. That is only defined in wayland mali but not in x11.

ghost commented 6 years ago

Holy... It seems that Armbian is now Wayland oriented. Any good desktop on Wayland working under Pi? Anyway, I broke my armbian installation so I cannot use apt. I'll return after reinstalling the whole stuff.

ghost commented 6 years ago

I'm back. Stock Armbian SDL won't work nor with X11 neither with Wayland. SDL built with OpenGL disabled and GLES2 enabled fails on both X11 and Wayland, with "Could not get EGL display". A.k.a "eglGetDisplay() failed" in es2_info.

ghost commented 6 years ago

Pathetic, Wayland itself tells that EGL is working, and running my app with sudo makes it fail even earlier. "No available video device".

ghost commented 6 years ago

Running the whole Weston as root, the error is "Could not get EGL display".

ghost commented 6 years ago

X11 SDL can't get GLES version with error 0, then can't compile vertex shader. Same story. But hey, for a second I had a window.

ghost commented 6 years ago

I've found what was wrong. It's -lGL in Makefile! So how could I link against GLES? -lGLESv2 would be fine?

ghost commented 6 years ago

Yes, that's fine. Just need to rebuild SDL without OpenGL and it would be fine. But I'll stay with gl4es, because I need other GL software to work without recompiling.