# intel/libvpl architecture

> Architecture diagram of the GitHub repository intel/libvpl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/intel/libvpl
- Repository: https://github.com/intel/libvpl

## Overview

##### Main Components Overview

**Application Layer**
- ↓
**Dispatcher Layer (Core Component)**
- ↓
**Runtime Implementation Layer**
- ↓
**Hardware Layer**

##### Key Components

a) Application Interface Layer:
- API Headers (/api/vpl/*.h files)
- Public Interfaces (mfxvideo.h, mfxdefs.h, etc.)

b) Dispatcher Core:
- Implementation Selection Logic
- Configuration Management
- Runtime Loading System

c) Runtime Implementations:
- Intel® VPL GPU Runtime
- Intel® Media SDK Runtime
- Stub Implementations (for testing)

d) Hardware Abstraction:
- GPU Access Layer
- DirectX Integration
- Memory Management

##### Component Relationships

- Function call flow from application through dispatcher to runtime
- Memory management paths
- Hardware acceleration interfaces
- Configuration flow

##### Specific Implementation Details

**┌─────────────────────────┐**
- Application Layer    │
- ┬──────────┘
- ↓
**┌─────────────────────────┐**
- VPL Dispatcher         │
- Implementation      │
- Selection           │
- Runtime Loading     │
- Config Management   │
- ┬──────────┘
- ↓
**┌─────────────────────────┐**
- Runtime Implementation  │
- ┌─────────┐ ┌─────────┐│
- VPL GPU  │ │Media SDK││
- Runtime  │ │Runtime  ││
- ┘ └─────────┘│
- ┬──────────┘
- ↓
**┌─────────────────────────┐**
- Hardware Layer       │
- (Intel GPU Support)    │
- ┘

##### Additional Elements

Annotations for:
- Version compatibility
- Platform support (as shown in README table)
- DirectX support levels
- Memory flow paths

##### Implementation Notes

- The dispatcher's role in runtime selection
- Platform-specific implementations
- Hardware acceleration paths
- Memory management between layers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef api fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef dispatcher fill:#90EE90,stroke:#333,stroke-width:2px
    classDef runtime fill:#FFB366,stroke:#333,stroke-width:2px
    classDef hardware fill:#E6E6E6,stroke:#333,stroke-width:2px
    classDef memory fill:#FFD700,stroke:#333,stroke-width:2px
    classDef config fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        API_Headers["API Headers"]:::api
        MFXVideo["mfxvideo.h"]:::api
        MFXDefs["mfxdefs.h"]:::api
        MFXCommon["mfxcommon.h"]:::api
        MFXDisp["mfxdispatcher.h"]:::api
    end

    %% Dispatcher Layer
    subgraph DispatcherLayer["Dispatcher Core"]
        DispCore["Dispatcher Implementation"]:::dispatcher
        ConfigMgmt["Configuration Management"]:::config
        RuntimeLoader["Runtime Loading System"]:::dispatcher
        ConfigInterface["Config Interface"]:::config
    end

    %% Runtime Layer
    subgraph RuntimeLayer["Runtime Implementation Layer"]
        VPLRuntime["Intel® VPL GPU Runtime"]:::runtime
        MediaSDK["Intel® Media SDK Runtime"]:::runtime
        StubImpl["Stub Implementations"]:::runtime
    end

    %% Hardware Layer
    subgraph HWLayer["Hardware Layer"]
        GPUAccess["GPU Access Layer"]:::hardware
        DXIntegration["DirectX Integration"]:::hardware
        MemoryMgmt["Memory Management"]:::hardware
    end

    %% Connections
    AppLayer --> DispatcherLayer
    DispatcherLayer --> RuntimeLayer
    RuntimeLayer --> HWLayer

    %% Click events
    click MFXVideo "https://github.com/intel/libvpl/blob/main/api/vpl/mfxvideo.h"
    click MFXDefs "https://github.com/intel/libvpl/blob/main/api/vpl/mfxdefs.h"
    click MFXCommon "https://github.com/intel/libvpl/blob/main/api/vpl/mfxcommon.h"
    click MFXDisp "https://github.com/intel/libvpl/blob/main/api/vpl/mfxdispatcher.h"
    click DispCore "https://github.com/intel/libvpl/blob/main/libvpl/src/mfx_dispatcher_vpl.cpp"
    click RuntimeLoader "https://github.com/intel/libvpl/blob/main/libvpl/src/mfx_dispatcher_vpl_loader.cpp"
    click ConfigInterface "https://github.com/intel/libvpl/blob/main/libvpl/src/mfx_config_interface/mfx_config_interface.cpp"
    click StubImpl "https://github.com/intel/libvpl/tree/main/libvpl/test/runtimes/stub"
    click DXIntegration "https://github.com/intel/libvpl/blob/main/libvpl/src/windows/mfx_dxva2_device.cpp"
    click ConfigMgmt "https://github.com/intel/libvpl/blob/main/libvpl/src/mfx_config_interface/mfx_config_interface.h"
    click MemoryMgmt "https://github.com/intel/libvpl/blob/main/api/vpl/mfxmemory.h"

    %% Legend
    subgraph Legend
        API[API Components]:::api
        DISP[Dispatcher Components]:::dispatcher
        RT[Runtime Components]:::runtime
        HW[Hardware Components]:::hardware
        CFG[Configuration Components]:::config
    end
```
