small performance gains
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
90e9492c18
commit
cb3ccbef0b
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Tue May 20 18:51:57 EDT 2025
|
||||
buildNumber=629
|
||||
#Thu May 22 18:46:40 EDT 2025
|
||||
buildNumber=630
|
||||
|
||||
@ -1937,6 +1937,8 @@ Debug view of entity colliders
|
||||
Fix lookup bug in debug physics ui
|
||||
Floating point starting to play nice with engine
|
||||
Fix geom-body collision sending wrong vector to body
|
||||
Per-mesh draw calls in batched static draw calls
|
||||
Main content pipeline tracking
|
||||
|
||||
|
||||
|
||||
|
||||
@ -31,6 +31,9 @@ public class ImGuiRenderer {
|
||||
shadowMapPipeline.setFarPlane(farPlaneArr[0]);
|
||||
}
|
||||
}
|
||||
if(ImGui.collapsingHeader("Main Content Pipeline")){
|
||||
ImGui.textWrapped(Globals.renderingEngine.getMainContentPipeline().getTrackingInfo());
|
||||
}
|
||||
if(ImGui.collapsingHeader("Post Processing Pipeline")){
|
||||
PostProcessingPipeline postProcessingPipeline = Globals.renderingEngine.getPostProcessingPipeline();
|
||||
if(ImGui.button("Toggle Blur")){
|
||||
|
||||
@ -27,4 +27,13 @@ public class DrawableUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity has a unique model
|
||||
* @param entity The entity
|
||||
* @return true if it has a unique model, false otherwise
|
||||
*/
|
||||
public static boolean hasUniqueModel(Entity entity){
|
||||
return entity.containsKey(EntityDataStrings.HAS_UNIQUE_MODEL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -304,6 +304,25 @@ public class Model {
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a specific mesh
|
||||
* @param i The index of the mesh
|
||||
*/
|
||||
public void drawMesh(RenderPipelineState renderPipelineState, OpenGLState openGLState, int i){
|
||||
if(i < 0 || i >= this.meshes.size()){
|
||||
throw new Error("Invalid mesh! " + i);
|
||||
}
|
||||
this.meshes.get(i).complexDraw(renderPipelineState, openGLState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of meshes in the model
|
||||
* @return The number of meshes
|
||||
*/
|
||||
public int getMeshCount(){
|
||||
return this.meshes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the correct shader to use for a given mesh
|
||||
* @param shaderMask The shader mask
|
||||
|
||||
@ -44,9 +44,15 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
*/
|
||||
private List<Entity> standardDrawCall = new LinkedList<Entity>();
|
||||
|
||||
/**
|
||||
* Number of terrain chunks rendered
|
||||
*/
|
||||
private int terrainChunks = 0;
|
||||
|
||||
@Override
|
||||
public void render(OpenGLState openGLState, RenderPipelineState renderPipelineState) {
|
||||
Globals.profiler.beginCpuSample("MainContentPipeline.render");
|
||||
this.clearTrackingData();
|
||||
|
||||
Matrix4d modelTransformMatrix = new Matrix4d();
|
||||
|
||||
@ -107,6 +113,11 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
currentActor.applySpatialData(new Matrix4d(modelTransformMatrix),new Vector3d(position));
|
||||
//draw
|
||||
currentActor.draw(renderPipelineState,openGLState);
|
||||
|
||||
//tracking
|
||||
if(currentEntity.containsKey(EntityDataStrings.TERRAIN_IS_TERRAIN)){
|
||||
this.terrainChunks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(ModelAccumulatorData accumulator : this.drawTargetAccumulator.getCalls()){
|
||||
@ -116,12 +127,14 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
List<Matrix4d> transforms = accumulator.getTransforms();
|
||||
List<Vector3d> positions = accumulator.getPositions();
|
||||
model.setMeshMask(null);
|
||||
for(int i = 0; i < count; i++){
|
||||
Vector3d position = positions.get(i);
|
||||
Matrix4d transform = transforms.get(i);
|
||||
model.setWorldPos(position);
|
||||
model.setModelMatrix(transform);
|
||||
model.draw(renderPipelineState, openGLState);
|
||||
for(int meshIndex = 0; meshIndex < model.getMeshCount(); meshIndex++){
|
||||
for(int i = 0; i < count; i++){
|
||||
Vector3d position = positions.get(i);
|
||||
Matrix4d transform = transforms.get(i);
|
||||
model.setWorldPos(position);
|
||||
model.setModelMatrix(transform);
|
||||
model.drawMesh(renderPipelineState, openGLState, meshIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,6 +340,13 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the tracking data
|
||||
*/
|
||||
private void clearTrackingData(){
|
||||
this.terrainChunks = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first person pipeline
|
||||
* @param firstPersonItemsPipeline the first person pipeline
|
||||
@ -351,4 +371,18 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
return standardDrawCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tracking info
|
||||
* @return The tracking info
|
||||
*/
|
||||
public String getTrackingInfo(){
|
||||
String message = "" +
|
||||
"Terrain entities:" + this.terrainChunks + "\n" +
|
||||
"";
|
||||
for(DrawTargetAccumulator.ModelAccumulatorData data : this.drawTargetAccumulator.getCalls()){
|
||||
message = message + data.getModelPath() + ": " + data.getCount() + "\n";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -147,12 +147,14 @@ public class ShadowMapPipeline implements RenderPipeline {
|
||||
List<Matrix4d> transforms = accumulator.getTransforms();
|
||||
List<Vector3d> positions = accumulator.getPositions();
|
||||
model.setMeshMask(null);
|
||||
for(int i = 0; i < count; i++){
|
||||
Vector3d position = positions.get(i);
|
||||
Matrix4d transform = transforms.get(i);
|
||||
model.setWorldPos(position);
|
||||
model.setModelMatrix(transform);
|
||||
model.draw(renderPipelineState, openGLState);
|
||||
for(int meshIndex = 0; meshIndex < model.getMeshCount(); meshIndex++){
|
||||
for(int i = 0; i < count; i++){
|
||||
Vector3d position = positions.get(i);
|
||||
Matrix4d transform = transforms.get(i);
|
||||
model.setWorldPos(position);
|
||||
model.setModelMatrix(transform);
|
||||
model.drawMesh(renderPipelineState, openGLState, meshIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.DrawableUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
@ -23,6 +24,7 @@ public class DrawTargetEvaluator {
|
||||
* Evaluates the draw targets
|
||||
*/
|
||||
public static void evaluate(){
|
||||
Globals.profiler.beginCpuSample("DrawTargetEvaluator.evaluate");
|
||||
//main content pipeline structures
|
||||
DrawTargetAccumulator mainAccumulator = Globals.renderingEngine.getMainContentPipeline().getDrawTargetAccumulator();
|
||||
List<Entity> mainQueue = Globals.renderingEngine.getMainContentPipeline().getStandardEntityQueue();
|
||||
@ -52,7 +54,7 @@ public class DrawTargetEvaluator {
|
||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||
//fetch actor
|
||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||
if(currentActor.isStaticDrawCall()){
|
||||
if(!DrawableUtils.hasUniqueModel(currentEntity) && currentActor.isStaticDrawCall()){
|
||||
//calculate camera-modified vector3d
|
||||
Vector3d cameraModifiedPosition = positionVec.set(position).sub(cameraCenter);
|
||||
//calculate and apply model transform
|
||||
@ -106,6 +108,8 @@ public class DrawTargetEvaluator {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user