Skip to content

Instantly share code, notes, and snippets.

View equalent's full-sized avatar
🍉

Andrei Tsurkan equalent

🍉
View GitHub Profile
@equalent
equalent / PixelFormat.csv
Last active October 13, 2025 05:33
Pixel formats in CSV (from Heath)
name value flags stride_formula size_formula dxgi_format vulkan_format metal_format
Unknown 0 None 0 0 DXGI_FORMAT_UNKNOWN VK_FORMAT_UNDEFINED MTLPixelFormatInvalid
A8Unorm 1 HasAlpha w w*h DXGI_FORMAT_A8_UNORM VK_FORMAT_R8_UNORM MTLPixelFormatA8Unorm
R8Unorm 10 HasRed w w*h DXGI_FORMAT_R8_UNORM VK_FORMAT_R8_UNORM MTLPixelFormatR8Unorm
R8Snorm 12 HasRed w w*h DXGI_FORMAT_R8_SNORM VK_FORMAT_R8_SNORM MTLPixelFormatR8Snorm
R8Uint 13 HasRed w w*h DXGI_FORMAT_R8_UINT VK_FORMAT_R8_UINT MTLPixelFormatR8Uint
R8Sint 14 HasRed w w*h DXGI_FORMAT_R8_SINT VK_FORMAT_R8_SINT MTLPixelFormatR8Sint
R16Unorm 20 HasRed w*2 w*h*2 DXGI_FORMAT_R16_UNORM VK_FORMAT_R16_UNORM MTLPixelFormatR16Unorm
R16Snorm 22 HasRed w*2 w*h*2 DXGI_FORMAT_R16_SNORM VK_FORMAT_R16_SNORM MTLPixelFormatR16Snorm
R16Uint 23 HasRed w*2 w*h*2 DXGI_FORMAT_R16_UINT VK_FORMAT_R16_UINT MTLPixelFormatR16Uint
using System.Text.RegularExpressions;
namespace Heath.Build.Generators;
public class NinjaWriter
{
private StreamWriter _writer;
private int _width;
/*
* MIT License
*
* Copyright (c) 2021-2022 John "Nielk1" Klein
*
* 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
@equalent
equalent / HDR_Output.md
Last active February 16, 2024 13:03
HDR Output

HDR Output

This is an overview of HDR output support on different platforms.

DXGI

Windows 10 Creators Update added native HDR support to DXGI:

  • must be enabled for display in Settings
  • requires flip-mode swap chain
@equalent
equalent / .clang-format
Created January 19, 2024 01:33
clang-format config for RHandy's C++ style
BasedOnStyle: LLVM
IndentWidth: 8
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Attach
SpaceAfterCStyleCast: true
SpacesInParentheses: false
PointerAlignment: Right
ReferenceAlignment: Right
SpacesInAngles: false
@equalent
equalent / rsqrt.h
Last active January 10, 2024 05:35
Inverse square root implementation in plain C (q_rsqrt) and using SSE / NEON intrinsics
#pragma once
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) \
|| defined(__x86_64) || defined(_M_AMD64)
#define RSQRT_ARCH_AMD64
#define RSQRT_ARCH_X86
#endif
#if defined(i386) || defined(__i386) || defined(__i386__) \
|| defined(__i386__) || defined(__IA32__) || defined(_M_IX86)
@equalent
equalent / KA_HY_FONTS.md
Last active November 7, 2023 22:45
Georgian/Armenian fonts for code

To read and write code that contains Georgian and/or Armenian characters, a combination of any preferred typeface with fallback DejaVu Sans Mono can be used.

For example, in VS Code settings.json:

{
    "editor.fontFamily": "'JetBrains Mono', 'DejaVu Sans Mono'"
}
@equalent
equalent / MakeID.h
Created November 6, 2022 14:20
MakeID.h
#ifndef MAKEID_H
#define MAKEID_H
/*
Author:
Emil Persson, A.K.A. Humus.
http://www.humus.name
Version history:
@equalent
equalent / lj_win64.ninja
Created August 24, 2022 11:12
Ninja makefile for LuaJIT
script =
tflags =
rule cc
command = cl /nologo /c /O2 /Ob3 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__forceinline -DLUAJIT_DISABLE_JIT -DLUAJIT_NO_UNWIND /showIncludes $tflags $in
deps = msvc
rule link
command = link /nologo /out:$out $in
@equalent
equalent / numeric_to_bit.pgsql
Created February 18, 2022 17:06
PostgreSQL PL/pgSQL NUMERIC to BIT VARYING
-- source: https://stackoverflow.com/a/50119025
create function numeric_to_bit(numeric) returns bit varying
language plpgsql
as
$$
DECLARE
num ALIAS FOR $1;
-- 1 + largest positive BIGINT --
max_bigint NUMERIC := '9223372036854775808' :: NUMERIC(19, 0);