|
I have the code below in my java application. I am trying to run this application on a headless ubuntu 18.04 server with nvidia tesla v100 GPUs. Currently the only way I can get this to run successfully is if I have Xvfb running a virtual display. But the code isn't actually using the nvidia GPU's. when I print out vendor and renderer info I get "VMware, Inc." and
"llvmpipe (LLVM 9.0, 256 bits)"... I've done some reading and I should not even have to have Xvfb running if EGL driver is being used but I can't get my code to run without Xvfb. How can I use/properly setup JOGL with EGL driver?
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
caps.setHardwareAccelerated(true);
caps.setAlphaBits(8);
caps.setRedBits(8);
caps.setBlueBits(8);
caps.setGreenBits(8);
caps.setOnscreen(false);
GLDrawableFactory factory = EGLDrawableFactory.getEGLFactory();
GLAutoDrawable drawable = factory.createOffscreenAutoDrawable(factory.getDefaultDevice(), caps, new DefaultGLCapabilitiesChooser(), 943, 468);
drawable.display();
drawable.getContext().makeCurrent();
GL3bc gl = drawable.getGL().getGL3bc();
gl.glEnable(GL_PROGRAM_POINT_SIZE);
gl.glEnable(GL2ES1.GL_POINT_SPRITE);
System.out.println(gl.glGetString(GL.GL_VENDOR));
System.out.println(gl.glGetString(GL.GL_RENDERER));
program = new Program(gl, Constant.EMPTY, "hello-triangle", "hello-triangle");
int positionAttributeLocation = gl.glGetAttribLocation(program.getName(), "a_position");
int resolutionUniformLocation = gl.glGetUniformLocation(program.getName(), "u_resolution");
FloatBuffer locationsBuffer = GLBuffers.newDirectFloatBuffer(locations);
gl.glGenBuffers(Buffer.MAX, bufferName);
gl.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX));
gl.glBufferData(GL_ARRAY_BUFFER, locationsBuffer.capacity() * Float.BYTES, locationsBuffer, GL_STATIC_DRAW);
gl.glViewport(0, 0, 943, 468);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClear(GL_COLOR_BUFFER_BIT);
gl.glUseProgram(program.getName());
gl.glEnableVertexAttribArray(positionAttributeLocation);
gl.glVertexAttribPointer(positionAttributeLocation, 2, GL_FLOAT, false, 0, 0);
gl.glUniform2f(resolutionUniformLocation, 943, 468);
gl.glDrawArrays(GL_POINTS, 0, (locations.length / 2));
|