Skip to content

Instantly share code, notes, and snippets.

namespace detail {
constexpr uint64_t sHashLo1 = 0x124b34c732f4a485ull;
constexpr uint64_t sHashLo2 = 0x6fafc7de1f728990ull;
constexpr uint64_t sHashLo3 = 0x9299b5768ee5e36dull;
constexpr uint64_t sHashHi1 = 0x4d8271fe7646891full;
constexpr uint64_t sHashHi2 = 0x6d48b8a30939437cull;
constexpr uint64_t sHashHi3 = 0x122f44ec3b08f41cull;
}
uint64_t hash_word(uint64_t hash, uint64_t w)
@rygorous
rygorous / morton3d_fun.cpp
Created July 4, 2025 05:49
Vectorized 3D Morton encoding for no reason
#include <immintrin.h>
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
typedef uint32_t uint32;
typedef __m128i Vec128_U32;
// "Insert" two 0 bits after each of the 11 low bits of x
static uint32 Part1By2(uint32 x)
@Luxistor
Luxistor / render_vk.c
Created June 12, 2025 16:17
Vulkan backend intialization
fn_decl void
r_init(R_Init_Params *params)
{
// Allocate memory
r_vk_state.permanent_arena = arena_alloc();
r_vk_state.frame_arena = arena_alloc();
r_vk_state.buffer_pool = pool_alloc(r_vk_state.permanent_arena, R_VK_Buffer, R_MAX_BUFFERS);
r_vk_state.texture_pool = pool_alloc(r_vk_state.permanent_arena, R_VK_Texture, R_MAX_TEXTURES);
r_vk_state.sampler_pool = pool_alloc(r_vk_state.permanent_arena, R_VK_Sampler, R_MAX_SAMPLERS);
@mmozeiko
mmozeiko / gpu_api_matrix.md
Last active January 16, 2026 11:38
GPU API matrix
↓ on → CPU OpenGL OpenGLES D3D9 D3D11 D3D12 Vulkan Metal
OpenGL [llvmpipe][] - [gl4es][] [TitaniumGL][] [d3d12][] [zink][]
OpenGLES [llvmpipe][] [SwiftShader][slegacy] [ANGLE][] - [ANGLE][] [ANGLE][] [d3d12][] [ANGLE][] [zink][] [ANGLE][] [ANGLE][] [MoltenGL][]
D3D9 [SwiftShader][slegacy] [wined3d][] - [D3D9on12][] [DXVK][]
D3D11 [WARP][] [wined3d][]
@lunacookies
lunacookies / AppDelegate.m
Created March 19, 2025 01:57
AppKit programmatic main menu
@implementation AppDelegate
- (instancetype)init {
self = [super init];
NSString *displayName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"Main Menu"];
{
@raysan5
raysan5 / installer_optimization_adventure.md
Last active February 13, 2026 11:16
10x Optimizations! An installer creation adventure!

10x Optimization! An installer creation adventure

Background: creating an installer tool

Lately I've been working on rInstallFriendly v2.0, my simple and easy-to-use tool to create fancy software installers.

rInstallFriendly, some visual_styles

rInstallFriendly v2.0, some of its multiple visual styles available. Style is fully customizable!

@d7samurai
d7samurai / .readme.md
Last active December 13, 2025 22:52
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

@mmozeiko
mmozeiko / _miniperf_readme.md
Last active February 6, 2026 05:43
get PMU counter values with ETW, perf or kperf

MiniPerf

Example of how to capture CPU counters with ETW on Windows, perf on Linux or kperf on Apple.

Using ETW needs somewhat recently updated Windows 10 or 11. Not sure about exact version.

Currently tested on:

  • etw on Qualcomm Snapdragon X Elite, Windows 11, arm64
  • etw on AMD Zen 3, Windows 11 (with virtualization enabled in BIOS)
@mmozeiko
mmozeiko / preview.c
Last active June 24, 2025 18:02
windows shell preview handler example
// example of using Windows Preview Handler
// https://learn.microsoft.com/en-us/windows/win32/shell/preview-handlers
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shlwapi.h>
#include <shellapi.h>
#include <shobjidl.h>
@JiayinCao
JiayinCao / tiny_fiber.h
Last active February 14, 2026 11:58
Tiny Fiber ( A razor thin cross platform fiber library )
/*
MIT License
Copyright (c) 2023 Jiayin Cao
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is