Skip to content

Instantly share code, notes, and snippets.

@pjako
pjako / hash_fnv1a.h
Created March 6, 2023 17:55 — forked from ruby0x1/hash_fnv1a.h
FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit
#pragma once
#include <stdint.h>
//fnv1a 32 and 64 bit hash functions
// key is the data to hash, len is the size of the data (or how much of it to hash against)
// code license: public domain or equivalent
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) {
@pjako
pjako / mpmpc.c
Last active January 28, 2021 10:58
Lockless mpmc queue
#include <stdatomic.h>
#include <stdint.h>
#include <assert.h>
#include <stdbool.h>
typedef _Atomic(uint64_t) a64;
typedef _Atomic(uint32_t) a32;
#define atomicCompareExchange64(DESTPTR, COMPERAND, EXCHANGE) atomic_compare_exchange_weak(DESTPTR, COMPERAND, EXCHANGE)
#define atomicCompareExchange32(DESTPTR, COMPERAND, EXCHANGE) atomicCompareExchange64(DESTPTR, COMPERAND, EXCHANGE)
#define atomicLoad64(VALPTR) atomic_load(VALPTR)
@pjako
pjako / handle.c
Created December 11, 2020 11:41
Handles with generation
#define HANDLE_SIZE 32
#define HANDLE_GEN_BITS 8
static const uint32_t handleIndexMask32 = (1 << (32 - HANDLE_GEN_BITS)) - 1;
static const uint32_t handleGenMask32 = ((1 << HANDLE_GEN_BITS) - 1);
static const uint32_t handleGenShift32 = (32 - HANDLE_GEN_BITS);
#define _handleIndex32(HANDLE) ((ui_u32)((HANDLE) & handleIndexMask32))
#define handleGeneration32(HANDLE) ((ui_u8)(((HANDLE) >> handleGenShift32) & handleGenMask32))
#define handleSameGeneration32(HANDLE, GENERATION) (((uint8_t)(((HANDLE) >> handleGenShift32) & handleGenShift32)) == (GENERATION % 255))
@pjako
pjako / CMakeLists.txt
Last active October 30, 2020 22:27
app func & shader generation
/* ... */
#=== EXECUTABLE func
function(app app_name)
if(APPLE)
add_executable(${app_name} MACOSX_BUNDLE ${ARGN} )
elseif(WIN32)
add_executable(${app_name} WIN32 ${ARGN})
else()
add_executable(${app_name} ${ARGN})
//------------------------------------------------------------------------------
// triangle-emsc.c
// Vertex buffer, simple shader, pipeline state object.
//------------------------------------------------------------------------------
#define SOKOL_IMPL
#define SOKOL_GLES2
#include "sokol_gfx.h"
sg_draw_state draw_state;
//------------------------------------------------------------------------------
// triangle-emsc.c
// Vertex buffer, simple shader, pipeline state object.
//------------------------------------------------------------------------------
#define SOKOL_IMPL
#define SOKOL_GLES2
#include "sokol_gfx.h"
sg_draw_state draw_state;
@pjako
pjako / gpu_arch_resources
Created March 5, 2017 23:15 — forked from jhaberstro/gpu_arch_resources
GPU Architecture Learning Resources
http://courses.cms.caltech.edu/cs179/
http://www.amd.com/Documents/GCN_Architecture_whitepaper.pdf
https://community.arm.com/graphics/b/blog
http://cdn.imgtec.com/sdk-documentation/PowerVR+Hardware.Architecture+Overview+for+Developers.pdf
http://cdn.imgtec.com/sdk-documentation/PowerVR+Series5.Architecture+Guide+for+Developers.pdf
https://www.imgtec.com/blog/a-look-at-the-powervr-graphics-architecture-tile-based-rendering/
https://www.imgtec.com/blog/the-dr-in-tbdr-deferred-rendering-in-rogue/
http://developer.amd.com/tools-and-sdks/opencl-zone/amd-accelerated-parallel-processing-app-sdk/opencl-optimization-guide/#50401334_pgfId-412605
https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/
https://community.arm.com/graphics/b/documents/posts/moving-mobile-graphics#siggraph2015
@pjako
pjako / docsGen.dart
Created April 3, 2012 13:05
Dart Docs generation Script
#import('dart:io');
final String PATH_TO_DARTSDK = "/Users/XYZ/dart-sdk";
final String SUBDIRECTORY = "";
final String LIBRARY_DARTFILE = "XYZ.dart";