unhandled operation nir_op_fdot3 in do_alu_action() in gallium/auxiliary/gallivm/lp_bld_nir.c

Viatcheslav Sysoltsev <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <[email protected]>
Hi,

I'm supporting a very old opengl-based programm and since latest OS update I got crash during old-style picking (through glRenderMode(GL_SELECT)). I've managed to compose quite small example with glut, it is attached. To compile and run:

> g++ test.cpp `pkgconf --cflags --libs glut glu gl` -g -O0 && a.out

When you click on the rectangle the program crashes. The stacktrace of crash is:

(gdb) bt
#0  0x00007ffff0a87432 in LLVMBuildBitCast () from /usr/lib/libLLVM-11.so
#1  0x00007ffff6146f90 in visit_alu (bld_base=<optimized out>, instr=0x5555556a3700) at ../mesa-21.1.1/src/gallium/auxiliary/gallivm/lp_bld_nir.c:1016
#2  0x00007ffff6afb1ab in visit_block (block=0x5555556964e0, block=0x5555556964e0, bld_base=0x7fffffff7a20) at ../mesa-21.1.1/src/gallium/auxiliary/gallivm/lp_bld_nir.c:2140
#3  visit_cf_list.isra.1 (bld_base=bld_base@entry=0x7fffffff7a20, list=<optimized out>, list=<optimized out>) at ../mesa-21.1.1/src/gallium/auxiliary/gallivm/lp_bld_nir.c:2200
#4  0x00007ffff611d669 in lp_build_nir_llvm (nir=<optimized out>, bld_base=0x7fffffff7a20) at ../mesa-21.1.1/src/gallium/auxiliary/gallivm/lp_bld_nir.c:2293
#5  lp_build_nir_soa (gallivm=<optimized out>, shader=<optimized out>, params=<optimized out>, outputs=<optimized out>) at ../mesa-21.1.1/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c:2443
#6  0x00007ffff60b2b00 in generate_vs (bld_mask=0x7fffffff84d0, clamp_vertex_color=1 '\001', draw_image=0x5555556bfdf0, draw_sampler=0x5555556bfd40, context_ptr=0x5555555c02c0, system_values=0x7fffffff86c0, inputs=0x7fffffff9bf0, outputs=0x7fffffff91f0, vs_type=..., builder=0x5555556a68d0, variant=0x55555568f010) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_llvm.c:973
#7  draw_llvm_generate (llvm=0x5555556e55e0, variant=<optimized out>) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_llvm.c:2287
#8  0x00007ffff60bfcf5 in draw_llvm_create_variant (key=0x7fffffffb290, num_inputs=2, llvm=0x5555556e55e0) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_llvm.c:909
#9  llvm_middle_end_prepare (middle=<optimized out>, in_prim=<optimized out>, opt=<optimized out>, max_vertices=<optimized out>) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c:399
#10 0x00007ffff6071f76 in vsplit_prepare (frontend=0x5555556cda90, in_prim=<optimized out>, middle=<optimized out>, opt=<optimized out>) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_pt_vsplit.c:229
#11 0x00007ffff6b01486 in draw_pt_arrays.isra.0 (draw=draw@entry=0x5555556b5090, prim=7, draw_info=draw_info@entry=0x7fffffffbf40, num_draws=num_draws@entry=1) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_pt.c:129
#12 0x00007ffff60617a5 in draw_instances (draw=draw@entry=0x5555556b5090, info=info@entry=0x7fffffffbf50, draws=draws@entry=0x7fffffffbf40, num_draws=num_draws@entry=1) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_pt.c:495
#13 0x00007ffff606b639 in draw_vbo (draw=0x5555556b5090, info=0x7fffffffbf50, indirect=<optimized out>, draws=0x7fffffffbf40, num_draws=1) at ../mesa-21.1.1/src/gallium/auxiliary/draw/draw_pt.c:619
#14 0x00007ffff5c44643 in st_feedback_draw_vbo (ctx=<optimized out>, prims=<optimized out>, nr_prims=<optimized out>, ib=<optimized out>, index_bounds_valid=<optimized out>, primitive_restart=<optimized out>, restart_index=<optimized out>, min_index=<optimized out>, max_index=<optimized out>, num_instances=<optimized out>, base_instance=<optimized out>) at ../mesa-21.1.1/src/mesa/state_tracker/st_draw_feedback.c:461
#15 0x00007ffff5cf12cb in _mesa_draw_gallium_fallback (ctx=0x7fffec3e6010, info=0x7fffec423270, draws=0x7fffec423298, num_draws=1) at ../mesa-21.1.1/src/mesa/main/draw.c:1004
#16 0x00007ffff5ce4713 in _mesa_draw_gallium_complex_fallback (ctx=0x7fffec3e6010, info=0x7fffec423270, draws=0x7fffec423298, mode=0x7fffec423498 "\a", base_vertex=0x0, num_draws=1) at ../mesa-21.1.1/src/mesa/main/draw.c:1087
#17 0x00007ffff5dff1ec in vbo_exec_vtx_flush (exec=0x7fffec421b60) at ../mesa-21.1.1/src/mesa/vbo/vbo_exec_draw.c:336
#18 0x00007ffff5dff565 in vbo_exec_FlushVertices_internal.part.0.lto_priv.0 (exec=0x7fffec421b60, flags=<optimized out>) at ../mesa-21.1.1/src/mesa/vbo/vbo_exec_api.c:685
#19 0x00007ffff5d4814c in vbo_exec_FlushVertices_internal (flags=1, exec=0x7fffec421b60) at ../mesa-21.1.1/src/mesa/vbo/vbo_exec_api.c:1101
#20 vbo_exec_FlushVertices (flags=1, ctx=0x7fffec3e6010) at ../mesa-21.1.1/src/mesa/vbo/vbo_exec_api.c:1119
#21 pop_matrix (stack=0x7fffec3fbc20, ctx=0x7fffec3e6010) at ../mesa-21.1.1/src/mesa/main/matrix.c:381
#22 _mesa_PopMatrix () at ../mesa-21.1.1/src/mesa/main/matrix.c:409
#23 0x00005555555555a9 in draw_block (colorInfill=16711680, x=-0.300000012, y=0, z=-2) at test.cpp:42
#24 0x000055555555560e in gl_draw () at test.cpp:54
#25 0x0000555555555873 in gl_select (x=213, y=220) at test.cpp:114
#26 0x0000555555555910 in mousedw (x=213, y=180, but=0) at test.cpp:127
#27 0x0000555555555945 in mouseClick (button=0, state=0, x=213, y=180) at test.cpp:131
#28 0x00007ffff7f187f9 in fgPlatformProcessSingleEvent () from /usr/lib/libglut.so.3
#29 0x00007ffff7f107f0 in glutMainLoopEvent () from /usr/lib/libglut.so.3
#30 0x00007ffff7f10938 in glutMainLoop () from /usr/lib/libglut.so.3
#31 0x00005555555559d3 in main (argc=1, argv=0x7fffffffe528) at test.cpp:145

