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

X11: fix usage of required configuration values #15148

Merged
merged 2 commits into from Feb 10, 2019
Merged

Conversation

AlwinEsch
Copy link
Member

@AlwinEsch AlwinEsch commented Dec 27, 2018

Description

Before has Kodi checked only the EGL_NATIVE_VISUAL_ID and ignored
others. With this was e.g. on some addons the needed EGL_DEPTH_SIZE
not available.

This separates a part of IsSuitableVisual(...) into a separate function
(SuitableCheck(...)) which is checked by GetEGLConfig(...) and takes the
necessary configuration from the list.

Motivation and Context

Sit for a while because the addons which use GL to switch to the 4.0 version so that they work again and was almost senseless.

Thought all the time to have done something wrong in the rework and now found that the error lies in Kodi.

In addition, I found in the end that it was with the override KODI_GL_INTERFACE=GLX ./Kodi-x11 went and finally found that the error lies in Kodi itself.

How Has This Been Tested?

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@yol
Copy link
Member

yol commented Jan 4, 2019

@AlwinEsch Can you make the changes? IMO this should go into v18 (@MartijnKaijser) so we have working viz and screen savers on X11.

@AlwinEsch
Copy link
Member Author

Is updated.

Sit still to change the addons, unbelievably complex to convert these to the shader type :-| .

@yol
Copy link
Member

yol commented Jan 6, 2019

@FernetMenta Can you comment on why there is this custom visual selection code in GetEGLConfig (that - strictly speaking - misses some checks such as EGL_RENDERABLE_TYPE and EGL_SURFACE_TYPE) as opposed to using eglChooseConfig like in the PB code?

@FernetMenta
Copy link
Contributor

@pkerling when selecting a config for rendering to the main window GetEGLConfig returns a config that matches the native visual. Such a config has all the attributes required by Kodi core.

@yol
Copy link
Member

yol commented Jan 7, 2019

when selecting a config for rendering to the main window GetEGLConfig returns a config that matches the native visual. Such a config has all the attributes required by Kodi core.

I believe you that it does (after all it is working fine so far), but that does not really answer my question :-) Which is why eglChooseConfig is basically reimplemented here but without the priority logic and ignoring important bits such as EGL_RENDERABLE_TYPE and EGL_SURFACE_TYPE. Theoretically, you might get a config that is only suitable for GLES. And if the first config in the list that has the right visual does not fit the other criteria, we currently just bail out instead of looking for a fitting one. Fortunately, I think you will usually get a window-surface-/GL-capable RGBA8888 config first so it hasn't been a problem.

@AlwinEsch AlwinEsch force-pushed the fix-gl branch 2 times, most recently from 8540151 to 44f42e3 Compare January 10, 2019 17:19
@AlwinEsch
Copy link
Member Author

I had to add a second commit. When switching I noticed another error.

Some addons need the stuff described above, but they have always been removed by Kodi with glClear.

@AlwinEsch
Copy link
Member Author

AlwinEsch commented Jan 10, 2019

Here the difference between of second commit (screensaver.rsxs.solarwinds):

Before:
bildschirmfoto von 2019-01-10 18-40-52

After:
bildschirmfoto von 2019-01-10 18-42-02
The shadow behind

Copy link
Member

@yol yol left a comment

Choose a reason for hiding this comment

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

Few minors then I think we are good to go

xbmc/windowing/X11/GLContextEGL.h Outdated Show resolved Hide resolved
xbmc/windowing/X11/GLContextEGL.cpp Outdated Show resolved Hide resolved
}

