This file contains 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
/* main.c */ | |
float muda(float x) | |
{ | |
float y; | |
float bora (float z) { | |
// extern float y; NG in gcc | |
return y + z; | |
} | |
This file contains 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
$ llvm-gcc -S -emit-llvm -fnested-functions main.c | |
; ModuleID = 'main.c' | |
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" | |
target triple = "i386-apple-darwin9.6" | |
%struct.FRAME.muda = type { float } | |
define float @muda(float %x) nounwind { | |
entry: | |
%x_addr = alloca float ; <float*> [#uses=2] |
This file contains 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
FrameBegin 1 | |
Format 512 512 1 | |
PixelSamples 2 2 | |
PixelFilter "box" 1 1 | |
ShadingRate 0.5 | |
ShadingInterpolation "smooth" | |
Display "ao.tiff" "file" "rgb" # render image to buffer | |
Projection "perspective" "fov" 22 | |
Translate 0 -0.5 8 | |
Rotate -40 1 0 0 |
This file contains 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
surface | |
ambocc(float samples = 128) | |
{ | |
float occ = 0; | |
normal nf = faceforward(normalize(N), I); | |
gather("illuminance", P, nf, PI/2, samples, "distribution", "cosine") { | |
occ += 1; | |
} |
This file contains 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
surface | |
mandel() | |
{ | |
float window_size = 512.0; | |
float xx, yy; | |
float x0, y0; | |
float max_iter = 255; | |
float iter = 0; |
This file contains 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
// Benchmark divpd and approximate division using cvt/rcp + Newton method. | |
#include <stdio.h> | |
#include <sys/time.h> | |
#include <xmmintrin.h> | |
#define NLOOP 100000 | |
#define ITER 256 | |
__m128d outputs[ITER]; | |
__m128d values[ITER]; |
This file contains 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
// | |
// SIMD Ray triangle intersection with ARM/NEON instruction. | |
// | |
// Compile: | |
// CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.2.1 | |
// CFLAGS=-march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon | |
// INCLUDES=-I/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin9/4.2.1/include | |
// OPTFLAGS=-O3 | |
// | |
// Copyright 2009. Syoyo Fujita. |
This file contains 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
isect4: | |
00000038 b081 sub sp, #4 | |
0000003a ed2d8b10 vstmdb sp!, {d8-d15} | |
0000003e b088 sub sp, #32 | |
00000040 ed9deb28 vldr d14, [sp, #160] | |
00000044 ed9dfb2a vldr d15, [sp, #168] | |
00000048 eddd2b2c vldr d18, [sp, #176] | |
0000004c eddd3b2e vldr d19, [sp, #184] | |
00000050 ed9d6b54 vldr d6, [sp, #336] | |
00000054 ed9d7b56 vldr d7, [sp, #344] |
This file contains 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
As binary form = '\xac\x00\x00\x00\x03global\x00\x9f\x00\x00\x00\x03camera\x00\x14\x00\x00\x00\x02name\x00\x05\x00\x00\x00muda\x00\x00\x04geom\x00x\x00\x00\x00\x030\x00p\x00\x00\x00\x04p\x00h\x00\x00\x00\x010\x00\x00\x00\x00\x00\x00\x00\xf0?\x011\x00\x00\x00\x00\x00\x00\x00\x00\x00\x012\x00\x00\x00\x00\x00\x00\x00\xf0?\x013\x00\x00\x00\x00\x00\x00\x00\x00@\x014\x00\x00\x00\x00\x00\x00\x00\x00\x00\x015\x00\x00\x00\x00\x00\x00\x00\xf0?\x016\x00\x00\x00\x00\x00\x00\x00\x08@\x017\x00\x00\x00\x00\x00\x00\x00\x00@\x018\x00\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00' | |
As python dict = {u'global': {u'camera': {u'name': u'muda'}, u'geom': [{u'p': [1.0, 0.0, 1.0, 2.0, 0.0, 1.0, 3.0, 2.0, 1.0]}]}} | |
As JSON = {"global": {"camera": {"name": "muda"}, "geom": [{"p": [1.0, 0.0, 1.0, 2.0, 0.0, 1.0, 3.0, 2.0, 1.0]}]}} |
This file contains 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
#!/usr/bin/env python | |
import json # Use JSON library provided by python 2.6 | |
from pymongo.bson import BSON | |
mycamera = {"name" : "muda"} | |
mygeom = {"p" : [1.0, 0.0, 1.0, 2.0, 0.0, 1.0, 3.0, 2.0, 1.0]} | |
scene = {"global" : {"camera" : mycamera, "geom" : [mygeom]}} |