csinkers / ualbion

A remake of the 1995 RPG Albion (requires data from an install of the original game)
MIT License
133 stars 12 forks source link

Unable to create OpenGL Context: #22

Open orderorder opened 3 years ago

orderorder commented 3 years ago

Im using Manjaro Linux. After copy "ALBION" folder (in capital letters) from "game.gog" to my ualbion base folder (not /ualbion/src/UALBION folder) and execute "./run.sh -gl" the game show this error:

[1] at 0: Entered main [1] at 37: Running as Game [4] at 40: Building event types [1] at 42: Found base directory /.../ualbion [1] at 45: Creating engine [7] at 55: Loaded settings [1] at 62: Starting change backend to OpenGL [4] at 201: Built event types [7] at 245: Loaded core config [6] at 245: Loaded general config [6] at 250: Attached LogExchange in 2ms [6] at 253: Attached AssetManager in 0ms [6] at 253: Attached AssetManager in 0ms [6] at 253: Attached Container in 3ms [6] at 253: Registered asset services Unhandled exception. [5] at 298: Loaded game config Veldrid.VeldridException: Unable to create OpenGL Context: "Could not create GL context". This may indicate that the system does not support the requested OpenGL profile, version, or Swapchain format. at Veldrid.StartupUtilities.VeldridStartup.CreateDefaultOpenGLGraphicsDevice(GraphicsDeviceOptions options, Sdl2Window window, GraphicsBackend backend) at Veldrid.StartupUtilities.VeldridStartup.CreateGraphicsDevice(Sdl2Window window, GraphicsDeviceOptions options, GraphicsBackend preferredBackend) at UAlbion.Core.Veldrid.VeldridEngine.ChangeBackend() in /.../ualbion/src/Core.Veldrid/VeldridEngine.cs:line 380 at UAlbion.Program.BuildEngine(CommandLineOptions commandLine) in /.../ualbion/src/UAlbion/Program.cs:line 119 at UAlbion.Program.Main(String[] args) in /.../ualbion/src/UAlbion/Program.cs:line 52

csinkers commented 3 years ago

Hmm, sounds like a hardware / OS support issue. I had it running on Manjaro a couple of days ago so it should work. Try running it with -gles or -vk.

orderorder commented 3 years ago

With -gles the same error

With -vk

Unhandled exception. Veldrid.VeldridException: A Vulkan validation error was encountered: [ErrorEXT] (InstanceEXT) setupLoaderTermPhysDevs: Failed to detect any valid GPUs in the current config

This is part of my glxinfo:

GLX_MESA_query_renderer, GLX_MESA_swap_control, GLX_OML_swap_method, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, Extended renderer info (GLX_MESA_query_renderer): OpenGL renderer string: AMD OLAND (DRM 2.50.0, 5.10.19-1-MANJARO, LLVM 11.1.0)

csinkers commented 3 years ago

So it's crashing at a very early point in the startup process, in graphics library code that I don't control. From the looks of it, there's something amiss with your Linux graphics setup. Are you able to run demo GL programs like glxgears or some of the sample programs from the Vulkan SDK? How about the NeoDemo sample from Veldrid? (the graphics layer abstraction library that I'm using - https://github.com/mellinoe/veldrid).

orderorder commented 3 years ago

The glxgears program works but veldrid dont work

/usr/share/dotnet/sdk/3.1.108/NuGet.targets(123,5): error : Unable to load the service index for source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

This are the dotnet packages i have installed

community/dotnet-host 3.1.8.sdk108-1 [instalado] A generic driver for the .NET Core Command Line Interface community/dotnet-runtime 3.1.8.sdk108-1 [instalado] The .NET Core runtime community/dotnet-sdk 3.1.8.sdk108-1 [instalado] The .NET Core SDK community/dotnet-targeting-pack 3.1.8.sdk108-1 [instalado] The .NET Core targeting pack

csinkers commented 3 years ago

Ok, looks like that's because veldrid was referencing some .NET Core packages hosted on myget from when it was still in pre-release; those packages are no longer hosted there anymore and they just redirect back to https://dotnet.microsoft.com, which is preventing the https connection because the certificate subject name doesn't match. The fix should be to edit NuGet.config in veldrid and remove these two lines: <add key="dotnet-myget dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> <add key="dotnet-myget dotnet-corefxlab" value="https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json" /> which should make it load them from the default nuget.org feeds.

