Skip to content

Commit

Permalink
Fix registry freeze timing
Browse files Browse the repository at this point in the history
- Move registry freezing to right before start of initial resource reload
- Also warn if Fabric config JSON is not an object
- Move Flywheel.java to API
- Remove Flywheel.LOGGER and others; add impl-specific and backend-specific loggers
- Remove unused mixins
- Organize imports
  • Loading branch information
PepperCode1 authored and Jozufozu committed May 17, 2024
1 parent 6dff488 commit 914ce0a
Show file tree
Hide file tree
Showing 54 changed files with 147 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package com.jozufozu.gradle.platform

import com.jozufozu.gradle.jarset.JarTaskSet
import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RemapSourcesJarTask
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.withType
import org.gradle.language.jvm.tasks.ProcessResources
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.*
import org.gradle.language.jvm.tasks.ProcessResources


class SubprojectPlugin: Plugin<Project> {
override fun apply(project: Project) {
project.extensions.create("defaultPackageInfos", PackageInfosExtension::class.java, project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.the

open class TransitiveSourceSetsExtension(private val project: Project) {
var compileClasspath: FileCollection? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.jozufozu.flywheel;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.jozufozu.flywheel.api;

import net.minecraft.resources.ResourceLocation;

public final class Flywheel {
public static final String ID = "flywheel";
public static final Logger LOGGER = LoggerFactory.getLogger(ID);

private Flywheel() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.jozufozu.flywheel.backend;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.backend.Backend;
import com.jozufozu.flywheel.backend.compile.IndirectPrograms;
import com.jozufozu.flywheel.backend.compile.InstancingPrograms;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.jozufozu.flywheel.backend;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jozufozu.flywheel.api.Flywheel;

public final class FlwBackend {
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/backend");

private FlwBackend() {
}

public static void init() {
ShaderIndices.init();
Backends.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.layout.FloatRepr;
import com.jozufozu.flywheel.api.layout.Layout;
import com.jozufozu.flywheel.api.layout.LayoutBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.slf4j.LoggerFactory;

import com.google.common.collect.ImmutableList;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.backend.ShaderIndices;
import com.jozufozu.flywheel.backend.compile.component.UberShaderComponent;
Expand All @@ -22,7 +22,7 @@
import net.minecraft.server.packs.resources.ResourceManager;

public final class FlwPrograms {
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/shaders");
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID + "/backend/shaders");

private static final ResourceLocation COMPONENTS_HEADER_VERT = Flywheel.rl("internal/components_header.vert");
private static final ResourceLocation COMPONENTS_HEADER_FRAG = Flywheel.rl("internal/components_header.frag");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.jozufozu.flywheel.backend.compile;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.jetbrains.annotations.Nullable;

import com.google.common.collect.ImmutableList;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.backend.compile.component.InstanceStructComponent;
import com.jozufozu.flywheel.backend.compile.component.SsboInstanceComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jozufozu.flywheel.backend.compile;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.jozufozu.flywheel.backend.compile;

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

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.backend.InternalVertex;
import com.jozufozu.flywheel.backend.Samplers;
import com.jozufozu.flywheel.backend.compile.component.InstanceStructComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.jozufozu.flywheel.backend.compile;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.backend.Samplers;
import com.jozufozu.flywheel.backend.compile.component.BufferTextureInstanceComponent;
import com.jozufozu.flywheel.backend.compile.component.SsboInstanceComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.ArrayList;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.api.layout.Layout;
import com.jozufozu.flywheel.backend.glsl.generate.FnSignature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Collection;
import java.util.Collections;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.api.layout.Layout;
import com.jozufozu.flywheel.backend.compile.LayoutInterpreter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.ArrayList;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.api.layout.Layout;
import com.jozufozu.flywheel.backend.engine.indirect.IndirectBuffers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Collection;
import java.util.Map;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.backend.glsl.SourceComponent;

public final class StringSubstitutionComponent implements SourceComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.backend.compile.core.SourceLoader;
import com.jozufozu.flywheel.backend.glsl.SourceComponent;
import com.jozufozu.flywheel.backend.glsl.SourceFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.backend.glsl.SourceFile;
import com.jozufozu.flywheel.backend.glsl.SourceLines;
import com.jozufozu.flywheel.backend.glsl.error.ConsoleColors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.backend.Engine;
import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.api.instance.Instancer;
import com.jozufozu.flywheel.api.model.Model;
import com.jozufozu.flywheel.backend.FlwBackend;
import com.jozufozu.flywheel.backend.engine.embed.Environment;
import com.jozufozu.flywheel.lib.util.Pair;

Expand Down Expand Up @@ -98,7 +98,7 @@ private static boolean checkAndWarnEmptyModel(Model model) {
.forEach(f -> builder.append("\n\t")
.append(f.toString()));

Flywheel.LOGGER.warn(builder.toString());
FlwBackend.LOGGER.warn(builder.toString());

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private static long writeCamera(long ptr) {
}

private static long writeTime(long ptr, RenderContext context) {
int ticks = ((LevelRendererAccessor) context.renderer()).flywheel$ticks();
int ticks = ((LevelRendererAccessor) context.renderer()).flywheel$getTicks();
float partialTick = context.partialTick();
float renderTicks = ticks + partialTick;
float renderSeconds = renderTicks / 20f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.lwjgl.opengl.KHRShaderSubgroup;
import org.lwjgl.system.MemoryStack;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.backend.FlwBackend;
import com.jozufozu.flywheel.backend.compile.core.Compilation;
import com.jozufozu.flywheel.backend.glsl.GlslVersion;
import com.jozufozu.flywheel.lib.math.MoreMath;
Expand All @@ -26,7 +26,7 @@ public final class GlCompat {
caps = GL.getCapabilities();
} catch (IllegalStateException e) {
// This happens with vulkanmod installed.
Flywheel.LOGGER.warn("Failed to get GL capabilities, all flywheel backends will be disabled.");
FlwBackend.LOGGER.warn("Failed to get GL capabilities; default Flywheel backends will be disabled.");
caps = null;
}
CAPABILITIES = caps;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@Mixin(LevelRenderer.class)
public interface LevelRendererAccessor {
@Accessor("ticks")
int flywheel$ticks();
int flywheel$getTicks();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.client.Options;

@Mixin(Options.class)
public class OptionsMixin {
abstract class OptionsMixin {
@Inject(method = "load()V", at = @At("RETURN"))
private void flywheel$onLoad(CallbackInfo ci) {
OptionsUniforms.update((Options) (Object) this);
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions common/src/backend/resources/flywheel.backend.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
"refmap": "backend-flywheel.refmap.json",
"client": [
"AbstractClientPlayerAccessor",
"GameRendererAccessor",
"GlStateManagerMixin",
"LevelRendererAccessor",
"LightTextureAccessor",
"OptionsMixin",
"OverlayTextureAccessor",
"RenderSystemMixin"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.jetbrains.annotations.ApiStatus;
import org.lwjgl.system.MemoryUtil;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.api.layout.FloatRepr;
import com.jozufozu.flywheel.api.layout.IntegerRepr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.jozufozu.flywheel.lib.internal;

import org.slf4j.Logger;

import com.jozufozu.flywheel.api.internal.DependencyInjection;
import com.jozufozu.flywheel.lib.transform.PoseTransformStack;
import com.mojang.blaze3d.vertex.PoseStack;

public interface FlwLibLink {
FlwLibLink INSTANCE = DependencyInjection.load(FlwLibLink.class, "com.jozufozu.flywheel.impl.FlwLibLinkImpl");

Logger getLogger();

PoseTransformStack getPoseTransformStackOf(PoseStack stack);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.jetbrains.annotations.ApiStatus;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.material.CutoutShader;

public class CutoutShaders {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.jetbrains.annotations.ApiStatus;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.material.FogShader;

public class FogShaders {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.jetbrains.annotations.ApiStatus;

import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.Flywheel;
import com.jozufozu.flywheel.api.material.MaterialShaders;

public final class StandardMaterialShaders {
Expand Down
Loading

0 comments on commit 914ce0a

Please sign in to comment.