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:
#	buildSrc/build.gradle.kts
#	buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt
#	forge/build.gradle.kts
#	gradle.properties
#	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information
IThundxr committed Sep 14, 2024
2 parents 3453715 + dfc1e3a commit 42290b2
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ local.properties
.buildpath

# Other
.DS_Store
mcmodsrepo
src/*/generatedPackageInfos/
*/src/*/generatedPackageInfos/
19 changes: 15 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import java.util.Properties

plugins {
id("java-gradle-plugin")
kotlin("jvm") version "1.9.23"
`kotlin-dsl`
idea
}

repositories {
Expand All @@ -17,6 +18,11 @@ repositories {
maven("https://maven.parchmentmc.org")
}

idea.module {
isDownloadJavadoc = true
isDownloadSources = true
}

gradlePlugin {
plugins {
create("platformPlugin") {
Expand All @@ -30,7 +36,12 @@ gradlePlugin {
}
}

val properties by lazy {
Properties().apply {
load(rootDir.parentFile.resolve("gradle.properties").inputStream())
}
}

dependencies {
// FIXME: This should not hard-code the Loom version.
implementation("dev.architectury.loom:dev.architectury.loom.gradle.plugin:1.7.+")
implementation("dev.architectury.loom:dev.architectury.loom.gradle.plugin:${properties["arch_loom_version"]}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class SubprojectPlugin: Plugin<Project> {
private fun setupLoom(project: Project) {
val loom = project.the<LoomGradleExtensionAPI>()
loom.silentMojangMappingsLicense()

//fixme is this still needed?
// loom.mixin.defaultRefmapName = "flywheel.refmap.json"
}

private fun setupJava(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import java.util.List;

import dev.engine_room.flywheel.api.instance.InstanceType;

import dev.engine_room.flywheel.api.instance.InstancerProvider;

import org.joml.Vector4fc;

import dev.engine_room.flywheel.api.instance.InstanceType;
import dev.engine_room.flywheel.api.instance.InstancerProvider;
import dev.engine_room.flywheel.api.material.Material;

public interface Model {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,21 @@

import dev.engine_room.flywheel.api.vertex.MutableVertexList;
import dev.engine_room.flywheel.api.vertex.VertexList;
import dev.engine_room.flywheel.lib.memory.MemoryBlock;

public final class SimpleQuadMesh implements QuadMesh {
private final VertexList vertexList;
// Unused but we need to hold on to a reference so the cleaner doesn't nuke us.
private final MemoryBlock data;
private final Vector4f boundingSphere;
@Nullable
private final String descriptor;

public SimpleQuadMesh(VertexList vertexList, MemoryBlock data, @Nullable String descriptor) {
public SimpleQuadMesh(VertexList vertexList, @Nullable String descriptor) {
this.vertexList = vertexList;
this.data = data;
boundingSphere = ModelUtil.computeBoundingSphere(vertexList);
this.descriptor = descriptor;
}

public SimpleQuadMesh(VertexList vertexList, MemoryBlock data) {
this(vertexList, data, null);
public SimpleQuadMesh(VertexList vertexList) {
this(vertexList, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static SimpleQuadMesh blockVerticesToMesh(MeshData data, @Nullable String

vertexView.ptr(dstPtr);
vertexView.vertexCount(vertexCount);
vertexView.nativeMemoryOwner(dst);

return new SimpleQuadMesh(vertexView, dst, meshDescriptor);
return new SimpleQuadMesh(vertexView, meshDescriptor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static Mesh convert(ModelPart modelPart, @Nullable PoseStack poseStack, @

VertexView vertexView = new PosTexNormalVertexView();
vertexView.load(data);
return new SimpleQuadMesh(vertexView, data, "source=ModelPartConverter");
return new SimpleQuadMesh(vertexView, "source=ModelPartConverter");
}

public static Mesh convert(ModelLayerLocation layer, @Nullable TextureAtlasSprite sprite, String... childPath) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package dev.engine_room.flywheel.lib.vertex;

import org.jetbrains.annotations.Nullable;

public abstract class AbstractVertexView implements VertexView {
protected long ptr;
protected int vertexCount;
@Nullable
private Object nativeMemoryOwner;

@Override
public long ptr() {
Expand All @@ -23,4 +27,15 @@ public int vertexCount() {
public void vertexCount(int vertexCount) {
this.vertexCount = vertexCount;
}

@Override
@Nullable
public final Object nativeMemoryOwner() {
return nativeMemoryOwner;
}

@Override
public final void nativeMemoryOwner(@Nullable Object owner) {
nativeMemoryOwner = owner;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.engine_room.flywheel.lib.vertex;

import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryUtil;

import dev.engine_room.flywheel.api.vertex.MutableVertexList;
Expand All @@ -14,6 +15,17 @@ public interface VertexView extends MutableVertexList {

long stride();

@Nullable
Object nativeMemoryOwner();

/**
* The memory referenced by this vertex view's pointer may be owned by another object, such that the memory is
* automatically freed when the other object becomes phantom reachable or is garbage collected. Use this method to
* ensure this vertex view retains a strong reference to the memory owner so this vertex view's pointer remains
* valid even when no other references to the memory owner are retained.
*/
void nativeMemoryOwner(@Nullable Object owner);

default void load(MemoryBlock data) {
long bytes = data.size();
long stride = stride();
Expand All @@ -24,6 +36,7 @@ default void load(MemoryBlock data) {

ptr(data.ptr());
vertexCount(vertexCount);
nativeMemoryOwner(data);
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ defaultPackageInfos {
sources(api, lib, backend, main)
}

loom {
mixin {
useLegacyMixinAp = true
add(main, "flywheel.refmap.json")
add(backend, "backend-flywheel.refmap.json")
}
}

dependencies {
modImplementation("net.fabricmc:fabric-loader:${property("fabric_loader_version")}")
modApi("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}")
Expand Down
12 changes: 12 additions & 0 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ defaultPackageInfos {
}

loom {
mixin {
useLegacyMixinAp = true
add(main, "flywheel.refmap.json")
add(backend, "backend-flywheel.refmap.json")
}

forge {
mixinConfig("flywheel.backend.mixins.json")
mixinConfig("flywheel.impl.mixins.json")
mixinConfig("flywheel.impl.sodium.mixins.json")
}

runs {
configureEach {
property("forge.logging.markers", "")
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ neoforge_version_range = [21.0.167,)

# General build dependency versions
java_version = 21
# FIXME: This doesn't do anything.
# arch_loom_version = 1.6-SNAPSHOT
arch_loom_version=1.7.412
cursegradle_version = 1.4.0
parchment_version = 2024.07.07

# Minecraft build dependency versions
Expand Down
6 changes: 0 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ pluginManagement {
maven("https://repo.spongepowered.org/repository/maven-public")
maven("https://maven.parchmentmc.org")
}

// FIXME: This doesn't do anything. The actual version is always the one defined in buildSrc/build.gradle.kts.
// plugins {
// val arch_loom_version: String by settings
// id("dev.architectury.loom") version arch_loom_version
// }
}

rootProject.name = "Flywheel"
Expand Down

0 comments on commit 42290b2

Please sign in to comment.