Flywheel/src/main/java/com/jozufozu/flywheel/backend/Backends.java
Jozufozu 19824e7a3c Apply directly to the buffer
- Add DSA abstraction to GlBuffer
- Move backing impls to their respective classes
- Remove versioned package, move impls to appropriate package
- Make fallback methods take no arguments
- Do VAO check/bind in GlStateTracker
- GlVertexArray actually checks the tracked info when binding attributes
- Add separate enable* and setup* methods in VertexArray
- Add support for DSA VAO with ARB instanced arrays incase there are
  some particularly cursed drivers out there
- Misc. cleanup
2023-05-01 23:43:01 -07:00

50 lines
2.1 KiB
Java

package com.jozufozu.flywheel.backend;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.backend.Backend;
import com.jozufozu.flywheel.backend.compile.IndirectPrograms;
import com.jozufozu.flywheel.backend.compile.InstancingPrograms;
import com.jozufozu.flywheel.backend.engine.batching.BatchingEngine;
import com.jozufozu.flywheel.backend.engine.indirect.IndirectEngine;
import com.jozufozu.flywheel.backend.engine.instancing.InstancingEngine;
import com.jozufozu.flywheel.gl.GlCompat;
import com.jozufozu.flywheel.lib.backend.SimpleBackend;
import com.jozufozu.flywheel.lib.context.Contexts;
import com.jozufozu.flywheel.lib.util.ShadersModHandler;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TextComponent;
public class Backends {
/**
* Use a thread pool to buffer instances in parallel on the CPU.
*/
public static final Backend BATCHING = SimpleBackend.builder()
.engineMessage(new TextComponent("Using Batching Engine").withStyle(ChatFormatting.GREEN))
.engineFactory(level -> new BatchingEngine(256))
.supported(() -> !ShadersModHandler.isShaderPackInUse())
.register(Flywheel.rl("batching"));
/**
* Use GPU instancing to render everything.
*/
public static final Backend INSTANCING = SimpleBackend.builder()
.engineMessage(new TextComponent("Using Instancing Engine").withStyle(ChatFormatting.GREEN))
.engineFactory(level -> new InstancingEngine(256, Contexts.WORLD))
.fallback(() -> Backends.BATCHING)
.supported(() -> !ShadersModHandler.isShaderPackInUse() && GlCompat.supportsInstancing() && InstancingPrograms.allLoaded())
.register(Flywheel.rl("instancing"));
/**
* Use Compute shaders to cull instances.
*/
public static final Backend INDIRECT = SimpleBackend.builder()
.engineMessage(new TextComponent("Using Indirect Engine").withStyle(ChatFormatting.GREEN))
.engineFactory(level -> new IndirectEngine(256))
.fallback(() -> Backends.INSTANCING)
.supported(() -> !ShadersModHandler.isShaderPackInUse() && GlCompat.supportsIndirect() && IndirectPrograms.allLoaded())
.register(Flywheel.rl("indirect"));
public static void init() {
}
}