Skip to content

Instantly share code, notes, and snippets.

View Themaister's full-sized avatar

Hans-Kristian Arntzen Themaister

View GitHub Profile
@Themaister
Themaister / test.cpp
Created October 5, 2025 11:39
Bringup sample #4 - Mandelbulb
#include "device.hpp"
#include "context.hpp"
#include "logging.hpp"
#include <stdlib.h>
static const uint32_t mandelbulb_shader[] =
#include "mandelbulb.h"
;
static void run_some_code(Vulkan::Device &dev)
@Themaister
Themaister / copy.comp
Last active October 5, 2025 10:10
Bringup sample #3 - descriptors
#version 460
layout(local_size_x = 16) in;
layout(set = 0, binding = 0) writeonly buffer Output
{
uint data[];
} o;
layout(set = 0, binding = 1) uniform usamplerBuffer i;
@Themaister
Themaister / copy.comp
Created October 4, 2025 11:01
Bringup sample #2 - Most basic compute
#version 460
// The version doesn't matter as much in Vulkan GLSL. This is the last version.
// In GLSL we have to enable special features as we use them.
#extension GL_EXT_buffer_reference : require
// For every workgroup, there is 16 threads.
layout(local_size_x = 16) in;
// Declares a pointer to data.
@Themaister
Themaister / CMakeLists.txt
Last active October 9, 2025 21:22
Bringup sample #1 - simple buffer copy
cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 99)
project(Vulkan-Bringup LANGUAGES CXX C)
# Don't want to build tons of unrelated cruft when building.
add_subdirectory(Granite EXCLUDE_FROM_ALL)
# Wrapper for add_executable plus linking some of the most basic libs like Vulkan backend.
add_granite_offline_tool(test test.cpp)
SIMD8 shader: 26 instructions. 0 loops. 572 cycles. 0:0 spills:fills. scheduled with mode top-down. Promoted 0 constants. Compacted 416 to 336 bytes (19%)
START B0 (352 cycles)
add(16) g4<1>UW g1.4<1,4,0>UW 0x11001010V { align1 WE_all 1H };
pln(8) g9<1>F g6<0,1,0>F g2<8,8,1>F { align1 1Q compacted };
pln(8) g10<1>F g6.4<0,1,0>F g2<8,8,1>F { align1 1Q compacted };
mov(8) g2<1>F g4<8,4,1>UW { align1 1Q };
mov(8) g3<1>F g4.4<8,4,1>UW { align1 1Q };
add(8) g2<1>F g2<8,8,1>F 0x3f000000F /* 0.5F */ { align1 1Q };
add(8) g3<1>F g3<8,8,1>F 0x3f000000F /* 0.5F */ { align1 1Q };
mov(8) g4<1>D g2<8,8,1>F { align1 1Q compacted };
// License: MIT
#include "jitter.hpp"
#include "llvm/IR/DataLayout.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Transforms/InstCombine/InstCombine.h"
#include "llvm/Transforms/Scalar.h"
// License: MIT
#pragma once
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/IR/IRBuilder.h"
@Themaister
Themaister / Setup.md
Last active January 10, 2019 20:32
Android Gradle basic setup for Vulkan

settings.gradle

include ':android' // Will pull in android/ folder as a subproject. I think you need this file even if you only have one project.

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
11-09 19:07:55.899 26914 26935 I Granite : Starting WSITiming frame serial: 468
11-09 19:07:55.899 26914 26935 I Granite : Updating frame pacing base to serial: 463 (delta: 16.760 ms)
11-09 19:07:55.899 26914 26935 I Granite : Have presentation timing for 5 frames in the past.
11-09 19:07:55.899 26914 26935 E Granite : *** Image was presented 1 frames late (target: 272190980.538 ms, rounded target: 272190979.494 ms, actual: 272190997.292 ms) compared to desired target. This normally happens in startup phase, but otherwise it's either a real hitch or app bug. ***
11-09 19:07:55.899 26914 26935 I Granite : Total latency: 61.869 ms, slack time: 16.608
11-09 19:07:55.899 26914 26935 E Granite : *** HITCH DETECTED ***
11-09 19:07:55.899 26914 26935 E Granite : Observed 1 dropped frames!
11-09 19:07:55.899 26914 26935 I Granite : Frame time ID #463: 33.470 ms
11-09 19:07:55.902 26914 26935 I Granite : Reported frame time: 16.793 ms
11-09 19:07:55.916 26914 26935 I Granite : Starting WSITiming frame serial: 469
#!/bin/bash
if [ -z $ANDROID_HOME ]; then
ANDROID_HOME="$HOME/Android/Sdk"
fi
echo "=== Installing SDK and NDK to $ANDROID_HOME. If this is not desired, override ANDROID_HOME environment variable! ==="
mkdir -p "$ANDROID_HOME"
cd "$ANDROID_HOME"