Skip to content

Instantly share code, notes, and snippets.

@rygorous
rygorous / gist:4153316
Created November 27, 2012 09:27
Parameter passing
// C++ chaining example: set up explicitly
OodleWorkOptions opts; // defaults
opts.SetKickImmediate(OodleKickImmediate_No);
opts.SetPriority(OodlePriority_High);
OodleWork_Run(job, &opts);
// C++ chaining: "immediate mode"
OodleWork_Run(job, OodleWorkOptions().SetPriority(OodlePriority_High));
// C version:
@rygorous
rygorous / gist:4172889
Created November 30, 2012 00:28
SSE/AVX matrix multiply
#include <immintrin.h>
#include <intrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
union Mat44 {
float m[4][4];
__m128 row[4];
};
/**
* @author mrdoob / http://mrdoob.com/
* @author mraleph / http://mrale.ph/
* @author ryg / http://farbrausch.de/~fg
*/
THREE.SoftwareRenderer = function () {
console.log( 'THREE.SoftwareRenderer', THREE.REVISION );
@rygorous
rygorous / gist:4644703
Created January 26, 2013 21:22
This is not an acceptable way to strip whitespace from a string.
void RemoveWhitespace(cString &szString)
{
// Remove leading whitespace
size_t nFirstIndex = szString.find_first_not_of(_L(' '));
if(nFirstIndex != cString::npos)
{
szString = szString.substr(nFirstIndex);
}
// Remove trailing newlines
Apr2005_d3dx9_25_x64.cab
Apr2005_d3dx9_25_x86.cab
Apr2006_d3dx9_30_x64.cab
Apr2006_d3dx9_30_x86.cab
Apr2006_MDX1_x86.cab
Apr2006_MDX1_x86_Archive.cab
Apr2006_XACT_x64.cab
Apr2006_XACT_x86.cab
Apr2006_xinput_x64.cab
Apr2006_xinput_x86.cab
@rygorous
rygorous / gist:4687628
Last active December 12, 2015 00:58
Why can't we all agree on the names of buttons on controllers?
// Template:
// [0] "controls: DPAD up/down=cursor up/down, DPAD left/right=selected column, <button_right>=go to graph mode,\n"
// [1] "<button_down>=toggle expand, <button_left>=toggle pause, <button_up>=toggle heatmap, shoulder L/R to switch Iggys, trigger L/R to switch modes"
// [2] "controls: <button_down>=toggle stacked graph, <button_left>=toggle pause, <button_right>=tree mode"
static const char *controller_help[3] =
{
#if defined(__RADPS3__)
"controls: DPAD up/down=cursor up/down, DPAD left/right=selected column, CIRCLE=go to graph mode,\n",
"CROSS=toggle expand, SQUARE=toggle pause, TRIANGLE=toggle heatmap, shoulder L/R to switch Iggys, trigger L/R to switch modes",
gplayer [-play directory\logfile [swffile]] | [-record directory\logfile swffile]
-playcount <#>: set number of times to playback file.
-noskiprenders: don't skip frame renders during playback.
-rerecord: same arguments as play, but rerecords images, etc. during playback.
-nosaveimages: don't save the images to hard drive.
-noimagecompare: don't compare images after saving.
-maskfpuexceptions: mask fpu exceptions.
-quiet: don't print informational messages, only errors.
-threshold <#>: pixel comparison threshold.
ID3D1X(PixelShader) *program = gdraw->fprog[which][additive].pshader;
if (r->stencil_set) {
// in stencil set mode, prefer not doing any shading at all
// but if alpha test is on, we need to make an exception
#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do NULL PS it seems
if (which != GDRAW_TEXTURE_alpha_test)
program = NULL;
else
#endif
@rygorous
rygorous / fxparticle_shader.asc.cpp
Created February 6, 2013 04:26
Altona shader compiler example
// Actually fxparticle_shader.asc, but renamed for syntax highlighting
/*+**************************************************************************/
/*** ***/
/*** This file is distributed under a BSD license. ***/
/*** See LICENSE.txt for details. ***/
/*** ***/
/**************************************************************************+*/
/****************************************************************************/
Change 27354 by FabianG@FABIANGPC on 2010/07/09 15:46:52
Enable RPhase Early Z/Stencil for shaders with Alpha Test, Alpha to Coverage or texkill as long as Z and Stencil writes are disabled.
Change Dasher/OMShaders to expect this behavior.
This makes a notable difference on most frames. Highlights:
<redacted1>-05: -8%
<redacted1>-16: -31.9%
<redacted2>-03: -4.7%
<redacted2>-12: -6.6%