Skip to content

Instantly share code, notes, and snippets.

@mmozeiko
mmozeiko / image_resize.c
Last active October 13, 2026 07:31
stb image resize example, single threaded & multithreaded (spmd style)
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
// https://github.com/nothings/stb/blob/master/stb_image.h
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC
#include "stb_image.h"
@mmozeiko
mmozeiko / radix_sort.c
Last active October 27, 2026 22:07
radix sort, single threaded & multithreaded (spmd style)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
//
// radix sort
//
static void radix_sort(uint64_t* array, size_t count, uint64_t* scratch)
{
@mmozeiko
mmozeiko / argononeup.md
Last active July 12, 2026 13:22
Argon ONE UP extras

NOTE: I use [ArchLinux ARM][] with [sway][] wayland window manager and [pipewire][] for audio.

All of the functionality here works with NO need to run argononeup.sh script.

First time setup

As a one time setup, update pi bootloader EEPROM configuration:

sudo pacman -S rpi5-eeprom

sudo rpi-eeprom-config -e

@mmozeiko
mmozeiko / gpu_api_matrix.md
Last active October 2, 2026 07:32
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][]
@mmozeiko
mmozeiko / debugger_example.c
Last active April 17, 2026 01:30
example for debug api & call stack unwinding & symbol lookup
#include <windows.h>
#include <dbghelp.h>
#include <stdio.h>
#include <assert.h>
#pragma comment (lib, "dbghelp")
int main()
{
STARTUPINFOW si = { .cb = sizeof(si) };
@mmozeiko
mmozeiko / snapdragonx.txt
Created October 16, 2024 03:54
Snapdragon X Elite PMC sources on Windows
Maximum selectable profile sources: 12.
Id Name Interval Min Max
--------------------------------------------------------------
0 Timer 10000 1221 1000000
2 TotalIssues 65536 4096 2147483647
4 LoadInstructions 65536 4096 2147483647
6 BranchInstructions 65536 4096 2147483647
8 DcacheMisses 65536 4096 2147483647
9 IcacheMisses 65536 4096 2147483647
@mmozeiko
mmozeiko / callstack_dump.c
Last active June 24, 2026 06:23
dumps callstack of all threads in a single process
#include <windows.h>
#include <dbghelp.h>
#include <tlhelp32.h>
#include <stdlib.h>
#include <stdio.h>
#pragma comment (lib, "dbghelp")
#pragma comment (lib, "advapi32")
int main(int argc, char* argv[])
@mmozeiko
mmozeiko / MagicRingBuffer.h
Last active October 20, 2026 20:56
Magic RingBuffer for Windows, Linux and macOS
#pragma once
//
// Magic Ring Buffer
// https://gist.github.com/mmozeiko/3b09a340f3c53e5eaed699a1aea95250
//
// Sets up memory mapping so the same memory block follows itself in virtual address space:
//
// [abcd...xyz][abc...xyz]
//
@mmozeiko
mmozeiko / wic.h
Last active June 11, 2026 23:36
simple wrapper to load or save D3D11 texture from/to image file with Windows Imaging Component
#pragma once
#define COBJMACROS
#include <windows.h>
#include <d3d11.h>
//
// interface
//
@mmozeiko
mmozeiko / _miniperf_readme.md
Last active July 19, 2026 14:56
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)