Skip to content

Instantly share code, notes, and snippets.

View jamornsriwasansak's full-sized avatar

Jamorn Sriwasansak jamornsriwasansak

View GitHub Profile
% Some predefined strings for conferences & journals
@string{AAAI = "Conference on Artificial Intelligence (AAAI)"}
@string{AISTATS = "International Conference on Artificial Intelligence and Statistics (AISTATS)"}
@string{Bernoulli = "Bernoulli"}
@string{Biometrika = "Biometrika"}
@string{CandG = "Computers \& Graphics"}
@string{CACM = "Commun. ACM"}
@string{CG_SIGGRAPH = "Comput. Graph. (Proc. SIGGRAPH)"}
@string{CGA = "IEEE Comput. Graph. Appl."}
@string{CGF = "Comput. Graph. Forum"}
@cdwfs
cdwfs / vk_cpu_gpu_timestamp.cpp
Last active December 12, 2021 06:01
Vulkan function to get a pair of timestamps (one CPU, one GPU) corresponding to (very nearly) the same point in absolute wall time.
struct CpuGpuTimestampInfo {
VkDevice device;
VkQueue queue;
uint32_t queue_family_index;
float timestamp_period; // Copy from VkPhysicalDeviceLimits::timestampPeriod
uint32_t timestamp_valid_bits; // Copy from VkQueueFamilyProperties::timestampValidBits
};
VkResult GetCpuGpuTimestamp(const CpuGpuTimestampInfo *info,
std::chrono::high_resolution_clock::time_point *out_cpu_time, uint64_t *out_gpu_time) {
if (info->timestamp_valid_bits == 0) {
@tilkinsc
tilkinsc / load_dds.c
Last active March 23, 2024 17:20
C OpenGL DDS Loading Tutorial
/*
Can load easier and more indepth with https://github.com/Hydroque/DDSLoader
Because a lot of crappy, weird DDS file loader files were found online. The resources are actually VERY VERY limited.
Written in C, can very easily port to C++ through casting mallocs (ensure your imports are correct), goto can be replaced.
https://www.gamedev.net/forums/topic/637377-loading-dds-textures-in-opengl-black-texture-showing/
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/
^ Two examples of terrible code
// smallgdpt: a simple implementation of gradient domain path tracing
// https://mediatech.aalto.fi/publications/graphics/GPT/
// adapted from smallpt by Kevin Beason http://www.kevinbeason.com/smallpt/
// and a screened poisson solver by Pravin Bhat http://grail.cs.washington.edu/projects/screenedPoissonEq/
// to build, type: g++ -o smallgdpt -fopenmp -O3 smallgdpt.cpp -L/usr/local/lib -lm -lfftw3
// you will need fftw3 http://www.fftw.org/ to compile
// usage: ./smallgdpt [number of samples per pixel]
#include <fftw3.h>
#include <math.h>
#include <stdlib.h>
@rygorous
rygorous / gist:2156668
Last active April 16, 2024 11:18
float->half variants
// float->half variants.
// by Fabian "ryg" Giesen.
//
// I hereby place this code in the public domain, as per the terms of the
// CC0 license:
//
// https://creativecommons.org/publicdomain/zero/1.0/
//
// float_to_half_full: This is basically the ISPC stdlib code, except
// I preserve the sign of NaNs (any good reason not to?)