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

Using Filament with shared context exits with BadMatch on Linux #1453

Closed
roxlu opened this issue Jul 30, 2019 · 5 comments · Fixed by #1456
Closed

Using Filament with shared context exits with BadMatch on Linux #1453

roxlu opened this issue Jul 30, 2019 · 5 comments · Fixed by #1456
Assignees
Labels
linux Issue/feature request for Linux only

Comments

@roxlu
Copy link
Contributor

roxlu commented Jul 30, 2019

Describe the bug

I'm embedding Filament into an GLFW based application on Linux (Linux arch680 5.2.1-arch1-1-ARCH #1 SMP PREEMPT Sun Jul 14 14:52:52 UTC 2019 x86_64 GNU/Linux). When sharing the GL context that's created by GLFW the application exists with a BadMatch error, see this output.

To Reproduce

I should create a test repository... hopefully I've got time to do that, but for now:

  1. Compile filament as described in the readme.
  2. Create a simple GLFW app.
  3. Initialize filament like in this test app.
  4. Run the application.

Expected behavior

A GLFW app that renders a triangle via Filament. I'm still diving into the code / documentation on how to correctly initialize and use filament in GLFW. I based my code on this example.

Desktop (please complete the following information):

  • OS: Arch Linux
  • GPU: NVIDIA GTX 960
  • Backend: OpenGL

Additional Info

I think the BadMatch is caused because the GL context is created with a GLXFBConfig that doesn't match with the GLXFBConfig of the shared GL context. I've updated PlatformGLX.cpp in such a way that it uses the GLXFBConfig from the shared GL context when it was given by the user.

@roxlu roxlu changed the title Using Filament with GLFW and shared context exists with BadMatch on Linux Using Filament with GLFW and shared context exits with BadMatch on Linux Jul 30, 2019
@prideout
Copy link
Contributor

Hi @roxlu, this isn't an issue specific to GLFW, it's more of a feature request for our context creation strategy on X to be more flexible. Your tentative modifications to PlatformGLX.cpp seem reasonable to me; by querying the shared context, we can create a matching one.

Curious what others on the team will think. Can you make a pull request? That way it will be easier for my colleagues to look over your changes.

@prideout prideout self-assigned this Jul 30, 2019
@prideout prideout added the linux Issue/feature request for Linux only label Jul 30, 2019
@romainguy
Copy link
Collaborator

This is tricky because arbitrary user configs may not work. We could document what Filament expects.

@prideout
Copy link
Contributor

Good point, Filament doesn't really care if they have stencil or depth but we do require an OpenGL 4.1 context.

@roxlu, with GLFW you should be able to set up context-related window creation hints to create a compatible context. Check it out:

https://www.glfw.org/docs/latest/window_guide.html#window_hints_ctx

Try setting GLFW_CONTEXT_VERSION_MAJOR to 4 and GLFW_CONTEXT_VERSION_MINOR to 1.

@prideout
Copy link
Contributor

Note that GLFW_SAMPLES should be 1, (Filament does AA in an offscreen buffer.)

@roxlu
Copy link
Contributor Author

roxlu commented Jul 30, 2019

@prideout

Thanks for your feedback. I created this pull request, please let me know if I'm doing this correctly.

Try setting GLFW_CONTEXT_VERSION_MAJOR to 4 and GLFW_CONTEXT_VERSION_MINOR to 1.
Note that GLFW_SAMPLES should be 1, (Filament does AA in an offscreen buffer.)

Yes I was using those indeed:

  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
  glfwWindowHint(GLFW_SAMPLES, 1);

When I use these glfwWindowHints I'm getting the same issue.

@romainguy and @prideout thanks, I indeed think that having a list with the required context attributes would be very useful. Also having some super tiny examples would probably make it a lot easier to get a general idea how Filament works. The current documentation is amazing, but I'm talking more about guides/styles that speed up the process of learning how to use Filament.

@roxlu roxlu changed the title Using Filament with GLFW and shared context exits with BadMatch on Linux Using Filament with shared context exits with BadMatch on Linux Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Issue/feature request for Linux only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants