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

Copy GLXFBConfig from shared context. #1456

Conversation

roxlu
Copy link
Contributor

@roxlu roxlu commented Jul 30, 2019

Fixes #1453

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@romainguy romainguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I left a bunch of comments that are mostly style related.

@@ -46,6 +46,11 @@ struct GLXFunctions {
PFNGLXCREATEPBUFFERPROC createPbuffer;
PFNGLXDESTROYPBUFFERPROC destroyPbuffer;
PFNGLXMAKECONTEXTCURRENTPROC setCurrentContext;

PFNGLXQUERYCONTEXTPROC queryContext; /* When creating a shared GL context, we query the used GLX_FBCONFIG_ID to make sure our display framebuffer attributes match; otherwise making our context current results in a BadMatch https://gist.github.com/roxlu/c282d642c353ce96ef19b6359c741bcb */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our code style limits a line width to 100 characters. Can you move those comments above the definitions and use multiple lines wrapped at 80 or 100 columns please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// Create a context
static int attribs[] = { GLX_DOUBLEBUFFER, True, None };
if (nullptr != sharedGLContext) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (nullptr != sharedGLContext) {

int r = -1;
int used_fb_id = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camelCase to name variables. The existing code makes the same mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

GLXContext shared_ctx = (GLXContext)((void*)sharedGLContext);

r = g_glx.queryContext(mGLXDisplay, shared_ctx, GLX_FBCONFIG_ID, &used_fb_id);
if (0 != r) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (r != 0) or if (r) if you prefer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


r = g_glx.queryContext(mGLXDisplay, shared_ctx, GLX_FBCONFIG_ID, &used_fb_id);
if (0 != r) {
printf("Error: failed to get GLX_FBCONFIG_ID from shared GL context.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't printf, use utils::slog.* (utils::slog.e << "Error: …" in this case)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed this. The first check on if(mGLXDisplay == nullptr) from the existing code uses printf(). I've changed this into utils::slog.e too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

int num_configs = 0;
GLXFBConfig* fb_configs = g_glx.getFbConfigs(mGLXDisplay, 0, &num_configs);

if (nullptr == fb_configs) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the order of the test, or just use !fbConfigs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

for (int i = 0; i < num_configs; ++i) {

r = g_glx.getFbConfigAttrib(mGLXDisplay, fb_configs[i], GLX_FBCONFIG_ID, &fb_id);
if (0 != r) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (mGLXConfig == nullptr || config_count == 0) {
int config_count = 0;
mGLXConfig = g_glx.chooseFbConfig(mGLXDisplay, DefaultScreen(mGLXDisplay),
attribs, &config_count);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continuation indents are 8 spaces in our code base, we don't align parameters in this way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

filament/backend/src/opengl/PlatformGLX.cpp Outdated Show resolved Hide resolved
roxlu added 2 commits July 31, 2019 11:36
…f github.com:roxlu/filament into rox/feature-glx-copy-fbconfig-from-shared-gl-context
Copy link
Collaborator

@romainguy romainguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@romainguy
Copy link
Collaborator

I'll wait for the CI builds to turn green before merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Filament with shared context exits with BadMatch on Linux
4 participants