Skip to content

Instantly share code, notes, and snippets.

View syoyo's full-sized avatar
💗
ray tracing

Syoyo Fujita syoyo

💗
ray tracing
View GitHub Profile
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]
//
// 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.
// 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];
surface
mandel()
{
float window_size = 512.0;
float xx, yy;
float x0, y0;
float max_iter = 255;
float iter = 0;
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;
}
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
$ 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]
/* main.c */
float muda(float x)
{
float y;
float bora (float z) {
// extern float y; NG in gcc
return y + z;
}
##RenderMan RIB-Structure 1.0
version 3.03
Option "searchpath" "shader" ".:&"
Display "muda.tif" "file" "rgb"
Format 256 256 1
WorldBegin
Surface "bora"
PointsPolygons [ 4 ] [ 0 3 2 1 ] "P" [ 0.500000 0.500000 0.500000 0.500000 -0.500000 0.500000 -0.500000 -0.500000 0.500000 -0.500000 0.500000 0.500000 ]
"facevarying float s" [0.0 1.0 1.0 0.0]
"facevarying float t" [0.0 0.0 1.0 1.0]
##RenderMan RIB-Structure 1.0
version 3.03
Option "searchpath" "shader" ".:&"
Display "muda.tif" "file" "rgb"
Format 256 256 1
WorldBegin
Surface "bora"
PointsPolygons [ 4 ] [ 0 3 2 1 ] "P" [ 0.500000 0.500000 0.500000 0.500000 -0.500000 0.500000 -0.500000 -0.500000 0.500000 -0.500000 0.500000 0.500000 ]
"s" [0.0 1.0 1.0 0.0]
"t" [0.0 0.0 1.0 1.0]