Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • solarus solarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 222
    • Issues 222
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Solarus Games
  • solarussolarus
  • Issues
  • #1437

Closed
Open
Created Nov 13, 2019 by Hugo Hromic@hhromicOwner

Shaders do not compile when using OpenGLES 3.0 in RPI

On RPI devices using KMS/DRM and the Mesa driver configured for OpenGL ES 3.0, Solarus fails to compile the default shaders:

[Solarus] [0] Info: Compilation result of vertex shader '':
0:1(10): error: GLSL 3.00 is not supported. Supported versions are: 1.00 ES, and 3.00 ES

[Solarus] [0] Error: Failed to compile vertex shader ''
[Solarus] [0] Info: Compilation result of fragment shader '':
0:1(10): error: GLSL 3.00 is not supported. Supported versions are: 1.00 ES, and 3.00 ES

[Solarus] [0] Error: Failed to compile fragment shader ''
[Solarus] [0] Info: Linking result of shader '':
error: no shaders attached to the program

The first problem seems to be that the computed version string to be passed to the shader compiler is 300 instead of 300 es as suggested by this Wikipedia article.

However after quickly fixing this in Shader.cpp, we now get the following compilation error for the default fragment shader:

[Solarus] [0] Info: Compilation result of fragment shader '':
0:5(1): error: No precision specified in this scope for type `vec4'

[Solarus] [0] Error: Failed to compile fragment shader ''
[Solarus] [0] Info: Linking result of shader '':
error: program lacks a fragment shader

[Solarus] [0] Error: Failed to link shader '':

This second problem seems to be caused because the default fragment shader program is defining the precision after declaring the out vec4 FragColor variable:

static const std::string source =
R"(#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
precision mediump float;
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

Moving the precision definition before the declaration of FragColor seems to fix the shader compilation problem altogether and all seems to be working fine for both GLES 2.0 and GLES 3.0.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking