How dfranx/shadered works
Project type and purpose
• SHADERed is a desktop, cross-platform (Windows, Linux, Web) native application for writing, previewing, and debugging GPU shaders.
• It consists of a UI layer (built on SDL2 + ImGui), a core “engine” that drives rendering, debugging and analysis, and plugin & export subsystems.
File structure
• src/SHADERed/ contains the heart of the application:
• EditorEngine, GUIManager, InterfaceManager
• Engine subfolder (GLUtils, AudioPlayer, GeometryFactory, RenderEngine)
• Objects subfolder (ShaderCompiler, PipelineManager, ProjectParser, DebugAdapterProtocol, SPIRVParser, WebAPI, PluginAPI)
• UI subfolder (all windows & dockable panels implemented in ImGui)
• libs/ holds external dependencies that are statically linked (ImGui, SPIRV-Cross, SPIRV-VM, glslang, Assimp, pugixml, etc.)
• bin/data & bin/examples/ contain runtime assets: example shaders, models, textures, themes, templates.
• CMakeLists.txt & cmake/ drive the build process and incorporate submodules.
Read the README for additional insights
• The README highlights major features: real-time preview, shader debugging (line-by-line + frame analyzer), plugin API, export facilities (C++ templates), and instant recompilation.
Main components & interactions
A. User Interface Layer (UI)
• Modules: GUIManager, InterfaceManager, all UI panels under src/SHADERed/UI
• Interaction: Captures user actions (open file, set breakpoint, run debug, change shader code)
B. Editor Core (EditorEngine)
• Coordinates between UI and engine subsystems
• Manages state: current project, open shaders, compile status
C. Render & Compute Engine
• RenderEngine uses GLUtils to call OpenGL via SDL2/GLEW
• GeometryFactory, Model loader (Assimp), AudioPlayer feed data into GPU
D. Shader Pipeline Manager
• PipelineManager constructs GPU pipeline stages (vertex, tessellation, geometry, pixel, compute)
• ShaderCompiler + ShaderFileIncluder compile HLSL/GLSL/SPIR-V through glslang + SPIRV-Cross
E. Debugger & Analyzer
• SPIRVParser + SPIRV-VM simulate or inspect GPU code
• DebugAdapterProtocol + ExpressionCompiler handle breakpoints, watches, immediate expressions
• FrameAnalyzer tracks per-pixel values, undefined behavior heatmap
F. Project & Asset Management
• ProjectParser reads .sprj files, manages asset references
• Resource layer: file I/O, parsing (pugixml for XML, inih for settings), zip_file for imports
G. Plugin System & Export
• PluginManager loads plugins conforming to PluginAPI
• ExportCPP generates C++ shader loading templates
H. External Interfaces
• WebAPI handles online browsing of examples and plugins
• File system and OS integration (SDL2 dialogs via ImFileDialog)
Architectural patterns & design principles
• Layered architecture: UI → EditorEngine → Subsystems (Render, Debug, Project) → Hardware/OS
• Plugin-based extensibility: clear PluginAPI interfaces in Objects/PluginAPI
• Separation of concerns: UI code never directly calls OpenGL; it delegates to RenderEngine
• Data-flow loops: code edit → immediate compile → RenderEngine → GPU → UI preview
Final checklist
• Clear, distinct labels on every component
• Layered layout reflecting logical separation: UI, core, infra