Skip to content

Instantly share code, notes, and snippets.

View BeRo1985's full-sized avatar

Benjamin Rosseaux BeRo1985

View GitHub Profile
@BeRo1985
BeRo1985 / clipline.glsl
Last active August 29, 2015 14:10
Clipping line in homogeneous coordinates
// by Benjamin 'BeRo' Rosseaux
// licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication ( http://creativecommons.org/publicdomain/zero/1.0/ )
void clipLineInHomogeneousCoordinates(inout vec4 pP0, inout vec4 pP1){
vec3 lWC0P = pP0.www + pP0.xyz;
vec3 lWC0S = pP0.www - pP0.xyz;
vec3 lWC1P = pP1.www + pP1.xyz;
vec3 lWC1S = pP1.www - pP1.xyz;
vec3 lTTP = lWC0P / (lWC0P - lWC1P);
vec3 lTTS = lWC0S / (lWC0S - lWC1S);
#ifdef NO_BOOLEAN_OPERATIONS
@BeRo1985
BeRo1985 / order_independent_transparency.glsl
Last active May 10, 2019 21:32
Hybrid atomic loop weighted blended order independent transparency implementation
// Hybrid atomic loop weighted blended order independent transparency implementation (work in progress)
// Copyright (C) 2014 by Benjamin 'BeRo' Rosseaux
// Licensed under the CC0 license, since in the German legislation exists no public
// domain.
// This implementation needs at least OpenGL 4.3 as minimum OpenGL version, due to my usage of shader storage buffer objects here
// Supports also additive blending for emission color portions
uniform sampler2D uTexTailWeightedBlendedOrderIndependentTransparencyColor;
@BeRo1985
BeRo1985 / compute shader NVIDIA driver 347.09 WHQL slowdown bug
Last active April 11, 2020 04:38
SDSM compute shader NVIDIA driver 347.09 WHQL slowdown bug
With version 347.09 WHQL tooks my SDSM tighting compute shader whole 70 ms per frame instead with the old verson 344.75 under 1ms (circa 0.7ms) on my GTX970.
See sdsm_reduce_tighting.glsl here, the $-stuff is my own preprocessor.
I'ver tracked to the "((lLinearZ >= reduceDataPartitions[lPartitionIndex].x) && (lLinearZ <= reduceDataPartitions[lPartitionIndex].w))" (in sdsm_reduce_tighting.glsl) comparsion down, but really just the comparsion itself, because:
70ms per frame:
if((lLinearZ >= reduceDataPartitions[lPartitionIndex].x) && (lLinearZ <= reduceDataPartitions[lPartitionIndex].w)){
minBoundsSun[lPartitionIndex] = min(minBoundsSun[lPartitionIndex], lSunLightSpaceCoord.xyz);
@BeRo1985
BeRo1985 / biginttest.dpr
Last active September 8, 2015 14:32
configurable fixed-bit-size signed big integer implementation
program biginttest;
{$ifdef fpc}
{$mode delphi}
{$endif}
{$APPTYPE CONSOLE}
(******************************************************************************
* zlib license *
*============================================================================*
* *
@BeRo1985
BeRo1985 / example1.asm
Last active August 29, 2015 14:27
ASM dot vs. non-dot per directive
;======================================================================
; With dot per directive
;======================================================================
.macro CopyData(Src, Dest, Count, UseRep){
.local Temp
cld
mov esi, Src
mov edi, Dest
@BeRo1985
BeRo1985 / test.c
Last active August 29, 2015 14:27
ScriptableAssembler (SASM) syntax example
/*
** Multi line comment
*/
// Single line commit
PE_SCN_CNT_CODE = 0x00000020
PE_SCN_CNT_INITIALIZED_DATA = 0x00000040
PE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080
PE_SCN_MEM_EXECUTE = 0x20000000
@BeRo1985
BeRo1985 / mtent12.txt
Created August 30, 2015 07:17
FLRE benchmark
Applied on http://www.gutenberg.org/files/3200/old/mtent12.txt at a whole-
file-loaded-into-the-RAM-base on a desktop computer with a Intel Xeon
E3-1245v2 CPU and 16GB (2x8GB) DDR3-1600 unbuffered ECC RAM under Windows
8.1
Time | Match count
==============================================================================
FLRE:
@BeRo1985
BeRo1985 / FLREvsSkRegExpW.txt
Last active September 4, 2015 20:19
FLREvsSkRegExpW
==============================================================================
FLRE:
/Twain/ : 8.24 ms | 2388
/(?i)Twain/ : 8.48 ms | 2657
/[a-z]shing/ : 8.67 ms | 1877
/Huck[a-zA-Z]+|Saw[a-zA-Z]+/ : 12.02 ms | 396
/\b\w+nn\b/ : 35.54 ms | 359
/[a-q][^u-z]{13}x/ : 110.64 ms | 4929
/Tom|Sawyer|Huckleberry|Finn/ : 20.05 ms | 3015
/(?i)Tom|Sawyer|Huckleberry|Finn/ : 29.85 ms | 4820
@BeRo1985
BeRo1985 / GDFWENet.pas
Last active September 26, 2015 06:04
enet pascal port with IPv6 support
(*
**
** Copyright (c) 2002-2015 Lee Salzman
** Copyright (c) 2013-2015 Benjamin 'BeRo' Rosseaux (Pascal port and IPv6)
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
** to deal in the Software without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Software, and to permit persons to whom the
@BeRo1985
BeRo1985 / nrook_antialiasing.glsl
Last active March 17, 2017 02:55
GLSL n-rook anti-aliasing - based on the idea from http://mlab.uiah.fi/~kkallio/antialiasing/EdgeFlagAA.pdf
// n-rook anti-aliasing - based on the idea from http://mlab.uiah.fi/~kkallio/antialiasing/
// GLSL implementation by Benjamin 'BeRo' Rosseaux
// licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication ( http://creativecommons.org/publicdomain/zero/1.0/ )
#version 150
#define nrookSamples 8
uniform vec2 resolution;
vec4 realMainContent(vec2 p){
vec4 c = vec4(0.);
// ...
return c;