Skip to content

Instantly share code, notes, and snippets.

View JayFoxRox's full-sized avatar

Jannik Vogel JayFoxRox

View GitHub Profile
#version 110
vec4 R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11;
#define R12 oPos /* R12 is a mirror of oPos */
int A0;
attribute vec4 v0;
attribute vec4 v1;
attribute vec4 v2;
static void debugger_export_vertex_shader(const char* file, KelvinState* kelvin, bool standalone) {
int i;
GLint prog;
glGetIntegerv(GL_CURRENT_PROGRAM,&prog);
FILE* f = fopen(file,"wb");
if (standalone) {
fprintf(f,"#version 110\n"
"\n"
// Writeable registers
"#define attribute\n"
@JayFoxRox
JayFoxRox / launch_program.fox
Created June 2, 2014 17:20
xqemu experimental launch program emulation for GL2
/*
* I can think of 3 ways to handle the launchable transform programs:
* - A CPU based interpreter and duplicate all behaviour from the vshader
* - Use the existing GPU code
* - Read back values using transform feedback (will require GL3, no mesa EXT)
* - Do one pass per constant and render the result into a float tex (GL2+EXT)
*/
#define GLSL_LOG_LENGTH 8192
@JayFoxRox
JayFoxRox / cubemap-flip.c
Last active August 29, 2015 14:02
OpengGL flipped GL_TEXTURE_CUBE_MAP
/* rm -f *.trace && reset && clear && clang cubemap-flip.c -lGL -lglut -lGLU -lGLEW && apitrace trace ./a.out */
#if 0
#define FLIP
#endif
/* This was written for XQEMU so we can see what to do about cubemaps in the
upside-down cache/FBO results.
FLIP and un-FLIP-ed should behave exactly the same. Also both should match
the reference (r key to switch).
// Module by infogulch and someone who "just stole it", just stolen again
#include "Chan.h"
#include "Modules.h"
#include "User.h"
class CQuitDetach : public CModule {
public:
MODCONSTRUCTOR(CQuitDetach) {}
virtual ~CQuitDetach() {}
#define LIT(dest, src) dest = _out(dest,_LIT(_in(src)))
vec4 _LIT(vec4 src)
{
vec4 s = src;
float epsilon=1.0/256.0;
s.w = clamp(s.w,-(128.0-epsilon),128.0-epsilon);
s.x = max(s.x,0.0);
s.y = max(s.y,0.0);
@JayFoxRox
JayFoxRox / xqemu-dotmapping
Last active August 29, 2015 14:27
xqemu DotMapping code. RFC
// GLSL
uvec4 texUint8(vec4 tex) {
return uivec4(tex * 255.0);
}
uint texUint32(vec4 tex) {
uvec4 utex = texUint8(tex);
return utex.a << 24 | utex.r << 16 | utex.g << 8 | utex.b;
}
// reset && clear && clang test-depth-fp.c && ./a.out 123
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
/* Found these by checking values represented by 0xFFFF and 0xFEFFFF */
#define F16_MAX 511.9375f
#define F24_MAX 340279770772509196049560342183603601408.0f
@JayFoxRox
JayFoxRox / tests.glsl
Last active September 25, 2015 12:50
MESA GLSL Notes
// Ran with MESA_GLSL=dump, "Mesa 11.0.0-devel (git-1bba29e) is supported"
#version 130
uniform vec4 ua;
uniform vec4 ub;
float add(float a, float b) {
@JayFoxRox
JayFoxRox / glsl-fail.glsl
Created September 25, 2015 13:00
MESA GLSL Notes (<3)
GLSL IR for linked vertex program 172:
(
(declare (location=0 shader_out ) vec4 gl_Position)
(declare (uniform ) vec4 ua)
(declare (uniform ) vec4 ub)
( function main
(signature void
(parameters
)
(