Theme Catppuccin
Make yourself at homeCatppuccin

A softer light for long learning sessions.

Appearance

Loading your preference…

Dark palette

Choose a dark palette to try it.

Light uses Latte. Your choices stay in this browser.

Back to your source shelf

Inside the companion

Vulkan · Signal Garden

Query a device and study a clear-color window with explicit frame and presentation lifetimes.

Project files 6

Exercise allocation boundaries

Alignment, zero inputs, overflow, and exact-budget cases without a GPU.

18 lines contracts_test.cpp
#include "contracts.hpp"
#include <iostream>
#include <limits>

int main() {
    using signal_garden::align_up;
    using signal_garden::checked_bytes;
    const auto max = std::numeric_limits<std::size_t>::max();
    const bool ok = align_up(0, 256) == 0 && align_up(257, 256) == 512 &&
        align_up(9, 3) == 9 && align_up(10, 3) == 12 && !align_up(1, 0) &&
        !align_up(max, 2) && align_up(max, 1) == max &&
        checked_bytes(1024, 32, 32768) == 32768 &&
        !checked_bytes(1025, 32, 32768) && !checked_bytes(max, 2, max) &&
        checked_bytes(0, 32, 32768) == 0 && !checked_bytes(4, 0, 100);
    if (!ok) { std::cerr << "allocation contract test failed\n"; return 1; }
    std::cout << "alignment and allocation-boundary tests passed\n";
}

This is the file included with the course. Copy and download give you its complete source.

Taking your work offline? Download all course companions