Skip to content

Instantly share code, notes, and snippets.

View pendingchaos's full-sized avatar

PendingChaos pendingchaos

  • Earth
View GitHub Profile
@pendingchaos
pendingchaos / mesa.diff
Last active September 19, 2018 20:29
glBufferSubData p2mf/m2mf performance test
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 2c604419ce..c846678dde 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -147,7 +147,9 @@ nouveau_transfer_staging(struct nouveau_context *nv,
if (!nv->push_data)
permit_pb = false;
- if ((size <= NOUVEAU_TRANSFER_PUSHBUF_THRESHOLD) && permit_pb) {
+ int pb = atoi(getenv("PB"));
@pendingchaos
pendingchaos / glxspheres.c
Last active July 5, 2018 13:48
VirtualGL's glxspheres without dependencies on the rest of VirtualGL
/* Copyright (C)2007 Sun Microsystems, Inc.
* Copyright (C)2011, 2013-2015, 2017-2018 D. R. Commander
*
* This library is free software and may be redistributed and/or modified under
* the terms of the wxWindows Library License, Version 3.1 or (at your option)
* any later version. The full license is in the LICENSE.txt file included
* with this distribution.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
38ac49d30e00000003d9a29a67fb4bb50100030002100031c1f2e6bf714350be5805216afc5aff0304000100000004200037f2df1e95dbfca2101e8786486fa01893258cfd343f67b9fb12798cff8fe9aa052000e633c970cf2aa9eb4c906ffb59e92c021540c0d8e3800c39aac4daa85f0805ea0608007017000000000000071000778c3f079856c185acd1e93aa1450753082000057173040fa9e4b1329119c9916a040a1409981c4b657d58c85607ff1babf8ac0920007a67e7515fa5152902459a94545811c53b9136c295b4ae5b87de12455ba39d350a0400020000000004000d0a0d0a18c8b11fac90e6961f5a5126d9839de34fce3603ff405e6f68ba93a11727522263622c1744b4a128f0cc35a2eff91529bd65e26257de5c571d35acaa1858e5c2b072b1ba3ca4408a0e5903a3f6c6d74a29f64eae9a431db7c15c1b3ffa3af277d651587e7f88fd40652e34616b79ca2927068540ea3952df568c207157a927969d2f10c10fdf3feef2ddc871aae283dbb47e45309eac85b70f0ef80518da2a051071113999c50df9af263446e4f5eea9f87f051456013e756128f246fe813a789a0c625c52b549f61a28ca9ed6e406406adf32b2d247add39206470a41f0ce8ad154d5fbafe99323de8c45a662edd637f676ced721899d5b66a9de216729b7cf29f7feafae942cdb4207237b479593e7b49787c92fa71af78a6f
@pendingchaos
pendingchaos / path.c
Created March 29, 2016 09:34
An extremely compact PATH implementation
#include<stdio.h>
#define A while((z=getc(f))^EOF)if(z=='\n')++Y,X=0;else{if
#define Z x+=(K&3)-1,y+=(K>>3)-1
#define J :z==
#define v m[C]
int m[30000];size_t s,C,r=1,K=10,x,y,X,Y=1;int main(int l,char**u){FILE*f=fopen(u[1],"r");char z;A(z=='$')break;++X;}x=X;y=Y;while(r){rewind(f);X=0,Y=1;A(X==x&Y==y)break;++X;}z=='#'?r=0 J'+'?v++J'-'?v--J'}'?C++J'{'?C--J','?v=getchar()J'.'?putchar(v)J'/'?K=K==10?1:K==17?8:K==8?17:10 J'\\'?K=K==10?17:K==17?10:K==8?1:8 J'^'?K=v?1:K J'<'?K=v?8:K J'>'?K=v?10:K J'v'?K=v?17:K J'!'?Z:0;Z;}return fclose(f);}
@pendingchaos
pendingchaos / Makefile
Last active April 23, 2016 12:35
A Makefile
CFLAGS = -pedantic -Wall -std=c11 -g
LDFLAGS =
OUTPUT =
RUN_OPT =
PREFIX ?= /usr/local
TARGET = $@
PREREQ1 = $<
src = $(wildcard src/*.c)
@pendingchaos
pendingchaos / README.md
Last active September 6, 2018 11:11
Base XScreensaver hack or screensaver

Installation

  • Copy base.xml to /usr/share/xscreensaver/config
  • Copy the compiled base.c (named "base") to /usr/libexec/xscreensaver
  • Add "GL: base -root\n" to programs in .xscreensaver in your home directory.
@pendingchaos
pendingchaos / aabb_tranform.c
Last active January 29, 2016 15:19
AABB transformation
//-O0: SSE is ~6.3x faster
//-O1: SSE is ~4.6x faster
//-O2: SSE is ~2.5x faster
//-O3: SSE is ~2.2x faster
//-Og: SSE is ~5.5x faster
//-Ofast: SSE is ~1.7x faster
//-Os: SSE is ~2.3x faster
//You probably should not trust these timings.
//Compiled with GCC 5.3.1
//Ran on a Intel(R) Core(TM) i7-3770K CPU
@pendingchaos
pendingchaos / style.css
Last active November 14, 2017 17:35
Opinionated Stylish Style for Twitter.
@-moz-document url("https://twitter.com/") {
body {
background-color: #131515;
background: #131515;
}
body:not(.edge-design) {
background-color: #131515 !important;
background: #131515 !important;
}
}
@pendingchaos
pendingchaos / gtk3.supp
Last active January 29, 2016 15:19
A Valgrind suppression file for GTK+ applications. Just add --suppressions=/path/to/gtk3.supp.
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
fun:g_malloc0
obj:/usr/lib64/libgobject-2.0.so.0.4200.2
fun:g_type_register_fundamental
obj:/usr/lib64/libgobject-2.0.so.0.4200.2
obj:/usr/lib64/libgobject-2.0.so.0.4200.2
@pendingchaos
pendingchaos / matrix_mul.cpp
Last active October 23, 2019 21:10
SSE 4x4 matrix multiplication
#include <xmmintrin.h>
//~2.4x faster than non-SSE unrolled version.
//Uses row-major order (D3D or non-OpenGL layout).
void mul(float result[4][4], float a[4][4], float b[4][4])
{
__m128 otherRow0 = _mm_loadu_ps(b[0]);
__m128 otherRow1 = _mm_loadu_ps(b[1]);
__m128 otherRow2 = _mm_loadu_ps(b[2]);
__m128 otherRow3 = _mm_loadu_ps(b[3]);