1 // machine generated, do not edit
2 
3 module sokol.gfx;
4 
5 /// Resource id typedefs:
6 /// 
7 /// sg_buffer:      vertex- and index-buffers
8 /// sg_image:       images used as textures and render-pass attachments
9 /// sg_sampler      sampler objects describing how a texture is sampled in a shader
10 /// sg_shader:      vertex- and fragment-shaders and shader interface information
11 /// sg_pipeline:    associated shader and vertex-layouts, and render states
12 /// sg_attachments: a baked collection of render pass attachment images
13 /// 
14 /// Instead of pointers, resource creation functions return a 32-bit
15 /// handle which uniquely identifies the resource object.
16 /// 
17 /// The 32-bit resource id is split into a 16-bit pool index in the lower bits,
18 /// and a 16-bit 'generation counter' in the upper bits. The index allows fast
19 /// pool lookups, and combined with the generation-counter it allows to detect
20 /// 'dangling accesses' (trying to use an object which no longer exists, and
21 /// its pool slot has been reused for a new object)
22 /// 
23 /// The resource ids are wrapped into a strongly-typed struct so that
24 /// trying to pass an incompatible resource id is a compile error
25 extern(C)
26 struct Buffer {
27     uint id = 0;
28 }
29 extern(C)
30 struct Image {
31     uint id = 0;
32 }
33 extern(C)
34 struct Sampler {
35     uint id = 0;
36 }
37 extern(C)
38 struct Shader {
39     uint id = 0;
40 }
41 extern(C)
42 struct Pipeline {
43     uint id = 0;
44 }
45 extern(C)
46 struct Attachments {
47     uint id = 0;
48 }
49 /// sg_range is a pointer-size-pair struct used to pass memory blobs into
50 /// sokol-gfx. When initialized from a value type (array or struct), you can
51 /// use the SG_RANGE() macro to build an sg_range struct. For functions which
52 /// take either a sg_range pointer, or a (C++) sg_range reference, use the
53 /// SG_RANGE_REF macro as a solution which compiles both in C and C++
54 extern(C)
55 struct Range {
56     const(void)* ptr = null;
57     size_t size = 0;
58 }
59 /// various compile-time constants in the public AP
60 /// various compile-time constants in the public AP
61 enum invalid_id = 0;
62 /// various compile-time constants in the public AP
63 enum num_inflight_frames = 2;
64 /// various compile-time constants in the public AP
65 enum max_color_attachments = 4;
66 /// various compile-time constants in the public AP
67 enum max_uniformblock_members = 16;
68 /// various compile-time constants in the public AP
69 enum max_vertex_attributes = 16;
70 /// various compile-time constants in the public AP
71 enum max_mipmaps = 16;
72 /// various compile-time constants in the public AP
73 enum max_texturearray_layers = 128;
74 /// various compile-time constants in the public AP
75 enum max_uniformblock_bindslots = 8;
76 /// various compile-time constants in the public AP
77 enum max_vertexbuffer_bindslots = 8;
78 /// various compile-time constants in the public AP
79 enum max_image_bindslots = 16;
80 /// various compile-time constants in the public AP
81 enum max_sampler_bindslots = 16;
82 /// various compile-time constants in the public AP
83 enum max_storagebuffer_bindslots = 8;
84 /// various compile-time constants in the public AP
85 enum max_image_sampler_pairs = 16;
86 /// sg_color
87 /// 
88 /// An RGBA color value
89 extern(C)
90 struct Color {
91     float r = 0.0f;
92     float g = 0.0f;
93     float b = 0.0f;
94     float a = 0.0f;
95 }
96 /// sg_backend
97 /// 
98 /// The active 3D-API backend, use the function sg_query_backend()
99 /// to get the currently active backend
100 enum Backend {
101     Glcore,
102     Gles3,
103     D3d11,
104     Metal_ios,
105     Metal_macos,
106     Metal_simulator,
107     Wgpu,
108     Dummy,
109 }
110 /// sg_pixel_format
111 /// 
112 /// sokol_gfx.h basically uses the same pixel formats as WebGPU, since these
113 /// are supported on most newer GPUs.
114 /// 
115 /// A pixelformat name consist of three parts:
116 /// 
117 ///     - components (R, RG, RGB or RGBA)
118 ///     - bit width per component (8, 16 or 32)
119 ///     - component data type:
120 ///         - unsigned normalized (no postfix)
121 ///         - signed normalized (SN postfix)
122 ///         - unsigned integer (UI postfix)
123 ///         - signed integer (SI postfix)
124 ///         - float (F postfix)
125 /// 
126 /// Not all pixel formats can be used for everything, call sg_query_pixelformat()
127 /// to inspect the capabilities of a given pixelformat. The function returns
128 /// an sg_pixelformat_info struct with the following members:
129 /// 
130 ///     - sample: the pixelformat can be sampled as texture at least with
131 ///               nearest filtering
132 ///     - filter: the pixelformat can be sampled as texture with linear
133 ///               filtering
134 ///     - render: the pixelformat can be used as render-pass attachment
135 ///     - blend:  blending is supported when used as render-pass attachment
136 ///     - msaa:   multisample-antialiasing is supported when used
137 ///               as render-pass attachment
138 ///     - depth:  the pixelformat can be used for depth-stencil attachments
139 ///     - compressed: this is a block-compressed format
140 ///     - bytes_per_pixel: the numbers of bytes in a pixel (0 for compressed formats)
141 /// 
142 /// The default pixel format for texture images is SG_PIXELFORMAT_RGBA8.
143 /// 
144 /// The default pixel format for render target images is platform-dependent
145 /// and taken from the sg_environment struct passed into sg_setup(). Typically
146 /// the default formats are:
147 /// 
148 ///     - for the Metal, D3D11 and WebGPU backends: SG_PIXELFORMAT_BGRA8
149 ///     - for GL backends: SG_PIXELFORMAT_RGBA
150 enum PixelFormat {
151     Default,
152     None,
153     R8,
154     R8sn,
155     R8ui,
156     R8si,
157     R16,
158     R16sn,
159     R16ui,
160     R16si,
161     R16f,
162     Rg8,
163     Rg8sn,
164     Rg8ui,
165     Rg8si,
166     R32ui,
167     R32si,
168     R32f,
169     Rg16,
170     Rg16sn,
171     Rg16ui,
172     Rg16si,
173     Rg16f,
174     Rgba8,
175     Srgb8a8,
176     Rgba8sn,
177     Rgba8ui,
178     Rgba8si,
179     Bgra8,
180     Rgb10a2,
181     Rg11b10f,
182     Rgb9e5,
183     Rg32ui,
184     Rg32si,
185     Rg32f,
186     Rgba16,
187     Rgba16sn,
188     Rgba16ui,
189     Rgba16si,
190     Rgba16f,
191     Rgba32ui,
192     Rgba32si,
193     Rgba32f,
194     Depth,
195     Depth_stencil,
196     Bc1_rgba,
197     Bc2_rgba,
198     Bc3_rgba,
199     Bc3_srgba,
200     Bc4_r,
201     Bc4_rsn,
202     Bc5_rg,
203     Bc5_rgsn,
204     Bc6h_rgbf,
205     Bc6h_rgbuf,
206     Bc7_rgba,
207     Bc7_srgba,
208     Pvrtc_rgb_2bpp,
209     Pvrtc_rgb_4bpp,
210     Pvrtc_rgba_2bpp,
211     Pvrtc_rgba_4bpp,
212     Etc2_rgb8,
213     Etc2_srgb8,
214     Etc2_rgb8a1,
215     Etc2_rgba8,
216     Etc2_srgb8a8,
217     Eac_r11,
218     Eac_r11sn,
219     Eac_rg11,
220     Eac_rg11sn,
221     Astc_4x4_rgba,
222     Astc_4x4_srgba,
223     Num,
224 }
225 /// Runtime information about a pixel format, returned by sg_query_pixelformat()
226 extern(C)
227 struct PixelformatInfo {
228     bool sample = false;
229     bool filter = false;
230     bool render = false;
231     bool blend = false;
232     bool msaa = false;
233     bool depth = false;
234     bool compressed = false;
235     int bytes_per_pixel = 0;
236 }
237 /// Runtime information about available optional features, returned by sg_query_features(
238 extern(C)
239 struct Features {
240     bool origin_top_left = false;
241     bool image_clamp_to_border = false;
242     bool mrt_independent_blend_state = false;
243     bool mrt_independent_write_mask = false;
244     bool storage_buffer = false;
245     bool msaa_image_bindings = false;
246 }
247 /// Runtime information about resource limits, returned by sg_query_limit(
248 extern(C)
249 struct Limits {
250     int max_image_size_2d = 0;
251     int max_image_size_cube = 0;
252     int max_image_size_3d = 0;
253     int max_image_size_array = 0;
254     int max_image_array_layers = 0;
255     int max_vertex_attrs = 0;
256     int gl_max_vertex_uniform_components = 0;
257     int gl_max_combined_texture_image_units = 0;
258 }
259 /// sg_resource_state
260 /// 
261 /// The current state of a resource in its resource pool.
262 /// Resources start in the INITIAL state, which means the
263 /// pool slot is unoccupied and can be allocated. When a resource is
264 /// created, first an id is allocated, and the resource pool slot
265 /// is set to state ALLOC. After allocation, the resource is
266 /// initialized, which may result in the VALID or FAILED state. The
267 /// reason why allocation and initialization are separate is because
268 /// some resource types (e.g. buffers and images) might be asynchronously
269 /// initialized by the user application. If a resource which is not
270 /// in the VALID state is attempted to be used for rendering, rendering
271 /// operations will silently be dropped.
272 /// 
273 /// The special INVALID state is returned in sg_query_xxx_state() if no
274 /// resource object exists for the provided resource id
275 enum ResourceState {
276     Initial,
277     Alloc,
278     Valid,
279     Failed,
280     Invalid,
281 }
282 /// sg_usage
283 /// 
284 /// A resource usage hint describing the update strategy of
285 /// buffers and images. This is used in the sg_buffer_desc.usage
286 /// and sg_image_desc.usage members when creating buffers
287 /// and images:
288 /// 
289 /// SG_USAGE_IMMUTABLE:     the resource will never be updated with
290 ///                         new data, instead the content of the
291 ///                         resource must be provided on creation
292 /// SG_USAGE_DYNAMIC:       the resource will be updated infrequently
293 ///                         with new data (this could range from "once
294 ///                         after creation", to "quite often but not
295 ///                         every frame")
296 /// SG_USAGE_STREAM:        the resource will be updated each frame
297 ///                         with new content
298 /// 
299 /// The rendering backends use this hint to prevent that the
300 /// CPU needs to wait for the GPU when attempting to update
301 /// a resource that might be currently accessed by the GPU.
302 /// 
303 /// Resource content is updated with the functions sg_update_buffer() or
304 /// sg_append_buffer() for buffer objects, and sg_update_image() for image
305 /// objects. For the sg_update_*() functions, only one update is allowed per
306 /// frame and resource object, while sg_append_buffer() can be called
307 /// multiple times per frame on the same buffer. The application must update
308 /// all data required for rendering (this means that the update data can be
309 /// smaller than the resource size, if only a part of the overall resource
310 /// size is used for rendering, you only need to make sure that the data that
311 /// *is* used is valid).
312 /// 
313 /// The default usage is SG_USAGE_IMMUTABLE
314 enum Usage {
315     Default,
316     Immutable,
317     Dynamic,
318     Stream,
319     Num,
320 }
321 /// sg_buffer_type
322 /// 
323 /// Indicates whether a buffer will be bound as vertex-,
324 /// index- or storage-buffer.
325 /// 
326 /// Used in the sg_buffer_desc.type member when creating a buffer.
327 /// 
328 /// The default value is SG_BUFFERTYPE_VERTEXBUFFER
329 enum BufferType {
330     Default,
331     Vertexbuffer,
332     Indexbuffer,
333     Storagebuffer,
334     Num,
335 }
336 /// sg_index_type
337 /// 
338 /// Indicates whether indexed rendering (fetching vertex-indices from an
339 /// index buffer) is used, and if yes, the index data type (16- or 32-bits).
340 /// 
341 /// This is used in the sg_pipeline_desc.index_type member when creating a
342 /// pipeline object.
343 /// 
344 /// The default index type is SG_INDEXTYPE_NONE
345 enum IndexType {
346     Default,
347     None,
348     Uint16,
349     Uint32,
350     Num,
351 }
352 /// sg_image_type
353 /// 
354 /// Indicates the basic type of an image object (2D-texture, cubemap,
355 /// 3D-texture or 2D-array-texture). Used in the sg_image_desc.type member when
356 /// creating an image, and in sg_shader_image_desc to describe a sampled texture
357 /// in the shader (both must match and will be checked in the validation layer
358 /// when calling sg_apply_bindings).
359 /// 
360 /// The default image type when creating an image is SG_IMAGETYPE_2D
361 enum ImageType {
362     Default,
363     _2d,
364     Cube,
365     _3d,
366     Array,
367     Num,
368 }
369 /// sg_image_sample_type
370 /// 
371 /// The basic data type of a texture sample as expected by a shader.
372 /// Must be provided in sg_shader_image and used by the validation
373 /// layer in sg_apply_bindings() to check if the provided image object
374 /// is compatible with what the shader expects. Apart from the sokol-gfx
375 /// validation layer, WebGPU is the only backend API which actually requires
376 /// matching texture and sampler type to be provided upfront for validation
377 /// (other 3D APIs treat texture/sampler type mismatches as undefined behaviour).
378 /// 
379 /// NOTE that the following texture pixel formats require the use
380 /// of SG_IMAGESAMPLETYPE_UNFILTERABLE_FLOAT, combined with a sampler
381 /// of type SG_SAMPLERTYPE_NONFILTERING:
382 /// 
383 /// - SG_PIXELFORMAT_R32F
384 /// - SG_PIXELFORMAT_RG32F
385 /// - SG_PIXELFORMAT_RGBA32F
386 /// 
387 /// (when using sokol-shdc, also check out the meta tags `@image_sample_type`
388 /// and `@sampler_type`
389 enum ImageSampleType {
390     Default,
391     Float,
392     Depth,
393     Sint,
394     Uint,
395     Unfilterable_float,
396     Num,
397 }
398 /// sg_sampler_type
399 /// 
400 /// The basic type of a texture sampler (sampling vs comparison) as
401 /// defined in a shader. Must be provided in sg_shader_sampler_desc.
402 /// 
403 /// sg_image_sample_type and sg_sampler_type for a texture/sampler
404 /// pair must be compatible with each other, specifically only
405 /// the following pairs are allowed:
406 /// 
407 /// - SG_IMAGESAMPLETYPE_FLOAT => (SG_SAMPLERTYPE_FILTERING or SG_SAMPLERTYPE_NONFILTERING)
408 /// - SG_IMAGESAMPLETYPE_UNFILTERABLE_FLOAT => SG_SAMPLERTYPE_NONFILTERING
409 /// - SG_IMAGESAMPLETYPE_SINT => SG_SAMPLERTYPE_NONFILTERING
410 /// - SG_IMAGESAMPLETYPE_UINT => SG_SAMPLERTYPE_NONFILTERING
411 /// - SG_IMAGESAMPLETYPE_DEPTH => SG_SAMPLERTYPE_COMPARISO
412 enum SamplerType {
413     Default,
414     Filtering,
415     Nonfiltering,
416     Comparison,
417     Num,
418 }
419 /// sg_cube_face
420 /// 
421 /// The cubemap faces. Use these as indices in the sg_image_desc.content
422 /// array
423 enum CubeFace {
424     Pos_x,
425     Neg_x,
426     Pos_y,
427     Neg_y,
428     Pos_z,
429     Neg_z,
430     Num,
431 }
432 /// sg_primitive_type
433 /// 
434 /// This is the common subset of 3D primitive types supported across all 3D
435 /// APIs. This is used in the sg_pipeline_desc.primitive_type member when
436 /// creating a pipeline object.
437 /// 
438 /// The default primitive type is SG_PRIMITIVETYPE_TRIANGLES
439 enum PrimitiveType {
440     Default,
441     Points,
442     Lines,
443     Line_strip,
444     Triangles,
445     Triangle_strip,
446     Num,
447 }
448 /// sg_filter
449 /// 
450 /// The filtering mode when sampling a texture image. This is
451 /// used in the sg_sampler_desc.min_filter, sg_sampler_desc.mag_filter
452 /// and sg_sampler_desc.mipmap_filter members when creating a sampler object.
453 /// 
454 /// For the default is SG_FILTER_NEAREST
455 enum Filter {
456     Default,
457     Nearest,
458     Linear,
459     Num,
460 }
461 /// sg_wrap
462 /// 
463 /// The texture coordinates wrapping mode when sampling a texture
464 /// image. This is used in the sg_image_desc.wrap_u, .wrap_v
465 /// and .wrap_w members when creating an image.
466 /// 
467 /// The default wrap mode is SG_WRAP_REPEAT.
468 /// 
469 /// NOTE: SG_WRAP_CLAMP_TO_BORDER is not supported on all backends
470 /// and platforms. To check for support, call sg_query_features()
471 /// and check the "clamp_to_border" boolean in the returned
472 /// sg_features struct.
473 /// 
474 /// Platforms which don't support SG_WRAP_CLAMP_TO_BORDER will silently fall back
475 /// to SG_WRAP_CLAMP_TO_EDGE without a validation error
476 enum Wrap {
477     Default,
478     Repeat,
479     Clamp_to_edge,
480     Clamp_to_border,
481     Mirrored_repeat,
482     Num,
483 }
484 /// sg_border_color
485 /// 
486 /// The border color to use when sampling a texture, and the UV wrap
487 /// mode is SG_WRAP_CLAMP_TO_BORDER.
488 /// 
489 /// The default border color is SG_BORDERCOLOR_OPAQUE_BLAC
490 enum BorderColor {
491     Default,
492     Transparent_black,
493     Opaque_black,
494     Opaque_white,
495     Num,
496 }
497 /// sg_vertex_format
498 /// 
499 /// The data type of a vertex component. This is used to describe
500 /// the layout of vertex data when creating a pipeline object
501 enum VertexFormat {
502     Invalid,
503     Float,
504     Float2,
505     Float3,
506     Float4,
507     Byte4,
508     Byte4n,
509     Ubyte4,
510     Ubyte4n,
511     Short2,
512     Short2n,
513     Ushort2n,
514     Short4,
515     Short4n,
516     Ushort4n,
517     Uint10_n2,
518     Half2,
519     Half4,
520     Num,
521 }
522 /// sg_vertex_step
523 /// 
524 /// Defines whether the input pointer of a vertex input stream is advanced
525 /// 'per vertex' or 'per instance'. The default step-func is
526 /// SG_VERTEXSTEP_PER_VERTEX. SG_VERTEXSTEP_PER_INSTANCE is used with
527 /// instanced-rendering.
528 /// 
529 /// The vertex-step is part of the vertex-layout definition
530 /// when creating pipeline objects
531 enum VertexStep {
532     Default,
533     Per_vertex,
534     Per_instance,
535     Num,
536 }
537 /// sg_uniform_type
538 /// 
539 /// The data type of a uniform block member. This is used to
540 /// describe the internal layout of uniform blocks when creating
541 /// a shader object. This is only required for the GL backend, all
542 /// other backends will ignore the interior layout of uniform blocks
543 enum UniformType {
544     Invalid,
545     Float,
546     Float2,
547     Float3,
548     Float4,
549     Int,
550     Int2,
551     Int3,
552     Int4,
553     Mat4,
554     Num,
555 }
556 /// sg_uniform_layout
557 /// 
558 /// A hint for the interior memory layout of uniform blocks. This is
559 /// only relevant for the GL backend where the internal layout
560 /// of uniform blocks must be known to sokol-gfx. For all other backends the
561 /// internal memory layout of uniform blocks doesn't matter, sokol-gfx
562 /// will just pass uniform data as a single memory blob to the
563 /// 3D backend.
564 /// 
565 /// SG_UNIFORMLAYOUT_NATIVE (default)
566 ///     Native layout means that a 'backend-native' memory layout
567 ///     is used. For the GL backend this means that uniforms
568 ///     are packed tightly in memory (e.g. there are no padding
569 ///     bytes).
570 /// 
571 /// SG_UNIFORMLAYOUT_STD140
572 ///     The memory layout is a subset of std140. Arrays are only
573 ///     allowed for the FLOAT4, INT4 and MAT4. Alignment is as
574 ///     is as follows:
575 /// 
576 ///         FLOAT, INT:         4 byte alignment
577 ///         FLOAT2, INT2:       8 byte alignment
578 ///         FLOAT3, INT3:       16 byte alignment(!)
579 ///         FLOAT4, INT4:       16 byte alignment
580 ///         MAT4:               16 byte alignment
581 ///         FLOAT4[], INT4[]:   16 byte alignment
582 /// 
583 ///     The overall size of the uniform block must be a multiple
584 ///     of 16.
585 /// 
586 /// For more information search for 'UNIFORM DATA LAYOUT' in the documentation block
587 /// at the start of the header
588 enum UniformLayout {
589     Default,
590     Native,
591     Std140,
592     Num,
593 }
594 /// sg_cull_mode
595 /// 
596 /// The face-culling mode, this is used in the
597 /// sg_pipeline_desc.cull_mode member when creating a
598 /// pipeline object.
599 /// 
600 /// The default cull mode is SG_CULLMODE_NON
601 enum CullMode {
602     Default,
603     None,
604     Front,
605     Back,
606     Num,
607 }
608 /// sg_face_winding
609 /// 
610 /// The vertex-winding rule that determines a front-facing primitive. This
611 /// is used in the member sg_pipeline_desc.face_winding
612 /// when creating a pipeline object.
613 /// 
614 /// The default winding is SG_FACEWINDING_CW (clockwise
615 enum FaceWinding {
616     Default,
617     Ccw,
618     Cw,
619     Num,
620 }
621 /// sg_compare_func
622 /// 
623 /// The compare-function for configuring depth- and stencil-ref tests
624 /// in pipeline objects, and for texture samplers which perform a comparison
625 /// instead of regular sampling operation.
626 /// 
627 /// Used in the following structs:
628 /// 
629 /// sg_pipeline_desc
630 ///     .depth
631 ///         .compare
632 ///     .stencil
633 ///         .front.compare
634 ///         .back.compar
635 /// 
636 /// sg_sampler_desc
637 ///     .compare
638 /// 
639 /// The default compare func for depth- and stencil-tests is
640 /// SG_COMPAREFUNC_ALWAYS.
641 /// 
642 /// The default compare func for samplers is SG_COMPAREFUNC_NEVER
643 enum CompareFunc {
644     Default,
645     Never,
646     Less,
647     Equal,
648     Less_equal,
649     Greater,
650     Not_equal,
651     Greater_equal,
652     Always,
653     Num,
654 }
655 /// sg_stencil_op
656 /// 
657 /// The operation performed on a currently stored stencil-value when a
658 /// comparison test passes or fails. This is used when creating a pipeline
659 /// object in the following sg_pipeline_desc struct items:
660 /// 
661 /// sg_pipeline_desc
662 ///     .stencil
663 ///         .front
664 ///             .fail_op
665 ///             .depth_fail_op
666 ///             .pass_op
667 ///         .back
668 ///             .fail_op
669 ///             .depth_fail_op
670 ///             .pass_op
671 /// 
672 /// The default value is SG_STENCILOP_KEEP
673 enum StencilOp {
674     Default,
675     Keep,
676     Zero,
677     Replace,
678     Incr_clamp,
679     Decr_clamp,
680     Invert,
681     Incr_wrap,
682     Decr_wrap,
683     Num,
684 }
685 /// sg_blend_factor
686 /// 
687 /// The source and destination factors in blending operations.
688 /// This is used in the following members when creating a pipeline object:
689 /// 
690 /// sg_pipeline_desc
691 ///     .colors[i]
692 ///         .blend
693 ///             .src_factor_rgb
694 ///             .dst_factor_rgb
695 ///             .src_factor_alpha
696 ///             .dst_factor_alpha
697 /// 
698 /// The default value is SG_BLENDFACTOR_ONE for source
699 /// factors, and SG_BLENDFACTOR_ZERO for destination factors
700 enum BlendFactor {
701     Default,
702     Zero,
703     One,
704     Src_color,
705     One_minus_src_color,
706     Src_alpha,
707     One_minus_src_alpha,
708     Dst_color,
709     One_minus_dst_color,
710     Dst_alpha,
711     One_minus_dst_alpha,
712     Src_alpha_saturated,
713     Blend_color,
714     One_minus_blend_color,
715     Blend_alpha,
716     One_minus_blend_alpha,
717     Num,
718 }
719 /// sg_blend_op
720 /// 
721 /// Describes how the source and destination values are combined in the
722 /// fragment blending operation. It is used in the following struct items
723 /// when creating a pipeline object:
724 /// 
725 /// sg_pipeline_desc
726 ///     .colors[i]
727 ///         .blend
728 ///             .op_rgb
729 ///             .op_alpha
730 /// 
731 /// The default value is SG_BLENDOP_ADD
732 enum BlendOp {
733     Default,
734     Add,
735     Subtract,
736     Reverse_subtract,
737     Num,
738 }
739 /// sg_color_mask
740 /// 
741 /// Selects the active color channels when writing a fragment color to the
742 /// framebuffer. This is used in the members
743 /// sg_pipeline_desc.colors[i].write_mask when creating a pipeline object.
744 /// 
745 /// The default colormask is SG_COLORMASK_RGBA (write all colors channels)
746 /// 
747 /// NOTE: since the color mask value 0 is reserved for the default value
748 /// (SG_COLORMASK_RGBA), use SG_COLORMASK_NONE if all color channels
749 /// should be disabled
750 enum ColorMask {
751     Default = 0,
752     None = 16,
753     R = 1,
754     G = 2,
755     Rg = 3,
756     B = 4,
757     Rb = 5,
758     Gb = 6,
759     Rgb = 7,
760     A = 8,
761     Ra = 9,
762     Ga = 10,
763     Rga = 11,
764     Ba = 12,
765     Rba = 13,
766     Gba = 14,
767     Rgba = 15,
768 }
769 /// sg_load_action
770 /// 
771 /// Defines the load action that should be performed at the start of a render pass:
772 /// 
773 /// SG_LOADACTION_CLEAR:        clear the render target
774 /// SG_LOADACTION_LOAD:         load the previous content of the render target
775 /// SG_LOADACTION_DONTCARE:     leave the render target in an undefined state
776 /// 
777 /// This is used in the sg_pass_action structure.
778 /// 
779 /// The default load action for all pass attachments is SG_LOADACTION_CLEAR,
780 /// with the values rgba = { 0.5f, 0.5f, 0.5f, 1.0f }, depth=1.0f and stencil=0.
781 /// 
782 /// If you want to override the default behaviour, it is important to not
783 /// only set the clear color, but the 'action' field as well (as long as this
784 /// is _SG_LOADACTION_DEFAULT, the value fields will be ignored)
785 enum LoadAction {
786     Default,
787     Clear,
788     Load,
789     Dontcare,
790 }
791 /// sg_store_action
792 /// 
793 /// Defines the store action that should be performed at the end of a render pass:
794 /// 
795 /// SG_STOREACTION_STORE:       store the rendered content to the color attachment image
796 /// SG_STOREACTION_DONTCARE:    allows the GPU to discard the rendered conten
797 enum StoreAction {
798     Default,
799     Store,
800     Dontcare,
801 }
802 /// sg_pass_action
803 /// 
804 /// The sg_pass_action struct defines the actions to be performed
805 /// at the start and end of a render pass.
806 /// 
807 /// - at the start of the pass: whether the render attachments should be cleared,
808 ///   loaded with their previous content, or start in an undefined state
809 /// - for clear operations: the clear value (color, depth, or stencil values)
810 /// - at the end of the pass: whether the rendering result should be
811 ///   stored back into the render attachment or discarde
812 extern(C)
813 struct ColorAttachmentAction {
814     LoadAction load_action;
815     StoreAction store_action;
816     Color clear_value;
817 }
818 extern(C)
819 struct DepthAttachmentAction {
820     LoadAction load_action;
821     StoreAction store_action;
822     float clear_value = 0.0f;
823 }
824 extern(C)
825 struct StencilAttachmentAction {
826     LoadAction load_action;
827     StoreAction store_action;
828     ubyte clear_value = 0;
829 }
830 extern(C)
831 struct PassAction {
832     ColorAttachmentAction[4] colors;
833     DepthAttachmentAction depth;
834     StencilAttachmentAction stencil;
835 }
836 /// sg_swapchain
837 /// 
838 /// Used in sg_begin_pass() to provide details about an external swapchain
839 /// (pixel formats, sample count and backend-API specific render surface objects).
840 /// 
841 /// The following information must be provided:
842 /// 
843 /// - the width and height of the swapchain surfaces in number of pixels,
844 /// - the pixel format of the render- and optional msaa-resolve-surface
845 /// - the pixel format of the optional depth- or depth-stencil-surface
846 /// - the MSAA sample count for the render and depth-stencil surface
847 /// 
848 /// If the pixel formats and MSAA sample counts are left zero-initialized,
849 /// their defaults are taken from the sg_environment struct provided in the
850 /// sg_setup() call.
851 /// 
852 /// The width and height *must* be > 0.
853 /// 
854 /// Additionally the following backend API specific objects must be passed in
855 /// as 'type erased' void pointers:
856 /// 
857 /// GL:
858 ///     - on all GL backends, a GL framebuffer object must be provided. This
859 ///       can be zero for the default framebuffer.
860 /// 
861 /// D3D11:
862 ///     - an ID3D11RenderTargetView for the rendering surface, without
863 ///       MSAA rendering this surface will also be displayed
864 ///     - an optional ID3D11DepthStencilView for the depth- or depth/stencil
865 ///       buffer surface
866 ///     - when MSAA rendering is used, another ID3D11RenderTargetView
867 ///       which serves as MSAA resolve target and will be displayed
868 /// 
869 /// WebGPU (same as D3D11, except different types)
870 ///     - a WGPUTextureView for the rendering surface, without
871 ///       MSAA rendering this surface will also be displayed
872 ///     - an optional WGPUTextureView for the depth- or depth/stencil
873 ///       buffer surface
874 ///     - when MSAA rendering is used, another WGPUTextureView
875 ///       which serves as MSAA resolve target and will be displayed
876 /// 
877 /// Metal (NOTE that the roles of provided surfaces is slightly different
878 /// than on D3D11 or WebGPU in case of MSAA vs non-MSAA rendering):
879 /// 
880 ///     - A current CAMetalDrawable (NOT an MTLDrawable!) which will be presented.
881 ///       This will either be rendered to directly (if no MSAA is used), or serve
882 ///       as MSAA-resolve target.
883 ///     - an optional MTLTexture for the depth- or depth-stencil buffer
884 ///     - an optional multisampled MTLTexture which serves as intermediate
885 ///       rendering surface which will then be resolved into the
886 ///       CAMetalDrawable.
887 /// 
888 /// NOTE that for Metal you must use an ObjC __bridge cast to
889 /// properly tunnel the ObjC object id through a C void*, e.g.:
890 /// 
891 ///     swapchain.metal.current_drawable = (__bridge const void*) [mtkView currentDrawable];
892 /// 
893 /// On all other backends you shouldn't need to mess with the reference count.
894 /// 
895 /// It's a good practice to write a helper function which returns an initialized
896 /// sg_swapchain structs, which can then be plugged directly into
897 /// sg_pass.swapchain. Look at the function sglue_swapchain() in the sokol_glue.h
898 /// as an example
899 extern(C)
900 struct MetalSwapchain {
901     const(void)* current_drawable = null;
902     const(void)* depth_stencil_texture = null;
903     const(void)* msaa_color_texture = null;
904 }
905 extern(C)
906 struct D3d11Swapchain {
907     const(void)* render_view = null;
908     const(void)* resolve_view = null;
909     const(void)* depth_stencil_view = null;
910 }
911 extern(C)
912 struct WgpuSwapchain {
913     const(void)* render_view = null;
914     const(void)* resolve_view = null;
915     const(void)* depth_stencil_view = null;
916 }
917 extern(C)
918 struct GlSwapchain {
919     uint framebuffer = 0;
920 }
921 extern(C)
922 struct Swapchain {
923     int width = 0;
924     int height = 0;
925     int sample_count = 0;
926     PixelFormat color_format;
927     PixelFormat depth_format;
928     MetalSwapchain metal;
929     D3d11Swapchain d3d11;
930     WgpuSwapchain wgpu;
931     GlSwapchain gl;
932 }
933 /// sg_pass
934 /// 
935 /// The sg_pass structure is passed as argument into the sg_begin_pass()
936 /// function.
937 /// 
938 /// For an offscreen rendering pass, an sg_pass_action struct and sg_attachments
939 /// object must be provided, and for swapchain passes, an sg_pass_action and
940 /// an sg_swapchain struct. It is an error to provide both an sg_attachments
941 /// handle and an initialized sg_swapchain struct in the same sg_begin_pass().
942 /// 
943 /// An sg_begin_pass() call for an offscreen pass would look like this (where
944 /// `attachments` is an sg_attachments handle):
945 /// 
946 ///     sg_begin_pass(&(sg_pass){
947 ///         .action = { ... },
948 ///         .attachments = attachments,
949 ///     });
950 /// 
951 /// ...and a swapchain render pass would look like this (using the sokol_glue.h
952 /// helper function sglue_swapchain() which gets the swapchain properties from
953 /// sokol_app.h):
954 /// 
955 ///     sg_begin_pass(&(sg_pass){
956 ///         .action = { ... },
957 ///         .swapchain = sglue_swapchain(),
958 ///     });
959 /// 
960 /// You can also omit the .action object to get default pass action behaviour
961 /// (clear to color=grey, depth=1 and stencil=0)
962 extern(C)
963 struct Pass {
964     uint _start_canary = 0;
965     PassAction action;
966     Attachments attachments;
967     Swapchain swapchain;
968     const(char)* label = null;
969     uint _end_canary = 0;
970 }
971 /// sg_bindings
972 /// 
973 /// The sg_bindings structure defines the buffers, images and
974 /// samplers resource bindings for the next draw call.
975 /// 
976 /// To update the resource bindings, call sg_apply_bindings() with
977 /// a pointer to a populated sg_bindings struct. Note that
978 /// sg_apply_bindings() must be called after sg_apply_pipeline()
979 /// and that bindings are not preserved across sg_apply_pipeline()
980 /// calls, even when the new pipeline uses the same 'bindings layout'.
981 /// 
982 /// A resource binding struct contains:
983 /// 
984 /// - 1..N vertex buffers
985 /// - 0..N vertex buffer offsets
986 /// - 0..1 index buffers
987 /// - 0..1 index buffer offsets
988 /// - 0..N images
989 /// - 0..N samplers
990 /// - 0..N storage buffers
991 /// 
992 /// Where 'N' is defined in the following constants:
993 /// 
994 /// - SG_MAX_VERTEXBUFFER_BINDSLOTS
995 /// - SG_MAX_IMAGE_BINDLOTS
996 /// - SG_MAX_SAMPLER_BINDSLOTS
997 /// - SG_MAX_STORAGEBUFFER_BINDGLOTS
998 /// 
999 /// When using sokol-shdc for shader authoring, the `layout(binding=N)`
1000 /// annotation in the shader code directly maps to the slot index for that
1001 /// resource type in the bindings struct, for instance the following vertex-
1002 /// and fragment-shader interface for sokol-shdc:
1003 /// 
1004 ///     @vs vs
1005 ///     layout(binding=0) uniform vs_params { ... };
1006 ///     layout(binding=0) readonly buffer ssbo { ... };
1007 ///     layout(binding=0) uniform texture2D vs_tex;
1008 ///     layout(binding=0) uniform sampler vs_smp;
1009 ///     ...
1010 ///     @end
1011 /// 
1012 ///     @fs fs
1013 ///     layout(binding=1) uniform fs_params { ... };
1014 ///     layout(binding=1) uniform texture2D fs_tex;
1015 ///     layout(binding=1) uniform sampler fs_smp;
1016 ///     ...
1017 ///     @end
1018 /// 
1019 /// ...would map to the following sg_bindings struct:
1020 /// 
1021 ///     const sg_bindings bnd = {
1022 ///         .vertex_buffers[0] = ...,
1023 ///         .images[0] = vs_tex,
1024 ///         .images[1] = fs_tex,
1025 ///         .samplers[0] = vs_smp,
1026 ///         .samplers[1] = fs_smp,
1027 ///         .storage_buffers[0] = ssbo,
1028 ///     };
1029 /// 
1030 /// ...alternatively you can use code-generated slot indices:
1031 /// 
1032 ///     const sg_bindings bnd = {
1033 ///         .vertex_buffers[0] = ...,
1034 ///         .images[IMG_vs_tex] = vs_tex,
1035 ///         .images[IMG_fs_tex] = fs_tex,
1036 ///         .samplers[SMP_vs_smp] = vs_smp,
1037 ///         .samplers[SMP_fs_smp] = fs_smp,
1038 ///         .storage_buffers[SBUF_ssbo] = ssbo,
1039 ///     };
1040 /// 
1041 /// Resource bindslots for a specific shader/pipeline may have gaps, and an
1042 /// sg_bindings struct may have populated bind slots which are not used by a
1043 /// specific shader. This allows to use the same sg_bindings struct across
1044 /// different shader variants.
1045 /// 
1046 /// When not using sokol-shdc, the bindslot indices in the sg_bindings
1047 /// struct need to match the per-resource reflection info slot indices
1048 /// in the sg_shader_desc struct (for details about that see the
1049 /// sg_shader_desc struct documentation).
1050 /// 
1051 /// The optional buffer offsets can be used to put different unrelated
1052 /// chunks of vertex- and/or index-data into the same buffer objects
1053 extern(C)
1054 struct Bindings {
1055     uint _start_canary = 0;
1056     Buffer[8] vertex_buffers;
1057     int[8] vertex_buffer_offsets = 0;
1058     Buffer index_buffer;
1059     int index_buffer_offset = 0;
1060     Image[16] images;
1061     Sampler[16] samplers;
1062     Buffer[8] storage_buffers;
1063     uint _end_canary = 0;
1064 }
1065 /// sg_buffer_desc
1066 /// 
1067 /// Creation parameters for sg_buffer objects, used in the
1068 /// sg_make_buffer() call.
1069 /// 
1070 /// The default configuration is:
1071 /// 
1072 /// .size:      0       (*must* be >0 for buffers without data)
1073 /// .type:      SG_BUFFERTYPE_VERTEXBUFFER
1074 /// .usage:     SG_USAGE_IMMUTABLE
1075 /// .data.ptr   0       (*must* be valid for immutable buffers)
1076 /// .data.size  0       (*must* be > 0 for immutable buffers)
1077 /// .label      0       (optional string label)
1078 /// 
1079 /// For immutable buffers which are initialized with initial data,
1080 /// keep the .size item zero-initialized, and set the size together with the
1081 /// pointer to the initial data in the .data item.
1082 /// 
1083 /// For mutable buffers without initial data, keep the .data item
1084 /// zero-initialized, and set the buffer size in the .size item instead.
1085 /// 
1086 /// You can also set both size values, but currently both size values must
1087 /// be identical (this may change in the future when the dynamic resource
1088 /// management may become more flexible).
1089 /// 
1090 /// ADVANCED TOPIC: Injecting native 3D-API buffers:
1091 /// 
1092 /// The following struct members allow to inject your own GL, Metal
1093 /// or D3D11 buffers into sokol_gfx:
1094 /// 
1095 /// .gl_buffers[SG_NUM_INFLIGHT_FRAMES]
1096 /// .mtl_buffers[SG_NUM_INFLIGHT_FRAMES]
1097 /// .d3d11_buffer
1098 /// 
1099 /// You must still provide all other struct items except the .data item, and
1100 /// these must match the creation parameters of the native buffers you
1101 /// provide. For SG_USAGE_IMMUTABLE, only provide a single native 3D-API
1102 /// buffer, otherwise you need to provide SG_NUM_INFLIGHT_FRAMES buffers
1103 /// (only for GL and Metal, not D3D11). Providing multiple buffers for GL and
1104 /// Metal is necessary because sokol_gfx will rotate through them when
1105 /// calling sg_update_buffer() to prevent lock-stalls.
1106 /// 
1107 /// Note that it is expected that immutable injected buffer have already been
1108 /// initialized with content, and the .content member must be 0!
1109 /// 
1110 /// Also you need to call sg_reset_state_cache() after calling native 3D-API
1111 /// functions, and before calling any sokol_gfx function
1112 extern(C)
1113 struct BufferDesc {
1114     uint _start_canary = 0;
1115     size_t size = 0;
1116     BufferType type;
1117     Usage usage;
1118     Range data;
1119     const(char)* label = null;
1120     uint[2] gl_buffers = 0;
1121     const(void)*[2] mtl_buffers = null;
1122     const(void)* d3d11_buffer = null;
1123     const(void)* wgpu_buffer = null;
1124     uint _end_canary = 0;
1125 }
1126 /// sg_image_data
1127 /// 
1128 /// Defines the content of an image through a 2D array of sg_range structs.
1129 /// The first array dimension is the cubemap face, and the second array
1130 /// dimension the mipmap level
1131 extern(C)
1132 struct ImageData {
1133     Range[6][16] subimage;
1134 }
1135 /// sg_image_desc
1136 /// 
1137 /// Creation parameters for sg_image objects, used in the sg_make_image() call.
1138 /// 
1139 /// The default configuration is:
1140 /// 
1141 /// .type:              SG_IMAGETYPE_2D
1142 /// .render_target:     false
1143 /// .width              0 (must be set to >0)
1144 /// .height             0 (must be set to >0)
1145 /// .num_slices         1 (3D textures: depth; array textures: number of layers)
1146 /// .num_mipmaps:       1
1147 /// .usage:             SG_USAGE_IMMUTABLE
1148 /// .pixel_format:      SG_PIXELFORMAT_RGBA8 for textures, or sg_desc.environment.defaults.color_format for render targets
1149 /// .sample_count:      1 for textures, or sg_desc.environment.defaults.sample_count for render targets
1150 /// .data               an sg_image_data struct to define the initial content
1151 /// .label              0 (optional string label for trace hooks)
1152 /// 
1153 /// Q: Why is the default sample_count for render targets identical with the
1154 /// "default sample count" from sg_desc.environment.defaults.sample_count?
1155 /// 
1156 /// A: So that it matches the default sample count in pipeline objects. Even
1157 /// though it is a bit strange/confusing that offscreen render targets by default
1158 /// get the same sample count as 'default swapchains', but it's better that
1159 /// an offscreen render target created with default parameters matches
1160 /// a pipeline object created with default parameters.
1161 /// 
1162 /// NOTE:
1163 /// 
1164 /// Images with usage SG_USAGE_IMMUTABLE must be fully initialized by
1165 /// providing a valid .data member which points to initialization data.
1166 /// 
1167 /// ADVANCED TOPIC: Injecting native 3D-API textures:
1168 /// 
1169 /// The following struct members allow to inject your own GL, Metal or D3D11
1170 /// textures into sokol_gfx:
1171 /// 
1172 /// .gl_textures[SG_NUM_INFLIGHT_FRAMES]
1173 /// .mtl_textures[SG_NUM_INFLIGHT_FRAMES]
1174 /// .d3d11_texture
1175 /// .d3d11_shader_resource_view
1176 /// .wgpu_texture
1177 /// .wgpu_texture_view
1178 /// 
1179 /// For GL, you can also specify the texture target or leave it empty to use
1180 /// the default texture target for the image type (GL_TEXTURE_2D for
1181 /// SG_IMAGETYPE_2D etc)
1182 /// 
1183 /// For D3D11 and WebGPU, either only provide a texture, or both a texture and
1184 /// shader-resource-view / texture-view object. If you want to use access the
1185 /// injected texture in a shader you *must* provide a shader-resource-view.
1186 /// 
1187 /// The same rules apply as for injecting native buffers (see sg_buffer_desc
1188 /// documentation for more details)
1189 extern(C)
1190 struct ImageDesc {
1191     uint _start_canary = 0;
1192     ImageType type;
1193     bool render_target = false;
1194     int width = 0;
1195     int height = 0;
1196     int num_slices = 0;
1197     int num_mipmaps = 0;
1198     Usage usage;
1199     PixelFormat pixel_format;
1200     int sample_count = 0;
1201     ImageData data;
1202     const(char)* label = null;
1203     uint[2] gl_textures = 0;
1204     uint gl_texture_target = 0;
1205     const(void)*[2] mtl_textures = null;
1206     const(void)* d3d11_texture = null;
1207     const(void)* d3d11_shader_resource_view = null;
1208     const(void)* wgpu_texture = null;
1209     const(void)* wgpu_texture_view = null;
1210     uint _end_canary = 0;
1211 }
1212 /// sg_sampler_desc
1213 /// 
1214 /// Creation parameters for sg_sampler objects, used in the sg_make_sampler() call
1215 /// 
1216 /// .min_filter:        SG_FILTER_NEAREST
1217 /// .mag_filter:        SG_FILTER_NEAREST
1218 /// .mipmap_filter      SG_FILTER_NEAREST
1219 /// .wrap_u:            SG_WRAP_REPEAT
1220 /// .wrap_v:            SG_WRAP_REPEAT
1221 /// .wrap_w:            SG_WRAP_REPEAT (only SG_IMAGETYPE_3D)
1222 /// .min_lod            0.0f
1223 /// .max_lod            FLT_MAX
1224 /// .border_color       SG_BORDERCOLOR_OPAQUE_BLACK
1225 /// .compare            SG_COMPAREFUNC_NEVER
1226 /// .max_anisotropy     1 (must be 1..16
1227 extern(C)
1228 struct SamplerDesc {
1229     uint _start_canary = 0;
1230     Filter min_filter;
1231     Filter mag_filter;
1232     Filter mipmap_filter;
1233     Wrap wrap_u;
1234     Wrap wrap_v;
1235     Wrap wrap_w;
1236     float min_lod = 0.0f;
1237     float max_lod = 0.0f;
1238     BorderColor border_color;
1239     CompareFunc compare;
1240     uint max_anisotropy = 0;
1241     const(char)* label = null;
1242     uint gl_sampler = 0;
1243     const(void)* mtl_sampler = null;
1244     const(void)* d3d11_sampler = null;
1245     const(void)* wgpu_sampler = null;
1246     uint _end_canary = 0;
1247 }
1248 /// sg_shader_desc
1249 /// 
1250 /// Used as parameter of sg_make_shader() to create a shader object which
1251 /// communicates shader source or bytecode and shader interface
1252 /// reflection information to sokol-gfx.
1253 /// 
1254 /// If you use sokol-shdc you can ignore the following information since
1255 /// the sg_shader_desc struct will be code generated.
1256 /// 
1257 /// Otherwise you need to provide the following information to the
1258 /// sg_make_shader() call:
1259 /// 
1260 /// - a vertex- and fragment-shader function:
1261 ///     - the shader source or bytecode
1262 ///     - an optional entry point name
1263 ///     - for D3D11: an optional compile target when source code is provided
1264 ///       (the defaults are "vs_4_0" and "ps_4_0")
1265 /// 
1266 /// - vertex attributes required by some backends:
1267 ///     - for the GL backend: optional vertex attribute names
1268 ///       used for name lookup
1269 ///     - for the D3D11 backend: semantic names and indices
1270 /// 
1271 /// - reflection information for each uniform block used by the shader:
1272 ///     - the shader stage the uniform block appears in (SG_SHADERSTAGE_*)
1273 ///     - the size in bytes of the uniform block
1274 ///     - backend-specific bindslots:
1275 ///         - HLSL: the constant buffer register `register(b0..7)`
1276 ///         - MSL: the buffer attribute `[[buffer(0..7)]]`
1277 ///         - WGSL: the binding in `@group(0) @binding(0..15)`
1278 ///     - GLSL only: a description of the uniform block interior
1279 ///         - the memory layout standard (SG_UNIFORMLAYOUT_*)
1280 ///         - for each member in the uniform block:
1281 ///             - the member type (SG_UNIFORM_*)
1282 ///             - if the member is an array, the array count
1283 ///             - the member name
1284 /// 
1285 /// - reflection information for each texture used by the shader:
1286 ///     - the shader stage the texture appears in (SG_SHADERSTAGE_*)
1287 ///     - the image type (SG_IMAGETYPE_*)
1288 ///     - the image-sample type (SG_IMAGESAMPLETYPE_*)
1289 ///     - whether the texture is multisampled
1290 ///     - backend specific bindslots:
1291 ///         - HLSL: the texture register `register(t0..23)`
1292 ///         - MSL: the texture attribute `[[texture(0..15)]]`
1293 ///         - WGSL: the binding in `@group(1) @binding(0..127)`
1294 /// 
1295 /// - reflection information for each sampler used by the shader:
1296 ///     - the shader stage the sampler appears in (SG_SHADERSTAGE_*)
1297 ///     - the sampler type (SG_SAMPLERTYPE_*)
1298 ///     - backend specific bindslots:
1299 ///         - HLSL: the sampler register `register(s0..15)`
1300 ///         - MSL: the sampler attribute `[[sampler(0..15)]]`
1301 ///         - WGSL: the binding in `@group(0) @binding(0..127)`
1302 /// 
1303 /// - reflection information for each storage buffer used by the shader:
1304 ///     - the shader stage the storage buffer appears in (SG_SHADERSTAGE_*)
1305 ///     - whether the storage buffer is readonly (currently this must
1306 ///       always be true)
1307 ///     - backend specific bindslots:
1308 ///         - HLSL: the texture(sic) register `register(t0..23)`
1309 ///         - MSL: the buffer attribute `[[buffer(8..15)]]`
1310 ///         - WGSL: the binding in `@group(1) @binding(0..127)`
1311 ///         - GL: the binding in `layout(binding=0..16)`
1312 /// 
1313 /// - reflection information for each combined image-sampler object
1314 ///   used by the shader:
1315 ///     - the shader stage (SG_SHADERSTAGE_*)
1316 ///     - the texture's array index in the sg_shader_desc.images[] array
1317 ///     - the sampler's array index in the sg_shader_desc.samplers[] array
1318 ///     - GLSL only: the name of the combined image-sampler object
1319 /// 
1320 /// The number and order of items in the sg_shader_desc.attrs[]
1321 /// array corresponds to the items in sg_pipeline_desc.layout.attrs.
1322 /// 
1323 ///     - sg_shader_desc.attrs[N] => sg_pipeline_desc.layout.attrs[N]
1324 /// 
1325 /// NOTE that vertex attribute indices currently cannot have gaps.
1326 /// 
1327 /// The items index in the sg_shader_desc.uniform_blocks[] array corresponds
1328 /// to the ub_slot arg in sg_apply_uniforms():
1329 /// 
1330 ///     - sg_shader_desc.uniform_blocks[N] => sg_apply_uniforms(N, ...)
1331 /// 
1332 /// The items in the shader_desc images, samplers and storage_buffers
1333 /// arrays correspond to the same array items in the sg_bindings struct:
1334 /// 
1335 ///     - sg_shader_desc.images[N] => sg_bindings.images[N]
1336 ///     - sg_shader_desc.samplers[N] => sg_bindings.samplers[N]
1337 ///     - sg_shader_desc.storage_buffers[N] => sg_bindings.storage_buffers[N]
1338 /// 
1339 /// For all GL backends, shader source-code must be provided. For D3D11 and Metal,
1340 /// either shader source-code or byte-code can be provided.
1341 /// 
1342 /// NOTE that the uniform block, image, sampler and storage_buffer arrays
1343 /// can have gaps. This allows to use the same sg_bindings struct for
1344 /// different related shader variants.
1345 /// 
1346 /// For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded
1347 /// on demand. If this fails, shader creation will fail. When compiling HLSL
1348 /// source code, you can provide an optional target string via
1349 /// sg_shader_stage_desc.d3d11_target, the default target is "vs_4_0" for the
1350 /// vertex shader stage and "ps_4_0" for the pixel shader stage
1351 enum ShaderStage {
1352     None,
1353     Vertex,
1354     Fragment,
1355 }
1356 extern(C)
1357 struct ShaderFunction {
1358     const(char)* source = null;
1359     Range bytecode;
1360     const(char)* entry = null;
1361     const(char)* d3d11_target = null;
1362 }
1363 extern(C)
1364 struct ShaderVertexAttr {
1365     const(char)* glsl_name = null;
1366     const(char)* hlsl_sem_name = null;
1367     ubyte hlsl_sem_index = 0;
1368 }
1369 extern(C)
1370 struct GlslShaderUniform {
1371     UniformType type;
1372     ushort array_count = 0;
1373     const(char)* glsl_name = null;
1374 }
1375 extern(C)
1376 struct ShaderUniformBlock {
1377     ShaderStage stage;
1378     uint size = 0;
1379     ubyte hlsl_register_b_n = 0;
1380     ubyte msl_buffer_n = 0;
1381     ubyte wgsl_group0_binding_n = 0;
1382     UniformLayout layout;
1383     GlslShaderUniform[16] glsl_uniforms;
1384 }
1385 extern(C)
1386 struct ShaderImage {
1387     ShaderStage stage;
1388     ImageType image_type;
1389     ImageSampleType sample_type;
1390     bool multisampled = false;
1391     ubyte hlsl_register_t_n = 0;
1392     ubyte msl_texture_n = 0;
1393     ubyte wgsl_group1_binding_n = 0;
1394 }
1395 extern(C)
1396 struct ShaderSampler {
1397     ShaderStage stage;
1398     SamplerType sampler_type;
1399     ubyte hlsl_register_s_n = 0;
1400     ubyte msl_sampler_n = 0;
1401     ubyte wgsl_group1_binding_n = 0;
1402 }
1403 extern(C)
1404 struct ShaderStorageBuffer {
1405     ShaderStage stage;
1406     bool readonly = false;
1407     ubyte hlsl_register_t_n = 0;
1408     ubyte msl_buffer_n = 0;
1409     ubyte wgsl_group1_binding_n = 0;
1410     ubyte glsl_binding_n = 0;
1411 }
1412 extern(C)
1413 struct ShaderImageSamplerPair {
1414     ShaderStage stage;
1415     ubyte image_slot = 0;
1416     ubyte sampler_slot = 0;
1417     const(char)* glsl_name = null;
1418 }
1419 extern(C)
1420 struct ShaderDesc {
1421     uint _start_canary = 0;
1422     ShaderFunction vertex_func;
1423     ShaderFunction fragment_func;
1424     ShaderVertexAttr[16] attrs;
1425     ShaderUniformBlock[8] uniform_blocks;
1426     ShaderStorageBuffer[8] storage_buffers;
1427     ShaderImage[16] images;
1428     ShaderSampler[16] samplers;
1429     ShaderImageSamplerPair[16] image_sampler_pairs;
1430     const(char)* label = null;
1431     uint _end_canary = 0;
1432 }
1433 /// sg_pipeline_desc
1434 /// 
1435 /// The sg_pipeline_desc struct defines all creation parameters for an
1436 /// sg_pipeline object, used as argument to the sg_make_pipeline() function:
1437 /// 
1438 /// - the vertex layout for all input vertex buffers
1439 /// - a shader object
1440 /// - the 3D primitive type (points, lines, triangles, ...)
1441 /// - the index type (none, 16- or 32-bit)
1442 /// - all the fixed-function-pipeline state (depth-, stencil-, blend-state, etc...)
1443 /// 
1444 /// If the vertex data has no gaps between vertex components, you can omit
1445 /// the .layout.buffers[].stride and layout.attrs[].offset items (leave them
1446 /// default-initialized to 0), sokol-gfx will then compute the offsets and
1447 /// strides from the vertex component formats (.layout.attrs[].format).
1448 /// Please note that ALL vertex attribute offsets must be 0 in order for the
1449 /// automatic offset computation to kick in.
1450 /// 
1451 /// The default configuration is as follows:
1452 /// 
1453 /// .shader:                0 (must be initialized with a valid sg_shader id!)
1454 /// .layout:
1455 ///     .buffers[]:         vertex buffer layouts
1456 ///         .stride:        0 (if no stride is given it will be computed)
1457 ///         .step_func      SG_VERTEXSTEP_PER_VERTEX
1458 ///         .step_rate      1
1459 ///     .attrs[]:           vertex attribute declarations
1460 ///         .buffer_index   0 the vertex buffer bind slot
1461 ///         .offset         0 (offsets can be omitted if the vertex layout has no gaps)
1462 ///         .format         SG_VERTEXFORMAT_INVALID (must be initialized!)
1463 /// .depth:
1464 ///     .pixel_format:      sg_desc.context.depth_format
1465 ///     .compare:           SG_COMPAREFUNC_ALWAYS
1466 ///     .write_enabled:     false
1467 ///     .bias:              0.0f
1468 ///     .bias_slope_scale:  0.0f
1469 ///     .bias_clamp:        0.0f
1470 /// .stencil:
1471 ///     .enabled:           false
1472 ///     .front/back:
1473 ///         .compare:       SG_COMPAREFUNC_ALWAYS
1474 ///         .fail_op:       SG_STENCILOP_KEEP
1475 ///         .depth_fail_op: SG_STENCILOP_KEEP
1476 ///         .pass_op:       SG_STENCILOP_KEEP
1477 ///     .read_mask:         0
1478 ///     .write_mask:        0
1479 ///     .ref:               0
1480 /// .color_count            1
1481 /// .colors[0..color_count]
1482 ///     .pixel_format       sg_desc.context.color_format
1483 ///     .write_mask:        SG_COLORMASK_RGBA
1484 ///     .blend:
1485 ///         .enabled:           false
1486 ///         .src_factor_rgb:    SG_BLENDFACTOR_ONE
1487 ///         .dst_factor_rgb:    SG_BLENDFACTOR_ZERO
1488 ///         .op_rgb:            SG_BLENDOP_ADD
1489 ///         .src_factor_alpha:  SG_BLENDFACTOR_ONE
1490 ///         .dst_factor_alpha:  SG_BLENDFACTOR_ZERO
1491 ///         .op_alpha:          SG_BLENDOP_ADD
1492 /// .primitive_type:            SG_PRIMITIVETYPE_TRIANGLES
1493 /// .index_type:                SG_INDEXTYPE_NONE
1494 /// .cull_mode:                 SG_CULLMODE_NONE
1495 /// .face_winding:              SG_FACEWINDING_CW
1496 /// .sample_count:              sg_desc.context.sample_count
1497 /// .blend_color:               (sg_color) { 0.0f, 0.0f, 0.0f, 0.0f }
1498 /// .alpha_to_coverage_enabled: false
1499 /// .label  0       (optional string label for trace hooks
1500 extern(C)
1501 struct VertexBufferLayoutState {
1502     int stride = 0;
1503     VertexStep step_func;
1504     int step_rate = 0;
1505 }
1506 extern(C)
1507 struct VertexAttrState {
1508     int buffer_index = 0;
1509     int offset = 0;
1510     VertexFormat format;
1511 }
1512 extern(C)
1513 struct VertexLayoutState {
1514     VertexBufferLayoutState[8] buffers;
1515     VertexAttrState[16] attrs;
1516 }
1517 extern(C)
1518 struct StencilFaceState {
1519     CompareFunc compare;
1520     StencilOp fail_op;
1521     StencilOp depth_fail_op;
1522     StencilOp pass_op;
1523 }
1524 extern(C)
1525 struct StencilState {
1526     bool enabled = false;
1527     StencilFaceState front;
1528     StencilFaceState back;
1529     ubyte read_mask = 0;
1530     ubyte write_mask = 0;
1531     ubyte _ref = 0;
1532 }
1533 extern(C)
1534 struct DepthState {
1535     PixelFormat pixel_format;
1536     CompareFunc compare;
1537     bool write_enabled = false;
1538     float bias = 0.0f;
1539     float bias_slope_scale = 0.0f;
1540     float bias_clamp = 0.0f;
1541 }
1542 extern(C)
1543 struct BlendState {
1544     bool enabled = false;
1545     BlendFactor src_factor_rgb;
1546     BlendFactor dst_factor_rgb;
1547     BlendOp op_rgb;
1548     BlendFactor src_factor_alpha;
1549     BlendFactor dst_factor_alpha;
1550     BlendOp op_alpha;
1551 }
1552 extern(C)
1553 struct ColorTargetState {
1554     PixelFormat pixel_format;
1555     ColorMask write_mask;
1556     BlendState blend;
1557 }
1558 extern(C)
1559 struct PipelineDesc {
1560     uint _start_canary = 0;
1561     Shader shader;
1562     VertexLayoutState layout;
1563     DepthState depth;
1564     StencilState stencil;
1565     int color_count = 0;
1566     ColorTargetState[4] colors;
1567     PrimitiveType primitive_type;
1568     IndexType index_type;
1569     CullMode cull_mode;
1570     FaceWinding face_winding;
1571     int sample_count = 0;
1572     Color blend_color;
1573     bool alpha_to_coverage_enabled = false;
1574     const(char)* label = null;
1575     uint _end_canary = 0;
1576 }
1577 /// sg_attachments_desc
1578 /// 
1579 /// Creation parameters for an sg_attachments object, used as argument to the
1580 /// sg_make_attachments() function.
1581 /// 
1582 /// An attachments object bundles 0..4 color attachments, 0..4 msaa-resolve
1583 /// attachments, and none or one depth-stencil attachmente for use
1584 /// in a render pass. At least one color attachment or one depth-stencil
1585 /// attachment must be provided (no color attachment and a depth-stencil
1586 /// attachment is useful for a depth-only render pass).
1587 /// 
1588 /// Each attachment definition consists of an image object, and two additional indices
1589 /// describing which subimage the pass will render into: one mipmap index, and if the image
1590 /// is a cubemap, array-texture or 3D-texture, the face-index, array-layer or
1591 /// depth-slice.
1592 /// 
1593 /// All attachments must have the same width and height.
1594 /// 
1595 /// All color attachments and the depth-stencil attachment must have the
1596 /// same sample count.
1597 /// 
1598 /// If a resolve attachment is set, an MSAA-resolve operation from the
1599 /// associated color attachment image into the resolve attachment image will take
1600 /// place in the sg_end_pass() function. In this case, the color attachment
1601 /// must have a (sample_count>1), and the resolve attachment a
1602 /// (sample_count==1). The resolve attachment also must have the same pixel
1603 /// format as the color attachment.
1604 /// 
1605 /// NOTE that MSAA depth-stencil attachments cannot be msaa-resolved
1606 extern(C)
1607 struct AttachmentDesc {
1608     Image image;
1609     int mip_level = 0;
1610     int slice = 0;
1611 }
1612 extern(C)
1613 struct AttachmentsDesc {
1614     uint _start_canary = 0;
1615     AttachmentDesc[4] colors;
1616     AttachmentDesc[4] resolves;
1617     AttachmentDesc depth_stencil;
1618     const(char)* label = null;
1619     uint _end_canary = 0;
1620 }
1621 /// sg_trace_hooks
1622 /// 
1623 /// Installable callback functions to keep track of the sokol-gfx calls,
1624 /// this is useful for debugging, or keeping track of resource creation
1625 /// and destruction.
1626 /// 
1627 /// Trace hooks are installed with sg_install_trace_hooks(), this returns
1628 /// another sg_trace_hooks struct with the previous set of
1629 /// trace hook function pointers. These should be invoked by the
1630 /// new trace hooks to form a proper call chain
1631 extern(C)
1632 struct TraceHooks {
1633     void* user_data = null;
1634     extern(C) void function(void*) reset_state_cache = null;
1635     extern(C) void function(const BufferDesc *, Buffer, void*) make_buffer = null;
1636     extern(C) void function(const ImageDesc *, Image, void*) make_image = null;
1637     extern(C) void function(const SamplerDesc *, Sampler, void*) make_sampler = null;
1638     extern(C) void function(const ShaderDesc *, Shader, void*) make_shader = null;
1639     extern(C) void function(const PipelineDesc *, Pipeline, void*) make_pipeline = null;
1640     extern(C) void function(const AttachmentsDesc *, Attachments, void*) make_attachments = null;
1641     extern(C) void function(Buffer, void*) destroy_buffer = null;
1642     extern(C) void function(Image, void*) destroy_image = null;
1643     extern(C) void function(Sampler, void*) destroy_sampler = null;
1644     extern(C) void function(Shader, void*) destroy_shader = null;
1645     extern(C) void function(Pipeline, void*) destroy_pipeline = null;
1646     extern(C) void function(Attachments, void*) destroy_attachments = null;
1647     extern(C) void function(Buffer, const Range *, void*) update_buffer = null;
1648     extern(C) void function(Image, const ImageData *, void*) update_image = null;
1649     extern(C) void function(Buffer, const Range *, int, void*) append_buffer = null;
1650     extern(C) void function(const Pass *, void*) begin_pass = null;
1651     extern(C) void function(int, int, int, int, bool, void*) apply_viewport = null;
1652     extern(C) void function(int, int, int, int, bool, void*) apply_scissor_rect = null;
1653     extern(C) void function(Pipeline, void*) apply_pipeline = null;
1654     extern(C) void function(const Bindings *, void*) apply_bindings = null;
1655     extern(C) void function(int, const Range *, void*) apply_uniforms = null;
1656     extern(C) void function(int, int, int, void*) draw = null;
1657     extern(C) void function(void*) end_pass = null;
1658     extern(C) void function(void*) commit = null;
1659     extern(C) void function(Buffer, void*) alloc_buffer = null;
1660     extern(C) void function(Image, void*) alloc_image = null;
1661     extern(C) void function(Sampler, void*) alloc_sampler = null;
1662     extern(C) void function(Shader, void*) alloc_shader = null;
1663     extern(C) void function(Pipeline, void*) alloc_pipeline = null;
1664     extern(C) void function(Attachments, void*) alloc_attachments = null;
1665     extern(C) void function(Buffer, void*) dealloc_buffer = null;
1666     extern(C) void function(Image, void*) dealloc_image = null;
1667     extern(C) void function(Sampler, void*) dealloc_sampler = null;
1668     extern(C) void function(Shader, void*) dealloc_shader = null;
1669     extern(C) void function(Pipeline, void*) dealloc_pipeline = null;
1670     extern(C) void function(Attachments, void*) dealloc_attachments = null;
1671     extern(C) void function(Buffer, const BufferDesc *, void*) init_buffer = null;
1672     extern(C) void function(Image, const ImageDesc *, void*) init_image = null;
1673     extern(C) void function(Sampler, const SamplerDesc *, void*) init_sampler = null;
1674     extern(C) void function(Shader, const ShaderDesc *, void*) init_shader = null;
1675     extern(C) void function(Pipeline, const PipelineDesc *, void*) init_pipeline = null;
1676     extern(C) void function(Attachments, const AttachmentsDesc *, void*) init_attachments = null;
1677     extern(C) void function(Buffer, void*) uninit_buffer = null;
1678     extern(C) void function(Image, void*) uninit_image = null;
1679     extern(C) void function(Sampler, void*) uninit_sampler = null;
1680     extern(C) void function(Shader, void*) uninit_shader = null;
1681     extern(C) void function(Pipeline, void*) uninit_pipeline = null;
1682     extern(C) void function(Attachments, void*) uninit_attachments = null;
1683     extern(C) void function(Buffer, void*) fail_buffer = null;
1684     extern(C) void function(Image, void*) fail_image = null;
1685     extern(C) void function(Sampler, void*) fail_sampler = null;
1686     extern(C) void function(Shader, void*) fail_shader = null;
1687     extern(C) void function(Pipeline, void*) fail_pipeline = null;
1688     extern(C) void function(Attachments, void*) fail_attachments = null;
1689     extern(C) void function(const(char)*, void*) push_debug_group = null;
1690     extern(C) void function(void*) pop_debug_group = null;
1691 }
1692 /// sg_buffer_info
1693 /// sg_image_info
1694 /// sg_sampler_info
1695 /// sg_shader_info
1696 /// sg_pipeline_info
1697 /// sg_attachments_info
1698 /// 
1699 /// These structs contain various internal resource attributes which
1700 /// might be useful for debug-inspection. Please don't rely on the
1701 /// actual content of those structs too much, as they are quite closely
1702 /// tied to sokol_gfx.h internals and may change more frequently than
1703 /// the other public API elements.
1704 /// 
1705 /// The *_info structs are used as the return values of the following functions:
1706 /// 
1707 /// sg_query_buffer_info()
1708 /// sg_query_image_info()
1709 /// sg_query_sampler_info()
1710 /// sg_query_shader_info()
1711 /// sg_query_pipeline_info()
1712 /// sg_query_pass_info(
1713 extern(C)
1714 struct SlotInfo {
1715     ResourceState state;
1716     uint res_id = 0;
1717 }
1718 extern(C)
1719 struct BufferInfo {
1720     SlotInfo slot;
1721     uint update_frame_index = 0;
1722     uint append_frame_index = 0;
1723     int append_pos = 0;
1724     bool append_overflow = false;
1725     int num_slots = 0;
1726     int active_slot = 0;
1727 }
1728 extern(C)
1729 struct ImageInfo {
1730     SlotInfo slot;
1731     uint upd_frame_index = 0;
1732     int num_slots = 0;
1733     int active_slot = 0;
1734 }
1735 extern(C)
1736 struct SamplerInfo {
1737     SlotInfo slot;
1738 }
1739 extern(C)
1740 struct ShaderInfo {
1741     SlotInfo slot;
1742 }
1743 extern(C)
1744 struct PipelineInfo {
1745     SlotInfo slot;
1746 }
1747 extern(C)
1748 struct AttachmentsInfo {
1749     SlotInfo slot;
1750 }
1751 /// sg_frame_stats
1752 /// 
1753 /// Allows to track generic and backend-specific stats about a
1754 /// render frame. Obtained by calling sg_query_frame_stats(). The returned
1755 /// struct contains information about the *previous* frame
1756 extern(C)
1757 struct FrameStatsGl {
1758     uint num_bind_buffer = 0;
1759     uint num_active_texture = 0;
1760     uint num_bind_texture = 0;
1761     uint num_bind_sampler = 0;
1762     uint num_use_program = 0;
1763     uint num_render_state = 0;
1764     uint num_vertex_attrib_pointer = 0;
1765     uint num_vertex_attrib_divisor = 0;
1766     uint num_enable_vertex_attrib_array = 0;
1767     uint num_disable_vertex_attrib_array = 0;
1768     uint num_uniform = 0;
1769 }
1770 extern(C)
1771 struct FrameStatsD3d11Pass {
1772     uint num_om_set_render_targets = 0;
1773     uint num_clear_render_target_view = 0;
1774     uint num_clear_depth_stencil_view = 0;
1775     uint num_resolve_subresource = 0;
1776 }
1777 extern(C)
1778 struct FrameStatsD3d11Pipeline {
1779     uint num_rs_set_state = 0;
1780     uint num_om_set_depth_stencil_state = 0;
1781     uint num_om_set_blend_state = 0;
1782     uint num_ia_set_primitive_topology = 0;
1783     uint num_ia_set_input_layout = 0;
1784     uint num_vs_set_shader = 0;
1785     uint num_vs_set_constant_buffers = 0;
1786     uint num_ps_set_shader = 0;
1787     uint num_ps_set_constant_buffers = 0;
1788 }
1789 extern(C)
1790 struct FrameStatsD3d11Bindings {
1791     uint num_ia_set_vertex_buffers = 0;
1792     uint num_ia_set_index_buffer = 0;
1793     uint num_vs_set_shader_resources = 0;
1794     uint num_ps_set_shader_resources = 0;
1795     uint num_vs_set_samplers = 0;
1796     uint num_ps_set_samplers = 0;
1797 }
1798 extern(C)
1799 struct FrameStatsD3d11Uniforms {
1800     uint num_update_subresource = 0;
1801 }
1802 extern(C)
1803 struct FrameStatsD3d11Draw {
1804     uint num_draw_indexed_instanced = 0;
1805     uint num_draw_indexed = 0;
1806     uint num_draw_instanced = 0;
1807     uint num_draw = 0;
1808 }
1809 extern(C)
1810 struct FrameStatsD3d11 {
1811     FrameStatsD3d11Pass pass;
1812     FrameStatsD3d11Pipeline pipeline;
1813     FrameStatsD3d11Bindings bindings;
1814     FrameStatsD3d11Uniforms uniforms;
1815     FrameStatsD3d11Draw draw;
1816     uint num_map = 0;
1817     uint num_unmap = 0;
1818 }
1819 extern(C)
1820 struct FrameStatsMetalIdpool {
1821     uint num_added = 0;
1822     uint num_released = 0;
1823     uint num_garbage_collected = 0;
1824 }
1825 extern(C)
1826 struct FrameStatsMetalPipeline {
1827     uint num_set_blend_color = 0;
1828     uint num_set_cull_mode = 0;
1829     uint num_set_front_facing_winding = 0;
1830     uint num_set_stencil_reference_value = 0;
1831     uint num_set_depth_bias = 0;
1832     uint num_set_render_pipeline_state = 0;
1833     uint num_set_depth_stencil_state = 0;
1834 }
1835 extern(C)
1836 struct FrameStatsMetalBindings {
1837     uint num_set_vertex_buffer = 0;
1838     uint num_set_vertex_texture = 0;
1839     uint num_set_vertex_sampler_state = 0;
1840     uint num_set_fragment_buffer = 0;
1841     uint num_set_fragment_texture = 0;
1842     uint num_set_fragment_sampler_state = 0;
1843 }
1844 extern(C)
1845 struct FrameStatsMetalUniforms {
1846     uint num_set_vertex_buffer_offset = 0;
1847     uint num_set_fragment_buffer_offset = 0;
1848 }
1849 extern(C)
1850 struct FrameStatsMetal {
1851     FrameStatsMetalIdpool idpool;
1852     FrameStatsMetalPipeline pipeline;
1853     FrameStatsMetalBindings bindings;
1854     FrameStatsMetalUniforms uniforms;
1855 }
1856 extern(C)
1857 struct FrameStatsWgpuUniforms {
1858     uint num_set_bindgroup = 0;
1859     uint size_write_buffer = 0;
1860 }
1861 extern(C)
1862 struct FrameStatsWgpuBindings {
1863     uint num_set_vertex_buffer = 0;
1864     uint num_skip_redundant_vertex_buffer = 0;
1865     uint num_set_index_buffer = 0;
1866     uint num_skip_redundant_index_buffer = 0;
1867     uint num_create_bindgroup = 0;
1868     uint num_discard_bindgroup = 0;
1869     uint num_set_bindgroup = 0;
1870     uint num_skip_redundant_bindgroup = 0;
1871     uint num_bindgroup_cache_hits = 0;
1872     uint num_bindgroup_cache_misses = 0;
1873     uint num_bindgroup_cache_collisions = 0;
1874     uint num_bindgroup_cache_invalidates = 0;
1875     uint num_bindgroup_cache_hash_vs_key_mismatch = 0;
1876 }
1877 extern(C)
1878 struct FrameStatsWgpu {
1879     FrameStatsWgpuUniforms uniforms;
1880     FrameStatsWgpuBindings bindings;
1881 }
1882 extern(C)
1883 struct FrameStats {
1884     uint frame_index = 0;
1885     uint num_passes = 0;
1886     uint num_apply_viewport = 0;
1887     uint num_apply_scissor_rect = 0;
1888     uint num_apply_pipeline = 0;
1889     uint num_apply_bindings = 0;
1890     uint num_apply_uniforms = 0;
1891     uint num_draw = 0;
1892     uint num_update_buffer = 0;
1893     uint num_append_buffer = 0;
1894     uint num_update_image = 0;
1895     uint size_apply_uniforms = 0;
1896     uint size_update_buffer = 0;
1897     uint size_append_buffer = 0;
1898     uint size_update_image = 0;
1899     FrameStatsGl gl;
1900     FrameStatsD3d11 d3d11;
1901     FrameStatsMetal metal;
1902     FrameStatsWgpu wgpu;
1903 }
1904 enum LogItem {
1905     Ok,
1906     Malloc_failed,
1907     Gl_texture_format_not_supported,
1908     Gl_3d_textures_not_supported,
1909     Gl_array_textures_not_supported,
1910     Gl_shader_compilation_failed,
1911     Gl_shader_linking_failed,
1912     Gl_vertex_attribute_not_found_in_shader,
1913     Gl_uniformblock_name_not_found_in_shader,
1914     Gl_image_sampler_name_not_found_in_shader,
1915     Gl_framebuffer_status_undefined,
1916     Gl_framebuffer_status_incomplete_attachment,
1917     Gl_framebuffer_status_incomplete_missing_attachment,
1918     Gl_framebuffer_status_unsupported,
1919     Gl_framebuffer_status_incomplete_multisample,
1920     Gl_framebuffer_status_unknown,
1921     D3d11_create_buffer_failed,
1922     D3d11_create_buffer_srv_failed,
1923     D3d11_create_depth_texture_unsupported_pixel_format,
1924     D3d11_create_depth_texture_failed,
1925     D3d11_create_2d_texture_unsupported_pixel_format,
1926     D3d11_create_2d_texture_failed,
1927     D3d11_create_2d_srv_failed,
1928     D3d11_create_3d_texture_unsupported_pixel_format,
1929     D3d11_create_3d_texture_failed,
1930     D3d11_create_3d_srv_failed,
1931     D3d11_create_msaa_texture_failed,
1932     D3d11_create_sampler_state_failed,
1933     D3d11_load_d3dcompiler_47_dll_failed,
1934     D3d11_shader_compilation_failed,
1935     D3d11_shader_compilation_output,
1936     D3d11_create_constant_buffer_failed,
1937     D3d11_create_input_layout_failed,
1938     D3d11_create_rasterizer_state_failed,
1939     D3d11_create_depth_stencil_state_failed,
1940     D3d11_create_blend_state_failed,
1941     D3d11_create_rtv_failed,
1942     D3d11_create_dsv_failed,
1943     D3d11_map_for_update_buffer_failed,
1944     D3d11_map_for_append_buffer_failed,
1945     D3d11_map_for_update_image_failed,
1946     Metal_create_buffer_failed,
1947     Metal_texture_format_not_supported,
1948     Metal_create_texture_failed,
1949     Metal_create_sampler_failed,
1950     Metal_shader_compilation_failed,
1951     Metal_shader_creation_failed,
1952     Metal_shader_compilation_output,
1953     Metal_shader_entry_not_found,
1954     Metal_create_rps_failed,
1955     Metal_create_rps_output,
1956     Metal_create_dss_failed,
1957     Wgpu_bindgroups_pool_exhausted,
1958     Wgpu_bindgroupscache_size_greater_one,
1959     Wgpu_bindgroupscache_size_pow2,
1960     Wgpu_createbindgroup_failed,
1961     Wgpu_create_buffer_failed,
1962     Wgpu_create_texture_failed,
1963     Wgpu_create_texture_view_failed,
1964     Wgpu_create_sampler_failed,
1965     Wgpu_create_shader_module_failed,
1966     Wgpu_shader_create_bindgroup_layout_failed,
1967     Wgpu_create_pipeline_layout_failed,
1968     Wgpu_create_render_pipeline_failed,
1969     Wgpu_attachments_create_texture_view_failed,
1970     Draw_required_bindings_or_uniforms_missing,
1971     Identical_commit_listener,
1972     Commit_listener_array_full,
1973     Trace_hooks_not_enabled,
1974     Dealloc_buffer_invalid_state,
1975     Dealloc_image_invalid_state,
1976     Dealloc_sampler_invalid_state,
1977     Dealloc_shader_invalid_state,
1978     Dealloc_pipeline_invalid_state,
1979     Dealloc_attachments_invalid_state,
1980     Init_buffer_invalid_state,
1981     Init_image_invalid_state,
1982     Init_sampler_invalid_state,
1983     Init_shader_invalid_state,
1984     Init_pipeline_invalid_state,
1985     Init_attachments_invalid_state,
1986     Uninit_buffer_invalid_state,
1987     Uninit_image_invalid_state,
1988     Uninit_sampler_invalid_state,
1989     Uninit_shader_invalid_state,
1990     Uninit_pipeline_invalid_state,
1991     Uninit_attachments_invalid_state,
1992     Fail_buffer_invalid_state,
1993     Fail_image_invalid_state,
1994     Fail_sampler_invalid_state,
1995     Fail_shader_invalid_state,
1996     Fail_pipeline_invalid_state,
1997     Fail_attachments_invalid_state,
1998     Buffer_pool_exhausted,
1999     Image_pool_exhausted,
2000     Sampler_pool_exhausted,
2001     Shader_pool_exhausted,
2002     Pipeline_pool_exhausted,
2003     Pass_pool_exhausted,
2004     Beginpass_attachment_invalid,
2005     Draw_without_bindings,
2006     Validate_bufferdesc_canary,
2007     Validate_bufferdesc_size,
2008     Validate_bufferdesc_data,
2009     Validate_bufferdesc_data_size,
2010     Validate_bufferdesc_no_data,
2011     Validate_bufferdesc_storagebuffer_supported,
2012     Validate_bufferdesc_storagebuffer_size_multiple_4,
2013     Validate_imagedata_nodata,
2014     Validate_imagedata_data_size,
2015     Validate_imagedesc_canary,
2016     Validate_imagedesc_width,
2017     Validate_imagedesc_height,
2018     Validate_imagedesc_rt_pixelformat,
2019     Validate_imagedesc_nonrt_pixelformat,
2020     Validate_imagedesc_msaa_but_no_rt,
2021     Validate_imagedesc_no_msaa_rt_support,
2022     Validate_imagedesc_msaa_num_mipmaps,
2023     Validate_imagedesc_msaa_3d_image,
2024     Validate_imagedesc_msaa_cube_image,
2025     Validate_imagedesc_depth_3d_image,
2026     Validate_imagedesc_rt_immutable,
2027     Validate_imagedesc_rt_no_data,
2028     Validate_imagedesc_injected_no_data,
2029     Validate_imagedesc_dynamic_no_data,
2030     Validate_imagedesc_compressed_immutable,
2031     Validate_samplerdesc_canary,
2032     Validate_samplerdesc_anistropic_requires_linear_filtering,
2033     Validate_shaderdesc_canary,
2034     Validate_shaderdesc_source,
2035     Validate_shaderdesc_bytecode,
2036     Validate_shaderdesc_source_or_bytecode,
2037     Validate_shaderdesc_no_bytecode_size,
2038     Validate_shaderdesc_no_cont_ub_members,
2039     Validate_shaderdesc_ub_size_is_zero,
2040     Validate_shaderdesc_ub_metal_buffer_slot_out_of_range,
2041     Validate_shaderdesc_ub_metal_buffer_slot_collision,
2042     Validate_shaderdesc_ub_hlsl_register_b_out_of_range,
2043     Validate_shaderdesc_ub_hlsl_register_b_collision,
2044     Validate_shaderdesc_ub_wgsl_group0_binding_out_of_range,
2045     Validate_shaderdesc_ub_wgsl_group0_binding_collision,
2046     Validate_shaderdesc_no_ub_members,
2047     Validate_shaderdesc_ub_uniform_glsl_name,
2048     Validate_shaderdesc_ub_size_mismatch,
2049     Validate_shaderdesc_ub_array_count,
2050     Validate_shaderdesc_ub_std140_array_type,
2051     Validate_shaderdesc_storagebuffer_metal_buffer_slot_out_of_range,
2052     Validate_shaderdesc_storagebuffer_metal_buffer_slot_collision,
2053     Validate_shaderdesc_storagebuffer_hlsl_register_t_out_of_range,
2054     Validate_shaderdesc_storagebuffer_hlsl_register_t_collision,
2055     Validate_shaderdesc_storagebuffer_glsl_binding_out_of_range,
2056     Validate_shaderdesc_storagebuffer_glsl_binding_collision,
2057     Validate_shaderdesc_storagebuffer_wgsl_group1_binding_out_of_range,
2058     Validate_shaderdesc_storagebuffer_wgsl_group1_binding_collision,
2059     Validate_shaderdesc_storagebuffer_readonly,
2060     Validate_shaderdesc_image_metal_texture_slot_out_of_range,
2061     Validate_shaderdesc_image_metal_texture_slot_collision,
2062     Validate_shaderdesc_image_hlsl_register_t_out_of_range,
2063     Validate_shaderdesc_image_hlsl_register_t_collision,
2064     Validate_shaderdesc_image_wgsl_group1_binding_out_of_range,
2065     Validate_shaderdesc_image_wgsl_group1_binding_collision,
2066     Validate_shaderdesc_sampler_metal_sampler_slot_out_of_range,
2067     Validate_shaderdesc_sampler_metal_sampler_slot_collision,
2068     Validate_shaderdesc_sampler_hlsl_register_s_out_of_range,
2069     Validate_shaderdesc_sampler_hlsl_register_s_collision,
2070     Validate_shaderdesc_sampler_wgsl_group1_binding_out_of_range,
2071     Validate_shaderdesc_sampler_wgsl_group1_binding_collision,
2072     Validate_shaderdesc_image_sampler_pair_image_slot_out_of_range,
2073     Validate_shaderdesc_image_sampler_pair_sampler_slot_out_of_range,
2074     Validate_shaderdesc_image_sampler_pair_image_stage_mismatch,
2075     Validate_shaderdesc_image_sampler_pair_sampler_stage_mismatch,
2076     Validate_shaderdesc_image_sampler_pair_glsl_name,
2077     Validate_shaderdesc_nonfiltering_sampler_required,
2078     Validate_shaderdesc_comparison_sampler_required,
2079     Validate_shaderdesc_image_not_referenced_by_image_sampler_pairs,
2080     Validate_shaderdesc_sampler_not_referenced_by_image_sampler_pairs,
2081     Validate_shaderdesc_attr_string_too_long,
2082     Validate_pipelinedesc_canary,
2083     Validate_pipelinedesc_shader,
2084     Validate_pipelinedesc_no_cont_attrs,
2085     Validate_pipelinedesc_layout_stride4,
2086     Validate_pipelinedesc_attr_semantics,
2087     Validate_attachmentsdesc_canary,
2088     Validate_attachmentsdesc_no_attachments,
2089     Validate_attachmentsdesc_no_cont_color_atts,
2090     Validate_attachmentsdesc_image,
2091     Validate_attachmentsdesc_miplevel,
2092     Validate_attachmentsdesc_face,
2093     Validate_attachmentsdesc_layer,
2094     Validate_attachmentsdesc_slice,
2095     Validate_attachmentsdesc_image_no_rt,
2096     Validate_attachmentsdesc_color_inv_pixelformat,
2097     Validate_attachmentsdesc_depth_inv_pixelformat,
2098     Validate_attachmentsdesc_image_sizes,
2099     Validate_attachmentsdesc_image_sample_counts,
2100     Validate_attachmentsdesc_resolve_color_image_msaa,
2101     Validate_attachmentsdesc_resolve_image,
2102     Validate_attachmentsdesc_resolve_sample_count,
2103     Validate_attachmentsdesc_resolve_miplevel,
2104     Validate_attachmentsdesc_resolve_face,
2105     Validate_attachmentsdesc_resolve_layer,
2106     Validate_attachmentsdesc_resolve_slice,
2107     Validate_attachmentsdesc_resolve_image_no_rt,
2108     Validate_attachmentsdesc_resolve_image_sizes,
2109     Validate_attachmentsdesc_resolve_image_format,
2110     Validate_attachmentsdesc_depth_image,
2111     Validate_attachmentsdesc_depth_miplevel,
2112     Validate_attachmentsdesc_depth_face,
2113     Validate_attachmentsdesc_depth_layer,
2114     Validate_attachmentsdesc_depth_slice,
2115     Validate_attachmentsdesc_depth_image_no_rt,
2116     Validate_attachmentsdesc_depth_image_sizes,
2117     Validate_attachmentsdesc_depth_image_sample_count,
2118     Validate_beginpass_canary,
2119     Validate_beginpass_attachments_exists,
2120     Validate_beginpass_attachments_valid,
2121     Validate_beginpass_color_attachment_image,
2122     Validate_beginpass_resolve_attachment_image,
2123     Validate_beginpass_depthstencil_attachment_image,
2124     Validate_beginpass_swapchain_expect_width,
2125     Validate_beginpass_swapchain_expect_width_notset,
2126     Validate_beginpass_swapchain_expect_height,
2127     Validate_beginpass_swapchain_expect_height_notset,
2128     Validate_beginpass_swapchain_expect_samplecount,
2129     Validate_beginpass_swapchain_expect_samplecount_notset,
2130     Validate_beginpass_swapchain_expect_colorformat,
2131     Validate_beginpass_swapchain_expect_colorformat_notset,
2132     Validate_beginpass_swapchain_expect_depthformat_notset,
2133     Validate_beginpass_swapchain_metal_expect_currentdrawable,
2134     Validate_beginpass_swapchain_metal_expect_currentdrawable_notset,
2135     Validate_beginpass_swapchain_metal_expect_depthstenciltexture,
2136     Validate_beginpass_swapchain_metal_expect_depthstenciltexture_notset,
2137     Validate_beginpass_swapchain_metal_expect_msaacolortexture,
2138     Validate_beginpass_swapchain_metal_expect_msaacolortexture_notset,
2139     Validate_beginpass_swapchain_d3d11_expect_renderview,
2140     Validate_beginpass_swapchain_d3d11_expect_renderview_notset,
2141     Validate_beginpass_swapchain_d3d11_expect_resolveview,
2142     Validate_beginpass_swapchain_d3d11_expect_resolveview_notset,
2143     Validate_beginpass_swapchain_d3d11_expect_depthstencilview,
2144     Validate_beginpass_swapchain_d3d11_expect_depthstencilview_notset,
2145     Validate_beginpass_swapchain_wgpu_expect_renderview,
2146     Validate_beginpass_swapchain_wgpu_expect_renderview_notset,
2147     Validate_beginpass_swapchain_wgpu_expect_resolveview,
2148     Validate_beginpass_swapchain_wgpu_expect_resolveview_notset,
2149     Validate_beginpass_swapchain_wgpu_expect_depthstencilview,
2150     Validate_beginpass_swapchain_wgpu_expect_depthstencilview_notset,
2151     Validate_beginpass_swapchain_gl_expect_framebuffer_notset,
2152     Validate_apip_pipeline_valid_id,
2153     Validate_apip_pipeline_exists,
2154     Validate_apip_pipeline_valid,
2155     Validate_apip_shader_exists,
2156     Validate_apip_shader_valid,
2157     Validate_apip_curpass_attachments_exists,
2158     Validate_apip_curpass_attachments_valid,
2159     Validate_apip_att_count,
2160     Validate_apip_color_format,
2161     Validate_apip_depth_format,
2162     Validate_apip_sample_count,
2163     Validate_abnd_pipeline,
2164     Validate_abnd_pipeline_exists,
2165     Validate_abnd_pipeline_valid,
2166     Validate_abnd_expected_vb,
2167     Validate_abnd_vb_exists,
2168     Validate_abnd_vb_type,
2169     Validate_abnd_vb_overflow,
2170     Validate_abnd_no_ib,
2171     Validate_abnd_ib,
2172     Validate_abnd_ib_exists,
2173     Validate_abnd_ib_type,
2174     Validate_abnd_ib_overflow,
2175     Validate_abnd_expected_image_binding,
2176     Validate_abnd_img_exists,
2177     Validate_abnd_image_type_mismatch,
2178     Validate_abnd_expected_multisampled_image,
2179     Validate_abnd_image_msaa,
2180     Validate_abnd_expected_filterable_image,
2181     Validate_abnd_expected_depth_image,
2182     Validate_abnd_expected_sampler_binding,
2183     Validate_abnd_unexpected_sampler_compare_never,
2184     Validate_abnd_expected_sampler_compare_never,
2185     Validate_abnd_expected_nonfiltering_sampler,
2186     Validate_abnd_smp_exists,
2187     Validate_abnd_expected_storagebuffer_binding,
2188     Validate_abnd_storagebuffer_exists,
2189     Validate_abnd_storagebuffer_binding_buffertype,
2190     Validate_aub_no_pipeline,
2191     Validate_aub_no_ub_at_slot,
2192     Validate_aub_size,
2193     Validate_updatebuf_usage,
2194     Validate_updatebuf_size,
2195     Validate_updatebuf_once,
2196     Validate_updatebuf_append,
2197     Validate_appendbuf_usage,
2198     Validate_appendbuf_size,
2199     Validate_appendbuf_update,
2200     Validate_updimg_usage,
2201     Validate_updimg_once,
2202     Validation_failed,
2203 }
2204 /// sg_desc
2205 /// 
2206 /// The sg_desc struct contains configuration values for sokol_gfx,
2207 /// it is used as parameter to the sg_setup() call.
2208 /// 
2209 /// The default configuration is:
2210 /// 
2211 /// .buffer_pool_size       128
2212 /// .image_pool_size        128
2213 /// .sampler_pool_size      64
2214 /// .shader_pool_size       32
2215 /// .pipeline_pool_size     64
2216 /// .pass_pool_size         16
2217 /// .uniform_buffer_size    4 MB (4*1024*1024)
2218 /// .max_commit_listeners   1024
2219 /// .disable_validation     false
2220 /// .mtl_force_managed_storage_mode false
2221 /// .wgpu_disable_bindgroups_cache  false
2222 /// .wgpu_bindgroups_cache_size     1024
2223 /// 
2224 /// .allocator.alloc_fn     0 (in this case, malloc() will be called)
2225 /// .allocator.free_fn      0 (in this case, free() will be called)
2226 /// .allocator.user_data    0
2227 /// 
2228 /// .environment.defaults.color_format: default value depends on selected backend:
2229 ///     all GL backends:    SG_PIXELFORMAT_RGBA8
2230 ///     Metal and D3D11:    SG_PIXELFORMAT_BGRA8
2231 ///     WebGPU:             *no default* (must be queried from WebGPU swapchain object)
2232 /// .environment.defaults.depth_format: SG_PIXELFORMAT_DEPTH_STENCIL
2233 /// .environment.defaults.sample_count: 1
2234 /// 
2235 /// Metal specific:
2236 ///     (NOTE: All Objective-C object references are transferred through
2237 ///     a bridged cast (__bridge const void*) to sokol_gfx, which will use an
2238 ///     unretained bridged cast (__bridge id<xxx>) to retrieve the Objective-C
2239 ///     references back. Since the bridge cast is unretained, the caller
2240 ///     must hold a strong reference to the Objective-C object until sg_setup()
2241 ///     returns.
2242 /// 
2243 ///     .mtl_force_managed_storage_mode
2244 ///         when enabled, Metal buffers and texture resources are created in managed storage
2245 ///         mode, otherwise sokol-gfx will decide whether to create buffers and
2246 ///         textures in managed or shared storage mode (this is mainly a debugging option)
2247 ///     .mtl_use_command_buffer_with_retained_references
2248 ///         when true, the sokol-gfx Metal backend will use Metal command buffers which
2249 ///         bump the reference count of resource objects as long as they are inflight,
2250 ///         this is slower than the default command-buffer-with-unretained-references
2251 ///         method, this may be a workaround when confronted with lifetime validation
2252 ///         errors from the Metal validation layer until a proper fix has been implemented
2253 ///     .environment.metal.device
2254 ///         a pointer to the MTLDevice object
2255 /// 
2256 /// D3D11 specific:
2257 ///     .environment.d3d11.device
2258 ///         a pointer to the ID3D11Device object, this must have been created
2259 ///         before sg_setup() is called
2260 ///     .environment.d3d11.device_context
2261 ///         a pointer to the ID3D11DeviceContext object
2262 ///     .d3d11_shader_debugging
2263 ///         set this to true to compile shaders which are provided as HLSL source
2264 ///         code with debug information and without optimization, this allows
2265 ///         shader debugging in tools like RenderDoc, to output source code
2266 ///         instead of byte code from sokol-shdc, omit the `--binary` cmdline
2267 ///         option
2268 /// 
2269 /// WebGPU specific:
2270 ///     .wgpu_disable_bindgroups_cache
2271 ///         When this is true, the WebGPU backend will create and immediately
2272 ///         release a BindGroup object in the sg_apply_bindings() call, only
2273 ///         use this for debugging purposes.
2274 ///     .wgpu_bindgroups_cache_size
2275 ///         The size of the bindgroups cache for re-using BindGroup objects
2276 ///         between sg_apply_bindings() calls. The smaller the cache size,
2277 ///         the more likely are cache slot collisions which will cause
2278 ///         a BindGroups object to be destroyed and a new one created.
2279 ///         Use the information returned by sg_query_stats() to check
2280 ///         if this is a frequent occurrence, and increase the cache size as
2281 ///         needed (the default is 1024).
2282 ///         NOTE: wgpu_bindgroups_cache_size must be a power-of-2 number!
2283 ///     .environment.wgpu.device
2284 ///         a WGPUDevice handle
2285 /// 
2286 /// When using sokol_gfx.h and sokol_app.h together, consider using the
2287 /// helper function sglue_environment() in the sokol_glue.h header to
2288 /// initialize the sg_desc.environment nested struct. sglue_environment() returns
2289 /// a completely initialized sg_environment struct with information
2290 /// provided by sokol_app.h
2291 extern(C)
2292 struct EnvironmentDefaults {
2293     PixelFormat color_format;
2294     PixelFormat depth_format;
2295     int sample_count = 0;
2296 }
2297 extern(C)
2298 struct MetalEnvironment {
2299     const(void)* device = null;
2300 }
2301 extern(C)
2302 struct D3d11Environment {
2303     const(void)* device = null;
2304     const(void)* device_context = null;
2305 }
2306 extern(C)
2307 struct WgpuEnvironment {
2308     const(void)* device = null;
2309 }
2310 extern(C)
2311 struct Environment {
2312     EnvironmentDefaults defaults;
2313     MetalEnvironment metal;
2314     D3d11Environment d3d11;
2315     WgpuEnvironment wgpu;
2316 }
2317 /// sg_commit_listener
2318 /// 
2319 /// Used with function sg_add_commit_listener() to add a callback
2320 /// which will be called in sg_commit(). This is useful for libraries
2321 /// building on top of sokol-gfx to be notified about when a frame
2322 /// ends (instead of having to guess, or add a manual 'new-frame'
2323 /// function
2324 extern(C)
2325 struct CommitListener {
2326     extern(C) void function(void*) func = null;
2327     void* user_data = null;
2328 }
2329 /// sg_allocator
2330 /// 
2331 /// Used in sg_desc to provide custom memory-alloc and -free functions
2332 /// to sokol_gfx.h. If memory management should be overridden, both the
2333 /// alloc_fn and free_fn function must be provided (e.g. it's not valid to
2334 /// override one function but not the other)
2335 extern(C)
2336 struct Allocator {
2337     extern(C) void* function(size_t, void*) alloc_fn = null;
2338     extern(C) void function(void*, void*) free_fn = null;
2339     void* user_data = null;
2340 }
2341 /// sg_logger
2342 /// 
2343 /// Used in sg_desc to provide a logging function. Please be aware
2344 /// that without logging function, sokol-gfx will be completely
2345 /// silent, e.g. it will not report errors, warnings and
2346 /// validation layer messages. For maximum error verbosity,
2347 /// compile in debug mode (e.g. NDEBUG *not* defined) and provide a
2348 /// compatible logger function in the sg_setup() call
2349 /// (for instance the standard logging function from sokol_log.h)
2350 extern(C)
2351 struct Logger {
2352     extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null;
2353     void* user_data = null;
2354 }
2355 extern(C)
2356 struct Desc {
2357     uint _start_canary = 0;
2358     int buffer_pool_size = 0;
2359     int image_pool_size = 0;
2360     int sampler_pool_size = 0;
2361     int shader_pool_size = 0;
2362     int pipeline_pool_size = 0;
2363     int attachments_pool_size = 0;
2364     int uniform_buffer_size = 0;
2365     int max_commit_listeners = 0;
2366     bool disable_validation = false;
2367     bool d3d11_shader_debugging = false;
2368     bool mtl_force_managed_storage_mode = false;
2369     bool mtl_use_command_buffer_with_retained_references = false;
2370     bool wgpu_disable_bindgroups_cache = false;
2371     int wgpu_bindgroups_cache_size = 0;
2372     Allocator allocator;
2373     Logger logger;
2374     Environment environment;
2375     uint _end_canary = 0;
2376 }
2377 /// setup and misc function
2378 extern(C) void sg_setup(const Desc *) @system @nogc nothrow;
2379 /// setup and misc function
2380 void setup(scope ref Desc desc) @trusted @nogc nothrow {
2381     sg_setup(&desc);
2382 }
2383 extern(C) void sg_shutdown() @system @nogc nothrow;
2384 void shutdown() @trusted @nogc nothrow {
2385     sg_shutdown();
2386 }
2387 extern(C) bool sg_isvalid() @system @nogc nothrow;
2388 bool isvalid() @trusted @nogc nothrow {
2389     return sg_isvalid();
2390 }
2391 extern(C) void sg_reset_state_cache() @system @nogc nothrow;
2392 void resetStateCache() @trusted @nogc nothrow {
2393     sg_reset_state_cache();
2394 }
2395 extern(C) TraceHooks sg_install_trace_hooks(const TraceHooks *) @system @nogc nothrow;
2396 TraceHooks installTraceHooks(scope ref TraceHooks trace_hooks) @trusted @nogc nothrow {
2397     return sg_install_trace_hooks(&trace_hooks);
2398 }
2399 extern(C) void sg_push_debug_group(const(char)*) @system @nogc nothrow;
2400 void pushDebugGroup(scope const(char)* name) @trusted @nogc nothrow {
2401     sg_push_debug_group(name);
2402 }
2403 extern(C) void sg_pop_debug_group() @system @nogc nothrow;
2404 void popDebugGroup() @trusted @nogc nothrow {
2405     sg_pop_debug_group();
2406 }
2407 extern(C) bool sg_add_commit_listener(CommitListener) @system @nogc nothrow;
2408 bool addCommitListener(CommitListener listener) @trusted @nogc nothrow {
2409     return sg_add_commit_listener(listener);
2410 }
2411 extern(C) bool sg_remove_commit_listener(CommitListener) @system @nogc nothrow;
2412 bool removeCommitListener(CommitListener listener) @trusted @nogc nothrow {
2413     return sg_remove_commit_listener(listener);
2414 }
2415 /// resource creation, destruction and updatin
2416 extern(C) Buffer sg_make_buffer(const BufferDesc *) @system @nogc nothrow;
2417 /// resource creation, destruction and updatin
2418 Buffer makeBuffer(scope ref BufferDesc desc) @trusted @nogc nothrow {
2419     return sg_make_buffer(&desc);
2420 }
2421 extern(C) Image sg_make_image(const ImageDesc *) @system @nogc nothrow;
2422 Image makeImage(scope ref ImageDesc desc) @trusted @nogc nothrow {
2423     return sg_make_image(&desc);
2424 }
2425 extern(C) Sampler sg_make_sampler(const SamplerDesc *) @system @nogc nothrow;
2426 Sampler makeSampler(scope ref SamplerDesc desc) @trusted @nogc nothrow {
2427     return sg_make_sampler(&desc);
2428 }
2429 extern(C) Shader sg_make_shader(const ShaderDesc *) @system @nogc nothrow;
2430 Shader makeShader(scope ref ShaderDesc desc) @trusted @nogc nothrow {
2431     return sg_make_shader(&desc);
2432 }
2433 extern(C) Pipeline sg_make_pipeline(const PipelineDesc *) @system @nogc nothrow;
2434 Pipeline makePipeline(scope ref PipelineDesc desc) @trusted @nogc nothrow {
2435     return sg_make_pipeline(&desc);
2436 }
2437 extern(C) Attachments sg_make_attachments(const AttachmentsDesc *) @system @nogc nothrow;
2438 Attachments makeAttachments(scope ref AttachmentsDesc desc) @trusted @nogc nothrow {
2439     return sg_make_attachments(&desc);
2440 }
2441 extern(C) void sg_destroy_buffer(Buffer) @system @nogc nothrow;
2442 void destroyBuffer(Buffer buf) @trusted @nogc nothrow {
2443     sg_destroy_buffer(buf);
2444 }
2445 extern(C) void sg_destroy_image(Image) @system @nogc nothrow;
2446 void destroyImage(Image img) @trusted @nogc nothrow {
2447     sg_destroy_image(img);
2448 }
2449 extern(C) void sg_destroy_sampler(Sampler) @system @nogc nothrow;
2450 void destroySampler(Sampler smp) @trusted @nogc nothrow {
2451     sg_destroy_sampler(smp);
2452 }
2453 extern(C) void sg_destroy_shader(Shader) @system @nogc nothrow;
2454 void destroyShader(Shader shd) @trusted @nogc nothrow {
2455     sg_destroy_shader(shd);
2456 }
2457 extern(C) void sg_destroy_pipeline(Pipeline) @system @nogc nothrow;
2458 void destroyPipeline(Pipeline pip) @trusted @nogc nothrow {
2459     sg_destroy_pipeline(pip);
2460 }
2461 extern(C) void sg_destroy_attachments(Attachments) @system @nogc nothrow;
2462 void destroyAttachments(Attachments atts) @trusted @nogc nothrow {
2463     sg_destroy_attachments(atts);
2464 }
2465 extern(C) void sg_update_buffer(Buffer, const Range *) @system @nogc nothrow;
2466 void updateBuffer(Buffer buf, scope ref Range data) @trusted @nogc nothrow {
2467     sg_update_buffer(buf, &data);
2468 }
2469 extern(C) void sg_update_image(Image, const ImageData *) @system @nogc nothrow;
2470 void updateImage(Image img, scope ref ImageData data) @trusted @nogc nothrow {
2471     sg_update_image(img, &data);
2472 }
2473 extern(C) int sg_append_buffer(Buffer, const Range *) @system @nogc nothrow;
2474 int appendBuffer(Buffer buf, scope ref Range data) @trusted @nogc nothrow {
2475     return sg_append_buffer(buf, &data);
2476 }
2477 extern(C) bool sg_query_buffer_overflow(Buffer) @system @nogc nothrow;
2478 bool queryBufferOverflow(Buffer buf) @trusted @nogc nothrow {
2479     return sg_query_buffer_overflow(buf);
2480 }
2481 extern(C) bool sg_query_buffer_will_overflow(Buffer, size_t) @system @nogc nothrow;
2482 bool queryBufferWillOverflow(Buffer buf, size_t size) @trusted @nogc nothrow {
2483     return sg_query_buffer_will_overflow(buf, size);
2484 }
2485 /// rendering function
2486 extern(C) void sg_begin_pass(const Pass *) @system @nogc nothrow;
2487 /// rendering function
2488 void beginPass(scope ref Pass pass) @trusted @nogc nothrow {
2489     sg_begin_pass(&pass);
2490 }
2491 extern(C) void sg_apply_viewport(int, int, int, int, bool) @system @nogc nothrow;
2492 void applyViewport(int x, int y, int width, int height, bool origin_top_left) @trusted @nogc nothrow {
2493     sg_apply_viewport(x, y, width, height, origin_top_left);
2494 }
2495 extern(C) void sg_apply_viewportf(float, float, float, float, bool) @system @nogc nothrow;
2496 void applyViewportf(float x, float y, float width, float height, bool origin_top_left) @trusted @nogc nothrow {
2497     sg_apply_viewportf(x, y, width, height, origin_top_left);
2498 }
2499 extern(C) void sg_apply_scissor_rect(int, int, int, int, bool) @system @nogc nothrow;
2500 void applyScissorRect(int x, int y, int width, int height, bool origin_top_left) @trusted @nogc nothrow {
2501     sg_apply_scissor_rect(x, y, width, height, origin_top_left);
2502 }
2503 extern(C) void sg_apply_scissor_rectf(float, float, float, float, bool) @system @nogc nothrow;
2504 void applyScissorRectf(float x, float y, float width, float height, bool origin_top_left) @trusted @nogc nothrow {
2505     sg_apply_scissor_rectf(x, y, width, height, origin_top_left);
2506 }
2507 extern(C) void sg_apply_pipeline(Pipeline) @system @nogc nothrow;
2508 void applyPipeline(Pipeline pip) @trusted @nogc nothrow {
2509     sg_apply_pipeline(pip);
2510 }
2511 extern(C) void sg_apply_bindings(const Bindings *) @system @nogc nothrow;
2512 void applyBindings(scope ref Bindings bindings) @trusted @nogc nothrow {
2513     sg_apply_bindings(&bindings);
2514 }
2515 extern(C) void sg_apply_uniforms(uint, const Range *) @system @nogc nothrow;
2516 void applyUniforms(uint ub_slot, scope ref Range data) @trusted @nogc nothrow {
2517     sg_apply_uniforms(ub_slot, &data);
2518 }
2519 extern(C) void sg_draw(uint, uint, uint) @system @nogc nothrow;
2520 void draw(uint base_element, uint num_elements, uint num_instances) @trusted @nogc nothrow {
2521     sg_draw(base_element, num_elements, num_instances);
2522 }
2523 extern(C) void sg_end_pass() @system @nogc nothrow;
2524 void endPass() @trusted @nogc nothrow {
2525     sg_end_pass();
2526 }
2527 extern(C) void sg_commit() @system @nogc nothrow;
2528 void commit() @trusted @nogc nothrow {
2529     sg_commit();
2530 }
2531 /// getting informatio
2532 extern(C) Desc sg_query_desc() @system @nogc nothrow;
2533 /// getting informatio
2534 Desc queryDesc() @trusted @nogc nothrow {
2535     return sg_query_desc();
2536 }
2537 extern(C) Backend sg_query_backend() @system @nogc nothrow;
2538 Backend queryBackend() @trusted @nogc nothrow {
2539     return sg_query_backend();
2540 }
2541 extern(C) Features sg_query_features() @system @nogc nothrow;
2542 Features queryFeatures() @trusted @nogc nothrow {
2543     return sg_query_features();
2544 }
2545 extern(C) Limits sg_query_limits() @system @nogc nothrow;
2546 Limits queryLimits() @trusted @nogc nothrow {
2547     return sg_query_limits();
2548 }
2549 extern(C) PixelformatInfo sg_query_pixelformat(PixelFormat) @system @nogc nothrow;
2550 PixelformatInfo queryPixelformat(PixelFormat fmt) @trusted @nogc nothrow {
2551     return sg_query_pixelformat(fmt);
2552 }
2553 extern(C) int sg_query_row_pitch(PixelFormat, int, int) @system @nogc nothrow;
2554 int queryRowPitch(PixelFormat fmt, int width, int row_align_bytes) @trusted @nogc nothrow {
2555     return sg_query_row_pitch(fmt, width, row_align_bytes);
2556 }
2557 extern(C) int sg_query_surface_pitch(PixelFormat, int, int, int) @system @nogc nothrow;
2558 int querySurfacePitch(PixelFormat fmt, int width, int height, int row_align_bytes) @trusted @nogc nothrow {
2559     return sg_query_surface_pitch(fmt, width, height, row_align_bytes);
2560 }
2561 /// get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID
2562 extern(C) ResourceState sg_query_buffer_state(Buffer) @system @nogc nothrow;
2563 /// get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID
2564 ResourceState queryBufferState(Buffer buf) @trusted @nogc nothrow {
2565     return sg_query_buffer_state(buf);
2566 }
2567 extern(C) ResourceState sg_query_image_state(Image) @system @nogc nothrow;
2568 ResourceState queryImageState(Image img) @trusted @nogc nothrow {
2569     return sg_query_image_state(img);
2570 }
2571 extern(C) ResourceState sg_query_sampler_state(Sampler) @system @nogc nothrow;
2572 ResourceState querySamplerState(Sampler smp) @trusted @nogc nothrow {
2573     return sg_query_sampler_state(smp);
2574 }
2575 extern(C) ResourceState sg_query_shader_state(Shader) @system @nogc nothrow;
2576 ResourceState queryShaderState(Shader shd) @trusted @nogc nothrow {
2577     return sg_query_shader_state(shd);
2578 }
2579 extern(C) ResourceState sg_query_pipeline_state(Pipeline) @system @nogc nothrow;
2580 ResourceState queryPipelineState(Pipeline pip) @trusted @nogc nothrow {
2581     return sg_query_pipeline_state(pip);
2582 }
2583 extern(C) ResourceState sg_query_attachments_state(Attachments) @system @nogc nothrow;
2584 ResourceState queryAttachmentsState(Attachments atts) @trusted @nogc nothrow {
2585     return sg_query_attachments_state(atts);
2586 }
2587 /// get runtime information about a resourc
2588 extern(C) BufferInfo sg_query_buffer_info(Buffer) @system @nogc nothrow;
2589 /// get runtime information about a resourc
2590 BufferInfo queryBufferInfo(Buffer buf) @trusted @nogc nothrow {
2591     return sg_query_buffer_info(buf);
2592 }
2593 extern(C) ImageInfo sg_query_image_info(Image) @system @nogc nothrow;
2594 ImageInfo queryImageInfo(Image img) @trusted @nogc nothrow {
2595     return sg_query_image_info(img);
2596 }
2597 extern(C) SamplerInfo sg_query_sampler_info(Sampler) @system @nogc nothrow;
2598 SamplerInfo querySamplerInfo(Sampler smp) @trusted @nogc nothrow {
2599     return sg_query_sampler_info(smp);
2600 }
2601 extern(C) ShaderInfo sg_query_shader_info(Shader) @system @nogc nothrow;
2602 ShaderInfo queryShaderInfo(Shader shd) @trusted @nogc nothrow {
2603     return sg_query_shader_info(shd);
2604 }
2605 extern(C) PipelineInfo sg_query_pipeline_info(Pipeline) @system @nogc nothrow;
2606 PipelineInfo queryPipelineInfo(Pipeline pip) @trusted @nogc nothrow {
2607     return sg_query_pipeline_info(pip);
2608 }
2609 extern(C) AttachmentsInfo sg_query_attachments_info(Attachments) @system @nogc nothrow;
2610 AttachmentsInfo queryAttachmentsInfo(Attachments atts) @trusted @nogc nothrow {
2611     return sg_query_attachments_info(atts);
2612 }
2613 /// get desc structs matching a specific resource (NOTE that not all creation attributes may be provided
2614 extern(C) BufferDesc sg_query_buffer_desc(Buffer) @system @nogc nothrow;
2615 /// get desc structs matching a specific resource (NOTE that not all creation attributes may be provided
2616 BufferDesc queryBufferDesc(Buffer buf) @trusted @nogc nothrow {
2617     return sg_query_buffer_desc(buf);
2618 }
2619 extern(C) ImageDesc sg_query_image_desc(Image) @system @nogc nothrow;
2620 ImageDesc queryImageDesc(Image img) @trusted @nogc nothrow {
2621     return sg_query_image_desc(img);
2622 }
2623 extern(C) SamplerDesc sg_query_sampler_desc(Sampler) @system @nogc nothrow;
2624 SamplerDesc querySamplerDesc(Sampler smp) @trusted @nogc nothrow {
2625     return sg_query_sampler_desc(smp);
2626 }
2627 extern(C) ShaderDesc sg_query_shader_desc(Shader) @system @nogc nothrow;
2628 ShaderDesc queryShaderDesc(Shader shd) @trusted @nogc nothrow {
2629     return sg_query_shader_desc(shd);
2630 }
2631 extern(C) PipelineDesc sg_query_pipeline_desc(Pipeline) @system @nogc nothrow;
2632 PipelineDesc queryPipelineDesc(Pipeline pip) @trusted @nogc nothrow {
2633     return sg_query_pipeline_desc(pip);
2634 }
2635 extern(C) AttachmentsDesc sg_query_attachments_desc(Attachments) @system @nogc nothrow;
2636 AttachmentsDesc queryAttachmentsDesc(Attachments atts) @trusted @nogc nothrow {
2637     return sg_query_attachments_desc(atts);
2638 }
2639 /// get resource creation desc struct with their default values replace
2640 extern(C) BufferDesc sg_query_buffer_defaults(const BufferDesc *) @system @nogc nothrow;
2641 /// get resource creation desc struct with their default values replace
2642 BufferDesc queryBufferDefaults(scope ref BufferDesc desc) @trusted @nogc nothrow {
2643     return sg_query_buffer_defaults(&desc);
2644 }
2645 extern(C) ImageDesc sg_query_image_defaults(const ImageDesc *) @system @nogc nothrow;
2646 ImageDesc queryImageDefaults(scope ref ImageDesc desc) @trusted @nogc nothrow {
2647     return sg_query_image_defaults(&desc);
2648 }
2649 extern(C) SamplerDesc sg_query_sampler_defaults(const SamplerDesc *) @system @nogc nothrow;
2650 SamplerDesc querySamplerDefaults(scope ref SamplerDesc desc) @trusted @nogc nothrow {
2651     return sg_query_sampler_defaults(&desc);
2652 }
2653 extern(C) ShaderDesc sg_query_shader_defaults(const ShaderDesc *) @system @nogc nothrow;
2654 ShaderDesc queryShaderDefaults(scope ref ShaderDesc desc) @trusted @nogc nothrow {
2655     return sg_query_shader_defaults(&desc);
2656 }
2657 extern(C) PipelineDesc sg_query_pipeline_defaults(const PipelineDesc *) @system @nogc nothrow;
2658 PipelineDesc queryPipelineDefaults(scope ref PipelineDesc desc) @trusted @nogc nothrow {
2659     return sg_query_pipeline_defaults(&desc);
2660 }
2661 extern(C) AttachmentsDesc sg_query_attachments_defaults(const AttachmentsDesc *) @system @nogc nothrow;
2662 AttachmentsDesc queryAttachmentsDefaults(scope ref AttachmentsDesc desc) @trusted @nogc nothrow {
2663     return sg_query_attachments_defaults(&desc);
2664 }
2665 /// assorted query function
2666 extern(C) size_t sg_query_buffer_size(Buffer) @system @nogc nothrow;
2667 /// assorted query function
2668 size_t queryBufferSize(Buffer buf) @trusted @nogc nothrow {
2669     return sg_query_buffer_size(buf);
2670 }
2671 extern(C) BufferType sg_query_buffer_type(Buffer) @system @nogc nothrow;
2672 BufferType queryBufferType(Buffer buf) @trusted @nogc nothrow {
2673     return sg_query_buffer_type(buf);
2674 }
2675 extern(C) Usage sg_query_buffer_usage(Buffer) @system @nogc nothrow;
2676 Usage queryBufferUsage(Buffer buf) @trusted @nogc nothrow {
2677     return sg_query_buffer_usage(buf);
2678 }
2679 extern(C) ImageType sg_query_image_type(Image) @system @nogc nothrow;
2680 ImageType queryImageType(Image img) @trusted @nogc nothrow {
2681     return sg_query_image_type(img);
2682 }
2683 extern(C) int sg_query_image_width(Image) @system @nogc nothrow;
2684 int queryImageWidth(Image img) @trusted @nogc nothrow {
2685     return sg_query_image_width(img);
2686 }
2687 extern(C) int sg_query_image_height(Image) @system @nogc nothrow;
2688 int queryImageHeight(Image img) @trusted @nogc nothrow {
2689     return sg_query_image_height(img);
2690 }
2691 extern(C) int sg_query_image_num_slices(Image) @system @nogc nothrow;
2692 int queryImageNumSlices(Image img) @trusted @nogc nothrow {
2693     return sg_query_image_num_slices(img);
2694 }
2695 extern(C) int sg_query_image_num_mipmaps(Image) @system @nogc nothrow;
2696 int queryImageNumMipmaps(Image img) @trusted @nogc nothrow {
2697     return sg_query_image_num_mipmaps(img);
2698 }
2699 extern(C) PixelFormat sg_query_image_pixelformat(Image) @system @nogc nothrow;
2700 PixelFormat queryImagePixelformat(Image img) @trusted @nogc nothrow {
2701     return sg_query_image_pixelformat(img);
2702 }
2703 extern(C) Usage sg_query_image_usage(Image) @system @nogc nothrow;
2704 Usage queryImageUsage(Image img) @trusted @nogc nothrow {
2705     return sg_query_image_usage(img);
2706 }
2707 extern(C) int sg_query_image_sample_count(Image) @system @nogc nothrow;
2708 int queryImageSampleCount(Image img) @trusted @nogc nothrow {
2709     return sg_query_image_sample_count(img);
2710 }
2711 /// separate resource allocation and initialization (for async setup
2712 extern(C) Buffer sg_alloc_buffer() @system @nogc nothrow;
2713 /// separate resource allocation and initialization (for async setup
2714 Buffer allocBuffer() @trusted @nogc nothrow {
2715     return sg_alloc_buffer();
2716 }
2717 extern(C) Image sg_alloc_image() @system @nogc nothrow;
2718 Image allocImage() @trusted @nogc nothrow {
2719     return sg_alloc_image();
2720 }
2721 extern(C) Sampler sg_alloc_sampler() @system @nogc nothrow;
2722 Sampler allocSampler() @trusted @nogc nothrow {
2723     return sg_alloc_sampler();
2724 }
2725 extern(C) Shader sg_alloc_shader() @system @nogc nothrow;
2726 Shader allocShader() @trusted @nogc nothrow {
2727     return sg_alloc_shader();
2728 }
2729 extern(C) Pipeline sg_alloc_pipeline() @system @nogc nothrow;
2730 Pipeline allocPipeline() @trusted @nogc nothrow {
2731     return sg_alloc_pipeline();
2732 }
2733 extern(C) Attachments sg_alloc_attachments() @system @nogc nothrow;
2734 Attachments allocAttachments() @trusted @nogc nothrow {
2735     return sg_alloc_attachments();
2736 }
2737 extern(C) void sg_dealloc_buffer(Buffer) @system @nogc nothrow;
2738 void deallocBuffer(Buffer buf) @trusted @nogc nothrow {
2739     sg_dealloc_buffer(buf);
2740 }
2741 extern(C) void sg_dealloc_image(Image) @system @nogc nothrow;
2742 void deallocImage(Image img) @trusted @nogc nothrow {
2743     sg_dealloc_image(img);
2744 }
2745 extern(C) void sg_dealloc_sampler(Sampler) @system @nogc nothrow;
2746 void deallocSampler(Sampler smp) @trusted @nogc nothrow {
2747     sg_dealloc_sampler(smp);
2748 }
2749 extern(C) void sg_dealloc_shader(Shader) @system @nogc nothrow;
2750 void deallocShader(Shader shd) @trusted @nogc nothrow {
2751     sg_dealloc_shader(shd);
2752 }
2753 extern(C) void sg_dealloc_pipeline(Pipeline) @system @nogc nothrow;
2754 void deallocPipeline(Pipeline pip) @trusted @nogc nothrow {
2755     sg_dealloc_pipeline(pip);
2756 }
2757 extern(C) void sg_dealloc_attachments(Attachments) @system @nogc nothrow;
2758 void deallocAttachments(Attachments attachments) @trusted @nogc nothrow {
2759     sg_dealloc_attachments(attachments);
2760 }
2761 extern(C) void sg_init_buffer(Buffer, const BufferDesc *) @system @nogc nothrow;
2762 void initBuffer(Buffer buf, scope ref BufferDesc desc) @trusted @nogc nothrow {
2763     sg_init_buffer(buf, &desc);
2764 }
2765 extern(C) void sg_init_image(Image, const ImageDesc *) @system @nogc nothrow;
2766 void initImage(Image img, scope ref ImageDesc desc) @trusted @nogc nothrow {
2767     sg_init_image(img, &desc);
2768 }
2769 extern(C) void sg_init_sampler(Sampler, const SamplerDesc *) @system @nogc nothrow;
2770 void initSampler(Sampler smg, scope ref SamplerDesc desc) @trusted @nogc nothrow {
2771     sg_init_sampler(smg, &desc);
2772 }
2773 extern(C) void sg_init_shader(Shader, const ShaderDesc *) @system @nogc nothrow;
2774 void initShader(Shader shd, scope ref ShaderDesc desc) @trusted @nogc nothrow {
2775     sg_init_shader(shd, &desc);
2776 }
2777 extern(C) void sg_init_pipeline(Pipeline, const PipelineDesc *) @system @nogc nothrow;
2778 void initPipeline(Pipeline pip, scope ref PipelineDesc desc) @trusted @nogc nothrow {
2779     sg_init_pipeline(pip, &desc);
2780 }
2781 extern(C) void sg_init_attachments(Attachments, const AttachmentsDesc *) @system @nogc nothrow;
2782 void initAttachments(Attachments attachments, scope ref AttachmentsDesc desc) @trusted @nogc nothrow {
2783     sg_init_attachments(attachments, &desc);
2784 }
2785 extern(C) void sg_uninit_buffer(Buffer) @system @nogc nothrow;
2786 void uninitBuffer(Buffer buf) @trusted @nogc nothrow {
2787     sg_uninit_buffer(buf);
2788 }
2789 extern(C) void sg_uninit_image(Image) @system @nogc nothrow;
2790 void uninitImage(Image img) @trusted @nogc nothrow {
2791     sg_uninit_image(img);
2792 }
2793 extern(C) void sg_uninit_sampler(Sampler) @system @nogc nothrow;
2794 void uninitSampler(Sampler smp) @trusted @nogc nothrow {
2795     sg_uninit_sampler(smp);
2796 }
2797 extern(C) void sg_uninit_shader(Shader) @system @nogc nothrow;
2798 void uninitShader(Shader shd) @trusted @nogc nothrow {
2799     sg_uninit_shader(shd);
2800 }
2801 extern(C) void sg_uninit_pipeline(Pipeline) @system @nogc nothrow;
2802 void uninitPipeline(Pipeline pip) @trusted @nogc nothrow {
2803     sg_uninit_pipeline(pip);
2804 }
2805 extern(C) void sg_uninit_attachments(Attachments) @system @nogc nothrow;
2806 void uninitAttachments(Attachments atts) @trusted @nogc nothrow {
2807     sg_uninit_attachments(atts);
2808 }
2809 extern(C) void sg_fail_buffer(Buffer) @system @nogc nothrow;
2810 void failBuffer(Buffer buf) @trusted @nogc nothrow {
2811     sg_fail_buffer(buf);
2812 }
2813 extern(C) void sg_fail_image(Image) @system @nogc nothrow;
2814 void failImage(Image img) @trusted @nogc nothrow {
2815     sg_fail_image(img);
2816 }
2817 extern(C) void sg_fail_sampler(Sampler) @system @nogc nothrow;
2818 void failSampler(Sampler smp) @trusted @nogc nothrow {
2819     sg_fail_sampler(smp);
2820 }
2821 extern(C) void sg_fail_shader(Shader) @system @nogc nothrow;
2822 void failShader(Shader shd) @trusted @nogc nothrow {
2823     sg_fail_shader(shd);
2824 }
2825 extern(C) void sg_fail_pipeline(Pipeline) @system @nogc nothrow;
2826 void failPipeline(Pipeline pip) @trusted @nogc nothrow {
2827     sg_fail_pipeline(pip);
2828 }
2829 extern(C) void sg_fail_attachments(Attachments) @system @nogc nothrow;
2830 void failAttachments(Attachments atts) @trusted @nogc nothrow {
2831     sg_fail_attachments(atts);
2832 }
2833 /// frame stat
2834 extern(C) void sg_enable_frame_stats() @system @nogc nothrow;
2835 /// frame stat
2836 void enableFrameStats() @trusted @nogc nothrow {
2837     sg_enable_frame_stats();
2838 }
2839 extern(C) void sg_disable_frame_stats() @system @nogc nothrow;
2840 void disableFrameStats() @trusted @nogc nothrow {
2841     sg_disable_frame_stats();
2842 }
2843 extern(C) bool sg_frame_stats_enabled() @system @nogc nothrow;
2844 bool frameStatsEnabled() @trusted @nogc nothrow {
2845     return sg_frame_stats_enabled();
2846 }
2847 extern(C) FrameStats sg_query_frame_stats() @system @nogc nothrow;
2848 FrameStats queryFrameStats() @trusted @nogc nothrow {
2849     return sg_query_frame_stats();
2850 }
2851 /// Backend-specific structs and functions, these may come in handy for mixing
2852 ///   sokol-gfx rendering with 'native backend' rendering functions.
2853 /// 
2854 ///   This group of functions will be expanded as needed
2855 extern(C)
2856 struct D3d11BufferInfo {
2857     const(void)* buf = null;
2858 }
2859 extern(C)
2860 struct D3d11ImageInfo {
2861     const(void)* tex2d = null;
2862     const(void)* tex3d = null;
2863     const(void)* res = null;
2864     const(void)* srv = null;
2865 }
2866 extern(C)
2867 struct D3d11SamplerInfo {
2868     const(void)* smp = null;
2869 }
2870 extern(C)
2871 struct D3d11ShaderInfo {
2872     const(void)*[8] cbufs = null;
2873     const(void)* vs = null;
2874     const(void)* fs = null;
2875 }
2876 extern(C)
2877 struct D3d11PipelineInfo {
2878     const(void)* il = null;
2879     const(void)* rs = null;
2880     const(void)* dss = null;
2881     const(void)* bs = null;
2882 }
2883 extern(C)
2884 struct D3d11AttachmentsInfo {
2885     const(void)*[4] color_rtv = null;
2886     const(void)*[4] resolve_rtv = null;
2887     const(void)* dsv = null;
2888 }
2889 extern(C)
2890 struct MtlBufferInfo {
2891     const(void)*[2] buf = null;
2892     int active_slot = 0;
2893 }
2894 extern(C)
2895 struct MtlImageInfo {
2896     const(void)*[2] tex = null;
2897     int active_slot = 0;
2898 }
2899 extern(C)
2900 struct MtlSamplerInfo {
2901     const(void)* smp = null;
2902 }
2903 extern(C)
2904 struct MtlShaderInfo {
2905     const(void)* vertex_lib = null;
2906     const(void)* fragment_lib = null;
2907     const(void)* vertex_func = null;
2908     const(void)* fragment_func = null;
2909 }
2910 extern(C)
2911 struct MtlPipelineInfo {
2912     const(void)* rps = null;
2913     const(void)* dss = null;
2914 }
2915 extern(C)
2916 struct WgpuBufferInfo {
2917     const(void)* buf = null;
2918 }
2919 extern(C)
2920 struct WgpuImageInfo {
2921     const(void)* tex = null;
2922     const(void)* view = null;
2923 }
2924 extern(C)
2925 struct WgpuSamplerInfo {
2926     const(void)* smp = null;
2927 }
2928 extern(C)
2929 struct WgpuShaderInfo {
2930     const(void)* vs_mod = null;
2931     const(void)* fs_mod = null;
2932     const(void)* bgl = null;
2933 }
2934 extern(C)
2935 struct WgpuPipelineInfo {
2936     const(void)* pip = null;
2937 }
2938 extern(C)
2939 struct WgpuAttachmentsInfo {
2940     const(void)*[4] color_view = null;
2941     const(void)*[4] resolve_view = null;
2942     const(void)* ds_view = null;
2943 }
2944 extern(C)
2945 struct GlBufferInfo {
2946     uint[2] buf = 0;
2947     int active_slot = 0;
2948 }
2949 extern(C)
2950 struct GlImageInfo {
2951     uint[2] tex = 0;
2952     uint tex_target = 0;
2953     uint msaa_render_buffer = 0;
2954     int active_slot = 0;
2955 }
2956 extern(C)
2957 struct GlSamplerInfo {
2958     uint smp = 0;
2959 }
2960 extern(C)
2961 struct GlShaderInfo {
2962     uint prog = 0;
2963 }
2964 extern(C)
2965 struct GlAttachmentsInfo {
2966     uint framebuffer = 0;
2967     uint[4] msaa_resolve_framebuffer = 0;
2968 }
2969 /// D3D11: return ID3D11Devic
2970 extern(C) const(void)* sg_d3d11_device() @system @nogc nothrow;
2971 /// D3D11: return ID3D11Devic
2972 scope const(void)* d3d11Device() @trusted @nogc nothrow {
2973     return sg_d3d11_device();
2974 }
2975 /// D3D11: return ID3D11DeviceContex
2976 extern(C) const(void)* sg_d3d11_device_context() @system @nogc nothrow;
2977 /// D3D11: return ID3D11DeviceContex
2978 scope const(void)* d3d11DeviceContext() @trusted @nogc nothrow {
2979     return sg_d3d11_device_context();
2980 }
2981 /// D3D11: get internal buffer resource object
2982 extern(C) D3d11BufferInfo sg_d3d11_query_buffer_info(Buffer) @system @nogc nothrow;
2983 /// D3D11: get internal buffer resource object
2984 D3d11BufferInfo d3d11QueryBufferInfo(Buffer buf) @trusted @nogc nothrow {
2985     return sg_d3d11_query_buffer_info(buf);
2986 }
2987 /// D3D11: get internal image resource object
2988 extern(C) D3d11ImageInfo sg_d3d11_query_image_info(Image) @system @nogc nothrow;
2989 /// D3D11: get internal image resource object
2990 D3d11ImageInfo d3d11QueryImageInfo(Image img) @trusted @nogc nothrow {
2991     return sg_d3d11_query_image_info(img);
2992 }
2993 /// D3D11: get internal sampler resource object
2994 extern(C) D3d11SamplerInfo sg_d3d11_query_sampler_info(Sampler) @system @nogc nothrow;
2995 /// D3D11: get internal sampler resource object
2996 D3d11SamplerInfo d3d11QuerySamplerInfo(Sampler smp) @trusted @nogc nothrow {
2997     return sg_d3d11_query_sampler_info(smp);
2998 }
2999 /// D3D11: get internal shader resource object
3000 extern(C) D3d11ShaderInfo sg_d3d11_query_shader_info(Shader) @system @nogc nothrow;
3001 /// D3D11: get internal shader resource object
3002 D3d11ShaderInfo d3d11QueryShaderInfo(Shader shd) @trusted @nogc nothrow {
3003     return sg_d3d11_query_shader_info(shd);
3004 }
3005 /// D3D11: get internal pipeline resource object
3006 extern(C) D3d11PipelineInfo sg_d3d11_query_pipeline_info(Pipeline) @system @nogc nothrow;
3007 /// D3D11: get internal pipeline resource object
3008 D3d11PipelineInfo d3d11QueryPipelineInfo(Pipeline pip) @trusted @nogc nothrow {
3009     return sg_d3d11_query_pipeline_info(pip);
3010 }
3011 /// D3D11: get internal pass resource object
3012 extern(C) D3d11AttachmentsInfo sg_d3d11_query_attachments_info(Attachments) @system @nogc nothrow;
3013 /// D3D11: get internal pass resource object
3014 D3d11AttachmentsInfo d3d11QueryAttachmentsInfo(Attachments atts) @trusted @nogc nothrow {
3015     return sg_d3d11_query_attachments_info(atts);
3016 }
3017 /// Metal: return __bridge-casted MTLDevic
3018 extern(C) const(void)* sg_mtl_device() @system @nogc nothrow;
3019 /// Metal: return __bridge-casted MTLDevic
3020 scope const(void)* mtlDevice() @trusted @nogc nothrow {
3021     return sg_mtl_device();
3022 }
3023 /// Metal: return __bridge-casted MTLRenderCommandEncoder in current pass (or zero if outside pass
3024 extern(C) const(void)* sg_mtl_render_command_encoder() @system @nogc nothrow;
3025 /// Metal: return __bridge-casted MTLRenderCommandEncoder in current pass (or zero if outside pass
3026 scope const(void)* mtlRenderCommandEncoder() @trusted @nogc nothrow {
3027     return sg_mtl_render_command_encoder();
3028 }
3029 /// Metal: get internal __bridge-casted buffer resource object
3030 extern(C) MtlBufferInfo sg_mtl_query_buffer_info(Buffer) @system @nogc nothrow;
3031 /// Metal: get internal __bridge-casted buffer resource object
3032 MtlBufferInfo mtlQueryBufferInfo(Buffer buf) @trusted @nogc nothrow {
3033     return sg_mtl_query_buffer_info(buf);
3034 }
3035 /// Metal: get internal __bridge-casted image resource object
3036 extern(C) MtlImageInfo sg_mtl_query_image_info(Image) @system @nogc nothrow;
3037 /// Metal: get internal __bridge-casted image resource object
3038 MtlImageInfo mtlQueryImageInfo(Image img) @trusted @nogc nothrow {
3039     return sg_mtl_query_image_info(img);
3040 }
3041 /// Metal: get internal __bridge-casted sampler resource object
3042 extern(C) MtlSamplerInfo sg_mtl_query_sampler_info(Sampler) @system @nogc nothrow;
3043 /// Metal: get internal __bridge-casted sampler resource object
3044 MtlSamplerInfo mtlQuerySamplerInfo(Sampler smp) @trusted @nogc nothrow {
3045     return sg_mtl_query_sampler_info(smp);
3046 }
3047 /// Metal: get internal __bridge-casted shader resource object
3048 extern(C) MtlShaderInfo sg_mtl_query_shader_info(Shader) @system @nogc nothrow;
3049 /// Metal: get internal __bridge-casted shader resource object
3050 MtlShaderInfo mtlQueryShaderInfo(Shader shd) @trusted @nogc nothrow {
3051     return sg_mtl_query_shader_info(shd);
3052 }
3053 /// Metal: get internal __bridge-casted pipeline resource object
3054 extern(C) MtlPipelineInfo sg_mtl_query_pipeline_info(Pipeline) @system @nogc nothrow;
3055 /// Metal: get internal __bridge-casted pipeline resource object
3056 MtlPipelineInfo mtlQueryPipelineInfo(Pipeline pip) @trusted @nogc nothrow {
3057     return sg_mtl_query_pipeline_info(pip);
3058 }
3059 /// WebGPU: return WGPUDevice objec
3060 extern(C) const(void)* sg_wgpu_device() @system @nogc nothrow;
3061 /// WebGPU: return WGPUDevice objec
3062 scope const(void)* wgpuDevice() @trusted @nogc nothrow {
3063     return sg_wgpu_device();
3064 }
3065 /// WebGPU: return WGPUQueue objec
3066 extern(C) const(void)* sg_wgpu_queue() @system @nogc nothrow;
3067 /// WebGPU: return WGPUQueue objec
3068 scope const(void)* wgpuQueue() @trusted @nogc nothrow {
3069     return sg_wgpu_queue();
3070 }
3071 /// WebGPU: return this frame's WGPUCommandEncode
3072 extern(C) const(void)* sg_wgpu_command_encoder() @system @nogc nothrow;
3073 /// WebGPU: return this frame's WGPUCommandEncode
3074 scope const(void)* wgpuCommandEncoder() @trusted @nogc nothrow {
3075     return sg_wgpu_command_encoder();
3076 }
3077 /// WebGPU: return WGPURenderPassEncoder of current pas
3078 extern(C) const(void)* sg_wgpu_render_pass_encoder() @system @nogc nothrow;
3079 /// WebGPU: return WGPURenderPassEncoder of current pas
3080 scope const(void)* wgpuRenderPassEncoder() @trusted @nogc nothrow {
3081     return sg_wgpu_render_pass_encoder();
3082 }
3083 /// WebGPU: get internal buffer resource object
3084 extern(C) WgpuBufferInfo sg_wgpu_query_buffer_info(Buffer) @system @nogc nothrow;
3085 /// WebGPU: get internal buffer resource object
3086 WgpuBufferInfo wgpuQueryBufferInfo(Buffer buf) @trusted @nogc nothrow {
3087     return sg_wgpu_query_buffer_info(buf);
3088 }
3089 /// WebGPU: get internal image resource object
3090 extern(C) WgpuImageInfo sg_wgpu_query_image_info(Image) @system @nogc nothrow;
3091 /// WebGPU: get internal image resource object
3092 WgpuImageInfo wgpuQueryImageInfo(Image img) @trusted @nogc nothrow {
3093     return sg_wgpu_query_image_info(img);
3094 }
3095 /// WebGPU: get internal sampler resource object
3096 extern(C) WgpuSamplerInfo sg_wgpu_query_sampler_info(Sampler) @system @nogc nothrow;
3097 /// WebGPU: get internal sampler resource object
3098 WgpuSamplerInfo wgpuQuerySamplerInfo(Sampler smp) @trusted @nogc nothrow {
3099     return sg_wgpu_query_sampler_info(smp);
3100 }
3101 /// WebGPU: get internal shader resource object
3102 extern(C) WgpuShaderInfo sg_wgpu_query_shader_info(Shader) @system @nogc nothrow;
3103 /// WebGPU: get internal shader resource object
3104 WgpuShaderInfo wgpuQueryShaderInfo(Shader shd) @trusted @nogc nothrow {
3105     return sg_wgpu_query_shader_info(shd);
3106 }
3107 /// WebGPU: get internal pipeline resource object
3108 extern(C) WgpuPipelineInfo sg_wgpu_query_pipeline_info(Pipeline) @system @nogc nothrow;
3109 /// WebGPU: get internal pipeline resource object
3110 WgpuPipelineInfo wgpuQueryPipelineInfo(Pipeline pip) @trusted @nogc nothrow {
3111     return sg_wgpu_query_pipeline_info(pip);
3112 }
3113 /// WebGPU: get internal pass resource object
3114 extern(C) WgpuAttachmentsInfo sg_wgpu_query_attachments_info(Attachments) @system @nogc nothrow;
3115 /// WebGPU: get internal pass resource object
3116 WgpuAttachmentsInfo wgpuQueryAttachmentsInfo(Attachments atts) @trusted @nogc nothrow {
3117     return sg_wgpu_query_attachments_info(atts);
3118 }
3119 /// GL: get internal buffer resource object
3120 extern(C) GlBufferInfo sg_gl_query_buffer_info(Buffer) @system @nogc nothrow;
3121 /// GL: get internal buffer resource object
3122 GlBufferInfo glQueryBufferInfo(Buffer buf) @trusted @nogc nothrow {
3123     return sg_gl_query_buffer_info(buf);
3124 }
3125 /// GL: get internal image resource object
3126 extern(C) GlImageInfo sg_gl_query_image_info(Image) @system @nogc nothrow;
3127 /// GL: get internal image resource object
3128 GlImageInfo glQueryImageInfo(Image img) @trusted @nogc nothrow {
3129     return sg_gl_query_image_info(img);
3130 }
3131 /// GL: get internal sampler resource object
3132 extern(C) GlSamplerInfo sg_gl_query_sampler_info(Sampler) @system @nogc nothrow;
3133 /// GL: get internal sampler resource object
3134 GlSamplerInfo glQuerySamplerInfo(Sampler smp) @trusted @nogc nothrow {
3135     return sg_gl_query_sampler_info(smp);
3136 }
3137 /// GL: get internal shader resource object
3138 extern(C) GlShaderInfo sg_gl_query_shader_info(Shader) @system @nogc nothrow;
3139 /// GL: get internal shader resource object
3140 GlShaderInfo glQueryShaderInfo(Shader shd) @trusted @nogc nothrow {
3141     return sg_gl_query_shader_info(shd);
3142 }
3143 /// GL: get internal pass resource object
3144 extern(C) GlAttachmentsInfo sg_gl_query_attachments_info(Attachments) @system @nogc nothrow;
3145 /// GL: get internal pass resource object
3146 GlAttachmentsInfo glQueryAttachmentsInfo(Attachments atts) @trusted @nogc nothrow {
3147     return sg_gl_query_attachments_info(atts);
3148 }