Package
io.homo.superresolution.api
1. API Entry Point
Core entry class: SuperResolutionAPI
EVENT_BUS: Unified event bus (based on NeoForged EventBus).getOriginMinecraftFrameBuffer(): Returns the original Minecraft render target.getMinecraftFrameBuffer(): Returns the current render target.getScreenWidth() / getScreenHeight(): Screen resolution.getRenderWidth() / getRenderHeight(): Actual render resolution.getCurrentAlgorithmDescription(): Description of the current algorithm.getCurrentAlgorithm(): Current algorithm instance.debugRenderdocCapture*()anddebugRenderdocTriggerCapture(): RenderDoc debug capture entry points.
2. Listening to Events
SuperResolutionAPI.EVENT_BUS.addListener((LevelRenderStartEvent event) -> {
// your code here
});3. Custom Upscaling Algorithm
3.1 Extending AbstractAlgorithm
You are required to implement the following methods:
init(): Initialize algorithm resources (shaders, buffers, contexts, etc.). Called only once when the algorithm is created.dispatch(DispatchResource dispatchResource): Executed every frame. The default implementation writes intoresources; you may callsuper.dispatch(...)first.resize(int width, int height): Update internal resources when the resolution changes. Called whenever the resolution changes.destroy(): Release resources. Called when the game shuts down or the algorithm is unloaded.getOutputFrameBuffer(): Returns the output framebuffer.
NOTE
AlgorithmDescription.createNewInstance() automatically calls init(); ensure that a no-argument constructor is available.
NOTE
AlgorithmRegistry.isAlgorithmSupported(...) has caching semantics; consider cache invalidation if runtime capabilities change.
Optional overrides:
getJitterOffset(...): Returns the jitter offset (default0, 0; unit: pixels; range[-1.0, 1.0]).isSupportJitter(): Whether jitter is supported (defaultfalse).getQualityPresets(): Returns the list of available quality presets (default empty).isCustomUpscaleRatio(): Whether a custom upscale ratio is allowed (defaulttrue).getOutputTextureId(): Directly retrieves the output color texture ID (typically obtained from the output FBO).
3.2 Input Resources
InputResourceSet is a record that holds the set of input textures:
colorTexture— Color texturedepthTexture— Depth texturemotionVectorsTexture— Motion vector texture. Format: RG16F, containing screen-space motion vectors (x: horizontal, y: vertical; range[-1.0, 1.0])
Access these in dispatch(...) via dispatchResource.resources().
3.3 Quality Presets
QualityPreset describes an available quality tier:
upscaleRatio: Upscale multiplier.name: Display name (Component).codeName: Internal code name (must be unique across all algorithms).
This class uses a fluent setter design and can be constructed as follows:
QualityPreset preset = new QualityPreset()
.setCodeName("quality")
.setName(Component.literal("Quality"))
.setUpscaleRatio(1.5f);4. Algorithm Registration and Discovery
4.1 AlgorithmDescription<T>
Describes a registerable algorithm.
Fields:
briefName: Short name.codeName: Unique code name (used as the index key).displayName: Display name.requirement: Runtime environment requirements.extraResources: Additional resources (e.g. DLL files).
Methods:
createNewInstance(): Creates a new algorithm instance via reflection and automatically callsinit().getId(): Returns the internal random UUID.
4.2 AlgorithmRegistry
registry(AlgorithmDescription<?>): Registers an algorithm.getAlgorithmMap(): Returns the current registry map.getDescriptionByID(String id): Looks up a description bycodeName.isAlgorithmSupported(AlgorithmDescription<?>): Checks and caches algorithm availability (based onRequirement.check()).
Note: The registry performs built-in algorithm registration during static initialization, after which
AlgorithmRegisterEventis fired. If you want to register a custom algorithm, listen to this event.
5. Events (api.event)
The following events can be subscribed to via SuperResolutionAPI.EVENT_BUS:
AlgorithmRegisterEvent: Fired after the algorithm registration process completes. Register custom algorithms here.AlgorithmDispatchEvent: Fired before algorithm execution. Provides:getAlgorithm()getDispatchResource()
AlgorithmDispatchFinishEvent: Fired after algorithm execution. Provides:getAlgorithm()getOutput()(output FBO)
AlgorithmResizeEvent: Fired when the screen resolution is updated and an algorithm instance exists. Provides:screenWidth / screenHeightrenderWidth / renderHeightgetAlgorithm()
LevelRenderStartEvent: Fired when world rendering begins.LevelRenderEndEvent: Fired when world rendering ends.ConfigChangedEvent: Fired when the configuration changes (avoid relying on this where possible).
NOTE
The exact trigger points of LevelRenderStart / LevelRenderEnd may be affected by capture mode.
6. Requirement System (api.utils.Requirement)
Requirement is used to declare algorithm runtime prerequisites and supports fluent builder-style construction:
- OpenGL requirements:
glVersion(major, minor)glMajorVersion(...)glMinorVersion(...)requiredGlExtension("...")
- Vulkan requirements:
requireVulkan(true)vulkanVersion(major, minor, patch)requireVulkanDeviceExtension("...")
- Platform and environment:
addSupportedOS(...)developmentEnvironment(true / false)
- Custom conditions:
isTrue(Supplier<Boolean>)isFalse(Supplier<Boolean>)
Validation entry points:
check()returns aRequirement.Result.result.support()directly indicates whether all conditions are met.getMissingGlExtensions() / getMissingVkExtensions()can be used to report missing capabilities.
NOTE
AlgorithmRegistry.isAlgorithmSupported(...) has caching semantics; consider cache invalidation if runtime capabilities change.
7. Extra Resource Downloads (api.registry.ExtraResource*)
7.1 ExtraResource
Represents a single external resource (e.g. gugugaga.dll):
check(DirectoryEnsurer): Checks whether the resource already exists in the target directory.get(...): Downloads or copies the resource based on its source (local or remote).
Resource source ResourceSource:
Type.Local: Copy from a local path.Type.Remote: Download via HTTP.
Error codes ErrorCode:
NetworkError— Network errorFileNotFound— Resource not foundPermissionDenied— Insufficient permissionsCancelled— Cancelled by userUnknownError— Unknown error
7.2 ExtraResources
Methods:
checkAll(directory): Checks for missing resources and returns the missing list.getAll(...): Batch-fetches resources (supportsasyncmulti-threading).cancelAll(): Cancels all ongoing downloads.resetCancelState() / isCancelled(): Cancel state management.
Callbacks:
ResourcesProgressListener— Download progress callbackResourcesFinishListener— Download completion callbackResourcesErrorListener— Download error callback