|
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
|
Back-to-front sorting for transparent billboard geometry. More...
#include "billboard_sorter.h"#include "gl_common.h"#include "gl_debug.h"#include "log.h"#include "platform/platform_utils.h"#include "profiler.h"#include "scene_config.h"#include "shader.h"#include "sphere_types.h"#include <cglm/types.h>#include <cglm/vec3.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>Enumerations | |
| enum | { EXPECTED_SPHERE_INSTANCE_SIZE = 128 } |
| enum | { WORKGROUP_SIZE = 1024 , DEFAULT_MIN_CAPACITY = 64 , MAX_SINGLE_PASS_COUNT = 1024 , RADIX_BITS_PER_PASS = 8 , RADIX_BUCKETS = 256 , RADIX_SHIFT_LIMIT = 32 , RADIX_MASK = 0xFF } |
Functions | |
| static int | next_pow2 (int val) |
| static bool | ensure_cpu_capacity (BillboardSorter *sorter, int count) |
Grow CPU scratchpads to hold at least count elements. | |
| static GLuint | upload_sorted_to_ssbo (BillboardSorter *sorter, int count) |
Upload count sorted instances from the CPU temp buffer to the SSBO. | |
| void | billboard_sorter_init (BillboardSorter *sorter, int initial_capacity) |
| Allocates internal buffers for the sorter. | |
| void | billboard_sorter_cleanup (BillboardSorter *sorter) |
| Destroys the sorter context. | |
| 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. | |
| static int | compare_sphere_entries (const void *lhs, const void *rhs) |
| 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. | |
| static uint32_t | float_to_sortable_uint (float f_val) |
| Converts a float to a uint32_t that preserves order (IEEE 754). This allows sorting floats using integer radix sort. | |
| 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. | |
| GLuint | billboard_sorter_sort (BillboardSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos, SortingMode mode) |
| Dispatches the sorting task using the specified SortingMode. | |
Variables | |
| static const uint32_t | FLOAT_SIGN_MASK = 0x80000000U |
| static const uint32_t | FLOAT_COMPLEMENT_MASK = 0xFFFFFFFFU |
| static const unsigned int | BIT_SHIFT_8 = 8U |
| static const unsigned int | BIT_SHIFT_16 = 16U |
| static const size_t | GPU_ENTRY_SIZE = 8 |
Back-to-front sorting for transparent billboard geometry.
| anonymous enum |
| void billboard_sorter_cleanup | ( | BillboardSorter * | sorter | ) |
Destroys the sorter context.
| sorter | Pointer to the struct. |
| void billboard_sorter_init | ( | BillboardSorter * | sorter, |
| int | initial_capacity | ||
| ) |
Allocates internal buffers for the sorter.
| sorter | Pointer to the struct. |
| initial_capacity | Expected number of instances. |
| GLuint billboard_sorter_sort | ( | BillboardSorter * | sorter, |
| const SphereInstance * | instances, | ||
| int | count, | ||
| const vec3 | camera_pos, | ||
| SortingMode | mode | ||
| ) |
Dispatches the sorting task using the specified SortingMode.
| sorter | Memory context. |
| instances | Array of instances. |
| count | Active element count. |
| camera_pos | World-space viewer position. |
| mode | Sorting algorithm choice. |
| 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.
| sorter | Memory context. |
| instances | Array of instances (will be copied and sorted internally). |
| count | Active element count. |
| camera_pos | World-space viewer position. |
| 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.
| sorter | Memory context. |
| instances | Array of instances. |
| count | Active element count. |
| camera_pos | World-space viewer position (for depth). |
| 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.
| sorter | Memory context. |
| instances | Pointer to the array of instances to upload. |
| count | Active element count. |
| camera_pos | World-space viewer position. |
|
static |
|
static |
Grow CPU scratchpads to hold at least count elements.
|
inlinestatic |
Converts a float to a uint32_t that preserves order (IEEE 754). This allows sorting floats using integer radix sort.
|
static |
|
static |
Upload count sorted instances from the CPU temp buffer to the SSBO.
|
static |
|
static |
Bit-shift constants for next_pow2 (named to satisfy linter).
|
static |
|
static |
|
static |
Size of the Entry struct in the compute shader: int (4) + float (4).