$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
sphere_sorting.h
Go to the documentation of this file.
1 
9 #ifndef SPHERE_SORTING_H
10 #define SPHERE_SORTING_H
11 
12 #include "instanced_rendering.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;
48 } SphereSorter;
49 
55 void sphere_sorter_init(SphereSorter* 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, int count,
105  const vec3 camera_pos);
106 
107 #endif /* SPHERE_SORTING_H */
Mesh-based instanced rendering for spheres.
void sphere_sorter_cleanup(SphereSorter *sorter)
Destroys the sorter context.
Definition: sphere_sorting.c:163
GLuint sphere_sorter_sort_gpu(SphereSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos)
Sorts the array of instances Back-to-Front (descending depth) on GPU.
Definition: sphere_sorting.c:180
GLuint sphere_sorter_sort_cpu(SphereSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos)
Sorts the array of instances Back-to-Front (descending depth) on CPU.
Definition: sphere_sorting.c:327
void sphere_sorter_init(SphereSorter *sorter, int initial_capacity)
Allocates internal buffers for the sorter.
Definition: sphere_sorting.c:123
GLuint sphere_sorter_sort_cpu_radix(SphereSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos)
Sorts the array of instances Back-to-Front (descending depth) using Radix Sort.
Definition: sphere_sorting.c:387
Per-instance data sent to the shader via an instanced VBO.
Definition: instanced_rendering.h:23
Lightweight proxy for sorting data without moving large structs.
Definition: sphere_sorting.h:19
float depth
Definition: sphere_sorting.h:21
int original_index
Definition: sphere_sorting.h:20
Reusable memory context for sorting operations.
Definition: sphere_sorting.h:28
GLuint compute_program
Definition: sphere_sorting.h:29
GLint loc_k
Definition: sphere_sorting.h:40
SphereSortEntry * entries
Definition: sphere_sorting.h:42
int ssbo_capacity
Definition: sphere_sorting.h:45
GLint loc_stage
Definition: sphere_sorting.h:35
GLuint instance_ssbo
Definition: sphere_sorting.h:30
SphereSortEntry * entries_aux
Definition: sphere_sorting.h:43
int cpu_capacity
Definition: sphere_sorting.h:46
int min_capacity
Definition: sphere_sorting.h:47
SphereInstance * temp_instances
Definition: sphere_sorting.h:44
GLint loc_count_pot
Definition: sphere_sorting.h:37
GLuint sorted_instance_ssbo
Definition: sphere_sorting.h:32
GLuint index_ssbo
Definition: sphere_sorting.h:31
GLint loc_cam
Definition: sphere_sorting.h:38
GLint loc_count
Definition: sphere_sorting.h:36
GLint loc_j
Definition: sphere_sorting.h:39