mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-01 01:46:39 +01:00
Automated nullability
- Remove most NotNull annotations - Automatically generate missing package-info.java files which contain annotations to establish that everything is not null by default - Remove CurseForge integration from build script - Fix some other formatting
This commit is contained in:
parent
470f207189
commit
f9e5d33296
46 changed files with 297 additions and 327 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -43,4 +43,6 @@ local.properties
|
|||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# Other
|
||||
mcmodsrepo
|
||||
src/*/generatedPackageInfos/
|
||||
|
|
19
build.gradle
19
build.gradle
|
@ -5,7 +5,6 @@ plugins {
|
|||
id 'net.minecraftforge.gradle' version "${forgegradle_version}"
|
||||
id 'org.parchmentmc.librarian.forgegradle' version "${librarian_version}"
|
||||
id 'org.spongepowered.mixin' version "${mixingradle_version}"
|
||||
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
|
||||
}
|
||||
|
||||
jarJar.enable()
|
||||
|
@ -166,6 +165,8 @@ tasks.named('processResources', ProcessResources).configure {
|
|||
}
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/package-infos.gradle')
|
||||
|
||||
void addLicense(jarTask) {
|
||||
jarTask.from('LICENSE.md') {
|
||||
rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2'
|
||||
|
@ -230,19 +231,3 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.curseforge.enabled = !dev && project.hasProperty('jozu_curseforge_key')
|
||||
|
||||
curseforge {
|
||||
if (project.hasProperty('jozu_curseforge_key')) {
|
||||
apiKey = project.jozu_curseforge_key
|
||||
}
|
||||
|
||||
project {
|
||||
id = project.projectId
|
||||
changelog = file('changelog.txt')
|
||||
releaseType = project.curse_type
|
||||
mainArtifact jar
|
||||
addGameVersion '1.20.1'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ org.gradle.daemon = false
|
|||
mod_version = 1.0.0-alpha
|
||||
artifact_minecraft_version = 1.20.1
|
||||
minecraft_version = 1.20.1
|
||||
forge_version=47.2.19
|
||||
forge_version = 47.2.19
|
||||
# Version ranges for the mods.toml
|
||||
minecraft_version_range=[1.20.1,1.20.3)
|
||||
forge_version_range=[47,)
|
||||
loader_version_range=[47,)
|
||||
minecraft_version_range = [1.20.1,1.20.2)
|
||||
forge_version_range = [47,)
|
||||
loader_version_range = [47,)
|
||||
|
||||
# build dependency versions
|
||||
forgegradle_version = [6.0.16,6.2)
|
||||
|
@ -18,10 +18,3 @@ mixin_version = 0.8.5
|
|||
librarian_version = 1.+
|
||||
cursegradle_version = 1.4.0
|
||||
parchment_version = 2023.09.03
|
||||
|
||||
# curseforge info
|
||||
projectId = 486392
|
||||
curse_type = release
|
||||
|
||||
# github info
|
||||
github_project = Jozufozu/Flywheel
|
||||
|
|
70
gradle/package-infos.gradle
Normal file
70
gradle/package-infos.gradle
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Adapted from https://github.com/FabricMC/fabric/blob/31787236d242247e0b6c4ae806b1cfaa7042a62c/gradle/package-info.gradle, which is licensed under Apache 2.0.
|
||||
|
||||
import java.nio.file.Files
|
||||
|
||||
setupGeneratePackageInfos(sourceSets.main)
|
||||
|
||||
def setupGeneratePackageInfos(SourceSet sourceSet) {
|
||||
// We have to capture the source set name for the lazy string literals,
|
||||
// otherwise it'll just be whatever the last source set is in the list.
|
||||
def sourceSetName = sourceSet.name
|
||||
def taskName = sourceSet.getTaskName('generate', 'PackageInfos')
|
||||
def task = tasks.register(taskName, GeneratePackageInfosTask) {
|
||||
group = 'flywheel'
|
||||
description = "Generates package-info files for $sourceSetName packages."
|
||||
|
||||
// Only apply to default source directory since we also add the generated
|
||||
// sources to the source set.
|
||||
sourceRoot = file("src/$sourceSetName/java")
|
||||
outputDir = file("src/$sourceSetName/generatedPackageInfos")
|
||||
}
|
||||
sourceSet.java.srcDir task
|
||||
|
||||
def cleanTask = tasks.register(sourceSet.getTaskName('clean', 'PackageInfos'), Delete) {
|
||||
group = 'flywheel'
|
||||
delete file("src/$sourceSetName/generatedPackageInfos")
|
||||
}
|
||||
clean.dependsOn cleanTask
|
||||
}
|
||||
|
||||
class GeneratePackageInfosTask extends DefaultTask {
|
||||
@SkipWhenEmpty
|
||||
@InputDirectory
|
||||
final DirectoryProperty sourceRoot = project.objects.directoryProperty()
|
||||
|
||||
@OutputDirectory
|
||||
final DirectoryProperty outputDir = project.objects.directoryProperty()
|
||||
|
||||
@TaskAction
|
||||
def run() {
|
||||
def output = outputDir.get().asFile.toPath()
|
||||
output.deleteDir()
|
||||
def root = sourceRoot.get().asFile.toPath()
|
||||
|
||||
root.eachDirRecurse {
|
||||
def containsJava = Files.list(it).any {
|
||||
Files.isRegularFile(it) && it.fileName.toString().endsWith('.java')
|
||||
}
|
||||
|
||||
if (containsJava && Files.notExists(it.resolve('package-info.java'))) {
|
||||
def relativePath = root.relativize(it)
|
||||
def target = output.resolve(relativePath)
|
||||
Files.createDirectories(target)
|
||||
|
||||
target.resolve('package-info.java').withWriter {
|
||||
def packageName = relativePath.toString().replace(File.separator, '.')
|
||||
it.write("""@ParametersAreNonnullByDefault
|
||||
|@FieldsAreNonnullByDefault
|
||||
|@MethodsReturnNonnullByDefault
|
||||
|package $packageName;
|
||||
|
|
||||
|import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
|
||||
|import net.minecraft.FieldsAreNonnullByDefault;
|
||||
|import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|""".stripMargin())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,6 @@ package com.jozufozu.flywheel.api.backend;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.event.RenderContext;
|
||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
|
@ -67,6 +65,6 @@ public interface Engine extends InstancerProvider {
|
|||
* @param pos The position of the block.
|
||||
* @param instances The instances associated with the BE at this position.
|
||||
*/
|
||||
record CrumblingBlock(int progress, BlockPos pos, List<@NotNull Instance> instances) {
|
||||
record CrumblingBlock(int progress, BlockPos pos, List<Instance> instances) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.jozufozu.flywheel.api.context;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.registry.Registry;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.impl.RegistryImpl;
|
||||
|
@ -11,7 +9,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
public interface Context {
|
||||
static Registry<Context> REGISTRY = RegistryImpl.create();
|
||||
|
||||
void onProgramLink(@NotNull GlProgram program);
|
||||
void onProgramLink(GlProgram program);
|
||||
|
||||
ResourceLocation vertexShader();
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface VertexList {
|
|||
return dest.set(x(i), y(i), z(i));
|
||||
}
|
||||
|
||||
default Vector3f getNormal(int i, Vector3f dest) {
|
||||
default Vector3f getNormal(int i, Vector3f dest) {
|
||||
return dest.set(normalX(i), normalY(i), normalZ(i));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.layout.FloatRepr;
|
||||
|
@ -126,152 +124,38 @@ public class IndirectComponent implements SourceComponent {
|
|||
throw new IllegalArgumentException("Unknown type " + type);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackMatrix(String name, GlslStruct packed, MatrixElementType matrix) {
|
||||
var repr = matrix.repr();
|
||||
|
||||
int rows = matrix.rows();
|
||||
int columns = matrix.columns();
|
||||
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < columns; i++) {
|
||||
args.add(unpackFloatVector(name + "_" + i, repr, packed, rows));
|
||||
}
|
||||
|
||||
return GlslExpr.call("mat" + columns + "x" + rows, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackScalar(String fieldName, GlslStruct packed, ScalarElementType scalar) {
|
||||
var repr = scalar.repr();
|
||||
|
||||
if (repr instanceof FloatRepr floatRepr) {
|
||||
return unpackFloatScalar(fieldName, floatRepr, packed);
|
||||
} else if (repr instanceof IntegerRepr intRepr) {
|
||||
if (repr instanceof IntegerRepr intRepr) {
|
||||
return unpackIntScalar(fieldName, intRepr, packed);
|
||||
} else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) {
|
||||
return unpackUnsignedScalar(fieldName, unsignedIntegerRepr, packed);
|
||||
} else if (repr instanceof FloatRepr floatRepr) {
|
||||
return unpackFloatScalar(fieldName, floatRepr, packed);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unknown repr " + repr);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackVector(String fieldName, GlslStruct packed, VectorElementType vector) {
|
||||
var repr = vector.repr();
|
||||
|
||||
int size = vector.size();
|
||||
|
||||
if (repr instanceof FloatRepr floatRepr) {
|
||||
return unpackFloatVector(fieldName, floatRepr, packed, size);
|
||||
} else if (repr instanceof IntegerRepr intRepr) {
|
||||
return unpackIntVector(fieldName, intRepr, packed, size);
|
||||
} else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) {
|
||||
return unpackUnsignedVector(fieldName, unsignedIntegerRepr, packed, size);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unknown repr " + repr);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackFloatVector(String fieldName, FloatRepr floatRepr, GlslStruct packed, int size) {
|
||||
return switch (floatRepr) {
|
||||
case NORMALIZED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackSnorm4x8");
|
||||
case NORMALIZED_UNSIGNED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackUnorm4x8");
|
||||
case NORMALIZED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackSnorm2x16");
|
||||
case NORMALIZED_UNSIGNED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackUnorm2x16");
|
||||
case NORMALIZED_INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.div(2147483647f)
|
||||
.clamp(-1, 1));
|
||||
case NORMALIZED_UNSIGNED_INT ->
|
||||
unpack(fieldName, packed, size, "uint", "vec" + size, e -> e.div(4294967295f));
|
||||
case BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
|
||||
.cast("float"));
|
||||
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
|
||||
case SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
|
||||
.cast("float"));
|
||||
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
|
||||
case INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.cast("float"));
|
||||
case UNSIGNED_INT -> unpack(fieldName, packed, size, "float", "vec" + size, e -> e.cast("float"));
|
||||
case FLOAT -> unpack(fieldName, packed, size, "float", "vec" + size);
|
||||
private static GlslExpr unpackIntScalar(String fieldName, IntegerRepr intRepr, GlslStruct packed) {
|
||||
return switch (intRepr) {
|
||||
case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF)
|
||||
.cast("int"));
|
||||
case SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF)
|
||||
.cast("int"));
|
||||
case INT -> unpackScalar(fieldName, packed, "int");
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackUnsignedVector(String fieldName, UnsignedIntegerRepr unsignedIntegerRepr, GlslStruct packed, int size) {
|
||||
return switch (unsignedIntegerRepr) {
|
||||
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
|
||||
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
|
||||
case UNSIGNED_INT -> unpack(fieldName, packed, size, "uint", "uvec" + size);
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackIntVector(String fieldName, IntegerRepr repr, GlslStruct packed, int size) {
|
||||
private static GlslExpr unpackUnsignedScalar(String fieldName, UnsignedIntegerRepr repr, GlslStruct packed) {
|
||||
return switch (repr) {
|
||||
case BYTE -> unpackByteBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int"));
|
||||
case SHORT -> unpackShortBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int"));
|
||||
case INT -> unpack(fieldName, packed, size, "int", "ivec" + size);
|
||||
case UNSIGNED_BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF));
|
||||
case UNSIGNED_SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF));
|
||||
case UNSIGNED_INT -> unpackScalar(fieldName, packed, "uint");
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType) {
|
||||
return unpack(fieldName, packed, size, backingType, outType, Function.identity());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
var name = fieldName + "_" + i;
|
||||
packed.addField(backingType, name);
|
||||
args.add(UNPACKING_VARIABLE.access(name)
|
||||
.transform(perElement));
|
||||
}
|
||||
return GlslExpr.call(outType, args);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GlslExpr unpackBuiltin(String fieldName, GlslStruct packed, int size, String func) {
|
||||
packed.addField("uint", fieldName);
|
||||
GlslExpr expr = UNPACKING_VARIABLE.access(fieldName)
|
||||
.callFunction(func);
|
||||
return switch (size) {
|
||||
case 2 -> expr.swizzle("xy");
|
||||
case 3 -> expr.swizzle("xyz");
|
||||
case 4 -> expr;
|
||||
default -> throw new IllegalArgumentException("Invalid vector size " + size);
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GlslExpr unpackByteBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
packed.addField("uint", fieldName);
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int bitPos = i * 8;
|
||||
var element = UNPACKING_VARIABLE.access(fieldName)
|
||||
.and(0xFF << bitPos)
|
||||
.rsh(bitPos);
|
||||
args.add(perElement.apply(element));
|
||||
}
|
||||
return GlslExpr.call(outType + size, args);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GlslExpr unpackShortBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int unpackField = i / 2;
|
||||
int bitPos = (i % 2) * 16;
|
||||
var name = fieldName + "_" + unpackField;
|
||||
if (bitPos == 0) {
|
||||
// First time we're seeing this field, add it to the struct.
|
||||
packed.addField("uint", name);
|
||||
}
|
||||
var element = UNPACKING_VARIABLE.access(name)
|
||||
.and(0xFFFF << bitPos)
|
||||
.rsh(bitPos);
|
||||
args.add(perElement.apply(element));
|
||||
}
|
||||
return GlslExpr.call(outType, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackFloatScalar(String fieldName, FloatRepr repr, GlslStruct packed) {
|
||||
return switch (repr) {
|
||||
case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF)
|
||||
|
@ -303,24 +187,6 @@ public class IndirectComponent implements SourceComponent {
|
|||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackUnsignedScalar(String fieldName, UnsignedIntegerRepr repr, GlslStruct packed) {
|
||||
return switch (repr) {
|
||||
case UNSIGNED_BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF));
|
||||
case UNSIGNED_SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF));
|
||||
case UNSIGNED_INT -> unpackScalar(fieldName, packed, "uint");
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackIntScalar(String fieldName, IntegerRepr intRepr, GlslStruct packed) {
|
||||
return switch (intRepr) {
|
||||
case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF)
|
||||
.cast("int"));
|
||||
case SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF)
|
||||
.cast("int"));
|
||||
case INT -> unpackScalar(fieldName, packed, "int");
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackScalar(String fieldName, GlslStruct packed, String packedType) {
|
||||
return unpackScalar(fieldName, packed, packedType, Function.identity());
|
||||
}
|
||||
|
@ -329,4 +195,131 @@ public class IndirectComponent implements SourceComponent {
|
|||
packed.addField(packedType, fieldName);
|
||||
return perElement.apply(UNPACKING_VARIABLE.access(fieldName));
|
||||
}
|
||||
|
||||
private static GlslExpr unpackVector(String fieldName, GlslStruct packed, VectorElementType vector) {
|
||||
var repr = vector.repr();
|
||||
|
||||
int size = vector.size();
|
||||
|
||||
if (repr instanceof IntegerRepr intRepr) {
|
||||
return unpackIntVector(fieldName, intRepr, packed, size);
|
||||
} else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) {
|
||||
return unpackUnsignedVector(fieldName, unsignedIntegerRepr, packed, size);
|
||||
} else if (repr instanceof FloatRepr floatRepr) {
|
||||
return unpackFloatVector(fieldName, floatRepr, packed, size);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unknown repr " + repr);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackIntVector(String fieldName, IntegerRepr repr, GlslStruct packed, int size) {
|
||||
return switch (repr) {
|
||||
case BYTE -> unpackByteBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int"));
|
||||
case SHORT -> unpackShortBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int"));
|
||||
case INT -> unpack(fieldName, packed, size, "int", "ivec" + size);
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackUnsignedVector(String fieldName, UnsignedIntegerRepr unsignedIntegerRepr, GlslStruct packed, int size) {
|
||||
return switch (unsignedIntegerRepr) {
|
||||
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
|
||||
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
|
||||
case UNSIGNED_INT -> unpack(fieldName, packed, size, "uint", "uvec" + size);
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackFloatVector(String fieldName, FloatRepr floatRepr, GlslStruct packed, int size) {
|
||||
return switch (floatRepr) {
|
||||
case NORMALIZED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackSnorm4x8");
|
||||
case NORMALIZED_UNSIGNED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackUnorm4x8");
|
||||
case NORMALIZED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackSnorm2x16");
|
||||
case NORMALIZED_UNSIGNED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackUnorm2x16");
|
||||
case NORMALIZED_INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.div(2147483647f)
|
||||
.clamp(-1, 1));
|
||||
case NORMALIZED_UNSIGNED_INT ->
|
||||
unpack(fieldName, packed, size, "uint", "vec" + size, e -> e.div(4294967295f));
|
||||
case BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
|
||||
.cast("float"));
|
||||
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
|
||||
case SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
|
||||
.cast("float"));
|
||||
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
|
||||
case INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.cast("float"));
|
||||
case UNSIGNED_INT -> unpack(fieldName, packed, size, "float", "vec" + size, e -> e.cast("float"));
|
||||
case FLOAT -> unpack(fieldName, packed, size, "float", "vec" + size);
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackByteBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
packed.addField("uint", fieldName);
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int bitPos = i * 8;
|
||||
var element = UNPACKING_VARIABLE.access(fieldName)
|
||||
.and(0xFF << bitPos)
|
||||
.rsh(bitPos);
|
||||
args.add(perElement.apply(element));
|
||||
}
|
||||
return GlslExpr.call(outType + size, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackShortBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int unpackField = i / 2;
|
||||
int bitPos = (i % 2) * 16;
|
||||
var name = fieldName + "_" + unpackField;
|
||||
if (bitPos == 0) {
|
||||
// First time we're seeing this field, add it to the struct.
|
||||
packed.addField("uint", name);
|
||||
}
|
||||
var element = UNPACKING_VARIABLE.access(name)
|
||||
.and(0xFFFF << bitPos)
|
||||
.rsh(bitPos);
|
||||
args.add(perElement.apply(element));
|
||||
}
|
||||
return GlslExpr.call(outType, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType) {
|
||||
return unpack(fieldName, packed, size, backingType, outType, Function.identity());
|
||||
}
|
||||
|
||||
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType, Function<GlslExpr, GlslExpr> perElement) {
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
var name = fieldName + "_" + i;
|
||||
packed.addField(backingType, name);
|
||||
args.add(UNPACKING_VARIABLE.access(name)
|
||||
.transform(perElement));
|
||||
}
|
||||
return GlslExpr.call(outType, args);
|
||||
}
|
||||
|
||||
private static GlslExpr unpackBuiltin(String fieldName, GlslStruct packed, int size, String func) {
|
||||
packed.addField("uint", fieldName);
|
||||
GlslExpr expr = UNPACKING_VARIABLE.access(fieldName)
|
||||
.callFunction(func);
|
||||
return switch (size) {
|
||||
case 2 -> expr.swizzle("xy");
|
||||
case 3 -> expr.swizzle("xyz");
|
||||
case 4 -> expr;
|
||||
default -> throw new IllegalArgumentException("Invalid vector size " + size);
|
||||
};
|
||||
}
|
||||
|
||||
private static GlslExpr unpackMatrix(String name, GlslStruct packed, MatrixElementType matrix) {
|
||||
var repr = matrix.repr();
|
||||
|
||||
int rows = matrix.rows();
|
||||
int columns = matrix.columns();
|
||||
|
||||
List<GlslExpr> args = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < columns; i++) {
|
||||
args.add(unpackFloatVector(name + "_" + i, repr, packed, rows));
|
||||
}
|
||||
|
||||
return GlslExpr.call("mat" + columns + "x" + rows, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.io.FileWriter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.compile.FlwPrograms;
|
||||
|
@ -33,7 +32,6 @@ public class Compilation {
|
|||
private final StringBuilder fullSource = new StringBuilder();
|
||||
private int generatedLines = 0;
|
||||
|
||||
@NotNull
|
||||
public ShaderResult compile(ShaderType shaderType, String name) {
|
||||
int handle = GL20.glCreateShader(shaderType.glEnum);
|
||||
var source = fullSource.toString();
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.function.BiFunction;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
|
@ -98,7 +97,7 @@ public class Compile<K> {
|
|||
public static class ShaderCompiler<K> {
|
||||
private final GlslVersion glslVersion;
|
||||
private final ShaderType shaderType;
|
||||
private final List<BiFunction<K, SourceLoader, SourceComponent>> fetchers = new ArrayList<>();
|
||||
private final List<BiFunction<K, SourceLoader, @Nullable SourceComponent>> fetchers = new ArrayList<>();
|
||||
private Consumer<Compilation> compilationCallbacks = $ -> {
|
||||
};
|
||||
private Function<K, String> nameMapper = Object::toString;
|
||||
|
@ -113,25 +112,25 @@ public class Compile<K> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ShaderCompiler<K> with(BiFunction<K, SourceLoader, SourceComponent> fetch) {
|
||||
public ShaderCompiler<K> with(BiFunction<K, SourceLoader, @Nullable SourceComponent> fetch) {
|
||||
fetchers.add(fetch);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShaderCompiler<K> withComponents(Collection<SourceComponent> components) {
|
||||
public ShaderCompiler<K> withComponents(Collection<@Nullable SourceComponent> components) {
|
||||
components.forEach(this::withComponent);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShaderCompiler<K> withComponent(SourceComponent component) {
|
||||
public ShaderCompiler<K> withComponent(@Nullable SourceComponent component) {
|
||||
return withComponent($ -> component);
|
||||
}
|
||||
|
||||
public ShaderCompiler<K> withComponent(Function<K, @NotNull SourceComponent> sourceFetcher) {
|
||||
public ShaderCompiler<K> withComponent(Function<K, @Nullable SourceComponent> sourceFetcher) {
|
||||
return with((key, $) -> sourceFetcher.apply(key));
|
||||
}
|
||||
|
||||
public ShaderCompiler<K> withResource(Function<K, @NotNull ResourceLocation> sourceFetcher) {
|
||||
public ShaderCompiler<K> withResource(Function<K, ResourceLocation> sourceFetcher) {
|
||||
return with((key, loader) -> loader.find(sourceFetcher.apply(key)));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
|
||||
|
@ -71,7 +70,6 @@ public class CompilerStats {
|
|||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String linkErrors() {
|
||||
return String.join("\n", programErrors);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import java.util.regex.Pattern;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceFile;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceLines;
|
||||
|
@ -49,7 +47,6 @@ public class FailedCompilation {
|
|||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Stream<ErrorBuilder> errorStream() {
|
||||
return errorLog.lines()
|
||||
.mapMulti(this::interpretLine);
|
||||
|
@ -142,7 +139,6 @@ public class FailedCompilation {
|
|||
.note("This generally indicates a bug in Flywheel, not your shader code.");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ErrorLevel parseErrorLevel(String level) {
|
||||
return switch (level.toLowerCase(Locale.ROOT)) {
|
||||
case "error" -> ErrorLevel.ERROR;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault
|
||||
package com.jozufozu.flywheel.backend.compile;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
|
@ -11,8 +11,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.backend.Engine;
|
||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
|
@ -158,7 +156,6 @@ public class IndirectDrawManager extends InstancerStorage<IndirectInstancer<?>>
|
|||
block.free();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Map<InstanceType<?>, Int2ObjectMap<List<Pair<IndirectInstancer<?>, InstanceHandleImpl>>>> doCrumblingSort(List<Engine.CrumblingBlock> crumblingBlocks) {
|
||||
Map<InstanceType<?>, Int2ObjectMap<List<Pair<IndirectInstancer<?>, InstanceHandleImpl>>>> byType = new HashMap<>();
|
||||
for (Engine.CrumblingBlock block : crumblingBlocks) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.jozufozu.flywheel.backend.engine.indirect;
|
|||
|
||||
import java.util.function.LongConsumer;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL45;
|
||||
import org.lwjgl.opengl.GL45C;
|
||||
|
@ -227,7 +226,6 @@ public class StagingBuffer {
|
|||
FlwMemoryTracker._freeCPUMemory(capacity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private MemoryBlock getScratch(long size) {
|
||||
if (scratch == null) {
|
||||
scratch = MemoryBlock.malloc(size);
|
||||
|
|
|
@ -74,14 +74,14 @@ public class DrawCall {
|
|||
}
|
||||
|
||||
public void delete() {
|
||||
if (vao != null) {
|
||||
vao.delete();
|
||||
vao = null;
|
||||
}
|
||||
if (vao != null) {
|
||||
vao.delete();
|
||||
vao = null;
|
||||
}
|
||||
|
||||
if (vaoScratch != null) {
|
||||
vaoScratch.delete();
|
||||
vaoScratch = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.jozufozu.flywheel.backend.engine.instancing;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import com.jozufozu.flywheel.api.model.IndexSequence;
|
||||
|
@ -55,7 +54,6 @@ public class EboCache {
|
|||
}
|
||||
|
||||
private record Entry(int ebo, int gpuSize) {
|
||||
@NotNull
|
||||
private static Entry create(IndexSequence provider, int indexCount) {
|
||||
int byteSize = indexCount * GlNumericType.UINT.byteWidth();
|
||||
var ebo = Buffer.IMPL.create();
|
||||
|
|
|
@ -5,8 +5,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.backend.Engine;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
import com.jozufozu.flywheel.backend.compile.InstancingPrograms;
|
||||
|
@ -74,7 +72,6 @@ public class InstancedCrumbling {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Map<ShaderState, Int2ObjectMap<List<Runnable>>> doCrumblingSort(List<Engine.CrumblingBlock> instances) {
|
||||
Map<ShaderState, Int2ObjectMap<List<Runnable>>> out = new HashMap<>();
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ import java.util.EnumMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
@ -108,7 +106,6 @@ public class InstancedDrawManager extends InstancerStorage<InstancedInstancer<?>
|
|||
return drawCalls.isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<Map.Entry<ShaderState, Collection<DrawCall>>> iterator() {
|
||||
return drawCalls.asMap()
|
||||
|
|
|
@ -53,7 +53,7 @@ public enum GlBufferType {
|
|||
};
|
||||
}
|
||||
|
||||
public void bind(int buffer) {
|
||||
public void bind(int buffer) {
|
||||
GlStateTracker.bindBuffer(this, buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -40,7 +39,6 @@ public class ShaderSources {
|
|||
cache.putAll(preloadCache);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LoadResult find(ResourceLocation location) {
|
||||
if (findStack.contains(location)) {
|
||||
// Make a copy of the find stack with the offending location added on top to show the full path.
|
||||
|
@ -57,7 +55,6 @@ public class ShaderSources {
|
|||
return out;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private LoadResult _find(ResourceLocation location) {
|
||||
// Can't use computeIfAbsent because mutual recursion causes ConcurrentModificationExceptions
|
||||
var out = cache.get(location);
|
||||
|
@ -68,7 +65,7 @@ public class ShaderSources {
|
|||
return out;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@VisibleForTesting
|
||||
protected LoadResult load(ResourceLocation loc) {
|
||||
return manager.getResource(loc.withPrefix(SHADER_DIR))
|
||||
.map(resource -> {
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -229,7 +228,6 @@ public class SourceFile implements SourceComponent {
|
|||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String generateFinalSource(ImmutableList<Import> imports, SourceLines source) {
|
||||
var out = new StringBuilder();
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.jozufozu.flywheel.backend.glsl;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.jozufozu.flywheel.backend.glsl.span.CharPos;
|
||||
|
||||
|
@ -14,8 +12,7 @@ import it.unimi.dsi.fastutil.ints.IntLists;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class SourceLines implements CharSequence {
|
||||
|
||||
private static final Pattern newLine = Pattern.compile("(\\r\\n|\\r|\\n)");
|
||||
private static final Pattern NEW_LINE = Pattern.compile("(\\r\\n|\\r|\\n)");
|
||||
|
||||
public final ResourceLocation name;
|
||||
/**
|
||||
|
@ -88,7 +85,7 @@ public class SourceLines implements CharSequence {
|
|||
IntList l = new IntArrayList();
|
||||
l.add(0); // first line is always at position 0
|
||||
|
||||
Matcher matcher = newLine.matcher(source);
|
||||
Matcher matcher = NEW_LINE.matcher(source);
|
||||
|
||||
while (matcher.find()) {
|
||||
l.add(matcher.end());
|
||||
|
@ -116,16 +113,17 @@ public class SourceLines implements CharSequence {
|
|||
return raw;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return raw.subSequence(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(int i) {
|
||||
return raw.charAt(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return raw.length();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
|
@ -148,7 +147,6 @@ public class ErrorBuilder {
|
|||
return lineStream.collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Stream<String> getLineStream() {
|
||||
int maxMargin = calculateMargin();
|
||||
|
||||
|
|
|
@ -17,28 +17,28 @@ public class GlslBuilder {
|
|||
|
||||
public GlslStruct struct() {
|
||||
return add(new GlslStruct());
|
||||
}
|
||||
}
|
||||
|
||||
public GlslFn function() {
|
||||
return add(new GlslFn());
|
||||
}
|
||||
public GlslFn function() {
|
||||
return add(new GlslFn());
|
||||
}
|
||||
|
||||
public GlslVertexInput vertexInput() {
|
||||
return add(new GlslVertexInput());
|
||||
}
|
||||
public GlslVertexInput vertexInput() {
|
||||
return add(new GlslVertexInput());
|
||||
}
|
||||
|
||||
public GlslUniformBlock uniformBlock() {
|
||||
return add(new GlslUniformBlock());
|
||||
}
|
||||
public GlslUniformBlock uniformBlock() {
|
||||
return add(new GlslUniformBlock());
|
||||
}
|
||||
|
||||
public <T extends Declaration> T add(T element) {
|
||||
elements.add(element);
|
||||
return element;
|
||||
}
|
||||
public <T extends Declaration> T add(T element) {
|
||||
elements.add(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
public void blankLine() {
|
||||
elements.add(Separators.BLANK_LINE);
|
||||
}
|
||||
public void blankLine() {
|
||||
elements.add(Separators.BLANK_LINE);
|
||||
}
|
||||
|
||||
public void _addRaw(String sourceString) {
|
||||
elements.add(() -> sourceString);
|
||||
|
|
|
@ -4,13 +4,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.lib.util.Pair;
|
||||
import com.jozufozu.flywheel.lib.util.StringUtil;
|
||||
|
||||
public class GlslSwitch implements GlslStmt {
|
||||
|
||||
private final GlslExpr on;
|
||||
|
||||
private final List<Pair<GlslExpr, GlslBlock>> cases = new ArrayList<>();
|
||||
|
@ -44,16 +41,15 @@ public class GlslSwitch implements GlslStmt {
|
|||
}""".formatted(on.prettyPrint(), formatCases());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String formatCases() {
|
||||
var cases = this.cases.stream()
|
||||
.map(GlslSwitch::prettyPrintCase)
|
||||
.collect(Collectors.joining("\n"));
|
||||
if (defaultCase != null) {
|
||||
cases += "\ndefault:\n" + StringUtil.indent(defaultCase.prettyPrint(), 4);
|
||||
}
|
||||
return cases;
|
||||
}
|
||||
private String formatCases() {
|
||||
var cases = this.cases.stream()
|
||||
.map(GlslSwitch::prettyPrintCase)
|
||||
.collect(Collectors.joining("\n"));
|
||||
if (defaultCase != null) {
|
||||
cases += "\ndefault:\n" + StringUtil.indent(defaultCase.prettyPrint(), 4);
|
||||
}
|
||||
return cases;
|
||||
}
|
||||
|
||||
private static String prettyPrintCase(Pair<GlslExpr, GlslBlock> p) {
|
||||
var variant = p.first()
|
||||
|
@ -64,5 +60,4 @@ public class GlslSwitch implements GlslStmt {
|
|||
case %s:
|
||||
%s""".formatted(variant, StringUtil.indent(block, 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,36 +8,36 @@ import com.jozufozu.flywheel.lib.util.Pair;
|
|||
import com.jozufozu.flywheel.lib.util.StringUtil;
|
||||
|
||||
public class GlslUniformBlock implements GlslBuilder.Declaration {
|
||||
private String qualifier;
|
||||
private String qualifier;
|
||||
private String name;
|
||||
private final List<Pair<String, String>> members = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String prettyPrint() {
|
||||
@Override
|
||||
public String prettyPrint() {
|
||||
return """
|
||||
layout(%s) uniform %s {
|
||||
%s
|
||||
};""".formatted(qualifier, name, StringUtil.indent(formatMembers(), 4));
|
||||
}
|
||||
}
|
||||
|
||||
private String formatMembers() {
|
||||
return members.stream()
|
||||
.map(p -> p.first() + " " + p.second() + ";")
|
||||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
private String formatMembers() {
|
||||
return members.stream()
|
||||
.map(p -> p.first() + " " + p.second() + ";")
|
||||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
public GlslUniformBlock layout(String qualifier) {
|
||||
this.qualifier = qualifier;
|
||||
return this;
|
||||
}
|
||||
public GlslUniformBlock layout(String qualifier) {
|
||||
this.qualifier = qualifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GlslUniformBlock name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GlslUniformBlock member(String typeName, String variableName) {
|
||||
members.add(Pair.of(typeName, variableName));
|
||||
public GlslUniformBlock member(String typeName, String variableName) {
|
||||
members.add(Pair.of(typeName, variableName));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault
|
||||
package com.jozufozu.flywheel.backend.glsl;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
|
@ -9,7 +9,6 @@ import com.jozufozu.flywheel.backend.glsl.SourceLines;
|
|||
import com.jozufozu.flywheel.backend.glsl.span.Span;
|
||||
|
||||
public class ShaderStruct {
|
||||
|
||||
// https://regexr.com/61rpe
|
||||
public static final Pattern PATTERN = Pattern.compile("struct\\s+([\\w_]*)\\s*\\{(.*?)}\\s*([\\w_]*)?\\s*;\\s", Pattern.DOTALL);
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.jozufozu.flywheel.backend.glsl.span;
|
|||
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceFile;
|
||||
import com.jozufozu.flywheel.backend.glsl.SourceLines;
|
||||
|
||||
|
@ -125,7 +123,7 @@ public abstract class Span implements CharSequence, Comparable<Span> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull Span o) {
|
||||
public int compareTo(Span o) {
|
||||
return Integer.compareUnsigned(startIndex(), o.startIndex());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class StringSpan extends Span {
|
|||
|
||||
@Override
|
||||
public Span subSpan(int from, int to) {
|
||||
return new StringSpan(in, start.pos() + from, start.pos() + to);
|
||||
return new StringSpan(in, start.pos() + from, start.pos() + to);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
|
@ -106,7 +105,7 @@ public class ParallelTaskExecutor implements TaskExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NotNull Runnable task) {
|
||||
public void execute(Runnable task) {
|
||||
if (!running.get()) {
|
||||
throw new IllegalStateException("Executor is stopped");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.jozufozu.flywheel.impl.visualization;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.FrustumIntersection;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
|
@ -9,7 +8,6 @@ import com.jozufozu.flywheel.api.event.RenderContext;
|
|||
import net.minecraft.core.Vec3i;
|
||||
|
||||
public record FrameContext(double cameraX, double cameraY, double cameraZ, FrustumIntersection frustum, float partialTick) {
|
||||
@NotNull
|
||||
public static FrameContext create(RenderContext context, Vec3i renderOrigin) {
|
||||
var cameraPos = context.camera()
|
||||
.getPosition();
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.jozufozu.flywheel.impl.visualization.storage;
|
|||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.task.Plan;
|
||||
import com.jozufozu.flywheel.api.task.TaskExecutor;
|
||||
import com.jozufozu.flywheel.lib.task.NestedPlan;
|
||||
|
@ -13,7 +11,6 @@ import com.jozufozu.flywheel.lib.task.UnitPlan;
|
|||
|
||||
public class VisualUpdatePlan<C> implements SimplyComposedPlan<C> {
|
||||
private final Supplier<List<Plan<C>>> initializer;
|
||||
@NotNull
|
||||
private Plan<C> plan = UnitPlan.of();
|
||||
private boolean initialized = false;
|
||||
private boolean needsSimplify = true;
|
||||
|
|
|
@ -205,7 +205,7 @@ public class MutableBox implements Box {
|
|||
maxZ = Math.min(this.maxZ, other.getMaxZ());
|
||||
}
|
||||
|
||||
public void fixMinMax() {
|
||||
public void fixMinMax() {
|
||||
int minX = Math.min(this.minX, this.maxX);
|
||||
int minY = Math.min(this.minY, this.maxY);
|
||||
int minZ = Math.min(this.minZ, this.maxZ);
|
||||
|
|
|
@ -12,8 +12,8 @@ import com.dreizak.miniball.highdim.Miniball;
|
|||
import com.dreizak.miniball.model.PointSet;
|
||||
import com.jozufozu.flywheel.api.material.Material;
|
||||
import com.jozufozu.flywheel.api.model.Mesh;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexView;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexView;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexViewProviderRegistry;
|
||||
import com.jozufozu.flywheel.lib.material.Materials;
|
||||
import com.jozufozu.flywheel.lib.memory.MemoryBlock;
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.jozufozu.flywheel.lib.model.baked;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
|
@ -51,7 +49,6 @@ public class PartialModel {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return getLocation()
|
||||
.toString();
|
||||
|
|
|
@ -5,4 +5,12 @@
|
|||
* interface, but do not need to create additional closure objects to translate when the consumer wishes to ignore
|
||||
* the context object.
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package com.jozufozu.flywheel.lib.task.functional;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import net.minecraft.FieldsAreNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.jozufozu.flywheel.lib.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
@ -55,7 +53,6 @@ public final class ResourceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toDebugFileNameNoExtension(ResourceLocation resourceLocation) {
|
||||
var stringLoc = resourceLocation.toString();
|
||||
return stringLoc.substring(0, stringLoc.lastIndexOf('.'))
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.jozufozu.flywheel.lib.visual;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.visual.BlockEntityVisual;
|
||||
import com.jozufozu.flywheel.api.visualization.BlockEntityVisualizer;
|
||||
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
|
||||
|
@ -45,7 +43,7 @@ public class SimpleBlockEntityVisualizer<T extends BlockEntity> implements Block
|
|||
|
||||
@FunctionalInterface
|
||||
public interface Factory<T extends BlockEntity> {
|
||||
@NotNull BlockEntityVisual<? super T> create(VisualizationContext ctx, T blockEntity);
|
||||
BlockEntityVisual<? super T> create(VisualizationContext ctx, T blockEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.jozufozu.flywheel.lib.visual;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.api.visual.EntityVisual;
|
||||
import com.jozufozu.flywheel.api.visualization.EntityVisualizer;
|
||||
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
|
||||
|
@ -45,7 +43,7 @@ public class SimpleEntityVisualizer<T extends Entity> implements EntityVisualize
|
|||
|
||||
@FunctionalInterface
|
||||
public interface Factory<T extends Entity> {
|
||||
@NotNull EntityVisual<? super T> create(VisualizationContext ctx, T entity);
|
||||
EntityVisual<? super T> create(VisualizationContext ctx, T entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,7 +70,7 @@ public class MinecartVisual<T extends AbstractMinecart> extends AbstractEntityVi
|
|||
return null;
|
||||
}
|
||||
|
||||
return instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.block(blockState), RenderStage.AFTER_ENTITIES)
|
||||
return instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.block(blockState), RenderStage.AFTER_ENTITIES)
|
||||
.createInstance();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ license = "MIT"
|
|||
|
||||
[[mods]]
|
||||
modId = "flywheel"
|
||||
# The Implementation-Version property in the jar's MANIFEST.MF file will be used as the mod version at runtime
|
||||
version = "${mod_version}"
|
||||
displayName = "Flywheel"
|
||||
logoFile = "logo.png"
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.FileNotFoundException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -21,7 +20,6 @@ public class MockShaderSources extends ShaderSources {
|
|||
sources.put(loc, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LoadResult load(ResourceLocation loc) {
|
||||
var maybeFound = sources.get(loc);
|
||||
|
|
|
@ -6,8 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -22,7 +20,6 @@ public class TestBase {
|
|||
return list.get(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <E extends LoadError> E findAndAssertError(Class<E> clazz, MockShaderSources sources, ResourceLocation loc) {
|
||||
var result = sources.find(loc);
|
||||
var failure = assertInstanceOf(LoadResult.Failure.class, result);
|
||||
|
@ -40,13 +37,11 @@ public class TestBase {
|
|||
return assertInstanceOf(finalErrType, pair.second());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SourceFile findAndAssertSuccess(MockShaderSources sources, ResourceLocation loc) {
|
||||
var result = sources.find(loc);
|
||||
return assertSuccessAndUnwrap(loc, result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SourceFile assertSuccessAndUnwrap(ResourceLocation expectedName, LoadResult result) {
|
||||
assertInstanceOf(LoadResult.Success.class, result);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.jozufozu.flywheel.backend.glsl;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -62,7 +61,6 @@ public class TestErrorMessages extends TestBase {
|
|||
assertEquals(expected.trim(), message.trim());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ErrorBuilder assertErrorAndGetMessage(MockShaderSources sources, ResourceLocation loc) {
|
||||
var result = sources.find(loc);
|
||||
var failure = assertInstanceOf(LoadResult.Failure.class, result);
|
||||
|
|
Loading…
Reference in a new issue