mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-03-04 06:34:40 +01:00
Intelligent priorities
- Rank indirect very low on intel drivers
This commit is contained in:
parent
7ec8a870bd
commit
9975833650
2 changed files with 23 additions and 5 deletions
|
@ -7,6 +7,7 @@ import dev.engine_room.flywheel.backend.compile.InstancingPrograms;
|
|||
import dev.engine_room.flywheel.backend.engine.EngineImpl;
|
||||
import dev.engine_room.flywheel.backend.engine.indirect.IndirectDrawManager;
|
||||
import dev.engine_room.flywheel.backend.engine.instancing.InstancedDrawManager;
|
||||
import dev.engine_room.flywheel.backend.gl.Driver;
|
||||
import dev.engine_room.flywheel.backend.gl.GlCompat;
|
||||
import dev.engine_room.flywheel.lib.backend.SimpleBackend;
|
||||
import dev.engine_room.flywheel.lib.util.ShadersModHelper;
|
||||
|
@ -26,7 +27,16 @@ public final class Backends {
|
|||
*/
|
||||
public static final Backend INDIRECT = SimpleBackend.builder()
|
||||
.engineFactory(level -> new EngineImpl(level, new IndirectDrawManager(IndirectPrograms.get()), 256))
|
||||
.priority(1000)
|
||||
.priority(() -> {
|
||||
// Read from GlCompat in these provider because loading GlCompat
|
||||
// at the same time the backends are registered causes GlCapabilities to be null.
|
||||
if (GlCompat.DRIVER == Driver.INTEL) {
|
||||
// Intel has very poor performance with indirect rendering, and on top of that has graphics bugs
|
||||
return 1;
|
||||
} else {
|
||||
return 1000;
|
||||
}
|
||||
})
|
||||
.supported(() -> GlCompat.SUPPORTS_INDIRECT && IndirectPrograms.allLoaded() && !ShadersModHelper.isShaderPackInUse())
|
||||
.register(Flywheel.rl("indirect"));
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
|
||||
public final class SimpleBackend implements Backend {
|
||||
private final Function<LevelAccessor, Engine> engineFactory;
|
||||
private final int priority;
|
||||
private final PriorityProvider priority;
|
||||
private final BooleanSupplier isSupported;
|
||||
|
||||
public SimpleBackend(int priority, Function<LevelAccessor, Engine> engineFactory, BooleanSupplier isSupported) {
|
||||
public SimpleBackend(PriorityProvider priority, Function<LevelAccessor, Engine> engineFactory, BooleanSupplier isSupported) {
|
||||
this.priority = priority;
|
||||
this.engineFactory = engineFactory;
|
||||
this.isSupported = isSupported;
|
||||
|
@ -31,7 +31,7 @@ public final class SimpleBackend implements Backend {
|
|||
|
||||
@Override
|
||||
public int priority() {
|
||||
return priority;
|
||||
return priority.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,9 +39,13 @@ public final class SimpleBackend implements Backend {
|
|||
return isSupported.getAsBoolean();
|
||||
}
|
||||
|
||||
public interface PriorityProvider {
|
||||
int get();
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private Function<LevelAccessor, Engine> engineFactory;
|
||||
private int priority = 0;
|
||||
private PriorityProvider priority = () -> 0;
|
||||
private BooleanSupplier isSupported;
|
||||
|
||||
public Builder engineFactory(Function<LevelAccessor, Engine> engineFactory) {
|
||||
|
@ -50,6 +54,10 @@ public final class SimpleBackend implements Backend {
|
|||
}
|
||||
|
||||
public Builder priority(int priority) {
|
||||
return priority(() -> priority);
|
||||
}
|
||||
|
||||
public Builder priority(PriorityProvider priority) {
|
||||
this.priority = priority;
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue