moderngl.error.Error: Ошибка компилятора GLSL - PullRequest
0 голосов
/ 04 апреля 2020

Я запустил этот код OpenGL (EGL и GLES), используя C в кластере, и он работал отлично. Сейчас я пытаюсь перенести этот код на Python, используя moderngl с egl backend. Когда я запускаю свой код, я получаю следующую ошибку:

libGL error: MESA-LOADER: malformed or no PCI ID
libGL error: unable to load driver: mali_drm_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: mali_drm
Traceback (most recent call last):
  File "main_vec_add.py", line 7, in <module>
    ferb_init()
  File "/home/fa/FYP_Code/ferb_master.py", line 16, in ferb_init
    gpu_init()
  File "/home/fa/FYP_Code/ferb_gpu.py", line 53, in gpu_init
    ''',
  File "/home/fa/berryconda3/lib/python3.6/site-packages/moderngl/context.py", line 861, in program
    varyings
moderngl.error.Error: GLSL Compiler failed

fragment_shader
===============
0:3(2): error: illegal use of reserved word `precision'
0:3(2): error: syntax error, unexpected ERROR_TOK

Я использую шейдер #version 120, так как #version 330 не поддерживается моей системой.

vertex_shader
=============
0:2(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, and 1.20

Здесь мой код:

vao = {}
prog_array = {}
vbo = None
fbo = None

def gpu_init():
    global vao
    global prog_array
    global vbo
    global fbo

    ctx = moderngl.create_context(standalone=True,
    backend='egl',
    libgl='libGL.so.1',
    libegl='libEGL.so.1',
    ) 
    fbo = ctx.simple_framebuffer((1000, 2), components=4)
    fbo.use()
    ctx.viewport = (0, 0, 1000, 2)
    ctx.clear(0.0, 0.0, 0.0, 1.0)

    prog_array[0] = ctx.program(
                vertex_shader='''
                            #version 330
                            attribute vec4 vPosition;

                            void main() {
                                gl_Position = vPosition;
                            }
                            ''',
                fragment_shader='''
                            #version 330
                            precision highp float;
                            uniform float Aarr[1000];
                            uniform float Barr[1000];

                            vec4 EncodeRangeV4(float value, float minVal, float maxVal) {
                                value        = clamp( (value-minVal) / (maxVal-minVal), 0.0, 1.0 );
                                value       *= 0.99999994039;
                                vec4 encode  = fract( value * vec4(1.0, 256.0, 65536.0, 16777216.0) );
                                return vec4( encode.xyz - encode.yzw / 256.0, encode.w );
                            }

                            void main() {
                                int my_index = int(gl_FragCoord[0]);
                                float result = Aarr[my_index] + Barr[my_index];
                                gl_FragColor = EncodeRangeV4(result, -512.0, 512.0) - (1.0/1300.0);
                            }
                        ''',
                    )
...