This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

segmentation fault with binary shader

Hi Team,

I am trying to use the binary shader. However I am getting segmentation fault. Any pointers to fix it would be helpful.

#version 320 es
in vec4 position;
out vec2 color;

void main (void)
{
    gl_Position = position;
    color.x = position.x + position.y;
    color.y = position.x - position.y;
}

I compiled using below command:

../Mali_Offline_Compiler_v6.4.0/malisc -c Mali-T880 -r r1p0 -d Mali-T600_r13p0-00rel0 -o vert.bin -v shader.vert

I am using binary shader in following way and getting seg fault in glShaderBinary().

    f = fopen("vert.bin", "rb");
    fseek(f, 0, SEEK_END);
    size = ftell(f);
    fseek(f, 0, SEEK_SET);
    vsBuffer = (GLubyte *) malloc(size);
    rsize = fread(vsBuffer, 1, size, f);
    fclose(f);
    
    
  
    CHECK_GL_ERROR(!glShaderBinary(1, &vert, GL_MALI_SHADER_BINARY_ARM, (void*)vsBuffer, size), glShaderBinary, "failed");
   

Best Regards,

Vikash

Parents
  • Hi Vikash, 

    In general we'd recommend not using the Mali Offline Compiler to generate shader binaries; they are not portable, requiring an exact match of GPU version and driver version, and are less efficient that full program binaries. We are actually going to remove this functionality in the next release, so the offline compiler just becomes a static analysis tool for performance analysis.

    Where possible it's highly recommended just to ship shader source code, using glGetProgramBinary() on the platform to save out compiled binaries to reduce application launch time if your platform doesn't provide automatic compilation caching.

    If you want to avoid shipping shader source in the product build then we're recommend using the run-time driver on the platform to generate program binaries which can be saved out and then packaged into the software, as these are guaranteed to be compatible with that specific platform, but note that these are not portable and may become invalid if the driver is updated.

    If needed we can look at the segfault; please can you provide more information such as a backtrace?

    Kind regards, 
    Pete

Reply
  • Hi Vikash, 

    In general we'd recommend not using the Mali Offline Compiler to generate shader binaries; they are not portable, requiring an exact match of GPU version and driver version, and are less efficient that full program binaries. We are actually going to remove this functionality in the next release, so the offline compiler just becomes a static analysis tool for performance analysis.

    Where possible it's highly recommended just to ship shader source code, using glGetProgramBinary() on the platform to save out compiled binaries to reduce application launch time if your platform doesn't provide automatic compilation caching.

    If you want to avoid shipping shader source in the product build then we're recommend using the run-time driver on the platform to generate program binaries which can be saved out and then packaged into the software, as these are guaranteed to be compatible with that specific platform, but note that these are not portable and may become invalid if the driver is updated.

    If needed we can look at the segfault; please can you provide more information such as a backtrace?

    Kind regards, 
    Pete

Children