-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Copy GLXFBConfig from shared context. #1456
Conversation
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
There was a problem hiding this 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 */ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments above
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…f github.com:roxlu/filament into rox/feature-glx-copy-fbconfig-from-shared-gl-context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I'll wait for the CI builds to turn green before merging this. |
Fixes #1453