-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
Common/src/main/java/dev/upcraft/sparkweave/api/logging/SparkweaveLoggerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Common/src/main/java/dev/upcraft/sparkweave/client/render/RenderDocHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package dev.upcraft.sparkweave.client.render; | ||
|
||
import dev.upcraft.sparkweave.api.SparkweaveApi; | ||
import dev.upcraft.sparkweave.logging.SparkweaveLogging; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class RenderDocHelper { | ||
|
||
private static final Logger LOGGER = SparkweaveLogging.getLogger(); | ||
|
||
public static void init() { | ||
if(SparkweaveApi.Client.LOAD_RENDERDOC) { | ||
var libraryPath = System.getProperty("java.library.path"); | ||
|
||
var rdHome = System.getenv("RENDERDOC_HOME"); | ||
if(rdHome != null) { | ||
LOGGER.debug("appending RENDERDOC_HOME to native library path"); | ||
libraryPath += File.pathSeparatorChar + rdHome; | ||
System.setProperty("java.library.path", libraryPath); | ||
} | ||
|
||
var libraryName = System.mapLibraryName("renderdoc"); | ||
|
||
var loaded = false; | ||
for(var dir : libraryPath.split(File.pathSeparator)) { | ||
try { | ||
var searchPath = Path.of(dir, libraryName).toAbsolutePath(); | ||
if(Files.exists(searchPath)) { | ||
LOGGER.debug("Attempting to load RenderDoc from {}", searchPath); | ||
System.load(searchPath.toString()); | ||
loaded = true; | ||
break; | ||
} | ||
} catch (SecurityException | UnsatisfiedLinkError e) { | ||
LOGGER.error("unable to load RenderDoc library", e); | ||
break; | ||
} | ||
} | ||
|
||
if(!loaded) { | ||
LOGGER.warn("RenderDoc not found or unable to load"); | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Common/src/main/java/dev/upcraft/sparkweave/mixin/client/MainMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.upcraft.sparkweave.mixin.client; | ||
|
||
import dev.upcraft.sparkweave.client.render.RenderDocHelper; | ||
import net.minecraft.client.main.Main; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(Main.class) | ||
public class MainMixin { | ||
|
||
@Inject(method = "main", at = @At("HEAD"), remap = false) | ||
private static void loadRenderdoc(String[] args, CallbackInfo ci) { | ||
RenderDocHelper.init(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"mixins": [ | ||
], | ||
"client": [ | ||
"client.MainMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
|