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

Allow renderer choice to be stored in user configuration (and add automatic fallbacks) #5682

Merged
merged 38 commits into from Mar 21, 2023

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Mar 16, 2023

RFC

The goal here is to provide both renderer fallback logic, but also expose the renderer to the user in a way they can interact with it from game settings (or via config file for recovery, should that ever be required).

Example with user set configuration that is invalid:

[runtime] 2023-03-16 10:45:09 [verbose]: 🖼 Configuration renderer choice: Vulkan
[runtime] 2023-03-16 10:45:09 [verbose]: 🖼️ Renderer fallback order: [ Vulkan, Metal, OpenGLLegacy ]
[runtime] 2023-03-16 10:45:09 [verbose]: 🖼️ Attempting initialisation using renderer: veldrid surface: Vulkan
[runtime] 2023-03-16 10:45:09 [verbose]: Updated display mode to desktop resolution: 2560x1440@144, SDL_PIXELFORMAT_ARGB8888
[runtime] 2023-03-16 10:45:09 [verbose]: 🖼️ Renderer initialisation failed with:
[runtime] 2023-03-16 10:45:09 [verbose]: System.TypeInitializationException: The type initializer for 'Vulkan.VulkanNative' threw an exception.
[runtime] 2023-03-16 10:45:09 [verbose]: ---> System.InvalidOperationException: Could not load libvulkan.dylib
[runtime] 2023-03-16 10:45:09 [verbose]: at Vulkan.NativeLibrary..ctor(String libraryName)
[runtime] 2023-03-16 10:45:09 [verbose]: at Vulkan.NativeLibrary.UnixNativeLibrary..ctor(String libraryName)
[runtime] 2023-03-16 10:45:09 [verbose]: at Vulkan.NativeLibrary.Load(String libraryName)
[runtime] 2023-03-16 10:45:09 [verbose]: at Vulkan.VulkanNative.LoadNativeLibrary()
[runtime] 2023-03-16 10:45:09 [verbose]: at Vulkan.VulkanNative..cctor()
[runtime] 2023-03-16 10:45:09 [verbose]: --- End of inner exception stack trace ---
[runtime] 2023-03-16 10:45:09 [verbose]: at Veldrid.Vk.VulkanUtil.EnumerateInstanceLayers()
[runtime] 2023-03-16 10:45:09 [verbose]: at Veldrid.Vk.VkGraphicsDevice.CreateInstance(Boolean debug, VulkanDeviceOptions options)
[runtime] 2023-03-16 10:45:09 [verbose]: at Veldrid.Vk.VkGraphicsDevice..ctor(GraphicsDeviceOptions options, Nullable`1 scDesc, VulkanDeviceOptions vkOptions)
[runtime] 2023-03-16 10:45:09 [verbose]: at Veldrid.Vk.VkGraphicsDevice..ctor(GraphicsDeviceOptions options, Nullable`1 scDesc)
[runtime] 2023-03-16 10:45:09 [verbose]: at Veldrid.GraphicsDevice.CreateVulkan(GraphicsDeviceOptions options, SwapchainDescription swapchainDescription)
[runtime] 2023-03-16 10:45:09 [verbose]: at osu.Framework.Graphics.Veldrid.VeldridRenderer.Initialise(IGraphicsSurface graphicsSurface) in /Users/dean/Projects/osu-framework/osu.Framework/Graphics/Veldrid/VeldridRenderer.cs:line 146
[runtime] 2023-03-16 10:45:09 [verbose]: at osu.Framework.Graphics.Rendering.Renderer.osu.Framework.Graphics.Rendering.IRenderer.Initialise(IGraphicsSurface graphicsSurface) in /Users/dean/Projects/osu-framework/osu.Framework/Graphics/Rendering/Renderer.cs:line 171
[runtime] 2023-03-16 10:45:09 [verbose]: at osu.Framework.Platform.GameHost.setupRendererAndWindow(String renderer, GraphicsSurfaceType surfaceType) in /Users/dean/Projects/osu-framework/osu.Framework/Platform/GameHost.cs:line 897
[runtime] 2023-03-16 10:45:09 [verbose]: 🖼️ Attempting initialisation using renderer: veldrid surface: Metal
[runtime] 2023-03-16 10:45:09 [verbose]: Updated display mode to desktop resolution: 2560x1440@144, SDL_PIXELFORMAT_ARGB8888
[runtime] 2023-03-16 10:45:09 [verbose]: Metal Initialized
[runtime] 2023-03-16 10:45:09 [verbose]: Metal Feature Set: macOS GPU family 2 (v1)
[runtime] 2023-03-16 10:45:09 [verbose]: 🖼️ Renderer initialised!

Legacy example:

