Skip to main content

Overview

The OpenGL backend implements the Graphics Abstraction Layer (GAL) using OpenGL 4.5 Core Profile and modern extensions. It translates high-level graphics commands from the GPU emulation layer into OpenGL API calls.
Ryujinx requires OpenGL 4.5 or higher with support for critical extensions like ARB_direct_state_access and ARB_shader_storage_buffer_object.

Architecture

OpenGLRenderer

The main renderer implementation that initializes and manages the OpenGL context.

Initialization

Hardware Capabilities

The renderer queries OpenGL implementation limits and available extensions:
The renderer detects GPU vendor and applies necessary workarounds:

Pipeline State Management

The Pipeline class implements IPipeline and manages all rendering state and resource bindings.

State Tracking

Drawing Operations

Pre/Post Draw Processing

Resource Management

Buffer Objects

Buffers are managed using Direct State Access (DSA) for efficiency:
Persistent Mapping: For frequently updated buffers, Ryujinx uses GL_MAP_PERSISTENT_BIT and GL_MAP_COHERENT_BIT flags to maintain mappings across draw calls, reducing driver overhead.

Texture Management

Textures are created with immutable storage for optimal performance:

Format Conversion

The FormatTable maps GAL formats to OpenGL formats:

Vertex Input State

The VertexArray class manages vertex buffer bindings and attribute configurations.

Vertex Array Objects

Framebuffer Management

Framebuffers bind color and depth/stencil attachments for rendering.

Shader Programs

Shader programs are compiled from GLSL generated by the shader translator.

Compute Shaders

Compute shader dispatch is straightforward:

Synchronization

OpenGL synchronization uses fence objects:

Performance Considerations

Direct State Access

Uses DSA (ARB_direct_state_access) to eliminate redundant bindings and reduce driver overhead

Persistent Mapping

Maps frequently updated buffers with persistent flags for zero-copy updates

Immutable Storage

Allocates textures with immutable storage (glTexStorage*) for driver optimization

State Tracking

Tracks OpenGL state to avoid redundant calls and minimize state changes

Debugging

References

Source Files

  • src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs
  • src/Ryujinx.Graphics.OpenGL/Pipeline.cs
  • src/Ryujinx.Graphics.OpenGL/Buffer.cs
  • src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs