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

Query GL extensions by enum instead of strings #25024

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sarbes
Copy link
Member

@sarbes sarbes commented Apr 20, 2024

Description

The PR changes the way to query for GL/GLES extensions. We can now query for an enum, instead of doing string compares.

Maybe there is a better way to implement it, but this approach looks reasonable to me. I'd like to hear if someone has some input.

Motivation and context

String compares are somewhat expensive. Some might be queried pretty often, so keeping track of what is supported might be better in terms of performance.

How has this been tested?

Compiles fine for GL/GLES. Runs fine.

What is the effect on users?

Almost none; except a tiny, tiny performance increase.

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)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • 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

@sarbes sarbes added v22 "P" Type: Improvement non-breaking change which improves existing functionality Component: GL rendering Component: GLES rendering labels Apr 20, 2024
@sarbes sarbes added this to the "P" 22.0 Alpha 1 milestone Apr 20, 2024
Copy link
Contributor

@lrusak lrusak left a comment

Choose a reason for hiding this comment

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

I'm not really sold on this idea. The problem is that it brings GL specifics into the base class. This problem may already exist (I didn't check) but we should avoid bloating the base class.

It may be a better idea to adjust the existing methods. For example we could tokenize the existing extension list and use std::unordered_map to cache the access. The hash lookup is likely less expensive than the string compare (sic).

@@ -140,4 +145,5 @@ class CRenderSystemGLES : public CRenderSystemBase
ShaderMethodGLES m_method = ShaderMethodGLES::SM_DEFAULT;

GLint m_viewPort[4];
std::map<GLEXTENSIONS::EXTENSION, bool> m_extensionMap{};
Copy link
Contributor

Choose a reason for hiding this comment

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

std::unordered_map


struct GLEXTENSIONS
{
enum EXTENSION
Copy link
Contributor

Choose a reason for hiding this comment

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

This email and values don't follow the normal conventions https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#83-enums

@@ -39,6 +40,7 @@ class CRenderSystemBase
virtual void PresentRender(bool rendered, bool videoLayer) = 0;
virtual bool ClearBuffers(UTILS::COLOR::Color color) = 0;
virtual bool IsExtSupported(const char* extension) const = 0;
virtual bool IsExtSupported(const GLEXTENSIONS::EXTENSION extension) { return false; }
Copy link
Contributor

Choose a reason for hiding this comment

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

This somewhat breaks abstraction by putting derived class specifics into the base class. I would think extensions would exist for the base class.

It is possible to get rid of this and cast winSystem where needed.

CRenderSystemBaseand CWindowSystemBase seem to be a dumping ground for non abstract methods.

@jenkins4kodi jenkins4kodi added the Rebase needed PR that does not apply/merge cleanly to current base branch label Jun 1, 2024
@jenkins4kodi
Copy link
Contributor

@sarbes this needs a rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: GL rendering Component: GLES rendering Rebase needed PR that does not apply/merge cleanly to current base branch Type: Improvement non-breaking change which improves existing functionality v22 "P"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants