Skip to content

Commit

Permalink
replace custom library load with net8 NativeLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcaceresm committed Sep 11, 2024
1 parent 164d653 commit 8046cfb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 165 deletions.
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

0 comments on commit 8046cfb

Please sign in to comment.