Skip to content

Instantly share code, notes, and snippets.

View bitshifter's full-sized avatar

Cameron Hart bitshifter

View GitHub Profile
#!/usr/bin/env python3
#
# Copyright 2014-2020 Cameron Hart <cameron.hart@gmail.com>.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@bitshifter
bitshifter / PurgeStandbyList.cpp
Last active October 3, 2023 08:26
Command line utility for purging Window's standby list. Requires /MANIFESTUAC:"level='highestAvailable'.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
#define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061L)
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemMemoryListInformation = 80, // 80, q: SYSTEM_MEMORY_LIST_INFORMATION; s: SYSTEM_MEMORY_LIST_COMMAND (requires SeProfileSingleProcessPrivilege)
} SYSTEM_INFORMATION_CLASS;
@bitshifter
bitshifter / fmaf.asm
Created February 19, 2022 22:11
msvc software fmaf
; id = {0xffffffff}, range = [0x000000018008f810-0x000000018008fab0), name="fmaf"
; Source location: unknown
7FFF8B1DF810: 48 8B C4 movq %rsp, %rax
7FFF8B1DF813: 55 pushq %rbp
7FFF8B1DF814: 53 pushq %rbx
7FFF8B1DF815: 56 pushq %rsi
7FFF8B1DF816: 57 pushq %rdi
7FFF8B1DF817: 41 56 pushq %r14
7FFF8B1DF819: 48 8D 68 A1 leaq -0x5f(%rax), %rbp
7FFF8B1DF81D: 48 81 EC B0 00 00 00 subq $0xb0, %rsp
@bitshifter
bitshifter / readme.md
Created December 6, 2020 20:40
glam master vs refactor branch codegen

I'm generating spriv of glam master branch versus glam refactor branch and overriding what glam rust-gpu is using via a .cargo/config overrive.

This is with Vec3 being repr(simd) on master.

I'm compiling using cargo run --bin example-runner-wgpu.

File sizes when built with master:

cam@zx:~/Projects/rust-gpu (main)$ ls -lah target/spirv-builder/spirv-unknown-unknown/release/*.spv
@bitshifter
bitshifter / main.rs
Created November 12, 2019 10:30
unit quaternion drift
use glam;
use rand::{thread_rng, Rng};
fn rand_angle<R: Rng>(rng: &mut R) -> f32 {
rng.gen_range(-std::f32::consts::PI, std::f32::consts::PI)
}
fn rand_quat<R: Rng>(rng: &mut R) -> glam::Quat {
let yaw = rand_angle(rng);
let pitch = rand_angle(rng);
@bitshifter
bitshifter / mat4_mul_mat4_compare.md
Last active June 4, 2019 13:20
mathbench mat4 mul comparison

mathbench Mat4 mul comparison

mathbench lib

pub fn glam_mat4_mul(lhs: glam::Mat4, rhs: glam::Mat4) -> glam::Mat4 {
    lhs * rhs
}

pub fn nalgebra_mat4_mul(
    lhs: nalgebra::Matrix4<f32>,
@bitshifter
bitshifter / sleepy_fib.cpp
Created July 22, 2018 10:41
sampling vs instrumentation
#include <chrono>
#include <random>
#include <iostream>
#include <thread>
int fib(int x) {
if (x == 0)
return 0;
if (x == 1)
return 1;
// 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 April 14, 2018 01:20
Minimal reproduction of rustc ICE issue #48638
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 / ctags-from-clangdb.py
Created February 7, 2014 13:01
Python script that generates ctags for files and dependencies of a clang compilation json database
#!/usr/bin/env python
#
# Copyright 2014 Cameron Hart <cam@bitshifter.net.nz>. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#