mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Compare commits
176 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4cf5565fa | ||
|
|
e784ac8d86 | ||
|
|
be7b134e1d | ||
|
|
4930df85f1 | ||
|
|
9a00bd89ef | ||
|
|
3d6fda1aca | ||
|
|
312944eb9a | ||
|
|
88a115ddbc | ||
|
|
2669c4c402 | ||
|
|
05c8814118 | ||
|
|
819ce1d8e4 | ||
|
|
91650fb4fb | ||
|
|
b6a5300f81 | ||
|
|
b7a3526131 | ||
|
|
617d3e81b2 | ||
|
|
729ab4970e | ||
|
|
ccbf6c0817 | ||
|
|
c4b32ec592 | ||
|
|
a8a73e28f4 | ||
|
|
e5983a9ec1 | ||
|
|
b7fa39d8cc | ||
|
|
3c30ed749c | ||
|
|
eb1a2ae9b4 | ||
|
|
ee0c31a8c3 | ||
|
|
4ab61b840a | ||
|
|
df29fa438a | ||
|
|
a3756c29bd | ||
|
|
4dc17f3aca | ||
|
|
d22280f177 | ||
|
|
9e8f7092ea | ||
|
|
de188cc773 | ||
|
|
784a02c0e7 | ||
|
|
c8db7f98db | ||
|
|
318c37e686 | ||
|
|
524be86449 | ||
|
|
ddeb78accd | ||
|
|
585e847818 | ||
|
|
ac3cb4dc2a | ||
|
|
c06ca39009 | ||
|
|
06b11a51f1 | ||
|
|
4938a159d4 | ||
|
|
27f2e270ce | ||
|
|
94e60e0b10 | ||
|
|
c6863033a5 | ||
|
|
917878d05f | ||
|
|
10e4766809 | ||
|
|
abd5149245 | ||
|
|
912b6da20a | ||
|
|
94fe0b7721 | ||
|
|
9fac1e78fb | ||
|
|
6697b76683 | ||
|
|
b2ab247b5b | ||
|
|
7411ae8138 | ||
|
|
d398e3a75b | ||
|
|
a5047224bb | ||
|
|
058821c08b | ||
|
|
0c691b061d | ||
|
|
51bbc5dc45 | ||
|
|
2d3522e752 | ||
|
|
d4f265c314 | ||
|
|
7654d38612 | ||
|
|
cdcc255123 | ||
|
|
2f56a6a110 | ||
|
|
16fc48cef2 | ||
|
|
5cecbb2cff | ||
|
|
6115d6d5cc | ||
|
|
60d26be139 | ||
|
|
186392ea80 | ||
|
|
ebe4538d4c | ||
|
|
745d0e5532 | ||
|
|
d4f7e60432 | ||
|
|
ced127c164 | ||
|
|
f91bcb62b1 | ||
|
|
5268a4a3f0 | ||
|
|
1f1e50539b | ||
|
|
ea3132bbba | ||
|
|
67ccaec418 | ||
|
|
40b70e9447 | ||
|
|
7d37db9ce0 | ||
|
|
dd8688df3d | ||
|
|
b02c53c6ad | ||
|
|
38d3b83818 | ||
|
|
f02cd0083a | ||
|
|
c2c8af16d0 | ||
|
|
b61003e2a0 | ||
|
|
fb0ec52f8c | ||
|
|
fee79d8aa5 | ||
|
|
4508105412 | ||
|
|
a0ebb290e2 | ||
|
|
d45497e53b | ||
|
|
ff8dd021c3 | ||
|
|
34a371ef1f | ||
|
|
83109b08e9 | ||
|
|
3d7b83db05 | ||
|
|
41b2ee19a1 | ||
|
|
856cdb8a3d | ||
|
|
b783cd79be | ||
|
|
b5ba964f61 | ||
|
|
09676a1d9f | ||
|
|
6959f21927 | ||
|
|
26a1fb35b5 | ||
|
|
7fb3ce0e70 | ||
|
|
5497b52100 | ||
|
|
18b5f33080 | ||
|
|
30d3367c50 | ||
|
|
f6aabd1a22 | ||
|
|
6d229a3eb2 | ||
|
|
da28bdbce5 | ||
|
|
0181988225 | ||
|
|
fb2ba7460a | ||
|
|
b70d20a217 | ||
|
|
ebc33df457 | ||
|
|
697af6771c | ||
|
|
20706870da | ||
|
|
372fa39228 | ||
|
|
d6bfbe4f6f | ||
|
|
54645b4adf | ||
|
|
7c16573f3e | ||
|
|
8935b39987 | ||
|
|
388f8369a8 | ||
|
|
217d889e36 | ||
|
|
f243baccf2 | ||
|
|
790f42ea70 | ||
|
|
a5fcf122b8 | ||
|
|
df2d6ab8c2 | ||
|
|
23c90c0c45 | ||
|
|
c69756e7f1 | ||
|
|
07fbd5263c | ||
|
|
ebce0daa1b | ||
|
|
c876eb1f4c | ||
|
|
1037fc735e | ||
|
|
d5df765467 | ||
|
|
93cf9f4227 | ||
|
|
d2977e2a63 | ||
|
|
a3f0ea19c4 | ||
|
|
d9032b8757 | ||
|
|
cba6e37f9f | ||
|
|
90ec9a80c9 | ||
|
|
7eaf2f590b | ||
|
|
0439ea9893 | ||
|
|
f7124cf755 | ||
|
|
6679c31d4b | ||
|
|
8ed78975eb | ||
|
|
b423235a4c | ||
|
|
27f7d9a8fb | ||
|
|
86a4253585 | ||
|
|
d8bb3cb896 | ||
|
|
26e4270312 | ||
|
|
850b26b14d | ||
|
|
db005b7ed9 | ||
|
|
b8fbca251e | ||
|
|
1cb2029e9d | ||
|
|
e83affa97d | ||
|
|
100dd2b66d | ||
|
|
5e3ecfc4a7 | ||
|
|
32dcf9a76e | ||
|
|
33bd0af9c1 | ||
|
|
0213606c4b | ||
|
|
0a205640d9 | ||
|
|
3fd5d6a49f | ||
|
|
3f87700ca8 | ||
|
|
3467362236 | ||
|
|
7f7294f0cc | ||
|
|
747ffd75c3 | ||
|
|
1ccb636a33 | ||
|
|
f4670562e5 | ||
|
|
e122f69b91 | ||
|
|
d87319c69b | ||
|
|
99e8dc5927 | ||
|
|
9343fb78c9 | ||
|
|
d2feebc4c8 | ||
|
|
0f51519f45 | ||
|
|
d634b25b87 | ||
|
|
e2a3796ceb | ||
|
|
86c350119d | ||
|
|
379971eaea |
2
.github/workflows/build-test.yml
vendored
2
.github/workflows/build-test.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest] # , macos-latest] - temporarily disabled due to libfreetype.dll errors.
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
||||
2
.github/workflows/publish-client.yml
vendored
2
.github/workflows/publish-client.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Package client
|
||||
run: Tools/package_client_build.py -p windows mac linux
|
||||
run: Tools/package_client_build.py
|
||||
|
||||
- name: Shuffle files around
|
||||
run: |
|
||||
|
||||
@@ -44,10 +44,11 @@
|
||||
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
|
||||
<PackageVersion Include="Nett" Version="0.15.0" />
|
||||
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
|
||||
<PackageVersion Include="OpenTK.OpenAL" Version="4.7.7" />
|
||||
<PackageVersion Include="OpenTK.Audio.OpenAL" Version="4.9.4" />
|
||||
<PackageVersion Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" />
|
||||
<PackageVersion Include="Pidgin" Version="3.3.0" />
|
||||
<PackageVersion Include="Robust.Natives" Version="0.1.1" />
|
||||
<PackageVersion Include="Robust.Natives" Version="0.2.3" />
|
||||
<PackageVersion Include="Robust.Natives.Zstd" Version="0.1.1-zstd1.5.7" />
|
||||
<PackageVersion Include="Robust.Natives.Cef" Version="131.3.5" />
|
||||
<PackageVersion Include="Robust.Shared.AuthLib" Version="0.1.2" />
|
||||
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.10" />
|
||||
@@ -58,8 +59,11 @@
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
|
||||
<PackageVersion Include="SpaceWizards.HttpListener" Version="0.1.1" />
|
||||
<PackageVersion Include="SpaceWizards.NFluidsynth" Version="0.2.2" />
|
||||
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.0.2" />
|
||||
<PackageVersion Include="SpaceWizards.Sdl" Version="1.0.0" />
|
||||
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.1.0" />
|
||||
<PackageVersion Include="SpaceWizards.Sodium" Version="0.2.1" />
|
||||
<PackageVersion Include="libsodium" Version="1.0.20.1" />
|
||||
<PackageVersion Include="System.Management" Version="9.0.8" />
|
||||
<PackageVersion Include="TerraFX.Interop.Windows" Version="10.0.26100.1" />
|
||||
<PackageVersion Include="TerraFX.Interop.Xlib" Version="6.4.0" />
|
||||
<PackageVersion Include="VorbisPizza" Version="1.3.0" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project>
|
||||
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
|
||||
|
||||
@@ -28,5 +28,5 @@
|
||||
<Import Project="Robust.Analyzers.targets" Condition="'$(SkipRobustAnalyzer)' != 'true'" />
|
||||
|
||||
<!-- serialization generator -->
|
||||
<Import Project="Robust.Serialization.Generator.targets" Condition="'$(SkipRobustAnalyzer)' != 'true'" />
|
||||
<Import Project="Robust.Serialization.Generator.targets" Condition="'$(SkipRobustAnalyzer)' != 'true' And '$(SkipRobustSerializationGenerator)' != 'true'" />
|
||||
</Project>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// Cursor.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Opaque handle to a GLFW cursor.
|
||||
/// </summary>
|
||||
public struct Cursor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// ClientApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The context client APIs.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintClientApi,ClientApi)"/>
|
||||
public enum ClientApi
|
||||
{
|
||||
/// <summary>
|
||||
/// No context API is created.
|
||||
/// </summary>
|
||||
NoApi = 0,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL context is created.
|
||||
/// </summary>
|
||||
OpenGlApi = 0x00030001,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL ES context is created.
|
||||
/// </summary>
|
||||
OpenGlEsApi = 0x00030002
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// ConnectedState.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies connected state of devices.
|
||||
/// </summary>
|
||||
public enum ConnectedState
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that a device is connected.
|
||||
/// </summary>
|
||||
Connected = 0x00040001,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a device is disconnected.
|
||||
/// </summary>
|
||||
Disconnected = 0x00040002
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// ContextApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The context API used to create the window context.
|
||||
/// </summary>
|
||||
public enum ContextApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Uses the native context API to create the window context.
|
||||
/// </summary>
|
||||
NativeContextApi = 0x00036001,
|
||||
|
||||
/// <summary>
|
||||
/// Uses Egl to create the window context.
|
||||
/// </summary>
|
||||
EglContextApi = 0x00036002
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// CursorModeValue.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The GLFW cursor modes.
|
||||
/// See <a href="https://www.glfw.org/docs/latest/input_guide.html#cursor_mode">cursor modes</a>.
|
||||
/// </summary>
|
||||
public enum CursorModeValue
|
||||
{
|
||||
/// <summary>
|
||||
/// The regular arrow cursor (or another cursor set with <see cref="GLFW.SetCursor"/>) is used
|
||||
/// and cursor motion is not limited.
|
||||
/// </summary>
|
||||
CursorNormal = 0x00034001,
|
||||
|
||||
/// <summary>
|
||||
/// Hides the arrow cursor when over a window.
|
||||
/// </summary>
|
||||
CursorHidden = 0x00034002,
|
||||
|
||||
/// <summary>
|
||||
/// Will hide the cursor and lock it to the specified window.
|
||||
/// GLFW will then take care of all the details of cursor re-centering and offset calculation
|
||||
/// and providing the application with a virtual cursor position.
|
||||
/// This virtual position is provided normally via both the cursor position callback and through polling.
|
||||
/// </summary>
|
||||
CursorDisabled = 0x00034003
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
//
|
||||
// CursorShape.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard cursor shapes.
|
||||
/// </summary>
|
||||
public enum CursorShape
|
||||
{
|
||||
/// <summary>
|
||||
/// The standard arrow shape. Used in almost all situations.
|
||||
/// </summary>
|
||||
Arrow = 0x00036001,
|
||||
|
||||
/// <summary>
|
||||
/// The I-Beam shape. Used when mousing over a place where text can be entered.
|
||||
/// </summary>
|
||||
IBeam = 0x00036002,
|
||||
|
||||
/// <summary>
|
||||
/// The crosshair shape. Used when dragging and dropping.
|
||||
/// </summary>
|
||||
Crosshair = 0x00036003,
|
||||
|
||||
/// <summary>
|
||||
/// The hand shape. Used when mousing over something that can be dragged around.
|
||||
/// </summary>
|
||||
Hand = 0x00036004,
|
||||
|
||||
/// <summary>
|
||||
/// The horizontal resize shape. Used when mousing over something that can be horizontally resized.
|
||||
/// </summary>
|
||||
HResize = 0x00036005,
|
||||
|
||||
/// <summary>
|
||||
/// The vertical resize shape. Used when mousing over something that can be vertically resized.
|
||||
/// </summary>
|
||||
VResize = 0x00036006
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// CursorStateAttribute.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for setting <see cref="CursorModeValue"/> of the cursor.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.SetInputMode(Window*,CursorStateAttribute,CursorModeValue)"/>
|
||||
/// <seealso cref="GLFW.GetInputMode(Window*,CursorStateAttribute)"/>
|
||||
public enum CursorStateAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for setting <see cref="CursorModeValue"/> of the cursor.
|
||||
/// </summary>
|
||||
Cursor = 0x00033001,
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
//
|
||||
// ErrorCode.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Error codes, used in the error callback.
|
||||
/// </summary>
|
||||
public enum ErrorCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Everything is running as intended. Yay!
|
||||
/// </summary>
|
||||
NoError = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Called a function before calling <see cref="GLFW.Init"/>. Initialize GLFW and then try again.
|
||||
/// </summary>
|
||||
NotInitialized = 0x00010001,
|
||||
|
||||
/// <summary>
|
||||
/// No OpenGL/OpenGL ES context on this thread.
|
||||
/// </summary>
|
||||
NoContext = 0x00010002,
|
||||
|
||||
/// <summary>
|
||||
/// Used an invalid enum value on a function.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This should hopefully never happen in the bindings, due to the added type safety of C# enums VS. GLFW's native #defines
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
InvalidEnum = 0x00010003,
|
||||
|
||||
/// <summary>
|
||||
/// Called a function with an invalid argument.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This can happen if you request an OpenGL version that doesn't exist, like 2.7.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If you request a version of OpenGL that exists, but isn't supported by this graphics card, it will return VersionUnavailable instead.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
InvalidValue = 0x00010004,
|
||||
|
||||
/// <summary>
|
||||
/// A memory allocation failed on GLFW's end.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Report this to the GLFW issue tracker if encountered.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
OutOfMemory = 0x00010005,
|
||||
|
||||
/// <summary>
|
||||
/// The requested API is not available on the system.
|
||||
/// </summary>
|
||||
ApiUnavailable = 0x00010006,
|
||||
|
||||
/// <summary>
|
||||
/// The requested OpenGL version is not available on the system.
|
||||
/// </summary>
|
||||
VersionUnavailable = 0x00010007,
|
||||
|
||||
/// <summary>
|
||||
/// A platform-specific error occurred that doesn't fit into any more specific category.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Report this to the GLFW issue tracker if encountered.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
PlatformError = 0x00010008,
|
||||
|
||||
/// <summary>
|
||||
/// The requested format is unavailable.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If emitted during window creation, the requested pixel format isn't available.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If emitted when using the clipboard, the contents of the clipboard couldn't be converted to the requested format.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
FormatUnavailable = 0x00010009,
|
||||
|
||||
/// <summary>
|
||||
/// There is no OpenGL/OpenGL ES context attached to this window.
|
||||
/// </summary>
|
||||
NoWindowContext = 0x0001000A
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
// InitHint.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialization hints are set before <see cref="GLFW.Init"/> and affect how the library behaves until termination.
|
||||
/// Hints are set with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
public enum InitHintBool
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify whether to also expose joystick hats as buttons,
|
||||
/// for compatibility with earlier versions of GLFW that did not have
|
||||
/// <see cref="GLFW.GetJoystickHats"/>.
|
||||
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
JoystickHatButtons = 0x00050001,
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify whether to set the current directory to the application to the Contents/Resources
|
||||
/// subdirectory of the application's bundle, if present.
|
||||
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only affects macOS; no effect on other platforms.
|
||||
/// </remarks>
|
||||
CocoaChdirResources = 0x00051001,
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify whether to create a basic menu bar, either from a nib or manually,
|
||||
/// when the first window is created, which is when AppKit is initialized.
|
||||
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only affects macOS; no effect on other platforms.
|
||||
/// </remarks>
|
||||
CocoaMenubar = 0x00051002
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialization hints are set before <see cref="GLFW.Init"/> and affect how the library behaves until termination.
|
||||
/// Hints are set with <see cref="GLFW.InitHint(InitHintInt, int)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// While this enum has no members,
|
||||
/// it can still be useful because it allows you to access the direct <c>glfwInitHint(int, int)</c> API.
|
||||
/// In case a future version of GLFW adds an int-taking int hint and we don't handle it.
|
||||
/// </remarks>
|
||||
public enum InitHintInt
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// InputAction.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines event information for <see cref="GLFWCallbacks.KeyCallback"/>
|
||||
/// or <see cref="GLFWCallbacks.MouseButtonCallback"/>.
|
||||
/// </summary>
|
||||
public enum InputAction : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// The key or mouse button was released.
|
||||
/// </summary>
|
||||
Release = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The key or mouse button was pressed.
|
||||
/// </summary>
|
||||
Press = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The key was held down until it repeated.
|
||||
/// </summary>
|
||||
Repeat = 2
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Status of a joystick hat.
|
||||
/// </summary>
|
||||
public enum JoystickHats : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Hat is centered.
|
||||
/// </summary>
|
||||
Centered = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing up.
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing right.
|
||||
/// </summary>
|
||||
Right = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing down.
|
||||
/// </summary>
|
||||
Down = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing left.
|
||||
/// </summary>
|
||||
Left = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing up and to the right.
|
||||
/// </summary>
|
||||
RightUp = Right | Up,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing down and to the right.
|
||||
/// </summary>
|
||||
RightDown = Right | Down,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing up and to the left.
|
||||
/// </summary>
|
||||
LeftUp = Left | Up,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing down and to the left.
|
||||
/// </summary>
|
||||
LeftDown = Left | Down,
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// KeyModifiers.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Key modifiers, such as Shift or CTRL.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum KeyModifiers : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// if one or more Shift keys were held down.
|
||||
/// </summary>
|
||||
Shift = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// If one or more Control keys were held down.
|
||||
/// </summary>
|
||||
Control = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// If one or more Alt keys were held down.
|
||||
/// </summary>
|
||||
Alt = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// If one or more Super keys were held down.
|
||||
/// </summary>
|
||||
Super = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// If caps lock is enabled.
|
||||
/// </summary>
|
||||
CapsLock = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// If num lock is enabled.
|
||||
/// </summary>
|
||||
NumLock = 0x0020,
|
||||
}
|
||||
}
|
||||
@@ -1,627 +0,0 @@
|
||||
//
|
||||
// Keys.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies key codes and modifiers in US keyboard layout.
|
||||
/// </summary>
|
||||
public enum Keys : short
|
||||
{
|
||||
/// <summary>
|
||||
/// An unknown key.
|
||||
/// </summary>
|
||||
Unknown = -1,
|
||||
|
||||
/// <summary>
|
||||
/// The spacebar key.
|
||||
/// </summary>
|
||||
Space = 32,
|
||||
|
||||
/// <summary>
|
||||
/// The apostrophe key.
|
||||
/// </summary>
|
||||
Apostrophe = 39 /* ' */,
|
||||
|
||||
/// <summary>
|
||||
/// The comma key.
|
||||
/// </summary>
|
||||
Comma = 44 /* , */,
|
||||
|
||||
/// <summary>
|
||||
/// The minus key.
|
||||
/// </summary>
|
||||
Minus = 45 /* - */,
|
||||
|
||||
/// <summary>
|
||||
/// The period key.
|
||||
/// </summary>
|
||||
Period = 46 /* . */,
|
||||
|
||||
/// <summary>
|
||||
/// The slash key.
|
||||
/// </summary>
|
||||
Slash = 47 /* / */,
|
||||
|
||||
/// <summary>
|
||||
/// The 0 key.
|
||||
/// </summary>
|
||||
D0 = 48,
|
||||
|
||||
/// <summary>
|
||||
/// The 1 key.
|
||||
/// </summary>
|
||||
D1 = 49,
|
||||
|
||||
/// <summary>
|
||||
/// The 2 key.
|
||||
/// </summary>
|
||||
D2 = 50,
|
||||
|
||||
/// <summary>
|
||||
/// The 3 key.
|
||||
/// </summary>
|
||||
D3 = 51,
|
||||
|
||||
/// <summary>
|
||||
/// The 4 key.
|
||||
/// </summary>
|
||||
D4 = 52,
|
||||
|
||||
/// <summary>
|
||||
/// The 5 key.
|
||||
/// </summary>
|
||||
D5 = 53,
|
||||
|
||||
/// <summary>
|
||||
/// The 6 key.
|
||||
/// </summary>
|
||||
D6 = 54,
|
||||
|
||||
/// <summary>
|
||||
/// The 7 key.
|
||||
/// </summary>
|
||||
D7 = 55,
|
||||
|
||||
/// <summary>
|
||||
/// The 8 key.
|
||||
/// </summary>
|
||||
D8 = 56,
|
||||
|
||||
/// <summary>
|
||||
/// The 9 key.
|
||||
/// </summary>
|
||||
D9 = 57,
|
||||
|
||||
/// <summary>
|
||||
/// The semicolon key.
|
||||
/// </summary>
|
||||
Semicolon = 59 /* ; */,
|
||||
|
||||
/// <summary>
|
||||
/// The equal key.
|
||||
/// </summary>
|
||||
Equal = 61 /* = */,
|
||||
|
||||
/// <summary>
|
||||
/// The A key.
|
||||
/// </summary>
|
||||
A = 65,
|
||||
|
||||
/// <summary>
|
||||
/// The B key.
|
||||
/// </summary>
|
||||
B = 66,
|
||||
|
||||
/// <summary>
|
||||
/// The C key.
|
||||
/// </summary>
|
||||
C = 67,
|
||||
|
||||
/// <summary>
|
||||
/// The D key.
|
||||
/// </summary>
|
||||
D = 68,
|
||||
|
||||
/// <summary>
|
||||
/// The E key.
|
||||
/// </summary>
|
||||
E = 69,
|
||||
|
||||
/// <summary>
|
||||
/// The F key.
|
||||
/// </summary>
|
||||
F = 70,
|
||||
|
||||
/// <summary>
|
||||
/// The G key.
|
||||
/// </summary>
|
||||
G = 71,
|
||||
|
||||
/// <summary>
|
||||
/// The H key.
|
||||
/// </summary>
|
||||
H = 72,
|
||||
|
||||
/// <summary>
|
||||
/// The I key.
|
||||
/// </summary>
|
||||
I = 73,
|
||||
|
||||
/// <summary>
|
||||
/// The J key.
|
||||
/// </summary>
|
||||
J = 74,
|
||||
|
||||
/// <summary>
|
||||
/// The K key.
|
||||
/// </summary>
|
||||
K = 75,
|
||||
|
||||
/// <summary>
|
||||
/// The L key.
|
||||
/// </summary>
|
||||
L = 76,
|
||||
|
||||
/// <summary>
|
||||
/// The M key.
|
||||
/// </summary>
|
||||
M = 77,
|
||||
|
||||
/// <summary>
|
||||
/// The N key.
|
||||
/// </summary>
|
||||
N = 78,
|
||||
|
||||
/// <summary>
|
||||
/// The O key.
|
||||
/// </summary>
|
||||
O = 79,
|
||||
|
||||
/// <summary>
|
||||
/// The P key.
|
||||
/// </summary>
|
||||
P = 80,
|
||||
|
||||
/// <summary>
|
||||
/// The Q key.
|
||||
/// </summary>
|
||||
Q = 81,
|
||||
|
||||
/// <summary>
|
||||
/// The R key.
|
||||
/// </summary>
|
||||
R = 82,
|
||||
|
||||
/// <summary>
|
||||
/// The S key.
|
||||
/// </summary>
|
||||
S = 83,
|
||||
|
||||
/// <summary>
|
||||
/// The T key.
|
||||
/// </summary>
|
||||
T = 84,
|
||||
|
||||
/// <summary>
|
||||
/// The U key.
|
||||
/// </summary>
|
||||
U = 85,
|
||||
|
||||
/// <summary>
|
||||
/// The V key.
|
||||
/// </summary>
|
||||
V = 86,
|
||||
|
||||
/// <summary>
|
||||
/// The W key.
|
||||
/// </summary>
|
||||
W = 87,
|
||||
|
||||
/// <summary>
|
||||
/// The X key.
|
||||
/// </summary>
|
||||
X = 88,
|
||||
|
||||
/// <summary>
|
||||
/// The Y key.
|
||||
/// </summary>
|
||||
Y = 89,
|
||||
|
||||
/// <summary>
|
||||
/// The Z key.
|
||||
/// </summary>
|
||||
Z = 90,
|
||||
|
||||
/// <summary>
|
||||
/// The left bracket(opening bracket) key.
|
||||
/// </summary>
|
||||
LeftBracket = 91 /* [ */,
|
||||
|
||||
/// <summary>
|
||||
/// The backslash.
|
||||
/// </summary>
|
||||
Backslash = 92 /* \ */,
|
||||
|
||||
/// <summary>
|
||||
/// The right bracket(closing bracket) key.
|
||||
/// </summary>
|
||||
RightBracket = 93 /* ] */,
|
||||
|
||||
/// <summary>
|
||||
/// The grave accent key.
|
||||
/// </summary>
|
||||
GraveAccent = 96 /* ` */,
|
||||
|
||||
/// <summary>
|
||||
/// Non US keyboard layout key 1.
|
||||
/// </summary>
|
||||
World1 = 161 /* non-US #1 */,
|
||||
|
||||
/// <summary>
|
||||
/// Non US keyboard layout key 2.
|
||||
/// </summary>
|
||||
World2 = 162 /* non-US #2 */,
|
||||
|
||||
/// <summary>
|
||||
/// The escape key.
|
||||
/// </summary>
|
||||
Escape = 256,
|
||||
|
||||
/// <summary>
|
||||
/// The enter key.
|
||||
/// </summary>
|
||||
Enter = 257,
|
||||
|
||||
/// <summary>
|
||||
/// The tab key.
|
||||
/// </summary>
|
||||
Tab = 258,
|
||||
|
||||
/// <summary>
|
||||
/// The backspace key.
|
||||
/// </summary>
|
||||
Backspace = 259,
|
||||
|
||||
/// <summary>
|
||||
/// The insert key.
|
||||
/// </summary>
|
||||
Insert = 260,
|
||||
|
||||
/// <summary>
|
||||
/// The delete key.
|
||||
/// </summary>
|
||||
Delete = 261,
|
||||
|
||||
/// <summary>
|
||||
/// The right arrow key.
|
||||
/// </summary>
|
||||
Right = 262,
|
||||
|
||||
/// <summary>
|
||||
/// The left arrow key.
|
||||
/// </summary>
|
||||
Left = 263,
|
||||
|
||||
/// <summary>
|
||||
/// The down arrow key.
|
||||
/// </summary>
|
||||
Down = 264,
|
||||
|
||||
/// <summary>
|
||||
/// The up arrow key.
|
||||
/// </summary>
|
||||
Up = 265,
|
||||
|
||||
/// <summary>
|
||||
/// The page up key.
|
||||
/// </summary>
|
||||
PageUp = 266,
|
||||
|
||||
/// <summary>
|
||||
/// The page down key.
|
||||
/// </summary>
|
||||
PageDown = 267,
|
||||
|
||||
/// <summary>
|
||||
/// The home key.
|
||||
/// </summary>
|
||||
Home = 268,
|
||||
|
||||
/// <summary>
|
||||
/// The end key.
|
||||
/// </summary>
|
||||
End = 269,
|
||||
|
||||
/// <summary>
|
||||
/// The caps lock key.
|
||||
/// </summary>
|
||||
CapsLock = 280,
|
||||
|
||||
/// <summary>
|
||||
/// The scroll lock key.
|
||||
/// </summary>
|
||||
ScrollLock = 281,
|
||||
|
||||
/// <summary>
|
||||
/// The num lock key.
|
||||
/// </summary>
|
||||
NumLock = 282,
|
||||
|
||||
/// <summary>
|
||||
/// The print screen key.
|
||||
/// </summary>
|
||||
PrintScreen = 283,
|
||||
|
||||
/// <summary>
|
||||
/// The pause key.
|
||||
/// </summary>
|
||||
Pause = 284,
|
||||
|
||||
/// <summary>
|
||||
/// The F1 key.
|
||||
/// </summary>
|
||||
F1 = 290,
|
||||
|
||||
/// <summary>
|
||||
/// The F2 key.
|
||||
/// </summary>
|
||||
F2 = 291,
|
||||
|
||||
/// <summary>
|
||||
/// The F3 key.
|
||||
/// </summary>
|
||||
F3 = 292,
|
||||
|
||||
/// <summary>
|
||||
/// The F4 key.
|
||||
/// </summary>
|
||||
F4 = 293,
|
||||
|
||||
/// <summary>
|
||||
/// The F5 key.
|
||||
/// </summary>
|
||||
F5 = 294,
|
||||
|
||||
/// <summary>
|
||||
/// The F6 key.
|
||||
/// </summary>
|
||||
F6 = 295,
|
||||
|
||||
/// <summary>
|
||||
/// The F7 key.
|
||||
/// </summary>
|
||||
F7 = 296,
|
||||
|
||||
/// <summary>
|
||||
/// The F8 key.
|
||||
/// </summary>
|
||||
F8 = 297,
|
||||
|
||||
/// <summary>
|
||||
/// The F9 key.
|
||||
/// </summary>
|
||||
F9 = 298,
|
||||
|
||||
/// <summary>
|
||||
/// The F10 key.
|
||||
/// </summary>
|
||||
F10 = 299,
|
||||
|
||||
/// <summary>
|
||||
/// The F11 key.
|
||||
/// </summary>
|
||||
F11 = 300,
|
||||
|
||||
/// <summary>
|
||||
/// The F12 key.
|
||||
/// </summary>
|
||||
F12 = 301,
|
||||
|
||||
/// <summary>
|
||||
/// The F13 key.
|
||||
/// </summary>
|
||||
F13 = 302,
|
||||
|
||||
/// <summary>
|
||||
/// The F14 key.
|
||||
/// </summary>
|
||||
F14 = 303,
|
||||
|
||||
/// <summary>
|
||||
/// The F15 key.
|
||||
/// </summary>
|
||||
F15 = 304,
|
||||
|
||||
/// <summary>
|
||||
/// The F16 key.
|
||||
/// </summary>
|
||||
F16 = 305,
|
||||
|
||||
/// <summary>
|
||||
/// The F17 key.
|
||||
/// </summary>
|
||||
F17 = 306,
|
||||
|
||||
/// <summary>
|
||||
/// The F18 key.
|
||||
/// </summary>
|
||||
F18 = 307,
|
||||
|
||||
/// <summary>
|
||||
/// The F19 key.
|
||||
/// </summary>
|
||||
F19 = 308,
|
||||
|
||||
/// <summary>
|
||||
/// The F20 key.
|
||||
/// </summary>
|
||||
F20 = 309,
|
||||
|
||||
/// <summary>
|
||||
/// The F21 key.
|
||||
/// </summary>
|
||||
F21 = 310,
|
||||
|
||||
/// <summary>
|
||||
/// The F22 key.
|
||||
/// </summary>
|
||||
F22 = 311,
|
||||
|
||||
/// <summary>
|
||||
/// The F23 key.
|
||||
/// </summary>
|
||||
F23 = 312,
|
||||
|
||||
/// <summary>
|
||||
/// The F24 key.
|
||||
/// </summary>
|
||||
F24 = 313,
|
||||
|
||||
/// <summary>
|
||||
/// The F25 key.
|
||||
/// </summary>
|
||||
F25 = 314,
|
||||
|
||||
/// <summary>
|
||||
/// The 0 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad0 = 320,
|
||||
|
||||
/// <summary>
|
||||
/// The 1 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad1 = 321,
|
||||
|
||||
/// <summary>
|
||||
/// The 2 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad2 = 322,
|
||||
|
||||
/// <summary>
|
||||
/// The 3 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad3 = 323,
|
||||
|
||||
/// <summary>
|
||||
/// The 4 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad4 = 324,
|
||||
|
||||
/// <summary>
|
||||
/// The 5 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad5 = 325,
|
||||
|
||||
/// <summary>
|
||||
/// The 6 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad6 = 326,
|
||||
|
||||
/// <summary>
|
||||
/// The 7 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad7 = 327,
|
||||
|
||||
/// <summary>
|
||||
/// The 8 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad8 = 328,
|
||||
|
||||
/// <summary>
|
||||
/// The 9 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad9 = 329,
|
||||
|
||||
/// <summary>
|
||||
/// The decimal key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadDecimal = 330,
|
||||
|
||||
/// <summary>
|
||||
/// The divide key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadDivide = 331,
|
||||
|
||||
/// <summary>
|
||||
/// The multiply key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadMultiply = 332,
|
||||
|
||||
/// <summary>
|
||||
/// The subtract key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadSubtract = 333,
|
||||
|
||||
/// <summary>
|
||||
/// The add key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadAdd = 334,
|
||||
|
||||
/// <summary>
|
||||
/// The enter key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadEnter = 335,
|
||||
|
||||
/// <summary>
|
||||
/// The equal key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadEqual = 336,
|
||||
|
||||
/// <summary>
|
||||
/// The left shift key.
|
||||
/// </summary>
|
||||
LeftShift = 340,
|
||||
|
||||
/// <summary>
|
||||
/// The left control key.
|
||||
/// </summary>
|
||||
LeftControl = 341,
|
||||
|
||||
/// <summary>
|
||||
/// The left alt key.
|
||||
/// </summary>
|
||||
LeftAlt = 342,
|
||||
|
||||
/// <summary>
|
||||
/// The left super key.
|
||||
/// </summary>
|
||||
LeftSuper = 343,
|
||||
|
||||
/// <summary>
|
||||
/// The right shift key.
|
||||
/// </summary>
|
||||
RightShift = 344,
|
||||
|
||||
/// <summary>
|
||||
/// The right control key.
|
||||
/// </summary>
|
||||
RightControl = 345,
|
||||
|
||||
/// <summary>
|
||||
/// The right alt key.
|
||||
/// </summary>
|
||||
RightAlt = 346,
|
||||
|
||||
/// <summary>
|
||||
/// The right super key.
|
||||
/// </summary>
|
||||
RightSuper = 347,
|
||||
|
||||
/// <summary>
|
||||
/// The menu key.
|
||||
/// </summary>
|
||||
Menu = 348,
|
||||
|
||||
/// <summary>
|
||||
/// The last valid key in this enum.
|
||||
/// </summary>
|
||||
LastKey = Menu
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the buttons of a mouse.
|
||||
/// </summary>
|
||||
public enum MouseButton : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// The first button.
|
||||
/// </summary>
|
||||
Button1 = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The second button.
|
||||
/// </summary>
|
||||
Button2 = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The third button.
|
||||
/// </summary>
|
||||
Button3 = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The fourth button.
|
||||
/// </summary>
|
||||
Button4 = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The fifth button.
|
||||
/// </summary>
|
||||
Button5 = 4,
|
||||
|
||||
/// <summary>
|
||||
/// The sixth button.
|
||||
/// </summary>
|
||||
Button6 = 5,
|
||||
|
||||
/// <summary>
|
||||
/// The seventh button.
|
||||
/// </summary>
|
||||
Button7 = 6,
|
||||
|
||||
/// <summary>
|
||||
/// The eighth button.
|
||||
/// </summary>
|
||||
Button8 = 7,
|
||||
|
||||
/// <summary>
|
||||
/// The left mouse button. This corresponds to <see cref="Button1"/>.
|
||||
/// </summary>
|
||||
Left = Button1,
|
||||
|
||||
/// <summary>
|
||||
/// The right mouse button. This corresponds to <see cref="Button2"/>.
|
||||
/// </summary>
|
||||
Right = Button2,
|
||||
|
||||
/// <summary>
|
||||
/// The middle mouse button. This corresponds to <see cref="Button3"/>.
|
||||
/// </summary>
|
||||
Middle = Button3,
|
||||
|
||||
/// <summary>
|
||||
/// The highest mouse button available.
|
||||
/// </summary>
|
||||
Last = Button8,
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// OpenGlProfile.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The OpenGL context profiles.
|
||||
/// </summary>
|
||||
public enum OpenGlProfile
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for unknown OpenGL profile or OpenGL ES.
|
||||
/// </summary>
|
||||
Any = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Known OpenGL Core profile.
|
||||
/// </summary>
|
||||
Core = 0x00032001,
|
||||
|
||||
/// <summary>
|
||||
/// Known OpenGL compatibility profile.
|
||||
/// </summary>
|
||||
Compat = 0x00032002
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// ReleaseBehavior.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The context release behaviors.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintReleaseBehavior,ReleaseBehavior)"/>
|
||||
public enum ReleaseBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the default release behavior of the platform.
|
||||
/// </summary>
|
||||
Any = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The pipeline will be flushed whenever the context is released from being the current one.
|
||||
/// </summary>
|
||||
Flush = 0x00035001,
|
||||
|
||||
/// <summary>
|
||||
/// The pipeline will not be flushed on release.
|
||||
/// </summary>
|
||||
None = 0x00035002
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// Robustness.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// OpenGL context robustness strategy.
|
||||
/// </summary>
|
||||
public enum Robustness
|
||||
{
|
||||
/// <summary>
|
||||
/// No context robustness strategy.
|
||||
/// </summary>
|
||||
NoRobustness = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Robust context without a reset notification.
|
||||
/// </summary>
|
||||
NoResetNotification = 0x00031001,
|
||||
|
||||
/// <summary>
|
||||
/// Lose context on reset.
|
||||
/// </summary>
|
||||
LoseContextOnReset = 0x00031002
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// StickyAttributes.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Attributes related to sticky keys and buttons.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.SetInputMode(Window*,StickyAttributes,bool)"/>
|
||||
/// <seealso cref="GLFW.GetInputMode(Window*,StickyAttributes)"/>
|
||||
public enum StickyAttributes
|
||||
{
|
||||
/// <summary>
|
||||
/// Specify whether keyboard input should be sticky or not.
|
||||
/// </summary>
|
||||
StickyKeys = 0x00033002,
|
||||
|
||||
/// <summary>
|
||||
/// Specify whether mouse button input should be sticky or not.
|
||||
/// </summary>
|
||||
StickyMouseButtons = 0x00033003
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
//
|
||||
// WindowAttributeSetter.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to get window related attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.GetWindowAttrib"/>
|
||||
public enum WindowAttributeGetter
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has input focus.
|
||||
/// Initial input focus is controlled by the window hint with the same name
|
||||
/// </summary>
|
||||
Focused = WindowHintBool.Focused,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is iconified,
|
||||
/// whether by the user or with <see cref="GLFW.IconifyWindow"/>.
|
||||
/// </summary>
|
||||
Iconified = WindowHintBool.Iconified,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is resizable by the user.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Resizable = WindowHintBool.Resizable,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is visible.
|
||||
/// Window visibility can be controlled with <see cref="GLFW.ShowWindow"/> and <see cref="GLFW.HideWindow"/>
|
||||
/// and initial visibility is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Visible = WindowHintBool.Visible,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Decorated = WindowHintBool.Decorated,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the full screen window will automatically iconify and restore
|
||||
/// the previous video mode on input focus loss.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
AutoIconify = WindowHintBool.AutoIconify,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
|
||||
/// This is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Floating = WindowHintBool.Floating,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is maximized,
|
||||
/// whether by the user or with <see cref="GLFW.MaximizeWindow"/>.
|
||||
/// </summary>
|
||||
Maximized = WindowHintBool.Maximized,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the cursor should be centered over newly created full screen windows.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
CenterCursor = WindowHintBool.CenterCursor,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window framebuffer will be transparent.
|
||||
/// If enabled and supported by the system, the window framebuffer alpha channel will be used
|
||||
/// to combine the framebuffer with the background.
|
||||
/// This does not affect window decorations. Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
TransparentFramebuffer = WindowHintBool.TransparentFramebuffer,
|
||||
|
||||
/// <summary>
|
||||
/// indicates whether the cursor is currently directly over the client area of the window,
|
||||
/// with no other windows between.
|
||||
/// See <a href="https://www.glfw.org/docs/3.3/input_guide.html#cursor_enter">Cursor enter/leave events</a>
|
||||
/// for details.
|
||||
/// </summary>
|
||||
Hovered = WindowHintBool.Hovered,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
FocusOnShow = WindowHintBool.FocusOnShow,
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
//
|
||||
// WindowAttributeSetter.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set window related attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.SetWindowAttrib"/>
|
||||
public enum WindowAttributeSetter
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is resizable by the user.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Resizable = WindowHintBool.Resizable,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Decorated = WindowHintBool.Decorated,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the full screen window will automatically iconify and restore
|
||||
/// the previous video mode on input focus loss.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
AutoIconify = WindowHintBool.AutoIconify,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
|
||||
/// This is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Floating = WindowHintBool.Floating,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
FocusOnShow = WindowHintBool.FocusOnShow
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
//
|
||||
// WindowHintBool.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Context related boolean attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintBool,bool)"/>
|
||||
public enum WindowHintBool
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has input focus.
|
||||
/// Initial input focus is controlled by the window hint with the same name
|
||||
/// </summary>
|
||||
Focused = 0x00020001,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is iconified,
|
||||
/// whether by the user or with <see cref="GLFW.IconifyWindow"/>.
|
||||
/// </summary>
|
||||
Iconified = 0x00020002,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is resizable by the user.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Resizable = 0x00020003,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is visible.
|
||||
/// Window visibility can be controlled with <see cref="GLFW.ShowWindow"/> and <see cref="GLFW.HideWindow"/>
|
||||
/// and initial visibility is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Visible = 0x00020004,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Decorated = 0x00020005,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the full screen window will automatically iconify and restore
|
||||
/// the previous video mode on input focus loss.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
AutoIconify = 0x00020006,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
|
||||
/// This is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Floating = 0x00020007,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is maximized,
|
||||
/// whether by the user or with <see cref="GLFW.MaximizeWindow"/>.
|
||||
/// </summary>
|
||||
Maximized = 0x00020008,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the cursor should be centered over newly created full screen windows.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
CenterCursor = 0x00020009,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window framebuffer will be transparent.
|
||||
/// If enabled and supported by the system, the window framebuffer alpha channel will be used
|
||||
/// to combine the framebuffer with the background.
|
||||
/// This does not affect window decorations. Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
TransparentFramebuffer = 0x0002000A,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the cursor is currently directly over the client area of the window,
|
||||
/// with no other windows between.
|
||||
/// See <a href="https://www.glfw.org/docs/3.3/input_guide.html#cursor_enter">Cursor enter/leave events</a>
|
||||
/// for details.
|
||||
/// </summary>
|
||||
Hovered = 0x0002000B,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
FocusOnShow = 0x0002000C,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window's context is an OpenGL forward-compatible one.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
OpenGLForwardCompat = 0x00022006,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window's context is an OpenGL debug context.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
OpenGLDebugContext = 0x00022007,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether errors should be generated by the context.
|
||||
/// If enabled, situations that would have generated errors instead cause undefined behavior.
|
||||
/// </summary>
|
||||
ContextNoError = 0x0002200A,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether to use stereoscopic rendering. This is a hard constraint.
|
||||
/// </summary>
|
||||
Stereo = 0x0002100C,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the framebuffer should be double buffered.
|
||||
/// You nearly always want to use double buffering. This is a hard constraint.
|
||||
/// </summary>
|
||||
DoubleBuffer = 0x00021010,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the framebuffer should be sRGB capable.
|
||||
/// If supported, a created OpenGL context will support the
|
||||
/// <c>GL_FRAMEBUFFER_SRGB</c> enable( also called <c>GL_FRAMEBUFFER_SRGB_EXT</c>)
|
||||
/// for controlling sRGB rendering and a created OpenGL ES context will always have sRGB rendering enabled.
|
||||
/// </summary>
|
||||
SrgbCapable = 0x0002100E,
|
||||
|
||||
ScaleToMonitor = 0x0002200C,
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// WindowHintClientApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Context related client API attribute.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintClientApi,ClientApi)"/>
|
||||
public enum WindowHintClientApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the client API provided by the window's context;
|
||||
/// either <see cref="GraphicsLibraryFramework.ClientApi.OpenGlApi"/>,
|
||||
/// <see cref="GraphicsLibraryFramework.ClientApi.OpenGlEsApi"/> or
|
||||
/// <see cref="GraphicsLibraryFramework.ClientApi.NoApi"/>.
|
||||
/// </summary>
|
||||
ClientApi = 0x00022001,
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// WindowHintContextApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify the context creation API.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintContextApi,ContextApi)"/>
|
||||
public enum WindowHintContextApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the context creation API used to create the window's context;
|
||||
/// either <see cref="ContextApi.NativeContextApi"/> or <see cref="ContextApi.EglContextApi"/>.
|
||||
/// </summary>
|
||||
ContextCreationApi = 0x0002200B,
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
//
|
||||
// WindowHintInt.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Context related attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintInt,int)"/>
|
||||
public enum WindowHintInt
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicate the client API version(major part) of the window's context.
|
||||
/// </summary>
|
||||
ContextVersionMajor = 0x00022002,
|
||||
|
||||
/// <summary>
|
||||
/// Indicate the client API version(minor part) of the window's context.
|
||||
/// </summary>
|
||||
ContextVersionMinor = 0x00022003,
|
||||
|
||||
/// <summary>
|
||||
/// Indicate the client API version(revision part) of the window's context.
|
||||
/// </summary>
|
||||
ContextRevision = 0x00022004,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the red component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
RedBits = 0x00021001,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the green component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
GreenBits = 0x00021002,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the blue component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
BlueBits = 0x00021003,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the alpha component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
AlphaBits = 0x00021004,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the depth component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
DepthBits = 0x00021005,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the stencil component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
StencilBits = 0x00021006,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the red component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumRedBits = 0x00021007,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the green component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumGreenBits = 0x00021008,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the blue component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumBlueBits = 0x00021009,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the alpha component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumAlphaBits = 0x0002100A,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the desired number of auxiliary buffers.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Auxiliary buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AuxBuffers = 0x0002100B,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the desired number of samples to use for multisampling. Zero disables multisampling.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
Samples = 0x0002100D,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the desired refresh rate for full screen windows.
|
||||
/// If set to <see cref="GLFW.DontCare"/>,
|
||||
/// the highest available refresh rate will be used. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
RefreshRate = 0x0002100F,
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// WindowHintOpenGlProfile.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set the OpenGlProfile attribute.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintOpenGlProfile,OpenGlProfile)"/>
|
||||
public enum WindowHintOpenGlProfile
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the OpenGL profile used by the context.
|
||||
/// This is <see cref="GraphicsLibraryFramework.OpenGlProfile.Core"/>
|
||||
/// or <see cref="GraphicsLibraryFramework.OpenGlProfile.Compat"/>
|
||||
/// if the context uses a known profile, or <see cref="GraphicsLibraryFramework.OpenGlProfile.Any"/>
|
||||
/// if the OpenGL profile is unknown or the context is an OpenGL ES context.
|
||||
/// Note that the returned profile may not match the profile bits of the context flags,
|
||||
/// as GLFW will try other means of detecting the profile when no bits are set. TODO: enum for missing crefs
|
||||
/// </summary>
|
||||
OpenGlProfile = 0x00022008,
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// WindowHintReleaseBehavior.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify the release behavior used by the local context.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintReleaseBehavior,ReleaseBehavior)"/>
|
||||
public enum WindowHintReleaseBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the release behavior to be used by the context.
|
||||
/// Possible values are one of <see cref="ReleaseBehavior.Any"/>,
|
||||
/// <see cref="ReleaseBehavior.Flush"/> or <see cref="ReleaseBehavior.None"/>.
|
||||
/// If the behavior is <see cref="ReleaseBehavior"/>, the default behavior
|
||||
/// of the context creation API will be used.
|
||||
/// If the behavior is <see cref="ReleaseBehavior.Flush"/>, the pipeline will be flushed
|
||||
/// whenever the context is released from being the current one.
|
||||
/// If the behavior is <see cref="ReleaseBehavior.None"/>, the pipeline will not be flushed on release.
|
||||
/// </summary>
|
||||
ContextReleaseBehavior = 0x00022009,
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// WindowHintRobustness.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set context robustness attribute.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintRobustness,Robustness)"/>
|
||||
public enum WindowHintRobustness
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the robustness strategy used by the context.
|
||||
/// This is <see cref="Robustness.LoseContextOnReset"/> or <see cref="Robustness.NoResetNotification"/>
|
||||
/// if the window's context supports robustness, or <see cref="Robustness.NoRobustness"/> otherwise.
|
||||
/// </summary>
|
||||
ContextRobustness = 0x00022005,
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Window hints for the WindowHintString function.
|
||||
/// </summary>
|
||||
public enum WindowHintString
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the frame name on Cocoa. On any other platform, this does nothing.
|
||||
/// </summary>
|
||||
CocoaFrameName = 0x00023002,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the class name on X11. On any other platform, this does nothing.
|
||||
/// </summary>
|
||||
X11ClassName = 0x00024001,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the instance name on X11. on any other platform, this does nothing.
|
||||
/// </summary>
|
||||
X11InstanceName = 0x00024002,
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,180 +0,0 @@
|
||||
//
|
||||
// GLFWCallbacks.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing GLFW related callbacks.
|
||||
/// </summary>
|
||||
public static unsafe class GLFWCallbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// The function signature for Unicode character callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="codepoint">The Unicode code point of the character.</param>
|
||||
/// <seealso cref="GLFW.SetCharCallback"/>
|
||||
public delegate void CharCallback(Window* window, uint codepoint);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for Unicode character with modifiers callback functions.
|
||||
/// It is called for each input character, regardless of what modifier keys are held down.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="codepoint">The Unicode code point of the character.</param>
|
||||
/// <param name="modifiers">Bit field describing which modifier keys were held down.</param>
|
||||
/// <seealso cref="GLFW.SetCharModsCallback"/>
|
||||
public delegate void CharModsCallback(Window* window, uint codepoint, KeyModifiers modifiers);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for cursor enter/leave callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="entered"><c>true</c> if the cursor entered the window's client area, or <c>false</c> if it left it.</param>
|
||||
/// <seealso cref="GLFW.SetCursorEnterCallback"/>
|
||||
public delegate void CursorEnterCallback(Window* window, bool entered);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for cursor position callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="x">The new cursor x-coordinate, relative to the left edge of the client area.</param>
|
||||
/// <param name="y">The new cursor y-coordinate, relative to the top edge of the client area.</param>
|
||||
/// <seealso cref="GLFW.SetCursorPosCallback"/>
|
||||
public delegate void CursorPosCallback(Window* window, double x, double y);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for file drop callbacks.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="count">The number of dropped files.</param>
|
||||
/// <param name="paths">The UTF-8 encoded file and/or directory path names.</param>
|
||||
/// <seealso cref="GLFW.SetDropCallback"/>
|
||||
public delegate void DropCallback(Window* window, int count, byte** paths);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for joystick configuration callback functions.
|
||||
/// </summary>
|
||||
/// <param name="joystick">The joystick that was connected or disconnected.</param>
|
||||
/// <param name="state">
|
||||
/// One of <see cref="ConnectedState.Connected"/> or <see cref="ConnectedState.Disconnected"/>.
|
||||
/// </param>
|
||||
/// <seealso cref="GLFW.SetJoystickCallback"/>
|
||||
public delegate void JoystickCallback(int joystick, ConnectedState state);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for keyboard key callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="key">The keyboard key that was pressed or released.</param>
|
||||
/// <param name="scanCode">The system-specific scancode of the key.</param>
|
||||
/// <param name="action">The <see cref="InputAction"/> for that <paramref name="key"/>.</param>
|
||||
/// <param name="mods">Bit field describing which modifier keys were held down.</param>
|
||||
/// <seealso cref="GLFW.SetKeyCallback"/>
|
||||
public delegate void KeyCallback(Window* window, Keys key, int scanCode, InputAction action, KeyModifiers mods);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for mouse button callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="button">The mouse button that was pressed or released.</param>
|
||||
/// <param name="action">One of <see cref="InputAction.Press"/> or <see cref="InputAction.Release"/>.</param>
|
||||
/// <param name="mods">Bit field describing which modifier keys were held down.</param>
|
||||
/// <seealso cref="GLFW.SetMouseButtonCallback"/>
|
||||
public delegate void MouseButtonCallback(Window* window, MouseButton button, InputAction action, KeyModifiers mods); // TODO: Make enums for int params in callback
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for scroll callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="offsetX">The scroll offset along the x-axis.</param>
|
||||
/// <param name="offsetY">The scroll offset along the y-axis.</param>
|
||||
/// <seealso cref="GLFW.SetScrollCallback"/>
|
||||
public delegate void ScrollCallback(Window* window, double offsetX, double offsetY);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for monitor configuration callback functions.
|
||||
/// </summary>
|
||||
/// <param name="monitor">The monitor that was connected or disconnected.</param>
|
||||
/// <param name="state">
|
||||
/// One <see cref="ConnectedState.Connected"/> of or <see cref="ConnectedState.Disconnected"/>.
|
||||
/// </param>
|
||||
/// <seealso cref="GLFW.SetMonitorCallback"/>
|
||||
public delegate void MonitorCallback(Monitor* monitor, ConnectedState state);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window close callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that the user attempted to close.</param>
|
||||
/// <seealso cref="GLFW.SetWindowCloseCallback"/>
|
||||
public delegate void WindowCloseCallback(Window* window);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window focus callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that gained or lost input focus.</param>
|
||||
/// <param name="focused"><c>true</c> if the window was given input focus, or <c>false</c> if it lost it.</param>
|
||||
/// <seealso cref="GLFW.SetWindowFocusCallback"/>
|
||||
public delegate void WindowFocusCallback(Window* window, bool focused);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window iconify/restore callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that was iconified or restored.</param>
|
||||
/// <param name="iconified"><c>true</c> if the window was iconified(minimized), or <c>false</c> if it was restored.</param>
|
||||
/// <seealso cref="GLFW.SetWindowIconifyCallback"/>
|
||||
public delegate void WindowIconifyCallback(Window* window, bool iconified);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window position callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that was moved.</param>
|
||||
/// <param name="x">
|
||||
/// The new x-coordinate, in screen coordinates, of the upper-left corner of the client area of the window.
|
||||
/// </param>
|
||||
/// <param name="y">
|
||||
/// The new y-coordinate, in screen coordinates, of the upper-left corner of the client area of the window.
|
||||
/// </param>
|
||||
/// <seealso cref="GLFW.SetWindowPosCallback"/>
|
||||
public delegate void WindowPosCallback(Window* window, int x, int y);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window size callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that was resized.</param>
|
||||
/// <param name="width">The new width, in screen coordinates, of the window.</param>
|
||||
/// <param name="height">The new height, in screen coordinates, of the window.</param>
|
||||
/// <seealso cref="GLFW.SetWindowSizeCallback"/>
|
||||
public delegate void WindowSizeCallback(Window* window, int width, int height);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for error callback functions.
|
||||
/// </summary>
|
||||
/// <param name="error">An error code.</param>
|
||||
/// <param name="description">A UTF-8 encoded string describing the error.</param>
|
||||
public delegate void ErrorCallback(ErrorCode error, string description);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window refresh functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that needs to be refreshed.</param>
|
||||
public delegate void WindowRefreshCallback(Window* window);
|
||||
|
||||
/// <summary>
|
||||
/// This is the function pointer type for window content scale callbacks.
|
||||
/// </summary>
|
||||
/// <param name="window">The window whose content scale changed. </param>
|
||||
/// <param name="xscale">The new x-axis content scale of the window. </param>
|
||||
/// <param name="yscale">The new y-axis content scale of the window.</param>
|
||||
/// <seealso cref="GLFW.SetWindowContentScaleCallback"/>
|
||||
public delegate void WindowContentScaleCallback(Window* window, float xscale, float yscale);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
//
|
||||
// GLFWException.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occur within GLFW.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class GLFWException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the underlying GLFW-error code.
|
||||
/// </summary>
|
||||
public ErrorCode ErrorCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class.
|
||||
/// </summary>
|
||||
public GLFWException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified detailed description.
|
||||
/// </summary>
|
||||
/// <param name="message">A detailed description of the error.</param>
|
||||
public GLFWException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class
|
||||
/// with the specified detailed description and GLFW error code.
|
||||
/// </summary>
|
||||
/// <param name="message">A detailed description of the error.</param>
|
||||
/// <param name="errorCode">The GLFW error code causing the exception.</param>
|
||||
public GLFWException(string message, ErrorCode errorCode)
|
||||
: base(message)
|
||||
{
|
||||
ErrorCode = errorCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified detailed description
|
||||
/// and the specified exception.
|
||||
/// </summary>
|
||||
/// <param name="message">A detailed description of the error.</param>
|
||||
/// <param name="innerException">A reference to the inner exception that is the cause of this exception.</param>
|
||||
public GLFWException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,414 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
internal static unsafe class GLFWNative
|
||||
{
|
||||
private const string LibraryName = "glfw3.dll";
|
||||
|
||||
public const int GLFW_TRUE = 1;
|
||||
public const int GLFW_FALSE = 0;
|
||||
|
||||
#if NETCOREAPP
|
||||
static GLFWNative()
|
||||
{
|
||||
// Register DllImport resolver so that the correct dynamic library is loaded on all platforms.
|
||||
// On net472, we rely on Mono's DllMap for this. See the .dll.config file.
|
||||
NativeLibrary.SetDllImportResolver(typeof(GLFWNative).Assembly, (name, assembly, path) =>
|
||||
{
|
||||
// Please keep in sync with what Robust.Shared/DllMapHelper.cs does.
|
||||
|
||||
if (name != "glfw3.dll")
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
string rName = null;
|
||||
if (OperatingSystem.IsLinux() || OperatingSystem.IsFreeBSD()) rName = "libglfw.so.3";
|
||||
else if (OperatingSystem.IsMacOS()) rName = "libglfw.3.dylib";
|
||||
|
||||
if ((rName != null) && NativeLibrary.TryLoad(rName, assembly, path, out var handle))
|
||||
return handle;
|
||||
|
||||
return IntPtr.Zero;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwInit();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwTerminate();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwInitHint(int hint, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetVersion(int* major, int* minor, int* revision);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetVersionString();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern ErrorCode glfwGetError(byte** description);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Monitor** glfwGetMonitors(int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetMonitorPos(Monitor* monitor, int* x, int* y);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetMonitorPhysicalSize(Monitor* monitor, int* width, int* height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetMonitorContentScale(Monitor* monitor, float* xscale, float* yscale);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetMonitorName(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetMonitorUserPointer(Monitor* monitor, void* pointer);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void* glfwGetMonitorUserPointer(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern VideoMode* glfwGetVideoModes(Monitor* monitor, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetGamma(Monitor* monitor, float gamma);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern GammaRamp* glfwGetGammaRamp(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetGammaRamp(Monitor* monitor, GammaRamp* ramp);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwDefaultWindowHints();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHintString(int hint, byte* value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowSizeLimits(Window* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowAspectRatio(Window* window, int numer, int denom);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowFrameSize(Window* window, int* left, int* top, int* right, int* bottom);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowContentScale(Window* window, float* xscale, float* yscale);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern float glfwGetWindowOpacity(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowOpacity(Window* window, float opacity);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwRequestWindowAttention(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowAttrib(Window* window, WindowAttributeSetter attrib, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwRawMouseMotionSupported();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetKeyName(Keys key, int scancode);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetKeyScancode(Keys key);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern InputAction glfwGetKey(Window* window, Keys key);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern InputAction glfwGetMouseButton(Window* window, MouseButton button);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetCursorPos(Window* window, double* xpos, double* ypos);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetCursorPos(Window* window, double xpos, double ypos);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Cursor* glfwCreateCursor(Image* image, int xhot, int yhot);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Cursor* glfwCreateStandardCursor(CursorShape shape);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwDestroyCursor(Cursor* cursor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetCursor(Window* window, Cursor* cursor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwJoystickPresent(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern float* glfwGetJoystickAxes(int jid, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern InputAction* glfwGetJoystickButtons(int jid, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern JoystickHats* glfwGetJoystickHats(int jid, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetJoystickName(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetJoystickGUID(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetJoystickUserPointer(int jid, void* ptr);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void* glfwGetJoystickUserPointer(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwJoystickIsGamepad(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwUpdateGamepadMappings(byte* newMapping);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetGamepadName(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetGamepadState(int jid, GamepadState* state);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern double glfwGetTime();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetTime(double time);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern long glfwGetTimerValue();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern long glfwGetTimerFrequency();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Window* glfwGetCurrentContext();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSwapBuffers(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwExtensionSupported(byte* extensionName);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwGetProcAddress(byte* procame);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Window* glfwCreateWindow(int width, int height, byte* title, Monitor* monitor, Window* share);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Monitor* glfwGetPrimaryMonitor();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwDestroyWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwFocusWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetFramebufferSize(Window* window, int* width, int* height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern CursorModeValue glfwGetInputMode(Window* window, CursorStateAttribute mode);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetInputMode(Window* window, StickyAttributes mode);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwRestoreWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern VideoMode* glfwGetVideoMode(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetWindowAttrib(Window* window, WindowAttributeGetter attribute);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowSize(Window* window, int* width, int* height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowPos(Window* window, int* x, int* y);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Monitor* glfwGetWindowMonitor(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwHideWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwIconifyWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwMakeContextCurrent(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwMaximizeWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwPollEvents();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwPostEmptyEvent();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintInt hint, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintBool hint, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintClientApi hint, ClientApi value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintReleaseBehavior hint, ReleaseBehavior value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintContextApi hint, ContextApi value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintRobustness hint, Robustness value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintOpenGlProfile hint, OpenGlProfile value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwWindowShouldClose(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCharCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCharModsCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCursorEnterCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCursorPosCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetDropCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetErrorCallback(IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetInputMode(Window* window, CursorStateAttribute mode, CursorModeValue value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetInputMode(Window* window, StickyAttributes mode, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetJoystickCallback(IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetKeyCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetScrollCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetMonitorCallback(IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetMouseButtonCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowCloseCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowFocusCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowIcon(Window* window, int count, Image* images);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowIconifyCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowContentScaleCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowTitle(Window* window, byte* title);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwShowWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowSize(Window* window, int width, int height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowSizeCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowShouldClose(Window* window, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowMonitor(Window* window, Monitor* monitor, int x, int y, int width, int height, int refreshRate);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowPos(Window* window, int x, int y);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowPosCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowRefreshCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSwapInterval(int interval);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWaitEvents();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWaitEventsTimeout(double timeout);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetClipboardString(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetClipboardString(Window* window, byte* data);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwVulkanSupported();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte** glfwGetRequiredInstanceExtensions(uint* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwGetInstanceProcAddress(VkHandle instance, byte* procName);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetPhysicalDevicePresentationSupport(VkHandle instance, VkHandle device, int queueFamily);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwCreateWindowSurface(VkHandle instance, Window* window, void* allocator, VkHandle surface);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern uint glfwGetX11Window(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwGetX11Display(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwGetWin32Window(Window* window);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// GamepadState.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// This describes the input state of a gamepad.
|
||||
/// </summary>
|
||||
public struct GamepadState
|
||||
{
|
||||
/// <summary>
|
||||
/// State of each of the 15 gamepad buttons, equal to <see cref="InputAction.Press"/> or <see cref="InputAction.Release"/>.
|
||||
/// </summary>
|
||||
public unsafe fixed byte Buttons[15];
|
||||
|
||||
/// <summary>
|
||||
/// State of each of the 6 gamepad axes, ranging from -1.0 to 1.0.
|
||||
/// </summary>
|
||||
public unsafe fixed float Axes[6];
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// GammaRamp.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Gamma ramp for a <see cref="Monitor"/>.
|
||||
/// </summary>
|
||||
public unsafe struct GammaRamp
|
||||
{
|
||||
/// <summary>
|
||||
/// Red components of the gamma ramp.
|
||||
/// </summary>
|
||||
public ushort* Red;
|
||||
|
||||
/// <summary>
|
||||
/// Green components of the gamma ramp.
|
||||
/// </summary>
|
||||
public ushort* Green;
|
||||
|
||||
/// <summary>
|
||||
/// Blue components of the gamma ramp.
|
||||
/// </summary>
|
||||
public ushort* Blue;
|
||||
|
||||
/// <summary>
|
||||
/// Length of the arrays.
|
||||
/// </summary>
|
||||
public uint Size;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
//
|
||||
// Image.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains GLFW Image data.
|
||||
/// </summary>
|
||||
public unsafe struct Image
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Image"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="width">The width of the image in pixels.</param>
|
||||
/// <param name="height">The height of the image in pixels.</param>
|
||||
/// <param name="pixels"><see cref="IntPtr"/> pointing to the RGBA pixel data of the image.</param>
|
||||
public Image(int width, int height, byte* pixels)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Pixels = pixels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The width, in pixels, of this <see cref="Image"/>.
|
||||
/// </summary>
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height, in pixels, of this <see cref="Image"/>.
|
||||
/// </summary>
|
||||
public int Height;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="byte"/> pointer pointing to the RGBA pixel data.
|
||||
/// </summary>
|
||||
public byte* Pixels;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2006-2019 Stefanos Apostolopoulos for the Open Toolkit project.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
- The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
#### Third party licenses may be applicable. These have been disclosed in [THIRD_PARTIES.md](THIRD_PARTIES.md)
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// Monitor.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Opaque handle to a GLFW monitor.
|
||||
/// </summary>
|
||||
public struct Monitor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
# Third parties
|
||||
|
||||
## AdvancedDLSupport
|
||||
> OpenTK uses AdvancedDLSupport for native interoperability. To enable compatibility with the LGPLv3 License, Firwood has given us a licensing exception.
|
||||
|
||||
* Read the [license grant](AdvancedDLSupport-LICENSE.pdf).
|
||||
* Read the [license summary](Short-LICENSE.md) for an easy-to-understand version.
|
||||
|
||||
## OpenEXR
|
||||
|
||||
> OpenTK.Half offers Half-to-Single and Single-to-Half conversions based on OpenEXR source code, which is covered by the following license:
|
||||
|
||||
Copyright (c) 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// VideoMode.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Replicated handle to a GLFW VideoMode.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct VideoMode
|
||||
{
|
||||
/// <summary>
|
||||
/// The width, in screen coordinates, of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height, in screen coordinates, of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int Height;
|
||||
|
||||
/// <summary>
|
||||
/// The bit depth of the red channel of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int RedBits;
|
||||
|
||||
/// <summary>
|
||||
/// The bit depth of the green channel of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int GreenBits;
|
||||
|
||||
/// <summary>
|
||||
/// The bit depth of the blue channel of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int BlueBits;
|
||||
|
||||
/// <summary>
|
||||
/// The refresh rate, in Hz, of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int RefreshRate;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to a Vulkan object.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct VkHandle
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual value of the Vulkan handle.
|
||||
/// </summary>
|
||||
public IntPtr Handle;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VkHandle"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="handle">
|
||||
/// The native Vulkan handle.
|
||||
/// This is NOT a pointer to a field containing the handle, this is the actual handle itself.
|
||||
/// </param>
|
||||
public VkHandle(IntPtr handle)
|
||||
{
|
||||
Handle = handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// Window.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Opaque handle to a GLFW window.
|
||||
/// </summary>
|
||||
public struct Window
|
||||
{
|
||||
}
|
||||
}
|
||||
161
RELEASE-NOTES.md
161
RELEASE-NOTES.md
@@ -39,31 +39,178 @@ END TEMPLATE-->
|
||||
|
||||
### New features
|
||||
|
||||
*None yet*
|
||||
* Sandbox:
|
||||
* Added `System.DateOnly` and `System.TimeOnly`.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
*None yet*
|
||||
* Fixed yaml hot reloading throwing invalid path exceptions.
|
||||
|
||||
### Other
|
||||
|
||||
*None yet*
|
||||
* Updated natives again to attempt to fix issues caused by the previous update.
|
||||
|
||||
### Internal
|
||||
|
||||
*None yet*
|
||||
|
||||
|
||||
## 266.0.4
|
||||
## 267.2.1
|
||||
|
||||
|
||||
## 266.0.3
|
||||
## 267.2.0
|
||||
|
||||
### New features
|
||||
|
||||
* Sprites and Sprite layers have a new `Loop` data field that can be set to false to automatically pause animations once they have finished.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fixed `CollectionExtensions.TryGetValue` throwing an exception when given a negative list index.
|
||||
* Fixed `EntityManager.PredictedQueueDeleteEntity()` not deferring changes for networked entities until the end of the tick.
|
||||
* Fixed `EntityManager.IsQueuedForDeletion` not returning true foe entities getting deleted via `PredictedQueueDeleteEntity()`
|
||||
|
||||
### Other
|
||||
|
||||
* `IResourceManager.GetContentRoots()` has been obsoleted and returns no more results.
|
||||
|
||||
### Internal
|
||||
|
||||
* `IResourceManager.GetContentRoots()` has been replaced with a similar method on `IResourceManagerInternal`. This new method returns `string`s instead of `ResPath`s, and usage code has been updated to use these paths correctly.
|
||||
|
||||
|
||||
## 266.0.2
|
||||
## 267.1.0
|
||||
|
||||
### New features
|
||||
|
||||
## 266.0.1
|
||||
* Animation:
|
||||
* `AnimationTrackProperty.KeyFrame` can now have easings functions applied.
|
||||
* Graphics:
|
||||
* `PointLightComponent` now has two fields, `falloff` and `curveFactor`, for controlling light falloff and the shape of the light attenuation curve.
|
||||
* `IClydeViewport` now has an `Id` and `ClearCachedResources` event. Together, these allow you to properly cache rendering resources per viewport.
|
||||
* Miscellaneous:
|
||||
* Added `display.max_fps` CVar.
|
||||
* Added `IGameTiming.FrameStartTime`.
|
||||
* Sandbox:
|
||||
* Added `System.WeakReference<T>`.
|
||||
* Added `SpaceWizards.Sodium.CryptoGenericHashBlake2B.Hash()`.
|
||||
* Added `System.Globalization.UnicodeCategory`.
|
||||
* Serialization:
|
||||
* Added a new entity yaml deserialization option (`SerializationOptions.EntityExceptionBehaviour`) that can optionally make deserialization more exception tolerant.
|
||||
* Tooling:
|
||||
* `devwindow` now has a tab listing active `IRenderTarget`s, allowing insight into resource consumption.
|
||||
* `loadgrid` now creates a map if passed an invalid map ID.
|
||||
* Added game version information to F3 overlay.
|
||||
* Added completions to more map commands.
|
||||
* UI system:
|
||||
* `Control.OrderedChildCollection` (gotten from `.Children`) now implements `IReadOnlyList<Control>`, allowing it to be indexed directly.
|
||||
* Added `WrapContainer` control. This lays out multiple elements along an axis, wrapping them if there's not enough space. It comes with many options and can handle multiple axes.
|
||||
* Popups/modals now work in secondary windows. This entails putting roots for these on each UI root.
|
||||
* If you are not using `OSWindow` and are instead creating secondary windows manually, you need to call `WindowRoot.CreateRootControls()` manually for this to work.
|
||||
* Added `Axis` enum, `IAxisImplementation` interface and axis implementations. These allow writing general-purpose UI layout code that can work on multiple axis at once.
|
||||
* WebView:
|
||||
* Added `web.remote_debug_port` CVar to change Chromium's remote debug port.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Audio:
|
||||
* Fix audio occlusion & velocity being calculated with the audio entity instead of the source entity.
|
||||
* Bound UI:
|
||||
* Try to fix an assert related to `UserInterfaceComponent` delta states.
|
||||
* Configuration:
|
||||
* The client no longer tries to send `CLIENT | REPLICATED` CVars when not connected to a server. This could cause test failures.
|
||||
* Math:
|
||||
* Fixed `Matrix3Helpers.TransformBounds()` returning an incorrect result. Now it effectively behaves like `Matrix3Helpers.TransformBox()` and has been marked as obsolete.
|
||||
* Physics:
|
||||
* Work around an undiagnosed crash processing entities without parents.
|
||||
* Serialization:
|
||||
* Fix `[DataRecord]`s with computed get-only properties.
|
||||
* Resources:
|
||||
* Fix some edge case broken path joining in `DirLoader` and `WritableDirProvider`.
|
||||
* Tests:
|
||||
* Fix `PlacementManager.CurrentMousePosition` in integration tests.
|
||||
* UI system:
|
||||
* Animations for the debug console and scrolling are no longer framerate dependent.
|
||||
* Fix `OutputPanel.SetMessage` triggering a scrolling animation when editing messages other than the last one.
|
||||
* Fix word wrapping with two-`char` runes in `RichTextLabel` and `OutputPanel`.
|
||||
* WebView:
|
||||
* Multiple clients with WebView can now run at the same time, thanks to better CEF cache management.
|
||||
|
||||
### Other
|
||||
|
||||
* Audio:
|
||||
* Improved error logging for invalid file names in `SharedAudioSystem`.
|
||||
* Configuration:
|
||||
* Fix crash if more than 255 `REPLICATED` CVars exist. Also increased the max size of the CVar replication message.
|
||||
* Entities:
|
||||
* Transform:
|
||||
* `AnchorEntity` logs instead of using an assert for invalid arguments.
|
||||
* Containers:
|
||||
* `SharedContainerSystem.CleanContainer` now uses `PredictedDel()` instead.
|
||||
* Networking:
|
||||
* The client now logs an error when attempting to send a network message without server connection. Previously, it would be silently dropped.
|
||||
* `net.interp` and `net.buffer_size` CVars are now `REPLICATED`.
|
||||
* Graphics:
|
||||
* The function used for pointlight attenuation has been modified to be c1 continuous as opposed to simply c0 continuous, resulting in smoother boundary behavior.
|
||||
* RSI validator no longer allows empty (`""`) state names.
|
||||
* Packaging:
|
||||
* Server packaging now excludes all files in the `Audio/` directory.
|
||||
* Server packaging now excludes engine resources `EngineFonts/` and `Midi/`.
|
||||
* ACZ explicitly specifies manifest charset as UTF-8.
|
||||
* Serialization:
|
||||
* `CurTime`-relative `TimeSpan` values that are `MaxValue` now deserialize without overflow.
|
||||
* `SpriteSpecifier.Texture` will now fail to validate if the path is inside a `.rsi`. Use RSI sprite specifiers instead.
|
||||
* Resources:
|
||||
* `IWritableDirProvider.RootDir` is now null on clients.
|
||||
* WebView:
|
||||
* CEF cache is no longer in the content-accessible user data directory.
|
||||
|
||||
### Internal
|
||||
|
||||
* Added some debug commands for debugging viewport resource management: `vp_clear_all_cached` & `vp_test_finalize`
|
||||
* `uitest` command now supports command argument for tab selection, like `uitest2`.
|
||||
* Rewrote `BoxContainer` implementation to make use of new axis system.
|
||||
* Moved `uitest2` and `devwindow` to use the `OSWindow` control.
|
||||
* SDL3 binding has been moved to `SpaceWizards.Sdl` NuGet package.
|
||||
* `dmetamem` command has been moved from `DEBUG` to `TOOLS`.
|
||||
* Consolidate `AttachToGridOrMap` with `TryGetMapOrGridCoordinates`.
|
||||
* Secondary window render targets have clear names specified.
|
||||
* Updated `SpaceWizards.NFluidsynth` to `0.2.2`.
|
||||
* `Robust.Client.WebView.Cef.Program` is now internal.
|
||||
* `download_manifest_file.py` script in repo now always decodes as UTF-8 correctly.
|
||||
* Added a new debug assert to game state processing.
|
||||
|
||||
## 267.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* When a player disconnects, the relevant callbacks are now fired *after* removing the channel from `INetManager`.
|
||||
|
||||
### New features
|
||||
|
||||
* Engine builds are now published for ARM64 & FreeBSD.
|
||||
* CPU model names are now detected on Windows & Linux ARM64.
|
||||
* Toolshed's `spawn:in` command now works on entities without `Physics` component.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* SDL3 windowing backend fixes:
|
||||
* Avoid macOS freezes with multiple windows.
|
||||
* Fix macOS rendering breaking when closing secondary windows.
|
||||
* File dialogs properly associate parent windows.
|
||||
* Fix IME positions not working with UI scaling properly.
|
||||
* Properly specify library names for loading native library.
|
||||
|
||||
* WinBit threads don't permanently stay stuck when their window closes.
|
||||
* Checking for the "`null`" literal in serialization is now culture invariant.
|
||||
|
||||
### Other
|
||||
|
||||
* Compat mode on the client now defaults to on for Windows Snapdragon devices, to work around driver bugs.
|
||||
* Update various libraries & natives. This enables out-of-the-box ARM64 support on all platforms and is a long-overdue modernization.
|
||||
* Key name displays now use proper Unicode symbols for macOS ⌥ and ⌘.
|
||||
* Automated CI for RobustToolbox runs on macOS again.
|
||||
* Autocompletions for `ProtoId<T>` in Toolshed now use `PrototypeIdsLimited` instead of arbitrarily cutting out if more than 256 of a prototype exists.
|
||||
|
||||
|
||||
## 266.0.0
|
||||
|
||||
@@ -1005,22 +1005,6 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
- name: GLFW
|
||||
license: |
|
||||
Copyright © 2002-2006 Marcus Geelnard
|
||||
|
||||
Copyright © 2006-2019 Camilla Löwy
|
||||
|
||||
This software is provided ‘as-is’, without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
|
||||
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
This notice may not be removed or altered from any source distribution.
|
||||
|
||||
- name: FluidSynth
|
||||
license: |
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
27
Resources/EngineShaders/Internal/default_sprite.wesl
Normal file
27
Resources/EngineShaders/Internal/default_sprite.wesl
Normal file
@@ -0,0 +1,27 @@
|
||||
import Robust::SpriteBatch::{VertexInput, VertexOutput, mainTexture, mainSampler, View};
|
||||
import Robust::Math::srgb_to_linear;
|
||||
|
||||
@vertex
|
||||
fn vs_main(input: VertexInput) -> VertexOutput {
|
||||
var transformed = vec3(input.position, 1.0) * View.projViewMatrix;
|
||||
|
||||
transformed += 1.0;
|
||||
transformed /= View.screenPixelSize * 2.0;
|
||||
transformed = floor(transformed + 0.5);
|
||||
transformed *= View.screenPixelSize * 2.0;
|
||||
transformed -= 1.0;
|
||||
|
||||
var out: VertexOutput;
|
||||
out.position = vec4(transformed, 0.0, 1.0);
|
||||
out.texCoord = input.texCoord;
|
||||
out.color = srgb_to_linear(input.color);
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(input: VertexOutput) -> @location(0) vec4f {
|
||||
var color = textureSample(mainTexture, mainSampler, input.texCoord);
|
||||
color = color * input.color;
|
||||
|
||||
return color;
|
||||
}
|
||||
6
Resources/EngineShaders/Math.wesl
Normal file
6
Resources/EngineShaders/Math.wesl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn srgb_to_linear(srgb: vec4f) -> vec4f {
|
||||
let higher = pow((srgb.rgb + 0.055) / 1.055, vec3(2.4));
|
||||
let lower = srgb.rgb / 12.92;
|
||||
let s = max(vec3(0.0), sign(srgb.rgb - 0.04045));
|
||||
return vec4(mix(lower, higher, s), srgb.a);
|
||||
}
|
||||
33
Resources/EngineShaders/SpriteBatch.wesl
Normal file
33
Resources/EngineShaders/SpriteBatch.wesl
Normal file
@@ -0,0 +1,33 @@
|
||||
// Group 0: global constants.
|
||||
struct UniformConstants {
|
||||
time: f32
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> Constants: UniformConstants;
|
||||
|
||||
// Group 1: parameters that change infrequently in a draw pass.
|
||||
struct UniformView {
|
||||
projViewMatrix: mat2x3f,
|
||||
screenPixelSize: vec2f
|
||||
}
|
||||
|
||||
@group(1) @binding(0) var<uniform> View: UniformView;
|
||||
|
||||
// Group 2: per-draw parameters.
|
||||
@group(2) @binding(0)
|
||||
var mainTexture: texture_2d<f32>;
|
||||
@group(2) @binding(1)
|
||||
var mainSampler: sampler;
|
||||
|
||||
|
||||
struct VertexInput {
|
||||
@location(0) position: vec2f,
|
||||
@location(1) texCoord: vec2f,
|
||||
@location(2) color: vec4f
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) position: vec4f,
|
||||
@location(0) texCoord: vec2f,
|
||||
@location(1) color: vec4f,
|
||||
}
|
||||
1
Resources/EngineShaders/Std.wesl
Normal file
1
Resources/EngineShaders/Std.wesl
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
Resources/Locale/en-US/_generic.ftl
Normal file
3
Resources/Locale/en-US/_generic.ftl
Normal file
@@ -0,0 +1,3 @@
|
||||
generic-map = map
|
||||
generic-grid = grid
|
||||
generic-mapid = map Id
|
||||
@@ -577,3 +577,5 @@ cmd-localization_set_culture-desc = Set DefaultCulture for the client Localizati
|
||||
cmd-localization_set_culture-help = Usage: localization_set_culture <cultureName>
|
||||
cmd-localization_set_culture-culture-name = <cultureName>
|
||||
cmd-localization_set_culture-changed = Localization changed to { $code } ({ $nativeName } / { $englishName })
|
||||
|
||||
cmd-addmap-hint-2 = runMapInit [true / false]
|
||||
|
||||
@@ -8,3 +8,18 @@ dev-window-tab-textures-info = Width: { $width } Height: { $height }
|
||||
PixelType: { $pixelType } sRGB: { $srgb }
|
||||
Name: { $name }
|
||||
Est. memory usage: { $bytes }
|
||||
|
||||
## "Render Targets" dev window tab
|
||||
dev-window-tab-render-targets-title = Render Targets
|
||||
dev-window-tab-render-targets-reload = Reload
|
||||
dev-window-tab-render-targets-filter = Filter
|
||||
dev-window-tab-render-targets-column-id = ID
|
||||
dev-window-tab-render-targets-column-name = Name
|
||||
dev-window-tab-render-targets-column-size = Size
|
||||
dev-window-tab-render-targets-column-type = Type
|
||||
dev-window-tab-render-targets-column-vram = VRAM
|
||||
dev-window-tab-render-targets-column-thumbnail = Thumbnail
|
||||
|
||||
dev-window-tab-render-targets-value-null = null
|
||||
dev-window-tab-render-targets-value-not-available = Not available
|
||||
dev-window-tab-render-targets-summary = Total VRAM: { $vram }
|
||||
|
||||
@@ -2,6 +2,7 @@ input-key-Escape = Escape
|
||||
input-key-Control = Control
|
||||
input-key-Shift = Shift
|
||||
input-key-Alt = Alt
|
||||
input-key-Alt-mac = ⌥
|
||||
input-key-Menu = Menu
|
||||
input-key-F1 = F1
|
||||
input-key-F2 = F2
|
||||
@@ -70,8 +71,8 @@ input-key-MouseButton9 = Mouse 9
|
||||
|
||||
input-key-LSystem-win = Left Win
|
||||
input-key-RSystem-win = Right Win
|
||||
input-key-LSystem-mac = Left Cmd
|
||||
input-key-RSystem-mac = Right Cmd
|
||||
input-key-LSystem-mac = Left ⌘
|
||||
input-key-RSystem-mac = Right ⌘
|
||||
input-key-LSystem-linux = Left Meta
|
||||
input-key-RSystem-linux = Right Meta
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ uniform highp vec2 lightCenter;
|
||||
uniform highp float lightRange;
|
||||
uniform highp float lightPower;
|
||||
uniform highp float lightSoftness;
|
||||
uniform highp float lightFalloff;
|
||||
uniform highp float lightCurveFactor;
|
||||
uniform highp float lightIndex;
|
||||
uniform sampler2D shadowMap;
|
||||
|
||||
@@ -47,8 +49,15 @@ void fragment()
|
||||
discard;
|
||||
}
|
||||
|
||||
highp float dist = dot(diff, diff) + LIGHTING_HEIGHT;
|
||||
highp float val = clamp((1.0 - clamp(sqrt(dist) / lightRange, 0.0, 1.0)) * (1.0 / (sqrt(dist + 1.0))), 0.0, 1.0);
|
||||
// this implementation of light attenuation primarily adapted from
|
||||
// https://lisyarus.github.io/blog/posts/point-light-attenuation.html
|
||||
highp float sqr_dist = dot(diff, diff) + LIGHTING_HEIGHT;
|
||||
|
||||
highp float s = clamp(sqrt(sqr_dist) / lightRange, 0.0, 1.0);
|
||||
highp float s2 = s * s;
|
||||
// controls curve by lerping between two variants (inverse-shape and inversequadratic-shape)
|
||||
highp float curveFactor = mix(s, s2, clamp(lightCurveFactor, 0.0, 1.0));
|
||||
highp float val = clamp(((1.0 - s2) * (1.0 - s2)) / (1.0 + lightFalloff * curveFactor), 0.0, 1.0);
|
||||
|
||||
val *= lightPower;
|
||||
val *= mask;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\PreferNonGenericVariantForAttribute.cs" LogicalName="Robust.Shared.Analyzers.PreferNonGenericVariantForAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\PreferOtherTypeAttribute.cs" LogicalName="Robust.Shared.Analyzers.PreferOtherTypeAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\ForbidLiteralAttribute.cs" LogicalName="Robust.Shared.Analyzers.ForbidLiteralAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\ObsoleteInheritanceAttribute.cs" LogicalName="Robust.Shared.Analyzers.ObsoleteInheritanceAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\IoC\DependencyAttribute.cs" LogicalName="Robust.Shared.IoC.DependencyAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared.Utility\Analyzers\ObsoleteInheritanceAttribute.cs" LogicalName="Robust.Shared.Analyzers.ObsoleteInheritanceAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared.Utility\IoC\DependencyAttribute.cs" LogicalName="Robust.Shared.IoC.DependencyAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\GameObjects\EventBusAttributes.cs" LogicalName="Robust.Shared.GameObjects.EventBusAttributes.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Serialization\NetSerializableAttribute.cs" LogicalName="Robust.Shared.Serialization.NetSerializableAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Prototypes\Attributes.cs" LogicalName="Robust.Shared.Prototypes.Attributes.cs" LinkBase="Implementations" />
|
||||
|
||||
4
Robust.Client.Graphics.Rhi/AssemblyInfo.cs
Normal file
4
Robust.Client.Graphics.Rhi/AssemblyInfo.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Robust.Client")]
|
||||
[module: SkipLocalsInit]
|
||||
22
Robust.Client.Graphics.Rhi/GlobalUsings.cs
Normal file
22
Robust.Client.Graphics.Rhi/GlobalUsings.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
global using Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
global using static Robust.Client.Interop.RobustNative.Webgpu.Wgpu;
|
||||
global using static Robust.Shared.Utility.FfiHelper;
|
||||
|
||||
global using unsafe WGPUTexture = Robust.Client.Interop.RobustNative.Webgpu.WGPUTextureImpl*;
|
||||
global using unsafe WGPUDevice = Robust.Client.Interop.RobustNative.Webgpu.WGPUDeviceImpl*;
|
||||
global using unsafe WGPUQueue = Robust.Client.Interop.RobustNative.Webgpu.WGPUQueueImpl*;
|
||||
global using unsafe WGPUAdapter = Robust.Client.Interop.RobustNative.Webgpu.WGPUAdapterImpl*;
|
||||
global using unsafe WGPUInstance = Robust.Client.Interop.RobustNative.Webgpu.WGPUInstanceImpl*;
|
||||
global using unsafe WGPUTextureView = Robust.Client.Interop.RobustNative.Webgpu.WGPUTextureViewImpl*;
|
||||
global using unsafe WGPUBindGroup = Robust.Client.Interop.RobustNative.Webgpu.WGPUBindGroupImpl*;
|
||||
global using unsafe WGPUBindGroupLayout = Robust.Client.Interop.RobustNative.Webgpu.WGPUBindGroupLayoutImpl*;
|
||||
global using unsafe WGPUBuffer = Robust.Client.Interop.RobustNative.Webgpu.WGPUBufferImpl*;
|
||||
global using unsafe WGPUSampler = Robust.Client.Interop.RobustNative.Webgpu.WGPUSamplerImpl*;
|
||||
global using unsafe WGPUCommandBuffer = Robust.Client.Interop.RobustNative.Webgpu.WGPUCommandBufferImpl*;
|
||||
global using unsafe WGPUCommandEncoder = Robust.Client.Interop.RobustNative.Webgpu.WGPUCommandEncoderImpl*;
|
||||
global using unsafe WGPURenderPassEncoder = Robust.Client.Interop.RobustNative.Webgpu.WGPURenderPassEncoderImpl*;
|
||||
global using unsafe WGPURenderPipeline = Robust.Client.Interop.RobustNative.Webgpu.WGPURenderPipelineImpl*;
|
||||
global using unsafe WGPUPipelineLayout = Robust.Client.Interop.RobustNative.Webgpu.WGPUPipelineLayoutImpl*;
|
||||
global using unsafe WGPUShaderModule = Robust.Client.Interop.RobustNative.Webgpu.WGPUShaderModuleImpl*;
|
||||
global using unsafe WGPUSurface = Robust.Client.Interop.RobustNative.Webgpu.WGPUSurfaceImpl*;
|
||||
131
Robust.Client.Graphics.Rhi/Rhi.Internal.cs
Normal file
131
Robust.Client.Graphics.Rhi/Rhi.Internal.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using Robust.Client.Graphics.Rhi.WebGpu;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi;
|
||||
|
||||
public abstract partial class RhiBase
|
||||
{
|
||||
//
|
||||
// Clyde <-> RHI API.
|
||||
//
|
||||
|
||||
internal abstract void Init(in RhiInitParams initParams, out RhiWebGpu.WindowData windowData);
|
||||
internal abstract void Shutdown();
|
||||
|
||||
/// <summary>
|
||||
/// A window was created by Clyde. It should be initialized by the RHI to make it ready for rendering.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Does not get called for the main window.
|
||||
/// </remarks>
|
||||
internal abstract RhiWebGpu.WindowData WindowCreated(in RhiWindowSurfaceParams surfaceParams, Vector2i size, bool vsync);
|
||||
|
||||
/// <summary>
|
||||
/// A window is about to be destroyed by Clyde. Clean up resources for it.
|
||||
/// </summary>
|
||||
internal abstract void WindowDestroy(RhiWebGpu.WindowData reg);
|
||||
|
||||
/// <summary>
|
||||
/// Recreate the native swap chain, in case it has become suboptimal (e.g. due to window resizing).
|
||||
/// </summary>
|
||||
internal abstract void WindowRecreateSwapchain(RhiWebGpu.WindowData reg, Vector2i size, bool vsyncEnabled);
|
||||
|
||||
internal abstract RhiTexture GetSurfaceTextureForWindow(RhiWebGpu.WindowData reg);
|
||||
internal abstract void WindowPresent(RhiWebGpu.WindowData reg);
|
||||
|
||||
//
|
||||
// RHI-internal API to de-OOP the public RHI API.
|
||||
//
|
||||
|
||||
internal abstract RhiRenderPassEncoder CommandEncoderBeginRenderPass(
|
||||
RhiCommandEncoder encoder,
|
||||
in RhiRenderPassDescriptor descriptor
|
||||
);
|
||||
|
||||
internal abstract RhiCommandBuffer CommandEncoderFinish(
|
||||
in RhiCommandEncoder encoder,
|
||||
in RhiCommandBufferDescriptor descriptor);
|
||||
|
||||
internal abstract void RenderPassEncoderSetPipeline(
|
||||
in RhiRenderPassEncoder encoder,
|
||||
RhiRenderPipeline pipeline
|
||||
);
|
||||
|
||||
internal abstract void RenderPassEncoderDraw(
|
||||
in RhiRenderPassEncoder encoder,
|
||||
uint vertexCount,
|
||||
uint instanceCount,
|
||||
uint firstVertex,
|
||||
uint firstInstance
|
||||
);
|
||||
|
||||
internal abstract void RenderPassEncoderEnd(RhiRenderPassEncoder encoder);
|
||||
|
||||
internal abstract void QueueSubmit(RhiQueue queue, RhiCommandBuffer[] commandBuffers);
|
||||
|
||||
internal abstract void QueueWriteTexture(
|
||||
RhiQueue queue,
|
||||
in RhiImageCopyTexture destination,
|
||||
ReadOnlySpan<byte> data,
|
||||
in RhiImageDataLayout dataLayout,
|
||||
RhiExtent3D size
|
||||
);
|
||||
|
||||
public abstract void QueueWriteBuffer(RhiBuffer buffer, ulong bufferOffset, ReadOnlySpan<byte> data);
|
||||
|
||||
internal abstract RhiTextureView TextureCreateView(RhiTexture texture, in RhiTextureViewDescriptor descriptor);
|
||||
internal abstract void TextureViewDrop(RhiTextureView textureView);
|
||||
internal abstract void BindGroupDrop(RhiBindGroup rhiBindGroup);
|
||||
|
||||
internal abstract void RenderPassEncoderSetBindGroup(
|
||||
RhiRenderPassEncoder encoder,
|
||||
uint index,
|
||||
RhiBindGroup? bindGroup
|
||||
);
|
||||
|
||||
internal abstract void RenderPassEncoderSetVertexBuffer(RhiRenderPassEncoder encoder,
|
||||
uint slot,
|
||||
RhiBuffer? buffer,
|
||||
ulong offset,
|
||||
ulong? size);
|
||||
|
||||
internal abstract void RenderPassEncoderSetScissorRect(RhiRenderPassEncoder encoder,
|
||||
uint x,
|
||||
uint y,
|
||||
uint w,
|
||||
uint h);
|
||||
|
||||
internal abstract void CommandBufferDrop(RhiCommandBuffer commandBuffer);
|
||||
|
||||
internal abstract RhiBufferMapState BufferGetMapState(RhiBuffer buffer);
|
||||
internal abstract ValueTask BufferMapAsync(RhiBuffer buffer, RhiMapModeFlags mode, nuint offset, nuint size);
|
||||
internal abstract RhiMappedBufferRange BufferGetMappedRange(RhiBuffer buffer, nuint offset, nuint size);
|
||||
internal abstract void BufferUnmap(RhiBuffer buffer);
|
||||
internal abstract void BufferDrop(RhiBuffer buffer);
|
||||
|
||||
internal struct RhiInitParams
|
||||
{
|
||||
public required string Backends;
|
||||
public required RhiPowerPreference PowerPreference;
|
||||
public required RhiWindowSurfaceParams MainWindowSurfaceParams;
|
||||
}
|
||||
|
||||
internal unsafe struct RhiWindowSurfaceParams
|
||||
{
|
||||
#if WINDOWS
|
||||
public void* HInstance;
|
||||
public void* HWnd;
|
||||
#elif MACOS
|
||||
public void* MetalLayer;
|
||||
#elif LINUX
|
||||
public bool Wayland; // False = X11
|
||||
public void* X11Display;
|
||||
public void* X11Window;
|
||||
|
||||
public void* WaylandDisplay;
|
||||
public void* WaylandSurface;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
internal record struct RhiHandle(long Value);
|
||||
40
Robust.Client.Graphics.Rhi/Rhi.ShaderTypes.cs
Normal file
40
Robust.Client.Graphics.Rhi/Rhi.ShaderTypes.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi;
|
||||
|
||||
/// <summary>
|
||||
/// Equivalent to a WGSL <c>mat2x3f</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This matrix is columnar and 2 columns, 3 rows. This is equivalent to .NET's <see cref="Matrix3x2"/>!
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct ShaderMat2x3F
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float M11;
|
||||
[FieldOffset(4)]
|
||||
public float M21;
|
||||
[FieldOffset(8)]
|
||||
public float M31;
|
||||
|
||||
[FieldOffset(16)]
|
||||
public float M12;
|
||||
[FieldOffset(20)]
|
||||
public float M22;
|
||||
[FieldOffset(24)]
|
||||
public float M32;
|
||||
|
||||
public static ShaderMat2x3F FromMatrix(in Matrix3x2 matrix)
|
||||
{
|
||||
var ret = default(ShaderMat2x3F);
|
||||
ret.M11 = matrix.M11;
|
||||
ret.M12 = matrix.M12;
|
||||
ret.M21 = matrix.M21;
|
||||
ret.M22 = matrix.M22;
|
||||
ret.M31 = matrix.M31;
|
||||
ret.M32 = matrix.M32;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
1197
Robust.Client.Graphics.Rhi/Rhi.cs
Normal file
1197
Robust.Client.Graphics.Rhi/Rhi.cs
Normal file
File diff suppressed because it is too large
Load Diff
18
Robust.Client.Graphics.Rhi/Robust.Client.Graphics.Rhi.csproj
Normal file
18
Robust.Client.Graphics.Rhi/Robust.Client.Graphics.Rhi.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\MSBuild\Robust.Engine.props"/>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<SkipRobustSerializationGenerator>true</SkipRobustSerializationGenerator>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Robust.Client.Interop.RobustNative\Robust.Client.Interop.RobustNative.csproj" />
|
||||
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
|
||||
<ProjectReference Include="..\Robust.Shared.Utility\Robust.Shared.Utility.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\MSBuild\Robust.Properties.targets"/>
|
||||
</Project>
|
||||
113
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.BindGroup.cs
Normal file
113
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.BindGroup.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, BindGroupLayoutReg> _bindGroupLayoutRegistry = new();
|
||||
private readonly Dictionary<RhiHandle, BindGroupReg> _bindGroupRegistry = new();
|
||||
|
||||
|
||||
internal override void BindGroupDrop(RhiBindGroup rhiBindGroup)
|
||||
{
|
||||
wgpuBindGroupRelease(_bindGroupRegistry[rhiBindGroup.Handle].Native);
|
||||
_bindGroupRegistry.Remove(rhiBindGroup.Handle);
|
||||
}
|
||||
|
||||
public override RhiBindGroupLayout CreateBindGroupLayout(in RhiBindGroupLayoutDescriptor descriptor)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[512];
|
||||
|
||||
var pDescriptor = BumpAllocate<WGPUBindGroupLayoutDescriptor>(ref buffer);
|
||||
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
var entries = descriptor.Entries;
|
||||
pDescriptor->entryCount = (uint)entries.Length;
|
||||
pDescriptor->entries = BumpAllocate<WGPUBindGroupLayoutEntry>(ref buffer, entries.Length);
|
||||
for (var i = 0; i < entries.Length; i++)
|
||||
{
|
||||
ref var entry = ref entries[i];
|
||||
var pEntry = &pDescriptor->entries[i];
|
||||
|
||||
pEntry->binding = entry.Binding;
|
||||
pEntry->visibility = (ulong)entry.Visibility;
|
||||
|
||||
switch (entry.Layout)
|
||||
{
|
||||
case RhiSamplerBindingLayout sampler:
|
||||
pEntry->sampler.type = (WGPUSamplerBindingType)sampler.Type;
|
||||
break;
|
||||
case RhiTextureBindingLayout texture:
|
||||
pEntry->texture.multisampled = texture.Multisampled ? 1u : 0u;
|
||||
pEntry->texture.sampleType = (WGPUTextureSampleType)texture.SampleType;
|
||||
pEntry->texture.viewDimension =
|
||||
(WGPUTextureViewDimension)ValidateTextureViewDimension(texture.ViewDimension);
|
||||
break;
|
||||
case RhiBufferBindingLayout layoutBuffer:
|
||||
pEntry->buffer.type = (WGPUBufferBindingType) layoutBuffer.Type;
|
||||
pEntry->buffer.hasDynamicOffset = layoutBuffer.HasDynamicOffset ? 1u : 0u;
|
||||
pEntry->buffer.minBindingSize = layoutBuffer.MinBindingSize;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
var native = wgpuDeviceCreateBindGroupLayout(_wgpuDevice, pDescriptor);
|
||||
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_bindGroupLayoutRegistry.Add(handle, new BindGroupLayoutReg { Native = native });
|
||||
return new RhiBindGroupLayout(this, handle);
|
||||
}
|
||||
|
||||
public override RhiBindGroup CreateBindGroup(in RhiBindGroupDescriptor descriptor)
|
||||
{
|
||||
// TODO: SAFETY
|
||||
Span<byte> buffer = stackalloc byte[1024];
|
||||
|
||||
var pDescriptor = BumpAllocate<WGPUBindGroupDescriptor>(ref buffer);
|
||||
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
pDescriptor->layout = _bindGroupLayoutRegistry[descriptor.Layout.Handle].Native;
|
||||
|
||||
var entries = descriptor.Entries;
|
||||
pDescriptor->entryCount = (uint) entries.Length;
|
||||
pDescriptor->entries = BumpAllocate<WGPUBindGroupEntry>(ref buffer, entries.Length);
|
||||
for (var i = 0; i < entries.Length; i++)
|
||||
{
|
||||
ref var entry = ref descriptor.Entries[i];
|
||||
var pEntry = &pDescriptor->entries[i];
|
||||
|
||||
pEntry->binding = entry.Binding;
|
||||
switch (entry.Resource)
|
||||
{
|
||||
case RhiSampler rhiSampler:
|
||||
pEntry->sampler = _samplerRegistry[rhiSampler.Handle].Native;
|
||||
break;
|
||||
case RhiTextureView rhiTextureView:
|
||||
pEntry->textureView = _textureViewRegistry[rhiTextureView.Handle].Native;
|
||||
break;
|
||||
case RhiBufferBinding bufferBinding:
|
||||
pEntry->buffer = _bufferRegistry[bufferBinding.Buffer.Handle].Native;
|
||||
pEntry->offset = bufferBinding.Offset;
|
||||
pEntry->size = bufferBinding.Size ?? WGPU_WHOLE_SIZE;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
var bindGroup = wgpuDeviceCreateBindGroup(_wgpuDevice, pDescriptor);
|
||||
|
||||
var handle = AllocRhiHandle();
|
||||
_bindGroupRegistry.Add(handle, new BindGroupReg { Native = bindGroup });
|
||||
return new RhiBindGroup(this, handle);
|
||||
}
|
||||
|
||||
private sealed class BindGroupLayoutReg
|
||||
{
|
||||
public WGPUBindGroupLayout Native;
|
||||
}
|
||||
|
||||
private sealed class BindGroupReg
|
||||
{
|
||||
public WGPUBindGroup Native;
|
||||
}
|
||||
}
|
||||
148
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Buffer.cs
Normal file
148
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Buffer.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, BufferReg> _bufferRegistry = new();
|
||||
|
||||
public override unsafe RhiBuffer CreateBuffer(in RhiBufferDescriptor descriptor)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[512];
|
||||
var pDescriptor = BumpAllocate<WGPUBufferDescriptor>(ref buffer);
|
||||
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
pDescriptor->mappedAtCreation = descriptor.MappedAtCreation ? 1u : 0u;
|
||||
pDescriptor->size = descriptor.Size;
|
||||
pDescriptor->usage = (ulong) descriptor.Usage;
|
||||
|
||||
var native = wgpuDeviceCreateBuffer(_wgpuDevice, pDescriptor);
|
||||
|
||||
var handle = AllocRhiHandle();
|
||||
_bufferRegistry.Add(handle, new BufferReg { Native = native });
|
||||
var rhiBuffer= new RhiBuffer(this, handle);
|
||||
|
||||
if (pDescriptor->mappedAtCreation == 1)
|
||||
{
|
||||
rhiBuffer.Mapping = new RhiBuffer.ActiveMapping(rhiBuffer) { Valid = true };
|
||||
}
|
||||
|
||||
return rhiBuffer;
|
||||
}
|
||||
|
||||
internal override unsafe RhiBufferMapState BufferGetMapState(RhiBuffer buffer)
|
||||
{
|
||||
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
|
||||
return (RhiBufferMapState) wgpuBufferGetMapState(nativeBuffer);
|
||||
}
|
||||
|
||||
internal override async ValueTask BufferMapAsync(RhiBuffer buffer, RhiMapModeFlags mode, nuint offset, nuint size)
|
||||
{
|
||||
// TODO: Probably need some more locks here idk.
|
||||
// So people can't map the buffer at the same time as or something.
|
||||
|
||||
buffer.MapState = RhiBufferMapState.Pending;
|
||||
|
||||
WgpuMapBufferAsyncResult result;
|
||||
using (var promise = new WgpuPromise<WgpuMapBufferAsyncResult>())
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
|
||||
|
||||
wgpuBufferMapAsync(
|
||||
nativeBuffer,
|
||||
(ulong) mode,
|
||||
offset,
|
||||
size,
|
||||
new WGPUBufferMapCallbackInfo
|
||||
{
|
||||
callback = &WgpuMapBufferAsyncCallback,
|
||||
userdata1 = promise.UserData,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: are we handling the error correctly, here?
|
||||
result = await promise.Task;
|
||||
|
||||
buffer.Mapping = new RhiBuffer.ActiveMapping(buffer) { Valid = true };
|
||||
}
|
||||
|
||||
if (result.Status != WGPUMapAsyncStatus.WGPUMapAsyncStatus_Success)
|
||||
throw new RhiException(result.Status.ToString());
|
||||
|
||||
buffer.MapState = RhiBufferMapState.Mapped;
|
||||
}
|
||||
|
||||
internal override unsafe RhiMappedBufferRange BufferGetMappedRange(RhiBuffer buffer, nuint offset, nuint size)
|
||||
{
|
||||
if (size > int.MaxValue)
|
||||
throw new ArgumentException("Mapped area too big!");
|
||||
|
||||
if (buffer.Mapping == null)
|
||||
throw new InvalidOperationException("Buffer is not mapped");
|
||||
|
||||
lock (buffer.Mapping)
|
||||
{
|
||||
if (!buffer.Mapping.Valid)
|
||||
{
|
||||
// Not sure if this is possible, but can't hurt.
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
|
||||
var mapped = wgpuBufferGetMappedRange(nativeBuffer, offset, size);
|
||||
|
||||
return new RhiMappedBufferRange(buffer.Mapping, mapped, (int) size);
|
||||
}
|
||||
}
|
||||
|
||||
internal override unsafe void BufferUnmap(RhiBuffer buffer)
|
||||
{
|
||||
if (buffer.Mapping == null)
|
||||
throw new InvalidOperationException("Buffer is not mapped!");
|
||||
|
||||
lock (buffer.Mapping)
|
||||
{
|
||||
if (!buffer.Mapping.Valid)
|
||||
{
|
||||
// Not sure if this is possible, but can't hurt.
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (buffer.Mapping.ActiveSpans > 0)
|
||||
throw new InvalidOperationException("Current thread has buffer accessible as span, cannot unmap!");
|
||||
|
||||
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
|
||||
wgpuBufferUnmap(nativeBuffer);
|
||||
|
||||
buffer.Mapping.Valid = false;
|
||||
buffer.Mapping = null;
|
||||
buffer.MapState = RhiBufferMapState.Unmapped;
|
||||
}
|
||||
}
|
||||
|
||||
internal override unsafe void BufferDrop(RhiBuffer buffer)
|
||||
{
|
||||
wgpuBufferRelease(_bufferRegistry[buffer.Handle].Native);
|
||||
_bufferRegistry.Remove(buffer.Handle);
|
||||
}
|
||||
|
||||
private sealed unsafe class BufferReg
|
||||
{
|
||||
public WGPUBuffer Native;
|
||||
}
|
||||
|
||||
private record struct WgpuMapBufferAsyncResult(WGPUMapAsyncStatus Status);
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static unsafe void WgpuMapBufferAsyncCallback(
|
||||
WGPUMapAsyncStatus status,
|
||||
WGPUStringView stringView,
|
||||
void* userdata1,
|
||||
void* userdata2)
|
||||
{
|
||||
WgpuPromise<WgpuMapBufferAsyncResult>.SetResult(userdata1, new WgpuMapBufferAsyncResult(status));
|
||||
}
|
||||
}
|
||||
21
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.CommandBuffer.cs
Normal file
21
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.CommandBuffer.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, CommandBufferReg> _commandBufferRegistry = new();
|
||||
|
||||
/// <summary>
|
||||
/// Command buffer was dropped natively, either via explicit call or implicit side effect (e.g. queue submit).
|
||||
/// </summary>
|
||||
private void CommandBufferDropped(RhiCommandBuffer commandBuffer)
|
||||
{
|
||||
_commandBufferRegistry.Remove(commandBuffer.Handle);
|
||||
GC.SuppressFinalize(commandBuffer);
|
||||
}
|
||||
|
||||
internal override void CommandBufferDrop(RhiCommandBuffer commandBuffer)
|
||||
{
|
||||
wgpuCommandBufferRelease(_commandBufferRegistry[commandBuffer.Handle].Native);
|
||||
CommandBufferDropped(commandBuffer);
|
||||
}
|
||||
}
|
||||
221
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.CommandEncoder.cs
Normal file
221
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.CommandEncoder.cs
Normal file
@@ -0,0 +1,221 @@
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, CommandEncoderReg> _commandEncoderRegistry = new();
|
||||
private readonly Dictionary<RhiHandle, RenderPassEncoderReg> _renderPassEncoderRegistry = new();
|
||||
|
||||
public override RhiCommandEncoder CreateCommandEncoder(in RhiCommandEncoderDescriptor descriptor)
|
||||
{
|
||||
WGPUCommandEncoder nativeEncoder;
|
||||
fixed (byte* pLabel = MakeLabel(descriptor.Label))
|
||||
{
|
||||
var nativeDescriptor = new WGPUCommandEncoderDescriptor
|
||||
{
|
||||
label = new WGPUStringView {data = (sbyte*)pLabel, length = WGPU_STRLEN}
|
||||
};
|
||||
|
||||
nativeEncoder = wgpuDeviceCreateCommandEncoder(_wgpuDevice, &nativeDescriptor);
|
||||
}
|
||||
|
||||
// TODO: thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_commandEncoderRegistry.Add(handle, new CommandEncoderReg { Native = nativeEncoder });
|
||||
return new RhiCommandEncoder(this, handle);
|
||||
}
|
||||
|
||||
internal override RhiRenderPassEncoder CommandEncoderBeginRenderPass(
|
||||
RhiCommandEncoder encoder,
|
||||
in RhiRenderPassDescriptor descriptor)
|
||||
{
|
||||
// TODO: Ensure not disposed
|
||||
// TODO: Thread safety
|
||||
|
||||
Span<byte> buffer = stackalloc byte[512];
|
||||
|
||||
var pDescriptor = BumpAllocate<WGPURenderPassDescriptor>(ref buffer);
|
||||
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
|
||||
var colorAttachments = descriptor.ColorAttachments;
|
||||
pDescriptor->colorAttachmentCount = (uint)colorAttachments.Length;
|
||||
pDescriptor->colorAttachments = BumpAllocate<WGPURenderPassColorAttachment>(ref buffer, colorAttachments.Length);
|
||||
for (var i = 0; i < colorAttachments.Length; i++)
|
||||
{
|
||||
ref var attachment = ref colorAttachments[i];
|
||||
var pAttachment = &pDescriptor->colorAttachments[i];
|
||||
pAttachment->view = _textureViewRegistry[attachment.View.Handle].Native;
|
||||
if (attachment.ResolveTarget is { } resolveTarget)
|
||||
pAttachment->resolveTarget = _textureViewRegistry[resolveTarget.Handle].Native;
|
||||
pAttachment->clearValue = WgpuColor(attachment.ClearValue);
|
||||
pAttachment->loadOp = (WGPULoadOp)attachment.LoadOp;
|
||||
pAttachment->storeOp = (WGPUStoreOp)attachment.StoreOp;
|
||||
pAttachment->depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
|
||||
}
|
||||
|
||||
if (descriptor.DepthStencilAttachment is { } depthStencilAttachment)
|
||||
{
|
||||
var pDepthStencilAttachment = BumpAllocate<WGPURenderPassDepthStencilAttachment>(ref buffer);
|
||||
pDescriptor->depthStencilAttachment = pDepthStencilAttachment;
|
||||
|
||||
pDepthStencilAttachment->view = _textureViewRegistry[depthStencilAttachment.View.Handle].Native;
|
||||
pDepthStencilAttachment->depthLoadOp = (WGPULoadOp)depthStencilAttachment.DepthLoadOp;
|
||||
pDepthStencilAttachment->depthStoreOp = (WGPUStoreOp)depthStencilAttachment.DepthStoreOp;
|
||||
pDepthStencilAttachment->depthClearValue = depthStencilAttachment.DepthClearValue;
|
||||
pDepthStencilAttachment->depthReadOnly = depthStencilAttachment.DepthReadOnly ? 1u : 0u;
|
||||
pDepthStencilAttachment->stencilLoadOp = (WGPULoadOp)depthStencilAttachment.StencilLoadOp;
|
||||
pDepthStencilAttachment->stencilStoreOp = (WGPUStoreOp)depthStencilAttachment.StencilStoreOp;
|
||||
pDepthStencilAttachment->stencilClearValue = depthStencilAttachment.StencilClearValue;
|
||||
pDepthStencilAttachment->stencilReadOnly = depthStencilAttachment.StencilReadOnly ? 1u : 0u;
|
||||
}
|
||||
|
||||
if (descriptor.OcclusionQuerySet != null)
|
||||
throw new NotImplementedException();
|
||||
|
||||
var pDescriptorMaxDrawCount = BumpAllocate<WGPURenderPassMaxDrawCount>(ref buffer);
|
||||
pDescriptor->nextInChain = (WGPUChainedStruct*)pDescriptorMaxDrawCount;
|
||||
pDescriptorMaxDrawCount->chain.sType = WGPUSType.WGPUSType_RenderPassMaxDrawCount;
|
||||
pDescriptorMaxDrawCount->maxDrawCount = descriptor.MaxDrawCount;
|
||||
|
||||
var nativeEncoder = wgpuCommandEncoderBeginRenderPass(
|
||||
_commandEncoderRegistry[encoder.Handle].Native,
|
||||
pDescriptor
|
||||
);
|
||||
|
||||
// TODO: thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_renderPassEncoderRegistry.Add(handle, new RenderPassEncoderReg { Native = nativeEncoder });
|
||||
return new RhiRenderPassEncoder(this, handle);
|
||||
}
|
||||
|
||||
internal override void RenderPassEncoderSetPipeline(
|
||||
in RhiRenderPassEncoder encoder,
|
||||
RhiRenderPipeline pipeline)
|
||||
{
|
||||
// TODO: safety
|
||||
wgpuRenderPassEncoderSetPipeline(
|
||||
_renderPassEncoderRegistry[encoder.Handle].Native,
|
||||
_renderPipelineRegistry[pipeline.Handle].Native
|
||||
);
|
||||
}
|
||||
|
||||
internal override void RenderPassEncoderDraw(
|
||||
in RhiRenderPassEncoder encoder,
|
||||
uint vertexCount,
|
||||
uint instanceCount,
|
||||
uint firstVertex,
|
||||
uint firstInstance)
|
||||
{
|
||||
// TODO: safety
|
||||
wgpuRenderPassEncoderDraw(
|
||||
_renderPassEncoderRegistry[encoder.Handle].Native,
|
||||
vertexCount,
|
||||
instanceCount,
|
||||
firstVertex,
|
||||
firstInstance
|
||||
);
|
||||
}
|
||||
|
||||
internal override void RenderPassEncoderEnd(RhiRenderPassEncoder encoder)
|
||||
{
|
||||
// TODO: safety
|
||||
var handle = encoder.Handle;
|
||||
|
||||
wgpuRenderPassEncoderEnd(_renderPassEncoderRegistry[handle].Native);
|
||||
RenderPassEncoderDropped(handle);
|
||||
}
|
||||
|
||||
internal override void RenderPassEncoderSetBindGroup(
|
||||
RhiRenderPassEncoder encoder,
|
||||
uint index,
|
||||
RhiBindGroup? bindGroup)
|
||||
{
|
||||
wgpuRenderPassEncoderSetBindGroup(
|
||||
_renderPassEncoderRegistry[encoder.Handle].Native,
|
||||
index,
|
||||
_bindGroupRegistry[bindGroup!.Handle].Native,
|
||||
0, null
|
||||
);
|
||||
}
|
||||
|
||||
internal override void RenderPassEncoderSetVertexBuffer(
|
||||
RhiRenderPassEncoder encoder,
|
||||
uint slot,
|
||||
RhiBuffer? buffer,
|
||||
ulong offset,
|
||||
ulong? size)
|
||||
{
|
||||
WGPUBuffer nativeBuffer = null;
|
||||
if (buffer != null)
|
||||
nativeBuffer = _bufferRegistry[buffer.Handle].Native;
|
||||
|
||||
wgpuRenderPassEncoderSetVertexBuffer(
|
||||
_renderPassEncoderRegistry[encoder.Handle].Native,
|
||||
slot,
|
||||
nativeBuffer,
|
||||
offset,
|
||||
size ?? WGPU_WHOLE_SIZE
|
||||
);
|
||||
}
|
||||
|
||||
internal override void RenderPassEncoderSetScissorRect(
|
||||
RhiRenderPassEncoder encoder,
|
||||
uint x, uint y, uint w, uint h)
|
||||
{
|
||||
// TODO: safety
|
||||
wgpuRenderPassEncoderSetScissorRect(
|
||||
_renderPassEncoderRegistry[encoder.Handle].Native,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h
|
||||
);
|
||||
}
|
||||
|
||||
internal override RhiCommandBuffer CommandEncoderFinish(
|
||||
in RhiCommandEncoder encoder,
|
||||
in RhiCommandBufferDescriptor descriptor)
|
||||
{
|
||||
// TODO: safety
|
||||
var handle = encoder.Handle;
|
||||
|
||||
Span<byte> buffer = stackalloc byte[512];
|
||||
var pDescriptor = BumpAllocate<WGPUCommandBufferDescriptor>(ref buffer);
|
||||
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
|
||||
var nativeBuffer = wgpuCommandEncoderFinish(
|
||||
_commandEncoderRegistry[handle].Native,
|
||||
pDescriptor
|
||||
);
|
||||
|
||||
CommandEncoderDropped(handle);
|
||||
|
||||
var bufferHandle = AllocRhiHandle();
|
||||
_commandBufferRegistry.Add(bufferHandle, new CommandBufferReg { Native = nativeBuffer });
|
||||
return new RhiCommandBuffer(this, bufferHandle);
|
||||
}
|
||||
|
||||
private void CommandEncoderDropped(RhiHandle encoder)
|
||||
{
|
||||
_commandEncoderRegistry.Remove(encoder);
|
||||
}
|
||||
|
||||
private void RenderPassEncoderDropped(RhiHandle encoder)
|
||||
{
|
||||
_renderPassEncoderRegistry.Remove(encoder);
|
||||
}
|
||||
|
||||
private sealed class CommandEncoderReg
|
||||
{
|
||||
public WGPUCommandEncoder Native;
|
||||
}
|
||||
|
||||
private sealed class RenderPassEncoderReg
|
||||
{
|
||||
public WGPURenderPassEncoder Native;
|
||||
}
|
||||
|
||||
private sealed class CommandBufferReg
|
||||
{
|
||||
public WGPUCommandBuffer Native;
|
||||
}
|
||||
}
|
||||
228
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Helpers.cs
Normal file
228
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Helpers.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private static string WgpuVersionToString(uint version)
|
||||
{
|
||||
var a = (version >> 24) & 0xFF;
|
||||
var b = (version >> 16) & 0xFF;
|
||||
var c = (version >> 08) & 0xFF;
|
||||
var d = (version >> 00) & 0xFF;
|
||||
|
||||
return $"{a}.{b}.{c}.{d}";
|
||||
}
|
||||
|
||||
private static WGPUOptionalBool WgpuOptionalBool(bool? value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
null => WGPUOptionalBool.WGPUOptionalBool_Undefined,
|
||||
false => WGPUOptionalBool.WGPUOptionalBool_False,
|
||||
true => WGPUOptionalBool.WGPUOptionalBool_True,
|
||||
};
|
||||
}
|
||||
|
||||
private static WGPUColor WgpuColor(RhiColor color) => new()
|
||||
{
|
||||
r = color.R,
|
||||
g = color.G,
|
||||
b = color.B,
|
||||
a = color.A
|
||||
};
|
||||
|
||||
private static WGPUExtent3D WgpuExtent3D(RhiExtent3D extent)
|
||||
{
|
||||
return new WGPUExtent3D
|
||||
{
|
||||
width = extent.Width,
|
||||
height = extent.Height,
|
||||
depthOrArrayLayers = extent.Depth
|
||||
};
|
||||
}
|
||||
|
||||
private static WGPUOrigin3D WgpuOrigin3D(RhiOrigin3D origin)
|
||||
{
|
||||
return new WGPUOrigin3D
|
||||
{
|
||||
x = origin.X,
|
||||
y = origin.Y,
|
||||
z = origin.Z
|
||||
};
|
||||
}
|
||||
|
||||
private static string? GetString(WGPUStringView stringView)
|
||||
{
|
||||
if (stringView.data == null)
|
||||
{
|
||||
if (stringView.length == WGPU_STRLEN)
|
||||
return null;
|
||||
if (stringView.length == 0)
|
||||
return "";
|
||||
throw new RhiException("Null address to WGPUStringView");
|
||||
}
|
||||
|
||||
if (stringView.length == WGPU_STRLEN)
|
||||
return Marshal.PtrToStringUTF8((IntPtr)stringView.data);
|
||||
|
||||
if (stringView.length > int.MaxValue)
|
||||
throw new RhiException("WGPUStringView too long!");
|
||||
|
||||
var span = new ReadOnlySpan<byte>(stringView.data, (int)stringView.length);
|
||||
return Encoding.UTF8.GetString(span);
|
||||
}
|
||||
|
||||
private static RhiTextureFormat ToRhiFormat(WGPUTextureFormat format)
|
||||
{
|
||||
return (RhiTextureFormat)format;
|
||||
}
|
||||
|
||||
private static WGPUTextureFormat ValidateTextureFormat(RhiTextureFormat format)
|
||||
{
|
||||
if (format is 0 or >= RhiTextureFormat.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiTextureFormat)}");
|
||||
|
||||
return (WGPUTextureFormat)format;
|
||||
}
|
||||
|
||||
private static WGPUTextureDimension ValidateTextureDimension(RhiTextureDimension dimension)
|
||||
{
|
||||
if (dimension > RhiTextureDimension.Dim3D)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiTextureDimension)}");
|
||||
|
||||
return dimension switch
|
||||
{
|
||||
RhiTextureDimension.Dim1D => WGPUTextureDimension.WGPUTextureDimension_1D,
|
||||
RhiTextureDimension.Dim2D => WGPUTextureDimension.WGPUTextureDimension_2D,
|
||||
RhiTextureDimension.Dim3D => WGPUTextureDimension.WGPUTextureDimension_3D,
|
||||
_ => throw new UnreachableException()
|
||||
};
|
||||
}
|
||||
|
||||
private static RhiTextureUsage ValidateTextureUsage(RhiTextureUsage usage)
|
||||
{
|
||||
if (usage >= RhiTextureUsage.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiTextureUsage)}");
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
||||
private static RhiTextureViewDimension ValidateTextureViewDimension(RhiTextureViewDimension dimension)
|
||||
{
|
||||
if (dimension >= RhiTextureViewDimension.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiTextureViewDimension)}");
|
||||
|
||||
return dimension;
|
||||
}
|
||||
|
||||
private static RhiTextureAspect ValidateTextureAspect(RhiTextureAspect aspect)
|
||||
{
|
||||
if (aspect >= RhiTextureAspect.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiTextureAspect)}");
|
||||
|
||||
return aspect;
|
||||
}
|
||||
|
||||
private static RhiAddressMode ValidateAddressMode(RhiAddressMode addressMode)
|
||||
{
|
||||
if (addressMode >= RhiAddressMode.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiAddressMode)}");
|
||||
|
||||
return addressMode;
|
||||
}
|
||||
|
||||
private static RhiFilterMode ValidateFilterMode(RhiFilterMode filterMode)
|
||||
{
|
||||
if (filterMode >= RhiFilterMode.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiFilterMode)}");
|
||||
|
||||
return filterMode;
|
||||
}
|
||||
|
||||
private static RhiMipmapFilterMode ValidateMipmapFilterMode(RhiMipmapFilterMode mipmapFilterMode)
|
||||
{
|
||||
if (mipmapFilterMode >= RhiMipmapFilterMode.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiMipmapFilterMode)}");
|
||||
|
||||
return mipmapFilterMode;
|
||||
}
|
||||
|
||||
private static RhiCompareFunction ValidateCompareFunction(RhiCompareFunction compareFunction)
|
||||
{
|
||||
if (compareFunction >= RhiCompareFunction.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiCompareFunction)}");
|
||||
|
||||
return compareFunction;
|
||||
}
|
||||
|
||||
private static WGPUPowerPreference ValidatePowerPreference(RhiPowerPreference powerPreference)
|
||||
{
|
||||
if (powerPreference >= RhiPowerPreference.Final)
|
||||
throw new ArgumentException($"Invalid {nameof(RhiPowerPreference)}");
|
||||
|
||||
return (WGPUPowerPreference) powerPreference;
|
||||
}
|
||||
|
||||
private static string MarshalFromString(byte* str)
|
||||
{
|
||||
return Marshal.PtrToStringUTF8((nint)str)!;
|
||||
}
|
||||
|
||||
[return: NotNullIfNotNull(nameof(label))]
|
||||
private static byte[]? MakeLabel(string? label)
|
||||
{
|
||||
// TODO: Replace with stackalloc
|
||||
|
||||
if (label == null)
|
||||
return null;
|
||||
|
||||
return Encoding.UTF8.GetBytes(label);
|
||||
}
|
||||
|
||||
private static WGPUStringView BumpAllocateStringView(ref Span<byte> buf, string? str)
|
||||
{
|
||||
if (str == null)
|
||||
return WGPUStringView.Null;
|
||||
|
||||
var byteCount = Encoding.UTF8.GetByteCount(str) ;
|
||||
var ptr = BumpAllocate(ref buf, byteCount);
|
||||
var dstSpan = new Span<byte>(ptr, byteCount);
|
||||
Encoding.UTF8.GetBytes(str, dstSpan);
|
||||
|
||||
return new WGPUStringView
|
||||
{
|
||||
data = (sbyte*)ptr,
|
||||
length = (nuint)byteCount
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private sealed class WgpuPromise<TResult> : IDisposable
|
||||
{
|
||||
private readonly TaskCompletionSource<TResult> _tcs;
|
||||
private GCHandle _gcHandle;
|
||||
public Task<TResult> Task => _tcs.Task;
|
||||
public void* UserData => (void*) GCHandle.ToIntPtr(_gcHandle);
|
||||
|
||||
public WgpuPromise()
|
||||
{
|
||||
_tcs = new TaskCompletionSource<TResult>();
|
||||
_gcHandle = GCHandle.Alloc(this);
|
||||
}
|
||||
|
||||
public static void SetResult(void* userdata, TResult result)
|
||||
{
|
||||
var self = (WgpuPromise<TResult>)GCHandle.FromIntPtr((nint) userdata).Target!;
|
||||
self._tcs.SetResult(result);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_gcHandle.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
85
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Queue.cs
Normal file
85
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Queue.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
public override RhiQueue Queue { get; }
|
||||
|
||||
// queue is ignored as parameter, since WebGPU only supports one queue for now.
|
||||
|
||||
internal override void QueueWriteTexture(
|
||||
RhiQueue queue,
|
||||
in RhiImageCopyTexture destination,
|
||||
ReadOnlySpan<byte> data,
|
||||
in RhiImageDataLayout dataLayout,
|
||||
RhiExtent3D size)
|
||||
{
|
||||
// TODO: Thread safety
|
||||
var nativeTexture = _textureRegistry[destination.Texture.Handle].Native;
|
||||
|
||||
var nativeDestination = new WGPUTexelCopyTextureInfo
|
||||
{
|
||||
aspect = (WGPUTextureAspect)ValidateTextureAspect(destination.Aspect),
|
||||
texture = nativeTexture,
|
||||
origin = WgpuOrigin3D(destination.Origin),
|
||||
mipLevel = destination.MipLevel
|
||||
};
|
||||
|
||||
var nativeDataLayout = new WGPUTexelCopyBufferLayout
|
||||
{
|
||||
// TODO: Validation
|
||||
offset = dataLayout.Offset,
|
||||
bytesPerRow = dataLayout.BytesPerRow,
|
||||
rowsPerImage = dataLayout.RowsPerImage
|
||||
};
|
||||
|
||||
var nativeSize = WgpuExtent3D(size);
|
||||
|
||||
fixed (byte* pData = data)
|
||||
{
|
||||
wgpuQueueWriteTexture(
|
||||
_wgpuQueue,
|
||||
&nativeDestination,
|
||||
pData, (nuint) data.Length,
|
||||
&nativeDataLayout,
|
||||
&nativeSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public override void QueueWriteBuffer(RhiBuffer buffer, ulong bufferOffset, ReadOnlySpan<byte> data)
|
||||
{
|
||||
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
|
||||
|
||||
fixed (byte* pData = data)
|
||||
{
|
||||
wgpuQueueWriteBuffer(
|
||||
_wgpuQueue,
|
||||
nativeBuffer,
|
||||
bufferOffset,
|
||||
pData,
|
||||
(nuint) data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void QueueSubmit(RhiQueue queue, RhiCommandBuffer[] commandBuffers)
|
||||
{
|
||||
// TODO: Safety
|
||||
|
||||
var pBuffers = stackalloc WGPUCommandBuffer[commandBuffers.Length];
|
||||
for (var i = 0; i < commandBuffers.Length; i++)
|
||||
{
|
||||
pBuffers[i] = _commandBufferRegistry[commandBuffers[i].Handle].Native;
|
||||
}
|
||||
|
||||
wgpuQueueSubmit(
|
||||
_wgpuQueue,
|
||||
(uint) commandBuffers.Length,
|
||||
pBuffers
|
||||
);
|
||||
|
||||
foreach (var commandBuffer in commandBuffers)
|
||||
{
|
||||
CommandBufferDropped(commandBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Registry.cs
Normal file
8
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Registry.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed partial class RhiWebGpu
|
||||
{
|
||||
private long _rhiHandleCounter;
|
||||
|
||||
private RhiHandle AllocRhiHandle() => new(Interlocked.Increment(ref _rhiHandleCounter));
|
||||
}
|
||||
226
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.RenderPipeline.cs
Normal file
226
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.RenderPipeline.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, RenderPipelineReg> _renderPipelineRegistry = new();
|
||||
private readonly Dictionary<RhiHandle, PipelineLayoutReg> _pipelineLayoutRegistry = new();
|
||||
|
||||
public override RhiPipelineLayout CreatePipelineLayout(in RhiPipelineLayoutDescriptor descriptor)
|
||||
{
|
||||
// TODO: SAFETY
|
||||
|
||||
Span<byte> buffer = stackalloc byte[128];
|
||||
var pDescriptor = BumpAllocate<WGPUPipelineLayoutDescriptor>(ref buffer);
|
||||
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
|
||||
var layouts = descriptor.BindGroupLayouts;
|
||||
pDescriptor->bindGroupLayoutCount = (uint) layouts.Length;
|
||||
pDescriptor->bindGroupLayouts = BumpAllocatePtr<WGPUBindGroupLayoutImpl>(ref buffer, layouts.Length);
|
||||
for (var i = 0; i < layouts.Length; i++)
|
||||
{
|
||||
pDescriptor->bindGroupLayouts[i] = _bindGroupLayoutRegistry[layouts[i].Handle].Native;
|
||||
}
|
||||
|
||||
var native = wgpuDeviceCreatePipelineLayout(_wgpuDevice, pDescriptor);
|
||||
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_pipelineLayoutRegistry.Add(handle, new PipelineLayoutReg { Native = native });
|
||||
return new RhiPipelineLayout(this, handle);
|
||||
}
|
||||
|
||||
public override RhiRenderPipeline CreateRenderPipeline(in RhiRenderPipelineDescriptor descriptor)
|
||||
{
|
||||
// TODO: THREAD SAFETY
|
||||
// TODO: INPUT VALIDATION
|
||||
|
||||
var vertexShader = _shaderModuleRegistry[descriptor.Vertex.ProgrammableStage.ShaderModule.Handle].Native;
|
||||
|
||||
const int bufferSize = 8192;
|
||||
var bufferPtr = NativeMemory.AlignedAlloc(bufferSize, 8);
|
||||
|
||||
WGPURenderPipeline nativePipeline;
|
||||
try
|
||||
{
|
||||
var buffer = new Span<byte>(bufferPtr, bufferSize);
|
||||
|
||||
WGPURenderPipelineDescriptor pipelineDesc = default;
|
||||
pipelineDesc.label = BumpAllocateStringView(ref buffer, descriptor.Label);
|
||||
|
||||
// Pipeline layout
|
||||
switch (descriptor.Layout)
|
||||
{
|
||||
case RhiPipelineLayout pipelineLayout:
|
||||
pipelineDesc.layout = _pipelineLayoutRegistry[pipelineLayout.Handle].Native;
|
||||
break;
|
||||
|
||||
case RhiAutoLayoutMode:
|
||||
throw new NotSupportedException("wgpu does not support auto layout yet");
|
||||
// Default case: no layout given, do nothing
|
||||
}
|
||||
|
||||
// Vertex state
|
||||
pipelineDesc.vertex.module = vertexShader;
|
||||
pipelineDesc.vertex.entryPoint = BumpAllocateStringView(
|
||||
ref buffer,
|
||||
descriptor.Vertex.ProgrammableStage.EntryPoint);
|
||||
|
||||
WgpuProgrammableConstants(
|
||||
ref buffer,
|
||||
descriptor.Vertex.ProgrammableStage.Constants,
|
||||
out pipelineDesc.vertex.constantCount,
|
||||
out pipelineDesc.vertex.constants);
|
||||
|
||||
var buffers = descriptor.Vertex.Buffers;
|
||||
pipelineDesc.vertex.bufferCount = (uint)buffers.Length;
|
||||
pipelineDesc.vertex.buffers = BumpAllocate<WGPUVertexBufferLayout>(ref buffer, buffers.Length);
|
||||
for (var i = 0; i < buffers.Length; i++)
|
||||
{
|
||||
ref var bufferLayout = ref pipelineDesc.vertex.buffers[i];
|
||||
bufferLayout.arrayStride = buffers[i].ArrayStride;
|
||||
bufferLayout.stepMode = buffers[i].StepMode == RhiVertexStepMode.Instance
|
||||
? WGPUVertexStepMode.WGPUVertexStepMode_Instance
|
||||
: WGPUVertexStepMode.WGPUVertexStepMode_Vertex;
|
||||
|
||||
var attributes = buffers[i].Attributes;
|
||||
bufferLayout.attributeCount = (uint)attributes.Length;
|
||||
bufferLayout.attributes = BumpAllocate<WGPUVertexAttribute>(ref buffer, attributes.Length);
|
||||
for (var j = 0; j < attributes.Length; j++)
|
||||
{
|
||||
ref var attribute = ref bufferLayout.attributes[j];
|
||||
attribute.format = (WGPUVertexFormat)attributes[j].Format;
|
||||
attribute.offset = attributes[j].Offset;
|
||||
attribute.shaderLocation = attributes[j].ShaderLocation;
|
||||
}
|
||||
}
|
||||
|
||||
// Primitive state
|
||||
pipelineDesc.primitive.topology = (WGPUPrimitiveTopology)descriptor.Primitive.Topology;
|
||||
pipelineDesc.primitive.stripIndexFormat = (WGPUIndexFormat)descriptor.Primitive.StripIndexformat;
|
||||
pipelineDesc.primitive.frontFace = (WGPUFrontFace)descriptor.Primitive.FrontFace;
|
||||
pipelineDesc.primitive.cullMode = (WGPUCullMode)descriptor.Primitive.CullMode;
|
||||
pipelineDesc.primitive.unclippedDepth = descriptor.Primitive.UnclippedDepth ? 1u : 0u;
|
||||
|
||||
// Depth stencil state
|
||||
if (descriptor.DepthStencil is { } depthStencil)
|
||||
{
|
||||
var pDepthStencil = BumpAllocate<WGPUDepthStencilState>(ref buffer);
|
||||
pipelineDesc.depthStencil = pDepthStencil;
|
||||
|
||||
pDepthStencil->format = (WGPUTextureFormat)depthStencil.Format;
|
||||
pDepthStencil->depthWriteEnabled = WgpuOptionalBool(depthStencil.DepthWriteEnabled);
|
||||
pDepthStencil->depthCompare = (WGPUCompareFunction)depthStencil.DepthCompare;
|
||||
pDepthStencil->stencilFront = WgpuStencilFaceState(depthStencil.StencilFront ?? new RhiStencilFaceState());
|
||||
pDepthStencil->stencilBack = WgpuStencilFaceState(depthStencil.StencilBack ?? new RhiStencilFaceState());
|
||||
pDepthStencil->stencilReadMask = depthStencil.StencilReadMask;
|
||||
pDepthStencil->stencilWriteMask = depthStencil.StencilWriteMask;
|
||||
pDepthStencil->depthBias = depthStencil.DepthBias;
|
||||
pDepthStencil->depthBiasSlopeScale = depthStencil.DepthBiasSlopeScale;
|
||||
pDepthStencil->depthBiasClamp = depthStencil.DepthBiasClamp;
|
||||
}
|
||||
|
||||
// Multisample state
|
||||
pipelineDesc.multisample.count = descriptor.Multisample.Count;
|
||||
pipelineDesc.multisample.mask = descriptor.Multisample.Mask;
|
||||
pipelineDesc.multisample.alphaToCoverageEnabled = descriptor.Multisample.AlphaToCoverageEnabled ? 1u : 0u;
|
||||
|
||||
// Fragment state
|
||||
if (descriptor.Fragment is { } fragment)
|
||||
{
|
||||
var fragmentShader = _shaderModuleRegistry[fragment.ProgrammableStage.ShaderModule.Handle].Native;
|
||||
|
||||
var pFragment = BumpAllocate<WGPUFragmentState>(ref buffer);
|
||||
pipelineDesc.fragment = pFragment;
|
||||
|
||||
pFragment->module = fragmentShader;
|
||||
pFragment->entryPoint = BumpAllocateStringView(ref buffer, fragment.ProgrammableStage.EntryPoint);
|
||||
|
||||
WgpuProgrammableConstants(
|
||||
ref buffer,
|
||||
fragment.ProgrammableStage.Constants,
|
||||
out pFragment->constantCount,
|
||||
out pFragment->constants);
|
||||
|
||||
var targets = fragment.Targets;
|
||||
pFragment->targetCount = (uint)targets.Length;
|
||||
pFragment->targets = BumpAllocate<WGPUColorTargetState>(ref buffer, targets.Length);
|
||||
for (var i = 0; i < targets.Length; i++)
|
||||
{
|
||||
ref var target = ref pFragment->targets[i];
|
||||
target.format = (WGPUTextureFormat)targets[i].Format;
|
||||
|
||||
if (targets[i].Blend is { } blend)
|
||||
{
|
||||
var pBlend = BumpAllocate<WGPUBlendState>(ref buffer);
|
||||
target.blend = pBlend;
|
||||
|
||||
pBlend->alpha = WgpuBlendComponent(blend.Alpha);
|
||||
pBlend->color = WgpuBlendComponent(blend.Color);
|
||||
}
|
||||
|
||||
target.writeMask = (ulong)targets[i].WriteMask;
|
||||
}
|
||||
}
|
||||
|
||||
nativePipeline = wgpuDeviceCreateRenderPipeline(_wgpuDevice, &pipelineDesc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
NativeMemory.AlignedFree(bufferPtr);
|
||||
}
|
||||
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_renderPipelineRegistry.Add(handle, new RenderPipelineReg { Native = nativePipeline });
|
||||
return new RhiRenderPipeline(this, handle);
|
||||
}
|
||||
|
||||
private static WGPUStencilFaceState WgpuStencilFaceState(in RhiStencilFaceState state)
|
||||
{
|
||||
return new WGPUStencilFaceState
|
||||
{
|
||||
compare = (WGPUCompareFunction)state.Compare,
|
||||
failOp = (WGPUStencilOperation)state.FailOp,
|
||||
depthFailOp = (WGPUStencilOperation)state.DepthFailOp,
|
||||
passOp = (WGPUStencilOperation)state.PassOp
|
||||
};
|
||||
}
|
||||
|
||||
private static void WgpuProgrammableConstants(
|
||||
ref Span<byte> buffer,
|
||||
RhiConstantEntry[] constants,
|
||||
out nuint constantCount,
|
||||
out WGPUConstantEntry* pConstants)
|
||||
{
|
||||
constantCount = (uint)constants.Length;
|
||||
pConstants = BumpAllocate<WGPUConstantEntry>(ref buffer, constants.Length);
|
||||
for (var i = 0; i < constants.Length; i++)
|
||||
{
|
||||
ref var constant = ref pConstants[i];
|
||||
constant.key = BumpAllocateStringView(ref buffer, constants[i].Key);
|
||||
constant.value = constants[i].Value;
|
||||
}
|
||||
}
|
||||
|
||||
private static WGPUBlendComponent WgpuBlendComponent(in RhiBlendComponent component)
|
||||
{
|
||||
return new WGPUBlendComponent
|
||||
{
|
||||
operation = (WGPUBlendOperation)component.Operation,
|
||||
dstFactor = (WGPUBlendFactor)component.DstFactor,
|
||||
srcFactor = (WGPUBlendFactor)component.SrcFactor,
|
||||
};
|
||||
}
|
||||
|
||||
private sealed class RenderPipelineReg
|
||||
{
|
||||
public WGPURenderPipeline Native;
|
||||
}
|
||||
|
||||
private sealed class PipelineLayoutReg
|
||||
{
|
||||
public WGPUPipelineLayout Native;
|
||||
}
|
||||
}
|
||||
52
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Sampler.cs
Normal file
52
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Sampler.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, SamplerReg> _samplerRegistry = new();
|
||||
|
||||
public override RhiSampler CreateSampler(in RhiSamplerDescriptor descriptor)
|
||||
{
|
||||
var addressModeU = ValidateAddressMode(descriptor.AddressModeU);
|
||||
var addressModeV = ValidateAddressMode(descriptor.AddressModeV);
|
||||
var addressModeW = ValidateAddressMode(descriptor.AddressModeW);
|
||||
var magFilter = ValidateFilterMode(descriptor.MagFilter);
|
||||
var minFilter = ValidateFilterMode(descriptor.MinFilter);
|
||||
var mipmapFilter = ValidateMipmapFilterMode(descriptor.MipmapFilter);
|
||||
var compare = ValidateCompareFunction(descriptor.Compare);
|
||||
|
||||
WGPUSampler sampler;
|
||||
fixed (byte* label = MakeLabel(descriptor.Label))
|
||||
{
|
||||
var samplerDesc = new WGPUSamplerDescriptor
|
||||
{
|
||||
addressModeU = (WGPUAddressMode) addressModeU,
|
||||
addressModeV = (WGPUAddressMode) addressModeV,
|
||||
addressModeW = (WGPUAddressMode) addressModeW,
|
||||
magFilter = (WGPUFilterMode) magFilter,
|
||||
minFilter = (WGPUFilterMode) minFilter,
|
||||
mipmapFilter = (WGPUMipmapFilterMode) mipmapFilter,
|
||||
lodMinClamp = descriptor.LodMinClamp,
|
||||
lodMaxClamp = descriptor.LodMaxClamp,
|
||||
compare = (WGPUCompareFunction) compare,
|
||||
maxAnisotropy = descriptor.MaxAnisotropy,
|
||||
label = new WGPUStringView
|
||||
{
|
||||
data = (sbyte*)label,
|
||||
length = WGPU_STRLEN
|
||||
}
|
||||
};
|
||||
|
||||
sampler = wgpuDeviceCreateSampler(_wgpuDevice, &samplerDesc);
|
||||
}
|
||||
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_samplerRegistry.Add(handle, new SamplerReg { Native = sampler });
|
||||
return new RhiSampler(this, handle);
|
||||
}
|
||||
|
||||
private sealed class SamplerReg
|
||||
{
|
||||
public WGPUSampler Native;
|
||||
}
|
||||
}
|
||||
55
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.ShaderModule.cs
Normal file
55
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.ShaderModule.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, ShaderModuleReg> _shaderModuleRegistry = new();
|
||||
|
||||
public override RhiShaderModule CreateShaderModule(in RhiShaderModuleDescriptor descriptor)
|
||||
{
|
||||
var codeBytes = Encoding.UTF8.GetBytes(descriptor.Code);
|
||||
|
||||
return CreateShaderModule(new RhiShaderModuleDescriptorUtf8
|
||||
{
|
||||
Code = codeBytes,
|
||||
Label = descriptor.Label
|
||||
});
|
||||
}
|
||||
|
||||
public override RhiShaderModule CreateShaderModule(in RhiShaderModuleDescriptorUtf8 descriptor)
|
||||
{
|
||||
WGPUShaderModule shaderModule;
|
||||
fixed (byte* pCode = descriptor.Code)
|
||||
fixed (byte* pLabel = MakeLabel(descriptor.Label))
|
||||
{
|
||||
var descWgsl = new WGPUShaderSourceWGSL();
|
||||
descWgsl.code = new WGPUStringView
|
||||
{
|
||||
data = (sbyte*)pCode,
|
||||
length = WGPU_STRLEN
|
||||
};
|
||||
descWgsl.chain.sType = WGPUSType.WGPUSType_ShaderSourceWGSL;
|
||||
|
||||
var desc = new WGPUShaderModuleDescriptor();
|
||||
desc.label = new WGPUStringView
|
||||
{
|
||||
data = (sbyte*)pLabel,
|
||||
length = WGPU_STRLEN
|
||||
};
|
||||
desc.nextInChain = (WGPUChainedStruct*) (&descWgsl);
|
||||
|
||||
shaderModule = wgpuDeviceCreateShaderModule(_wgpuDevice, &desc);
|
||||
}
|
||||
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_shaderModuleRegistry.Add(handle, new ShaderModuleReg { Native = shaderModule });
|
||||
return new RhiShaderModule(this, handle);
|
||||
}
|
||||
|
||||
private sealed class ShaderModuleReg
|
||||
{
|
||||
public WGPUShaderModule Native;
|
||||
}
|
||||
}
|
||||
152
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Texture.cs
Normal file
152
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Texture.cs
Normal file
@@ -0,0 +1,152 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private readonly Dictionary<RhiHandle, TextureReg> _textureRegistry = new();
|
||||
private readonly Dictionary<RhiHandle, TextureViewReg> _textureViewRegistry = new();
|
||||
|
||||
public override RhiTexture CreateTexture(in RhiTextureDescriptor descriptor)
|
||||
{
|
||||
var format = descriptor.Format;
|
||||
var usage = descriptor.Usage;
|
||||
ValidateTextureFormat(format);
|
||||
var dimension = ValidateTextureDimension(descriptor.Dimension);
|
||||
ValidateTextureUsage(usage);
|
||||
|
||||
// TODO: Copy to stackalloc instead.
|
||||
var viewFormats = descriptor.ViewFormats?.ToArray() ?? [];
|
||||
foreach (var vf in viewFormats)
|
||||
{
|
||||
ValidateTextureFormat(vf);
|
||||
}
|
||||
|
||||
Debug.Assert(
|
||||
sizeof(RhiTextureFormat) == sizeof(WGPUTextureFormat),
|
||||
"Pointer to view formats array is cast directly to pass to native, sizes must match");
|
||||
|
||||
WGPUTexture texturePtr;
|
||||
var label = MakeLabel(descriptor.Label);
|
||||
fixed (byte* pLabel = label)
|
||||
fixed (RhiTextureFormat* pViewFormats = viewFormats)
|
||||
{
|
||||
var webGpuDesc = new WGPUTextureDescriptor
|
||||
{
|
||||
sampleCount = descriptor.SampleCount,
|
||||
mipLevelCount = descriptor.MipLevelCount,
|
||||
dimension = dimension,
|
||||
format = (WGPUTextureFormat) format,
|
||||
label = new WGPUStringView
|
||||
{
|
||||
data = (sbyte*)pLabel,
|
||||
length = (UIntPtr)(label?.Length ?? 0),
|
||||
},
|
||||
size = WgpuExtent3D(descriptor.Size),
|
||||
usage = (ulong) usage,
|
||||
viewFormats = (WGPUTextureFormat*) pViewFormats,
|
||||
viewFormatCount = checked((uint) viewFormats.Length),
|
||||
};
|
||||
|
||||
texturePtr = wgpuDeviceCreateTexture(_wgpuDevice, &webGpuDesc);
|
||||
}
|
||||
|
||||
if (texturePtr == null)
|
||||
throw new RhiException("Texture creation failed");
|
||||
|
||||
return AllocRhiTexture(texturePtr);
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_textureRegistry.Add(handle, new TextureReg { Native = texturePtr });
|
||||
return new RhiTexture(this, handle);
|
||||
}
|
||||
|
||||
internal override RhiTextureView TextureCreateView(RhiTexture texture, in RhiTextureViewDescriptor descriptor)
|
||||
{
|
||||
// TODO: Thread safety
|
||||
var nativeTexture = _textureRegistry[texture.Handle].Native;
|
||||
|
||||
var format = ValidateTextureFormat(descriptor.Format);
|
||||
var dimension = ValidateTextureViewDimension(descriptor.Dimension);
|
||||
var aspect = ValidateTextureAspect(descriptor.Aspect);
|
||||
|
||||
var mipLevelCount = descriptor.MipLevelCount;
|
||||
var arrayLayerCount = descriptor.ArrayLayerCount;
|
||||
|
||||
if (mipLevelCount == 0)
|
||||
throw new ArgumentException($"Invalid {nameof(descriptor.MipLevelCount)}");
|
||||
|
||||
if (arrayLayerCount == 0)
|
||||
throw new ArgumentException($"Invalid {nameof(descriptor.ArrayLayerCount)}");
|
||||
|
||||
WGPUTextureView textureView;
|
||||
fixed (byte* label = MakeLabel(descriptor.Label))
|
||||
{
|
||||
var webGpuDesc = new WGPUTextureViewDescriptor
|
||||
{
|
||||
format = (WGPUTextureFormat) format,
|
||||
dimension = (WGPUTextureViewDimension) dimension,
|
||||
aspect = (WGPUTextureAspect) aspect,
|
||||
label = new WGPUStringView
|
||||
{
|
||||
data = (sbyte*)label,
|
||||
length = WGPU_STRLEN
|
||||
},
|
||||
baseMipLevel = descriptor.BaseMipLevel,
|
||||
mipLevelCount = mipLevelCount,
|
||||
baseArrayLayer = descriptor.BaseArrayLayer,
|
||||
arrayLayerCount = descriptor.ArrayLayerCount
|
||||
};
|
||||
|
||||
textureView = wgpuTextureCreateView(nativeTexture, &webGpuDesc);
|
||||
}
|
||||
|
||||
return AllocRhiTextureView(textureView);
|
||||
}
|
||||
|
||||
internal override void TextureViewDrop(RhiTextureView textureView)
|
||||
{
|
||||
wgpuTextureViewRelease(_textureViewRegistry[textureView.Handle].Native);
|
||||
|
||||
_textureViewRegistry.Remove(textureView.Handle);
|
||||
}
|
||||
|
||||
internal override RhiTexture GetSurfaceTextureForWindow(WindowData reg)
|
||||
{
|
||||
// TODO: Thread safety
|
||||
|
||||
var surface = reg.Surface;
|
||||
|
||||
// This creates a new texture view handle.
|
||||
WGPUSurfaceTexture textureRet;
|
||||
wgpuSurfaceGetCurrentTexture(surface, &textureRet);
|
||||
|
||||
return AllocRhiTexture(textureRet.texture);
|
||||
}
|
||||
|
||||
private RhiTexture AllocRhiTexture(WGPUTexture native)
|
||||
{
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_textureRegistry.Add(handle, new TextureReg { Native = native });
|
||||
return new RhiTexture(this, handle);
|
||||
}
|
||||
|
||||
private RhiTextureView AllocRhiTextureView(WGPUTextureView native)
|
||||
{
|
||||
// TODO: Thread safety
|
||||
var handle = AllocRhiHandle();
|
||||
_textureViewRegistry.Add(handle, new TextureViewReg { Native = native });
|
||||
return new RhiTextureView(this, handle);
|
||||
}
|
||||
|
||||
private sealed class TextureReg
|
||||
{
|
||||
public WGPUTexture Native;
|
||||
}
|
||||
|
||||
private sealed class TextureViewReg
|
||||
{
|
||||
public WGPUTextureView Native;
|
||||
}
|
||||
}
|
||||
171
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Window.cs
Normal file
171
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Window.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu
|
||||
{
|
||||
private RhiTextureFormat _mainTextureFormat;
|
||||
private WGPUPresentMode[] _availPresentModes = [];
|
||||
|
||||
public override RhiTextureFormat MainTextureFormat => _mainTextureFormat;
|
||||
|
||||
public sealed class WindowData
|
||||
{
|
||||
public WGPUSurface Surface;
|
||||
}
|
||||
|
||||
private WindowData CreateSurfaceForWindow(in RhiWindowSurfaceParams surfaceParams)
|
||||
{
|
||||
WGPUSurfaceDescriptor surfaceDesc = default;
|
||||
|
||||
#if WINDOWS
|
||||
var surfaceDescHwnd = new WGPUSurfaceSourceWindowsHWND
|
||||
{
|
||||
chain =
|
||||
{
|
||||
sType = WGPUSType.WGPUSType_SurfaceSourceWindowsHWND
|
||||
},
|
||||
hinstance = surfaceParams.HInstance,
|
||||
hwnd = surfaceParams.HWnd,
|
||||
};
|
||||
|
||||
surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescHwnd);
|
||||
|
||||
#elif MACOS
|
||||
var surfaceDescMetal = new WGPUSurfaceSourceMetalLayer
|
||||
{
|
||||
chain =
|
||||
{
|
||||
sType = WGPUSType.WGPUSType_SurfaceSourceMetalLayer
|
||||
},
|
||||
layer = surfaceParams.MetalLayer
|
||||
};
|
||||
|
||||
surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescMetal);
|
||||
|
||||
#elif LINUX
|
||||
WGPUSurfaceSourceWaylandSurface surfaceDescWayland;
|
||||
WGPUSurfaceSourceXlibWindow surfaceDescX11;
|
||||
|
||||
if (surfaceParams.Wayland)
|
||||
{
|
||||
surfaceDescWayland = new WGPUSurfaceSourceWaylandSurface
|
||||
{
|
||||
chain =
|
||||
{
|
||||
sType = WGPUSType.WGPUSType_SurfaceSourceWaylandSurface
|
||||
},
|
||||
display = surfaceParams.WaylandDisplay,
|
||||
surface = surfaceParams.WaylandSurface,
|
||||
};
|
||||
|
||||
surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescWayland);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceDescX11 = new WGPUSurfaceSourceXlibWindow()
|
||||
{
|
||||
chain =
|
||||
{
|
||||
sType = WGPUSType.WGPUSType_SurfaceSourceXlibWindow
|
||||
},
|
||||
display = surfaceParams.X11Display,
|
||||
// TODO "Oh my god x11 support might be a nightmare this is outside of your ability to deal with -pjb"
|
||||
// window = surfaceParams.X11Window,
|
||||
};
|
||||
|
||||
surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescX11);
|
||||
}
|
||||
#endif
|
||||
|
||||
var surface = wgpuInstanceCreateSurface(_wgpuInstance, &surfaceDesc);
|
||||
return new WindowData
|
||||
{
|
||||
Surface = surface
|
||||
};
|
||||
}
|
||||
|
||||
private void DecideMainTextureFormat(WindowData mainWindow)
|
||||
{
|
||||
WGPUSurfaceCapabilities surfaceCaps;
|
||||
var res = wgpuSurfaceGetCapabilities(mainWindow.Surface, _wgpuAdapter, &surfaceCaps);
|
||||
if (res != WGPUStatus.WGPUStatus_Success)
|
||||
throw new RhiException("wgpuSurfaceGetCapabilities failed");
|
||||
|
||||
var modes = new Span<WGPUPresentMode>(surfaceCaps.presentModes, (int)surfaceCaps.presentModeCount);
|
||||
_availPresentModes = modes.ToArray();
|
||||
_sawmill.Debug($"Available present modes: {string.Join(", ", _availPresentModes)}");
|
||||
|
||||
var formats = new Span<WGPUTextureFormat>(surfaceCaps.formats, (int)surfaceCaps.formatCount);
|
||||
|
||||
var found = false;
|
||||
foreach (var format in formats)
|
||||
{
|
||||
if (format == WGPUTextureFormat.WGPUTextureFormat_BGRA8UnormSrgb ||
|
||||
format == WGPUTextureFormat.WGPUTextureFormat_RGBA8UnormSrgb)
|
||||
{
|
||||
found = true;
|
||||
_mainTextureFormat = ToRhiFormat(format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_sawmill.Debug($"Available surface formats: {string.Join(", ", formats.ToArray())}");
|
||||
|
||||
if (!found)
|
||||
throw new RhiException("Unable to find suitable surface format for main window!");
|
||||
|
||||
_sawmill.Debug($"Preferred surface format is {_mainTextureFormat}");
|
||||
|
||||
wgpuSurfaceCapabilitiesFreeMembers(surfaceCaps);
|
||||
}
|
||||
|
||||
private void ConfigureSurface(WindowData window, Vector2i size, bool vsync)
|
||||
{
|
||||
var swapChainDesc = new WGPUSurfaceConfiguration
|
||||
{
|
||||
format = ValidateTextureFormat(_mainTextureFormat),
|
||||
width = (uint)size.X,
|
||||
height = (uint)size.Y,
|
||||
usage = WGPUTextureUsage_RenderAttachment,
|
||||
presentMode = WGPUPresentMode.WGPUPresentMode_Fifo,
|
||||
device = _wgpuDevice
|
||||
};
|
||||
|
||||
if (!vsync)
|
||||
{
|
||||
if (_availPresentModes.Contains(WGPUPresentMode.WGPUPresentMode_Immediate))
|
||||
swapChainDesc.presentMode = WGPUPresentMode.WGPUPresentMode_Immediate;
|
||||
else if (_availPresentModes.Contains(WGPUPresentMode.WGPUPresentMode_Mailbox))
|
||||
swapChainDesc.presentMode = WGPUPresentMode.WGPUPresentMode_Mailbox;
|
||||
}
|
||||
|
||||
wgpuSurfaceConfigure(window.Surface, &swapChainDesc);
|
||||
|
||||
_sawmill.Verbose("WebGPU Surface reconfigured!");
|
||||
}
|
||||
|
||||
internal override WindowData WindowCreated(in RhiWindowSurfaceParams surfaceParams, Vector2i size, bool vsync)
|
||||
{
|
||||
var windowData = CreateSurfaceForWindow(in surfaceParams);
|
||||
ConfigureSurface(windowData, size, vsync);
|
||||
return windowData;
|
||||
}
|
||||
|
||||
internal override void WindowDestroy(WindowData reg)
|
||||
{
|
||||
wgpuSurfaceUnconfigure(reg.Surface);
|
||||
wgpuSurfaceRelease(reg.Surface);
|
||||
}
|
||||
|
||||
internal override void WindowRecreateSwapchain(WindowData reg, Vector2i size, bool vsyncEnabled)
|
||||
{
|
||||
ConfigureSurface(reg, size, vsyncEnabled);
|
||||
}
|
||||
|
||||
internal override void WindowPresent(WindowData reg)
|
||||
{
|
||||
// TODO: Safety
|
||||
wgpuSurfacePresent(reg.Surface);
|
||||
}
|
||||
}
|
||||
335
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.cs
Normal file
335
Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.cs
Normal file
@@ -0,0 +1,335 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Utility;
|
||||
using RLogLevel = Robust.Shared.Log.LogLevel;
|
||||
|
||||
#pragma warning disable CS8500
|
||||
|
||||
namespace Robust.Client.Graphics.Rhi.WebGpu;
|
||||
|
||||
internal sealed unsafe partial class RhiWebGpu : RhiBase
|
||||
{
|
||||
private readonly ISawmill _sawmill;
|
||||
private readonly ISawmill _apiLogSawmill;
|
||||
|
||||
private WGPUInstance _wgpuInstance;
|
||||
private WGPUAdapter _wgpuAdapter;
|
||||
private WGPUDevice _wgpuDevice;
|
||||
private WGPUQueue _wgpuQueue;
|
||||
|
||||
private RhiLimits? _deviceLimits;
|
||||
private RhiAdapterInfo? _adapterProperties;
|
||||
private string _description = "not initialized";
|
||||
|
||||
public override RhiLimits DeviceLimits =>
|
||||
_deviceLimits ?? throw new InvalidOperationException("Not initialized yet");
|
||||
|
||||
public override RhiAdapterInfo AdapterInfo =>
|
||||
_adapterProperties ?? throw new InvalidOperationException("Not initialized yet");
|
||||
|
||||
public override string Description => _description;
|
||||
|
||||
public RhiWebGpu(IDependencyCollection dependencies)
|
||||
{
|
||||
var logMgr = dependencies.Resolve<ILogManager>();
|
||||
|
||||
_sawmill = logMgr.GetSawmill("clyde.rhi.webGpu");
|
||||
_apiLogSawmill = logMgr.GetSawmill("clyde.rhi.webGpu.apiLog");
|
||||
|
||||
Queue = new RhiQueue(this, default);
|
||||
}
|
||||
|
||||
internal override void Init(in RhiInitParams initParams, out WindowData windowData)
|
||||
{
|
||||
_sawmill.Info("Initializing WebGPU RHI!");
|
||||
|
||||
InitInstance(in initParams);
|
||||
|
||||
windowData = CreateSurfaceForWindow(in initParams.MainWindowSurfaceParams);
|
||||
|
||||
_sawmill.Debug("WebGPU main surface created!");
|
||||
|
||||
InitAdapterAndDevice(in initParams, windowData.Surface);
|
||||
DecideMainTextureFormat(windowData);
|
||||
}
|
||||
|
||||
private void InitInstance(in RhiInitParams initParams)
|
||||
{
|
||||
var wgpuVersion = WgpuVersionToString(wgpuGetVersion());
|
||||
_sawmill.Debug($"wgpu-native loaded, version: {wgpuVersion}");
|
||||
|
||||
_description = $"WebGPU (wgpu-native {wgpuVersion})";
|
||||
|
||||
InitLogging();
|
||||
|
||||
Span<byte> buffer = stackalloc byte[128];
|
||||
var pInstanceDescriptor = BumpAllocate<WGPUInstanceDescriptor>(ref buffer);
|
||||
|
||||
// Specify instance extras for wgpu-native.
|
||||
var pInstanceExtras = BumpAllocate<WGPUInstanceExtras>(ref buffer);
|
||||
pInstanceDescriptor->nextInChain = (WGPUChainedStruct*)pInstanceExtras;
|
||||
pInstanceExtras->chain.sType = (WGPUSType)WGPUNativeSType.WGPUSType_InstanceExtras;
|
||||
pInstanceExtras->backends = (uint)GetInstanceBackendCfg(initParams.Backends);
|
||||
|
||||
_wgpuInstance = wgpuCreateInstance(pInstanceDescriptor);
|
||||
|
||||
_sawmill.Debug("WebGPU instance created!");
|
||||
}
|
||||
|
||||
private ulong GetInstanceBackendCfg(string backendCvar)
|
||||
{
|
||||
if (backendCvar == "all")
|
||||
return WGPUInstanceBackend_Primary | WGPUInstanceBackend_Secondary;
|
||||
|
||||
var backends = 0ul;
|
||||
foreach (var opt in backendCvar.Split(","))
|
||||
{
|
||||
backends |= opt switch
|
||||
{
|
||||
"vulkan" => WGPUInstanceBackend_Vulkan,
|
||||
"gl" => WGPUInstanceBackend_GL,
|
||||
"metal" => WGPUInstanceBackend_Metal,
|
||||
"dx12" => WGPUInstanceBackend_DX12,
|
||||
"dx11" => WGPUInstanceBackend_DX11,
|
||||
"browser" => WGPUInstanceBackend_BrowserWebGPU,
|
||||
_ => throw new ArgumentException($"Unknown wgpu backend: '{opt}'")
|
||||
};
|
||||
}
|
||||
|
||||
return backends;
|
||||
}
|
||||
|
||||
private void InitAdapterAndDevice(in RhiInitParams initParams, WGPUSurface forSurface)
|
||||
{
|
||||
var powerPreference = ValidatePowerPreference(initParams.PowerPreference);
|
||||
|
||||
var requestAdapterOptions = new WGPURequestAdapterOptions
|
||||
{
|
||||
compatibleSurface = forSurface,
|
||||
powerPreference = powerPreference
|
||||
};
|
||||
|
||||
WgpuRequestAdapterResult result;
|
||||
wgpuInstanceRequestAdapter(
|
||||
_wgpuInstance,
|
||||
&requestAdapterOptions,
|
||||
new WGPURequestAdapterCallbackInfo
|
||||
{
|
||||
callback = &WgpuRequestAdapterCallback,
|
||||
userdata1 = &result,
|
||||
});
|
||||
|
||||
if (result.Status != WGPURequestAdapterStatus.WGPURequestAdapterStatus_Success)
|
||||
throw new RhiException($"Adapter request failed: {result.Message}");
|
||||
|
||||
_sawmill.Debug("WebGPU adapter created!");
|
||||
|
||||
_wgpuAdapter = result.Adapter.P;
|
||||
|
||||
WGPUAdapterInfo adapterProps = default;
|
||||
wgpuAdapterGetInfo(_wgpuAdapter, &adapterProps);
|
||||
|
||||
WGPULimits adapterLimits = default;
|
||||
wgpuAdapterGetLimits(_wgpuAdapter, &adapterLimits);
|
||||
|
||||
_sawmill.Debug($"adapter device: {GetString(adapterProps.device)}");
|
||||
_sawmill.Debug($"adapter vendor: {GetString(adapterProps.vendor)} ({adapterProps.vendorID})");
|
||||
_sawmill.Debug($"adapter description: {GetString(adapterProps.description)}");
|
||||
_sawmill.Debug($"adapter architecture: {GetString(adapterProps.architecture)}");
|
||||
_sawmill.Debug($"adapter backend: {adapterProps.backendType}");
|
||||
_sawmill.Debug($"adapter type: {adapterProps.adapterType}");
|
||||
_sawmill.Debug($"adapter UBO alignment: {adapterLimits.minUniformBufferOffsetAlignment}");
|
||||
|
||||
_adapterProperties = new RhiAdapterInfo(
|
||||
adapterProps.vendorID,
|
||||
adapterProps.deviceID,
|
||||
GetString(adapterProps.vendor) ?? "",
|
||||
GetString(adapterProps.architecture) ?? "",
|
||||
GetString(adapterProps.device) ?? "",
|
||||
GetString(adapterProps.description) ?? "",
|
||||
(RhiAdapterType) adapterProps.adapterType,
|
||||
(RhiBackendType) adapterProps.backendType
|
||||
);
|
||||
|
||||
_description += $", backend: {_adapterProperties.BackendType}";
|
||||
|
||||
// Default limits, from WebGPU spec.
|
||||
var requiredLimits = new WGPULimits();
|
||||
if (false)
|
||||
{
|
||||
// GLES3.0
|
||||
requiredLimits.maxComputeWorkgroupStorageSize = 16384;
|
||||
requiredLimits.maxComputeInvocationsPerWorkgroup = 256;
|
||||
requiredLimits.maxComputeWorkgroupSizeX = 256;
|
||||
requiredLimits.maxComputeWorkgroupSizeY = 256;
|
||||
requiredLimits.maxComputeWorkgroupSizeZ = 256;
|
||||
requiredLimits.maxComputeWorkgroupsPerDimension = 65536;
|
||||
requiredLimits.maxDynamicStorageBuffersPerPipelineLayout = 0;
|
||||
requiredLimits.maxStorageBuffersPerShaderStage = 4;
|
||||
requiredLimits.maxStorageBufferBindingSize = 134217728;
|
||||
}
|
||||
|
||||
// Required minimums
|
||||
requiredLimits.minStorageBufferOffsetAlignment = 256;
|
||||
requiredLimits.minUniformBufferOffsetAlignment = 256;
|
||||
|
||||
requiredLimits.maxTextureArrayLayers = 256;
|
||||
requiredLimits.maxBindGroups = 4;
|
||||
requiredLimits.maxBindingsPerBindGroup = 1000;
|
||||
requiredLimits.maxDynamicUniformBuffersPerPipelineLayout = 8;
|
||||
requiredLimits.maxSampledTexturesPerShaderStage = 16;
|
||||
requiredLimits.maxSamplersPerShaderStage = 16;
|
||||
requiredLimits.maxUniformBuffersPerShaderStage = 12;
|
||||
requiredLimits.maxUniformBufferBindingSize = 65536;
|
||||
requiredLimits.maxVertexBuffers = 8;
|
||||
requiredLimits.maxVertexAttributes = 16;
|
||||
requiredLimits.maxVertexBufferArrayStride = 2048;
|
||||
requiredLimits.maxInterStageShaderVariables = 16;
|
||||
requiredLimits.maxColorAttachments = 8;
|
||||
requiredLimits.maxColorAttachmentBytesPerSample = 32;
|
||||
requiredLimits.maxBufferSize = 268435456;
|
||||
|
||||
// Custom limits
|
||||
// Take as low UBO alignment as we can get.
|
||||
requiredLimits.minUniformBufferOffsetAlignment = adapterLimits.minUniformBufferOffsetAlignment;
|
||||
// Take as large textures as we can get.
|
||||
requiredLimits.maxTextureDimension1D = adapterLimits.maxTextureDimension1D;
|
||||
requiredLimits.maxTextureDimension2D = adapterLimits.maxTextureDimension2D;
|
||||
requiredLimits.maxTextureDimension3D = adapterLimits.maxTextureDimension3D;
|
||||
|
||||
// TODO: clear this.
|
||||
var errorGCHandle = GCHandle.Alloc(this);
|
||||
|
||||
var deviceDesc = new WGPUDeviceDescriptor();
|
||||
deviceDesc.requiredLimits = &requiredLimits;
|
||||
deviceDesc.uncapturedErrorCallbackInfo = new WGPUUncapturedErrorCallbackInfo
|
||||
{
|
||||
callback = &UncapturedErrorCallback,
|
||||
userdata1 = (void*)GCHandle.ToIntPtr(errorGCHandle),
|
||||
};
|
||||
WgpuRequestDeviceResult deviceResult;
|
||||
wgpuAdapterRequestDevice(
|
||||
_wgpuAdapter,
|
||||
&deviceDesc,
|
||||
new WGPURequestDeviceCallbackInfo
|
||||
{
|
||||
callback = &WgpuRequestDeviceCallback,
|
||||
userdata1 = &deviceResult
|
||||
});
|
||||
|
||||
if (deviceResult.Status != WGPURequestDeviceStatus.WGPURequestDeviceStatus_Success)
|
||||
throw new Exception($"Device request failed: {deviceResult.Message}");
|
||||
|
||||
_sawmill.Debug("WebGPU device created!");
|
||||
|
||||
_wgpuDevice = deviceResult.Device;
|
||||
_wgpuQueue = wgpuDeviceGetQueue(_wgpuDevice);
|
||||
|
||||
_deviceLimits = new RhiLimits(
|
||||
requiredLimits.maxTextureDimension1D,
|
||||
requiredLimits.maxTextureDimension2D,
|
||||
requiredLimits.maxTextureDimension3D,
|
||||
requiredLimits.maxTextureArrayLayers,
|
||||
requiredLimits.maxBindGroups,
|
||||
requiredLimits.maxBindingsPerBindGroup,
|
||||
requiredLimits.maxDynamicUniformBuffersPerPipelineLayout,
|
||||
requiredLimits.maxDynamicStorageBuffersPerPipelineLayout,
|
||||
requiredLimits.maxSampledTexturesPerShaderStage,
|
||||
requiredLimits.maxSamplersPerShaderStage,
|
||||
requiredLimits.maxStorageBuffersPerShaderStage,
|
||||
requiredLimits.maxStorageTexturesPerShaderStage,
|
||||
requiredLimits.maxUniformBuffersPerShaderStage,
|
||||
requiredLimits.maxUniformBufferBindingSize,
|
||||
requiredLimits.maxStorageBufferBindingSize,
|
||||
requiredLimits.minUniformBufferOffsetAlignment,
|
||||
requiredLimits.minStorageBufferOffsetAlignment,
|
||||
requiredLimits.maxVertexBuffers,
|
||||
requiredLimits.maxBufferSize,
|
||||
requiredLimits.maxVertexAttributes,
|
||||
requiredLimits.maxVertexBufferArrayStride,
|
||||
requiredLimits.maxInterStageShaderVariables,
|
||||
requiredLimits.maxColorAttachments,
|
||||
requiredLimits.maxColorAttachmentBytesPerSample,
|
||||
requiredLimits.maxComputeWorkgroupStorageSize,
|
||||
requiredLimits.maxComputeInvocationsPerWorkgroup,
|
||||
requiredLimits.maxComputeWorkgroupSizeX,
|
||||
requiredLimits.maxComputeWorkgroupSizeY,
|
||||
requiredLimits.maxComputeWorkgroupSizeZ,
|
||||
requiredLimits.maxComputeWorkgroupsPerDimension
|
||||
);
|
||||
}
|
||||
|
||||
private void InitLogging()
|
||||
{
|
||||
// TODO: clear this.
|
||||
var gcHandle = GCHandle.Alloc(this);
|
||||
|
||||
wgpuSetLogCallback(&LogCallback, (void*)GCHandle.ToIntPtr(gcHandle));
|
||||
wgpuSetLogLevel(WGPULogLevel.WGPULogLevel_Warn);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static void LogCallback(WGPULogLevel level, WGPUStringView message, void* userdata)
|
||||
{
|
||||
var self = (RhiWebGpu)GCHandle.FromIntPtr((nint)userdata).Target!;
|
||||
var messageString = GetString(message)!;
|
||||
|
||||
var robustLevel = level switch
|
||||
{
|
||||
WGPULogLevel.WGPULogLevel_Error => RLogLevel.Error,
|
||||
WGPULogLevel.WGPULogLevel_Warn => RLogLevel.Warning,
|
||||
WGPULogLevel.WGPULogLevel_Info => RLogLevel.Info,
|
||||
WGPULogLevel.WGPULogLevel_Debug => RLogLevel.Debug,
|
||||
WGPULogLevel.WGPULogLevel_Trace or _ => RLogLevel.Verbose,
|
||||
};
|
||||
|
||||
self._apiLogSawmill.Log(robustLevel, messageString);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static void UncapturedErrorCallback(WGPUDevice* device, WGPUErrorType level, WGPUStringView message, void* userdata1, void* userdata2)
|
||||
{
|
||||
var self = (RhiWebGpu)GCHandle.FromIntPtr((nint)userdata1).Target!;
|
||||
var messageString = GetString(message);
|
||||
|
||||
self._apiLogSawmill.Error(messageString ?? "Unknown error");
|
||||
}
|
||||
|
||||
internal override void Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
private record struct WgpuRequestAdapterResult(WGPURequestAdapterStatus Status, Ptr<WGPUAdapterImpl> Adapter, string Message);
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static void WgpuRequestAdapterCallback(
|
||||
WGPURequestAdapterStatus status,
|
||||
WGPUAdapter adapter,
|
||||
WGPUStringView message,
|
||||
void* userdata1,
|
||||
void* userdata2)
|
||||
{
|
||||
*(WgpuRequestAdapterResult*)userdata1 = new WgpuRequestAdapterResult(
|
||||
status,
|
||||
adapter,
|
||||
GetString(message) ?? "");
|
||||
}
|
||||
|
||||
private record struct WgpuRequestDeviceResult(WGPURequestDeviceStatus Status, Ptr<WGPUDeviceImpl> Device, string Message);
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static void WgpuRequestDeviceCallback(
|
||||
WGPURequestDeviceStatus status,
|
||||
WGPUDevice device,
|
||||
WGPUStringView message,
|
||||
void* userdata1,
|
||||
void* userdata2)
|
||||
{
|
||||
*(WgpuRequestDeviceResult*)userdata1 = new WgpuRequestDeviceResult(
|
||||
status,
|
||||
device,
|
||||
GetString(message) ?? "");
|
||||
}
|
||||
}
|
||||
5
Robust.Client.Interop.RobustNative/AssemblyInfo.cs
Normal file
5
Robust.Client.Interop.RobustNative/AssemblyInfo.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Robust.Client")]
|
||||
[assembly: InternalsVisibleTo("Robust.Client.Graphics.Rhi")]
|
||||
[module: SkipLocalsInit]
|
||||
21
Robust.Client.Interop.RobustNative/DllMap.cs
Normal file
21
Robust.Client.Interop.RobustNative/DllMap.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Robust.Client.Interop.RobustNative;
|
||||
|
||||
|
||||
internal static class DllMap
|
||||
{
|
||||
#pragma warning disable CA2255
|
||||
[ModuleInitializer]
|
||||
#pragma warning restore CA2255
|
||||
public static void Initializer()
|
||||
{
|
||||
if (Environment.GetEnvironmentVariable("ROBUST_NATIVE_PATH") is not { } nativePath)
|
||||
return;
|
||||
|
||||
NativeLibrary.SetDllImportResolver(
|
||||
typeof(DllMap).Assembly,
|
||||
(_, _, _) => NativeLibrary.Load(nativePath));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\MSBuild\Robust.Engine.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<SkipRobustAnalyzer>true</SkipRobustAnalyzer>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=webgpu_005Cgen/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
/// <summary>Defines the annotation found in a native declaration.</summary>
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
|
||||
[Conditional("DEBUG")]
|
||||
internal sealed partial class NativeAnnotationAttribute : Attribute
|
||||
{
|
||||
private readonly string _annotation;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="NativeAnnotationAttribute" /> class.</summary>
|
||||
/// <param name="annotation">The annotation that was used in the native declaration.</param>
|
||||
public NativeAnnotationAttribute(string annotation)
|
||||
{
|
||||
_annotation = annotation;
|
||||
}
|
||||
|
||||
/// <summary>Gets the annotation that was used in the native declaration.</summary>
|
||||
public string Annotation => _annotation;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
/// <summary>Defines the type of a member as it was used in the native signature.</summary>
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)]
|
||||
[Conditional("DEBUG")]
|
||||
internal sealed partial class NativeTypeNameAttribute : Attribute
|
||||
{
|
||||
private readonly string _name;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="NativeTypeNameAttribute" /> class.</summary>
|
||||
/// <param name="name">The name of the type that was used in the native signature.</param>
|
||||
public NativeTypeNameAttribute(string name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/// <summary>Gets the name of the type that was used in the native signature.</summary>
|
||||
public string Name => _name;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal partial struct WGPUAdapterImpl
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal unsafe partial struct WGPUAdapterInfo
|
||||
{
|
||||
public WGPUChainedStructOut* nextInChain;
|
||||
|
||||
public WGPUStringView vendor;
|
||||
|
||||
public WGPUStringView architecture;
|
||||
|
||||
public WGPUStringView device;
|
||||
|
||||
public WGPUStringView description;
|
||||
|
||||
public WGPUBackendType backendType;
|
||||
|
||||
public WGPUAdapterType adapterType;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint vendorID;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint deviceID;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal enum WGPUAdapterType
|
||||
{
|
||||
WGPUAdapterType_DiscreteGPU = 0x00000001,
|
||||
WGPUAdapterType_IntegratedGPU = 0x00000002,
|
||||
WGPUAdapterType_CPU = 0x00000003,
|
||||
WGPUAdapterType_Unknown = 0x00000004,
|
||||
WGPUAdapterType_Force32 = 0x7FFFFFFF,
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal enum WGPUAddressMode
|
||||
{
|
||||
WGPUAddressMode_Undefined = 0x00000000,
|
||||
WGPUAddressMode_ClampToEdge = 0x00000001,
|
||||
WGPUAddressMode_Repeat = 0x00000002,
|
||||
WGPUAddressMode_MirrorRepeat = 0x00000003,
|
||||
WGPUAddressMode_Force32 = 0x7FFFFFFF,
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal enum WGPUBackendType
|
||||
{
|
||||
WGPUBackendType_Undefined = 0x00000000,
|
||||
WGPUBackendType_Null = 0x00000001,
|
||||
WGPUBackendType_WebGPU = 0x00000002,
|
||||
WGPUBackendType_D3D11 = 0x00000003,
|
||||
WGPUBackendType_D3D12 = 0x00000004,
|
||||
WGPUBackendType_Metal = 0x00000005,
|
||||
WGPUBackendType_Vulkan = 0x00000006,
|
||||
WGPUBackendType_OpenGL = 0x00000007,
|
||||
WGPUBackendType_OpenGLES = 0x00000008,
|
||||
WGPUBackendType_Force32 = 0x7FFFFFFF,
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal unsafe partial struct WGPUBindGroupDescriptor
|
||||
{
|
||||
[NativeTypeName("const WGPUChainedStruct *")]
|
||||
public WGPUChainedStruct* nextInChain;
|
||||
|
||||
public WGPUStringView label;
|
||||
|
||||
[NativeTypeName("WGPUBindGroupLayout")]
|
||||
public WGPUBindGroupLayoutImpl* layout;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public nuint entryCount;
|
||||
|
||||
[NativeTypeName("const WGPUBindGroupEntry *")]
|
||||
public WGPUBindGroupEntry* entries;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal unsafe partial struct WGPUBindGroupEntry
|
||||
{
|
||||
[NativeTypeName("const WGPUChainedStruct *")]
|
||||
public WGPUChainedStruct* nextInChain;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint binding;
|
||||
|
||||
[NativeTypeName("WGPUBuffer")]
|
||||
public WGPUBufferImpl* buffer;
|
||||
|
||||
[NativeTypeName("uint64_t")]
|
||||
public ulong offset;
|
||||
|
||||
[NativeTypeName("uint64_t")]
|
||||
public ulong size;
|
||||
|
||||
[NativeTypeName("WGPUSampler")]
|
||||
public WGPUSamplerImpl* sampler;
|
||||
|
||||
[NativeTypeName("WGPUTextureView")]
|
||||
public WGPUTextureViewImpl* textureView;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal unsafe partial struct WGPUBindGroupEntryExtras
|
||||
{
|
||||
public WGPUChainedStruct chain;
|
||||
|
||||
[NativeTypeName("const WGPUBuffer *")]
|
||||
public WGPUBufferImpl** buffers;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public nuint bufferCount;
|
||||
|
||||
[NativeTypeName("const WGPUSampler *")]
|
||||
public WGPUSamplerImpl** samplers;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public nuint samplerCount;
|
||||
|
||||
[NativeTypeName("const WGPUTextureView *")]
|
||||
public WGPUTextureViewImpl** textureViews;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public nuint textureViewCount;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal partial struct WGPUBindGroupImpl
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal unsafe partial struct WGPUBindGroupLayoutDescriptor
|
||||
{
|
||||
[NativeTypeName("const WGPUChainedStruct *")]
|
||||
public WGPUChainedStruct* nextInChain;
|
||||
|
||||
public WGPUStringView label;
|
||||
|
||||
[NativeTypeName("size_t")]
|
||||
public nuint entryCount;
|
||||
|
||||
[NativeTypeName("const WGPUBindGroupLayoutEntry *")]
|
||||
public WGPUBindGroupLayoutEntry* entries;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal unsafe partial struct WGPUBindGroupLayoutEntry
|
||||
{
|
||||
[NativeTypeName("const WGPUChainedStruct *")]
|
||||
public WGPUChainedStruct* nextInChain;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint binding;
|
||||
|
||||
[NativeTypeName("WGPUShaderStage")]
|
||||
public ulong visibility;
|
||||
|
||||
public WGPUBufferBindingLayout buffer;
|
||||
|
||||
public WGPUSamplerBindingLayout sampler;
|
||||
|
||||
public WGPUTextureBindingLayout texture;
|
||||
|
||||
public WGPUStorageTextureBindingLayout storageTexture;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal partial struct WGPUBindGroupLayoutEntryExtras
|
||||
{
|
||||
public WGPUChainedStruct chain;
|
||||
|
||||
[NativeTypeName("uint32_t")]
|
||||
public uint count;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal partial struct WGPUBindGroupLayoutImpl
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal partial struct WGPUBlendComponent
|
||||
{
|
||||
public WGPUBlendOperation operation;
|
||||
|
||||
public WGPUBlendFactor srcFactor;
|
||||
|
||||
public WGPUBlendFactor dstFactor;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal enum WGPUBlendFactor
|
||||
{
|
||||
WGPUBlendFactor_Undefined = 0x00000000,
|
||||
WGPUBlendFactor_Zero = 0x00000001,
|
||||
WGPUBlendFactor_One = 0x00000002,
|
||||
WGPUBlendFactor_Src = 0x00000003,
|
||||
WGPUBlendFactor_OneMinusSrc = 0x00000004,
|
||||
WGPUBlendFactor_SrcAlpha = 0x00000005,
|
||||
WGPUBlendFactor_OneMinusSrcAlpha = 0x00000006,
|
||||
WGPUBlendFactor_Dst = 0x00000007,
|
||||
WGPUBlendFactor_OneMinusDst = 0x00000008,
|
||||
WGPUBlendFactor_DstAlpha = 0x00000009,
|
||||
WGPUBlendFactor_OneMinusDstAlpha = 0x0000000A,
|
||||
WGPUBlendFactor_SrcAlphaSaturated = 0x0000000B,
|
||||
WGPUBlendFactor_Constant = 0x0000000C,
|
||||
WGPUBlendFactor_OneMinusConstant = 0x0000000D,
|
||||
WGPUBlendFactor_Src1 = 0x0000000E,
|
||||
WGPUBlendFactor_OneMinusSrc1 = 0x0000000F,
|
||||
WGPUBlendFactor_Src1Alpha = 0x00000010,
|
||||
WGPUBlendFactor_OneMinusSrc1Alpha = 0x00000011,
|
||||
WGPUBlendFactor_Force32 = 0x7FFFFFFF,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Robust.Client.Interop.RobustNative.Webgpu;
|
||||
|
||||
internal enum WGPUBlendOperation
|
||||
{
|
||||
WGPUBlendOperation_Undefined = 0x00000000,
|
||||
WGPUBlendOperation_Add = 0x00000001,
|
||||
WGPUBlendOperation_Subtract = 0x00000002,
|
||||
WGPUBlendOperation_ReverseSubtract = 0x00000003,
|
||||
WGPUBlendOperation_Min = 0x00000004,
|
||||
WGPUBlendOperation_Max = 0x00000005,
|
||||
WGPUBlendOperation_Force32 = 0x7FFFFFFF,
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user