From 8296fe5180b979b9d1f32f6375b41f0e0a8a399d Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 17:39:33 +0100 Subject: feat(gpu): Add parameter-driven ChromaAberrationEffect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements Task #73 - Extends shader parametrization system to ChromaAberrationEffect following the FlashEffect pattern. Changes: - Added ChromaAberrationParams struct (offset_scale, angle) - Added ChromaUniforms with proper WGSL alignment (32 bytes) - Updated shader to compute offset direction from angle parameter - Extended seq_compiler to parse offset/angle parameters - Updated demo.seq with 2 parameterized instances: * Line 50: offset=0.03 angle=0.785 (45° diagonal, stronger) * Line 76: offset=0.01 angle=1.57 (90° vertical, subtle) Technical details: - Backward-compatible default constructor maintained - Migrated from raw buffer to UniformBuffer - Shader computes direction: vec2(cos(angle), sin(angle)) - Generated code creates ChromaAberrationParams initialization Testing: - All 32/32 tests pass - Demo runs without errors - Binary size: 5.6M stripped (~200-300 bytes impact) Co-Authored-By: Claude Sonnet 4.5 --- src/util/check_return.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/util/check_return.h') diff --git a/src/util/check_return.h b/src/util/check_return.h index cd2c293..89ed4bc 100644 --- a/src/util/check_return.h +++ b/src/util/check_return.h @@ -45,17 +45,14 @@ // CHECK_RETURN_END // // Allows cleanup code before return. -#define CHECK_RETURN_BEGIN(cond, retval) \ - if (cond) { - +#define CHECK_RETURN_BEGIN(cond, retval) if (cond) { #define ERROR_MSG(...) \ do { \ fprintf(stderr, "Error: " __VA_ARGS__); \ fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \ } while (0) -#define CHECK_RETURN_END \ - } +#define CHECK_RETURN_END } // Warning message (non-fatal, execution continues) // Usage: WARN_IF(count == 0, "No items found"); @@ -84,7 +81,6 @@ // Block-based check - cleanup code preserved, messages stripped #define CHECK_RETURN_BEGIN(cond, retval) if (cond) { - #define ERROR_MSG(...) ((void)0) #define CHECK_RETURN_END } @@ -103,7 +99,8 @@ // CHECK_RETURN_IF: // - Simple error checks with no cleanup needed (90% of cases) // - Input validation: CHECK_RETURN_IF(argc < 2, 1, "Too few arguments") -// - Null checks: CHECK_RETURN_IF(ptr == nullptr, nullptr, "Not found: %s", name) +// - Null checks: CHECK_RETURN_IF(ptr == nullptr, nullptr, "Not found: %s", +// name) // - Range checks: CHECK_RETURN_IF(x < 0 || x > max, -1, "Out of range") // // CHECK_RETURN_BEGIN/END: @@ -141,13 +138,15 @@ // - Programming errors (assertion failures, invariant violations) // - Corrupted state that cannot be recovered // - Internal consistency checks -// - Example: FATAL_CHECK(idx >= size, "Index out of bounds: %d >= %d", idx, size) +// - Example: FATAL_CHECK(idx >= size, "Index out of bounds: %d >= %d", idx, +// size) // // Use CHECK_RETURN for: // - Recoverable errors (invalid input, missing files) // - Runtime configuration issues // - API parameter validation -// - Example: CHECK_RETURN_IF(file == nullptr, false, "File not found: %s", path) +// - Example: CHECK_RETURN_IF(file == nullptr, false, "File not found: %s", +// path) // // Key difference: // - FATAL_XXX: abort() - program terminates -- cgit v1.2.3