mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-25 14:44:28 +00:00
initial commit for gl-fences (#2285)
This commit is contained in:
1 parent
69124e3f2f
commit
73d61d385c
16 files changed
+115
-72
No files matched your search
@@ -323,7 +323,7 @@ public class BatchingFontRenderer {
|
||||
|
||||
public static void endFrame() {
|
||||
if (streamRing != null) {
|
||||
streamRing.postDraw();
|
||||
streamRing.endFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.ffp.ShaderManager;
|
||||
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
|
||||
import com.gtnewhorizons.angelica.glsm.profiling.TracyBackend;
|
||||
import com.gtnewhorizons.angelica.glsm.streaming.PersistentStreamingBuffer;
|
||||
import com.gtnewhorizons.angelica.glsm.streaming.TessellatorStreamingDrawer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.rendering.FramePacer;
|
||||
@@ -45,6 +46,7 @@ public final class TracyFramePlots {
|
||||
private static final PlotDelta P_GL_ORPHAN_FALLBACKS = new PlotDelta("gl.orphanFallbacks");
|
||||
private static final PlotDelta P_GL_STREAM_CONTIGUOUS = new PlotDelta("gl.streamContiguous");
|
||||
private static final PlotDelta P_GL_RING_WRAPS = new PlotDelta("gl.ringWraps");
|
||||
private static final PlotDelta P_GL_ALL_RING_FENCES = new PlotDelta("gl.allRingFences");
|
||||
private static final long P_GL_SECTION_META_BYTES = Tracy.plotHandle("gl.sectionMetaBytes", TracyBackend.PLOT_FORMAT_MEMORY);
|
||||
|
||||
private static final long P_SHADOW_RELAY_FRAMES = Tracy.plotHandle("shadow.relayFrames");
|
||||
@@ -200,6 +202,7 @@ public final class TracyFramePlots {
|
||||
P_GL_ORPHAN_FALLBACKS.plot(TessellatorStreamingDrawer.orphanFallbacks);
|
||||
P_GL_STREAM_CONTIGUOUS.plot(TessellatorStreamingDrawer.streamContiguous);
|
||||
P_GL_RING_WRAPS.plot(TessellatorStreamingDrawer.ringWraps());
|
||||
P_GL_ALL_RING_FENCES.plot(PersistentStreamingBuffer.getFencesIssuedByAllRings());
|
||||
Tracy.plotInt(P_GL_SECTION_META_BYTES, TerrainDrawStats.takeSectionMetaBytes());
|
||||
Tracy.plotInt(P_SHADOW_RELAY_FRAMES, ShadowRenderer.SHADOW_TERRAIN_RELAID ? 1 : 0);
|
||||
Tracy.plotInt(P_TERRAIN_DRAW_COMMANDS, TerrainDrawStats.takeCommandsSubmitted());
|
||||
|
||||
@@ -60,7 +60,6 @@ public final class ParticleInstancer {
|
||||
private static DeferredWorldRenderingPipeline unavailableFor;
|
||||
private static DeferredWorldRenderingPipeline deferred;
|
||||
private static Tessellator run;
|
||||
private static boolean ringUsedThisLayer;
|
||||
|
||||
private static float rotX;
|
||||
private static float rotXZ;
|
||||
@@ -180,7 +179,6 @@ public final class ParticleInstancer {
|
||||
}
|
||||
layerActive = false;
|
||||
Throwable failure = null;
|
||||
ringUsedThisLayer = false;
|
||||
try {
|
||||
if (groupCount > 0) {
|
||||
restoreDepth = GLStateManager.pushState(StateSet.BATCH);
|
||||
@@ -212,13 +210,6 @@ public final class ParticleInstancer {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ringUsedThisLayer) {
|
||||
try {
|
||||
ring().postDraw();
|
||||
} catch (Throwable t) {
|
||||
failure = RenderFailures.suppress(failure, t);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < groupCount; i++) {
|
||||
final ByteBuffer list = GROUP_POOL.get(i).list;
|
||||
if (list != null) list.clear();
|
||||
@@ -227,7 +218,6 @@ public final class ParticleInstancer {
|
||||
deferred = null;
|
||||
run = null;
|
||||
layerStarted = false;
|
||||
ringUsedThisLayer = false;
|
||||
}
|
||||
RenderFailures.rethrowWrapped(failure);
|
||||
}
|
||||
@@ -253,7 +243,6 @@ public final class ParticleInstancer {
|
||||
run = null;
|
||||
unavailableFor = null;
|
||||
groupCount = 0;
|
||||
ringUsedThisLayer = false;
|
||||
for (int i = 0; i < GROUP_POOL.size(); i++) {
|
||||
GROUP_POOL.get(i).list = null;
|
||||
}
|
||||
@@ -297,7 +286,6 @@ public final class ParticleInstancer {
|
||||
}
|
||||
}
|
||||
|
||||
ringUsedThisLayer = true;
|
||||
final long base = ring().upload(list, STRIDE);
|
||||
list.clear();
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ public final class InstanceRing {
|
||||
private PersistentStreamingBuffer persistentRing;
|
||||
private OrphanStreamingBuffer orphanRing;
|
||||
private boolean initialized;
|
||||
private boolean usedThisFrame;
|
||||
private boolean lastUploadKept;
|
||||
private int bufferId;
|
||||
|
||||
@@ -19,7 +18,6 @@ public final class InstanceRing {
|
||||
initialized = true;
|
||||
persistentRing = PersistentStreamingBuffer.createOrNull(PersistentStreamingBuffer.DEFAULT_CAPACITY);
|
||||
}
|
||||
usedThisFrame = true;
|
||||
if (persistentRing != null) {
|
||||
final int index = persistentRing.upload(data, stride);
|
||||
if (index >= 0) {
|
||||
@@ -36,18 +34,19 @@ public final class InstanceRing {
|
||||
}
|
||||
|
||||
public int keptUploadsEpoch() {
|
||||
return lastUploadKept && persistentRing != null ? persistentRing.getWraps() : -1;
|
||||
if (!lastUploadKept || persistentRing == null) return -1;
|
||||
// Once a fence covers an upload, the ring may reuse that range while a later redraw still reads it.
|
||||
return persistentRing.getFencesIssued() & Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public int bufferId() {
|
||||
return bufferId;
|
||||
}
|
||||
|
||||
public void postDraw() {
|
||||
if (usedThisFrame && persistentRing != null) {
|
||||
persistentRing.postDraw();
|
||||
public void endFrame() {
|
||||
if (persistentRing != null) {
|
||||
persistentRing.endFrame();
|
||||
}
|
||||
usedThisFrame = false;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
@@ -60,7 +59,6 @@ public final class InstanceRing {
|
||||
orphanRing = null;
|
||||
}
|
||||
initialized = false;
|
||||
usedThisFrame = false;
|
||||
lastUploadKept = false;
|
||||
bufferId = 0;
|
||||
}
|
||||
|
||||
@@ -311,10 +311,6 @@ final class InstancedTemplateRenderer {
|
||||
return extVbo;
|
||||
}
|
||||
|
||||
void endFrame() {
|
||||
ring.postDraw();
|
||||
}
|
||||
|
||||
void retire(TemplateBuffer template) {
|
||||
retired.add(template);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public final class ModelPartBatcher {
|
||||
private static final long SWEEP_INTERVAL_MS = 5_000L;
|
||||
|
||||
private static final Tracy.ZoneId Z_ENTITY_LAYER_LOOP = Tracy.zoneId("entityLayerLoop", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_ENTITY_DEFERRED = Tracy.zoneId("entityDeferred", Tracy.COLOR_CLIENT);
|
||||
|
||||
private final AngelicaBufferSource bufferSource = new AngelicaBufferSource();
|
||||
private final AngelicaBufferSource entitySource = new AngelicaBufferSource();
|
||||
@@ -309,9 +310,6 @@ public final class ModelPartBatcher {
|
||||
if (wrapEntities) GbufferPrograms.endEntities();
|
||||
}
|
||||
}
|
||||
if (instancedThisCycle && !hold) {
|
||||
TesrBatchRenderer.INSTANCE.instancedRenderer.endFrame();
|
||||
}
|
||||
if (!TesrBatchRenderer.INSTANCE.hasPendingGeometry()) {
|
||||
BatchingFontRenderer.flushDeferredText();
|
||||
}
|
||||
@@ -337,6 +335,7 @@ public final class ModelPartBatcher {
|
||||
if (!entityTranslucentsHeld) return;
|
||||
entityTranslucentsHeld = false;
|
||||
BatchStateGuard.suspend();
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_ENTITY_DEFERRED);
|
||||
try {
|
||||
final EntityRenderer entityRenderer = Minecraft.getMinecraft().entityRenderer;
|
||||
final int deferredDepth = GLStateManager.pushState(StateSet.BATCH);
|
||||
@@ -352,9 +351,6 @@ public final class ModelPartBatcher {
|
||||
if (wrap) GbufferPrograms.beginEntities();
|
||||
try {
|
||||
entitySource.endBatch(entityGroups);
|
||||
if (instancedThisCycle) {
|
||||
TesrBatchRenderer.INSTANCE.instancedRenderer.endFrame();
|
||||
}
|
||||
recycleAtlas();
|
||||
AngelicaBufferSource.rebindPass();
|
||||
} finally {
|
||||
|
||||
@@ -59,7 +59,6 @@ public final class TesrBatchRenderer {
|
||||
|
||||
private static final Tracy.ZoneId Z_TESR_OPAQUE = Tracy.zoneId("tesrOpaque", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_TESR_BATCH = Tracy.zoneId("tesrBatch", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_TESR_INSTANCED = Tracy.zoneId("tesrInstanced", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_TESR_TEXT = Tracy.zoneId("tesrText", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_TESR_DEFERRED = Tracy.zoneId("tesrDeferred", Tracy.COLOR_CLIENT);
|
||||
|
||||
@@ -388,7 +387,6 @@ public final class TesrBatchRenderer {
|
||||
deferredFlushPending = false;
|
||||
pendingDeferredHook = null;
|
||||
bufferSource.endBatch(hook);
|
||||
instancedRenderer.endFrame();
|
||||
BatchingFontRenderer.flushDeferredText();
|
||||
}
|
||||
|
||||
@@ -413,12 +411,6 @@ public final class TesrBatchRenderer {
|
||||
} finally {
|
||||
if (Tracy.ENABLED) Tracy.endZone();
|
||||
}
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_TESR_INSTANCED);
|
||||
try {
|
||||
instancedRenderer.endFrame();
|
||||
} finally {
|
||||
if (Tracy.ENABLED) Tracy.endZone();
|
||||
}
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_TESR_TEXT);
|
||||
try {
|
||||
BatchingFontRenderer.flushDeferredText();
|
||||
@@ -462,7 +454,6 @@ public final class TesrBatchRenderer {
|
||||
}
|
||||
try {
|
||||
bufferSource.endBatch(hook);
|
||||
instancedRenderer.endFrame();
|
||||
AngelicaBufferSource.rebindPass();
|
||||
BatchingFontRenderer.flushDeferredText();
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user