Raxol.Terminal.Graphics.GPUAccelerator (Raxol v2.0.1)
View SourceGPU acceleration specifically for terminal graphics operations.
This module provides hardware acceleration for:
- Image processing and transformation
- Graphics rendering pipeline optimization
- Memory-efficient texture management
- Parallel graphics operations
- Real-time visual effects
Built on top of the existing Raxol.Terminal.Rendering.GPUAccelerator, this module focuses specifically on graphics element acceleration.
Features
- Hardware-accelerated image scaling and rotation
- GPU-based image format conversion
- Parallel graphics element rendering
- Texture atlas management for graphics
- Memory pooling for large graphics operations
- Real-time visual effects (blur, glow, shadows)
Usage
# Initialize graphics GPU acceleration
{:ok, context} = GraphicsGPUAccelerator.init()
# Accelerate image processing
{:ok, processed} = GraphicsGPUAccelerator.process_image(context, image_data, %{
scale: 0.5,
rotation: 90,
effects: [:blur, :glow]
})
# Batch process multiple graphics
{:ok, results} = GraphicsGPUAccelerator.batch_process(context, graphics_list)
Summary
Functions
Processes multiple graphics elements in parallel using GPU.
Returns a specification to start this module under a supervisor.
Creates optimized texture atlas for frequently used graphics.
Gets current GPU performance metrics.
Checks if GPU acceleration is available and working.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.
Initializes GPU acceleration for terminal graphics.
Processes a single graphics element with GPU acceleration.
Types
@type batch_job() :: %{ id: String.t(), operations: [graphics_operation()], graphics_data: [binary()], callback: function() | nil }
@type graphics_operation() :: %{ type: :scale | :rotate | :filter | :composite | :effect, parameters: map(), priority: :low | :normal | :high | :critical }
Functions
@spec batch_process(gpu_context(), [{binary(), map()}], map()) :: {:ok, [binary()]} | {:error, term()}
Processes multiple graphics elements in parallel using GPU.
Parameters
context- GPU contextgraphics_list- List of {graphics_data, operations} tuplesoptions- Batch processing options
Returns
{:ok, [processed_graphics]}- Successfully processed graphics{:error, reason}- Processing failed
Examples
graphics = [
{image1_data, %{scale: 0.5}},
{image2_data, %{rotation: 90}},
{image3_data, %{effects: [:blur]}}
]
{:ok, results} = GPUAccelerator.batch_process(context, graphics)
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec create_texture_atlas(gpu_context(), [binary()], map()) :: {:ok, term()} | {:error, term()}
Creates optimized texture atlas for frequently used graphics.
@spec get_performance_metrics() :: map()
Gets current GPU performance metrics.
@spec gpu_available?() :: boolean()
Checks if GPU acceleration is available and working.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.
@spec initialize(map()) :: {:ok, gpu_context()} | {:error, term()}
Initializes GPU acceleration for terminal graphics.
@spec process_graphics(gpu_context(), binary(), map()) :: {:ok, binary()} | {:error, term()}
Processes a single graphics element with GPU acceleration.
Parameters
context- GPU context from init/1graphics_data- Binary graphics data (image, etc.)operations- Map of operations to perform
Examples
{:ok, processed} = GPUAccelerator.process_graphics(context, image_data, %{
scale: {0.5, 0.8}, # width 50%, height 80%
rotation: 45, # degrees
effects: [:blur, :shadow],
quality: :high
})