Skip to content

Instantly share code, notes, and snippets.

View Shimmen's full-sized avatar

Simon Moos Shimmen

View GitHub Profile
@Shimmen
Shimmen / queue.glsl
Last active February 9, 2024 23:00
Generic range processor using MPMC circular queue in pseudo-GLSL
#ifndef QUEUE_GLSL
#define QUEUE_GLSL
////////////////////////////////////////////////////////////////////////////////
//
// The macro below will define functions `<name>QueueEnqueue` and `<name>QueueDequeue` which will return
// true or false depending on the success of the operation (will only try once) and take the element as
// the first parameter, as a in or out variable respectively.
//
// Note that these functions must be called from the subgroupElect():ed // subgroup in a shader invocation!
////////////////////////////////////////////////////////////////////////////////
// Range list logic
#define LIST_BUFFER_SIZE (8196)
#define LIST_BUFFER_MASK (LIST_BUFFER_SIZE - 1)
layout(set = 10, binding = 0) buffer coherent restrict WorkingCountsBlock {
uvec2 listBuffer[LIST_BUFFER_SIZE];
uint listWriteHead;
uint listWriteTail;
@Shimmen
Shimmen / mdlBufferToArray.swift
Created February 7, 2019 23:00
Convert a MDLMeshBuffer to an array of element types T
func toDataArray<T>(ofType type: T.Type, from buffer: MDLMeshBuffer, count: Int) -> [T] {
let pointer = buffer.map().bytes.bindMemory(to: type, capacity: count)
let bufferPointer = UnsafeBufferPointer(start: pointer, count: count)
return Array(bufferPointer)
}
package teamtim.teamtimapp.activities;
import android.app.Activity;
import android.content.Intent;
import java.util.List;
import teamtim.teamtimapp.database.DatabaseInterface;
import teamtim.teamtimapp.database.MockDatabase;
@Shimmen
Shimmen / snippet-breakdown.js
Created August 6, 2016 10:57
Google Analytics snippet breakdown
//
// Google Analytics snippet breakdown
//
// State that the name of the object is 'ga' (this can be changed if every instance of 'ga' in this file is replaced)
window['GoogleAnalyticsObject'] = 'ga';
// Set up the ga function. If it already exists, self assign it
window['ga'] = window['ga'] || function() {