If glxgears works then maybe the problem is in SDL2 (which Veldrid.Startup uses to create the window and initialise GL). Testing if a minimal SDL OpenGL program works might help narrow down the issue, looking around I found a couple that should be pretty simple: https://gist.github.com/koute/7391344 or https://gist.github.com/jordandee/94b187bcc51df9528a2f

csinkers commented 3 years ago

Ah, that issue just got fixed in the veldrid repo actually, so you should just need to get the latest version of veldrid to be able to test NeoDemo.

orderorder commented 3 years ago

That two little programs work, they open a window with colors inside.

Veldrid shows a new error:

.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: Error inesperado en la tarea "Nerdbank.GitVersioning.Tasks.GetBuildVersion".
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: ---> System.PlatformNotSupportedException: manjaro-x64
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.RuntimeIdMap.GetNativeLibraryDirectoryName(String runtimeIdentifier)
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.GitLoaderContext.GetNativeLibraryDirectory()
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at Nerdbank.GitVersioning.GitLoaderContext.LoadUnmanagedDll(String unmanagedDllName)
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext)
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
.nuget/packages/nerdbank.gitversioning/3.3.37/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: at LibGit2Sharp.Core.NativeMethods..cctor()

csinkers commented 3 years ago

Ah, that old issue. Remove these lines from Directory.Build.props and it should build:

  <PropertyGroup>
    <NerdbankGitVersioningVersion>3.3.37</NerdbankGitVersioningVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Nerdbank.GitVersioning" Version="$(NerdbankGitVersioningVersion)" PrivateAssets="all" />
  </ItemGroup>
orderorder commented 3 years ago

In the veldrid folder i use:

 dotnet run --project src/NeoDemo --runtime linux-x64 -- $*

then:

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Veldrid, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040) File name: 'Veldrid, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null' at Veldrid.NeoDemo.ShaderHelper.LoadSPIRV(GraphicsDevice gd, ResourceFactory factory, String setName) at Veldrid.NeoDemo.StaticResourceCache.GetShaders(GraphicsDevice gd, ResourceFactory factory, String name) in .../veldrid/src/NeoDemo/StaticResourceCache.cs:line 64 at Veldrid.NeoDemo.Objects.TexturedMesh.CreateDeviceObjects(GraphicsDevice gd, CommandList cl, SceneContext sc) in .../veldrid/src/NeoDemo/Objects/TexturedMesh.cs:line 115 at Veldrid.NeoDemo.Scene.CreateAllDeviceObjects(GraphicsDevice gd, CommandList cl, SceneContext sc) in .../veldrid/src/NeoDemo/Scene.cs:line 606 at Veldrid.NeoDemo.NeoDemo.CreateAllObjects() in .../veldrid/src/NeoDemo/NeoDemo.cs:line 649 at Veldrid.NeoDemo.NeoDemo..ctor() in .../veldrid/src/NeoDemo/NeoDemo.cs:line 118 at Veldrid.NeoDemo.Program.Main(String[] args) in .../veldrid/src/NeoDemo/Program.cs:line 9

csinkers commented 3 years ago

I'll boot into my manjaro setup after I finish work and investigate this, in the meantime you might have better luck with the samples from https://github.com/mellinoe/veldrid-samples - they should load their veldrid dependency from NuGet and avoid some of the version mismatch issues that can happen when building it from source.

orderorder commented 3 years ago

Thanks for your help and patience but i didnt have luck with the veldrid-samples. I have other programs like videogames or emulators that work with acceleration but i think that the problem is the integration of dotnet in linux.

dotnet run -p src/TexturedCube/Desktop/ --runtime linux-x64 -- $*

veldrid-samples/src/AssetProcessor/AssetProcessor.csproj : error : NETSDK1061: the project was restored using Microsoft.NETCore.App version 2.0.9, but with the current configuration, version 2.0.0 would be used instead. To resolve this problem, make sure that the same settings are used for restoring and for subsequent operations such as compiling or publishing. Typically, this problem can occur if the `RuntimeIdentifier property is set during compilation or publishing but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection.