Hacky program link debug info

- Log which gl ids are assigned to different programs
 - Log name and basic state information
This commit is contained in:
Jozufozu 2021-07-13 15:57:14 -07:00
parent d23b88d462
commit 6ed59fb877
4 changed files with 33 additions and 2 deletions

View File

@ -7,6 +7,9 @@ Technical/API
- Deprecate instance registration functions in favor of builders - Deprecate instance registration functions in favor of builders
- Refactor breaking overlay renderer to be cleaner and more contained - Refactor breaking overlay renderer to be cleaner and more contained
- Move per-world material managers out of WorldContext into InstancedRenderDispatcher - Move per-world material managers out of WorldContext into InstancedRenderDispatcher
- Add helper for getting information about texture atlases
- Add more debug information for shader loading
- Delete shaders after they're linked to programs
0.1.0: 0.1.0:
Fixes Fixes

View File

@ -44,7 +44,16 @@ public abstract class ShaderContext<P extends GlProgram> implements IShaderConte
fragmentFile.defineAll(state.getDefines()); fragmentFile.defineAll(state.getDefines());
} }
return link(buildProgram(spec.name, vertexFile, fragmentFile)); Program linked = link(buildProgram(spec.name, vertexFile, fragmentFile));
String descriptor = linked.program + ": " + spec.name;
if (state != null)
descriptor += "#" + state;
Backend.log.debug(descriptor);
return linked;
} }
protected Shader getSource(ShaderType type, ResourceLocation name) { protected Shader getSource(ShaderType type, ResourceLocation name) {
@ -52,7 +61,7 @@ public abstract class ShaderContext<P extends GlProgram> implements IShaderConte
} }
protected Program link(Program program) { protected Program link(Program program) {
return program.link(); return program.link().deleteLinkedShaders();
} }
@Override @Override

View File

@ -11,11 +11,16 @@ import static org.lwjgl.opengl.GL20.glLinkProgram;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Map; import java.util.Map;
import java.util.function.IntConsumer;
import org.lwjgl.opengl.GL20;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.gl.shader.GlShader; import com.jozufozu.flywheel.backend.gl.shader.GlShader;
import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class Program { public class Program {
@ -26,10 +31,13 @@ public class Program {
public final Map<ShaderType, Shader> attached; public final Map<ShaderType, Shader> attached;
private final IntList shaders;
public Program(ResourceLocation name) { public Program(ResourceLocation name) {
this.name = name; this.name = name;
this.program = glCreateProgram(); this.program = glCreateProgram();
attached = new EnumMap<>(ShaderType.class); attached = new EnumMap<>(ShaderType.class);
shaders = new IntArrayList(2);
} }
public Program attachShader(Shader shader, GlShader glShader) { public Program attachShader(Shader shader, GlShader glShader) {
@ -66,4 +74,9 @@ public class Program {
return this; return this;
} }
public Program deleteLinkedShaders() {
shaders.forEach((IntConsumer) GL20::glDeleteShader);
return this;
}
} }

View File

@ -2,6 +2,7 @@ package com.jozufozu.flywheel.core.shader.spec;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension; import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
import com.jozufozu.flywheel.util.CodecUtil; import com.jozufozu.flywheel.util.CodecUtil;
@ -55,4 +56,9 @@ public class ProgramState {
public List<IProgramExtension> getExtensions() { public List<IProgramExtension> getExtensions() {
return extensions; return extensions;
} }
@Override
public String toString() {
return "ProgramState{" + "gameState=" + context.getID() + ", defines=" + defines + ", extensions=" + extensions.stream().map(IProgramExtension::getID).collect(Collectors.toList()) + '}';
}
} }