Would mesa be built in debug mode, I would get assert(0) in do_alu_action (src/gallium/auxiliary/gallivm/lp_bld_nir.c:518), since the operation nir_op_fdot3 is not supported in the switch there and the function returns an uninitialized pointer. Is is a bug in Mesa, should it be reported? I haven't used opengl for over decade, so I'm quite newbie in the corner :/

// latest Archlinux, x86_64, Nvidia Quadro NVS 295 with nouveau driver. Mesa 21.1.1-1.

With best regards, Slava

_______________________________________________
mesa-users mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-users
test.cpp (text/x-c++src, 3.5 KB)
#include <GL/glut.h>

#include <stdio.h>
#include <stdlib.h>

#define SW 400
#define SH 400

void gl_init(int w, int h) {
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glViewport(0, 0, w, h);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective(60.0, 1.0, 0.0001, 1000.0);

    glMatrixMode(GL_MODELVIEW);

    GLfloat LightDiffuse[] = { 1.0, 1.0, 1.0, 1.0 };
    glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); // add lighting. (ambient)
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
    glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);
}

#define RED(c) ((c >> 16) & 0xff) * 1.0 / 256
#define GREEN(c) ((c >> 8) & 0xff) * 1.0 / 256
#define BLUE(c) ((c) & 0xff) * 1.0 / 256

void draw_block(int colorInfill, float x, float y, float z) {
    glPushMatrix();
    glTranslatef(x, y, z);
    glColor3f(RED(colorInfill), GREEN(colorInfill), BLUE(colorInfill));
    glBegin(GL_QUADS);
    glVertex2f(0.0, 0.0);
    glVertex2f(1.0, 0.0);
    glVertex2f(1.0, 1.0);
    glVertex2f(0.0, 1.0);
    glEnd();
    glPopMatrix();
}

void gl_draw() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(0.0, 0.0, -5.0);

    glLoadName(7);
    draw_block(0xff0000, -0.3, 0, -2);

    glLoadName(14);
    draw_block(0x00ff00, 0, 0, -4);

    glLoadName(21);
    draw_block(0x0000ff, 0.3, 0, -6);

    glutSwapBuffers();
}

void list_hits(GLint hits, GLuint *names) {
    int i;

    /*
	For each hit in the buffer are allocated 4 bytes:
	1. Number of hits selected (always one,
				    because when we draw each object
				    we use glLoadName, so we replace the
				    previous name in the stack)
	2. Min Z
	3. Max Z
	4. Name of the hit (glLoadName)
    */

    printf("%d hits:\n", hits);

    for (i = 0; i < hits; i++)
        printf("Number: %d\n"
               "Min Z: %d\n"
               "Max Z: %d\n"
               "Name on stack: %d\n",
               (GLubyte) names[i * 4],
               (GLubyte) names[i * 4 + 1],
               (GLubyte) names[i * 4 + 2],
               (GLubyte) names[i * 4 + 3]
        );

    printf("\n");
}

void gl_select(int x, int y) {
    GLuint buff[64] = {0};
    GLint hits, view[4];
    int id;

    glSelectBuffer(64, buff);
    glGetIntegerv(GL_VIEWPORT, view);
    glRenderMode(GL_SELECT);
    glInitNames();
    glPushName(0);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    /* restrict the draw to an area around the cursor */
    gluPickMatrix(x, y, 1.0, 1.0, view);
    gluPerspective(60, 1.0, 0.0001, 1000.0);

    glMatrixMode(GL_MODELVIEW);
    gl_draw();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

    hits = glRenderMode(GL_RENDER);

    list_hits(hits, buff);

    glMatrixMode(GL_MODELVIEW);
}

void mousedw(int x, int y, int but) {
    printf("Mouse button %d pressed at %d %d\n", but, x, y);
    gl_select(x, SH - y); //Important: gl (0,0) ist bottom left but window coords (0,0) are top left so we have to change this!
}

void mouseClick(int button, int state, int x, int y) {
    if ((button == GLUT_LEFT_BUTTON) && (state == GLUT_DOWN)) { mousedw(x, y, button); }
}

int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    glutInitWindowSize(SW, SH);
    glutInitWindowPosition(0, 0);
    glutCreateWindow(argv[0]);
    glutDisplayFunc(gl_draw);
    glutMouseFunc(mouseClick);

    gl_init(SW, SH);

    glutMainLoop();

    return EXIT_SUCCESS;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.