▲ 26 r/CUDA+1 crossposts

I made my own GPU graphics API

Hello everyone, in the last few weeks i decided to start a new project to learn and experiment with CUDA. So I decided to create my own graphics api for fun since i have not really seen a project like this before.

It's nothing particulary impressive but it could be interesting to some.

https://preview.redd.it/nye4qc37t39h1.png?width=1261&format=png&auto=webp&s=921e0a2b7899b6ad8d2d2b839a4041a4434d4435

The performance is very bad but hey at least it works!

API Interface

The API interface is exposed with a normal C header but the implementation is in CUDA.

The interface exposes:

  • stage buffers
  • textures
  • vertex and index buffers
  • command buffers
  • render passes
  • line, quad, and triangle draws
  • swapchain

Of course I didnt implement shaders or custom vertex attributes since I wanted to keep this simple and that would have been way too much work to do.

Current Performance Bottleneck

Right now the main bottleneck is Windows presentation through GDI (SetDIBitsToDevice).

C3D renders into CUDA-managed GPU memory, but CUDA cannot present that memory directly to a window surface. Instead, it has to copy the rendered image back to CPU-visible memory and hand it off to GDI for presentation. That extra GPU-to-CPU transfer plus the GDI blit is currently the slowest part of the frame path.

Here is a Tracy capture from the demo showing the presentation path under inspection:

https://preview.redd.it/qq9ifv56s39h1.png?width=1047&format=png&auto=webp&s=2b0d837e6106f49526285fb87c1de19acfec005b

Github

Heres the github repo if you want to check the code for yourself: https://github.com/luppichristian/C3D

Note: I used AI to write some of the code, my objective was to learn.

reddit.com
u/Slight_Watch697 — 12 days ago
▲ 7 r/cprogramming+1 crossposts

A better build system for C: bbs

Hi, I recently started working on a better build system for my C/C++ projects:

https://github.com/luppichristian/bbs.

It's basically a build system "frontend" built on top of cmake and bash that allows you to:

  • Metabuilder support (modify the compilation at runtime WITH CUSTOM HOOKED DLLS)
  • Automatic SDK detection (Vulkan SDK, etc.)
  • Cross-platform builds from a single configuration
  • Cross-compilation support (WSL, Docker, remote toolchains)
  • Automatic generation of .gitignore, CI workflows, and project files
  • File watching + hot-builds (looking at directory changes)
  • User-level package cache (dependencies downloaded once, reused everywhere, basically package system)
  • Unified compiler abstraction (translate flags between MSVC/GCC/Clang automatically)
  • Distribution pipeline for packaging releases
  • Integrated CTest support
  • Automatic toolchain setup and discovery
  • Automatic assets copy in distribution setups
  • Multi-target / multi-architecture builds
  • No manual SDK paths or environment setup required

What CMAKE does not do:

  • Discover and configure SDKs automatically
  • Set up cross-compilation environments
  • Manage user-wide dependency caches
  • Generate CI pipelines
  • Create distribution workflows
  • Watch files and rebuild automatically
  • Normalize compiler flags across toolchains
  • Configure Docker/WSL build environments

Why Add Another Layer On Top Of CMake:

  • CMake is widely used, but it still leaves a lot of multi-platform build setup in the hands of the project author
  • You still need to model targets, platform differences, toolchain choices, and common workflows in a way that stays manageable across environments

Why Build On Top Of CMake Instead Of Replacing It:

  • Most third-party C and C++ libraries already support CMake
  • Building on top of it means it stay compatible with the tooling and dependency ecosystem people already use

Maybe planned features:

  • shader compilation
  • custom asset compilation and pipeline support
  • metaprogramming features built around the Clang AST

NOTE: THIS IS AN EXPERIMENTAL PROJECT NOT PRODUCTION READY OR ANYTHING

I would appreciate if you try it out, since i am trying to fix as many bugs as possible.

Thank you

u/Slight_Watch697 — 1 month ago