Skip to content

Instantly share code, notes, and snippets.

View aras-p's full-sized avatar

Aras Pranckevičius aras-p

View GitHub Profile
// stb_c_lexer.h 0.01 -- public domain Sean Barrett 2013
// lexer for making little C-like languages with recursive-descent parsers
//
// This file provides both the interface and the implementation.
// To instantiate the implementation,
// #define STB_C_LEXER_IMPLEMENTATION
// in *ONE* source file, before #including this file.
//
// The default configuration is fairly close to a C lexer, although
// suffixes on integer constants are not handled (you can override this).
@aras-p
aras-p / gist:5072716
Created March 2, 2013 19:20
shader-move notes
Changes:
* Majority of built-in shaders are now only included into your game data if they are actually used.
This saves about 200 kilobytes off your mobile game size if you're not using many built-in shaders.
If you need some built-in shaders to be available without explicit references to them, set them up in
Edit -> Project Settings -> Grpahics (by default Diffuse shader is always included).
Fixes:
* Object Selector shows built-in shaders now
@aras-p
aras-p / gist:5088284
Last active December 14, 2015 12:39
GfxDevice source sizes
Platform specific GfxDevice implementation source code size in Unity:
Direct3D 9 342k
Direct3D 11 446k, 146k of which fixed function emulation ;)
Flash Stage3D 147k
OpenGL 303k
OpenGL ES 1.1 140k
OpenGL ES 2.0 308k
PS3 libGCM 279k
Xbox 360 225k
in .txt file:
STRUCT ParticleCollisionEvent
CSRAW
private Vector3 m_Intersection;
private Vector3 m_Normal;
private Vector3 m_Velocity;
private GameObject m_GameObject;
// ...
END
@aras-p
aras-p / gist:5115269
Last active December 14, 2015 16:29
SourceTree performance
So our setup is quite slow for Hg as well. I'm using mid-2010 MBP with SSD, and hg
2.5.1 (have setup sourcetree to use system hg). We do use hg largefiles.
regular hg summary time: ~2.8s; hg status time: ~2.0s.
In ST I have automatic refresh disabled, since it's unusable with it. Manual
refresh of file status window takes about 4-5 seconds, and I do see two Python
processes launched - I guess it's using both hg summary & hg status? Could it
do summary in the background without blocking the UI, or an option to turn it off?
#ifdef CGBATCH_DLL
#if UNITY_WIN
#define CGBATCH_API extern "C" __declspec(dllexport)
#else
#define CGBATCH_API extern "C" __attribute__((visibility("default")))
#endif
#else
@aras-p
aras-p / sundaycoding.c
Created April 14, 2013 19:31
Sunday coding!
// actual code I've written today
// I was also reading this, which is excellent: http://www.agner.org/optimize/calling_conventions.pdf
*d++=0x48;*d++=0x81;*d++=0xEC;*(int*)d=kArgsSpace+8;d+=4; // sub rsp, kArgsSpace+8
*d++=0x4C;*d++=0x89;*d++=0x44;*d++=0x24;*d++=0x28; // mov [rsp+40], r8
*d++=0x4C;*d++=0x89;*d++=0x4C;*d++=0x24;*d++=0x30; // mov [rsp+48], r9
*d++=0x49;*d++=0x89;*d++=0xD0; // mov r8, rdx
*d++=0x49;*d++=0x89;*d++=0xC9; // mov r9, rcx
*d++=0x48;*d++=0x89;*d++=0xF9; // mov rcx, rdi
*d++=0x48;*d++=0x89;*d++=0xF2; // mov rdx, rsi
@aras-p
aras-p / set_gs_darwin.s
Last active May 26, 2023 04:28
How to set %gs base on Darwin
# _seems_ to make %gs base point to address in %rdi
# on x86-64 Darwin
#
# (what would be amd64_set_gsbase on FreeBSD, or
# arch_prctl with ARCH_SET_GS on Linux)
#
# Could find exacty zero documentation on this!
movl $0x3000003, %eax;
syscall;
@aras-p
aras-p / gist:5829553
Created June 21, 2013 07:38
C# vs US enum to float cast
// works in C#
Shader.SetGlobalFloat("_SrcBlendGlobal", (float)UnityEngine.Rendering.BlendMode.SrcAlpha);
// no worky in US
Shader.SetGlobalFloat("_SrcBlendGlobal", UnityEngine.Rendering.BlendMode.One cast float);
// BCE0022: Cannot convert 'UnityEngine.Rendering.BlendMode' to 'float'.
@aras-p
aras-p / timings.md
Last active December 19, 2015 01:29
lump timings

3yr old MBP, MacEditor

"./jam MacEditor -sCONFIG=release -a" for full rebuild; without -a for incremental

No lumps compared with lumping:

  • Full rebuild: 15:12 vs 10:47 (3747 vs 2878 targets)
  • Modify GameObject.h: 8:06 vs 5:23 (664 vs 157 targets)
  • Modify GfxDevice.h: 2:32 vs 3:17 (186 vs 68 targets) (lumping slower!)
  • Modify UnityGL.h: 0:48 vs 2:11 (60 vs 46 targets) (lumping slower!) -- however GL gfxdevice not lumped