GithubHelp home page GithubHelp logo

Cant run minimal example about pegl HOT 6 CLOSED

mreyarea-fy avatar mreyarea-fy commented on September 13, 2024
Cant run minimal example

from pegl.

Comments (6)

perey avatar perey commented on September 13, 2024

Thanks for the report!

It would appear that choose_config isn't finding any configs that support OpenGL ES. (In this case, IndexError basically means, "You asked for the first item in a list with no items!") You can replace dpy.choose_config(...) with dpy.get_configs(), which gets all configs without trying to filter them.

Could you run the following code for me and report the results?

import pegl, platform
print('Python', platform.python_version(), 'on', platform.platform(terse=True))
dpy = pegl.Display()
print('EGL version:', dpy.version_string, 'by', dpy.vendor)
all_configs = dpy.get_configs()
print('Configs available:', len(all_configs))
if len(all_configs) > 0:
    cfg = all_configs[0]
    print('The first config...')
    print('\tAPIs supported:', cfg.renderable_type)
    print(f'\tColor buffer: {cfg.buffer_size}-bit', cfg.color_buffer_type.name)
else:
    print('What kind of EGL implementation offers no configurations, anyway?!')

For comparison, here's the results on the computer I'm currently at:

Python 3.10.5 on Linux-5.18.10-100.fc35.x86_64-x86_64-with-glibc2.34
EGL version: 1.5 by Mesa Project
Configs available: 64
The first config...
APIs supported: ClientAPIFlag.OPENGL_ES3|OPENGL|OPENGL_ES2|OPENGL_ES
Color buffer: 32-bit RGB

from pegl.

mreyarea-fy avatar mreyarea-fy commented on September 13, 2024

I get something pretty similar. Sorry I am not too familiar with this. Do not even know what configurations are! :').

Python 3.7.13 on Linux-5.13.0-52-generic-x86_64-with-glibc2.17
EGL version: 1.5 by NVIDIA
Configs available: 65
The first config (which in theory should be the most capable)...
	APIs supported: ClientAPIFlag.OPENGL_ES3|OPENGL|OPENGL_ES2|OPENGL_ES
	Color buffer: 32-bit RGB

from pegl.

mreyarea-fy avatar mreyarea-fy commented on September 13, 2024

Ok so I tried on my own laptop with integrated GPU that uses Mesa and it works. I am wondering if I can choose which vendor I want to use EGL from? Instead of NVIDIA I could choose Mesa, although it might come with decrease in rendering speeds?

from pegl.

perey avatar perey commented on September 13, 2024

Well, colour me confused. choose_config isn't finding any configs that support OpenGL ES, but the first available config supports OpenGL ES? Weird. I think I might have to chalk this one up to Nvidia's EGL implementation doing peculiar things.

To resolve the issue in your specific case, I'd suggest replacing the offending line with one of the following:

# 1) Request configs that meet given requirements, but don't make API support
# one of the requirements. This one says a 32-bit colour buffer is required,
# but that's just for the sake of an example.
conf = dpy.choose_config({pegl.ConfigAttrib.BUFFER_SIZE: 32})[0]

# 2) Request configs that meet given requirements... and don't actually set any.
conf = dpy.choose_config({})[0]

# 3) Just grab the first available config and hope it works!
conf = dpy.get_configs(1)[0]

Do not even know what configurations are! :').

They're basically sets of graphics capabilities: "my program wants to use OpenGL ES 2 instructions to render into a 16-bit colour buffer that uses at least 1 bit for alpha", that sort of thing.

I'd say you can browse the Pegl documentation for an explanation, but at present you'd have to build it yourself (clone repo, cd docs, make html), or else read the reStructuredText source. Putting it online somewhere like Read the Docs is planned (issue #8).

Even then, it's all written by me based on my own understanding and is in no way authoritative! You can check out the EGL specification for the official details; configs are covered in section 3.4.

(Incidentally, looking that up has made me realise I mis-remembered how configs are sorted. Contrary to my off-hand comment in the test code earlier, the first config returned is not likely to be the most capable, but rather the reverse: it's likely to be the bare minimum that meets the given requirements. I'm just noting this here for my own reference, and for the sake of anyone who comes reading this issue later.)

I am wondering if I can choose which vendor I want to use EGL from? Instead of NVIDIA I could choose Mesa, although it might come with decrease in rendering speeds?

This may be possible, but I'm afraid I don't know whether, or how well, it would work. You would need to make sure Mesa's EGL implementation is installed (something like mesa-libEGL in your system's repositories), and then convince Pegl to talk to it rather than the Nvidia one. But on typical Linux systems, this appears to be managed by libglvnd, and how to force that to do your bidding is beyond me. ☹️

from pegl.

mreyarea-fy avatar mreyarea-fy commented on September 13, 2024

Thanks for the explanation.

Some updates. Following this tutorial from NVIDIA I was able to solve it. Basically, the default single attribute {pegl.ConfigAttrib.RENDERABLE_TYPE: pegl.ClientAPIFlag.OPENGL_ES} is not enough for nvidia requirements. The set of configuration attributes that worked for me were:

attribs = {pegl.ConfigAttrib.SURFACE_TYPE: pegl.SurfaceTypeFlag.PBUFFER,
           pegl.ConfigAttrib.BLUE_SIZE: 8,
           pegl.ConfigAttrib.GREEN_SIZE: 8,
           pegl.ConfigAttrib.RED_SIZE: 8,
           pegl.ConfigAttrib.DEPTH_SIZE: 8,
           pegl.ConfigAttrib.RENDERABLE_TYPE: pegl.ClientAPIFlag.OPENGL_ES_BIT}

Then, I bind pegl.ClientAPI.OPENGL as API and, voilà!

from pegl.

perey avatar perey commented on September 13, 2024

Excellent! I'm glad you were able to find a solution.

I still find it strange that they need all of that information (the EGL spec defines default search behaviour for when it's not supplied), but oh well.

from pegl.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.