Skip to content

VKCompute — Vulkan Compute from Scratch

A GPGPU tutorial series for Vulkan. No graphics pipeline, no swapchain, no window — just compute.

Most Vulkan material teaches rendering first and treats compute as a late chapter. VKCompute goes straight at general-purpose GPU programming in plain C11, across 10 self-contained chapters.

Each chapter is a single standalone main.c that builds to its own executable, prints what it is doing, and verifies its own results.

Who This Is For

  • You know C and want to use the GPU for computation rather than rendering.
  • You are coming from CUDA or OpenCL and want the portable, cross-vendor equivalent.
  • You have read a graphics-first Vulkan tutorial and want the compute path covered properly.

Prior GPU programming experience helps but is not required. Graphics experience is not needed at all.

What You'll Learn

Chapter Topic What You'll Build
01 Hello Compute Your first Vulkan program
02 Buffers GPU memory management
03 Descriptors Shader resource binding
04 Pipelines Compute pipeline creation
05 Synchronization GPU/CPU coordination
06 Memory Advanced memory strategies
07 Push Constants Fast parameter passing
08 Specialization Compile-time optimization
09 Subgroups Wave-level parallelism
10 Debugging Validation and profiling

Why Vulkan Compute?

Vulkan Compute gives you direct control over the GPU for general-purpose computing:

  • Cross-platform: Works on Windows, Linux, macOS, Android, and more
  • High performance: Minimal driver overhead, explicit control
  • Modern: Designed for today's parallel hardware
  • Industry standard: Backed by Khronos Group

Prerequisites

Before starting, you should have:

  • Basic C programming knowledge
  • Understanding of pointers and memory
  • Familiarity with command line/terminal
  • Prior GPU programming experience is appreciated but not exclusively required

Quick Start

# Clone the repository
git clone https://github.com/Rounak-Paul/vkcompute.git
cd vkcompute

# Build all chapters
./build.sh  # Linux/macOS
build.bat   # Windows

# Run your first program
./build/bin/ch01_hello_compute

Project Structure

vkcompute/
├── chapters/           # Tutorial source code
│   ├── ch01_hello_compute/
│   ├── ch02_buffers/
│   └── ...
├── vkc/               # Shared helper library
│   ├── include/       # Headers (vk_init.h, vk_utils.h, file_utils.h)
│   └── src/           # Implementation files
├── docs/              # This documentation
└── build/             # Compiled binaries

The vkc Helper Library

Chapter 1 uses raw Vulkan API to show every detail of initialization. From Chapter 2 onwards, we use the vkc helper library to reduce boilerplate so we can focus on the concepts being taught.

The library provides:

Header Purpose
vk_init.h VkcContext struct, instance/device creation, buffer helpers, shader loading, pipeline creation
vk_utils.h VK_CHECK error macros, logging, memory-type and queue-family lookup, timing
file_utils.h File I/O, SPIR-V loading, path resolution relative to executable

Key types and functions:

// Context holds all Vulkan state
VkcContext ctx;
vkc_init(&ctx, NULL);  // Initialize Vulkan

// Buffer creation with automatic memory allocation
VkcBuffer buffer;
vkc_create_buffer(&ctx, size, usage, memory_flags, &buffer);
vkc_upload_buffer(&ctx, &buffer, data, size);

// Shader loading
VkShaderModule shader;
vkc_load_shader(&ctx, "shader.comp.spv", &shader);

Educational Focus

The vkc library is intentionally simple and explicit. It's not a production framework — it's designed to be readable so you can see exactly what Vulkan calls are being made.

Ready to Begin?

Start with the Introduction for an overview of Vulkan concepts, or jump straight to Chapter 01 if you prefer learning by doing.

Learning Approach

Each chapter builds on the previous one. We recommend going through them in order, but feel free to skip ahead if you're already familiar with certain concepts.