Skip to content

Commit

Permalink
try to load librenderdoc using LWJGL bindings first before passing on…
Browse files Browse the repository at this point in the history
…to JNA to mitigate JNA's incorrect handling of RTLD_NOLOAD
  • Loading branch information
gliscowo committed Dec 9, 2023
1 parent 1c2ea70 commit f2f021b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.0
# Mod Properties
mod_version=0.12.0-pre.1
mod_version=0.12.0-pre.2
maven_group=io.wispforest
archives_base_name=owo-lib
# Dependencies
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/io/wispforest/owo/renderdoc/RenderDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.system.linux.DynamicLinkLoader;

import java.time.Instant;
import java.util.Arrays;
Expand All @@ -38,7 +39,12 @@ private RenderDoc() {}
if (os == Util.OperatingSystem.WINDOWS) {
renderdocLibrary = Native.load("renderdoc", RenderdocLibrary.class);
} else {
renderdocLibrary = Native.load("renderdoc", RenderdocLibrary.class, Map.of(Library.OPTION_OPEN_FLAGS, 0x2 | 0x4));
int flags = DynamicLinkLoader.RTLD_NOW | DynamicLinkLoader.RTLD_NOLOAD;
if (DynamicLinkLoader.dlopen("librenderdoc.so", flags) == 0) {
throw new UnsatisfiedLinkError();
}

renderdocLibrary = Native.load("renderdoc", RenderdocLibrary.class, Map.of(Library.OPTION_OPEN_FLAGS, flags));
}

int initResult = renderdocLibrary.RENDERDOC_GetAPI(10500, apiPointer);
Expand All @@ -53,8 +59,7 @@ private RenderDoc() {}
apiInstance.GetAPIVersion.call(major, minor, patch);
Owo.LOGGER.info("Connected to RenderDoc API v" + major.getValue() + "." + minor.getValue() + "." + patch.getValue());
}
} catch (UnsatisfiedLinkError ignored) {
}
} catch (UnsatisfiedLinkError ignored) {}
}

renderdoc = apiInstance;
Expand Down

0 comments on commit f2f021b

Please sign in to comment.