How to set up a Vulkan application in C using libplacebo and SDL3 for boilerplate and rendering.
libplacebo is, in a nutshell, the core rendering algorithms and ideas of
mpv rewritten as an independent library. As of today,
libplacebo contains a large assortment of video processing shaders, focusing
on both quality and performance. These include features such as the following:
High-quality, optimized upscaling and downscaling including support for
polar filters ("Jinc"), anti-aliasing, anti-ringing and gamma correct
scaling.
Dynamic HDR tone mapping, including real-time measurement of scene
histogram, scene change detection, dynamic exposure control, perceptual gamut
stretching, contrast recovery and more.
Native support for Dolby Vision HDR, including Profile 5 conversion to
HDR/PQ or SDR, reading DV side data, and reshaping.
A colorimetrically accurate color management engine with support for
soft gamut mapping, ICC profiles, accurate ITU-R BT.1886 emulation, black
point compensation, and custom 3DLUTs (.cube).
A pluggable, extensible custom shader
system. This can be used to
arbitrarily extend the range of custom shaders to include popular user
shaders like RAVU, FSRCNNX, or Anime4K. See the mpv wiki on user
scripts
for more information.
High performance film grain synthesis for AV1 and H.274, allowing media
players to offload this part of decoding from the CPU to the GPU.
Tunable, fast debanding and deinterlacing shaders.
High quality gamma-correct dithering, including error diffusion modes.
Every attempt was made to provide these features at a high level of
abstraction, taking away all the messy details of GPU programming, color
spaces, obscure subsampling modes, image metadata manipulation, and so on.
Expert-level functionality is packed into easy-to-use functions like
pl_frame_from_avframe and pl_render_image.
Vulkan is a cross-platform API and open standard for 3D graphics and parallelized computing. It was intended to address the shortcomings of OpenGL, and allow developers more control over the GPU. It is designed to support a wide variety of GPUs, CPUs and operating systems, and modern multi-core CPUs also.
Vulkan is intended to offer higher performance and more efficient CPU and GPU usage compared to the older OpenGL and Direct3D 11 APIs, by providing a considerably lower-level API that more closely resembles how modern GPUs work. Vulkan is comparable to Apple's Metal API and Microsoft's Direct3D 12. In addition to its lower CPU usage, Vulkan is designed to allow developers to better distribute work among multiple CPU cores.
Vulkan was first announced by the non-profit Khronos Group at GDC 2015. The Vulkan API was initially referred to as the "next generation OpenGL initiative", or "OpenGL next" by Khronos, but use of those names was discontinued when "Vulkan" was announced.
Vulkan is derived from and built upon components of AMD's Mantle API, which was donated by AMD to Khronos with the intent of giving Khronos a foundation on which to begin developing a low-level API that they could standardize across the industry.
Simpl
Why it's here
1 person recommends this
What people say. Recommended as a great demonstration of using libplacebo to simplify Vulkan boilerplate in C.
C
u/CodesOtakuYTin r/C_Programming • Recommends
Vulkan app in 100 lines of pure C!
Am using libplacebo for the boilerplate, which is used by MPV for vulkan rendering
it gives you an HDR capable swapchain out of the gate, checks for surface compatibility for you and create async compute/transfer queues, acquire image for you, present for you, create an instance with validation layer callback for you, gives you a great allocator (no need for VMA which is C++)
supports OpenGL, Direct3D and Vulkan, gives you runtime shaders too, and helpers for loading, uploading and creating pipelines
and most importantly you don't lose control at any point, you still have full access to vulkan handles so if you don't like some libplacebo abstraction, y…