Rework rendering pipeline to make better use of multithreading

Move OpenGL frame to ARGB conversion to processing threads
Move video exporting to processing threads
Skip creation of BufferedImage and instead use ByteBuffer with ARGB content directly
This commit is contained in:
johni0702
2015-07-15 14:21:18 +02:00
parent 3a2c35cb22
commit 7fd429e25f
44 changed files with 1142 additions and 1244 deletions

View File

@@ -0,0 +1,73 @@
package eu.crushedpixel.replaymod.video.rendering;
import eu.crushedpixel.replaymod.settings.RenderOptions;
import eu.crushedpixel.replaymod.video.capturer.*;
import eu.crushedpixel.replaymod.video.entity.CubicEntityRenderer;
import eu.crushedpixel.replaymod.video.entity.CustomEntityRenderer;
import eu.crushedpixel.replaymod.video.entity.StereoscopicEntityRenderer;
import eu.crushedpixel.replaymod.video.frame.ARGBFrame;
import eu.crushedpixel.replaymod.video.frame.CubicOpenGlFrame;
import eu.crushedpixel.replaymod.video.frame.OpenGlFrame;
import eu.crushedpixel.replaymod.video.frame.StereoscopicOpenGlFrame;
import eu.crushedpixel.replaymod.video.processor.CubicToARGBProcessor;
import eu.crushedpixel.replaymod.video.processor.EquirectangularToARGBProcessor;
import eu.crushedpixel.replaymod.video.processor.OpenGlToARGBProcessor;
import eu.crushedpixel.replaymod.video.processor.StereoscopicToARGBProcessor;
import lombok.experimental.UtilityClass;
@UtilityClass
public class Pipelines {
public enum Preset {
DEFAULT, STEREOSCOPIC, CUBIC, EQUIRECTANGULAR
}
public static Pipeline newPipeline(Preset preset, RenderInfo renderInfo, FrameConsumer<ARGBFrame> consumer) {
switch (preset) {
case DEFAULT:
return newDefaultPipeline(renderInfo, consumer);
case STEREOSCOPIC:
return newStereoscopicPipeline(renderInfo, consumer);
case CUBIC:
return newCubicPipeline(renderInfo, consumer);
case EQUIRECTANGULAR:
return newEquirectangularPipeline(renderInfo, consumer);
}
throw new UnsupportedOperationException("Unknown preset: " + preset);
}
public static Pipeline<OpenGlFrame, ARGBFrame> newDefaultPipeline(RenderInfo renderInfo, FrameConsumer<ARGBFrame> consumer) {
RenderOptions options = renderInfo.getRenderOptions();
return new Pipeline<OpenGlFrame, ARGBFrame>(
new SimpleOpenGlFrameCapturer(new CustomEntityRenderer<CaptureData>(options), renderInfo),
new OpenGlToARGBProcessor(),
consumer
);
}
public static Pipeline<StereoscopicOpenGlFrame, ARGBFrame> newStereoscopicPipeline(RenderInfo renderInfo, FrameConsumer<ARGBFrame> consumer) {
RenderOptions options = renderInfo.getRenderOptions();
return new Pipeline<StereoscopicOpenGlFrame, ARGBFrame>(
new StereoscopicOpenGlFrameCapturer(new StereoscopicEntityRenderer(options), renderInfo),
new StereoscopicToARGBProcessor(),
consumer
);
}
public static Pipeline<CubicOpenGlFrame, ARGBFrame> newCubicPipeline(RenderInfo renderInfo, FrameConsumer<ARGBFrame> consumer) {
RenderOptions options = renderInfo.getRenderOptions();
return new Pipeline<CubicOpenGlFrame, ARGBFrame>(
new CubicOpenGlFrameCapturer(new CubicEntityRenderer(options), renderInfo, options.getWidth() / 4),
new CubicToARGBProcessor(),
consumer
);
}
public static Pipeline<CubicOpenGlFrame, ARGBFrame> newEquirectangularPipeline(RenderInfo renderInfo, FrameConsumer<ARGBFrame> consumer) {
RenderOptions options = renderInfo.getRenderOptions();
return new Pipeline<CubicOpenGlFrame, ARGBFrame>(
new CubicOpenGlFrameCapturer(new CubicEntityRenderer(options), renderInfo, options.getWidth() / 4),
new EquirectangularToARGBProcessor(options.getWidth() / 4),
consumer
);
}
}