remove framebuffer caching for debug
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
1dff7ecc28
commit
9443811a2c
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
@ -18,6 +18,14 @@
|
||||
"vmArgs": "-Xmx2G -Xms100m -XX:+UseZGC -XX:+UseDynamicNumberOfGCThreads -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"/tmp\"",
|
||||
"projectName": "Renderer"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Launch Main (Debug Memory)",
|
||||
"request": "launch",
|
||||
"mainClass": "electrosphere.engine.Main",
|
||||
"vmArgs": "-Xmx2G -Xms100m -XX:+UseZGC -XX:+UseDynamicNumberOfGCThreads -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"/tmp\" -javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log",
|
||||
"projectName": "Renderer"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Launch Main (Debug Audio)",
|
||||
|
||||
@ -102,7 +102,6 @@ import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.menu.debug.ImGuiWindowMacros;
|
||||
import electrosphere.menu.ingame.MenuGeneratorsInGame;
|
||||
import electrosphere.menu.ingame.MenuGeneratorsInventory;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.renderer.ui.elements.Window;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.KeyboardEvent;
|
||||
@ -1206,7 +1205,7 @@ public class ControlHandler {
|
||||
menuNavigationControlList.add(controls.get(MENU_CAPTURE_SCREEN));
|
||||
controls.get(MENU_CAPTURE_SCREEN).setOnPress(new Control.ControlMethod() {public void execute(){
|
||||
FileUtils.writeBufferedImage(
|
||||
RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState()),
|
||||
Globals.renderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState()),
|
||||
"Screenshots/" + System.currentTimeMillis() + ".png"
|
||||
);
|
||||
}});
|
||||
|
||||
@ -159,12 +159,12 @@ public class OpenGLState {
|
||||
* @param framebufferPointer the pointer to the framebuffer
|
||||
*/
|
||||
public void glBindFramebuffer(int framebufferType, int framebufferPointer){
|
||||
if(DISABLE_CACHING || this.framebufferType != framebufferType || this.framebufferPointer != framebufferPointer){
|
||||
// if(DISABLE_CACHING || this.framebufferType != framebufferType || this.framebufferPointer != framebufferPointer){
|
||||
this.framebufferType = framebufferType;
|
||||
this.framebufferPointer = framebufferPointer;
|
||||
GL40.glBindFramebuffer(this.framebufferType,this.framebufferPointer);
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -19,15 +19,7 @@ import org.joml.Vector3f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import static org.lwjgl.opengl.GL15.GL_ARRAY_BUFFER;
|
||||
import static org.lwjgl.opengl.GL15.GL_STATIC_DRAW;
|
||||
import static org.lwjgl.opengl.GL15.glBindBuffer;
|
||||
import static org.lwjgl.opengl.GL15.glGenBuffers;
|
||||
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
|
||||
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||
import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
|
||||
/**
|
||||
* Utilities to assist with rendering
|
||||
@ -37,8 +29,8 @@ public class RenderUtils {
|
||||
|
||||
|
||||
static int createScreenTextureVAO(){
|
||||
int rVal = glGenVertexArrays();
|
||||
glBindVertexArray(rVal);
|
||||
int rVal = GL40.glGenVertexArrays();
|
||||
GL40.glBindVertexArray(rVal);
|
||||
//vertices
|
||||
FloatBuffer vertexArrayBufferData = BufferUtils.createFloatBuffer(12);
|
||||
vertexArrayBufferData.put(-1.0f);
|
||||
@ -59,11 +51,11 @@ public class RenderUtils {
|
||||
vertexArrayBufferData.put( 1.0f);
|
||||
vertexArrayBufferData.put( 1.0f);
|
||||
vertexArrayBufferData.flip();
|
||||
int vertexBuffer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
||||
GL15.glBufferData(GL_ARRAY_BUFFER, vertexArrayBufferData, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
|
||||
glEnableVertexAttribArray(0);
|
||||
int vertexBuffer = GL40.glGenBuffers();
|
||||
GL40.glBindBuffer(GL40.GL_ARRAY_BUFFER, vertexBuffer);
|
||||
GL40.glBufferData(GL40.GL_ARRAY_BUFFER, vertexArrayBufferData, GL40.GL_STATIC_DRAW);
|
||||
GL40.glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
|
||||
GL40.glEnableVertexAttribArray(0);
|
||||
|
||||
|
||||
|
||||
@ -89,11 +81,11 @@ public class RenderUtils {
|
||||
textureArrayBufferData.put(1.0f);
|
||||
textureArrayBufferData.put(1.0f);
|
||||
textureArrayBufferData.flip();
|
||||
int textureCoordBuffer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, textureCoordBuffer);
|
||||
GL15.glBufferData(GL_ARRAY_BUFFER, textureArrayBufferData, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);
|
||||
glEnableVertexAttribArray(1);
|
||||
int textureCoordBuffer = GL40.glGenBuffers();
|
||||
GL40.glBindBuffer(GL40.GL_ARRAY_BUFFER, textureCoordBuffer);
|
||||
GL40.glBufferData(GL40.GL_ARRAY_BUFFER, textureArrayBufferData, GL40.GL_STATIC_DRAW);
|
||||
GL40.glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);
|
||||
GL40.glEnableVertexAttribArray(1);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
@ -215,7 +207,7 @@ public class RenderUtils {
|
||||
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
|
||||
|
||||
|
||||
@ -328,7 +320,7 @@ public class RenderUtils {
|
||||
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
|
||||
|
||||
|
||||
@ -423,7 +415,7 @@ public class RenderUtils {
|
||||
m.setShader(ShaderProgram.loadSpecificShader("/Shaders/font/basicbitmap/basicbitmap.vs", "/Shaders/font/basicbitmap/basicbitmap.fs"));
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
m.setParent(rVal);
|
||||
|
||||
Material uiMat = new Material();
|
||||
@ -520,7 +512,7 @@ public class RenderUtils {
|
||||
m.setShader(ShaderProgram.loadSpecificShader("/Shaders/font/bitmapchar/bitmapchar.vs", "/Shaders/font/bitmapchar/bitmapchar.fs"));
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
m.setParent(rVal);
|
||||
|
||||
rVal.getMeshes().add(m);
|
||||
@ -604,7 +596,7 @@ public class RenderUtils {
|
||||
m.setShader(ShaderProgram.loadSpecificShader(vertexShader, fragmentShader));
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
m.setParent(rVal);
|
||||
|
||||
rVal.getMeshes().add(m);
|
||||
@ -774,7 +766,7 @@ public class RenderUtils {
|
||||
//texture indices
|
||||
m.bufferCustomFloatAttribArray(textureIndices, 4, 5);
|
||||
m.setShader(program);
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
m.setParent(rVal);
|
||||
|
||||
Material groundMat = new Material();
|
||||
@ -1334,7 +1326,7 @@ public class RenderUtils {
|
||||
//texture indices
|
||||
m.bufferCustomFloatAttribArray(textureIndices, 4, 5);
|
||||
m.setShader(program);
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
m.setParent(rVal);
|
||||
|
||||
Material groundMat = new Material();
|
||||
@ -1558,7 +1550,7 @@ public class RenderUtils {
|
||||
//buffer texture coords
|
||||
m.bufferTextureCoords(texture_coords, 2);
|
||||
m.setShader(ShaderProgram.smart_assemble_shader(false,true));
|
||||
glBindVertexArray(0);
|
||||
GL40.glBindVertexArray(0);
|
||||
m.setParent(rVal);
|
||||
|
||||
Material groundMat = new Material();
|
||||
|
||||
@ -116,7 +116,7 @@ public class RenderingEngine {
|
||||
public static int screenTextureVAO;
|
||||
public static ShaderProgram screenTextureShaders;
|
||||
public static ShaderProgram drawChannel;
|
||||
public static Framebuffer defaultFramebuffer;
|
||||
public Framebuffer defaultFramebuffer;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ public class Framebuffer {
|
||||
* Creates a framebuffer
|
||||
*/
|
||||
public Framebuffer(){
|
||||
framebufferPointer = GL40.glGenFramebuffers();
|
||||
this.framebufferPointer = GL40.glGenFramebuffers();
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ public class Framebuffer {
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, this.framebufferPointer);
|
||||
GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_COLOR_ATTACHMENT0 + attachmentNum, GL40.GL_TEXTURE_2D, texture.getTexturePointer(), 0);
|
||||
Globals.renderingEngine.checkError();
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,7 +226,7 @@ public class Framebuffer {
|
||||
this.depthTexture = depthTexture;
|
||||
GL40.glFramebufferTexture2D(GL40.GL_FRAMEBUFFER, GL40.GL_DEPTH_ATTACHMENT, GL40.GL_TEXTURE_2D, depthTexture.getTexturePointer(), 0);
|
||||
Globals.renderingEngine.checkError();
|
||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER, 0);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -187,7 +187,7 @@ public class FramebufferUtils {
|
||||
//check make sure compiled
|
||||
buffer.checkStatus();
|
||||
//re-bind default buffer
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ public class CompositePipeline implements RenderPipeline {
|
||||
//Close down pipeline
|
||||
//
|
||||
GL40.glBindVertexArray(0);
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
|
||||
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
@ -209,7 +209,7 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
//
|
||||
// Reset State
|
||||
//
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ public class NormalsForOutlinePipeline implements RenderPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class PostProcessingPipeline implements RenderPipeline {
|
||||
GL40.glBindVertexArray(0);
|
||||
}
|
||||
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
Globals.renderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ import javax.imageio.ImageIO;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
|
||||
/**
|
||||
* Utilities for comparing renders
|
||||
@ -32,7 +31,7 @@ public class TestRenderingUtils {
|
||||
} catch (IOException e){
|
||||
fail("Failed to read existing image path " + existingRenderPath);
|
||||
}
|
||||
BufferedImage screenshot = RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||
BufferedImage screenshot = Globals.renderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||
//check basic data
|
||||
//
|
||||
//width
|
||||
@ -89,7 +88,7 @@ public class TestRenderingUtils {
|
||||
* @param existingRenderPath The filepath of the existing render
|
||||
*/
|
||||
public static void saveTestRender(String existingRenderPath){
|
||||
BufferedImage screenshot = RenderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||
BufferedImage screenshot = Globals.renderingEngine.defaultFramebuffer.getPixels(Globals.renderingEngine.getOpenGLState());
|
||||
try {
|
||||
ImageIO.write(screenshot, "png", new File(existingRenderPath));
|
||||
} catch (IOException e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user