|
SBgl 0.1.0
A graphics framework in C99
|
All notable changes to this project will be documented in this file.
sbgl_context_internal.h: New internal header exposing sbgl_GetContextArena() to allow subsystems (e.g., voxel engine) to allocate from the context's persistent arena instead of malloc.sbgl_BlendMode enum (NONE, ALPHA, ADDITIVE) to sbgl_PipelineConfig. The Vulkan backend now dynamically configures VkPipelineColorBlendAttachmentState based on the selected mode instead of hardcoding blendEnable = VK_FALSE.sbgl_Draw and sbgl_DrawIndexed to accept an explicit instanceCount parameter, enabling direct instancing without requiring Multi-Draw Indirect.SBGL_VOXEL_CHUNK_SIZE Constant: Replaced the magic number 256.0f and the local CHUNK_SIZE_F variable with a module-level #define in sbgl_voxel.c for maintainability.sbgl_Clear to sbgl_SetClearColor: The function name now accurately reflects its behavior (it stores the clear color for the next frame, not the current one). A backward-compatible #define sbgl_Clear sbgl_SetClearColor alias is provided, so existing code compiles without modification.sbgl_Voxel_Create and sbgl_Voxel_Destroy now use the context's persistent arena instead of malloc/free, aligning the voxel subsystem with the library's Data-Oriented Design memory model.sbgl_AABB mirror (cpuAABB). This eliminates a read-write hazard where the GPU could consume the previous frame's AABB data while the CPU was writing new AABBs.sbgl_LoadShaderFromFile fallback buffer from 256 to 1024 bytes to prevent silent path truncation with deeply nested directory structures.sbgl_gfx_PushConstants that rejects sizes exceeding SBGL_VK_PUSH_CONSTANT_SIZE (128 bytes) before the size_t to uint32_t cast, preventing silent truncation on 64-bit builds.managed_heap_free now emits a stderr warning when the requested offset is not found in any tracked range, aiding detection of double-free or memory corruption.SBL_ARENA_IMPLEMENTATION_GUARD to prevent the implementation section from being compiled twice when the header is included multiple times with SBL_ARENA_IMPLEMENTATION defined.(void) casts suppressing unused-function warnings for static_heap_alloc, dynamic_heap_alloc, managed_heap_alloc, and managed_heap_free in sbgl_backend_vulkan.c, as these functions are actively used by sbgl_gfx_CreateBuffer.SBGL_MANAGED_HEAP_SIZE from 256MB to 512MB to support high-density 3D voxel environments without buffer overflow.SBGL_BARRIER_HOST_TO_GRAPHICS to the public API and Vulkan backend to ensure host-mapped metadata (like chunk AABBs) is visible to the graphics pipeline.voxel3D_main where terrain would appear to regenerate or warp during movement.voxel_gen.comp to ensure noise sampling is consistent across chunk boundaries.shellPipe compute dispatch dimensions in sbgl_voxel.c to properly iterate over the entire 64x64 voxel column grid.voxel_mesh.comp by utilizing correctly scaled global heights.sbgl_Voxel_Update to synchronize GPU-side chunk deactivation with the subsequent culling and rendering passes.max_slots to 256 to improve performance and stability during rapid camera movement.vkAllocateMemory calls.tests/gpu_memory_test.c to verify the robustness of the managed heap's splitting and coalescing logic.bufferActive array for O(1) cache-efficient resource status checks.sbgl_gfx_CreateBuffer to perform linear metadata scans, fitting hundreds of checks into a single cache line.minUniformBufferOffsetAlignment across diverse GPU hardware.docs/manual/memory_management.md and docs/manual/vulkan_backend.md with detailed architectural deep-dives into the new hybrid memory model.sbgl_CreateComputePipeline, sbgl_DispatchCompute, and sbgl_MemoryBarrier to the public API.SBGL_SHADER_STAGE_COMPUTE in the shader loading system.examples/voxels/voxel3D_main.c.docs/COMPUTE.md with technical deep-dives into GPU culling and pipeline synchronization.volk (v1.4.350) using CMake FetchContent. This enables device-level function dispatching via VolkDeviceTable, reducing driver overhead for draw calls.math_test, arena_test, voxel_logic_test, etc.) to replace passive variable usage with explicit runtime validation, ensuring robust testing and resolving compiler warnings in Debug builds.SBGL_BUILD_STANDALONE mode where volk and platform-specific definitions were not correctly propagated to examples and tests.-Werror build in both Debug and Release configurations.sbgl_gfx_AllocateTransient to the internal HAL to enable low-overhead, linear sub-allocation from the persistent transient buffers.Debug to Release to prioritize performance.sbgl_radix_sort to use 8-bit passes (256 buckets) instead of 16-bit passes (65,536 buckets). This significantly reduces CPU cache misses and stack zeroing overhead.sbgl_radix_sort to accept external workspace buffers, eliminating per-frame malloc/free calls in the core batching system.sbgl_RenderQueuesEx to use the transient GPU allocator and optimized sorter, resolving the CPU bottleneck in the voxel example.sbgl_gfx_DrawIndirect to accept a byte offset, supporting multi-draw indirect commands within shared transient buffers.SblArena alignment to 16 bytes. This ensures compatibility with SIMD-optimized instructions generated by the compiler for aligned data types like sbgl_Mat4.sbl_arena_alloc where the first allocation in a new memory block could be misaligned if the block header size was not a multiple of the alignment.w component to 1.0.voxel_main, reducing CPU frame time from ~11ms to <2ms for standard render distances.sbgl_DrawPacket from 24 bytes to 16 bytes by packing MeshID, MaterialID, and rendering flags into a 32-bit header. This increases CPU cache density by 50% during sorting and batching.sbgl_Vertex to a 16-byte cache-aligned structure using int16_t[4] for positions (SNORM) and uint32_t for packed RGBA8 colors, reducing GPU vertex bandwidth by over 50%.transientArena in the engine context to handle merge-and-sort operations, eliminating heap allocations in the hot path.sbgl_SubmitDraw to expose bit-packed rendering flags (blendMode, sidedness, tags) directly to the public API.packet_packing_test.c to ensure structural alignment and bit-packing logic integrity.sbgl_SubmitDraw signature.tests/CMakeLists.txt to correctly handle engine test compilation when SBGL_BUILD_STANDALONE is enabled.core_flags_test.c to comply with strict compiler warnings and verified internal state machine transitions.vkGetPhysicalDeviceSurfaceFormatsKHR to resolve hardcoded format validation errors.VK_FORMAT_B8G8R8A8_SRGB and VK_FORMAT_R8G8B8A8_SRGB as preferred swapchain formats.sbgl_Buffer, sbgl_Shader, sbgl_Pipeline) for GPU resources using internal SoA pools for DOD-compliant performance.xxd).sbgl_DeviceWaitIdle() to the public API to ensure the GPU is idle before destroying resources.examples/triangle/triangle_main.c: Triangle rendering using vertex buffers and optional push-constant interaction.examples/camera/camera_main.c: 3D example with a rotating pyramid, depth testing, and perspective projection.docs/manual/rendering_pipeline.md covering the architecture and usage workflows.examples/ directory into topic-based subdirectories (window, input, camera, triangle, batching) and added docs/examples/index.md to catalog them.vkDestroyPipeline and vkDestroyBuffer validation errors (VUID-vkDestroyPipeline-pipeline-00765, VUID-vkDestroyBuffer-buffer-00922) in examples by adding explicit sbgl_DeviceWaitIdle() calls before resource destruction.sbgl.h and docs/manual/vulkan_backend.md with critical warnings regarding GPU synchronization and teardown sequences.vkCreateSwapchainKHR crashes (floating point exception) caused by zero-extent windows (minimized or unmapped) and unsupported image formats.imageFormat and imageColorSpace mismatches.examples/ directory. Tests are now located in a top-level tests/ directory.SBGL_BUILD_TESTS CMake option to toggle the compilation of internal tests independently of examples.SBGL_BUILD_EXAMPLES to strictly target demonstration applications.Debug build configuration to ensure development environments have Vulkan validation layers and strict warnings enabled by default.-Werror, -Wmissing-prototypes, -Wstrict-prototypes on GCC/Clang; /WX on MSVC) specifically for Debug builds to enforce coding standards.int main(void) and ensured all internal functions use explicit (void) parameter lists to satisfy strict prototype requirements..spv shader files were deleted by the CMake build system after header conversion, preventing examples from loading them at runtime.copy_if_different.-Werror build.docs/out to build/docs.CMakeLists.txt to dynamically configure Doxygen output paths, ensuring a cleaner root directory.shaders/ directory into examples/shaders/ to reduce root directory clutter and better reflect its purpose as example-only assets.sbgl_math.h) providing Vector (Vec2, Vec3, Vec4), Matrix (Mat4), and Quaternion types.sbgl_InvSqrt) based on the Quake III Arena algorithm using C99-compliant union punning.sbgl_vec3()) for natural initialization syntax.docs/MATH_LIB.md) with usage examples and implementation rationales.sbgl_IsKeyDown, sbgl_IsKeyPressed, sbgl_IsMouseButtonDown, sbgl_GetMousePos, and sbgl_GetMouseDelta.sbgl_GetInputState, providing a read-only pointer to the contiguous sbgl_InputState structure for direct array access.sbgl_GetWindowSize to the public API for context-based dimension queries.sbgl_InputState structure tied directly to the sbgl_Context.keysPressed tracking for frame-accurate trigger detection.malloc and free from the platform and Vulkan layers.sbgl_gfx_Init to accept the context's SblArena for graphics-layer allocations.sbgl_IsKeyDown, etc.) to perform validation checks and read directly from the context's internal state.CMakeLists.txt with automatic backend detection and protocol generation.SBGL_BUILD_EXAMPLES option (defaults to OFF for a minimal core build).SBGL_BUILD_STANDALONE option for compiling library sources directly into executables (Unity-style build).CMAKE_EXPORT_COMPILE_COMMANDS for LSP context support.docs-clean target to manage documentation artifacts.sbgl_platform.h for OS-agnostic windowing, timing, and native integration.window.c, input.c) with virtual key mapping.window_x11.c, input_x11.c).window_wayland.c, input_wayland.c).linux_internal.h.SBGL_USE_WAYLAND CMake option.libvulkan.so or vulkan-1.dll at runtime, eliminating build-time link dependencies.BeginFrame and EndFrame to clear the screen to a color using dynamic rendering.sbgl.h with an explicit Context management and physical scancode definitions.sbl_arena.h for zero-isolated-malloc window state allocation.sbgl_types.h to centralize forward declarations and resolve C99 typedef redefinition warnings.sbgl_input.h) and platform-specific implementations.memcpy for keyboard states with Struct Assignment.sbgl_IsKeyPressed)..gitignore.docs target to CMake (cmake --build build --target docs).docs/manual/vulkan_backend.md with a detailed explanation of the engine's graphics architecture.hello_window.c and input_test.c (interactive color switching) to verify the entire stack.sbgl_math.h using the __extension__ keyword.(void) casts, ensuring a clean build with -Wall -Wextra -Wpedantic.sbl_arena_free caused by a Use-After-Free when the arena structure was self-contained within its own memory blocks.isDrawing flag), preventing out-of-order command submissions.wl_keyboard and wl_pointer.BeginDrawing/EndDrawing pattern.