Skip to content

GL: re-implement the RSP pipeline on top of magma#906

Open
snacchus wants to merge 1 commit into
DragonMinded:previewfrom
snacchus:gl-magma-port
Open

GL: re-implement the RSP pipeline on top of magma#906
snacchus wants to merge 1 commit into
DragonMinded:previewfrom
snacchus:gl-magma-port

Conversation

@snacchus

@snacchus snacchus commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

This PR completely replaces the RSP pipeline of the OpenGL implementation with an improved version that is based on magma. This results in overall greatly improved performance (up to ~4,6x less RSP time required has been measured).

Overview

The rspq overlay rsp_gl_pipeline has been removed and replaced with a magma vertex shader of the same name. Like the old overlay, the shader expects vertices in a fixed format, but flexible layout. Since magma works most efficiently when loading large batches of vertices, the new implementation therefore has to convert all vertex data into internal buffers before handing them off to magma. The data is converted on demand when draw calls are dispatched.

In some cases, whenever GL is able to track changes to vertex layout and vertex data, converted data may be retained and reused across frames. This is the case when using vertex buffer objects and vertex array objects in conjunction. This is consequently the most optimal way to render geometry now, as opposed to display lists with the old implementation.

Because best practices for optimal performance are changing with this re-implementation, drawing models with model64 will not be optimal for now. The performance benefits from the new implementation still outweigh this pessimization, however (see measurements below). An improved version of model64 will follow in a later PR.

Performance comparison

The following measurements were made on a real PAL N64.

This is the baseline, using the old RSP pipeline:
Profiler results: baseline

Compare with the new, magma based implementation without further modifications to model64:
Profiler results: new implementation with unoptimized mesh

And finally, the new implementation using an optimized version of model64:
Profiler results: new implementation with optimized mesh

Breaking changes

  • The currently bound GL_ELEMENT_ARRAY_BUFFER_ARB is no longer a global state and instead now scoped to the current vertex array object. This now correctly implements the GL specification.
  • Texture coordinates with 3 or more components don't work correctly in the new implementation. They are effectively treated as 2 components. Depending on demand, this will be fixed in the future.
  • Tex gen with GL_OBJECT_PLANE and GL_EYE_PLANE is no longer supported by the RSP pipeline. The CPU pipeline will be used instead.

Other changes

  • The new packed format GL_SHORT_5_6_5_N64 has been added and is available for use in glNormalPointer.
  • The custom hashtable implementation in obj_map.h has been removed and usages migrated to hashtable_internal.h.

@snacchus snacchus marked this pull request as ready for review June 14, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant