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

Bye bye std::string in the GL library #499

Merged
merged 27 commits into from
Jan 2, 2023
Merged

Bye bye std::string in the GL library #499

merged 27 commits into from
Jan 2, 2023

Commits on Jan 1, 2023

  1. Configuration menu
    Copy the full SHA
    c6e627d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4f5fc0a View commit details
    Browse the repository at this point in the history
  3. GL: deduplicate & simplify DebugOutput::setCallback() internals.

    The previous callback pointer was needed just to disambiguate, so it can
    be a bool; the user pointer can be set from the caller already instead
    of being done in each variant again.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    475a748 View commit details
    Browse the repository at this point in the history
  4. GL: don't use // comments.

    Those are reserved for temporary TODOs and debugging, not meant to stay
    there forever.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    569e494 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    527a4d8 View commit details
    Browse the repository at this point in the history
  6. GL: properly test failed AbstractShaderProgram::validate().

    So far everything everywhere was just testing the success case, without
    checking that the message is properly retrieved and returned. Sigh.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    f3de392 View commit details
    Browse the repository at this point in the history
  7. GL: trim whitespace from AbstractShaderProgram::validate().

    The test added in previous commit passed on Mesa, but not on
    SwiftShader.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    e35a52e View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e933849 View commit details
    Browse the repository at this point in the history
  9. GL: port Debug{Output,Group,Message} away from std::string.

    Most of these are just inputs, so a compatibility StringStl.h include
    will do, the only exception is the callback for which there needs to
    stay a deprecated overload (which is internally delegated from the
    StringView one).
    
    Also explicitly testing with non-null-terminated strings -- the APIs
    take an explicit size so it shouldn't be a problem, but it's always good
    to have this verified independently. Drivers are crap, you know.
    
    One consequence of no longer using an impossible-to-forward-declare
    std::string is that I had to deinline the DebugGroup constructor because
    it no longer worked with just a forward-declared StringView.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    d89b882 View commit details
    Browse the repository at this point in the history
  10. Shaders: ditch the insane Phong light initializer setup.

    Do it the same as for the skinning stuff, format() and string
    multiplication. No need to get this crazy.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    2f57162 View commit details
    Browse the repository at this point in the history
  11. GL: port Shader and ShaderProgram away from std::string.

    Same as in the previous commit, most cases are inputs so a StringStl.h
    compatibility include will do, the only breaking change is
    GL::Shader::sources() which now returns a StringIterable instead of a
    std::vector<std::string> (ew).
    
    Awesome about this whole thing is that The Shader API now allows
    creating a shader from sources coming either from string view literals
    or Utility::Resource completely without having to allocate any strings
    internally, because all those can be just non-owning references wrapped
    with String::nullTerminatedGlobalView(). The only parts which aren't
    references are the #line markers, but (especially on 64bit) those can
    easily fit into the 22-byte (or 10-byte on 32bit) SSO storage.
    
    Also, various Shader constructors and assignment operators had to be
    deinlined in order to avoid having to include the String header, which
    would be needed for Array destruction during a move.
    
    Co-authored-by: Hugo Amiard <[email protected]>
    mosra and Hugo Amiard committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    db2cb49 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    18f0b31 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    b2f72c9 View commit details
    Browse the repository at this point in the history
  14. GL: drop std::pair from AbstractShaderProgram::validate() as well.

    Given that I made a breaking change by returning Containers::String
    instead of a std::string, I can take it further and replace also
    std::pair with Containers::Pair -- it won't bring any more pain to the
    users, they have to change their code anyway.
    
    Co-authored-by: Hugo Amiard <[email protected]>
    mosra and Hugo Amiard committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    d0e18e1 View commit details
    Browse the repository at this point in the history
  15. GL: drop std::pair from texture state tracker internals.

    Apparently even `= {}` was broken for std::pair once, not to mention the
    unnecessary extra overhead with this type not being trivially copyable.
    Good riddance.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    e0210a1 View commit details
    Browse the repository at this point in the history
  16. GL: drop another std::pair occurence from the internals.

    Hm, and here I used the "capability" of std::pair that allowed it to
    store references. I don't even want to know what all was involved to
    support that, Containers::Reference is much easier to reason about.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    2620eca View commit details
    Browse the repository at this point in the history
  17. GL: don't use std::pair in Context internals.

    And this, this change allows the growable Array to use malloc() instead
    of new, and thus also realloc(), saving unnecessary reallocations if the
    memory can be grown in-place. All because Containers::Pair is trivially
    copyable while std::pair wasn't.
    
    There isn't any good reason to use the STL anymore.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    468d68e View commit details
    Browse the repository at this point in the history
  18. DebugTools: port screenshot() away from std::string.

    Simple & easy, for a change.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    19ba079 View commit details
    Browse the repository at this point in the history
  19. DebugTools: port FrameProfiler away from std::string.

    One of the last remaining leftovers.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    cec3c21 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    e4f6625 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    6a2d7a4 View commit details
    Browse the repository at this point in the history
  22. Remove random unneeded <string> and StringStl.h includes.

    Or document why is it still needed.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    5d0454c View commit details
    Browse the repository at this point in the history
  23. doc: remove std::string usage from doc image generators.

    From some, at least. The easings need to wait for a growable String.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    31b77f0 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    b8cec8d View commit details
    Browse the repository at this point in the history
  25. DebugTools,Shaders,TextureTools: use string view literals everywhere.

    Mainly important for Shader::addSource() to prevent it from creating a
    needless copy, but doesn't hurt to do the same also for
    uniformLocation(), bindAttributeLocation() etc. -- it'll avoid a runtime
    strlen() in that case at least.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    3e7298f View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    9b4a813 View commit details
    Browse the repository at this point in the history
  27. package/archlinux: include also RelWithDebInfo in the dev PKGBUILD.

    Not built by default, but handy for profiling.
    mosra committed Jan 1, 2023
    Configuration menu
    Copy the full SHA
    ac03515 View commit details
    Browse the repository at this point in the history