SBgl 0.1.0
A graphics framework in C99
Loading...
Searching...
No Matches
sbgl_types.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "sbgl_math.h"
Include dependency graph for sbgl_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sbgl_InstanceData
 Per-instance data for automated batching. More...
 
struct  sbgl_Vertex
 Standard vertex structure for basic geometry rendering. Optimized for cache density (16 bytes). More...
 
struct  sbgl_DrawPacket
 Encapsulates all data required to submit a single draw call. Optimized for cache density (16 bytes). More...
 
struct  sbgl_IndirectCommand
 Standard Vulkan Indirect Draw command layout. More...
 
struct  sbgl_VertexAttribute
 Vertex attribute definition. More...
 
struct  sbgl_Telemetry
 Performance telemetry data for a single frame. More...
 
struct  sbgl_VertexLayout
 Vertex input layout definition. More...
 
struct  sbgl_PipelineConfig
 Configuration for creating a graphics pipeline. More...
 
struct  sbgl_ErrorDetail
 Detailed error information for debugging. More...
 
struct  sbgl_Context
 Engine context. More...
 
struct  sbgl_ResourceLimits
 Resource limits for engine initialization. More...
 
struct  sbgl_InitConfig
 Configuration for engine initialization. More...
 
struct  sbgl_InitResult
 Result structure for initialization. More...
 

Macros

#define SBGL_INVALID_HANDLE   0
 
#define SBGL_INVALID_OFFSET   ((uint32_t)-1)
 
#define SBGL_PACKET_MESH_MASK   0x7FF
 
#define SBGL_PACKET_MAT_MASK   0x7FF
 
#define SBGL_PACKET_BLEND_MASK   0x3
 
#define SBGL_PACKET_SIDED_MASK   0x1
 
#define SBGL_PACKET_TAGS_MASK   0x7F
 
#define SBGL_PACKET_MAT_SHIFT   11
 
#define SBGL_PACKET_BLEND_SHIFT   22
 
#define SBGL_PACKET_SIDED_SHIFT   24
 
#define SBGL_PACKET_TAGS_SHIFT   25
 
#define SBGL_VOXEL_ID_MASK   0x3FFFF
 
#define SBGL_VOXEL_SCALE_MASK   0xFF
 
#define SBGL_VOXEL_SCALE_SHIFT   18
 
#define SBGL_VOXEL_MAT_MASK   0x3F
 
#define SBGL_VOXEL_MAT_SHIFT   26
 
#define SBGL_PACK_VOXEL_INSTANCE(id, scale, mat)
 
#define SBGL_PACK_HEADER(mesh, mat, blend, sided, tags)
 
#define SBGL_GET_MESH_ID(h)
 
#define SBGL_GET_MAT_ID(h)
 
#define SBGL_GET_BLEND_MODE(h)
 
#define sbgl_DefaultInitConfig
 Default initialization configuration values.
 

Typedefs

typedef uint32_t sbgl_Buffer
 Handle for a GPU-side buffer.
 
typedef uint32_t sbgl_Shader
 Handle for a shader module.
 
typedef uint32_t sbgl_Pipeline
 Handle for a graphics pipeline.
 
typedef uint32_t sbgl_ComputePipeline
 Handle for a compute pipeline.
 
typedef uint64_t sbgl_SortKey
 Bit-packed key used for sorting draw commands to minimize state changes.
 
typedef struct sbgl_RenderQueue sbgl_RenderQueue
 Internal queue used to batch and sort draw packets before submission.
 
typedef struct sbgl_Context sbgl_Context
 Engine context.
 
typedef struct sbgl_Window sbgl_Window
 

Enumerations

enum  sbgl_BufferUsage {
  SBGL_BUFFER_USAGE_VERTEX = 0x01 , SBGL_BUFFER_USAGE_INDEX = 0x02 , SBGL_BUFFER_USAGE_STORAGE = 0x04 , SBGL_BUFFER_USAGE_INDIRECT = 0x08 ,
  SBGL_BUFFER_USAGE_TRANSFER_DST = 0x10
}
 Buffer usage flags. More...
 
