Skip to content

Instantly share code, notes, and snippets.

@gomson
gomson / PDCollection.cs
Created July 29, 2017 21:41 — forked from akbyrd/PDCollection.cs
An in-progress collection drawer for Unity. Enum specialization is prototype stage, feel free to ignore.
namespace PixelDash.Tools.Editor.Presentation
{
using System;
using PixelDash.Tools.Presentation;
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;
using UObject = UnityEngine.Object;
using Flags = PixelDash.Tools.Presentation.PDCollectionFlags;
// TODO: Need to update to C++11 proper so that I can store unions of complex types and remove
// all these function calls.
#ifndef INCLUDED_CORE_MATH
#define INCLUDED_CORE_MATH
#if defined(__cplusplus)
#define MATH_CPP
@gomson
gomson / main.cpp
Created June 13, 2017 20:58 — forked from anonymous/main.cpp
FSE bug? repro case
#include <stdio.h>
#include <cstdint>
#include <cstdio>
#include <crtdefs.h>
uint16_t TTTT[] = {
892, 636, 0, 641, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
@gomson
gomson / billboard_sao.frag
Created May 9, 2017 15:54 — forked from transitive-bullshit/billboard_sao.frag
WebGL GLSL SAO (Scalable Ambient Obscurance) fragment shader. SAO is a more efficient method for computing SSAO (Screen-Space Ambient Occlusion). Converts the g-buffer to an occlusion buffer which estimates local ambient occlusion at each fragment in screen-space. For details on the technique itself, see: McGuire et al [12] http://graphics.cs.wi…
// total number of samples at each fragment
#define NUM_SAMPLES {{ numSamples }}
#define NUM_SPIRAL_TURNS {{ numSpiralTurns }}
#define USE_ACTUAL_NORMALS {{ useActualNormals }}
#define VARIATION {{ variation }}
uniform sampler2D sGBuffer;
@gomson
gomson / static_if.cc
Created May 4, 2017 08:46 — forked from lichray/static_if.cc
Implement static_if using C11 generic selection
#include <type_traits>
#include <tuple>
#include <iostream>
// Link: https://github.com/aeyakovenko/notes
//count arguments
//COUNT_ARGS :: ... -> Int
#define COUNT_ARGS(...) COUNT_ARGS_(,##__VA_ARGS__,6,5,4,3,2,1,0)
#define COUNT_ARGS_(z,a,b,c,d,e,f,cnt,...) cnt
@gomson
gomson / kotaku_hzd.txt
Created April 19, 2017 06:55 — forked from nothings/kotaku_hzd.md
Why Frustum Culling Matters, and Why It's Not Important
There is a nice GIF illustrating a technique called "frustum culling" in this
Kotaku article: http://kotaku.com/horizon-zero-dawn-uses-all-sorts-of-clever-tricks-to-lo-1794385026
The interwebs being what they are, this has also led to some controversy.
Some people have interpreted the opening sentence "Every time you move the camera in
Horizon Zero Dawn, the game is doing all sorts of under-the-hood calculations, loading
and unloading chunks of world to ensure that it all runs properly," as being about the
GIF; that's not what frustum culling does, but that's probably not what the article's
author meant anyway.
BubbleSort PROC
;//performs the bubble sort algorithm
;//recieves ESI: offset of myarray and ECX: The length
push eax
L1:
mov eax, [esi]
mov edx, [esi + 4]
cmp edx, eax
jg swapo
jmp ending
@gomson
gomson / gist:6cb9cf3b03c6a77148c06fce4010e13f
Created March 18, 2017 18:45 — forked from rygorous/gist:e0f055bfb74e3d5f0af20690759de5a7
A bit of background on compilers exploiting signed overflow
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those
mysterious cases where it helps?
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but
I think it's useful to know what compiler writers are accomplishing by this.
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some
fairly common cases. The signed overflow UB exploitation is an attempt to work around this.

Trying out Rust for Graphics Programming (March 1st, 2017)

This post is a brain-dump of my experience jumping into Rust, where I took time off my regular job for the Blender Foundation to spend 7 months of uninterrupted time learning Rust.

My general goal is to use Rust for graphics application development, as an alternative to C/C++ which is dominant in this area.

@gomson
gomson / gpu_arch_resources
Created March 6, 2017 22:09 — 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