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
//============================================================================ | |
// Copyright (c) 2024, Jarkko Lempiainen | |
// All rights reserved. | |
//============================================================================ | |
// This #include helper file can be used to #include OpenCL source files | |
// either as regular C++ source files to be compiled with a C++11 compiler | |
// (as normally done with regular #include) OR embedded as a c-strings to C++ | |
// programs. | |
// | |
// The included OpenCL files must be enclosed within OCL_SOURCE_BEGIN and |
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
template<typename T> | |
void bitonic_sort64(T vals_[64]) | |
{ | |
int h=-1; | |
do | |
{ | |
for(unsigned i=0; i<32; ++i) | |
{ | |
unsigned idx0=2*i; | |
unsigned idx1=4*(i&h)-2*(i+h)-1; |
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
uint16_t encode16_morton2(uint8_t x_, uint8_t y_) | |
{ | |
uint32_t res=x_|(uint32_t(y_)<<16); | |
res=(res|(res<<4))&0x0f0f0f0f; | |
res=(res|(res<<2))&0x33333333; | |
res=(res|(res<<1))&0x55555555; | |
return uint16_t(res|(res>>15)); | |
} | |
//---- |
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
struct vec2f {float x, y;}; | |
struct vec3f {float x, y, z;}; | |
//============================================================================ | |
// cone_uniform_vector | |
//============================================================================ | |
// Returns uniformly distributed unit vector on a [0, 0, 1] oriented cone of | |
// given apex angle and uniform random vector xi ([x, y] in range [0, 1]). | |
// e.g. cos_half_apex_angle = 0 returns samples on a hemisphere (cos(pi/2)=0), | |
// while cos_half_apex_angle = -1 returns samples on a sphere (cos(pi)=-1) |
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
struct vec3f {float x, y, z;}; | |
struct vec4f {float x, y, z, w;}; | |
struct mat44f {vec4f x, y, z, w;}; | |
//============================================================================ | |
// sphere_screen_extents | |
//============================================================================ | |
// Calculates the exact screen extents xyzw=[left, bottom, right, top] in | |
// normalized screen coordinates [-1, 1] for a sphere in view space. For | |
// performance, the projection matrix (v2p) is assumed to be setup so that |