Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace custom library load with net8 NativeLibrary #6

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions RenderDocGen/Evergine.Bindings.RenderDoc/Kernel32.cs

This file was deleted.

21 changes: 0 additions & 21 deletions RenderDocGen/Evergine.Bindings.RenderDoc/Libdl.cs

This file was deleted.

112 changes: 0 additions & 112 deletions RenderDocGen/Evergine.Bindings.RenderDoc/NativeLibrary.cs

This file was deleted.

23 changes: 10 additions & 13 deletions RenderDocGen/Evergine.Bindings.RenderDoc/RenderDoc.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using System.Net;

namespace Evergine.Bindings.RenderDoc
{
Expand All @@ -24,22 +21,22 @@ public unsafe class RenderDoc
/// <returns>Whether RenderDoc was successfully loaded.</returns>
public static bool Load(out RenderDoc renderDoc)
{
try
var libName = GetRenderDocLibName();
if (NativeLibrary.TryLoad(libName, out var lib) ||
NativeLibrary.TryLoad(libName, typeof(RenderDoc).Assembly, null, out lib))
{
var nativeLib = NativeLibrary.Load(GetRenderDocLibName());
renderDoc = new RenderDoc(nativeLib);
renderDoc = new RenderDoc(lib);
return true;
}
catch
{
renderDoc = null;
return false;
}

renderDoc = null;
return false;
}

private unsafe RenderDoc(NativeLibrary nativeLib)
private unsafe RenderDoc(IntPtr nativeLib)
{
nativeLib.LoadFunction("RENDERDOC_GetAPI", out pRENDERDOC_GetAPI getApiDelegate);
NativeLibrary.TryGetExport(nativeLib, "RENDERDOC_GetAPI", out IntPtr funcPtr);
var getApiDelegate = Marshal.GetDelegateForFunctionPointer<pRENDERDOC_GetAPI>(funcPtr);
void* apiPointers;
int result = getApiDelegate(RENDERDOC_Version.eRENDERDOC_API_Version_1_4_1, &apiPointers);
if (result != 1)
Expand Down