[runtime] 2023-03-16 10:45:45 [verbose]: 🖼 Configuration renderer choice: OpenGLLegacy
[runtime] 2023-03-16 10:45:45 [verbose]: 🖼️ Renderer fallback order: [ OpenGLLegacy ]
[runtime] 2023-03-16 10:45:45 [verbose]: 🖼️ Attempting initialisation using renderer: gl surface: OpenGL
[runtime] 2023-03-16 10:45:45 [verbose]: Updated display mode to desktop resolution: 2560x1440@144, SDL_PIXELFORMAT_ARGB8888
[runtime] 2023-03-16 10:45:45 [verbose]: GL Initialized
[runtime] 2023-03-16 10:45:45 [verbose]: GL Version:                 4.1 ATI-4.9.51
[runtime] 2023-03-16 10:45:45 [verbose]: GL Renderer:                AMD Radeon Pro 580X OpenGL Engine
[runtime] 2023-03-16 10:45:45 [verbose]: GL Shader Language version: 4.10
[runtime] 2023-03-16 10:45:45 [verbose]: GL Vendor:                  ATI Technologies Inc.
[runtime] 2023-03-16 10:45:45 [verbose]: GL Extensions:              GL_ARB_blend_func_extended GL_ARB_draw_buffers_blend GL_ARB_draw_indirect GL_ARB_ES2_compatibility GL_ARB_explicit_attrib_location GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shader5 GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_occlusion_query2 GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_separate_shader_objects GL_ARB_shader_bit_encoding GL_ARB_shader_subroutine GL_ARB_shading_language_include GL_ARB_tessellation_shader GL_ARB_texture_buffer_object_rgb32 GL_ARB_texture_cube_map_array GL_ARB_texture_gather GL_ARB_texture_query_lod GL_ARB_texture_rgb10_a2ui GL_ARB_texture_storage GL_ARB_texture_swizzle GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_vertex_attrib_64bit GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_depth_bounds_test GL_EXT_texture_compression_s3tc GL_EXT_texture_filter_anisotropic GL_EXT_texture_mirror_clamp GL_EXT_texture_sRGB_decode GL_APPLE_client_storage GL_APPLE_container_object_shareable GL_APPLE_flush_render GL_APPLE_object_purgeable GL_APPLE_rgb_422 GL_APPLE_row_bytes GL_APPLE_texture_range GL_ATI_texture_mirror_once GL_NV_texture_barrier
[runtime] 2023-03-16 10:45:45 [verbose]: 🖼️ Renderer initialised!

frenzibyte
frenzibyte previously approved these changes Mar 17, 2023
Copy link
Member

@frenzibyte frenzibyte left a comment

Choose a reason for hiding this comment

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

Looking pretty solid to me. I've pushed a number of minor changes to further solidify the logic and get this to a complete state. @peppy check and see whether you're on board with it.

@smoogipoo would appreciate another pair of eyes on this one.

@peppy
Copy link
Sponsor Member Author

peppy commented Mar 17, 2023

Would have preferred review rather than direct commits for changes.

@frenzibyte
Copy link
Member

Would have preferred review rather than direct commits for changes.

Fair enough, will keep that in mind.

@peppy
Copy link
Sponsor Member Author

peppy commented Mar 17, 2023

I've added one more important log output to allow for this:

osu! 2023-03-17 at 08 55 05

@peppy
Copy link
Sponsor Member Author

peppy commented Mar 17, 2023

I've refactored this heavily to allow the game-side select to work... Will probably just push to this branch since it changes so much.

@peppy
Copy link
Sponsor Member Author

peppy commented Mar 17, 2023

@frenzibyte please re-review for readability. see usage at https://github.com/ppy/osu/compare/master...peppy:osu:add-renderer-selection?expand=1 if curious.

smoogipoo
smoogipoo previously approved these changes Mar 17, 2023
Copy link
Contributor

@smoogipoo smoogipoo left a comment

Choose a reason for hiding this comment

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

Bit of a preliminary review for now

Comment on lines 828 to 830
case RuntimeInfo.Platform.Linux:
case RuntimeInfo.Platform.Android:
yield return RendererType.Vulkan;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we don't use Vulkan on Linux yet. Since I'm a Linux user I'll be debugging it, but it is broken at runtime.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

@smoogipoo the way i have things setup right now, if a renderer isn't in the preference list it won't be displayed at all. do you think we should still allow it to be displayed in settings (this can be done quite easily, just want to check your opinion first).

osu.Framework/Platform/GameHost.cs Outdated Show resolved Hide resolved
Comment on lines 808 to 809
.Append(RendererType.OpenGL)
.Append(RendererType.OpenGLLegacy);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably reverse the order of these for now since OpenGL is pretty broken until veldrid/veldrid#481 and I don't know how deep the effects of it go beyond the intro (e.g. I don't if there's some case where sliders also won't render as a result/etc).

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Yeah for sure. Also potentially d3d before vulkan on windows

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

These aren't in the preferred renderers, so order doesn't actually matter (it's basically for display order).

Veldrid GL isn't preferred at all for now.

Comment on lines 823 to 824
yield return RendererType.Vulkan;
yield return RendererType.Direct3D11;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should default to Vulkan on Windows yet. For me it looks to be deadlocking in an infinite allocate loop on a 3060ti, and I'm not sure where yet (somewhere inside Veldrid) because I haven't really been testing Vulkan on Windows.

D3D11, while still not yet perfect and will experience glitchyness, is at least a little bit more stable and I will be continuing my work there before Vulkan because I don't know how Vulkan will behave with Optimus for example.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Yep, agree here too.

osu.Framework/Platform/GameHost.cs Outdated Show resolved Hide resolved
osu.Framework/Platform/GameHost.cs Show resolved Hide resolved
osu.Framework/Platform/GameHost.cs Outdated Show resolved Hide resolved
@peppy peppy added the next-release Pull requests which are almost there label Mar 20, 2023
frenzibyte
frenzibyte previously approved these changes Mar 20, 2023
Co-authored-by: Salman Ahmed <frenzibyte@gmail.com>
@smoogipoo smoogipoo merged commit 2ba7466 into ppy:master Mar 21, 2023
@peppy peppy deleted the renderer-config-fallback branch March 27, 2023 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:graphics next-release Pull requests which are almost there size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants