mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-22 10:57:55 +01:00
Simply struct
- Inline Instanced* and Batched* StructType - flw.dumpShaderSource need only be present - Make Backend's static fields screaming snake case
This commit is contained in:
parent
1765aa74f8
commit
d22f715f79
15 changed files with 56 additions and 87 deletions
|
@ -1,7 +0,0 @@
|
||||||
package com.jozufozu.flywheel.api.struct;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
|
||||||
|
|
||||||
public interface BatchedStructType<S> extends StructType<S> {
|
|
||||||
void transform(S d, ModelTransformer.Params b);
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.jozufozu.flywheel.api.struct;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.source.FileResolution;
|
|
||||||
|
|
||||||
public interface InstancedStructType<S> extends StructType<S> {
|
|
||||||
/**
|
|
||||||
* Create a {@link StructWriter} that will consume instances of S and write them to the given buffer.
|
|
||||||
*
|
|
||||||
* @param backing The buffer that the StructWriter will write to.
|
|
||||||
*/
|
|
||||||
StructWriter<S> getWriter(ByteBuffer backing);
|
|
||||||
|
|
||||||
FileResolution getInstanceShader();
|
|
||||||
}
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.jozufozu.flywheel.api.struct;
|
package com.jozufozu.flywheel.api.struct;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||||
|
import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
|
import com.jozufozu.flywheel.core.source.FileResolution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A StructType contains metadata for a specific instance struct that Flywheel can interface with.
|
* A StructType contains metadata for a specific instance struct that Flywheel can interface with.
|
||||||
|
@ -18,4 +22,15 @@ public interface StructType<S> {
|
||||||
*/
|
*/
|
||||||
BufferLayout getLayout();
|
BufferLayout getLayout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link StructWriter} that will consume instances of S and write them to the given buffer.
|
||||||
|
*
|
||||||
|
* @param backing The buffer that the StructWriter will write to.
|
||||||
|
*/
|
||||||
|
StructWriter<S> getWriter(ByteBuffer backing);
|
||||||
|
|
||||||
|
FileResolution getInstanceShader();
|
||||||
|
|
||||||
|
void transform(S d, ModelTransformer.Params b);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.jozufozu.flywheel.backend;
|
package com.jozufozu.flywheel.backend;
|
||||||
|
|
||||||
import java.lang.ref.Cleaner;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
@ -19,19 +17,19 @@ import net.minecraft.world.level.LevelAccessor;
|
||||||
public class Backend {
|
public class Backend {
|
||||||
public static final Logger LOGGER = LogUtils.getLogger();
|
public static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public static boolean dumpShaderSource = Boolean.getBoolean("flw.dumpShaderSource");
|
public static boolean DUMP_SHADER_SOURCE = System.getProperty("flw.dumpShaderSource") != null;
|
||||||
|
|
||||||
private static BackendType backendType;
|
private static BackendType TYPE;
|
||||||
|
|
||||||
private static ParallelTaskEngine taskEngine;
|
private static ParallelTaskEngine EXECUTOR;
|
||||||
|
|
||||||
private static final Loader loader = new Loader();
|
private static final Loader LOADER = new Loader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current Flywheel backend type.
|
* Get the current Flywheel backend type.
|
||||||
*/
|
*/
|
||||||
public static BackendType getBackendType() {
|
public static BackendType getBackendType() {
|
||||||
return backendType;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,12 +37,12 @@ public class Backend {
|
||||||
* @return A global Flywheel thread pool.
|
* @return A global Flywheel thread pool.
|
||||||
*/
|
*/
|
||||||
public static ParallelTaskEngine getTaskEngine() {
|
public static ParallelTaskEngine getTaskEngine() {
|
||||||
if (taskEngine == null) {
|
if (EXECUTOR == null) {
|
||||||
taskEngine = new ParallelTaskEngine("Flywheel");
|
EXECUTOR = new ParallelTaskEngine("Flywheel");
|
||||||
taskEngine.startWorkers();
|
EXECUTOR.startWorkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
return taskEngine;
|
return EXECUTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,15 +50,15 @@ public class Backend {
|
||||||
* (Meshlet, MDI, GL31 Draw Instanced are planned), this will name which one is in use.
|
* (Meshlet, MDI, GL31 Draw Instanced are planned), this will name which one is in use.
|
||||||
*/
|
*/
|
||||||
public static String getBackendDescriptor() {
|
public static String getBackendDescriptor() {
|
||||||
return backendType == null ? "Uninitialized" : backendType.getProperName();
|
return TYPE == null ? "Uninitialized" : TYPE.getProperName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void refresh() {
|
public static void refresh() {
|
||||||
backendType = chooseEngine();
|
TYPE = chooseEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOn() {
|
public static boolean isOn() {
|
||||||
return backendType != BackendType.OFF;
|
return TYPE != BackendType.OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canUseInstancing(@Nullable Level world) {
|
public static boolean canUseInstancing(@Nullable Level world) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class GlShader extends GlObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dumpSource(String source, ShaderType type) {
|
private void dumpSource(String source, ShaderType type) {
|
||||||
if (!Backend.dumpShaderSource) {
|
if (!Backend.DUMP_SHADER_SOURCE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.MaterialGroup;
|
import com.jozufozu.flywheel.api.MaterialGroup;
|
||||||
import com.jozufozu.flywheel.api.struct.BatchedStructType;
|
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.instancing.BatchDrawingTracker;
|
import com.jozufozu.flywheel.backend.instancing.BatchDrawingTracker;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
||||||
|
@ -17,7 +16,7 @@ public class BatchedMaterialGroup implements MaterialGroup {
|
||||||
|
|
||||||
protected final RenderType state;
|
protected final RenderType state;
|
||||||
|
|
||||||
private final Map<BatchedStructType<? extends InstanceData>, CPUInstancerFactory<?>> materials = new HashMap<>();
|
private final Map<StructType<? extends InstanceData>, CPUInstancerFactory<?>> materials = new HashMap<>();
|
||||||
private int vertexCount;
|
private int vertexCount;
|
||||||
private int instanceCount;
|
private int instanceCount;
|
||||||
|
|
||||||
|
@ -28,11 +27,7 @@ public class BatchedMaterialGroup implements MaterialGroup {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <D extends InstanceData> CPUInstancerFactory<D> material(StructType<D> type) {
|
public <D extends InstanceData> CPUInstancerFactory<D> material(StructType<D> type) {
|
||||||
if (type instanceof BatchedStructType<D> batched) {
|
return (CPUInstancerFactory<D>) materials.computeIfAbsent(type, CPUInstancerFactory::new);
|
||||||
return (CPUInstancerFactory<D>) materials.computeIfAbsent(batched, CPUInstancerFactory::new);
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException("Cannot use type '" + type + "' with CPU instancing.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(PoseStack stack, BatchDrawingTracker source, TaskEngine pool) {
|
public void render(PoseStack stack, BatchDrawingTracker source, TaskEngine pool) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.struct.BatchedStructType;
|
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.instancing.BatchDrawingTracker;
|
import com.jozufozu.flywheel.backend.instancing.BatchDrawingTracker;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Engine;
|
import com.jozufozu.flywheel.backend.instancing.Engine;
|
||||||
|
@ -21,17 +20,13 @@ import net.minecraft.core.Vec3i;
|
||||||
|
|
||||||
public class BatchingEngine implements Engine {
|
public class BatchingEngine implements Engine {
|
||||||
|
|
||||||
private final Map<BatchedStructType<? extends InstanceData>, CPUInstancerFactory<?>> factories = new HashMap<>();
|
private final Map<StructType<? extends InstanceData>, CPUInstancerFactory<?>> factories = new HashMap<>();
|
||||||
private final BatchDrawingTracker batchTracker = new BatchDrawingTracker();
|
private final BatchDrawingTracker batchTracker = new BatchDrawingTracker();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <D extends InstanceData> CPUInstancerFactory<D> factory(StructType<D> type) {
|
public <D extends InstanceData> CPUInstancerFactory<D> factory(StructType<D> type) {
|
||||||
if (type instanceof BatchedStructType<D> batched) {
|
return (CPUInstancerFactory<D>) factories.computeIfAbsent(type, CPUInstancerFactory::new);
|
||||||
return (CPUInstancerFactory<D>) factories.computeIfAbsent(batched, CPUInstancerFactory::new);
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException("Cannot use type '" + type + "' with CPU instancing.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing.batching;
|
package com.jozufozu.flywheel.backend.instancing.batching;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.struct.BatchedStructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
||||||
import com.jozufozu.flywheel.backend.model.DirectVertexConsumer;
|
import com.jozufozu.flywheel.backend.model.DirectVertexConsumer;
|
||||||
|
@ -14,7 +14,7 @@ public class CPUInstancer<D extends InstanceData> extends AbstractInstancer<D> {
|
||||||
//
|
//
|
||||||
// final ModelTransformer sbb;
|
// final ModelTransformer sbb;
|
||||||
|
|
||||||
public CPUInstancer(BatchedStructType<D> type) {
|
public CPUInstancer(StructType<D> type) {
|
||||||
super(type::create);
|
super(type::create);
|
||||||
// batchingType = type;
|
// batchingType = type;
|
||||||
//
|
//
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.Instancer;
|
import com.jozufozu.flywheel.api.Instancer;
|
||||||
import com.jozufozu.flywheel.api.InstancerFactory;
|
import com.jozufozu.flywheel.api.InstancerFactory;
|
||||||
import com.jozufozu.flywheel.api.struct.BatchedStructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.core.model.ModelSupplier;
|
import com.jozufozu.flywheel.core.model.ModelSupplier;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
@ -14,9 +14,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
public class CPUInstancerFactory<D extends InstanceData> implements InstancerFactory<D> {
|
public class CPUInstancerFactory<D extends InstanceData> implements InstancerFactory<D> {
|
||||||
|
|
||||||
protected final Map<ModelSupplier, CPUInstancer<D>> models;
|
protected final Map<ModelSupplier, CPUInstancer<D>> models;
|
||||||
private final BatchedStructType<D> type;
|
private final StructType<D> type;
|
||||||
|
|
||||||
public CPUInstancerFactory(BatchedStructType<D> type) {
|
public CPUInstancerFactory(StructType<D> type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
this.models = new HashMap<>();
|
this.models = new HashMap<>();
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.struct.InstancedStructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer;
|
||||||
|
@ -17,7 +17,7 @@ import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||||
public class GPUInstancer<D extends InstanceData> extends AbstractInstancer<D> {
|
public class GPUInstancer<D extends InstanceData> extends AbstractInstancer<D> {
|
||||||
|
|
||||||
final BufferLayout instanceFormat;
|
final BufferLayout instanceFormat;
|
||||||
final InstancedStructType<D> instancedType;
|
final StructType<D> instancedType;
|
||||||
|
|
||||||
GlBuffer vbo;
|
GlBuffer vbo;
|
||||||
int attributeBaseIndex;
|
int attributeBaseIndex;
|
||||||
|
@ -25,7 +25,7 @@ public class GPUInstancer<D extends InstanceData> extends AbstractInstancer<D> {
|
||||||
|
|
||||||
boolean anyToUpdate;
|
boolean anyToUpdate;
|
||||||
|
|
||||||
public GPUInstancer(InstancedStructType<D> type) {
|
public GPUInstancer(StructType<D> type) {
|
||||||
super(type::create);
|
super(type::create);
|
||||||
this.instanceFormat = type.getLayout();
|
this.instanceFormat = type.getLayout();
|
||||||
instancedType = type;
|
instancedType = type;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.Instancer;
|
import com.jozufozu.flywheel.api.Instancer;
|
||||||
import com.jozufozu.flywheel.api.InstancerFactory;
|
import com.jozufozu.flywheel.api.InstancerFactory;
|
||||||
import com.jozufozu.flywheel.api.material.Material;
|
import com.jozufozu.flywheel.api.material.Material;
|
||||||
import com.jozufozu.flywheel.api.struct.InstancedStructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.model.MeshPool;
|
import com.jozufozu.flywheel.backend.model.MeshPool;
|
||||||
import com.jozufozu.flywheel.core.model.ModelSupplier;
|
import com.jozufozu.flywheel.core.model.ModelSupplier;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
public class GPUInstancerFactory<D extends InstanceData> implements InstancerFactory<D> {
|
public class GPUInstancerFactory<D extends InstanceData> implements InstancerFactory<D> {
|
||||||
|
|
||||||
protected final Map<ModelSupplier, InstancedModel<D>> models = new HashMap<>();
|
protected final Map<ModelSupplier, InstancedModel<D>> models = new HashMap<>();
|
||||||
protected final InstancedStructType<D> type;
|
protected final StructType<D> type;
|
||||||
|
|
||||||
protected final List<InstancedModel<D>> uninitialized = new ArrayList<>();
|
protected final List<InstancedModel<D>> uninitialized = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class GPUInstancerFactory<D extends InstanceData> implements InstancerFac
|
||||||
public final Multimap<RenderType, Material> materials = HashMultimap.create();
|
public final Multimap<RenderType, Material> materials = HashMultimap.create();
|
||||||
public final Multimap<Material, Renderable> renderables = ArrayListMultimap.create();
|
public final Multimap<Material, Renderable> renderables = ArrayListMultimap.create();
|
||||||
|
|
||||||
public GPUInstancerFactory(InstancedStructType<D> type) {
|
public GPUInstancerFactory(StructType<D> type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
import com.jozufozu.flywheel.api.InstanceData;
|
||||||
import com.jozufozu.flywheel.api.material.Material;
|
import com.jozufozu.flywheel.api.material.Material;
|
||||||
import com.jozufozu.flywheel.api.struct.InstancedStructType;
|
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Engine;
|
import com.jozufozu.flywheel.backend.instancing.Engine;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
||||||
|
@ -44,7 +43,7 @@ public class InstancingEngine<P extends WorldProgram> implements Engine {
|
||||||
protected final ProgramCompiler<P> context;
|
protected final ProgramCompiler<P> context;
|
||||||
private MeshPool allocator;
|
private MeshPool allocator;
|
||||||
|
|
||||||
protected final Map<InstancedStructType<? extends InstanceData>, GPUInstancerFactory<?>> factories = new HashMap<>();
|
protected final Map<StructType<? extends InstanceData>, GPUInstancerFactory<?>> factories = new HashMap<>();
|
||||||
|
|
||||||
protected final Set<RenderType> toRender = new HashSet<>();
|
protected final Set<RenderType> toRender = new HashSet<>();
|
||||||
|
|
||||||
|
@ -62,11 +61,7 @@ public class InstancingEngine<P extends WorldProgram> implements Engine {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <D extends InstanceData> GPUInstancerFactory<D> factory(StructType<D> type) {
|
public <D extends InstanceData> GPUInstancerFactory<D> factory(StructType<D> type) {
|
||||||
if (type instanceof InstancedStructType<D> instanced) {
|
return (GPUInstancerFactory<D>) factories.computeIfAbsent(type, GPUInstancerFactory::new);
|
||||||
return (GPUInstancerFactory<D>) factories.computeIfAbsent(instanced, GPUInstancerFactory::new);
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException("Cannot use type '" + type + "' with GPU instancing.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,9 +103,9 @@ public class InstancingEngine<P extends WorldProgram> implements Engine {
|
||||||
Textures.bindActiveTextures();
|
Textures.bindActiveTextures();
|
||||||
CoreShaderInfo coreShaderInfo = getCoreShaderInfo();
|
CoreShaderInfo coreShaderInfo = getCoreShaderInfo();
|
||||||
|
|
||||||
for (Map.Entry<InstancedStructType<? extends InstanceData>, GPUInstancerFactory<?>> entry : factories.entrySet()) {
|
for (var entry : factories.entrySet()) {
|
||||||
InstancedStructType<? extends InstanceData> instanceType = entry.getKey();
|
var instanceType = entry.getKey();
|
||||||
GPUInstancerFactory<?> factory = entry.getValue();
|
var factory = entry.getValue();
|
||||||
|
|
||||||
var materials = factory.materials.get(type);
|
var materials = factory.materials.get(type);
|
||||||
for (Material material : materials) {
|
for (Material material : materials) {
|
||||||
|
@ -146,7 +141,7 @@ public class InstancingEngine<P extends WorldProgram> implements Engine {
|
||||||
return coreShaderInfo;
|
return coreShaderInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected P setup(InstancedStructType<?> instanceType, Material material, CoreShaderInfo coreShaderInfo, double camX, double camY, double camZ, Matrix4f viewProjection, ClientLevel level) {
|
protected P setup(StructType<?> instanceType, Material material, CoreShaderInfo coreShaderInfo, double camX, double camY, double camZ, Matrix4f viewProjection, ClientLevel level) {
|
||||||
float alphaDiscard = coreShaderInfo.alphaDiscard();
|
float alphaDiscard = coreShaderInfo.alphaDiscard();
|
||||||
if (alphaDiscard == 0) {
|
if (alphaDiscard == 0) {
|
||||||
alphaDiscard = 0.0001f;
|
alphaDiscard = 0.0001f;
|
||||||
|
|
|
@ -2,17 +2,13 @@ package com.jozufozu.flywheel.core.crumbling;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.InstanceData;
|
|
||||||
import com.jozufozu.flywheel.api.material.Material;
|
import com.jozufozu.flywheel.api.material.Material;
|
||||||
import com.jozufozu.flywheel.api.struct.InstancedStructType;
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlStateTracker;
|
import com.jozufozu.flywheel.backend.gl.GlStateTracker;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
|
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine;
|
import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine;
|
||||||
import com.jozufozu.flywheel.backend.instancing.instancing.GPUInstancerFactory;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
|
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
|
||||||
import com.jozufozu.flywheel.backend.instancing.instancing.Renderable;
|
import com.jozufozu.flywheel.backend.instancing.instancing.Renderable;
|
||||||
import com.jozufozu.flywheel.core.Contexts;
|
import com.jozufozu.flywheel.core.Contexts;
|
||||||
|
@ -182,9 +178,9 @@ public class CrumblingRenderer {
|
||||||
Textures.bindActiveTextures();
|
Textures.bindActiveTextures();
|
||||||
CoreShaderInfo coreShaderInfo = getCoreShaderInfo();
|
CoreShaderInfo coreShaderInfo = getCoreShaderInfo();
|
||||||
|
|
||||||
for (Map.Entry<InstancedStructType<? extends InstanceData>, GPUInstancerFactory<?>> entry : factories.entrySet()) {
|
for (var entry : factories.entrySet()) {
|
||||||
InstancedStructType<? extends InstanceData> instanceType = entry.getKey();
|
var instanceType = entry.getKey();
|
||||||
GPUInstancerFactory<?> factory = entry.getValue();
|
var factory = entry.getValue();
|
||||||
|
|
||||||
var materials = factory.materials.get(type);
|
var materials = factory.materials.get(type);
|
||||||
for (Material material : materials) {
|
for (Material material : materials) {
|
||||||
|
|
|
@ -2,8 +2,7 @@ package com.jozufozu.flywheel.core.structs.model;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.struct.BatchedStructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.api.struct.InstancedStructType;
|
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||||
import com.jozufozu.flywheel.core.layout.CommonItems;
|
import com.jozufozu.flywheel.core.layout.CommonItems;
|
||||||
|
@ -11,7 +10,7 @@ import com.jozufozu.flywheel.core.model.ModelTransformer;
|
||||||
import com.jozufozu.flywheel.core.source.FileResolution;
|
import com.jozufozu.flywheel.core.source.FileResolution;
|
||||||
import com.jozufozu.flywheel.core.structs.InstanceShaders;
|
import com.jozufozu.flywheel.core.structs.InstanceShaders;
|
||||||
|
|
||||||
public class ModelType implements InstancedStructType<ModelData>, BatchedStructType<ModelData> {
|
public class ModelType implements StructType<ModelData> {
|
||||||
|
|
||||||
public static final BufferLayout FORMAT = BufferLayout.builder()
|
public static final BufferLayout FORMAT = BufferLayout.builder()
|
||||||
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
|
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
|
||||||
|
|
|
@ -2,8 +2,7 @@ package com.jozufozu.flywheel.core.structs.oriented;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.struct.BatchedStructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.api.struct.InstancedStructType;
|
|
||||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||||
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
import com.jozufozu.flywheel.core.layout.BufferLayout;
|
||||||
import com.jozufozu.flywheel.core.layout.CommonItems;
|
import com.jozufozu.flywheel.core.layout.CommonItems;
|
||||||
|
@ -12,7 +11,7 @@ import com.jozufozu.flywheel.core.source.FileResolution;
|
||||||
import com.jozufozu.flywheel.core.structs.InstanceShaders;
|
import com.jozufozu.flywheel.core.structs.InstanceShaders;
|
||||||
import com.mojang.math.Quaternion;
|
import com.mojang.math.Quaternion;
|
||||||
|
|
||||||
public class OrientedType implements InstancedStructType<OrientedData>, BatchedStructType<OrientedData> {
|
public class OrientedType implements StructType<OrientedData> {
|
||||||
|
|
||||||
public static final BufferLayout FORMAT = BufferLayout.builder()
|
public static final BufferLayout FORMAT = BufferLayout.builder()
|
||||||
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
|
.addItems(CommonItems.LIGHT, CommonItems.RGBA)
|
||||||
|
|
Loading…
Reference in a new issue