enum  sbgl_ShaderStage { SBGL_SHADER_STAGE_VERTEX = 0x01 , SBGL_SHADER_STAGE_FRAGMENT = 0x02 , SBGL_SHADER_STAGE_COMPUTE = 0x04 }
 Shader stage flags. More...
 
enum  sbgl_BarrierType {
  SBGL_BARRIER_COMPUTE_TO_COMPUTE = 0 , SBGL_BARRIER_COMPUTE_TO_INDIRECT = 1 , SBGL_BARRIER_COMPUTE_TO_GRAPHICS = 2 , SBGL_BARRIER_GRAPHICS_TO_COMPUTE = 3 ,
  SBGL_BARRIER_HOST_TO_COMPUTE = 4 , SBGL_BARRIER_HOST_TO_GRAPHICS = 5
}
 Memory barrier types for compute synchronization. More...
 
enum  sbgl_Format {
  SBGL_FORMAT_R32_SFLOAT = 0 , SBGL_FORMAT_R32G32_SFLOAT = 1 , SBGL_FORMAT_R32G32B32_SFLOAT = 2 , SBGL_FORMAT_R32G32B32A32_SFLOAT = 3 ,
  SBGL_FORMAT_R16G16B16A16_SNORM = 4 , SBGL_FORMAT_R8G8B8A8_UNORM = 5
}
 Data formats for vertex attributes. More...
 
enum  sbgl_BlendMode { SBGL_BLEND_MODE_NONE = 0 , SBGL_BLEND_MODE_ALPHA = 1 , SBGL_BLEND_MODE_ADDITIVE = 2 }
 Blending modes for pipeline color attachments. More...
 
enum  sbgl_Result {
  SBGL_SUCCESS = 0 , SBGL_ERROR_NULL_CONTEXT = 1 , SBGL_ERROR_INVALID_ARGUMENT = 2 , SBGL_ERROR_INITIALIZATION_FAILED = 3 ,
  SBGL_ERROR_WINDOW_CREATION_FAILED = 4 , SBGL_ERROR_GRAPHICS_FAILED = 5 , SBGL_ERROR_OUT_OF_MEMORY = 6 , SBGL_ERROR_DEVICE_BUSY = 7 ,
  SBGL_ERROR_INVALID_HANDLE = 8 , SBGL_ERROR_SWAPCHAIN_FAILED = 9 , SBGL_ERROR_SHADER_FAILED = 10 , SBGL_ERROR_PIPELINE_FAILED = 11 ,
  SBGL_ERROR_PLATFORM_FAILED = 12
}
 Result codes for engine operations. More...
 
enum  sbgl_platform_Result { SBGL_PLATFORM_SUCCESS = 0 , SBGL_PLATFORM_ERROR_WINDOW_FAILED = 1 , SBGL_PLATFORM_ERROR_NO_DISPLAY = 2 , SBGL_PLATFORM_ERROR_INIT_FAILED = 3 }
 Result codes for platform layer operations. More...
 
enum  sbgl_BackendType { SBGL_BACKEND_VULKAN = 0 }
 Backend types supported by the engine. More...
 

Macro Definition Documentation

◆ sbgl_DefaultInitConfig

#define sbgl_DefaultInitConfig
Value:
.windowWidth = 800, \
.windowHeight = 600, \
.windowTitle = "SBgl Application", \
.limits = { .maxBuffers = 1024, .maxShaders = 256, .maxPipelines = 256 }, \
.enableValidation = true \
})
Configuration for engine initialization.
Definition sbgl_types.h:308

Default initialization configuration values.

Use this as a starting point for custom configurations:

config.windowWidth = 1920;
config.windowHeight = 1080;
config.limits.maxBuffers = 4096;
sbgl_InitResult sbgl_InitWithConfig(const sbgl_InitConfig *config)
Initializes the engine and opens a window with explicit configuration.
Definition sbgl_core.c:112
#define sbgl_DefaultInitConfig
Default initialization configuration values.
Definition sbgl_types.h:328
uint32_t windowWidth
Definition sbgl_types.h:309
sbgl_ResourceLimits limits
Definition sbgl_types.h:312
uint32_t windowHeight
Definition sbgl_types.h:310
Result structure for initialization.
Definition sbgl_types.h:339

