Skip to content

Commit

Permalink
Don't dump shaders by default in "developer" workspaces
Browse files Browse the repository at this point in the history
This would show up in *other* people's developer workspaces,
which is very noisy and disruptive.

Instead, add the Java property `sodium.debug.shaders.dump`,
which can be configured via Java runtime arguments.
  • Loading branch information
jellysquid3 committed Jan 26, 2025
1 parent 214b0ad commit 194cb11
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.caffeinemc.mods.sodium.client.gl.shader;

import com.google.common.base.Objects;
import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation;
import org.apache.commons.io.IOUtils;

Expand All @@ -13,6 +14,9 @@
public class ShaderLoader {
private static final Logger LOGGER = LoggerFactory.getLogger("Sodium-ShaderLoader");

private static final boolean OPTION_DEBUG_SHADERS =
Objects.equal(System.getProperty("sodium.debug.shaders.dump", "false"), "true");

/**
* Creates an OpenGL shader from GLSL sources. The GLSL source file should be made available on the classpath at the
* path of `/assets/{namespace}/shaders/{path}`. User defines can be used to declare variables in the shader source
Expand All @@ -25,10 +29,12 @@ public class ShaderLoader {
*/
public static GlShader loadShader(ShaderType type, ResourceLocation name, ShaderConstants constants) {
var parsedShader = ShaderParser.parseShader(getShaderSource(name), constants);
if (PlatformRuntimeInformation.INSTANCE.isDevelopmentEnvironment()) {

if (OPTION_DEBUG_SHADERS) {
LOGGER.info("Loaded shader {} with constants {}", name, constants);
LOGGER.info(parsedShader.src());
}

return new GlShader(type, name, parsedShader);
}

Expand Down

0 comments on commit 194cb11

Please sign in to comment.