Skip to content

Instantly share code, notes, and snippets.

View matias-eduardo's full-sized avatar
🏝️
🇵🇷

matias matias-eduardo

🏝️
🇵🇷
View GitHub Profile
// "Virtual" key codes... these are not the same as windows; as many as possible are
// mapped to the ASCII codes so you can ASCII index them, and they're repacked to
// fit from 0..127. There are no keycodes for mouse buttons or IME events.
enum
{
// no mouse button aliases yet (ever?)
STBVK_PAUSE = 0x07, // new?
STBVK_BACK = 0x08,
STBVK_TAB = 0x09, // "\t"
STBVK_LWIN = 0x0a,
#ifndef STBP_NUM_INPUT_HISTORY
#define STBP_NUM_INPUT_HISTORY 20 // 100ms at 5ms/sample
#endif
#ifndef STBP_MAX_CHARS_PER_FRAME
#define STBP_MAX_CHARS_PER_FRAME 50
#endif
typedef struct {
float seconds_delta;
double seconds;

why doesn't radfft support AVX on PC?

So there's two separate issues here: using instructions added in AVX and using 256-bit wide vectors. The former turns out to be much easier than the latter for our use case.

Problem number 1 was that you positively need to put AVX code in a separate file with different compiler settings (/arch:AVX for VC++, -mavx for GCC/Clang) that make all SSE code emitted also use VEX encoding, and at the time radfft was written there was no way in CDep to set compiler flags for just one file, just for the overall build.

[There's the GCC "target" annotations on individual funcs, which in principle fix this, but I ran into nasty problems with this for several compiler versions, and VC++ has no equivalent, so we're not currently using that and just sticking with different compilation units.]

The other issue is to do with CPU power management.

@d7samurai
d7samurai / .readme.md
Last active March 19, 2025 22:39
Minimal D3D11

Minimal D3D11

Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube

hollowcube

Other gists in this series:

// --- Library --------------------------------------------------------------------------
#include <string.h>
#include <assert.h>
struct ui_box {int x,y,w,h;};
typedef unsigned long long ui_id;
struct ui_node {
int parent;
int lst, end, nxt;
int siz[2];
@bkaradzic
bkaradzic / idl.md
Last active February 3, 2025 14:50
bgfx is switching to IDL to generate API

bgfx is switching to IDL to generate API

bgfx main API is using basic C++ that looks like C, but it's C++ enough that can't be used directly in C projects. C is important as it provides ability to bind API to other languages, and also as sanity check for API design.

Every time API changes manual process of process for adding/changing API for C99 bindings was changing header declarations of function and function type for interface virtual table (I'll use bgfx::createVertexBuffer function as an example):

/* ... bunch of funcs ... */

/**/
BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(
CREATE OR REPLACE FUNCTION generate_sequential_uuid(p_interval_length int DEFAULT 60)
RETURNS uuid
LANGUAGE plpgsql
AS $$
DECLARE
v_i int;
v_time bigint;
v_bytes int[16] = '{}';
v_hex text[16] = '{}';
BEGIN
@Reedbeta
Reedbeta / interesting-libs.txt
Last active July 4, 2023 02:38
Interesting libraries I might like to use in a project
Interesting libraries I might like to use in a project...
Asset loading:
assetsys.h - virtual filesystem with ZIP backing, overlaying, etc https://github.com/mattiasgustavsson/libs/blob/master/docs/assetsys.md
cute_filewatch.h - file modification watching, for runtime reloading etc https://github.com/RandyGaul/cute_headers/blob/master/cute_filewatch.h
flatbuffers - data serialization, zero-copy deserialization, extensible schemas https://github.com/google/flatbuffers
stb_image - https://github.com/nothings/stb/blob/master/stb_image.h
tinyexr - https://github.com/syoyo/tinyexr
tinygltf - https://github.com/syoyo/tinygltf
tinyobjloader - https://github.com/syoyo/tinyobjloader
@nothings
nothings / gist:ef38135f4aa4799e8f09069a44ded5a2
Created October 21, 2019 00:26
current stb_platform API structure
typedef struct {
float seconds_delta;
double seconds;
stbp_uint64 ns;
stbp_uint64 ns_delta;
stbp_uint64 ms;
stbp_uint64 ms_delta;
} stbp_time_info;
typedef struct {
@DanielGibson
DanielGibson / XPlatformSockets.h
Last active January 13, 2024 13:55
Mostly finished/usable crossplatform sockets (UNIX/BSD sockets vs Winsocks) abstraction
// Crossplatform-Sockets-API ("XSA"), abstracting the differences between
// UNIX Sockets (from Linux, *BSD, OSX, ...) and Winsock (WSA)
/*
* (C) 2017-2021 Daniel Gibson
*
* License:
* This software is dual-licensed to the public domain and under the following
* license: you are granted a perpetual, irrevocable license to copy, modify,
* publish, and distribute this file as you see fit.