Definition at line 328 of file sbgl_types.h.

328#define sbgl_DefaultInitConfig ((sbgl_InitConfig){ \
329 .windowWidth = 800, \
330 .windowHeight = 600, \
331 .windowTitle = "SBgl Application", \
332 .limits = { .maxBuffers = 1024, .maxShaders = 256, .maxPipelines = 256 }, \
333 .enableValidation = true \
334})

◆ SBGL_GET_BLEND_MODE

#define SBGL_GET_BLEND_MODE ( h)
Value:
#define SBGL_PACKET_BLEND_SHIFT
Definition sbgl_types.h:66
#define SBGL_PACKET_BLEND_MASK
Definition sbgl_types.h:61

Definition at line 91 of file sbgl_types.h.

◆ SBGL_GET_MAT_ID

#define SBGL_GET_MAT_ID ( h)
Value:
#define SBGL_PACKET_MAT_MASK
Definition sbgl_types.h:60
#define SBGL_PACKET_MAT_SHIFT
Definition sbgl_types.h:65

Definition at line 90 of file sbgl_types.h.

◆ SBGL_GET_MESH_ID

#define SBGL_GET_MESH_ID ( h)
Value:
#define SBGL_PACKET_MESH_MASK
Definition sbgl_types.h:59

Definition at line 89 of file sbgl_types.h.

◆ SBGL_INVALID_HANDLE

#define SBGL_INVALID_HANDLE   0

Definition at line 8 of file sbgl_types.h.

◆ SBGL_INVALID_OFFSET

#define SBGL_INVALID_OFFSET   ((uint32_t)-1)

Definition at line 9 of file sbgl_types.h.

◆ SBGL_PACK_HEADER

#define SBGL_PACK_HEADER ( mesh,
mat,
blend,
sided,
tags )
Value:
(((mesh) & SBGL_PACKET_MESH_MASK) | \
#define SBGL_PACKET_SIDED_SHIFT
Definition sbgl_types.h:67
#define SBGL_PACKET_SIDED_MASK
Definition sbgl_types.h:62
#define SBGL_PACKET_TAGS_MASK
Definition sbgl_types.h:63
#define SBGL_PACKET_TAGS_SHIFT
Definition sbgl_types.h:68

Definition at line 82 of file sbgl_types.h.

82#define SBGL_PACK_HEADER(mesh, mat, blend, sided, tags) \
83 (((mesh) & SBGL_PACKET_MESH_MASK) | \
84 (((mat) & SBGL_PACKET_MAT_MASK) << SBGL_PACKET_MAT_SHIFT) | \
85 (((blend) & SBGL_PACKET_BLEND_MASK) << SBGL_PACKET_BLEND_SHIFT) | \
86 (((sided) & SBGL_PACKET_SIDED_MASK) << SBGL_PACKET_SIDED_SHIFT) | \
87 (((tags) & SBGL_PACKET_TAGS_MASK) << SBGL_PACKET_TAGS_SHIFT))

◆ SBGL_PACK_VOXEL_INSTANCE

#define SBGL_PACK_VOXEL_INSTANCE ( id,
scale,
mat )
Value:
#define SBGL_VOXEL_SCALE_SHIFT
Definition sbgl_types.h:75
#define SBGL_VOXEL_SCALE_MASK
Definition sbgl_types.h:74
#define SBGL_VOXEL_MAT_SHIFT
Definition sbgl_types.h:77
#define SBGL_VOXEL_ID_MASK
Definition sbgl_types.h:73
#define SBGL_VOXEL_MAT_MASK
Definition sbgl_types.h:76

Definition at line 79 of file sbgl_types.h.

79#define SBGL_PACK_VOXEL_INSTANCE(id, scale, mat) \
80 (((id) & SBGL_VOXEL_ID_MASK) | (((scale) & SBGL_VOXEL_SCALE_MASK) << SBGL_VOXEL_SCALE_SHIFT) | (((mat) & SBGL_VOXEL_MAT_MASK) << SBGL_VOXEL_MAT_SHIFT))

