DFPSR Software Rendering Library

repository·master·Indexed 41 days ago

https://github.com/dawoodoz/dfpsr

A C++14 real-time software rendering library providing high-performance 2D and 3D graphics on the CPU using SIMD (SSE/AVX/NEON). Designed for determinism and minimal system dependencies, it features a GUI framework, an occlusion system, and a SIMD abstraction layer via simd.h. Currently in public beta, it supports Linux (X11), MacOS, and Windows.

Tokens
4.8K
Snippets
11
Records
27
Agent score
99%

What's inside DFPSR

  1. Overview of the DFPSR source structure

    master

    The DFPSR repository is organized into several functional areas that provide a framework for software rendering, hardware abstraction, and system-specific integrations:

    • DFPSR Framework: The core logic of the library.
    • System Dependent Backends: Modules that abstract hardware and operating system differences.
    • Code Examples: Demonstrations of how to use the library.
    • Tools: Utility software provided with the framework.
  2. Overview of the Sprite Engine for DFPSR SDK

    master

    The Sprite Engine is a specialized isometric rendering engine built for the DFPSR SDK. It serves as both a functional component for the SDK and a reference implementation for developers wanting to build their own custom isometric rendering engines on top of DFPSR.

    Key characteristics:

    • Extensibility: Developers are encouraged to modify the code and optimize custom filters using DFPSR's SIMD and threading abstractions.
    • Implementation Detail: The engine currently re-uses some internal DFPSR components from the image and render folders.
    • Stability Warning: The image and render internal APIs are not version stable and may break backward compatibility in future updates.
  3. Overview of DFPSR

    master

    DFPSR is a real-time software rendering library for C++14 designed for high portability and long-term maintainability. It uses SIMD (SSE/AVX/NEON) to achieve high performance on the CPU without requiring GPU drivers or complex graphics APIs like OpenGL.

    Key characteristics include:

    • Minimal Dependencies: Uses a monolithic approach with minimal system dependencies, making it easy to port to future systems.
    • Determinism: Software rendering ensures consistent behavior across different hardware and operating systems.
    • Static Linking: The library is designed to be statically linked with your program, including core system APIs, to ensure maximum reliability.
    • No Binaries: The library is compiled entirely from source, ensuring transparency and ease of inspection.
  4. Understand DFPSR system-dependent abstractions

    master

    DFPSR uses several abstraction layers to ensure cross-platform compatibility and performance across different hardware and operating systems:

    • File Access: Handled via Source/DFPSR/api/fileAPI to provide a unified interface for file operations across different OSs.
    • SIMD Abstraction: The Source/DFPSR/base/simd.h header provides a SIMD abstraction layer. It is designed to work even on architectures without SIMD support, but can be optimized for specific processor architectures by implementing specific features.
    • Memory Alignment: The getCacheLineSize function in Source/DFPSR/base/heap.cpp retrieves the cache line width from the operating system. This is used for memory alignment, which is critical for thread safety and performance.
    • Graphics and Input: Source/windowManagers contains integrations for displaying graphics and handling mouse and keyboard input. These are selected at compile-time based on the operating system in Source/DFPSR/DFPSR.DsrHead.
    • Audio: Source/soundManagers contains OS-specific sound integrations, also selected via Source/DFPSR/DFPSR.DsrHead.
  5. Understand the API stability and development status

    master

    DFPSR is currently in public beta. Developers should be aware of the following stability levels:

    • Stable APIs: Buffer, file, image, draw, filter, string, and time APIs are considered version stable.
    • Unstable APIs: Theme, GUI, font, and sound APIs are under active development and may undergo significant breaking changes before version 1.0.

    You can choose to pin your project to a specific version, stay updated with the latest changes, or wait for the stable 1.0 release.

  6. Core Features of DFPSR

    master

    DFPSR provides a comprehensive suite of tools for game and application development:

    • 2D Drawing: Pixel-exact calls for lines, rectangles, solid image copies, alpha-filtered images, depth-buffered drawing, and stencil drawing.
    • 3D Rendering: Supports bi-linear texture sampling, mipmapping, lightmaps, and alpha filtering (comparable to Direct3D 7).
    • Occlusion System: Includes an occlusion grid to skip drawing triangles or objects based on visibility tests.
    • SIMD Abstraction: Use simd.h to write readable math syntax that automatically generates efficient SSE, AVX, or NEON intrinsics.
    • GUI Framework: Load visual interfaces via layout files or strings and attach events using lambda functions.
    • Media Layer: Cross-platform handling of sound (Alsa/WinMM) and window management (using multi-threading for canvas uploads to avoid GPU driver dependencies).
    • File & Process Management: C++14 compatible filesystem and process management tools.
    • Memory Safety: SafePointer.h provides informative error messages during development with zero overhead in release builds.
  7. Check supported hardware and SIMD acceleration

    master

    DFPSR utilizes SIMD intrinsics to optimize software rendering performance across different architectures:

    • Intel/AMD: Supports SSE2, SSSE3, AVX, and AVX2.
    • ARM: Supports NEON.
    • RISC-V: Currently uses a scalar fallback path (dedicated SIMD backend pending).
    • Unknown Architectures: Uses optimized vector operations without SIMD hardware acceleration to improve execution window filling compared to naive loops.
  8. Install dependencies for Linux (Mint/Ubuntu/Debian)

    master

    Before compiling DFPSR on Linux distributions like Mint, you must install the necessary compiler and X11 development headers using apt.

    sudo apt install g++
    sudo apt install libx11-dev
  9. Build a project on Linux

    master

    To build your DFPSR project on Linux, ensure the build script has execution permissions and then run it from the terminal. Note that when providing the relative path, you must prefix it with ./ to distinguish it from global aliases.

    chmod +x build_linux.sh
    ./build_linux.sh
  10. Initialize a new project with DFPSR

    master

    To start a new project using DFPSR, follow these steps to set up the directory structure and references:

    1. Copy a Template: Copy one of the existing project folders into a location with stable relative access to the DFPSR library. Alternatively, place DFPSR in a standard path and use absolute paths.
    2. Update Header Includes: In your main.cpp, update the #include directive to point to the correct location of includeFramework.h.
    3. Configure Build Scripts:
      • For Linux: Update the path for tools/builder/buildProject.sh inside build_linux.sh.
      • For Windows: Update the path for tools/builder/buildProject.bat inside build_windows.bat.
    4. Update Project Files: If your project imports DFPSR/DFPSR.DsrHead, update the path in your main.DsrProj file.
    // In main.cpp, update the path to the header
    #include "../../DFPSR/includeFramework.h"
  11. Automated C++ Build System

    master

    DFPSR features a fully automatic build system that eliminates the need for manual source file lists.

    To use it:

    1. Include the library's project header to specify the backend for your platform.
    2. Tell the build system to 'crawl from main'; it will automatically find all included headers and their corresponding source files by name.
    3. The system uses checksums to only rebuild files that have changed, avoiding the need to manage separate static libraries for different parts of your code.