bool CGLContextEGL::SuitableCheck(EGLDisplay& eglDisplay, EGLConfig& config)
{
if (config == EGL_NO_CONFIG)
Copy link
Member

Choose a reason for hiding this comment

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

You can move this block to IsSuitableVisual

Copy link
Member Author

Choose a reason for hiding this comment

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

Your mean to let the

  if (config == EGL_NO_CONFIG)
  {
    CLog::Log(LOGERROR, "Failed to determine egl config for visual info");
    return false;
  }

away?

Copy link
Member Author

Choose a reason for hiding this comment

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

And:

bool CGLContextEGL::IsSuitableVisual(XVisualInfo *vInfo)
{
  EGLConfig config = GetEGLConfig(m_eglDisplay, vInfo);
  if (config == EGL_NO_CONFIG)
  {
    CLog::Log(LOGERROR, "Failed to determine egl config for visual info");
    return false;
  }
  return true;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

If yes makes not direct sense, before was it only to report a failed GetEGLConfig and to prevent the further check. But now becomes everything done inside the GetEGLConfig and can report EGL_NO_CONFIG frequently.

Copy link
Member

Choose a reason for hiding this comment

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

Why should GetEGLConfig frequently report EGL_NO_CONFIG? In that case we will not get any display

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed the IsSuitableVisual call complete, where this becomes called is the GetEGLConfig called directly after.

Now think that it is a remnant of the conversion of the old CGLContextGLX where this call was necessary.

The CLog::Log(LOGERROR, "Failed to determine egl config for visual info"); should never come, only for the worst case where a "eglGetConfigs" call returns true with a empty entry in list.

Copy link
Member

Choose a reason for hiding this comment

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

Point still stands: This function is never called with EGL_NO_CONFIG, so having the log message makes no sense

@AlwinEsch AlwinEsch force-pushed the fix-gl branch 3 times, most recently from b70439b to f982588 Compare January 24, 2019 00:13
@AlwinEsch
Copy link
Member Author

jenkins build this please

@MartijnKaijser MartijnKaijser removed this from the Leia 18.0-Final milestone Jan 28, 2019
@AlwinEsch
Copy link
Member Author

How is the state to bring in? The most OpenGL related addons need this.

if (m_renderClearCnt == 0)
return;

/* make five render calls with clear to prevent mix with cached display data */
Copy link
Member

Choose a reason for hiding this comment

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

???

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's really crazy, but without that, when you start some visualizations (which used previous screen data and no "glClear") it flickers to the wild (for example, some modes in Screensaver Solar Winds)

Copy link
Member

Choose a reason for hiding this comment

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

This hack should under no circumstances go in.

I just noticed another thing: The screensavers render directly to display, right? If so, not calling glClear will not solve the problem for example on Wayland. We call eglSwapBuffers to display the content, but this is not a simple "front-back-buffer-switch" which it might have been in former times. Modern graphics drivers have multiple buffers ready and cycle through them as they see fit. Spec says: "The contents of ancillary buffers are always undefined after calling eglSwapBuffers. The contents of the color buffer are undefined if the value of the EGL_SWAP_BEHAVIOR attribute of surface is not EGL_BUFFER_PRESERVED." So the color buffer content is undefined when not calling glClear and the screensaver cannot rely on any specific content still being there.

m_eglConfig = GetEGLConfig(m_eglDisplay, vInfo);
XFree(vInfo);

if (m_eglConfig == EGL_NO_CONFIG)
{
CLog::Log(LOGERROR, "failed to get eglconfig for visual id");
CLog::Log(LOGWARNING, "failed to get matching eglconfig for visual 0x%x of the window and is not suitable", visualid);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
CLog::Log(LOGWARNING, "failed to get matching eglconfig for visual 0x%x of the window and is not suitable", visualid);
CLog::Log(LOGERROR, "failed to get suitable eglconfig for visual 0x%x", visualid);

Leave as error

@AlwinEsch AlwinEsch force-pushed the fix-gl branch 3 times, most recently from 511c6fd to e8aef1b Compare February 2, 2019 01:25
@@ -68,6 +68,9 @@ bool CGUIWindowScreensaver::OnMessage(CGUIMessage& message)

case GUI_MSG_WINDOW_INIT:
{
// override the clear colour - we must never clear fullscreen
m_clearBackground = 0;
Copy link
Member Author

@AlwinEsch AlwinEsch Feb 2, 2019

Choose a reason for hiding this comment

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

Found another way, the way before with count was really not nice.

There are also a few other places in Kodi that go that way. Also, 3D video rendering must avoid a glClear is called (over other way).

Copy link
Member

Choose a reason for hiding this comment

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

See #15148 (comment) - not calling glClear does not mean that the buffer contents are preserved.

Copy link
Member Author

@AlwinEsch AlwinEsch Feb 3, 2019

Choose a reason for hiding this comment

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

Why is it then also needed on other fullscreen places in Kodi? In a visualization I can maybe understand, this are combinated with other parts on screen and could get mixed up.

There must be somewhere and somehow a way possible.

Copy link
Member

Choose a reason for hiding this comment

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

Why is it then also needed on other fullscreen places in Kodi?

How do you know it is needed? It might just be a performance optimization (no use clearing the buffer if we draw over everything anyway) - do you have a specific place where you know that it is really necessary?

Does the complete screen content have to be copied with every render call to have it back at the next frame?

Yes and no. There are extensions that can be used instead of the often unsupported EGL_BUFFER_PRESERVED. But they will not give you the last frame, but instead an arbitrary previous frame and tell you how old it is (EGL_EXT_buffer_age) - this also works with Wayland. But it will not help with the solarwinds screensaver because I guess that it is implemented in a way that it needs the exact previous frame. Then yes, you need to copy when swapping buffers. This is also what the driver would usually do for you anyway when setting EGL_BUFFER_PRESERVED. See also e.g. https://community.arm.com/graphics/b/blog/posts/mali-performance-3-is-egl_5f00_buffer_5f00_preserved-a-good-thing

Other option is to modify solarwinds screensaver to always draw everything.

@AlwinEsch
Copy link
Member Author

Have now also tested with wayland over xbmc/screensavers.rsxs#20 and runs without problems

@AlwinEsch AlwinEsch force-pushed the fix-gl branch 2 times, most recently from 7d97867 to 40c111e Compare February 7, 2019 14:24
@AlwinEsch
Copy link
Member Author

Have removed the last commit. Must be for Leia now a separate request created?

Copy link
Member

@yol yol left a comment

Choose a reason for hiding this comment

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

Should be OK now

@yol
Copy link
Member

yol commented Feb 8, 2019

Afaik we have not branched yet, so no backport needed

Before has Kodi checked only the EGL_NATIVE_VISUAL_ID and ignored
others. With this was e.g. on a some addons the needed EGL_DEPTH_SIZE
not available.

This separates a part of IsSuitableVisual (...) into a separate function
(SuitableCheck (...)) which is checked by GetEGLConfig and takes the
necessary configuration from the list.
This calls GetEGLConfig which becomes also called direct after
the place where IsSuitableVisual is called.
@AlwinEsch AlwinEsch merged commit efb8798 into xbmc:master Feb 10, 2019
@AlwinEsch AlwinEsch deleted the fix-gl branch February 10, 2019 00:09
@Rechi Rechi added this to the Leia 18.1-rc1 milestone Feb 10, 2019
@yol
Copy link
Member

yol commented Feb 10, 2019

@AlwinEsch thanks for your persistence! happy to see the screensavers and visualizations get some love :)

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

Successfully merging this pull request may close these issues.

None yet

5 participants