Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-load…
Browse files Browse the repository at this point in the history
…er-1.21

# Conflicts:
#	common/src/lib/java/dev/engine_room/flywheel/lib/util/ShadersModHandler.java
#	common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java
#	common/src/main/java/dev/engine_room/flywheel/impl/compat/SodiumCompat.java
#	common/src/main/java/dev/engine_room/flywheel/impl/mixin/BlockEntityTypeMixin.java
#	fabric/build.gradle.kts
#	fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java
#	fabric/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java
#	fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/sodium/ChunkBuilderMeshingTaskMixin.java
#	fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/sodium/SodiumMixinPlugin.java
#	fabric/src/main/resources/fabric.mod.json
#	forge/build.gradle.kts
#	forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java
#	forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java
#	forge/src/main/java/dev/engine_room/flywheel/impl/FlywheelForge.java
#	forge/src/main/resources/META-INF/neoforge.mods.toml
#	gradle.properties
#	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information
IThundxr committed Oct 29, 2024
2 parents 68d1504 + 3a949c7 commit 07e66bb
Show file tree
Hide file tree
Showing 35 changed files with 591 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@ open class PlatformExtension(val project: Project) {

var apiArtifactId: String = "flywheel-${project.name}-api-${project.property("artifact_minecraft_version")}"

private val sources = mutableSetOf<SourceSet>()
private val commonSourceSets: SourceSetContainer by lazy { commonProject.the<SourceSetContainer>() }

fun sources(vararg sourceSets: SourceSet) {
this.sources.addAll(sourceSets)
}

fun setupLoomMod() {
fun setupLoomMod(vararg sourceSets: SourceSet) {
project.the<LoomGradleExtensionAPI>().mods.maybeCreate("main").apply {
sources.forEach(::sourceSet)
sourceSets.forEach(::sourceSet)
}
}

Expand Down Expand Up @@ -61,13 +56,13 @@ open class PlatformExtension(val project: Project) {
}
}

fun compileWithCommonSourceSets() {
fun compileWithCommonSourceSets(vararg sourceSets: SourceSet) {
project.tasks.apply {
withType<JavaCompile>().configureEach {
JarTaskSet.excludeDuplicatePackageInfos(this)
}

sources.forEach {
sourceSets.forEach {
val commonSourceSet = commonSourceSets.named(it.name).get()

named<JavaCompile>(it.compileJavaTaskName).configure {
Expand All @@ -80,10 +75,10 @@ open class PlatformExtension(val project: Project) {
}
}

fun setupFatJar() {
fun setupFatJar(vararg sourceSets: SourceSet) {
project.tasks.apply {
val extraSourceSets = sources.filter { it.name != "main" }.toList()
val commonSources = sources.map { commonSourceSets.named(it.name).get() }
val extraSourceSets = sourceSets.filter { it.name != "main" }.toList()
val commonSources = sourceSets.map { commonSourceSets.named(it.name).get() }

named<Jar>("jar").configure {
extraSourceSets.forEach { from(it.output) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class TransitiveSourceSetsExtension(private val project: Project) {

fun createCompileConfigurations() {
val configs = transitives.mapValues { (sourceSet, _) ->
project.configurations.create("for${sourceSet.name.capitalize()}") {
project.configurations.create("for${sourceSet.name.replaceFirstChar { it.uppercase() }}") {
isCanBeConsumed = true
isCanBeResolved = false
}
Expand All @@ -43,7 +43,7 @@ open class TransitiveSourceSetsExtension(private val project: Project) {

fun createRuntimeConfigurations() {
val configs = transitives.mapValues { (sourceSet, _) ->
project.configurations.create("run${sourceSet.name.capitalize()}") {
project.configurations.create("run${sourceSet.name.replaceFirstChar { it.uppercase() }}") {
isCanBeConsumed = true
isCanBeResolved = false
}
Expand Down
7 changes: 6 additions & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
val api = sourceSets.create("api")
val lib = sourceSets.create("lib")
val backend = sourceSets.create("backend")
val stubs = sourceSets.create("stubs")
val main = sourceSets.getByName("main")

transitiveSourceSets {
Expand All @@ -25,8 +26,11 @@ transitiveSourceSets {
rootCompile()
compile(api, lib)
}
sourceSet(stubs) {
rootCompile()
}
sourceSet(main) {
compile(api, lib, backend)
compile(api, lib, backend, stubs)
}
sourceSet(sourceSets.getByName("test")) {
implementation(api, lib, backend)
Expand All @@ -42,6 +46,7 @@ jarSets {
outgoing("commonApiOnly", api)
outgoing("commonLib", lib)
outgoing("commonBackend", backend)
outgoing("commonStubs", stubs)
outgoing("commonImpl", main)

// For publishing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import dev.engine_room.flywheel.backend.engine.instancing.InstancedDrawManager;
import dev.engine_room.flywheel.backend.gl.GlCompat;
import dev.engine_room.flywheel.lib.backend.SimpleBackend;
import dev.engine_room.flywheel.lib.util.ShadersModHandler;
import dev.engine_room.flywheel.lib.util.ShadersModHelper;

public final class Backends {
/**
Expand All @@ -18,7 +18,7 @@ public final class Backends {
public static final Backend INSTANCING = SimpleBackend.builder()
.engineFactory(level -> new EngineImpl(level, new InstancedDrawManager(InstancingPrograms.get()), 256))
.priority(500)
.supported(() -> GlCompat.SUPPORTS_INSTANCING && InstancingPrograms.allLoaded() && !ShadersModHandler.isShaderPackInUse())
.supported(() -> GlCompat.SUPPORTS_INSTANCING && InstancingPrograms.allLoaded() && !ShadersModHelper.isShaderPackInUse())
.register(Flywheel.rl("instancing"));

/**
Expand All @@ -27,7 +27,7 @@ public final class Backends {
public static final Backend INDIRECT = SimpleBackend.builder()
.engineFactory(level -> new EngineImpl(level, new IndirectDrawManager(IndirectPrograms.get()), 256))
.priority(1000)
.supported(() -> GlCompat.SUPPORTS_INDIRECT && IndirectPrograms.allLoaded() && !ShadersModHandler.isShaderPackInUse())
.supported(() -> GlCompat.SUPPORTS_INDIRECT && IndirectPrograms.allLoaded() && !ShadersModHelper.isShaderPackInUse())
.register(Flywheel.rl("indirect"));

private Backends() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package dev.engine_room.flywheel.backend.compile;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;

import dev.engine_room.flywheel.api.Flywheel;
import dev.engine_room.flywheel.api.instance.InstanceType;
Expand Down Expand Up @@ -30,7 +33,7 @@
import net.minecraft.resources.ResourceLocation;

public final class PipelineCompiler {
private static final List<PipelineCompiler> ALL = List.of();
private static final Set<PipelineCompiler> ALL = Collections.newSetFromMap(new WeakHashMap<>());

private static final Compile<PipelineProgramKey> PIPELINE = new Compile<>();

Expand All @@ -44,6 +47,7 @@ public final class PipelineCompiler {

public PipelineCompiler(CompilationHarness<PipelineProgramKey> harness) {
this.harness = harness;
ALL.add(this);
}

public GlProgram get(InstanceType<?> instanceType, ContextShader contextShader, Material material) {
Expand All @@ -57,15 +61,12 @@ public GlProgram get(InstanceType<?> instanceType, ContextShader contextShader,
MaterialShaderIndices.fogSources()
.index(fog.source());

boolean useCutout = cutout != CutoutShaders.OFF;
// Same thing for cutout.
// Add OFF to the index here anyway to ensure MaterialEncoder doesn't deleteAll at an inappropriate time.
MaterialShaderIndices.cutoutSources()
.index(cutout.source());

if (useCutout) {
// Same thing for cutout.
MaterialShaderIndices.cutoutSources()
.index(cutout.source());
}

return harness.get(new PipelineProgramKey(instanceType, contextShader, light, shaders, useCutout, FrameUniforms.debugOn()));
return harness.get(new PipelineProgramKey(instanceType, contextShader, light, shaders, cutout != CutoutShaders.OFF, FrameUniforms.debugOn()));
}

public void delete() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ public interface FlwLibLink {
void compileModelPart(ModelPart part, PoseStack.Pose pose, VertexConsumer consumer, int light, int overlay, int color);

Deque<PoseStack.Pose> getPoseStack(PoseStack stack);

boolean isIrisLoaded();

boolean isOptifineInstalled();

boolean isShaderPackInUse();

boolean isRenderingShadowPass();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package dev.engine_room.flywheel.lib.internal;

import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;

import dev.engine_room.flywheel.api.internal.DependencyInjection;
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder;
import dev.engine_room.flywheel.lib.util.ShadersModHandler;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelManager;
Expand All @@ -29,7 +27,4 @@ public interface FlwLibXplat {
BlockModelBuilder createBlockModelBuilder(BlockState state);

MultiBlockModelBuilder createMultiBlockModelBuilder(BlockAndTintGetter level, Iterable<BlockPos> positions);

@Nullable
ShadersModHandler.InternalHandler createIrisHandler();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.engine_room.flywheel.api.Flywheel;
import dev.engine_room.flywheel.api.material.LightShader;

public class LightShaders {
public final class LightShaders {
public static final LightShader SMOOTH_WHEN_EMBEDDED = new SimpleLightShader(Flywheel.rl("light/smooth_when_embedded.glsl"));
public static final LightShader SMOOTH = new SimpleLightShader(Flywheel.rl("light/smooth.glsl"));
public static final LightShader FLAT = new SimpleLightShader(Flywheel.rl("light/flat.glsl"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public Builder copyFrom(Material material) {
shaders = material.shaders();
fog = material.fog();
cutout = material.cutout();
light = material.light();
texture = material.texture();
blur = material.blur();
mipmap = material.mipmap();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.engine_room.flywheel.lib.util;

import dev.engine_room.flywheel.lib.internal.FlwLibLink;

public final class ShadersModHelper {
public static final boolean IS_IRIS_LOADED = FlwLibLink.INSTANCE.isIrisLoaded();
public static final boolean IS_OPTIFINE_INSTALLED = FlwLibLink.INSTANCE.isOptifineInstalled();

private ShadersModHelper() {
}

public static boolean isShaderPackInUse() {
return FlwLibLink.INSTANCE.isShaderPackInUse();
}

public static boolean isRenderingShadowPass() {
return FlwLibLink.INSTANCE.isRenderingShadowPass();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import dev.engine_room.flywheel.api.Flywheel;
import dev.engine_room.flywheel.backend.FlwBackend;
import dev.engine_room.flywheel.impl.registry.IdRegistryImpl;
import dev.engine_room.flywheel.lib.util.ShadersModHandler;
import dev.engine_room.flywheel.vanilla.VanillaVisuals;

public final class FlwImpl {
Expand All @@ -21,7 +20,6 @@ public static void init() {
BackendManagerImpl.init();

// lib
ShadersModHandler.init();

// backend
FlwBackend.init(FlwConfig.INSTANCE.backendConfig());
Expand Down
Loading

0 comments on commit 07e66bb

Please sign in to comment.