GL: re-implement the RSP pipeline on top of magma#906
Open
snacchus wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_pipelinehas 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:

Compare with the new, magma based implementation without further modifications to model64:

And finally, the new implementation using an optimized version of model64:

Breaking changes
GL_ELEMENT_ARRAY_BUFFER_ARBis no longer a global state and instead now scoped to the current vertex array object. This now correctly implements the GL specification.GL_OBJECT_PLANEandGL_EYE_PLANEis no longer supported by the RSP pipeline. The CPU pipeline will be used instead.Other changes
GL_SHORT_5_6_5_N64has been added and is available for use inglNormalPointer.obj_map.hhas been removed and usages migrated tohashtable_internal.h.