This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install -y build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config xvfb nodejs npm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const benchmark = require('./src/index'), | |
fs = require('fs'); | |
const out = benchmark.multipleBenchmark({ | |
commonOptions: { | |
cpu_benchmark: true, | |
num_benchmarks: 5 | |
}, | |
range: { | |
optionName: 'matrix_size', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { parse } = require('acorn'); | |
const fs = require('fs'); | |
const file = fs.readFileSync('./__tests__/file-name.js').toString(); | |
const rootAST = parse(file, { | |
locations: true | |
}); | |
function traverse(ast) { | |
if (Array.isArray(ast)) { | |
for (let i = 0; i < ast.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken from examples at gpu.js: https://github.com/gpujs/gpu.js/blob/develop/examples/mandelbrot-set.html | |
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
import { GLView } from 'expo-gl'; | |
import { GPU } from '@gpujs/expo-gl'; | |
export default function App() { | |
createKernel(); | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kernel(context = null) { | |
const gl = context; | |
const glVariables0 = gl.getExtension('OES_texture_float'); | |
const glVariables1 = gl.getExtension('OES_texture_float_linear'); | |
const glVariables2 = gl.getExtension('OES_element_index_uint'); | |
const glVariables3 = gl.getExtension('WEBGL_draw_buffers'); | |
const glVariables4 = gl.getExtension('WEBGL_color_buffer_float'); | |
const glVariable5 = gl.createTexture(); | |
const glVariable6 = gl.createTexture(); | |
gl.enable(gl.SCISSOR_TEST); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float getMemoryOptimized32(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) { | |
ivec3 xyz = ivec3(x, y, z); | |
__GET_WRAPAROUND__; | |
int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z); | |
int channel = integerMod(index, 4); | |
index = index / 4; | |
int w = texSize.x; | |
vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5; | |
vec4 texel = texture2D(tex, st / vec2(texSize)); | |
if (channel == 0) return texel.r; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GPU } = require('gpu.js'); | |
const gpu = new GPU({ mode: 'gpu' }); | |
for (let i = 0; i < 1000; i++) { //1000 seems... so small... | |
const setup = setupBenchmark(i * 512); | |
benchmark(setup); | |
} | |
function setupBenchmark(size) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<canvas></canvas> | |
</body> | |
<script> | |
const canvas = document.querySelector('canvas'); | |
const gl = canvas.getContext('webgl2', { | |
alpha: false, | |
depth: false, | |
antialias: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<canvas></canvas> | |
</body> | |
<script> | |
const canvas = document.querySelector('canvas'); | |
const gl = canvas.getContext('webgl2', { | |
alpha: false, | |
depth: false, | |
antialias: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<canvas></canvas> | |
</body> | |
<script> | |
const canvas = document.querySelector('canvas'); | |
const gl = canvas.getContext('webgl2', { | |
alpha: false, | |
depth: false, | |
antialias: false |