Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triangles do not appear in headless-rendering on Ubuntu #369

Closed
yshhrknmr opened this issue Jan 15, 2020 · 18 comments
Closed

Triangles do not appear in headless-rendering on Ubuntu #369

yshhrknmr opened this issue Jan 15, 2020 · 18 comments

Comments

@yshhrknmr
Copy link

yshhrknmr commented Jan 15, 2020

Description

With reference to the following URLs, I wrote some headless-rendering codes. The codes worked on Windows 10, but didn't on Ubuntu 16.04. It seems that ctx.clear() works but vao.render() doesn't.

Proof of code

Here's a short version of my headless-rendering code:

http://kanamori.cs.tsukuba.ac.jp/tmp/moderngl/sample.py

$ export DISPLAY=:99.0
$ Xvfb :99 -screen 0 640x480x24 &
$ python sample.py

yields the following white image:

http://kanamori.cs.tsukuba.ac.jp/tmp/moderngl/output_ubuntu.png

Expected behavior

On Windows 10, I got the following image as expected.

http://kanamori.cs.tsukuba.ac.jp/tmp/moderngl/output_windows.png

Version info

$ python -m moderngl
moderngl 5.5.4
--------------
vendor: VMware, Inc.
renderer: llvmpipe (LLVM 6.0, 256 bits)
version: 3.3 (Core Profile) Mesa 18.0.5
python: 3.6.6 (default, Jul 23 2018, 14:41:45)
[GCC 5.4.0 20160609]
platform: linux
code: 330

Here's also a log of glxinfo:

http://kanamori.cs.tsukuba.ac.jp/tmp/moderngl/glxinfo_dump.txt

@einarf
Copy link
Member

einarf commented Jan 15, 2020

Do you see any gl errors (appart from right after context creation). You can query for errors with ctx.error.

@yshhrknmr
Copy link
Author

yshhrknmr commented Jan 15, 2020

Thanks for your comment. Yes, after the line,

prog['mvp'].write((proj * lookat).astype('f4').tobytes())

I got GL_INVALID_OPERATION.

@einarf
Copy link
Member

einarf commented Jan 15, 2020

Does that mean you get something rendered by dropping the mvp uniform? (in shader and python)

WIthout the mvp in the shader, I do get:
output

Still, you should not get GL_INVALID_OPERATION. Did you call ctx.error right after context creation first, then narrow down the line triggering the error?

There might still be an issue here. Just trying to narrow it down.

@yshhrknmr
Copy link
Author

yshhrknmr commented Jan 15, 2020

I added many error-checking codes

print(ctx.error)

before and after each ctx call, and confirmed that GL_INVALID_OPERATION occurs only after prog['mvp'] = ....

I also omitted the line prog['mvp'] = ... as you did, and I got no errors, but the result was without a triangle, with only white background.

@einarf
Copy link
Member

einarf commented Jan 15, 2020

Did you also remove the uniform from the shader code? Sorry about the details here, just need to narrow it down.

@yshhrknmr
Copy link
Author

yshhrknmr commented Jan 15, 2020

Did you also remove the uniform from the shader code?

Sorry, I misunderstood. Now I also deleted mvp from the shader code, and got a triangle!
But, note that this is just a toy example, and I need mvp for my other shader codes.

@einarf
Copy link
Member

einarf commented Jan 15, 2020

Just to sanity check the uniform, you could output its details. Then we'd know if it's the program inspection or the uniform itself. I do suspect this might be related to something outside of moderngl.

mvp = prog['mvp']
print('name', mvp.name)
print('location', mvp.location)
print('dimension', mvp.dimension)
print('array_length', mvp.array_length)
print('value', mvp.value)

outputs

name mvp
location 0
dimension 16
array_length 1
value (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)

I would also make sure the same version of pyrr and numpy are used on both systems to be sure. I can try to spin up a VM.

@yshhrknmr
Copy link
Author

My result was the same:

name mvp
location 0
dimension 16
array_length 1
value (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)

The versions of pyrr and numpy are:

>>> import numpy
>>> numpy.__version__
'1.17.4'
>>> import pyrr
>>> pyrr.__version__
'0.10.3'

python -m moderngl says as if I were using a VM but I don't actually.

@einarf
Copy link
Member

einarf commented Jan 16, 2020

@cprogrammer1994 Have any input on this one if you're not too busy?

@szabolcsdombi
Copy link
Member

Uniforms are read or set with some non 3.3 core function if I remember correctly (must check)
even older drivers with really old HW had those at hand, but still it can happen the driver on your side does not have these functions.

setting the uniforms require glProgramUniform to be implemented despite 3.3 core is requested.

Please check with some other libraries if the glProgramUniform is present and !working!

glProgramUniform was used to avoid per uniform setter program binding. it was tested on virtual machines with no GPU support

@einarf
Copy link
Member

einarf commented Jan 19, 2020

Works for me on ubuntu 19 with llvmpipe driver 9.0

@yshhrknmr
Copy link
Author

yshhrknmr commented Jan 21, 2020

@cprogrammer1994 Thank you very much for your comment. But may I ask you how I can confirm whether glProgramUniform is supported with my current driver (Mesa 18.0.5)? For example, should I write a C++ code?

@einarf
Copy link
Member

einarf commented Jan 21, 2020

To add more info about a working setup (Ubuntu 19.04 or 19.10). It may work better out of the box with ubuntu 18 as well.

vendor: VMware Inc.
ModernGL: 5.5.4
renderer: llvmpipe (LVVM 8.0, 128 bits)
version: 3.3 core (Core Profile) Mesa 19.0.8

It's hard to say if it's lvvm, mesa or something else.

@einarf
Copy link
Member

einarf commented Jan 26, 2020

You can give EGL a try when we release 5.6. Very soon.
Added simple example here : https://github.com/moderngl/moderngl/blob/master/examples/headless_egl.py

@yoyonel
Copy link
Contributor

yoyonel commented Jan 29, 2020

@einarf : I send a PR on cprogrammer1994/Headless-rendering-with-python to fix scripts and some unit tests + CI.
In this PR i experiment a images comparaison with an energy computation (from wavelets analysis), pretty simple and cheap, but seems to work ^^
Maybe this technique can be a good start for ModernGL and some control quality, CI, CD, etc ...

@einarf
Copy link
Member

einarf commented Jan 31, 2020

Nice. I don't have access to that repo and I think cprogrammer1994 are fairly busy these days.

Ci stuff goes here: #377

@einarf
Copy link
Member

einarf commented Feb 3, 2020

@yshhrknmr https://moderngl.readthedocs.io/en/latest/the_guide/headless_ubunut18_server.html

Definitely works on ubuntu 18 server. Optionally you can try to install a more recent version of mesa.

@einarf
Copy link
Member

einarf commented Feb 3, 2020

Closing this as it seems like a driver issue. We've added guide in docs and updated the headless repo.

@einarf einarf closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants