Skip to content

Instantly share code, notes, and snippets.

@kayru
kayru / BoilerplateD3D11.cpp
Last active November 29, 2020 11:21
D3D11 Boilerplate code
// clang main.cpp
#include <tchar.h>
#include <stdint.h>
#include <stdio.h>
#include <windows.h>
#include <D3D11.h>
#include <D3Dcompiler.h>
@kayru
kayru / halftofloat.cpp
Created October 18, 2011 23:51
SSE2 Half to Float
// Yuriy O'Donnell <yuriyo@gmail.com>
// Released under MIT License (do whatever you want with it)
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <windows.h>
#include <xnamath.h>
#include <malloc.h>
glslangValidator -l shaders/test.comp

Keybase proof

I hereby claim:

  • I am kayru on github.
  • I am kayru (https://keybase.io/kayru) on keybase.
  • I have a public key ASBrKn33Jb_jISpGxCZO_GMLgyDMxEhN_4g6dqyNWRko9Qo

To claim this, I am signing this object:

@kayru
kayru / cube.c
Created July 26, 2018 08:38
Modified Vulkan Cube demo to show dropped frames in windowed FIFO present mode
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
ffmpegCmd << "ffmpeg -r 60 -f rawvideo -pix_fmt rgba "
<< "-s " << FrameWidth << "x" << FrameHeight << " "
<< "-i - -preset fast -y -pix_fmt yuv420p -crf 21 " << CaptureVideoPath;
ffmpegPipe = _popen(ffmpegCmd, "wb");
while(rendering)
{
fwrite(framePixels, frameSizeInBytes, 1, ffmpegPipe);
}
@kayru
kayru / cachebench-results.txt
Last active June 25, 2018 08:14
Cache benchmark results
iPhone X
sizeLog2: 10 - Data size: 1 KiB (16 cache lines) - Total time: 0.096518 sec - Time/elem: 2.876475 ns -
sizeLog2: 11 - Data size: 2 KiB (32 cache lines) - Total time: 0.098588 sec - Time/elem: 2.938146 ns -
sizeLog2: 12 - Data size: 4 KiB (64 cache lines) - Total time: 0.098571 sec - Time/elem: 2.937641 ns -
sizeLog2: 13 - Data size: 8 KiB (128 cache lines) - Total time: 0.098576 sec - Time/elem: 2.937794 ns -
sizeLog2: 14 - Data size: 16 KiB (256 cache lines) - Total time: 0.098489 sec - Time/elem: 2.935203 ns -
sizeLog2: 15 - Data size: 32 KiB (512 cache lines) - Total time: 0.098492 sec - Time/elem: 2.935303 ns -
sizeLog2: 16 - Data size: 64 KiB (1024 cache lines) - Total time: 0.098705 sec - Time/elem: 2.941644 ns -
sizeLog2: 17 - Data size: 128 KiB (2048 cache lines) - Total time: 0.293225 sec - Time/elem: 8.738775 ns -
sizeLog2: 18 - Data size: 256 KiB (4096 cache lines) - Total time: 0.324969 sec - Time/elem: 9.684835 ns -
@kayru
kayru / cachebench.cpp
Last active June 24, 2018 21:30
CPU cache performance testbed
// clang++ -o cachebench -O2 -std=c++14 cachebench.cpp
#include <stdio.h>
#include <chrono>
#include <vector>
#include <algorithm>
#include <random>
#include <float.h>
#include <stdint.h>
#include <cstring>
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <windows.h>
#include <stdint.h>
#include <math.h>
#include <float.h>
#include <algorithm>
#include <vector>
// cl /nologo /I "%DXSDK_DIR%\Include" rastafontgpu.cpp /link /LIBPATH:"%DXSDK_DIR%\Lib\x86"
#include <tchar.h>
#include <stdint.h>
#include <stdio.h>
#include <windows.h>
#include <D3D11.h>
#pragma comment(lib, "kernel32.lib")