mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-10 12:34:11 +01:00
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:
parent
d23b88d462
commit
6ed59fb877
@ -7,6 +7,9 @@ Technical/API
|
||||
- Deprecate instance registration functions in favor of builders
|
||||
- Refactor breaking overlay renderer to be cleaner and more contained
|
||||
- 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:
|
||||
Fixes
|
||||
|
@ -44,7 +44,16 @@ public abstract class ShaderContext<P extends GlProgram> implements IShaderConte
|
||||
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) {
|
||||
@ -52,7 +61,7 @@ public abstract class ShaderContext<P extends GlProgram> implements IShaderConte
|
||||
}
|
||||
|
||||
protected Program link(Program program) {
|
||||
return program.link();
|
||||
return program.link().deleteLinkedShaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,11 +11,16 @@ import static org.lwjgl.opengl.GL20.glLinkProgram;
|
||||
|
||||
import java.util.EnumMap;
|
||||
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.gl.shader.GlShader;
|
||||
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;
|
||||
|
||||
public class Program {
|
||||
@ -26,10 +31,13 @@ public class Program {
|
||||
|
||||
public final Map<ShaderType, Shader> attached;
|
||||
|
||||
private final IntList shaders;
|
||||
|
||||
public Program(ResourceLocation name) {
|
||||
this.name = name;
|
||||
this.program = glCreateProgram();
|
||||
attached = new EnumMap<>(ShaderType.class);
|
||||
shaders = new IntArrayList(2);
|
||||
}
|
||||
|
||||
public Program attachShader(Shader shader, GlShader glShader) {
|
||||
@ -66,4 +74,9 @@ public class Program {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Program deleteLinkedShaders() {
|
||||
shaders.forEach((IntConsumer) GL20::glDeleteShader);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.jozufozu.flywheel.core.shader.spec;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.util.CodecUtil;
|
||||
@ -55,4 +56,9 @@ public class ProgramState {
|
||||
public List<IProgramExtension> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProgramState{" + "gameState=" + context.getID() + ", defines=" + defines + ", extensions=" + extensions.stream().map(IProgramExtension::getID).collect(Collectors.toList()) + '}';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user