$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
billboard_sorting.h
Go to the documentation of this file.
1 
9 #ifndef BILLBOARD_SORTING_H
10 #define BILLBOARD_SORTING_H
11 
12 #include "sphere_types.h"
13 #include <cglm/cglm.h>
14 
19 typedef struct {
21  float depth;
23 
28 typedef struct {
29  GLuint compute_program;
30  GLuint instance_ssbo;
31  GLuint index_ssbo;
34  /* Cached uniform locations (resolved once at init). */
35  GLint loc_stage;
36  GLint loc_count;
37  GLint loc_count_pot;
38  GLint loc_cam;
39  GLint loc_j;
40  GLint loc_k;
49 
55 void billboard_sorter_init(BillboardSorter* sorter, int initial_capacity);
56 
62 
76  const SphereInstance* instances, int count,
77  const vec3 camera_pos);
78 
91  const SphereInstance* instances, int count,
92  const vec3 camera_pos);
93 
104  const SphereInstance* instances,
105  int count, const vec3 camera_pos);
106 
107 #endif /* BILLBOARD_SORTING_H */
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.
Definition: billboard_sorting.c:395
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.
Definition: billboard_sorting.c:186
void billboard_sorter_init(BillboardSorter *sorter, int initial_capacity)
Allocates internal buffers for the sorter.
Definition: billboard_sorting.c:129
void billboard_sorter_cleanup(BillboardSorter *sorter)
Destroys the sorter context.
Definition: billboard_sorting.c:169
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.
Definition: billboard_sorting.c:334
Pure-data type for per-instance sphere attributes.
Lightweight proxy for sorting data without moving large structs.
Definition: billboard_sorting.h:19
float depth
Definition: billboard_sorting.h:21
int original_index
Definition: billboard_sorting.h:20
Reusable memory context for sorting operations.
Definition: billboard_sorting.h:28
GLint loc_cam
Definition: billboard_sorting.h:38
int cpu_capacity
Definition: billboard_sorting.h:46
GLuint instance_ssbo
Definition: billboard_sorting.h:30
GLuint index_ssbo
Definition: billboard_sorting.h:31
int ssbo_capacity
Definition: billboard_sorting.h:45
BillboardSortEntry * entries_aux
Definition: billboard_sorting.h:43
GLint loc_j
Definition: billboard_sorting.h:39
GLint loc_count_pot
Definition: billboard_sorting.h:37
GLint loc_count
Definition: billboard_sorting.h:36
GLuint compute_program
Definition: billboard_sorting.h:29
int min_capacity
Definition: billboard_sorting.h:47
SphereInstance * temp_instances
Definition: billboard_sorting.h:44
GLuint sorted_instance_ssbo
Definition: billboard_sorting.h:32
GLint loc_k
Definition: billboard_sorting.h:40
GLint loc_stage
Definition: billboard_sorting.h:35
BillboardSortEntry * entries
Definition: billboard_sorting.h:42
Per-instance data sent to the shader via an instanced VBO.
Definition: sphere_types.h:25