Skip to content

Instantly share code, notes, and snippets.

View johnbartholomew's full-sized avatar

John Bartholomew johnbartholomew

View GitHub Profile

why doesn't radfft support AVX on PC?

So there's two separate issues here: using instructions added in AVX and using 256-bit wide vectors. The former turns out to be much easier than the latter for our use case.

Problem number 1 was that you positively need to put AVX code in a separate file with different compiler settings (/arch:AVX for VC++, -mavx for GCC/Clang) that make all SSE code emitted also use VEX encoding, and at the time radfft was written there was no way in CDep to set compiler flags for just one file, just for the overall build.

[There's the GCC "target" annotations on individual funcs, which in principle fix this, but I ran into nasty problems with this for several compiler versions, and VC++ has no equivalent, so we're not currently using that and just sticking with different compilation units.]

The other issue is to do with CPU power management.

@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;
anonymous
anonymous / AITest.lua
Created December 27, 2012 18:55
function Space:SpawnShipTest(range)
ship = Space.SpawnShip("eagle_lrf", range, range)
ship:AddEquip("DRIVE_CLASS1")
ship:AddEquip("AUTOPILOT")
ship:AddEquip("WATER", 7)
targ = Game.player:GetNavTarget()
ship:AIFlyTo(targ)
Game.player:SetNavTarget(ship)
end
@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];
};
@Brianetta
Brianetta / cheatMission.lua
Created November 3, 2012 18:45
New UI cheat menu
local ui = Engine.ui
local CheatList = ui:VBox()
local cheatMission = function (loaded)
local cheats = {
{'Add cash', function () Game.player:AddMoney(100000) end},
{'Refuel (prop tank)', function () Game.player:SetFuelPercent() end},