Skip to content

Commit

Permalink
Literally unusable
Browse files Browse the repository at this point in the history
- Trim out dead light code from *EmbeddedEnvironment
- Fix indirect never deleting empty culling groups
- Fix embedded transforms not being applied
  • Loading branch information
Jozufozu committed Jul 13, 2024
1 parent b2686db commit 22aefa3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public void flush() {

@Override
public void setupDraw(GlProgram program) {
setupLight(program);

program.setMat4(EmbeddingUniforms.MODEL_MATRIX, poseComposed);
program.setMat3(EmbeddingUniforms.NORMAL_MATRIX, normalComposed);
}
Expand Down Expand Up @@ -109,7 +107,5 @@ public void delete() {
deleted = true;
}

public abstract void setupLight(GlProgram program);

public abstract void composeMatrices(Matrix4f pose, Matrix3f normal);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import dev.engine_room.flywheel.api.event.RenderStage;
import dev.engine_room.flywheel.backend.engine.EngineImpl;
import dev.engine_room.flywheel.backend.gl.shader.GlProgram;
import it.unimi.dsi.fastutil.longs.LongSet;

public class NestedEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
Expand All @@ -21,11 +20,6 @@ public void lightChunks(LongSet chunks) {
// noop
}

@Override
public void setupLight(GlProgram program) {
parent.setupLight(program);
}

@Override
public void composeMatrices(Matrix4f pose, Matrix3f normal) {
parent.composeMatrices(pose, normal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import dev.engine_room.flywheel.api.event.RenderStage;
import dev.engine_room.flywheel.backend.engine.EngineImpl;
import dev.engine_room.flywheel.backend.gl.shader.GlProgram;
import it.unimi.dsi.fastutil.longs.LongArraySet;
import it.unimi.dsi.fastutil.longs.LongSet;

Expand All @@ -27,11 +26,6 @@ public void addLightSections(LongSet out) {
out.addAll(lightSections);
}

@Override
public void setupLight(GlProgram program) {
program.setBool(EmbeddingUniforms.USE_LIGHT_VOLUME, !lightSections.isEmpty());
}

@Override
public void composeMatrices(Matrix4f pose, Matrix3f normal) {
pose.set(this.pose);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ public void delete() {
buffers.delete();
}

public boolean checkEmptyAndDelete() {
var out = indirectDraws.isEmpty();

if (out) {
delete();
}

return out;
}

private record MultiDraw(Material material, int start, int end) {
private void submit() {
if (GlCompat.DRIVER == Driver.INTEL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ public void flush(LightStorage lightStorage) {
group.flushInstancers();
}

instancers.values().removeIf(instancer -> instancer.instanceCount() == 0);
cullingGroups.values()
.removeIf(IndirectCullingGroup::checkEmptyAndDelete);

instancers.values()
.removeIf(instancer -> instancer.instanceCount() == 0);

meshPool.flush();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public InstancedDrawManager(InstancingPrograms programs) {
public void flush(LightStorage lightStorage) {
super.flush(lightStorage);

var instancers = this.instancers.values();
instancers.removeIf(instancer -> {
this.instancers.values()
.removeIf(instancer -> {
// Update the instancers and remove any that are empty.
instancer.update();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ vec2 getCrumblingTexCoord() {
}
#endif

#ifdef _FLW_EMBEDDED
#ifdef FLW_EMBEDDED
uniform mat4 _flw_modelMatrix;
uniform mat3 _flw_normalMatrix;
#endif
Expand All @@ -82,7 +82,7 @@ void _flw_main(in FlwInstance instance, in uint stableInstanceID) {
_flw_crumblingTexCoord = getCrumblingTexCoord();
#endif

#ifdef _FLW_EMBEDDED
#ifdef FLW_EMBEDDED
flw_vertexPos = _flw_modelMatrix * flw_vertexPos;
flw_vertexNormal = _flw_normalMatrix * flw_vertexNormal;
#endif
Expand Down

0 comments on commit 22aefa3

Please sign in to comment.