◆ SBGL_PACKET_BLEND_MASK

#define SBGL_PACKET_BLEND_MASK   0x3

Definition at line 61 of file sbgl_types.h.

◆ SBGL_PACKET_BLEND_SHIFT

#define SBGL_PACKET_BLEND_SHIFT   22

Definition at line 66 of file sbgl_types.h.

◆ SBGL_PACKET_MAT_MASK

#define SBGL_PACKET_MAT_MASK   0x7FF

Definition at line 60 of file sbgl_types.h.

◆ SBGL_PACKET_MAT_SHIFT

#define SBGL_PACKET_MAT_SHIFT   11

Definition at line 65 of file sbgl_types.h.

◆ SBGL_PACKET_MESH_MASK

#define SBGL_PACKET_MESH_MASK   0x7FF

Definition at line 59 of file sbgl_types.h.

◆ SBGL_PACKET_SIDED_MASK

#define SBGL_PACKET_SIDED_MASK   0x1

Definition at line 62 of file sbgl_types.h.

◆ SBGL_PACKET_SIDED_SHIFT

#define SBGL_PACKET_SIDED_SHIFT   24

Definition at line 67 of file sbgl_types.h.

◆ SBGL_PACKET_TAGS_MASK

#define SBGL_PACKET_TAGS_MASK   0x7F

Definition at line 63 of file sbgl_types.h.

◆ SBGL_PACKET_TAGS_SHIFT

#define SBGL_PACKET_TAGS_SHIFT   25

Definition at line 68 of file sbgl_types.h.

◆ SBGL_VOXEL_ID_MASK

#define SBGL_VOXEL_ID_MASK   0x3FFFF

Definition at line 73 of file sbgl_types.h.

◆ SBGL_VOXEL_MAT_MASK

#define SBGL_VOXEL_MAT_MASK   0x3F

Definition at line 76 of file sbgl_types.h.

◆ SBGL_VOXEL_MAT_SHIFT

#define SBGL_VOXEL_MAT_SHIFT   26

Definition at line 77 of file sbgl_types.h.

◆ SBGL_VOXEL_SCALE_MASK

#define SBGL_VOXEL_SCALE_MASK   0xFF

Definition at line 74 of file sbgl_types.h.

◆ SBGL_VOXEL_SCALE_SHIFT

#define SBGL_VOXEL_SCALE_SHIFT   18

Definition at line 75 of file sbgl_types.h.

Typedef Documentation

◆ sbgl_Buffer

typedef uint32_t sbgl_Buffer

Handle for a GPU-side buffer.

Definition at line 37 of file sbgl_types.h.

◆ sbgl_ComputePipeline

typedef uint32_t sbgl_ComputePipeline

Handle for a compute pipeline.

Definition at line 52 of file sbgl_types.h.

◆ sbgl_Context

typedef struct sbgl_Context sbgl_Context

Engine context.

The context serves as the handle for all SBgl operations. It utilizes an opaque pointer pattern to encapsulate internal engine state, ensuring that OS-specific handles and internal memory management are hidden from the public API.

◆ sbgl_Pipeline

typedef uint32_t sbgl_Pipeline

Handle for a graphics pipeline.

Definition at line 47 of file sbgl_types.h.

◆ sbgl_RenderQueue

typedef struct sbgl_RenderQueue sbgl_RenderQueue

Internal queue used to batch and sort draw packets before submission.

Definition at line 106 of file sbgl_types.h.

◆ sbgl_Shader

typedef uint32_t sbgl_Shader

Handle for a shader module.

Definition at line 42 of file sbgl_types.h.

◆ sbgl_SortKey

typedef uint64_t sbgl_SortKey

Bit-packed key used for sorting draw commands to minimize state changes.

Definition at line 57 of file sbgl_types.h.

◆ sbgl_Window

typedef struct sbgl_Window sbgl_Window

Definition at line 344 of file sbgl_types.h.

Enumeration Type Documentation

◆ sbgl_BackendType

Backend types supported by the engine.

Enumerator
SBGL_BACKEND_VULKAN 

Definition at line 243 of file sbgl_types.h.

243 {
sbgl_BackendType
Backend types supported by the engine.
Definition sbgl_types.h:243
@ SBGL_BACKEND_VULKAN
Definition sbgl_types.h:244

◆ sbgl_BarrierType

Memory barrier types for compute synchronization.

Enumerator
SBGL_BARRIER_COMPUTE_TO_COMPUTE 
SBGL_BARRIER_COMPUTE_TO_INDIRECT 
SBGL_BARRIER_COMPUTE_TO_GRAPHICS 
SBGL_BARRIER_GRAPHICS_TO_COMPUTE 
SBGL_BARRIER_HOST_TO_COMPUTE 
SBGL_BARRIER_HOST_TO_GRAPHICS 

Definition at line 142 of file sbgl_types.h.

142 {
sbgl_BarrierType
Memory barrier types for compute synchronization.
Definition sbgl_types.h:142
@ SBGL_BARRIER_COMPUTE_TO_INDIRECT
Definition sbgl_types.h:144
@ SBGL_BARRIER_GRAPHICS_TO_COMPUTE
Definition sbgl_types.h:146
@ SBGL_BARRIER_COMPUTE_TO_COMPUTE
Definition sbgl_types.h:143
@ SBGL_BARRIER_HOST_TO_GRAPHICS
Definition sbgl_types.h:148
@ SBGL_BARRIER_HOST_TO_COMPUTE
Definition sbgl_types.h:147
@ SBGL_BARRIER_COMPUTE_TO_GRAPHICS
Definition sbgl_types.h:145

◆ sbgl_BlendMode

Blending modes for pipeline color attachments.

Enumerator
SBGL_BLEND_MODE_NONE 
SBGL_BLEND_MODE_ALPHA 
SBGL_BLEND_MODE_ADDITIVE 

Definition at line 195 of file sbgl_types.h.

195 {
sbgl_BlendMode
Blending modes for pipeline color attachments.
Definition sbgl_types.h:195
@ SBGL_BLEND_MODE_ADDITIVE
Definition sbgl_types.h:198
@ SBGL_BLEND_MODE_ALPHA
Definition sbgl_types.h:197
@ SBGL_BLEND_MODE_NONE
Definition sbgl_types.h:196

◆ sbgl_BufferUsage

Buffer usage flags.

Enumerator
SBGL_BUFFER_USAGE_VERTEX 
SBGL_BUFFER_USAGE_INDEX 
SBGL_BUFFER_USAGE_STORAGE 
SBGL_BUFFER_USAGE_INDIRECT 
SBGL_BUFFER_USAGE_TRANSFER_DST 

Definition at line 122 of file sbgl_types.h.

122 {
sbgl_BufferUsage
Buffer usage flags.
Definition sbgl_types.h:122
@ SBGL_BUFFER_USAGE_INDEX
Definition sbgl_types.h:124
@ SBGL_BUFFER_USAGE_INDIRECT
Definition sbgl_types.h:126
@ SBGL_BUFFER_USAGE_TRANSFER_DST
Definition sbgl_types.h:127
@ SBGL_BUFFER_USAGE_STORAGE
Definition sbgl_types.h:125
@ SBGL_BUFFER_USAGE_VERTEX
Definition sbgl_types.h:123

◆ sbgl_Format

Data formats for vertex attributes.

Enumerator
SBGL_FORMAT_R32_SFLOAT 
SBGL_FORMAT_R32G32_SFLOAT 
SBGL_FORMAT_R32G32B32_SFLOAT 
SBGL_FORMAT_R32G32B32A32_SFLOAT 
SBGL_FORMAT_R16G16B16A16_SNORM 
SBGL_FORMAT_R8G8B8A8_UNORM 

Definition at line 154 of file sbgl_types.h.

154 {
sbgl_Format
Data formats for vertex attributes.
Definition sbgl_types.h:154
@ SBGL_FORMAT_R8G8B8A8_UNORM
Definition sbgl_types.h:160
@ SBGL_FORMAT_R32G32_SFLOAT
Definition sbgl_types.h:156
@ SBGL_FORMAT_R16G16B16A16_SNORM
Definition sbgl_types.h:159
@ SBGL_FORMAT_R32G32B32_SFLOAT
Definition sbgl_types.h:157
@ SBGL_FORMAT_R32G32B32A32_SFLOAT
Definition sbgl_types.h:158
@ SBGL_FORMAT_R32_SFLOAT
Definition sbgl_types.h:155

◆ sbgl_platform_Result

Result codes for platform layer operations.

Enumerator
SBGL_PLATFORM_SUCCESS 
SBGL_PLATFORM_ERROR_WINDOW_FAILED 
SBGL_PLATFORM_ERROR_NO_DISPLAY 
SBGL_PLATFORM_ERROR_INIT_FAILED 

Definition at line 233 of file sbgl_types.h.

233 {
sbgl_platform_Result
Result codes for platform layer operations.
Definition sbgl_types.h:233
@ SBGL_PLATFORM_SUCCESS
Definition sbgl_types.h:234
@ SBGL_PLATFORM_ERROR_INIT_FAILED
Definition sbgl_types.h:237
@ SBGL_PLATFORM_ERROR_NO_DISPLAY
Definition sbgl_types.h:236
@ SBGL_PLATFORM_ERROR_WINDOW_FAILED
Definition sbgl_types.h:235

◆ sbgl_Result

Result codes for engine operations.

Enumerator
SBGL_SUCCESS 
SBGL_ERROR_NULL_CONTEXT 
SBGL_ERROR_INVALID_ARGUMENT 
SBGL_ERROR_INITIALIZATION_FAILED 
SBGL_ERROR_WINDOW_CREATION_FAILED 
SBGL_ERROR_GRAPHICS_FAILED 
SBGL_ERROR_OUT_OF_MEMORY 
SBGL_ERROR_DEVICE_BUSY 
SBGL_ERROR_INVALID_HANDLE 
SBGL_ERROR_SWAPCHAIN_FAILED 
SBGL_ERROR_SHADER_FAILED 
SBGL_ERROR_PIPELINE_FAILED 
SBGL_ERROR_PLATFORM_FAILED 

Definition at line 214 of file sbgl_types.h.

214 {
215 SBGL_SUCCESS = 0,
sbgl_Result
Result codes for engine operations.
Definition sbgl_types.h:214
@ SBGL_ERROR_INITIALIZATION_FAILED
Definition sbgl_types.h:218
@ SBGL_ERROR_DEVICE_BUSY
Definition sbgl_types.h:222
@ SBGL_ERROR_OUT_OF_MEMORY
Definition sbgl_types.h:221
@ SBGL_ERROR_PLATFORM_FAILED
Definition sbgl_types.h:227
@ SBGL_ERROR_SWAPCHAIN_FAILED
Definition sbgl_types.h:224
@ SBGL_ERROR_PIPELINE_FAILED
Definition sbgl_types.h:226
@ SBGL_SUCCESS
Definition sbgl_types.h:215
@ SBGL_ERROR_WINDOW_CREATION_FAILED
Definition sbgl_types.h:219
@ SBGL_ERROR_GRAPHICS_FAILED
Definition sbgl_types.h:220
@ SBGL_ERROR_SHADER_FAILED
Definition sbgl_types.h:225
@ SBGL_ERROR_INVALID_HANDLE
Definition sbgl_types.h:223
@ SBGL_ERROR_INVALID_ARGUMENT
Definition sbgl_types.h:217
@ SBGL_ERROR_NULL_CONTEXT
Definition sbgl_types.h:216

◆ sbgl_ShaderStage

Shader stage flags.

Enumerator
SBGL_SHADER_STAGE_VERTEX 
SBGL_SHADER_STAGE_FRAGMENT 
SBGL_SHADER_STAGE_COMPUTE 

Definition at line 133 of file sbgl_types.h.

133 {
sbgl_ShaderStage
Shader stage flags.
Definition sbgl_types.h:133
@ SBGL_SHADER_STAGE_COMPUTE
Definition sbgl_types.h:136
@ SBGL_SHADER_STAGE_FRAGMENT
Definition sbgl_types.h:135
@ SBGL_SHADER_STAGE_VERTEX
Definition sbgl_types.h:134