mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-08-04 07:21:06 +00:00
Add Xlib support
This commit is contained in:
parent
50cd75fe35
commit
521661451e
|
@ -41,8 +41,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Generators", "
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTK.Standard", "src\OpenTK\OpenTK.Standard.csproj", "{67F02FD3-8F7F-4D89-8551-359993271CA3}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VkTest", "VkTest\VkTest.csproj", "{B0F33C2F-B9BD-4E55-85E3-6C1760D39DE9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vk.generator", "src\vk.generator\vk.generator.csproj", "{3766DF33-E28B-402D-9EE1-975C2AFB5EAF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vk.rewrite", "src\vk.rewrite\vk.rewrite.csproj", "{3E9B1C4D-BCB4-418A-A94E-DD164A19C6A2}"
|
||||
|
@ -97,10 +95,6 @@ Global
|
|||
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{67F02FD3-8F7F-4D89-8551-359993271CA3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B0F33C2F-B9BD-4E55-85E3-6C1760D39DE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0F33C2F-B9BD-4E55-85E3-6C1760D39DE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0F33C2F-B9BD-4E55-85E3-6C1760D39DE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0F33C2F-B9BD-4E55-85E3-6C1760D39DE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3766DF33-E28B-402D-9EE1-975C2AFB5EAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
|
@ -221,6 +221,11 @@ namespace OpenTK
|
|||
|
||||
return supported;
|
||||
}
|
||||
#else
|
||||
private static bool DetectSdl2()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void DetectUnix(out bool unix, out bool linux, out bool macos)
|
||||
|
|
|
@ -9,12 +9,26 @@ namespace OpenTK.Graphics.Vulkan
|
|||
{
|
||||
private static NativeLibrary s_nativeLib;
|
||||
|
||||
static VK()
|
||||
static public void LoadFunctions()
|
||||
{
|
||||
if (s_nativeLib == null)
|
||||
{
|
||||
s_nativeLib = LoadNativeLibrary();
|
||||
}
|
||||
|
||||
LoadFunctionPointers();
|
||||
}
|
||||
|
||||
public static IntPtr LoadFunctionPointer(string functionName)
|
||||
{
|
||||
if (s_nativeLib == null)
|
||||
{
|
||||
s_nativeLib = LoadNativeLibrary();
|
||||
}
|
||||
|
||||
return s_nativeLib.LoadFunctionPointer(functionName);
|
||||
}
|
||||
|
||||
private static NativeLibrary LoadNativeLibrary()
|
||||
{
|
||||
return NativeLibrary.Load(GetVulkanName());
|
||||
|
|
|
@ -4,14 +4,14 @@ using System.Text;
|
|||
|
||||
namespace OpenTK.Graphics.Vulkan
|
||||
{
|
||||
public unsafe class FixedUtf8String : IDisposable
|
||||
public unsafe class NativeString : IDisposable
|
||||
{
|
||||
private GCHandle _handle;
|
||||
private uint _numBytes;
|
||||
|
||||
public byte* StringPtr => (byte*)_handle.AddrOfPinnedObject().ToPointer();
|
||||
|
||||
public FixedUtf8String(string s)
|
||||
public NativeString(string s)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
|
@ -46,9 +46,9 @@ namespace OpenTK.Graphics.Vulkan
|
|||
_handle.Free();
|
||||
}
|
||||
|
||||
public static implicit operator byte* (FixedUtf8String utf8String) => utf8String.StringPtr;
|
||||
public static implicit operator IntPtr (FixedUtf8String utf8String) => new IntPtr(utf8String.StringPtr);
|
||||
public static implicit operator FixedUtf8String(string s) => new FixedUtf8String(s);
|
||||
public static implicit operator string(FixedUtf8String utf8String) => utf8String.GetString();
|
||||
public static implicit operator byte* (NativeString utf8String) => utf8String.StringPtr;
|
||||
public static implicit operator IntPtr (NativeString utf8String) => new IntPtr(utf8String.StringPtr);
|
||||
public static implicit operator NativeString(string s) => new NativeString(s);
|
||||
public static implicit operator string(NativeString utf8String) => utf8String.GetString();
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
namespace OpenTK.Graphics.Vulkan
|
||||
{
|
||||
public static class Strings
|
||||
{
|
||||
public static FixedUtf8String VK_KHR_SURFACE_EXTENSION_NAME = "VK_KHR_surface";
|
||||
public static FixedUtf8String VK_KHR_WIN32_SURFACE_EXTENSION_NAME = "VK_KHR_win32_surface";
|
||||
public static FixedUtf8String VK_KHR_XCB_SURFACE_EXTENSION_NAME = "VK_KHR_xcb_surface";
|
||||
public static FixedUtf8String VK_KHR_XLIB_SURFACE_EXTENSION_NAME = "VK_KHR_xlib_surface";
|
||||
public static FixedUtf8String VK_KHR_SWAPCHAIN_EXTENSION_NAME = "VK_KHR_swapchain";
|
||||
public static FixedUtf8String VK_EXT_DEBUG_REPORT_EXTENSION_NAME = "VK_EXT_debug_report";
|
||||
public static FixedUtf8String StandardValidationLayeName = "VK_LAYER_LUNARG_standard_validation";
|
||||
public static FixedUtf8String main = "main";
|
||||
}
|
||||
}
|
14
src/OpenTK/Graphics/Vulkan/VulkanStrings.cs
Normal file
14
src/OpenTK/Graphics/Vulkan/VulkanStrings.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace OpenTK.Graphics.Vulkan
|
||||
{
|
||||
public static class VulkanStrings
|
||||
{
|
||||
public static NativeString VK_KHR_SURFACE_EXTENSION_NAME = "VK_KHR_surface";
|
||||
public static NativeString VK_KHR_WIN32_SURFACE_EXTENSION_NAME = "VK_KHR_win32_surface";
|
||||
public static NativeString VK_KHR_XCB_SURFACE_EXTENSION_NAME = "VK_KHR_xcb_surface";
|
||||
public static NativeString VK_KHR_XLIB_SURFACE_EXTENSION_NAME = "VK_KHR_xlib_surface";
|
||||
public static NativeString VK_KHR_SWAPCHAIN_EXTENSION_NAME = "VK_KHR_swapchain";
|
||||
public static NativeString VK_EXT_DEBUG_REPORT_EXTENSION_NAME = "VK_EXT_debug_report";
|
||||
public static NativeString StandardValidationLayerName = "VK_LAYER_LUNARG_standard_validation";
|
||||
public static NativeString main = "main";
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
namespace OpenTK.Graphics.Vulkan
|
||||
{
|
||||
public struct Version
|
||||
public struct VulkanVersion
|
||||
{
|
||||
private readonly uint value;
|
||||
|
||||
public Version(uint major, uint minor, uint patch)
|
||||
public VulkanVersion(uint major, uint minor, uint patch)
|
||||
{
|
||||
value = major << 22 | minor << 12 | patch;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
|||
|
||||
public uint Patch => (value >> 22) & 0xfff;
|
||||
|
||||
public static implicit operator uint(Version version)
|
||||
public static implicit operator uint(VulkanVersion version)
|
||||
{
|
||||
return version.value;
|
||||
}
|
|
@ -50,7 +50,7 @@ namespace OpenTK
|
|||
private bool events;
|
||||
private bool previous_cursor_visible = true;
|
||||
|
||||
public VkResult CreateVulkanSurface(VkInstance instance, out VkSurfaceKHR surface)
|
||||
public unsafe VkResult CreateVulkanSurface(VkInstance instance, out VkSurfaceKHR surface)
|
||||
{
|
||||
IPlatformFactory factory = Factory.Default;
|
||||
|
||||
|
@ -62,9 +62,24 @@ namespace OpenTK
|
|||
|
||||
return VK.CreateWin32SurfaceKHR(instance, ref createInfo, IntPtr.Zero, out surface);
|
||||
}
|
||||
else if (implementation is Platform.X11.X11GLNative x11)
|
||||
{
|
||||
Platform.X11.X11WindowInfo info = x11.WindowInfo as Platform.X11.X11WindowInfo;
|
||||
|
||||
Graphics.Vulkan.Xlib.Window window = new Graphics.Vulkan.Xlib.Window();
|
||||
window.Value = info.WindowHandle;
|
||||
|
||||
VkXlibSurfaceCreateInfoKHR createInfo = VkXlibSurfaceCreateInfoKHR.New();
|
||||
createInfo.dpy = (Graphics.Vulkan.Xlib.Display*)info.Display;
|
||||
createInfo.window = window;
|
||||
|
||||
return VK.CreateXlibSurfaceKHR(instance, &createInfo, IntPtr.Zero, out surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//If someone knows how to create a MoltenVK surface, please add it here
|
||||
|
||||
throw new NotImplementedException(implementation.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,11 +87,15 @@ namespace OpenTK
|
|||
{
|
||||
if (implementation is Platform.Windows.WinGLNative win)
|
||||
{
|
||||
return new IntPtr[] { Strings.VK_KHR_WIN32_SURFACE_EXTENSION_NAME };
|
||||
return new IntPtr[] { VulkanStrings.VK_KHR_WIN32_SURFACE_EXTENSION_NAME };
|
||||
}
|
||||
else if (implementation is Platform.X11.X11GLNative x11)
|
||||
{
|
||||
return new IntPtr[] { VulkanStrings.VK_KHR_XLIB_SURFACE_EXTENSION_NAME };
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new NotImplementedException(implementation.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<AssemblyName>OpenTK</AssemblyName>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RootNamespace>OpenTK</RootNamespace>
|
||||
<DefineConstants>$(DefineConstants);WIN32;CARBON;X11;SDL2;OPENGL;OPENGLES;MINIMAL</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);WIN32;CARBON;X11;OPENGL;OPENGLES;MINIMAL</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
|
@ -68,8 +68,8 @@
|
|||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>1.0.2</Version>
|
||||
<Description>The Open Toolkit library (OpenTK) is an advanced, low-level C# wrapper for OpenGL, OpenGL ES and OpenAL.
|
||||
<Version>1.1.7</Version>
|
||||
<Description>The Open Toolkit library (OpenTK) is an advanced, low-level C# wrapper for OpenGL, OpenGL ES, OpenAL and Vulkan.
|
||||
It is suitable for games, scientific visualizations and projects that require 3d graphics, audio or compute functionality.
|
||||
|
||||
Features
|
||||
|
@ -83,7 +83,9 @@ This version can be found at https://github.com/emmauss/opentk</Description>
|
|||
<Authors>emmaus</Authors>
|
||||
<Company>emmaus</Company>
|
||||
<Product>OpenTK</Product>
|
||||
<PackageProjectUrl>https://github.com/emmauss/opentk</PackageProjectUrl>
|
||||
<PackageProjectUrl>https://github.com/Ryujinx/Opentk</PackageProjectUrl>
|
||||
<AssemblyVersion>1.1.7.0</AssemblyVersion>
|
||||
<FileVersion>1.1.7.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="$(OutputPath)..\..\..\..\Generator.Rewrite\bin\Debug\Rewrite.exe --assembly $(OutputPath)OpenTK.dll --signing-key ..\..\OpenTK.snk -debug -netstandard" Condition="$(OS) == 'Windows_NT' and $(Configuration) == 'Debug'" />
|
||||
|
|
|
@ -46,8 +46,9 @@ namespace OpenTK.Platform
|
|||
Toolkit.Init();
|
||||
|
||||
// Create regular platform backend
|
||||
if (false) { }
|
||||
#if SDL2
|
||||
if (Configuration.RunningOnSdl2)
|
||||
else if (Configuration.RunningOnSdl2)
|
||||
{
|
||||
Default = new SDL2.Sdl2Factory();
|
||||
}
|
||||
|
|
|
@ -692,10 +692,10 @@ namespace OpenTK.Platform.X11
|
|||
public int backing_store;
|
||||
public IntPtr backing_planes;
|
||||
public IntPtr backing_pixel;
|
||||
public bool save_under;
|
||||
public int save_under;
|
||||
public IntPtr event_mask;
|
||||
public IntPtr do_not_propagate_mask;
|
||||
public bool override_redirect;
|
||||
public int override_redirect;
|
||||
public IntPtr colormap;
|
||||
public IntPtr cursor;
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ namespace OpenTK.Platform.X11
|
|||
public IntPtr backing_pixel;
|
||||
public byte save_under;
|
||||
public IntPtr colormap;
|
||||
public bool map_installed;
|
||||
public int map_installed;
|
||||
public MapState map_state;
|
||||
public IntPtr all_event_masks;
|
||||
public IntPtr your_event_mask;
|
||||
|
|
Loading…
Reference in a new issue