$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
billboard_sorting.h File Reference

Back-to-front sorting for transparent geometry. More...

#include "sphere_types.h"
#include <cglm/cglm.h>
Include dependency graph for billboard_sorting.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BillboardSortEntry
 Lightweight proxy for sorting data without moving large structs. More...
 
struct  BillboardSorter
 Reusable memory context for sorting operations. More...
 

Functions

void billboard_sorter_init (BillboardSorter *sorter, int initial_capacity)
 Allocates internal buffers for the sorter. More...
 
void billboard_sorter_cleanup (BillboardSorter *sorter)
 Destroys the sorter context. More...
 
GLuint billboard_sorter_sort_gpu (BillboardSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos)
 Sorts the array of instances Back-to-Front (descending depth) on GPU. More...
 
GLuint billboard_sorter_sort_cpu (BillboardSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos)
 Sorts the array of instances Back-to-Front (descending depth) on CPU. More...
 
GLuint billboard_sorter_sort_cpu_radix (BillboardSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos)
 Sorts the array of instances Back-to-Front (descending depth) using Radix Sort. More...
 

Detailed Description

Back-to-front sorting for transparent geometry.

This module provides an efficient sorting mechanism for sphere instances, which is required for correct alpha blending of billboarded spheres.

Function Documentation

◆ billboard_sorter_cleanup()

void billboard_sorter_cleanup ( BillboardSorter *  sorter)

Destroys the sorter context.

Parameters
sorterPointer to the struct.

◆ billboard_sorter_init()

void billboard_sorter_init ( BillboardSorter *  sorter,
int  initial_capacity 
)

Allocates internal buffers for the sorter.

Parameters
sorterPointer to the struct.
initial_capacityExpected number of instances.
Here is the call graph for this function:

◆ billboard_sorter_sort_cpu()

GLuint billboard_sorter_sort_cpu ( BillboardSorter *  sorter,
const SphereInstance *  instances,
int  count,
const vec3  camera_pos 
)

Sorts the array of instances Back-to-Front (descending depth) on CPU.

Uses qsort on the host and uploads the result to the SSBO.

Parameters
sorterMemory context.
instancesArray of instances (will be copied and sorted internally).
countActive element count.
camera_posWorld-space viewer position.
Returns
The SSBO handle containing the sorted instances.
Here is the call graph for this function:

◆ billboard_sorter_sort_cpu_radix()

GLuint billboard_sorter_sort_cpu_radix ( BillboardSorter *  sorter,
const SphereInstance *  instances,
int  count,
const vec3  camera_pos 
)

Sorts the array of instances Back-to-Front (descending depth) using Radix Sort.

Parameters
sorterMemory context.
instancesArray of instances.
countActive element count.
camera_posWorld-space viewer position (for depth).
Returns
The SSBO handle containing the sorted instances.
Here is the call graph for this function:

◆ billboard_sorter_sort_gpu()

GLuint billboard_sorter_sort_gpu ( BillboardSorter *  sorter,
const SphereInstance *  instances,
int  count,
const vec3  camera_pos 
)

Sorts the array of instances Back-to-Front (descending depth) on GPU.

Uploads instances to an SSBO, sorts them using a compute shader, and prepares them for rendering.

Parameters
sorterMemory context.
instancesPointer to the array of instances to upload.
countActive element count.
camera_posWorld-space viewer position.
Returns
The SSBO handle containing the sorted instances.
Here is the call graph for this function: