Skip to content

Instantly share code, notes, and snippets.

View vertver's full-sized avatar
🍉

vertver vertver

🍉
View GitHub Profile
@rygorous
rygorous / more_serious_fft.cpp
Created December 10, 2025 06:11
Core for a 2x unrolled radix-2 (not really radix-4) FFT kernel
// The FFT alg used here was designed to be very FMA-friendly, but because we can't assume FMAs are present on
// all target HW and want consistent results everywhere, we're using FMA-less algorithms for this application.
// Notation throughout this file:
//
// Let z = a + bi. Then conj(z) = a - bi.
//
// We can swap the real and imaginary parts of z to yield s(z) = b + ai ("swap").
// Now because
//
@rygorous
rygorous / rr_dds.h
Created March 7, 2025 01:45
rr_dds loader/writer
//===================================================
// Oodle2 DDS Tool
// (C) Copyright 1994-2022 Epic Games Tools LLC
//===================================================
#ifndef RR_DDS_INCLUDED
#define RR_DDS_INCLUDED
#include <stdint.h>
#include <stddef.h>
@vertver
vertver / dxbc_compiler.c
Last active December 12, 2024 22:07
Simple FXC replacement compiler written on C
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct ID3DInclude *PID3DInclude;
@RealNeGate
RealNeGate / nbhm.h
Last active December 25, 2025 06:39
////////////////////////////////
// NBHM - Non-blocking hashmap
////////////////////////////////
// You wanna intern lots of things on lots of cores? this is for you. It's
// inspired by Cliff's non-blocking hashmap.
//
// To use it, you'll need to define NBHM_FN and then include the header:
//
// #define NBHM_FN(n) XXX_hm_ ## n
// #include <nbhm.h>
@d7samurai
d7samurai / .readme.md
Last active October 29, 2026 09:43
Minimal D3D11 sprite renderer NEO

sponsored by SuperNeo copy 4

Minimal D3D11 sprite renderer NEO

Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes anchor/pivot point, rotation, color filtering, alpha blending and built-in antialiased point sampling. As usual: complete, runnable single-function app. ~150 LOC. No modern C++, OOP or (other) obscuring cruft.

Minimal D3D11 sprite renderer NEO 1337

Sprites are rendered back-to-front (AKA "painter's algorithm") in the order they are submitted, as one draw call. The provided setup employs a single texture atlas containing all the sprite graphics.

The renderer is "im

// Mostly portable example of creating an object file to embed a binary.
// Requires stb_ds.h (https://github.com/nothings/stb/blob/master/stb_ds.h)
// Arguments:
//
// coff_embed [name] [input]
//
// name must be a valid C-identifier if you wanna actually import into C, the
// idea is that the 'input' file is going to be embedded into an object file
// under the symbol name 'name', the content's length is a size_t with the name
// _length appended to the name.
// Compile with clang or MSVC (WINDOWS ONLY RN)
//
// Implementing a POC green threads system using safepoints to show how cheap and simple it can
// be done, all you need to do is call SAFEPOINT_POLL in your own language at the top of every
// loop and function body (you can loosen up on this depending on the latency of pausing you're
// willing to pay). Safepoint polling is made cheap because it's a load without a use site
// which means it doesn't introduce a stall and pays a sub-cycle cost because of it (wastes resources
// sure but doesn't block up the rest of execution).
//
// # safepoint poll
Complete stuff:
https://xmonader.github.io/letsbuildacompiler-pretty/
Lexers + DFAs:
https://gist.github.com/pervognsen/218ea17743e1442e59bb60d29b1aa725
Parsing:
https://eli.thegreenplace.net/2012/08/02/parsing-expressions-by-precedence-climbing
Backend:
@h3r2tic
h3r2tic / raymarch.hlsl
Last active October 31, 2026 01:22
Depth buffer raymarching for contact shadows, SSGI, SSR, etc.
// Copyright (c) 2023 Tomasz Stachowiak
//
// This contribution is dual licensed under EITHER OF
//
// Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
// MIT license (http://opensource.org/licenses/MIT)
//
// at your option.
#include "/inc/frame_constants.hlsl"
@d7samurai
d7samurai / .readme.md
Last active March 19, 2026 09:15
Minimal WASAPI

Minimal WASAPI

Minimal WASAPI reference implementation. Runnable console application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft. Produces a steady sine wave sound.

(This is a re-post of the same gist I posted a few years earlier, simply due to me wanting the Minimal D3D11 series to be listed contiguously and it's not possible to hide or rearrange gists).