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

renderer/glimp: new GL detection and selection code #478

Merged
merged 2 commits into from
Feb 23, 2022

Commits on Jun 4, 2021

  1. sdl_glimp,tr_init: rewrite the original GL selection code, improve gf…

    …xinfo
    
    This commit squashes multiple commits by illwieckz and slipher.
    
    See #478
    
    Co-authored-by: Thomas “illwieckz” Debesse <[email protected]>
    Co-authored-by: slipher <[email protected]>
    
    == Squashed commits by illwieckz
    
    :: sdl_glimp: rewrite the original GL selection code
    
    - Detect best configuration possible.
    - Try custom configuration if exists.
    - If no custom configuration or if it fails,
      load the recommended configuration if
      possible (OpenGL 3.2 core) or the best
      one available.
    - Reuse window and context when possible.
    - Display meaningful popup telling user
      OpenGL version is too low or required
      extensions are missing when that happens.
    - Rely on more return codes for GLimp_SetMode().
    - Test for negative SDL_Init return value,
      not just -1.
    
    :: sdl_glimp,tr_init: do not test all OpenGL versions unless r_glExtendedValidation is set
    
    When r_glExtendedValidation is enabled, the engine
    tests if OpenGL versions higher than 3.2 core
    are supported for logging and diagnostic purpose,
    but still requestes 3.2 core anyway. Some drivers
    may provide more than 3.2 when requesting 3.2, this
    is not our fault.
    
    :: sdl_glimp,tr_init: rewrite logging, improve gfxinfo
    
    - Move GL query for logging purpose from tr_init to sdl_glimp.
    - Do not split MODE log message.
    - Unify some log.
    - Add more debug log when building GL extension list.
    - Also increase the extensions_string length to not
      truncate the string, 4096 is not enough, there can
      be more than 6000 characters on an OpenGL 4.6 driver.
    - Also log missing extensions to make gfxinfo more useful.
    - Rewrite gfxinfo in more useful way.
    - List enabled and missing GL extensions.
    
    :: sdl_glimp: silence the GL error when querying if context
    is core on non-core implementation
    
    - Silence the error that may happen when querying if the
      OpenGL context uses core profile when core profile is not
      supported by the OpenGL implementation to begin with.
    
    For example this may happen on implementations not supporting
    higher than OpenGL 2.1, while forcing OpenGL 2.1 on
    implementations supporting higher versions including
    core profiles may not raise an error.
    
    :: sdl_glimp: make GLimp_StartDriverAndSetMode only return true on RSERR_OK
    
    - Only return true on OK, don't return true on unknown errors.
    
    :: sdl_glimp: catch errors from GLimp_DetectAvailableModes to prevent further segfault
    
    It may be possible to create a valid context that is unusable.
    
    For example the 3840×2160 resolution is too large for the
    Radeon 9700 and the Mesa r300 driver may print this error
    when the requested resolution is higher than what is supported
    by hardware:
    
    > r300: Implementation error: Render targets are too big in r300_set_framebuffer_state, refusing to bind framebuffer state!
    
    It will unfortunately return a valid but unusable context that will
    make the engine segfault when calling GL_SetDefaultState().
    
    :: sdl_glimp: flag fullscreen window as borderless when borderless is enabled
    
    Flag fullscreen window as borderless when borderless is enabled
    otherwise the window will be bordered when leaving fullscreen
    while the borderless option would be enabled.
    
    :: sdl_glimp,tr_init: remove unused depthBits
    
    :: sdl_glimp: remove SDL_INIT_NOPARACHUTE
    
    In GLimp_StartDriverAndSetMod() the SDL_INIT_NOPARACHUTE flag was
    removed from SDL_Init( SDL_INIT_VIDEO ) as this flag is now
    ignored, see https://wiki.libsdl.org/SDL_Init
    
    == Squashed commits by slipher
    
    :: Better type safety in GL detection code
    
    :: Simplify GL_ValidateBestContext duplicate loop
    
    :: GLimp_SetMode - simplify error handling
    
    :: Rework GL initialization
    
    Have GLimp_ValidateBestContext() validate both the highest-numbered
    available context (if r_glExtendedValidation is enabled), and the
    highest context that we actually want to use (at most 3.2). This means
    most of the code in GLimp_ApplyPreferredOptions can be removed because
    it was duplicating the knowledge about version preferences and the code
    for instantiating them in GLimp_ValidateBestContext.
    
    :: Also cut down on other code duplication.
    
    :: Remove dead cvar r_stencilBits
    
    :: Fix glConfig.colorBits logging
    
    - show actual not requested
    - don't log it twice at notice level
    illwieckz committed Jun 4, 2021
    Configuration menu
    Copy the full SHA
    e820efc View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2021

  1. system: enable GL 2.1 on Intel Gen 3 hardware, <3 papap

    This may not be enough to make the game run on such
    hardware anyway.
    
    The Mesa i915 driver for GMA Gen 3 disabled GL 2.1 on such
    hardware to force Google Chrome to use its CPU fallback
    that was faster but we don't implement such fallback.
    See https://gitlab.freedesktop.org/mesa/mesa/-/commit/a1891da7c865c80d95c450abfc0d2bc49db5f678
    
    Only Mesa i915 on Linux supports GL 2.1 for GMA Gen 3,
    so there is no similar tweak being required for Windows
    and macOS.
    
    Enabling those options would at least make the engine
    properly report missing extension instead of missing
    GL version, for example the Intel GMA 3100 G33 (Gen 3)
    will report missing GL_ARB_half_float_vertex extension
    instead of missing OpenGL 2.1 version.
    
    The GMA 3150 is known to have wider OpenGL support than
    GMA 3100, for example it has OpenGL version similar to
    GMA 4 on Windows while being a GMA 3 so the list of
    available GL extensions may be larger.
    
    Thanks papap and its LanPower association for the kind
    report and availability for testing.
    http://asso.lanpower.free.fr
    illwieckz committed Jul 14, 2021
    Configuration menu
    Copy the full SHA
    b15aa4e View commit details
    Browse the repository at this point in the history