Skip to content

Instantly share code, notes, and snippets.

// Dasher: refine check to allow stencil only early Z/stencil
if (((prcs->ControlDWORD & CONTROL_DWORD_INTERPOLATED_USED_FOR_Z) || !prcs->DepthState.ZEnable) &&
- !(pCompiled->MiscState.AlphaToCoverageEnable ||
- pCompiled->MiscState.AlphaTestEnable ||
- OMSHADER_COMPILEDOBJ_I::PSKillsPixel(prcs->pShader)))
+ !((prcs->DepthState.ZWrite || prcs->StencilState.FrontFace.StencilEnable || prcs->StencilState.BackFace.StencilEnable) &&
+ (pCompiled->MiscState.AlphaTestEnable ||
+ pCompiled->MiscState.AlphaToCoverageEnable ||
+ OMSHADER_COMPILEDOBJ_I::PSKillsPixel(prcs->pShader))))
{
<redacted1>-05: -0.6%
Change 27056 by mikeab@mikeapc on 2010/06/22 15:40:14
Fabian's clever trick to fool the compiler into not doing movzx.
@rygorous
rygorous / gist:5210848
Last active December 15, 2015 05:39
Weird rendering problem
Weird rendering problem:
We need to render a 3D object such that the z values getting passed on to depth test/write for all pixels
are all exactly the same value (constant per batch), and we need to be able to choose that value freely.
This is what we'd like to do, but it doesn't work:
// at the end of the VS
out.pos.z = ourZValue * out.pos.w;
@rygorous
rygorous / gist:5230065
Created March 24, 2013 01:36
Exhibit A.
From: Casey Muratori, 10/17/12
Well, you will notice that that loop _does not_ stat unless it's
running on a filesystem that doesn't support readdir dtypes (because
it needs to know whether or not to recurse, which you can do with the
dtype on ext*, but not on NTFS et al, since they didn't bother to
implement it or something - everything comes back as DT_UNKNOWN). I
haven't looked at the code to find out if/where they actually do stat
as a matter of course elsewhere, but as I mentioned last night, it is
_only the stat_ that causes the catastrophic case. In my experiments,
@rygorous
rygorous / gist:5312588
Created April 4, 2013 17:59
GDraw extension wrangling
///////////////////////////////////////////////////////////////////////////////
//
// Extensions (we map to GL 2.0 function names for a uniform interface
// across platforms)
//
#define GDRAW_GL_EXTENSION_LIST \
/* identifier import procname */ \
/* GL_ARB_multitexture */ \
GLE(ActiveTexture, "ActiveTextureARB", ACTIVETEXTUREARB) \
@rygorous
rygorous / gist:5379497
Created April 13, 2013 18:25
How I got my job at RAD.
First mail I ever got from Jeff:
----
From: Jeff Roberts
Subject: dude!
To: Fabian "ryg" Giesen
Date: 5/17/2009 2:42PM
Hey, man - I don't think we have ever talked before directly!
With Tundra 1.2 I get:
----
C:\Store\Code\tundra-1.2a-win32\examples\hello-world>..\..\tundra.exe
Build script execution failed
[string "tundra.tools.msvc-vs2008"]:31: RegOpenKeyExA: The system cannot find the file specified.
stack traceback:
[C]: in function 'assert'
@rygorous
rygorous / gist:5534382
Last active December 17, 2015 02:19 — forked from anonymous/gist:5534375
Instruction decode/dispatch variants

Okay, here's the different op splitting/fusing strategies for different cores, as far as I've been able to discern them:

  • Pentium: Complex instructions are U-pipe only but execute directly, they don't get split.
  • Atom (Bonnel/Saltwell): Certain complex instructions don't get split.
  • Pentium Pro/2/3: All ops get split into, tracked as, and executed as uOps.
  • Pentium 4: This never happened.
  • Pentium M/Core: All ops get split into uOps. Post-split, the core can fuse two types of multi-uOp sequences into a larger fused op used for tracking:
  • For stores, address generation + actual store uOps can get fused.
@rygorous
rygorous / mgs.cpp
Last active October 22, 2021 14:36
Classical and Modified Gram-Schmidt orthogonalization
#include <stdio.h>
#include <float.h>
#include <math.h>
struct Vec3f
{
float v[3];
Vec3f() {}
Vec3f(float x, float y, float z)
@rygorous
rygorous / the_problem.cpp
Created June 9, 2013 20:41
The problem.
// This function finds a pair of approximations
// [c1 -s1] [c2 -s2]
// [s1 c1] and [s2 c2]
// to given planar rotations subject to the following constraints:
// 1. c1, s1, c2, s2 are all integer
// 2. c1*c1 + s1*s1 == c2*c2 + s2*s2, i.e. the approximations have the same norm.
// This is done while simultaneously trying to minimize:
// 1. The relative errors of the approximations
// 2. The size of the integers in question (smaller is better)
// 3. The cost of computing this approximation when no integer multiplies are available.