[RZE-16] feat: add layered compositor to render loop#4
Open
FrkAk wants to merge 1 commit into
Open
Conversation
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
[RZE-16]— replaces the single-effect-per-handle render path with a layered compositor that alpha-blends up toMAX_LAYERS=4effect instances perDeviceHandleinto the pre-allocated canvas, then writes to hardware via the existingwrite_frame.src/razer_effect/compositor.pyhousesLayer,LayerStack,blend, andbuild_layer_stack.LayerStack.appendraisesValueErroronce the cap is reached;blenddoes src-over alpha compositing bottom-to-top using only pre-allocated buffers (stack._blend_tmp+ eachLayer.scratch).src/razer_effect/main.pynow readscfg['profiles'][cfg['active_profile']]['layers']instead of the v1 flatcfg['effect']. Structural reload detection is keyed off a(profile, ((effect, opacity, enabled), ...))signature so opacity/enable/effect changes rebuild stacks while param-only edits route througheffect.configure. Rescan reconciliation keeps surviving handles' stacks alive._migrate_v1_to_v2—load_configalways handsmain.pya v2 shape, so no shim lives inmain.pyorcompositor.py.composer/RZE-18/attempt-1(per-handle dispatch) which is stacked oncomposer/RZE-19/attempt-1(v2 config schema). PR base is set to RZE-18.Type of change
Testing
AC verification via
uv run python -c …snippets (no test suite yet — RZE-14 scope):static_colorlayers (red @1.0, blue @0.5) blend to[127.5, 0, 127.5]across every pixel;tracemallocshows ~1.8 KB delta over 120 ticks (tracemalloc bookkeeping itself, no per-tick numpy allocations). Mixedstatic_color + wavestack composites with ~1.5 KB delta over 120 ticks.LayerStack(6, 22)accepts 4 layers; the 5thappendraisesValueError(\"LayerStack cannot exceed MAX_LAYERS=4 layers\").{effect: 'static_color', hue: 240, ...}) round-trips throughload_configand produces a single-layer stack witheffect_name='static_color', opacity 1.0, enabled True.uv run ruff format .+uv run ruff check .clean.uv run ty checkreports only the pre-existingopenrazer.clientunresolved import indevice.py(unrelated).Notes for reviewer
compositor.pymodule is the single source of truth for blend math; future effects (ripple, breathing, twinkle, gradient_sweep, ambient, system_status, gaming_highlight) plug into it unchanged.--loopone-shot path now reads the active profile's first layer (falling back tokey_shuffle) instead of unconditionally instantiatingKeyShuffle.write_frame(matches v1 semantics of leaving unsupported devices untouched). Configurable later if we ever want a "blank on no-effect" mode.np.copyto,np.multiply(..., out=...), andnp.add(..., out=...).