Skip to content

Instantly share code, notes, and snippets.

Cameron Hart bitshifter

View GitHub Profile
@bitshifter
bitshifter / sleepy_fib.cpp
Created Jul 22, 2018
sampling vs instrumentation
View sleepy_fib.cpp
#include <chrono>
#include <random>
#include <iostream>
#include <thread>
int fib(int x) {
if (x == 0)
return 0;
if (x == 1)
return 1;
View gist:2fb86002961f33869b9873d5841e33a2
// test_dynamic.rs
#![crate_type="lib"]
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
pub fn add_scalar(a: &[f32], b: &[f32], c: &mut [f32]) {
for ((a, b), c) in a.iter().zip(b.iter()).zip(c.iter_mut()) {
@bitshifter
bitshifter / main.rs
Created Apr 14, 2018
Minimal reproduction of rustc ICE issue #48638
View main.rs
use std::any::Any;
use std::fmt::Debug;
use std::marker::PhantomData;
// use std::ops::Mul;
pub trait Scalar: Copy + PartialEq + Debug + Any {}
impl Scalar for f64 {}
pub trait Dim: Any + Debug + Copy + PartialEq + Send {}
@bitshifter
bitshifter / issue96.patch
Created Jan 1, 2018
Test case for issue 96, replicating cgmath AsMut ambiguity.
View issue96.patch
diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs
index c9cc5c8..e5ec03a 100644
--- a/imgui-examples/examples/test_window_impl.rs
+++ b/imgui-examples/examples/test_window_impl.rs
@@ -4,9 +4,34 @@ extern crate imgui;
extern crate imgui_glium_renderer;
use imgui::*;
+use std::mem;
View gist:71f0c5f3146db43a223ce08cdd0247c2
# bench_f32 loop:
.LBB23_30:
vmovss (%rdi), %xmm1
vmovsd 4(%rdi), %xmm2
vmulss 12(%rdi), %xmm1, %xmm1
vmovsd 16(%rdi), %xmm3
vmulps %xmm3, %xmm2, %xmm2
vaddss %xmm2, %xmm1, %xmm1
vmovshdup %xmm2, %xmm2
vaddss %xmm2, %xmm1, %xmm1
View task_fence.hpp
#ifndef TASK_FENCE_HPP
#define TASK_FENCE_HPP
#include <condition_variable>
#include <mutex>
class TaskFence
{
int taskCount_;
std::condition_variable taskCV_;
View SerializedTaskArena.h
#include "tbb/tbb.h"
#include "tbb/concurrent_queue.h"
#include "tbb/task_arena.h"
// Based on LocalSerializer pattern which enforces execution order based on submission order
// https://www.threadingbuildingblocks.org/docs/help/tbb_userguide/Design_Patterns/Local_Serializer.html
class SerializedTaskArena
{
public:
View Shit Pong
extern crate sdl2;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::Rect;
const BORDER: i32 = 32;
const WIDTH: i32 = 1024;
const HEIGHT: i32 = 768;
@bitshifter
bitshifter / ack.cmd
Created Jan 7, 2016
Git bash commands
View ack.cmd
@rem Do not use "echo off" to not affect any child calls.
@setlocal
@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\usr\bin;%PATH%
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
@bitshifter
bitshifter / gdc2015.md
Last active Feb 17, 2018
GDC2015 Talks
View gdc2015.md

Programming track

  • Advanced DirectX12 graphics and performance | Max McMullen, Microsoft video
  • Code clinic - How to Write Code the Compiler Can Actually Optimize | Mike Acton, Engine Director, Insomniac Games slideshare
  • Destiny - Six years in the making | Chris Butcher, Bungie video
  • Fast Iteration for Far Cry 4 - Optimizing Key Parts of the Dunia Pipeline | Remi Quenin, Engine Architect, Ubisoft pptx
  • More on Vulkan and SPIR-V - The future of high-performance graphics | Khronos Group pdf video
  • Parallelizing the Naughty Dog engine using fibers | Ch
You can’t perform that action at this time.