Skip to content

Add SEGA hi-res FLUX runtime pipeline integration#231

Draft
timfox wants to merge 4 commits into
mainfrom
cursor/implement-sega-d22f
Draft

Add SEGA hi-res FLUX runtime pipeline integration#231
timfox wants to merge 4 commits into
mainfrom
cursor/implement-sega-d22f

Conversation

@timfox
Copy link
Copy Markdown
Owner

@timfox timfox commented Jun 1, 2026

Summary

Integrates rajabi2001/sega (Spectral-Energy Guided Attention for hi-res diffusion) as a runtime external pipeline in the idTech3 client, following the same pattern as FLUX and TRELLIS.

SEGA is not embedded in the engine — PyTorch/diffusers run out-of-process via sega_flux_generate.py, orchestrated by console commands and optional async SDL background jobs.

Changes

  • Vendored upstream under external/sega/ (flux_sega/, qwen_sega/, requirements.txt)
  • scripts/sega_flux_generate.py — idTech3 wrapper for SEGA FLUX generation (copied to release/ on build)
  • src/client/cl_sega.c — job system, cvars, commands:
    • sega_generate, sega_status, sega_cancel, sega_view
    • Cvars: cl_sega_enable (default 0), cl_sega_async, cl_sega_repo, resolution/steps/seed/checkpoint, etc.
  • src/client/cl_pipeline.c/h — shared shell template expansion extracted from cl_main.c
  • USE_SEGA CMake option (default ON)
  • docs/SEGA.md, scripts/sega_runtime_check.sh, smoke/compat check updates

Usage

set cl_sega_enable 1
set cl_sega_repo "/path/to/sega"   // e.g. repo checkout at external/sega
sega_generate "a misty mountain at dawn"
sega_status
sega_view

Validation

  • ./scripts/compile_engine.sh vulkan — builds cleanly
  • ./scripts/sega_runtime_check.sh release — passes
  • Client links sega_generate / cl_sega_enable symbols
  • cl_sega_enable defaults to 0 (Q3/OA compat check)

Note: Full smoke_test currently fails on a pre-existing cs_autoInit compat check unrelated to this PR.

Requirements

  • Linux + NVIDIA GPU with sufficient VRAM for target resolution
  • Python conda env (default name sega) with PyTorch + diffusers per external/sega/requirements.txt
  • FLUX weights from Hugging Face on first run
Open in Web Open in Cursor 

cursoragent and others added 4 commits June 1, 2026 02:03
Integrate rajabi2001/sega as an external PyTorch generation hook mirroring
FLUX/TRELLIS: async SDL jobs, console commands, and texture hot-reload.

- Vendored upstream flux_sega/ and qwen_sega/ under external/sega/
- scripts/sega_flux_generate.py wrapper copied to release on build
- src/client/cl_sega.c with cvars, sega_generate/status/cancel/view
- Shared cl_pipeline.c/h for shell template expansion (FLUX/TRELLIS/SEGA)
- USE_SEGA CMake option (default ON), docs/SEGA.md, runtime check script
- cl_sega_enable defaults to 0 for classic mod compatibility

Co-authored-by: Tim Fox <timfox@outlook.com>
User-facing commands, cvars, CMake flag, docs, and scripts now use
spec_energy_* / USE_SPEC_ENERGY instead of sega_* / USE_SEGA.

Vendored upstream moved to external/flux_spec_energy/ (upstream
flux_sega/ layout unchanged). GitHub repo URL kept only as upstream
reference in docs.

Co-authored-by: Tim Fox <timfox@outlook.com>
- Add spec_energy_runtime_check to CTest, validate_ci_build, smoke_test
- Fix cs_autoInit compat grep (Cvar_Get vs ri.Cvar_Get)
- Document release wrappers in DEVELOPMENT_SETUP; cross-link TRELLIS.md

Co-authored-by: Tim Fox <timfox@outlook.com>
- Upstream layout validator (flux_sega/, qwen_sega/, requirements.txt)
- spec_energy_runtime_check runs layout check on vendored copy
- COMPATIBILITY.md notes generative hooks default off

Co-authored-by: Tim Fox <timfox@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants