1199 lines
56 KiB
Zig
1199 lines
56 KiB
Zig
pub const c = @import("c.zig").c;
|
|
|
|
pub const PropertiesID = u32;
|
|
pub const Window = c.SDL_Window;
|
|
|
|
pub const GPUTextureUsageFlags = packed struct(u32) {
|
|
textureusageSampler: bool = false,
|
|
textureusageColorTarget: bool = false,
|
|
textureusageDepthStencilTarget: bool = false,
|
|
textureusageGraphicsStorageRead: bool = false,
|
|
textureusageComputeStorageRead: bool = false,
|
|
textureusageComputeStorageWrite: bool = false,
|
|
textureusageComputeStorageSimultaneousReadWrite: bool = false,
|
|
pad0: u24 = 0,
|
|
rsvd: bool = false,
|
|
};
|
|
pub const GPUBufferUsageFlags = packed struct(u32) {
|
|
bufferusageVertex: bool = false,
|
|
bufferusageIndex: bool = false,
|
|
bufferusageIndirect: bool = false,
|
|
bufferusageGraphicsStorageRead: bool = false,
|
|
bufferusageComputeStorageRead: bool = false,
|
|
bufferusageComputeStorageWrite: bool = false,
|
|
pad0: u25 = 0,
|
|
rsvd: bool = false,
|
|
};
|
|
pub const GPUColorComponentFlags = packed struct(u8) {
|
|
colorcomponentR: bool = false,
|
|
colorcomponentG: bool = false,
|
|
colorcomponentB: bool = false,
|
|
colorcomponentA: bool = false,
|
|
pad0: u3 = 0,
|
|
rsvd: bool = false,
|
|
};
|
|
pub const GPUShaderFormat = packed struct(u32) {
|
|
shaderformatPrivate: bool = false,
|
|
shaderformatSpirv: bool = false,
|
|
shaderformatDxbc: bool = false,
|
|
shaderformatDxil: bool = false,
|
|
shaderformatMsl: bool = false,
|
|
shaderformatMetallib: bool = false,
|
|
pad0: u25 = 0,
|
|
rsvd: bool = false,
|
|
pub const Invalid: @This() = .{};
|
|
};
|
|
pub const GPUPrimitiveType = enum(c_int) {
|
|
primitivetypeTrianglelist, //*< A series of separate triangles. */
|
|
primitivetypeTrianglestrip, //*< A series of connected triangles. */
|
|
primitivetypeLinelist, //*< A series of separate lines. */
|
|
primitivetypeLinestrip, //*< A series of connected lines. */
|
|
primitivetypePointlist, //*< A series of separate points. */
|
|
};
|
|
|
|
pub const GPULoadOp = enum(c_int) {
|
|
loadopLoad, //*< The previous contents of the texture will be preserved. */
|
|
loadopClear, //*< The contents of the texture will be cleared to a color. */
|
|
loadopDontCare, //*< The previous contents of the texture need not be preserved. The contents will be undefined. */
|
|
};
|
|
|
|
pub const GPUStoreOp = enum(c_int) {
|
|
storeopStore, //*< The contents generated during the render pass will be written to memory. */
|
|
storeopDontCare, //*< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */
|
|
storeopResolve, //*< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture may then be discarded and will be undefined. */
|
|
storeopResolveAndStore, //*< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture will be written to memory. */
|
|
};
|
|
|
|
pub const GPUIndexElementSize = enum(c_int) {
|
|
indexelementsize16bit, //*< The index elements are 16-bit. */
|
|
indexelementsize32bit, //*< The index elements are 32-bit. */
|
|
};
|
|
|
|
pub const GPUTextureFormat = enum(c_int) {
|
|
textureformatInvalid,
|
|
textureformatA8Unorm,
|
|
textureformatR8Unorm,
|
|
textureformatR8g8Unorm,
|
|
textureformatR8g8b8a8Unorm,
|
|
textureformatR16Unorm,
|
|
textureformatR16g16Unorm,
|
|
textureformatR16g16b16a16Unorm,
|
|
textureformatR10g10b10a2Unorm,
|
|
textureformatB5g6r5Unorm,
|
|
textureformatB5g5r5a1Unorm,
|
|
textureformatB4g4r4a4Unorm,
|
|
textureformatB8g8r8a8Unorm,
|
|
textureformatBc1RgbaUnorm,
|
|
textureformatBc2RgbaUnorm,
|
|
textureformatBc3RgbaUnorm,
|
|
textureformatBc4RUnorm,
|
|
textureformatBc5RgUnorm,
|
|
textureformatBc7RgbaUnorm,
|
|
textureformatBc6hRgbFloat,
|
|
textureformatBc6hRgbUfloat,
|
|
textureformatR8Snorm,
|
|
textureformatR8g8Snorm,
|
|
textureformatR8g8b8a8Snorm,
|
|
textureformatR16Snorm,
|
|
textureformatR16g16Snorm,
|
|
textureformatR16g16b16a16Snorm,
|
|
textureformatR16Float,
|
|
textureformatR16g16Float,
|
|
textureformatR16g16b16a16Float,
|
|
textureformatR32Float,
|
|
textureformatR32g32Float,
|
|
textureformatR32g32b32a32Float,
|
|
textureformatR11g11b10Ufloat,
|
|
textureformatR8Uint,
|
|
textureformatR8g8Uint,
|
|
textureformatR8g8b8a8Uint,
|
|
textureformatR16Uint,
|
|
textureformatR16g16Uint,
|
|
textureformatR16g16b16a16Uint,
|
|
textureformatR32Uint,
|
|
textureformatR32g32Uint,
|
|
textureformatR32g32b32a32Uint,
|
|
textureformatR8Int,
|
|
textureformatR8g8Int,
|
|
textureformatR8g8b8a8Int,
|
|
textureformatR16Int,
|
|
textureformatR16g16Int,
|
|
textureformatR16g16b16a16Int,
|
|
textureformatR32Int,
|
|
textureformatR32g32Int,
|
|
textureformatR32g32b32a32Int,
|
|
textureformatR8g8b8a8UnormSrgb,
|
|
textureformatB8g8r8a8UnormSrgb,
|
|
textureformatBc1RgbaUnormSrgb,
|
|
textureformatBc2RgbaUnormSrgb,
|
|
textureformatBc3RgbaUnormSrgb,
|
|
textureformatBc7RgbaUnormSrgb,
|
|
textureformatD16Unorm,
|
|
textureformatD24Unorm,
|
|
textureformatD32Float,
|
|
textureformatD24UnormS8Uint,
|
|
textureformatD32FloatS8Uint,
|
|
textureformatAstc4x4Unorm,
|
|
textureformatAstc5x4Unorm,
|
|
textureformatAstc5x5Unorm,
|
|
textureformatAstc6x5Unorm,
|
|
textureformatAstc6x6Unorm,
|
|
textureformatAstc8x5Unorm,
|
|
textureformatAstc8x6Unorm,
|
|
textureformatAstc8x8Unorm,
|
|
textureformatAstc10x5Unorm,
|
|
textureformatAstc10x6Unorm,
|
|
textureformatAstc10x8Unorm,
|
|
textureformatAstc10x10Unorm,
|
|
textureformatAstc12x10Unorm,
|
|
textureformatAstc12x12Unorm,
|
|
textureformatAstc4x4UnormSrgb,
|
|
textureformatAstc5x4UnormSrgb,
|
|
textureformatAstc5x5UnormSrgb,
|
|
textureformatAstc6x5UnormSrgb,
|
|
textureformatAstc6x6UnormSrgb,
|
|
textureformatAstc8x5UnormSrgb,
|
|
textureformatAstc8x6UnormSrgb,
|
|
textureformatAstc8x8UnormSrgb,
|
|
textureformatAstc10x5UnormSrgb,
|
|
textureformatAstc10x6UnormSrgb,
|
|
textureformatAstc10x8UnormSrgb,
|
|
textureformatAstc10x10UnormSrgb,
|
|
textureformatAstc12x10UnormSrgb,
|
|
textureformatAstc12x12UnormSrgb,
|
|
textureformatAstc4x4Float,
|
|
textureformatAstc5x4Float,
|
|
textureformatAstc5x5Float,
|
|
textureformatAstc6x5Float,
|
|
textureformatAstc6x6Float,
|
|
textureformatAstc8x5Float,
|
|
textureformatAstc8x6Float,
|
|
textureformatAstc8x8Float,
|
|
textureformatAstc10x5Float,
|
|
textureformatAstc10x6Float,
|
|
textureformatAstc10x8Float,
|
|
textureformatAstc10x10Float,
|
|
textureformatAstc12x10Float,
|
|
textureformatAstc12x12Float,
|
|
};
|
|
|
|
pub const GPUTextureType = enum(c_int) {
|
|
texturetype2d, //*< The texture is a 2-dimensional image. */
|
|
texturetype2dArray, //*< The texture is a 2-dimensional array image. */
|
|
texturetype3d, //*< The texture is a 3-dimensional image. */
|
|
texturetypeCube, //*< The texture is a cube image. */
|
|
texturetypeCubeArray, //*< The texture is a cube array image. */
|
|
};
|
|
|
|
pub const GPUSampleCount = enum(c_int) {
|
|
samplecount1, //*< No multisampling. */
|
|
samplecount2, //*< MSAA 2x */
|
|
samplecount4, //*< MSAA 4x */
|
|
samplecount8, //*< MSAA 8x */
|
|
};
|
|
|
|
pub const GPUCubeMapFace = enum(c_int) {
|
|
cubemapfacePositivex,
|
|
cubemapfaceNegativex,
|
|
cubemapfacePositivey,
|
|
cubemapfaceNegativey,
|
|
cubemapfacePositivez,
|
|
cubemapfaceNegativez,
|
|
};
|
|
|
|
pub const GPUTransferBufferUsage = enum(c_int) {
|
|
transferbufferusageUpload,
|
|
transferbufferusageDownload,
|
|
};
|
|
|
|
pub const GPUShaderStage = enum(c_int) {
|
|
shaderstageVertex,
|
|
shaderstageFragment,
|
|
};
|
|
|
|
pub const GPUVertexElementFormat = enum(c_int) {
|
|
vertexelementformatInvalid,
|
|
vertexelementformatInt,
|
|
vertexelementformatInt2,
|
|
vertexelementformatInt3,
|
|
vertexelementformatInt4,
|
|
vertexelementformatUint,
|
|
vertexelementformatUint2,
|
|
vertexelementformatUint3,
|
|
vertexelementformatUint4,
|
|
vertexelementformatFloat,
|
|
vertexelementformatFloat2,
|
|
vertexelementformatFloat3,
|
|
vertexelementformatFloat4,
|
|
vertexelementformatByte2,
|
|
vertexelementformatByte4,
|
|
vertexelementformatUbyte2,
|
|
vertexelementformatUbyte4,
|
|
vertexelementformatByte2Norm,
|
|
vertexelementformatByte4Norm,
|
|
vertexelementformatUbyte2Norm,
|
|
vertexelementformatUbyte4Norm,
|
|
vertexelementformatShort2,
|
|
vertexelementformatShort4,
|
|
vertexelementformatUshort2,
|
|
vertexelementformatUshort4,
|
|
vertexelementformatShort2Norm,
|
|
vertexelementformatShort4Norm,
|
|
vertexelementformatUshort2Norm,
|
|
vertexelementformatUshort4Norm,
|
|
vertexelementformatHalf2,
|
|
vertexelementformatHalf4,
|
|
};
|
|
|
|
pub const GPUVertexInputRate = enum(c_int) {
|
|
vertexinputrateVertex, //*< Attribute addressing is a function of the vertex index. */
|
|
vertexinputrateInstance, //*< Attribute addressing is a function of the instance index. */
|
|
};
|
|
|
|
pub const GPUFillMode = enum(c_int) {
|
|
fillmodeFill, //*< Polygons will be rendered via rasterization. */
|
|
fillmodeLine, //*< Polygon edges will be drawn as line segments. */
|
|
};
|
|
|
|
pub const GPUCullMode = enum(c_int) {
|
|
cullmodeNone, //*< No triangles are culled. */
|
|
cullmodeFront, //*< Front-facing triangles are culled. */
|
|
cullmodeBack, //*< Back-facing triangles are culled. */
|
|
};
|
|
|
|
pub const GPUFrontFace = enum(c_int) {
|
|
frontfaceCounterClockwise, //*< A triangle with counter-clockwise vertex winding will be considered front-facing. */
|
|
frontfaceClockwise, //*< A triangle with clockwise vertex winding will be considered front-facing. */
|
|
};
|
|
|
|
pub const GPUCompareOp = enum(c_int) {
|
|
compareopInvalid,
|
|
compareopNever, //*< The comparison always evaluates false. */
|
|
compareopLess, //*< The comparison evaluates reference < test. */
|
|
compareopEqual, //*< The comparison evaluates reference == test. */
|
|
compareopLessOrEqual, //*< The comparison evaluates reference <= test. */
|
|
compareopGreater, //*< The comparison evaluates reference > test. */
|
|
compareopNotEqual, //*< The comparison evaluates reference != test. */
|
|
compareopGreaterOrEqual, //*< The comparison evalutes reference >= test. */
|
|
compareopAlways, //*< The comparison always evaluates true. */
|
|
};
|
|
|
|
pub const GPUStencilOp = enum(c_int) {
|
|
stencilopInvalid,
|
|
stencilopKeep, //*< Keeps the current value. */
|
|
stencilopZero, //*< Sets the value to 0. */
|
|
stencilopReplace, //*< Sets the value to reference. */
|
|
stencilopIncrementAndClamp, //*< Increments the current value and clamps to the maximum value. */
|
|
stencilopDecrementAndClamp, //*< Decrements the current value and clamps to 0. */
|
|
stencilopInvert, //*< Bitwise-inverts the current value. */
|
|
stencilopIncrementAndWrap, //*< Increments the current value and wraps back to 0. */
|
|
stencilopDecrementAndWrap, //*< Decrements the current value and wraps to the maximum value. */
|
|
};
|
|
|
|
pub const GPUBlendOp = enum(c_int) {
|
|
blendopInvalid,
|
|
blendopAdd, //*< (source * source_factor) + (destination * destination_factor) */
|
|
blendopSubtract, //*< (source * source_factor) - (destination * destination_factor) */
|
|
blendopReverseSubtract, //*< (destination * destination_factor) - (source * source_factor) */
|
|
blendopMin, //*< min(source
|
|
blendopMax, //*< max(source, destination) */
|
|
};
|
|
|
|
pub const GPUBlendFactor = enum(c_int) {
|
|
blendfactorInvalid,
|
|
blendfactorZero, //*< 0 */
|
|
blendfactorOne, //*< 1 */
|
|
blendfactorSrcColor, //*< source color */
|
|
blendfactorOneMinusSrcColor, //*< 1 - source color */
|
|
blendfactorDstColor, //*< destination color */
|
|
blendfactorOneMinusDstColor, //*< 1 - destination color */
|
|
blendfactorSrcAlpha, //*< source alpha */
|
|
blendfactorOneMinusSrcAlpha, //*< 1 - source alpha */
|
|
blendfactorDstAlpha, //*< destination alpha */
|
|
blendfactorOneMinusDstAlpha, //*< 1 - destination alpha */
|
|
blendfactorConstantColor, //*< blend constant */
|
|
blendfactorOneMinusConstantColor, //*< 1 - blend constant */
|
|
blendfactorSrcAlphaSaturate, //*< min(source alpha, 1 - destination alpha) */
|
|
};
|
|
|
|
pub const GPUFilter = enum(c_int) {
|
|
filterNearest, //*< Point filtering. */
|
|
filterLinear, //*< Linear filtering. */
|
|
};
|
|
|
|
pub const GPUSamplerMipmapMode = enum(c_int) {
|
|
samplermipmapmodeNearest, //*< Point filtering. */
|
|
samplermipmapmodeLinear, //*< Linear filtering. */
|
|
};
|
|
|
|
pub const GPUSamplerAddressMode = enum(c_int) {
|
|
sampleraddressmodeRepeat, //*< Specifies that the coordinates will wrap around. */
|
|
sampleraddressmodeMirroredRepeat, //*< Specifies that the coordinates will wrap around mirrored. */
|
|
sampleraddressmodeClampToEdge, //*< Specifies that the coordinates will clamp to the 0-1 range. */
|
|
};
|
|
|
|
pub const GPUPresentMode = enum(c_int) {
|
|
presentmodeVsync,
|
|
presentmodeImmediate,
|
|
presentmodeMailbox,
|
|
};
|
|
|
|
pub const GPUSwapchainComposition = enum(c_int) {
|
|
swapchaincompositionSdr,
|
|
swapchaincompositionSdrLinear,
|
|
swapchaincompositionHdrExtendedLinear,
|
|
swapchaincompositionHdr10St2084,
|
|
};
|
|
|
|
pub const FlipMode = enum(c_int) {
|
|
sdlFlipNone, //*< Do not flip */
|
|
sdlFlipHorizontal, //*< flip horizontally */
|
|
sdlFlipVertical, //*< flip vertically */
|
|
};
|
|
|
|
pub const GPUViewport = extern struct {
|
|
x: f32, // The left offset of the viewport.
|
|
y: f32, // The top offset of the viewport.
|
|
w: f32, // The width of the viewport.
|
|
h: f32, // The height of the viewport.
|
|
min_depth: f32, // The minimum depth of the viewport.
|
|
max_depth: f32, // The maximum depth of the viewport.
|
|
};
|
|
|
|
pub const GPUTextureTransferInfo = extern struct {
|
|
transfer_buffer: *GPUTransferBuffer, // The transfer buffer used in the transfer operation.
|
|
offset: u32, // The starting byte of the image data in the transfer buffer.
|
|
pixels_per_row: u32, // The number of pixels from one row to the next.
|
|
rows_per_layer: u32, // The number of rows from one layer/depth-slice to the next.
|
|
};
|
|
|
|
pub const GPUTransferBufferLocation = extern struct {
|
|
transfer_buffer: *GPUTransferBuffer, // The transfer buffer used in the transfer operation.
|
|
offset: u32, // The starting byte of the buffer data in the transfer buffer.
|
|
};
|
|
|
|
pub const GPUTextureLocation = extern struct {
|
|
texture: *GPUTexture, // The texture used in the copy operation.
|
|
mip_level: u32, // The mip level index of the location.
|
|
layer: u32, // The layer index of the location.
|
|
x: u32, // The left offset of the location.
|
|
y: u32, // The top offset of the location.
|
|
z: u32, // The front offset of the location.
|
|
};
|
|
|
|
pub const GPUTextureRegion = extern struct {
|
|
texture: *GPUTexture, // The texture used in the copy operation.
|
|
mip_level: u32, // The mip level index to transfer.
|
|
layer: u32, // The layer index to transfer.
|
|
x: u32, // The left offset of the region.
|
|
y: u32, // The top offset of the region.
|
|
z: u32, // The front offset of the region.
|
|
w: u32, // The width of the region.
|
|
h: u32, // The height of the region.
|
|
d: u32, // The depth of the region.
|
|
};
|
|
|
|
pub const GPUBlitRegion = extern struct {
|
|
texture: *GPUTexture, // The texture.
|
|
mip_level: u32, // The mip level index of the region.
|
|
layer_or_depth_plane: u32, // The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures.
|
|
x: u32, // The left offset of the region.
|
|
y: u32, // The top offset of the region.
|
|
w: u32, // The width of the region.
|
|
h: u32, // The height of the region.
|
|
};
|
|
|
|
pub const GPUBufferLocation = extern struct {
|
|
buffer: *GPUBuffer, // The buffer.
|
|
offset: u32, // The starting byte within the buffer.
|
|
};
|
|
|
|
pub const GPUBufferRegion = extern struct {
|
|
buffer: *GPUBuffer, // The buffer.
|
|
offset: u32, // The starting byte within the buffer.
|
|
size: u32, // The size in bytes of the region.
|
|
};
|
|
|
|
pub const GPUIndirectDrawCommand = extern struct {
|
|
num_vertices: u32, // The number of vertices to draw.
|
|
num_instances: u32, // The number of instances to draw.
|
|
first_vertex: u32, // The index of the first vertex to draw.
|
|
first_instance: u32, // The ID of the first instance to draw.
|
|
};
|
|
|
|
pub const GPUIndexedIndirectDrawCommand = extern struct {
|
|
num_indices: u32, // The number of indices to draw per instance.
|
|
num_instances: u32, // The number of instances to draw.
|
|
first_index: u32, // The base index within the index buffer.
|
|
vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
|
|
first_instance: u32, // The ID of the first instance to draw.
|
|
};
|
|
|
|
pub const GPUIndirectDispatchCommand = extern struct {
|
|
groupcount_x: u32, // The number of local workgroups to dispatch in the X dimension.
|
|
groupcount_y: u32, // The number of local workgroups to dispatch in the Y dimension.
|
|
groupcount_z: u32, // The number of local workgroups to dispatch in the Z dimension.
|
|
};
|
|
|
|
pub const GPUSamplerCreateInfo = extern struct {
|
|
min_filter: GPUFilter, // The minification filter to apply to lookups.
|
|
mag_filter: GPUFilter, // The magnification filter to apply to lookups.
|
|
mipmap_mode: GPUSamplerMipmapMode, // The mipmap filter to apply to lookups.
|
|
address_mode_u: GPUSamplerAddressMode, // The addressing mode for U coordinates outside [0, 1).
|
|
address_mode_v: GPUSamplerAddressMode, // The addressing mode for V coordinates outside [0, 1).
|
|
address_mode_w: GPUSamplerAddressMode, // The addressing mode for W coordinates outside [0, 1).
|
|
mip_lod_bias: f32, // The bias to be added to mipmap LOD calculation.
|
|
max_anisotropy: f32, // The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored.
|
|
compare_op: GPUCompareOp, // The comparison operator to apply to fetched data before filtering.
|
|
min_lod: f32, // Clamps the minimum of the computed LOD value.
|
|
max_lod: f32, // Clamps the maximum of the computed LOD value.
|
|
enable_anisotropy: bool, // true to enable anisotropic filtering.
|
|
enable_compare: bool, // true to enable comparison against a reference value during lookups.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPUVertexBufferDescription = extern struct {
|
|
slot: u32, // The binding slot of the vertex buffer.
|
|
pitch: u32, // The byte pitch between consecutive elements of the vertex buffer.
|
|
input_rate: GPUVertexInputRate, // Whether attribute addressing is a function of the vertex index or instance index.
|
|
instance_step_rate: u32, // Reserved for future use. Must be set to 0.
|
|
};
|
|
|
|
pub const GPUVertexAttribute = extern struct {
|
|
location: u32, // The shader input location index.
|
|
buffer_slot: u32, // The binding slot of the associated vertex buffer.
|
|
format: GPUVertexElementFormat, // The size and type of the attribute data.
|
|
offset: u32, // The byte offset of this attribute relative to the start of the vertex element.
|
|
};
|
|
|
|
pub const GPUVertexInputState = extern struct {
|
|
vertex_buffer_descriptions: [*c]const GPUVertexBufferDescription, // A pointer to an array of vertex buffer descriptions.
|
|
num_vertex_buffers: u32, // The number of vertex buffer descriptions in the above array.
|
|
vertex_attributes: [*c]const GPUVertexAttribute, // A pointer to an array of vertex attribute descriptions.
|
|
num_vertex_attributes: u32, // The number of vertex attribute descriptions in the above array.
|
|
};
|
|
|
|
pub const GPUStencilOpState = extern struct {
|
|
fail_op: GPUStencilOp, // The action performed on samples that fail the stencil test.
|
|
pass_op: GPUStencilOp, // The action performed on samples that pass the depth and stencil tests.
|
|
depth_fail_op: GPUStencilOp, // The action performed on samples that pass the stencil test and fail the depth test.
|
|
compare_op: GPUCompareOp, // The comparison operator used in the stencil test.
|
|
};
|
|
|
|
pub const GPUColorTargetBlendState = extern struct {
|
|
src_color_blendfactor: GPUBlendFactor, // The value to be multiplied by the source RGB value.
|
|
dst_color_blendfactor: GPUBlendFactor, // The value to be multiplied by the destination RGB value.
|
|
color_blend_op: GPUBlendOp, // The blend operation for the RGB components.
|
|
src_alpha_blendfactor: GPUBlendFactor, // The value to be multiplied by the source alpha.
|
|
dst_alpha_blendfactor: GPUBlendFactor, // The value to be multiplied by the destination alpha.
|
|
alpha_blend_op: GPUBlendOp, // The blend operation for the alpha component.
|
|
color_write_mask: GPUColorComponentFlags, // A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false.
|
|
enable_blend: bool, // Whether blending is enabled for the color target.
|
|
enable_color_write_mask: bool, // Whether the color write mask is enabled.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const GPUShaderCreateInfo = extern struct {
|
|
code_size: usize, // The size in bytes of the code pointed to.
|
|
code: [*c]const u8, // A pointer to shader code.
|
|
entrypoint: [*c]const u8, // A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader.
|
|
format: GPUShaderFormat, // The format of the shader code.
|
|
stage: GPUShaderStage, // The stage the shader program corresponds to.
|
|
num_samplers: u32, // The number of samplers defined in the shader.
|
|
num_storage_textures: u32, // The number of storage textures defined in the shader.
|
|
num_storage_buffers: u32, // The number of storage buffers defined in the shader.
|
|
num_uniform_buffers: u32, // The number of uniform buffers defined in the shader.
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPUTextureCreateInfo = extern struct {
|
|
type: GPUTextureType, // The base dimensionality of the texture.
|
|
format: GPUTextureFormat, // The pixel format of the texture.
|
|
usage: GPUTextureUsageFlags, // How the texture is intended to be used by the client.
|
|
width: u32, // The width of the texture.
|
|
height: u32, // The height of the texture.
|
|
layer_count_or_depth: u32, // The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures.
|
|
num_levels: u32, // The number of mip levels in the texture.
|
|
sample_count: GPUSampleCount, // The number of samples per texel. Only applies if the texture is used as a render target.
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPUBufferCreateInfo = extern struct {
|
|
usage: GPUBufferUsageFlags, // How the buffer is intended to be used by the client.
|
|
size: u32, // The size in bytes of the buffer.
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPUTransferBufferCreateInfo = extern struct {
|
|
usage: GPUTransferBufferUsage, // How the transfer buffer is intended to be used by the client.
|
|
size: u32, // The size in bytes of the transfer buffer.
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPURasterizerState = extern struct {
|
|
fill_mode: GPUFillMode, // Whether polygons will be filled in or drawn as lines.
|
|
cull_mode: GPUCullMode, // The facing direction in which triangles will be culled.
|
|
front_face: GPUFrontFace, // The vertex winding that will cause a triangle to be determined as front-facing.
|
|
depth_bias_constant_factor: f32, // A scalar factor controlling the depth value added to each fragment.
|
|
depth_bias_clamp: f32, // The maximum depth bias of a fragment.
|
|
depth_bias_slope_factor: f32, // A scalar factor applied to a fragment's slope in depth calculations.
|
|
enable_depth_bias: bool, // true to bias fragment depth values.
|
|
enable_depth_clip: bool, // true to enable depth clip, false to enable depth clamp.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const GPUMultisampleState = extern struct {
|
|
sample_count: GPUSampleCount, // The number of samples to be used in rasterization.
|
|
sample_mask: u32, // Reserved for future use. Must be set to 0.
|
|
enable_mask: bool, // Reserved for future use. Must be set to false.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const GPUDepthStencilState = extern struct {
|
|
compare_op: GPUCompareOp, // The comparison operator used for depth testing.
|
|
back_stencil_state: GPUStencilOpState, // The stencil op state for back-facing triangles.
|
|
front_stencil_state: GPUStencilOpState, // The stencil op state for front-facing triangles.
|
|
compare_mask: u8, // Selects the bits of the stencil values participating in the stencil test.
|
|
write_mask: u8, // Selects the bits of the stencil values updated by the stencil test.
|
|
enable_depth_test: bool, // true enables the depth test.
|
|
enable_depth_write: bool, // true enables depth writes. Depth writes are always disabled when enable_depth_test is false.
|
|
enable_stencil_test: bool, // true enables the stencil test.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const GPUColorTargetDescription = extern struct {
|
|
format: GPUTextureFormat, // The pixel format of the texture to be used as a color target.
|
|
blend_state: GPUColorTargetBlendState, // The blend state to be used for the color target.
|
|
};
|
|
|
|
pub const GPUGraphicsPipelineTargetInfo = extern struct {
|
|
color_target_descriptions: [*c]const GPUColorTargetDescription, // A pointer to an array of color target descriptions.
|
|
num_color_targets: u32, // The number of color target descriptions in the above array.
|
|
depth_stencil_format: GPUTextureFormat, // The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false.
|
|
has_depth_stencil_target: bool, // true specifies that the pipeline uses a depth-stencil target.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const GPUGraphicsPipelineCreateInfo = extern struct {
|
|
vertex_shader: *GPUShader, // The vertex shader used by the graphics pipeline.
|
|
fragment_shader: *GPUShader, // The fragment shader used by the graphics pipeline.
|
|
vertex_input_state: GPUVertexInputState, // The vertex layout of the graphics pipeline.
|
|
primitive_type: GPUPrimitiveType, // The primitive topology of the graphics pipeline.
|
|
rasterizer_state: GPURasterizerState, // The rasterizer state of the graphics pipeline.
|
|
multisample_state: GPUMultisampleState, // The multisample state of the graphics pipeline.
|
|
depth_stencil_state: GPUDepthStencilState, // The depth-stencil state of the graphics pipeline.
|
|
target_info: GPUGraphicsPipelineTargetInfo, // Formats and blend modes for the render targets of the graphics pipeline.
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPUComputePipelineCreateInfo = extern struct {
|
|
code_size: usize, // The size in bytes of the compute shader code pointed to.
|
|
code: [*c]const u8, // A pointer to compute shader code.
|
|
entrypoint: [*c]const u8, // A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader.
|
|
format: GPUShaderFormat, // The format of the compute shader code.
|
|
num_samplers: u32, // The number of samplers defined in the shader.
|
|
num_readonly_storage_textures: u32, // The number of readonly storage textures defined in the shader.
|
|
num_readonly_storage_buffers: u32, // The number of readonly storage buffers defined in the shader.
|
|
num_readwrite_storage_textures: u32, // The number of read-write storage textures defined in the shader.
|
|
num_readwrite_storage_buffers: u32, // The number of read-write storage buffers defined in the shader.
|
|
num_uniform_buffers: u32, // The number of uniform buffers defined in the shader.
|
|
threadcount_x: u32, // The number of threads in the X dimension. This should match the value in the shader.
|
|
threadcount_y: u32, // The number of threads in the Y dimension. This should match the value in the shader.
|
|
threadcount_z: u32, // The number of threads in the Z dimension. This should match the value in the shader.
|
|
props: PropertiesID, // A properties ID for extensions. Should be 0 if no extensions are needed.
|
|
};
|
|
|
|
pub const GPUColorTargetInfo = extern struct {
|
|
texture: *GPUTexture, // The texture that will be used as a color target by a render pass.
|
|
mip_level: u32, // The mip level to use as a color target.
|
|
layer_or_depth_plane: u32, // The layer index or depth plane to use as a color target. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures.
|
|
clear_color: FColor, // The color to clear the color target to at the start of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
|
|
load_op: GPULoadOp, // What is done with the contents of the color target at the beginning of the render pass.
|
|
store_op: GPUStoreOp, // What is done with the results of the render pass.
|
|
resolve_texture: ?*GPUTexture, // The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used.
|
|
resolve_mip_level: u32, // The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used.
|
|
resolve_layer: u32, // The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used.
|
|
cycle: bool, // true cycles the texture if the texture is bound and load_op is not LOAD
|
|
cycle_resolve_texture: bool, // true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const GPUDepthStencilTargetInfo = extern struct {
|
|
texture: *GPUTexture, // The texture that will be used as the depth stencil target by the render pass.
|
|
clear_depth: f32, // The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
|
|
load_op: GPULoadOp, // What is done with the depth contents at the beginning of the render pass.
|
|
store_op: GPUStoreOp, // What is done with the depth results of the render pass.
|
|
stencil_load_op: GPULoadOp, // What is done with the stencil contents at the beginning of the render pass.
|
|
stencil_store_op: GPUStoreOp, // What is done with the stencil results of the render pass.
|
|
cycle: bool, // true cycles the texture if the texture is bound and any load ops are not LOAD
|
|
clear_stencil: u8, // The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
};
|
|
|
|
pub const GPUBlitInfo = extern struct {
|
|
destination: GPUBlitRegion, // The destination region for the blit.
|
|
load_op: GPULoadOp, // What is done with the contents of the destination before the blit.
|
|
clear_color: FColor, // The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR.
|
|
flip_mode: FlipMode, // The flip mode for the source region.
|
|
filter: GPUFilter, // The filter mode used when blitting.
|
|
cycle: bool, // true cycles the destination texture if it is already bound.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const GPUBufferBinding = extern struct {
|
|
buffer: *GPUBuffer, // The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffer.
|
|
offset: u32, // The starting byte of the data to bind in the buffer.
|
|
};
|
|
|
|
pub const GPUTextureSamplerBinding = extern struct {
|
|
texture: *GPUTexture, // The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
|
|
sampler: *GPUSampler, // The sampler to bind.
|
|
};
|
|
|
|
pub const GPUStorageBufferReadWriteBinding = extern struct {
|
|
buffer: *GPUBuffer, // The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE.
|
|
cycle: bool, // true cycles the buffer if it is already bound.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const GPUStorageTextureReadWriteBinding = extern struct {
|
|
texture: *GPUTexture, // The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE.
|
|
mip_level: u32, // The mip level index to bind.
|
|
layer: u32, // The layer index to bind.
|
|
cycle: bool, // true cycles the texture if it is already bound.
|
|
padding1: u8,
|
|
padding2: u8,
|
|
padding3: u8,
|
|
};
|
|
|
|
pub const FColor = extern struct {
|
|
r: f32,
|
|
g: f32,
|
|
b: f32,
|
|
a: f32,
|
|
};
|
|
|
|
pub const Rect = extern struct {
|
|
x: c_int,
|
|
y: c_int,
|
|
w: c_int,
|
|
h: c_int,
|
|
};
|
|
|
|
// SDL_GPUSupportsShaderFormats
|
|
pub inline fn gpuSupportsShaderFormats(format_flags: GPUShaderFormat, name: [*c]const u8) bool {
|
|
return c.SDL_GPUSupportsShaderFormats(@bitCast(format_flags), name);
|
|
}
|
|
|
|
// SDL_GPUSupportsProperties
|
|
pub inline fn gpuSupportsProperties(props: PropertiesID) bool {
|
|
return c.SDL_GPUSupportsProperties(@bitCast(props));
|
|
}
|
|
|
|
// SDL_CreateGPUDevice
|
|
pub inline fn createGPUDevice(format_flags: GPUShaderFormat, debug_mode: bool, name: [*c]const u8) *GPUDevice {
|
|
return @ptrCast(c.SDL_CreateGPUDevice(@bitCast(format_flags), debug_mode, name));
|
|
}
|
|
|
|
// SDL_CreateGPUDeviceWithProperties
|
|
pub inline fn createGPUDeviceWithProperties(props: PropertiesID) *GPUDevice {
|
|
return @ptrCast(c.SDL_CreateGPUDeviceWithProperties(@bitCast(props)));
|
|
}
|
|
|
|
// SDL_GetNumGPUDrivers
|
|
pub inline fn getNumGPUDrivers() c_int {
|
|
return @bitCast(c.SDL_GetNumGPUDrivers());
|
|
}
|
|
|
|
// SDL_GetGPUDriver
|
|
pub inline fn getGPUDriver(index: c_int) [*c]const u8 {
|
|
return @ptrCast(c.SDL_GetGPUDriver(@bitCast(index)));
|
|
}
|
|
|
|
// SDL_GPUTextureFormatTexelBlockSize
|
|
pub inline fn gpuTextureFormatTexelBlockSize(format: GPUTextureFormat) u32 {
|
|
return @bitCast(c.SDL_GPUTextureFormatTexelBlockSize(@bitCast(format)));
|
|
}
|
|
|
|
// SDL_CalculateGPUTextureFormatSize
|
|
pub inline fn calculateGPUTextureFormatSize(format: GPUTextureFormat, width: u32, height: u32, depth_or_layer_count: u32) u32 {
|
|
return @bitCast(c.SDL_CalculateGPUTextureFormatSize(@bitCast(format), @bitCast(width), @bitCast(height), @bitCast(depth_or_layer_count)));
|
|
}
|
|
|
|
pub const GPUDevice = opaque {
|
|
// SDL_DestroyGPUDevice
|
|
pub inline fn destroyGPUDevice(device: *GPUDevice) void {
|
|
c.SDL_DestroyGPUDevice(@ptrCast(device));
|
|
}
|
|
|
|
// SDL_GetGPUDeviceDriver
|
|
pub inline fn getGPUDeviceDriver(device: *GPUDevice) [*c]const u8 {
|
|
return @ptrCast(c.SDL_GetGPUDeviceDriver(@ptrCast(device)));
|
|
}
|
|
|
|
// SDL_GetGPUShaderFormats
|
|
pub inline fn getGPUShaderFormats(device: *GPUDevice) GPUShaderFormat {
|
|
return @bitCast(c.SDL_GetGPUShaderFormats(@ptrCast(device)));
|
|
}
|
|
|
|
// SDL_CreateGPUComputePipeline
|
|
pub inline fn createGPUComputePipeline(device: *GPUDevice, createinfo: [*c]const GPUComputePipelineCreateInfo) *GPUComputePipeline {
|
|
return @ptrCast(c.SDL_CreateGPUComputePipeline(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_CreateGPUGraphicsPipeline
|
|
pub inline fn createGPUGraphicsPipeline(device: *GPUDevice, createinfo: [*c]const GPUGraphicsPipelineCreateInfo) *GPUGraphicsPipeline {
|
|
return @ptrCast(c.SDL_CreateGPUGraphicsPipeline(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_CreateGPUSampler
|
|
pub inline fn createGPUSampler(device: *GPUDevice, createinfo: [*c]const GPUSamplerCreateInfo) *GPUSampler {
|
|
return @ptrCast(c.SDL_CreateGPUSampler(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_CreateGPUShader
|
|
pub inline fn createGPUShader(device: *GPUDevice, createinfo: [*c]const GPUShaderCreateInfo) *GPUShader {
|
|
return @ptrCast(c.SDL_CreateGPUShader(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_CreateGPUTexture
|
|
pub inline fn createGPUTexture(device: *GPUDevice, createinfo: [*c]const GPUTextureCreateInfo) *GPUTexture {
|
|
return @ptrCast(c.SDL_CreateGPUTexture(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_CreateGPUBuffer
|
|
pub inline fn createGPUBuffer(device: *GPUDevice, createinfo: [*c]const GPUBufferCreateInfo) *GPUBuffer {
|
|
return @ptrCast(c.SDL_CreateGPUBuffer(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_CreateGPUTransferBuffer
|
|
pub inline fn createGPUTransferBuffer(device: *GPUDevice, createinfo: [*c]const GPUTransferBufferCreateInfo) *GPUTransferBuffer {
|
|
return @ptrCast(c.SDL_CreateGPUTransferBuffer(@ptrCast(device), @ptrCast(createinfo)));
|
|
}
|
|
|
|
// SDL_SetGPUBufferName
|
|
pub inline fn setGPUBufferName(device: *GPUDevice, buffer: *GPUBuffer, text: [*c]const u8) void {
|
|
c.SDL_SetGPUBufferName(@ptrCast(device), @ptrCast(buffer), text);
|
|
}
|
|
|
|
// SDL_SetGPUTextureName
|
|
pub inline fn setGPUTextureName(device: *GPUDevice, texture: *GPUTexture, text: [*c]const u8) void {
|
|
c.SDL_SetGPUTextureName(@ptrCast(device), @ptrCast(texture), text);
|
|
}
|
|
|
|
// SDL_ReleaseGPUTexture
|
|
pub inline fn releaseGPUTexture(device: *GPUDevice, texture: *GPUTexture) void {
|
|
c.SDL_ReleaseGPUTexture(@ptrCast(device), @ptrCast(texture));
|
|
}
|
|
|
|
// SDL_ReleaseGPUSampler
|
|
pub inline fn releaseGPUSampler(device: *GPUDevice, sampler: *GPUSampler) void {
|
|
c.SDL_ReleaseGPUSampler(@ptrCast(device), @ptrCast(sampler));
|
|
}
|
|
|
|
// SDL_ReleaseGPUBuffer
|
|
pub inline fn releaseGPUBuffer(device: *GPUDevice, buffer: *GPUBuffer) void {
|
|
c.SDL_ReleaseGPUBuffer(@ptrCast(device), @ptrCast(buffer));
|
|
}
|
|
|
|
// SDL_ReleaseGPUTransferBuffer
|
|
pub inline fn releaseGPUTransferBuffer(device: *GPUDevice, transfer_buffer: *GPUTransferBuffer) void {
|
|
c.SDL_ReleaseGPUTransferBuffer(@ptrCast(device), @ptrCast(transfer_buffer));
|
|
}
|
|
|
|
// SDL_ReleaseGPUComputePipeline
|
|
pub inline fn releaseGPUComputePipeline(device: *GPUDevice, compute_pipeline: *GPUComputePipeline) void {
|
|
c.SDL_ReleaseGPUComputePipeline(@ptrCast(device), @ptrCast(compute_pipeline));
|
|
}
|
|
|
|
// SDL_ReleaseGPUShader
|
|
pub inline fn releaseGPUShader(device: *GPUDevice, shader: *GPUShader) void {
|
|
c.SDL_ReleaseGPUShader(@ptrCast(device), @ptrCast(shader));
|
|
}
|
|
|
|
// SDL_ReleaseGPUGraphicsPipeline
|
|
pub inline fn releaseGPUGraphicsPipeline(device: *GPUDevice, graphics_pipeline: *GPUGraphicsPipeline) void {
|
|
c.SDL_ReleaseGPUGraphicsPipeline(@ptrCast(device), @ptrCast(graphics_pipeline));
|
|
}
|
|
|
|
// SDL_AcquireGPUCommandBuffer
|
|
pub inline fn acquireGPUCommandBuffer(device: *GPUDevice) *GPUCommandBuffer {
|
|
return @ptrCast(c.SDL_AcquireGPUCommandBuffer(@ptrCast(device)));
|
|
}
|
|
|
|
// SDL_MapGPUTransferBuffer
|
|
pub inline fn mapGPUTransferBuffer(device: *GPUDevice, transfer_buffer: *GPUTransferBuffer, cycle: bool) [*c]u8 {
|
|
return @ptrCast(c.SDL_MapGPUTransferBuffer(@ptrCast(device), @ptrCast(transfer_buffer), cycle));
|
|
}
|
|
|
|
// SDL_UnmapGPUTransferBuffer
|
|
pub inline fn unmapGPUTransferBuffer(device: *GPUDevice, transfer_buffer: *GPUTransferBuffer) void {
|
|
c.SDL_UnmapGPUTransferBuffer(@ptrCast(device), @ptrCast(transfer_buffer));
|
|
}
|
|
|
|
// SDL_WindowSupportsGPUSwapchainComposition
|
|
pub inline fn windowSupportsGPUSwapchainComposition(device: *GPUDevice, window: *Window, swapchain_composition: GPUSwapchainComposition) bool {
|
|
return c.SDL_WindowSupportsGPUSwapchainComposition(@ptrCast(device), @ptrCast(window), @bitCast(swapchain_composition));
|
|
}
|
|
|
|
// SDL_WindowSupportsGPUPresentMode
|
|
pub inline fn windowSupportsGPUPresentMode(device: *GPUDevice, window: *Window, present_mode: GPUPresentMode) bool {
|
|
return c.SDL_WindowSupportsGPUPresentMode(@ptrCast(device), @ptrCast(window), @bitCast(present_mode));
|
|
}
|
|
|
|
// SDL_ClaimWindowForGPUDevice
|
|
pub inline fn claimWindowForGPUDevice(device: *GPUDevice, window: *Window) bool {
|
|
return c.SDL_ClaimWindowForGPUDevice(@ptrCast(device), @ptrCast(window));
|
|
}
|
|
|
|
// SDL_ReleaseWindowFromGPUDevice
|
|
pub inline fn releaseWindowFromGPUDevice(device: *GPUDevice, window: *Window) void {
|
|
c.SDL_ReleaseWindowFromGPUDevice(@ptrCast(device), @ptrCast(window));
|
|
}
|
|
|
|
// SDL_SetGPUSwapchainParameters
|
|
pub inline fn setGPUSwapchainParameters(device: *GPUDevice, window: *Window, swapchain_composition: GPUSwapchainComposition, present_mode: GPUPresentMode) bool {
|
|
return c.SDL_SetGPUSwapchainParameters(@ptrCast(device), @ptrCast(window), @bitCast(swapchain_composition), @bitCast(present_mode));
|
|
}
|
|
|
|
// SDL_SetGPUAllowedFramesInFlight
|
|
pub inline fn setGPUAllowedFramesInFlight(device: *GPUDevice, allowed_frames_in_flight: u32) bool {
|
|
return c.SDL_SetGPUAllowedFramesInFlight(@ptrCast(device), @bitCast(allowed_frames_in_flight));
|
|
}
|
|
|
|
// SDL_GetGPUSwapchainTextureFormat
|
|
pub inline fn getGPUSwapchainTextureFormat(device: *GPUDevice, window: *Window) GPUTextureFormat {
|
|
return @enumFromInt(c.SDL_GetGPUSwapchainTextureFormat(@ptrCast(device), @ptrCast(window)));
|
|
}
|
|
|
|
// SDL_WaitForGPUSwapchain
|
|
pub inline fn waitForGPUSwapchain(device: *GPUDevice, window: *Window) bool {
|
|
return c.SDL_WaitForGPUSwapchain(@ptrCast(device), @ptrCast(window));
|
|
}
|
|
|
|
// SDL_WaitForGPUIdle
|
|
pub inline fn waitForGPUIdle(device: *GPUDevice) bool {
|
|
return c.SDL_WaitForGPUIdle(@ptrCast(device));
|
|
}
|
|
|
|
// SDL_WaitForGPUFences
|
|
pub inline fn waitForGPUFences(device: *GPUDevice, wait_all: bool, fences: [*c]*GPUFence, num_fences: u32) bool {
|
|
return c.SDL_WaitForGPUFences(@ptrCast(device), wait_all, @ptrCast(fences), @bitCast(num_fences));
|
|
}
|
|
|
|
// SDL_QueryGPUFence
|
|
pub inline fn queryGPUFence(device: *GPUDevice, fence: *GPUFence) bool {
|
|
return c.SDL_QueryGPUFence(@ptrCast(device), @ptrCast(fence));
|
|
}
|
|
|
|
// SDL_ReleaseGPUFence
|
|
pub inline fn releaseGPUFence(device: *GPUDevice, fence: *GPUFence) void {
|
|
c.SDL_ReleaseGPUFence(@ptrCast(device), @ptrCast(fence));
|
|
}
|
|
|
|
// SDL_GPUTextureSupportsFormat
|
|
pub inline fn gpuTextureSupportsFormat(device: *GPUDevice, format: GPUTextureFormat, _type: GPUTextureType, usage: GPUTextureUsageFlags) bool {
|
|
return c.SDL_GPUTextureSupportsFormat(@ptrCast(device), @bitCast(format), @bitCast(_type), @bitCast(usage));
|
|
}
|
|
|
|
// SDL_GPUTextureSupportsSampleCount
|
|
pub inline fn gpuTextureSupportsSampleCount(device: *GPUDevice, format: GPUTextureFormat, sample_count: GPUSampleCount) bool {
|
|
return c.SDL_GPUTextureSupportsSampleCount(@ptrCast(device), @bitCast(format), @bitCast(sample_count));
|
|
}
|
|
|
|
// SDL_GDKSuspendGPU
|
|
pub inline fn gdkSuspendGPU(device: *GPUDevice) void {
|
|
c.SDL_GDKSuspendGPU(@ptrCast(device));
|
|
}
|
|
|
|
// SDL_GDKResumeGPU
|
|
pub inline fn gdkResumeGPU(device: *GPUDevice) void {
|
|
c.SDL_GDKResumeGPU(@ptrCast(device));
|
|
}
|
|
};
|
|
|
|
pub const GPUBuffer = opaque {};
|
|
|
|
pub const GPUTransferBuffer = opaque {};
|
|
|
|
pub const GPUTexture = opaque {};
|
|
|
|
pub const GPUSampler = opaque {};
|
|
|
|
pub const GPUShader = opaque {};
|
|
|
|
pub const GPUComputePipeline = opaque {};
|
|
|
|
pub const GPUGraphicsPipeline = opaque {};
|
|
|
|
pub const GPUCommandBuffer = opaque {
|
|
// SDL_InsertGPUDebugLabel
|
|
pub inline fn insertGPUDebugLabel(command_buffer: *GPUCommandBuffer, text: [*c]const u8) void {
|
|
c.SDL_InsertGPUDebugLabel(@ptrCast(command_buffer), text);
|
|
}
|
|
|
|
// SDL_PushGPUDebugGroup
|
|
pub inline fn pushGPUDebugGroup(command_buffer: *GPUCommandBuffer, name: [*c]const u8) void {
|
|
c.SDL_PushGPUDebugGroup(@ptrCast(command_buffer), name);
|
|
}
|
|
|
|
// SDL_PopGPUDebugGroup
|
|
pub inline fn popGPUDebugGroup(command_buffer: *GPUCommandBuffer) void {
|
|
c.SDL_PopGPUDebugGroup(@ptrCast(command_buffer));
|
|
}
|
|
|
|
// SDL_PushGPUVertexUniformData
|
|
pub inline fn pushGPUVertexUniformData(command_buffer: *GPUCommandBuffer, slot_index: u32, data: ?*anyopaque, length: u32) void {
|
|
c.SDL_PushGPUVertexUniformData(@ptrCast(command_buffer), @bitCast(slot_index), @ptrCast(data), @bitCast(length));
|
|
}
|
|
|
|
// SDL_PushGPUFragmentUniformData
|
|
pub inline fn pushGPUFragmentUniformData(command_buffer: *GPUCommandBuffer, slot_index: u32, data: ?*anyopaque, length: u32) void {
|
|
c.SDL_PushGPUFragmentUniformData(@ptrCast(command_buffer), @bitCast(slot_index), @ptrCast(data), @bitCast(length));
|
|
}
|
|
|
|
// SDL_PushGPUComputeUniformData
|
|
pub inline fn pushGPUComputeUniformData(command_buffer: *GPUCommandBuffer, slot_index: u32, data: ?*anyopaque, length: u32) void {
|
|
c.SDL_PushGPUComputeUniformData(@ptrCast(command_buffer), @bitCast(slot_index), @ptrCast(data), @bitCast(length));
|
|
}
|
|
|
|
// SDL_BeginGPURenderPass
|
|
pub inline fn beginGPURenderPass(command_buffer: *GPUCommandBuffer, color_target_infos: [*c]const GPUColorTargetInfo, num_color_targets: u32, depth_stencil_target_info: [*c]const GPUDepthStencilTargetInfo) *GPURenderPass {
|
|
return @ptrCast(c.SDL_BeginGPURenderPass(@ptrCast(command_buffer), @ptrCast(color_target_infos), @bitCast(num_color_targets), @ptrCast(depth_stencil_target_info)));
|
|
}
|
|
|
|
// SDL_BeginGPUComputePass
|
|
pub inline fn beginGPUComputePass(command_buffer: *GPUCommandBuffer, storage_texture_bindings: [*c]const GPUStorageTextureReadWriteBinding, num_storage_texture_bindings: u32, storage_buffer_bindings: [*c]const GPUStorageBufferReadWriteBinding, num_storage_buffer_bindings: u32) *GPUComputePass {
|
|
return @ptrCast(c.SDL_BeginGPUComputePass(@ptrCast(command_buffer), @ptrCast(storage_texture_bindings), @bitCast(num_storage_texture_bindings), @ptrCast(storage_buffer_bindings), @bitCast(num_storage_buffer_bindings)));
|
|
}
|
|
|
|
// SDL_BeginGPUCopyPass
|
|
pub inline fn beginGPUCopyPass(command_buffer: *GPUCommandBuffer) *GPUCopyPass {
|
|
return @ptrCast(c.SDL_BeginGPUCopyPass(@ptrCast(command_buffer)));
|
|
}
|
|
|
|
// SDL_GenerateMipmapsForGPUTexture
|
|
pub inline fn generateMipmapsForGPUTexture(command_buffer: *GPUCommandBuffer, texture: *GPUTexture) void {
|
|
c.SDL_GenerateMipmapsForGPUTexture(@ptrCast(command_buffer), @ptrCast(texture));
|
|
}
|
|
|
|
// SDL_BlitGPUTexture
|
|
pub inline fn blitGPUTexture(command_buffer: *GPUCommandBuffer, info: [*c]const GPUBlitInfo) void {
|
|
c.SDL_BlitGPUTexture(@ptrCast(command_buffer), @ptrCast(info));
|
|
}
|
|
|
|
// SDL_AcquireGPUSwapchainTexture
|
|
pub inline fn acquireGPUSwapchainTexture(command_buffer: *GPUCommandBuffer, window: *Window, swapchain_texture: [*c]*GPUTexture, swapchain_texture_width: [*c]u32, swapchain_texture_height: [*c]u32) bool {
|
|
return c.SDL_AcquireGPUSwapchainTexture(@ptrCast(command_buffer), @ptrCast(window), @ptrCast(swapchain_texture), @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height));
|
|
}
|
|
|
|
// SDL_WaitAndAcquireGPUSwapchainTexture
|
|
pub inline fn waitAndAcquireGPUSwapchainTexture(command_buffer: *GPUCommandBuffer, window: *Window, swapchain_texture: [*c]*GPUTexture, swapchain_texture_width: [*c]u32, swapchain_texture_height: [*c]u32) bool {
|
|
return c.SDL_WaitAndAcquireGPUSwapchainTexture(@ptrCast(command_buffer), @ptrCast(window), @ptrCast(swapchain_texture), @ptrCast(swapchain_texture_width), @ptrCast(swapchain_texture_height));
|
|
}
|
|
|
|
// SDL_SubmitGPUCommandBuffer
|
|
pub inline fn submitGPUCommandBuffer(command_buffer: *GPUCommandBuffer) bool {
|
|
return c.SDL_SubmitGPUCommandBuffer(@ptrCast(command_buffer));
|
|
}
|
|
|
|
// SDL_SubmitGPUCommandBufferAndAcquireFence
|
|
pub inline fn submitGPUCommandBufferAndAcquireFence(command_buffer: *GPUCommandBuffer) *GPUFence {
|
|
return @ptrCast(c.SDL_SubmitGPUCommandBufferAndAcquireFence(@ptrCast(command_buffer)));
|
|
}
|
|
|
|
// SDL_CancelGPUCommandBuffer
|
|
pub inline fn cancelGPUCommandBuffer(command_buffer: *GPUCommandBuffer) bool {
|
|
return c.SDL_CancelGPUCommandBuffer(@ptrCast(command_buffer));
|
|
}
|
|
};
|
|
|
|
pub const GPURenderPass = opaque {
|
|
// SDL_BindGPUGraphicsPipeline
|
|
pub inline fn bindGPUGraphicsPipeline(render_pass: *GPURenderPass, graphics_pipeline: *GPUGraphicsPipeline) void {
|
|
c.SDL_BindGPUGraphicsPipeline(@ptrCast(render_pass), @ptrCast(graphics_pipeline));
|
|
}
|
|
|
|
// SDL_SetGPUViewport
|
|
pub inline fn setGPUViewport(render_pass: *GPURenderPass, viewport: [*c]const GPUViewport) void {
|
|
c.SDL_SetGPUViewport(@ptrCast(render_pass), @ptrCast(viewport));
|
|
}
|
|
|
|
// SDL_SetGPUScissor
|
|
pub inline fn setGPUScissor(render_pass: *GPURenderPass, scissor: [*c]const Rect) void {
|
|
c.SDL_SetGPUScissor(@ptrCast(render_pass), @ptrCast(scissor));
|
|
}
|
|
|
|
// SDL_SetGPUBlendConstants
|
|
pub inline fn setGPUBlendConstants(render_pass: *GPURenderPass, blend_constants: FColor) void {
|
|
c.SDL_SetGPUBlendConstants(@ptrCast(render_pass), @bitCast(blend_constants));
|
|
}
|
|
|
|
// SDL_SetGPUStencilReference
|
|
pub inline fn setGPUStencilReference(render_pass: *GPURenderPass, reference: u8) void {
|
|
c.SDL_SetGPUStencilReference(@ptrCast(render_pass), @bitCast(reference));
|
|
}
|
|
|
|
// SDL_BindGPUVertexBuffers
|
|
pub inline fn bindGPUVertexBuffers(
|
|
render_pass: *GPURenderPass,
|
|
first_slot: u32,
|
|
bindings: [*c]const GPUBufferBinding,
|
|
num_bindings: u32,
|
|
) void {
|
|
c.SDL_BindGPUVertexBuffers(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(bindings), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUIndexBuffer
|
|
pub inline fn bindGPUIndexBuffer(render_pass: *GPURenderPass, binding: [*c]const GPUBufferBinding, index_element_size: GPUIndexElementSize) void {
|
|
c.SDL_BindGPUIndexBuffer(@ptrCast(render_pass), @ptrCast(binding), @intFromEnum(index_element_size));
|
|
}
|
|
|
|
// SDL_BindGPUVertexSamplers
|
|
pub inline fn bindGPUVertexSamplers(render_pass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: [*c]const GPUTextureSamplerBinding, num_bindings: u32) void {
|
|
c.SDL_BindGPUVertexSamplers(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(texture_sampler_bindings), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUVertexStorageTextures
|
|
pub inline fn bindGPUVertexStorageTextures(render_pass: *GPURenderPass, first_slot: u32, storage_textures: [*c]*GPUTexture, num_bindings: u32) void {
|
|
c.SDL_BindGPUVertexStorageTextures(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(storage_textures), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUVertexStorageBuffers
|
|
pub inline fn bindGPUVertexStorageBuffers(render_pass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]*GPUBuffer, num_bindings: u32) void {
|
|
c.SDL_BindGPUVertexStorageBuffers(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(storage_buffers), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUFragmentSamplers
|
|
pub inline fn bindGPUFragmentSamplers(render_pass: *GPURenderPass, first_slot: u32, texture_sampler_bindings: [*c]const GPUTextureSamplerBinding, num_bindings: u32) void {
|
|
c.SDL_BindGPUFragmentSamplers(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(texture_sampler_bindings), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUFragmentStorageTextures
|
|
pub inline fn bindGPUFragmentStorageTextures(render_pass: *GPURenderPass, first_slot: u32, storage_textures: [*c]*GPUTexture, num_bindings: u32) void {
|
|
c.SDL_BindGPUFragmentStorageTextures(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(storage_textures), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUFragmentStorageBuffers
|
|
pub inline fn bindGPUFragmentStorageBuffers(render_pass: *GPURenderPass, first_slot: u32, storage_buffers: [*c]*GPUBuffer, num_bindings: u32) void {
|
|
c.SDL_BindGPUFragmentStorageBuffers(@ptrCast(render_pass), @bitCast(first_slot), @ptrCast(storage_buffers), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_DrawGPUIndexedPrimitives
|
|
pub inline fn drawGPUIndexedPrimitives(render_pass: *GPURenderPass, num_indices: u32, num_instances: u32, first_index: u32, vertex_offset: i32, first_instance: u32) void {
|
|
c.SDL_DrawGPUIndexedPrimitives(@ptrCast(render_pass), @bitCast(num_indices), @bitCast(num_instances), @bitCast(first_index), @bitCast(vertex_offset), @bitCast(first_instance));
|
|
}
|
|
|
|
// SDL_DrawGPUPrimitives
|
|
pub inline fn drawGPUPrimitives(render_pass: *GPURenderPass, num_vertices: u32, num_instances: u32, first_vertex: u32, first_instance: u32) void {
|
|
c.SDL_DrawGPUPrimitives(@ptrCast(render_pass), @bitCast(num_vertices), @bitCast(num_instances), @bitCast(first_vertex), @bitCast(first_instance));
|
|
}
|
|
|
|
// SDL_DrawGPUPrimitivesIndirect
|
|
pub inline fn drawGPUPrimitivesIndirect(render_pass: *GPURenderPass, buffer: *GPUBuffer, offset: u32, draw_count: u32) void {
|
|
c.SDL_DrawGPUPrimitivesIndirect(@ptrCast(render_pass), @ptrCast(buffer), @bitCast(offset), @bitCast(draw_count));
|
|
}
|
|
|
|
// SDL_DrawGPUIndexedPrimitivesIndirect
|
|
pub inline fn drawGPUIndexedPrimitivesIndirect(render_pass: *GPURenderPass, buffer: *GPUBuffer, offset: u32, draw_count: u32) void {
|
|
c.SDL_DrawGPUIndexedPrimitivesIndirect(@ptrCast(render_pass), @ptrCast(buffer), @bitCast(offset), @bitCast(draw_count));
|
|
}
|
|
|
|
// SDL_EndGPURenderPass
|
|
pub inline fn endGPURenderPass(render_pass: *GPURenderPass) void {
|
|
c.SDL_EndGPURenderPass(@ptrCast(render_pass));
|
|
}
|
|
};
|
|
|
|
pub const GPUComputePass = opaque {
|
|
// SDL_BindGPUComputePipeline
|
|
pub inline fn bindGPUComputePipeline(compute_pass: *GPUComputePass, compute_pipeline: *GPUComputePipeline) void {
|
|
c.SDL_BindGPUComputePipeline(@ptrCast(compute_pass), @ptrCast(compute_pipeline));
|
|
}
|
|
|
|
// SDL_BindGPUComputeSamplers
|
|
pub inline fn bindGPUComputeSamplers(compute_pass: *GPUComputePass, first_slot: u32, texture_sampler_bindings: [*c]const GPUTextureSamplerBinding, num_bindings: u32) void {
|
|
c.SDL_BindGPUComputeSamplers(@ptrCast(compute_pass), @bitCast(first_slot), @ptrCast(texture_sampler_bindings), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUComputeStorageTextures
|
|
pub inline fn bindGPUComputeStorageTextures(compute_pass: *GPUComputePass, first_slot: u32, storage_textures: [*c]*GPUTexture, num_bindings: u32) void {
|
|
c.SDL_BindGPUComputeStorageTextures(@ptrCast(compute_pass), @bitCast(first_slot), @ptrCast(storage_textures), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_BindGPUComputeStorageBuffers
|
|
pub inline fn bindGPUComputeStorageBuffers(compute_pass: *GPUComputePass, first_slot: u32, storage_buffers: [*c]*GPUBuffer, num_bindings: u32) void {
|
|
c.SDL_BindGPUComputeStorageBuffers(@ptrCast(compute_pass), @bitCast(first_slot), @ptrCast(storage_buffers), @bitCast(num_bindings));
|
|
}
|
|
|
|
// SDL_DispatchGPUCompute
|
|
pub inline fn dispatchGPUCompute(compute_pass: *GPUComputePass, groupcount_x: u32, groupcount_y: u32, groupcount_z: u32) void {
|
|
c.SDL_DispatchGPUCompute(@ptrCast(compute_pass), @bitCast(groupcount_x), @bitCast(groupcount_y), @bitCast(groupcount_z));
|
|
}
|
|
|
|
// SDL_DispatchGPUComputeIndirect
|
|
pub inline fn dispatchGPUComputeIndirect(compute_pass: *GPUComputePass, buffer: *GPUBuffer, offset: u32) void {
|
|
c.SDL_DispatchGPUComputeIndirect(@ptrCast(compute_pass), @ptrCast(buffer), @bitCast(offset));
|
|
}
|
|
|
|
// SDL_EndGPUComputePass
|
|
pub inline fn endGPUComputePass(compute_pass: *GPUComputePass) void {
|
|
c.SDL_EndGPUComputePass(@ptrCast(compute_pass));
|
|
}
|
|
};
|
|
|
|
pub const GPUCopyPass = opaque {
|
|
// SDL_UploadToGPUTexture
|
|
pub inline fn uploadToGPUTexture(copy_pass: *GPUCopyPass, source: [*c]const GPUTextureTransferInfo, destination: [*c]const GPUTextureRegion, cycle: bool) void {
|
|
c.SDL_UploadToGPUTexture(@ptrCast(copy_pass), @ptrCast(source), @ptrCast(destination), cycle);
|
|
}
|
|
|
|
// SDL_UploadToGPUBuffer
|
|
pub inline fn uploadToGPUBuffer(copy_pass: *GPUCopyPass, source: [*c]const GPUTransferBufferLocation, destination: [*c]const GPUBufferRegion, cycle: bool) void {
|
|
c.SDL_UploadToGPUBuffer(@ptrCast(copy_pass), @ptrCast(source), @ptrCast(destination), cycle);
|
|
}
|
|
|
|
// SDL_CopyGPUTextureToTexture
|
|
pub inline fn copyGPUTextureToTexture(copy_pass: *GPUCopyPass, source: [*c]const GPUTextureLocation, destination: [*c]const GPUTextureLocation, w: u32, h: u32, d: u32, cycle: bool) void {
|
|
c.SDL_CopyGPUTextureToTexture(@ptrCast(copy_pass), @ptrCast(source), @ptrCast(destination), @bitCast(w), @bitCast(h), @bitCast(d), cycle);
|
|
}
|
|
|
|
// SDL_CopyGPUBufferToBuffer
|
|
pub inline fn copyGPUBufferToBuffer(copy_pass: *GPUCopyPass, source: [*c]const GPUBufferLocation, destination: [*c]const GPUBufferLocation, size: u32, cycle: bool) void {
|
|
c.SDL_CopyGPUBufferToBuffer(@ptrCast(copy_pass), @ptrCast(source), @ptrCast(destination), @bitCast(size), cycle);
|
|
}
|
|
|
|
// SDL_DownloadFromGPUTexture
|
|
pub inline fn downloadFromGPUTexture(copy_pass: *GPUCopyPass, source: [*c]const GPUTextureRegion, destination: [*c]const GPUTextureTransferInfo) void {
|
|
c.SDL_DownloadFromGPUTexture(@ptrCast(copy_pass), @ptrCast(source), @ptrCast(destination));
|
|
}
|
|
|
|
// SDL_DownloadFromGPUBuffer
|
|
pub inline fn downloadFromGPUBuffer(copy_pass: *GPUCopyPass, source: [*c]const GPUBufferRegion, destination: [*c]const GPUTransferBufferLocation) void {
|
|
c.SDL_DownloadFromGPUBuffer(@ptrCast(copy_pass), @ptrCast(source), @ptrCast(destination));
|
|
}
|
|
|
|
// SDL_EndGPUCopyPass
|
|
pub inline fn endGPUCopyPass(copy_pass: *GPUCopyPass) void {
|
|
c.SDL_EndGPUCopyPass(@ptrCast(copy_pass));
|
|
}
|
|
};
|
|
|
|
pub const GPUFence = opaque {};
|