1 /++
2 + Machine generated D bindings for Sokol library.
3 + 
4 +     Source header: sokol_gfx.h
5 +     Module: sokol.gfx
6 + 
7 +     Do not edit manually; regenerate using gen_d.py.
8 +/
9 module sokol.gfx;
10 
11 /++
12 + Resource id typedefs:
13 + 
14 +     sg_buffer:      vertex- and index-buffers
15 +     sg_image:       images used as textures and render-pass attachments
16 +     sg_sampler      sampler objects describing how a texture is sampled in a shader
17 +     sg_shader:      vertex- and fragment-shaders and shader interface information
18 +     sg_pipeline:    associated shader and vertex-layouts, and render states
19 +     sg_view:        a resource view object used for bindings and render-pass attachments
20 + 
21 +     Instead of pointers, resource creation functions return a 32-bit
22 +     handle which uniquely identifies the resource object.
23 + 
24 +     The 32-bit resource id is split into a 16-bit pool index in the lower bits,
25 +     and a 16-bit 'generation counter' in the upper bits. The index allows fast
26 +     pool lookups, and combined with the generation-counter it allows to detect
27 +     'dangling accesses' (trying to use an object which no longer exists, and
28 +     its pool slot has been reused for a new object)
29 + 
30 +     The resource ids are wrapped into a strongly-typed struct so that
31 +     trying to pass an incompatible resource id is a compile error.
32 +/
33 extern(C) struct Buffer {
34     uint id = 0;
35 }
36 extern(C) struct Image {
37     uint id = 0;
38 }
39 extern(C) struct Sampler {
40     uint id = 0;
41 }
42 extern(C) struct Shader {
43     uint id = 0;
44 }
45 extern(C) struct Pipeline {
46     uint id = 0;
47 }
48 extern(C) struct View {
49     uint id = 0;
50 }
51 /++
52 + sg_range is a pointer-size-pair struct used to pass memory blobs into
53 +     sokol-gfx. When initialized from a value type (array or struct), you can
54 +     use the SG_RANGE() macro to build an sg_range struct. For functions which
55 +     take either a sg_range pointer, or a (C++) sg_range reference, use the
56 +     SG_RANGE_REF macro as a solution which compiles both in C and C++.
57 +/
58 extern(C) struct Range {
59     const(void)* ptr = null;
60     size_t size = 0;
61 }
62 /++
63 + various compile-time constants in the public API
64 +/
65 enum invalid_id = 0;
66 enum num_inflight_frames = 2;
67 enum max_color_attachments = 8;
68 enum max_uniformblock_members = 16;
69 enum max_vertex_attributes = 16;
70 enum max_mipmaps = 16;
71 enum max_vertexbuffer_bindslots = 8;
72 enum max_uniformblock_bindslots = 8;
73 enum max_view_bindslots = 32;
74 enum max_sampler_bindslots = 12;
75 enum max_texture_sampler_pairs = 32;
76 enum max_portable_color_attachments = 4;
77 enum max_portable_texture_bindings_per_stage = 16;
78 enum max_portable_storagebuffer_bindings_per_stage = 8;
79 enum max_portable_storageimage_bindings_per_stage = 4;
80 /++
81 + sg_color
82 + 
83 +     An RGBA color value.
84 +/
85 extern(C) struct Color {
86     float r = 0.0f;
87     float g = 0.0f;
88     float b = 0.0f;
89     float a = 0.0f;
90 }
91 /++
92 + sg_backend
93 + 
94 +     The active 3D-API backend, use the function sg_query_backend()
95 +     to get the currently active backend.
96 +/
97 enum Backend {
98     Glcore,
99     Gles3,
100     D3d11,
101     Metal_ios,
102     Metal_macos,
103     Metal_simulator,
104     Wgpu,
105     Vulkan,
106     Dummy,
107 }
108 /++
109 + sg_pixel_format
110 + 
111 +     sokol_gfx.h basically uses the same pixel formats as WebGPU, since these
112 +     are supported on most newer GPUs.
113 + 
114 +     A pixelformat name consist of three parts:
115 + 
116 +         - components (R, RG, RGB or RGBA)
117 +         - bit width per component (8, 16 or 32)
118 +         - component data type:
119 +             - unsigned normalized (no postfix)
120 +             - signed normalized (SN postfix)
121 +             - unsigned integer (UI postfix)
122 +             - signed integer (SI postfix)
123 +             - float (F postfix)
124 + 
125 +     Not all pixel formats can be used for everything, call sg_query_pixelformat()
126 +     to inspect the capabilities of a given pixelformat. The function returns
127 +     an sg_pixelformat_info struct with the following members:
128 + 
129 +         - sample: the pixelformat can be sampled as texture at least with
130 +                   nearest filtering
131 +         - filter: the pixelformat can be sampled as texture with linear
132 +                   filtering
133 +         - render: the pixelformat can be used as render-pass attachment
134 +         - blend:  blending is supported when used as render-pass attachment
135 +         - msaa:   multisample-antialiasing is supported when used
136 +                   as render-pass attachment
137 +         - depth:  the pixelformat can be used for depth-stencil attachments
138 +         - compressed: this is a block-compressed format
139 +         - bytes_per_pixel: the numbers of bytes in a pixel (0 for compressed formats)
140 + 
141 +     The default pixel format for texture images is SG_PIXELFORMAT_RGBA8.
142 + 
143 +     The default pixel format for render target images is platform-dependent
144 +     and taken from the sg_environment struct passed into sg_setup(). Typically
145 +     the default formats are:
146 + 
147 +         - for the Metal, D3D11 and WebGPU backends: SG_PIXELFORMAT_BGRA8
148 +         - for GL backends: SG_PIXELFORMAT_RGBA8
149 +/
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     Etc2_rgb8,
209     Etc2_srgb8,
210     Etc2_rgb8a1,
211     Etc2_rgba8,
212     Etc2_srgb8a8,
213     Eac_r11,
214     Eac_r11sn,
215     Eac_rg11,
216     Eac_rg11sn,
217     Astc_4x4_rgba,
218     Astc_4x4_srgba,
219     Num,
220 }
221 /++
222 + Runtime information about a pixel format, returned by sg_query_pixelformat().
223 +/
224 extern(C) struct PixelformatInfo {
225     bool sample = false;
226     bool filter = false;
227     bool render = false;
228     bool blend = false;
229     bool msaa = false;
230     bool depth = false;
231     bool compressed = false;
232     bool read = false;
233     bool write = false;
234     int bytes_per_pixel = 0;
235 }
236 /++
237 + Runtime information about available optional features, returned by sg_query_features()
238 +/
239 extern(C) 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 compute = false;
245     bool msaa_texture_bindings = false;
246     bool separate_buffer_types = false;
247     bool draw_base_vertex = false;
248     bool draw_base_instance = false;
249     bool dual_source_blending = false;
250     bool gl_texture_views = false;
251 }
252 /++
253 + Runtime information about resource limits, returned by sg_query_limit()
254 +/
255 extern(C) struct Limits {
256     int max_image_size_2d = 0;
257     int max_image_size_cube = 0;
258     int max_image_size_3d = 0;
259     int max_image_size_array = 0;
260     int max_image_array_layers = 0;
261     int max_vertex_attrs = 0;
262     int max_color_attachments = 0;
263     int max_texture_bindings_per_stage = 0;
264     int max_storage_buffer_bindings_per_stage = 0;
265     int max_storage_image_bindings_per_stage = 0;
266     int gl_max_vertex_uniform_components = 0;
267     int gl_max_combined_texture_image_units = 0;
268     int d3d11_max_unordered_access_views = 0;
269     int vk_min_uniform_buffer_offset_alignment = 0;
270 }
271 /++
272 + sg_resource_state
273 + 
274 +     The current state of a resource in its resource pool.
275 +     Resources start in the INITIAL state, which means the
276 +     pool slot is unoccupied and can be allocated. When a resource is
277 +     created, first an id is allocated, and the resource pool slot
278 +     is set to state ALLOC. After allocation, the resource is
279 +     initialized, which may result in the VALID or FAILED state. The
280 +     reason why allocation and initialization are separate is because
281 +     some resource types (e.g. buffers and images) might be asynchronously
282 +     initialized by the user application. If a resource which is not
283 +     in the VALID state is attempted to be used for rendering, rendering
284 +     operations will silently be dropped.
285 + 
286 +     The special INVALID state is returned in sg_query_xxx_state() if no
287 +     resource object exists for the provided resource id.
288 +/
289 enum ResourceState {
290     Initial,
291     Alloc,
292     Valid,
293     Failed,
294     Invalid,
295 }
296 /++
297 + sg_index_type
298 + 
299 +     Indicates whether indexed rendering (fetching vertex-indices from an
300 +     index buffer) is used, and if yes, the index data type (16- or 32-bits).
301 + 
302 +     This is used in the sg_pipeline_desc.index_type member when creating a
303 +     pipeline object.
304 + 
305 +     The default index type is SG_INDEXTYPE_NONE.
306 +/
307 enum IndexType {
308     Default,
309     None,
310     Uint16,
311     Uint32,
312     Num,
313 }
314 /++
315 + sg_image_type
316 + 
317 +     Indicates the basic type of an image object (2D-texture, cubemap,
318 +     3D-texture or 2D-array-texture). Used in the sg_image_desc.type member when
319 +     creating an image, and in sg_shader_image_desc to describe a sampled texture
320 +     in the shader (both must match and will be checked in the validation layer
321 +     when calling sg_apply_bindings).
322 + 
323 +     The default image type when creating an image is SG_IMAGETYPE_2D.
324 +/
325 enum ImageType {
326     Default,
327     _2d,
328     Cube,
329     _3d,
330     Array,
331     Num,
332 }
333 /++
334 + sg_image_sample_type
335 + 
336 +     The basic data type of a texture sample as expected by a shader.
337 +     Must be provided in sg_shader_image and used by the validation
338 +     layer in sg_apply_bindings() to check if the provided image object
339 +     is compatible with what the shader expects. Apart from the sokol-gfx
340 +     validation layer, WebGPU is the only backend API which actually requires
341 +     matching texture and sampler type to be provided upfront for validation
342 +     (other 3D APIs treat texture/sampler type mismatches as undefined behaviour).
343 + 
344 +     NOTE that the following texture pixel formats require the use
345 +     of SG_IMAGESAMPLETYPE_UNFILTERABLE_FLOAT, combined with a sampler
346 +     of type SG_SAMPLERTYPE_NONFILTERING:
347 + 
348 +     - SG_PIXELFORMAT_R32F
349 +     - SG_PIXELFORMAT_RG32F
350 +     - SG_PIXELFORMAT_RGBA32F
351 + 
352 +     (when using sokol-shdc, also check out the meta tags `@image_sample_type`
353 +     and `@sampler_type`)
354 +/
355 enum ImageSampleType {
356     Default,
357     Float,
358     Depth,
359     Sint,
360     Uint,
361     Unfilterable_float,
362     Num,
363 }
364 /++
365 + sg_sampler_type
366 + 
367 +     The basic type of a texture sampler (sampling vs comparison) as
368 +     defined in a shader. Must be provided in sg_shader_sampler_desc.
369 + 
370 +     sg_image_sample_type and sg_sampler_type for a texture/sampler
371 +     pair must be compatible with each other, specifically only
372 +     the following pairs are allowed:
373 + 
374 +     - SG_IMAGESAMPLETYPE_FLOAT => (SG_SAMPLERTYPE_FILTERING or SG_SAMPLERTYPE_NONFILTERING)
375 +     - SG_IMAGESAMPLETYPE_UNFILTERABLE_FLOAT => SG_SAMPLERTYPE_NONFILTERING
376 +     - SG_IMAGESAMPLETYPE_SINT => SG_SAMPLERTYPE_NONFILTERING
377 +     - SG_IMAGESAMPLETYPE_UINT => SG_SAMPLERTYPE_NONFILTERING
378 +     - SG_IMAGESAMPLETYPE_DEPTH => SG_SAMPLERTYPE_COMPARISON
379 +/
380 enum SamplerType {
381     Default,
382     Filtering,
383     Nonfiltering,
384     Comparison,
385     Num,
386 }
387 /++
388 + sg_primitive_type
389 + 
390 +     This is the common subset of 3D primitive types supported across all 3D
391 +     APIs. This is used in the sg_pipeline_desc.primitive_type member when
392 +     creating a pipeline object.
393 + 
394 +     The default primitive type is SG_PRIMITIVETYPE_TRIANGLES.
395 +/
396 enum PrimitiveType {
397     Default,
398     Points,
399     Lines,
400     Line_strip,
401     Triangles,
402     Triangle_strip,
403     Num,
404 }
405 /++
406 + sg_filter
407 + 
408 +     The filtering mode when sampling a texture image. This is
409 +     used in the sg_sampler_desc.min_filter, sg_sampler_desc.mag_filter
410 +     and sg_sampler_desc.mipmap_filter members when creating a sampler object.
411 + 
412 +     For the default is SG_FILTER_NEAREST.
413 +/
414 enum Filter {
415     Default,
416     Nearest,
417     Linear,
418     Num,
419 }
420 /++
421 + sg_wrap
422 + 
423 +     The texture coordinates wrapping mode when sampling a texture
424 +     image. This is used in the sg_image_desc.wrap_u, .wrap_v
425 +     and .wrap_w members when creating an image.
426 + 
427 +     The default wrap mode is SG_WRAP_REPEAT.
428 + 
429 +     NOTE: SG_WRAP_CLAMP_TO_BORDER is not supported on all backends
430 +     and platforms. To check for support, call sg_query_features()
431 +     and check the "clamp_to_border" boolean in the returned
432 +     sg_features struct.
433 + 
434 +     Platforms which don't support SG_WRAP_CLAMP_TO_BORDER will silently fall back
435 +     to SG_WRAP_CLAMP_TO_EDGE without a validation error.
436 +/
437 enum Wrap {
438     Default,
439     Repeat,
440     Clamp_to_edge,
441     Clamp_to_border,
442     Mirrored_repeat,
443     Num,
444 }
445 /++
446 + sg_border_color
447 + 
448 +     The border color to use when sampling a texture, and the UV wrap
449 +     mode is SG_WRAP_CLAMP_TO_BORDER.
450 + 
451 +     The default border color is SG_BORDERCOLOR_OPAQUE_BLACK
452 +/
453 enum BorderColor {
454     Default,
455     Transparent_black,
456     Opaque_black,
457     Opaque_white,
458     Num,
459 }
460 /++
461 + sg_vertex_format
462 + 
463 +     The data type of a vertex component. This is used to describe
464 +     the layout of input vertex data when creating a pipeline object.
465 + 
466 +     NOTE that specific mapping rules exist from the CPU-side vertex
467 +     formats to the vertex attribute base type in the vertex shader code
468 +     (see doc header section 'ON VERTEX FORMATS').
469 +/
470 enum VertexFormat {
471     Invalid,
472     Float,
473     Float2,
474     Float3,
475     Float4,
476     Int,
477     Int2,
478     Int3,
479     Int4,
480     Uint,
481     Uint2,
482     Uint3,
483     Uint4,
484     Byte4,
485     Byte4n,
486     Ubyte4,
487     Ubyte4n,
488     Short2,
489     Short2n,
490     Ushort2,
491     Ushort2n,
492     Short4,
493     Short4n,
494     Ushort4,
495     Ushort4n,
496     Uint10_n2,
497     Half2,
498     Half4,
499     Num,
500 }
501 /++
502 + sg_vertex_step
503 + 
504 +     Defines whether the input pointer of a vertex input stream is advanced
505 +     'per vertex' or 'per instance'. The default step-func is
506 +     SG_VERTEXSTEP_PER_VERTEX. SG_VERTEXSTEP_PER_INSTANCE is used with
507 +     instanced-rendering.
508 + 
509 +     The vertex-step is part of the vertex-layout definition
510 +     when creating pipeline objects.
511 +/
512 enum VertexStep {
513     Default,
514     Per_vertex,
515     Per_instance,
516     Num,
517 }
518 /++
519 + sg_uniform_type
520 + 
521 +     The data type of a uniform block member. This is used to
522 +     describe the internal layout of uniform blocks when creating
523 +     a shader object. This is only required for the GL backend, all
524 +     other backends will ignore the interior layout of uniform blocks.
525 +/
526 enum UniformType {
527     Invalid,
528     Float,
529     Float2,
530     Float3,
531     Float4,
532     Int,
533     Int2,
534     Int3,
535     Int4,
536     Mat4,
537     Num,
538 }
539 /++
540 + sg_uniform_layout
541 + 
542 +     A hint for the interior memory layout of uniform blocks. This is
543 +     only relevant for the GL backend where the internal layout
544 +     of uniform blocks must be known to sokol-gfx. For all other backends the
545 +     internal memory layout of uniform blocks doesn't matter, sokol-gfx
546 +     will just pass uniform data as an opaque memory blob to the
547 +     3D backend.
548 + 
549 +     SG_UNIFORMLAYOUT_NATIVE (default)
550 +         Native layout means that a 'backend-native' memory layout
551 +         is used. For the GL backend this means that uniforms
552 +         are packed tightly in memory (e.g. there are no padding
553 +         bytes).
554 + 
555 +     SG_UNIFORMLAYOUT_STD140
556 +         The memory layout is a subset of std140. Arrays are only
557 +         allowed for the FLOAT4, INT4 and MAT4. Alignment is as
558 +         is as follows:
559 + 
560 +             FLOAT, INT:         4 byte alignment
561 +             FLOAT2, INT2:       8 byte alignment
562 +             FLOAT3, INT3:       16 byte alignment(!)
563 +             FLOAT4, INT4:       16 byte alignment
564 +             MAT4:               16 byte alignment
565 +             FLOAT4[], INT4[]:   16 byte alignment
566 + 
567 +         The overall size of the uniform block must be a multiple
568 +         of 16.
569 + 
570 +     For more information search for 'UNIFORM DATA LAYOUT' in the documentation block
571 +     at the start of the header.
572 +/
573 enum UniformLayout {
574     Default,
575     Native,
576     Std140,
577     Num,
578 }
579 /++
580 + sg_cull_mode
581 + 
582 +     The face-culling mode, this is used in the
583 +     sg_pipeline_desc.cull_mode member when creating a
584 +     pipeline object.
585 + 
586 +     The default cull mode is SG_CULLMODE_NONE
587 +/
588 enum CullMode {
589     Default,
590     None,
591     Front,
592     Back,
593     Num,
594 }
595 /++
596 + sg_face_winding
597 + 
598 +     The vertex-winding rule that determines a front-facing primitive. This
599 +     is used in the member sg_pipeline_desc.face_winding
600 +     when creating a pipeline object.
601 + 
602 +     The default winding is SG_FACEWINDING_CW (clockwise)
603 +/
604 enum FaceWinding {
605     Default,
606     Ccw,
607     Cw,
608     Num,
609 }
610 /++
611 + sg_compare_func
612 + 
613 +     The compare-function for configuring depth- and stencil-ref tests
614 +     in pipeline objects, and for texture samplers which perform a comparison
615 +     instead of regular sampling operation.
616 + 
617 +     Used in the following structs:
618 + 
619 +     sg_pipeline_desc
620 +         .depth
621 +             .compare
622 +         .stencil
623 +             .front.compare
624 +             .back.compare
625 + 
626 +     sg_sampler_desc
627 +         .compare
628 + 
629 +     The default compare func for depth- and stencil-tests is
630 +     SG_COMPAREFUNC_ALWAYS.
631 + 
632 +     The default compare func for samplers is SG_COMPAREFUNC_NEVER.
633 +/
634 enum CompareFunc {
635     Default,
636     Never,
637     Less,
638     Equal,
639     Less_equal,
640     Greater,
641     Not_equal,
642     Greater_equal,
643     Always,
644     Num,
645 }
646 /++
647 + sg_stencil_op
648 + 
649 +     The operation performed on a currently stored stencil-value when a
650 +     comparison test passes or fails. This is used when creating a pipeline
651 +     object in the following sg_pipeline_desc struct items:
652 + 
653 +     sg_pipeline_desc
654 +         .stencil
655 +             .front
656 +                 .fail_op
657 +                 .depth_fail_op
658 +                 .pass_op
659 +             .back
660 +                 .fail_op
661 +                 .depth_fail_op
662 +                 .pass_op
663 + 
664 +     The default value is SG_STENCILOP_KEEP.
665 +/
666 enum StencilOp {
667     Default,
668     Keep,
669     Zero,
670     Replace,
671     Incr_clamp,
672     Decr_clamp,
673     Invert,
674     Incr_wrap,
675     Decr_wrap,
676     Num,
677 }
678 /++
679 + sg_blend_factor
680 + 
681 +     The source and destination factors in blending operations.
682 +     This is used in the following members when creating a pipeline object:
683 + 
684 +     sg_pipeline_desc
685 +         .colors[i]
686 +             .blend
687 +                 .src_factor_rgb
688 +                 .dst_factor_rgb
689 +                 .src_factor_alpha
690 +                 .dst_factor_alpha
691 + 
692 +     The default value is SG_BLENDFACTOR_ONE for source
693 +     factors, and for the destination SG_BLENDFACTOR_ZERO if the associated
694 +     blend-op is ADD, SUBTRACT or REVERSE_SUBTRACT or SG_BLENDFACTOR_ONE
695 +     if the associated blend-op is MIN or MAX.
696 +/
697 enum BlendFactor {
698     Default,
699     Zero,
700     One,
701     Src_color,
702     One_minus_src_color,
703     Src_alpha,
704     One_minus_src_alpha,
705     Dst_color,
706     One_minus_dst_color,
707     Dst_alpha,
708     One_minus_dst_alpha,
709     Src_alpha_saturated,
710     Blend_color,
711     One_minus_blend_color,
712     Blend_alpha,
713     One_minus_blend_alpha,
714     Src1_color,
715     One_minus_src1_color,
716     Src1_alpha,
717     One_minus_src1_alpha,
718     Num,
719 }
720 /++
721 + sg_blend_op
722 + 
723 +     Describes how the source and destination values are combined in the
724 +     fragment blending operation. It is used in the following struct items
725 +     when creating a pipeline object:
726 + 
727 +     sg_pipeline_desc
728 +         .colors[i]
729 +             .blend
730 +                 .op_rgb
731 +                 .op_alpha
732 + 
733 +     The default value is SG_BLENDOP_ADD.
734 +/
735 enum BlendOp {
736     Default,
737     Add,
738     Subtract,
739     Reverse_subtract,
740     Min,
741     Max,
742     Num,
743 }
744 /++
745 + sg_color_mask
746 + 
747 +     Selects the active color channels when writing a fragment color to the
748 +     framebuffer. This is used in the members
749 +     sg_pipeline_desc.colors[i].write_mask when creating a pipeline object.
750 + 
751 +     The default colormask is SG_COLORMASK_RGBA (write all colors channels)
752 + 
753 +     NOTE: since the color mask value 0 is reserved for the default value
754 +     (SG_COLORMASK_RGBA), use SG_COLORMASK_NONE if all color channels
755 +     should be disabled.
756 +/
757 enum ColorMask {
758     Default = 0,
759     None = 16,
760     R = 1,
761     G = 2,
762     Rg = 3,
763     B = 4,
764     Rb = 5,
765     Gb = 6,
766     Rgb = 7,
767     A = 8,
768     Ra = 9,
769     Ga = 10,
770     Rga = 11,
771     Ba = 12,
772     Rba = 13,
773     Gba = 14,
774     Rgba = 15,
775 }
776 /++
777 + sg_load_action
778 + 
779 +     Defines the load action that should be performed at the start of a render pass:
780 + 
781 +     SG_LOADACTION_CLEAR:        clear the render target
782 +     SG_LOADACTION_LOAD:         load the previous content of the render target
783 +     SG_LOADACTION_DONTCARE:     leave the render target in an undefined state
784 + 
785 +     This is used in the sg_pass_action structure.
786 + 
787 +     The default load action for all pass attachments is SG_LOADACTION_CLEAR,
788 +     with the values rgba = { 0.5f, 0.5f, 0.5f, 1.0f }, depth=1.0f and stencil=0.
789 + 
790 +     If you want to override the default behaviour, it is important to not
791 +     only set the clear color, but the 'action' field as well (as long as this
792 +     is _SG_LOADACTION_DEFAULT, the value fields will be ignored).
793 +/
794 enum LoadAction {
795     Default,
796     Clear,
797     Load,
798     Dontcare,
799 }
800 /++
801 + sg_store_action
802 + 
803 +     Defines the store action that should be performed at the end of a render pass:
804 + 
805 +     SG_STOREACTION_STORE:       store the rendered content to the color attachment image
806 +     SG_STOREACTION_DONTCARE:    allows the GPU to discard the rendered content
807 +/
808 enum StoreAction {
809     Default,
810     Store,
811     Dontcare,
812 }
813 /++
814 + sg_pass_action
815 + 
816 +     The sg_pass_action struct defines the actions to be performed
817 +     at the start and end of a render pass.
818 + 
819 +     - at the start of the pass: whether the render attachments should be cleared,
820 +       loaded with their previous content, or start in an undefined state
821 +     - for clear operations: the clear value (color, depth, or stencil values)
822 +     - at the end of the pass: whether the rendering result should be
823 +       stored back into the render attachment or discarded
824 +/
825 extern(C) struct ColorAttachmentAction {
826     LoadAction load_action = LoadAction.Default;
827     StoreAction store_action = StoreAction.Default;
828     Color clear_value = {};
829 }
830 extern(C) struct DepthAttachmentAction {
831     LoadAction load_action = LoadAction.Default;
832     StoreAction store_action = StoreAction.Default;
833     float clear_value = 0.0f;
834 }
835 extern(C) struct StencilAttachmentAction {
836     LoadAction load_action = LoadAction.Default;
837     StoreAction store_action = StoreAction.Default;
838     ubyte clear_value = 0;
839 }
840 extern(C) struct PassAction {
841     ColorAttachmentAction[8] colors = [];
842     DepthAttachmentAction depth = {};
843     StencilAttachmentAction stencil = {};
844 }
845 /++
846 + sg_swapchain
847 + 
848 +     Used in sg_begin_pass() to provide details about an external swapchain
849 +     (pixel formats, sample count and backend-API specific render surface objects).
850 + 
851 +     The following information must be provided:
852 + 
853 +     - the width and height of the swapchain surfaces in number of pixels,
854 +     - the pixel format of the render- and optional msaa-resolve-surface
855 +     - the pixel format of the optional depth- or depth-stencil-surface
856 +     - the MSAA sample count for the render and depth-stencil surface
857 + 
858 +     If the pixel formats and MSAA sample counts are left zero-initialized,
859 +     their defaults are taken from the sg_environment struct provided in the
860 +     sg_setup() call.
861 + 
862 +     The width and height *must* be > 0.
863 + 
864 +     Additionally the following backend API specific objects must be passed in
865 +     as 'type erased' void pointers:
866 + 
867 +     GL:
868 +         - on all GL backends, a GL framebuffer object must be provided. This
869 +           can be zero for the default framebuffer.
870 + 
871 +     D3D11:
872 +         - an ID3D11RenderTargetView for the rendering surface, without
873 +           MSAA rendering this surface will also be displayed
874 +         - an optional ID3D11DepthStencilView for the depth- or depth/stencil
875 +           buffer surface
876 +         - when MSAA rendering is used, another ID3D11RenderTargetView
877 +           which serves as MSAA resolve target and will be displayed
878 + 
879 +     WebGPU (same as D3D11, except different types)
880 +         - a WGPUTextureView for the rendering surface, without
881 +           MSAA rendering this surface will also be displayed
882 +         - an optional WGPUTextureView for the depth- or depth/stencil
883 +           buffer surface
884 +         - when MSAA rendering is used, another WGPUTextureView
885 +           which serves as MSAA resolve target and will be displayed
886 + 
887 +     Metal (NOTE that the roles of provided surfaces is slightly different
888 +     than on D3D11 or WebGPU in case of MSAA vs non-MSAA rendering):
889 + 
890 +         - A current CAMetalDrawable (NOT an MTLDrawable!) which will be presented.
891 +           This will either be rendered to directly (if no MSAA is used), or serve
892 +           as MSAA-resolve target.
893 +         - an optional MTLTexture for the depth- or depth-stencil buffer
894 +         - an optional multisampled MTLTexture which serves as intermediate
895 +           rendering surface which will then be resolved into the
896 +           CAMetalDrawable.
897 + 
898 +     NOTE that for Metal you must use an ObjC __bridge cast to
899 +     properly tunnel the ObjC object id through a C void*, e.g.:
900 + 
901 +         swapchain.metal.current_drawable = (__bridge const void*) [mtkView currentDrawable];
902 + 
903 +     On all other backends you shouldn't need to mess with the reference count.
904 + 
905 +     It's a good practice to write a helper function which returns an initialized
906 +     sg_swapchain struct, which can then be plugged directly into
907 +     sg_pass.swapchain. Look at the function sglue_swapchain() in the sokol_glue.h
908 +     as an example.
909 +/
910 extern(C) struct MetalSwapchain {
911     const(void)* current_drawable = null;
912     const(void)* depth_stencil_texture = null;
913     const(void)* msaa_color_texture = null;
914 }
915 extern(C) struct D3d11Swapchain {
916     const(void)* render_view = null;
917     const(void)* resolve_view = null;
918     const(void)* depth_stencil_view = null;
919 }
920 extern(C) struct WgpuSwapchain {
921     const(void)* render_view = null;
922     const(void)* resolve_view = null;
923     const(void)* depth_stencil_view = null;
924 }
925 extern(C) struct VulkanSwapchain {
926     const(void)* render_image = null;
927     const(void)* render_view = null;
928     const(void)* resolve_image = null;
929     const(void)* resolve_view = null;
930     const(void)* depth_stencil_image = null;
931     const(void)* depth_stencil_view = null;
932     const(void)* render_finished_semaphore = null;
933     const(void)* present_complete_semaphore = null;
934 }
935 extern(C) struct GlSwapchain {
936     uint framebuffer = 0;
937 }
938 extern(C) struct Swapchain {
939     int width = 0;
940     int height = 0;
941     int sample_count = 0;
942     PixelFormat color_format = PixelFormat.Default;
943     PixelFormat depth_format = PixelFormat.Default;
944     MetalSwapchain metal = {};
945     D3d11Swapchain d3d11 = {};
946     WgpuSwapchain wgpu = {};
947     VulkanSwapchain vulkan = {};
948     GlSwapchain gl = {};
949 }
950 /++
951 + sg_attachments
952 + 
953 +     Used in sg_pass to provide render pass attachment views. Each
954 +     type of pass attachment has it corresponding view type:
955 + 
956 +     sg_attachments.colors[]:
957 +         populate with color-attachment views, e.g.:
958 + 
959 +         sg_make_view(&(sg_view_desc){
960 +             .color_attachment = { ... },
961 +         });
962 + 
963 +     sg_attachments.resolves[]:
964 +         populate with resolve-attachment views, e.g.:
965 + 
966 +         sg_make_view(&(sg_view_desc){
967 +             .resolve_attachment = { ... },
968 +         });
969 + 
970 +     sg_attachments.depth_stencil:
971 +         populate with depth-stencil-attachment views, e.g.:
972 + 
973 +         sg_make_view(&(sg_view_desc){
974 +             .depth_stencil_attachment = { ... },
975 +         });
976 +/
977 extern(C) struct Attachments {
978     View[8] colors = [];
979     View[8] resolves = [];
980     View depth_stencil = {};
981 }
982 /++
983 + sg_pass
984 + 
985 +     The sg_pass structure is passed as argument into the sg_begin_pass()
986 +     function.
987 + 
988 +     For a swapchain render pass, provide an sg_pass_action and sg_swapchain
989 +     struct (for instance via the sglue_swapchain() helper function from
990 +     sokol_glue.h):
991 + 
992 +         sg_begin_pass(&(sg_pass){
993 +             .action = { ... },
994 +             .swapchain = sglue_swapchain(),
995 +         });
996 + 
997 +     For an offscreen render pass, provide an sg_pass_action struct with
998 +     attachment view objects:
999 + 
1000 +         sg_begin_pass(&(sg_pass){
1001 +             .action = { ... },
1002 +             .attachments = {
1003 +                 .colors = { ... },
1004 +                 .resolves = { ... },
1005 +                 .depth_stencil = ...,
1006 +             },
1007 +         });
1008 + 
1009 +     You can also omit the .action object to get default pass action behaviour
1010 +     (clear to color=grey, depth=1 and stencil=0).
1011 + 
1012 +     For a compute pass, just set the sg_pass.compute boolean to true:
1013 + 
1014 +         sg_begin_pass(&(sg_pass){ .compute = true });
1015 +/
1016 extern(C) struct Pass {
1017     uint _start_canary = 0;
1018     bool compute = false;
1019     PassAction action = {};
1020     Attachments attachments = {};
1021     Swapchain swapchain = {};
1022     const(char)* label = null;
1023     uint _end_canary = 0;
1024 }
1025 /++
1026 + sg_bindings
1027 + 
1028 +     The sg_bindings structure defines the resource bindings for
1029 +     the next draw call.
1030 + 
1031 +     To update the resource bindings, call sg_apply_bindings() with
1032 +     a pointer to a populated sg_bindings struct. Note that
1033 +     sg_apply_bindings() must be called after sg_apply_pipeline()
1034 +     and that bindings are not preserved across sg_apply_pipeline()
1035 +     calls, even when the new pipeline uses the same 'bindings layout'.
1036 + 
1037 +     A resource binding struct contains:
1038 + 
1039 +     - 1..N vertex buffers
1040 +     - 1..N vertex buffer offsets
1041 +     - 0..1 index buffer
1042 +     - 0..1 index buffer offset
1043 +     - 0..N resource views (texture-, storage-image, storage-buffer-views)
1044 +     - 0..N samplers
1045 + 
1046 +     Where 'N' is defined in the following constants:
1047 + 
1048 +     - SG_MAX_VERTEXBUFFER_BINDSLOTS
1049 +     - SG_MAX_VIEW_BINDSLOTS
1050 +     - SG_MAX_SAMPLER_BINDSLOTS
1051 + 
1052 +     Note that inside compute passes vertex- and index-buffer-bindings are
1053 +     disallowed.
1054 + 
1055 +     When using sokol-shdc for shader authoring, the `layout(binding=N)`
1056 +     for texture-, storage-image- and storage-buffer-bindings directly
1057 +     maps to the views-array index, for instance the following vertex-
1058 +     and fragment-shader interface for sokol-shdc:
1059 + 
1060 +         @vs vs
1061 +         layout(binding=0) uniform vs_params { ... };
1062 +         layout(binding=0) readonly buffer ssbo { ... };
1063 +         layout(binding=1) uniform texture2D vs_tex;
1064 +         layout(binding=0) uniform sampler vs_smp;
1065 +         ...
1066 +         @end
1067 + 
1068 +         @fs fs
1069 +         layout(binding=1) uniform fs_params { ... };
1070 +         layout(binding=2) uniform texture2D fs_tex;
1071 +         layout(binding=1) uniform sampler fs_smp;
1072 +         ...
1073 +         @end
1074 + 
1075 +     ...would map to the following sg_bindings struct:
1076 + 
1077 +         const sg_bindings bnd = {
1078 +             .vertex_buffers[0] = ...,
1079 +             .views[0] = ssbo_view,
1080 +             .views[1] = vs_tex_view,
1081 +             .views[2] = fs_tex_view,
1082 +             .samplers[0] = vs_smp,
1083 +             .samplers[1] = fs_smp,
1084 +         };
1085 + 
1086 +     ...alternatively you can use code-generated slot indices:
1087 + 
1088 +         const sg_bindings bnd = {
1089 +             .vertex_buffers[0] = ...,
1090 +             .views[VIEW_ssbo] = ssbo_view,
1091 +             .views[VIEW_vs_tex] = vs_tex_view,
1092 +             .views[VIEW_fs_tex] = fs_tex_view,
1093 +             .samplers[SMP_vs_smp] = vs_smp,
1094 +             .samplers[SMP_fs_smp] = fs_smp,
1095 +         };
1096 + 
1097 +     Resource bindslots for a specific shader/pipeline may have gaps, and an
1098 +     sg_bindings struct may have populated bind slots which are not used by a
1099 +     specific shader. This allows to use the same sg_bindings struct across
1100 +     different shader variants.
1101 + 
1102 +     When not using sokol-shdc, the bindslot indices in the sg_bindings
1103 +     struct need to match the per-binding reflection info slot indices
1104 +     in the sg_shader_desc struct (for details about that see the
1105 +     sg_shader_desc struct documentation).
1106 + 
1107 +     The optional buffer offsets can be used to put different unrelated
1108 +     chunks of vertex- and/or index-data into the same buffer objects.
1109 +/
1110 extern(C) struct Bindings {
1111     uint _start_canary = 0;
1112     Buffer[8] vertex_buffers = [];
1113     int[8] vertex_buffer_offsets = [0, 0, 0, 0, 0, 0, 0, 0];
1114     Buffer index_buffer = {};
1115     int index_buffer_offset = 0;
1116     View[32] views = [];
1117     Sampler[12] samplers = [];
1118     uint _end_canary = 0;
1119 }
1120 /++
1121 + sg_buffer_usage
1122 + 
1123 +     Describes how a buffer object is going to be used:
1124 + 
1125 +     .vertex_buffer (default: true)
1126 +         the buffer will be bound as vertex buffer via sg_bindings.vertex_buffers[]
1127 +     .index_buffer (default: false)
1128 +         the buffer will be bound as index buffer via sg_bindings.index_buffer
1129 +     .storage_buffer (default: false)
1130 +         the buffer will be bound as storage buffer via storage-buffer-view
1131 +         in sg_bindings.views[]
1132 +     .immutable (default: true)
1133 +         the buffer content will never be updated from the CPU side (but
1134 +         may be written to by a compute shader)
1135 +     .dynamic_update (default: false)
1136 +         the buffer content will be infrequently updated from the CPU side
1137 +     .stream_upate (default: false)
1138 +         the buffer content will be updated each frame from the CPU side
1139 +/
1140 extern(C) struct BufferUsage {
1141     bool vertex_buffer = false;
1142     bool index_buffer = false;
1143     bool storage_buffer = false;
1144     bool _immutable = false;
1145     bool dynamic_update = false;
1146     bool stream_update = false;
1147 }
1148 /++
1149 + sg_buffer_desc
1150 + 
1151 +     Creation parameters for sg_buffer objects, used in the sg_make_buffer() call.
1152 + 
1153 +     The default configuration is:
1154 + 
1155 +     .size:      0       (*must* be >0 for buffers without data)
1156 +     .usage      { .vertex_buffer = true, .immutable = true }
1157 +     .data.ptr   0       (*must* be valid for immutable buffers without storage buffer usage)
1158 +     .data.size  0       (*must* be > 0 for immutable buffers without storage buffer usage)
1159 +     .label      0       (optional string label)
1160 + 
1161 +     For immutable buffers which are initialized with initial data,
1162 +     keep the .size item zero-initialized, and set the size together with the
1163 +     pointer to the initial data in the .data item.
1164 + 
1165 +     For immutable or mutable buffers without initial data, keep the .data item
1166 +     zero-initialized, and set the buffer size in the .size item instead.
1167 + 
1168 +     You can also set both size values, but currently both size values must
1169 +     be identical (this may change in the future when the dynamic resource
1170 +     management may become more flexible).
1171 + 
1172 +     NOTE: Immutable buffers without storage-buffer-usage *must* be created
1173 +     with initial content, this restriction doesn't apply to storage buffer usage,
1174 +     because storage buffers may also get their initial content by running
1175 +     a compute shader on them.
1176 + 
1177 +     NOTE: Buffers without initial data will have undefined content, e.g.
1178 +     do *not* expect the buffer to be zero-initialized!
1179 + 
1180 +     ADVANCED TOPIC: Injecting native 3D-API buffers:
1181 + 
1182 +     The following struct members allow to inject your own GL, Metal
1183 +     or D3D11 buffers into sokol_gfx:
1184 + 
1185 +     .gl_buffers[SG_NUM_INFLIGHT_FRAMES]
1186 +     .mtl_buffers[SG_NUM_INFLIGHT_FRAMES]
1187 +     .d3d11_buffer
1188 + 
1189 +     You must still provide all other struct items except the .data item, and
1190 +     these must match the creation parameters of the native buffers you provide.
1191 +     For sg_buffer_desc.usage.immutable buffers, only provide a single native
1192 +     3D-API buffer, otherwise you need to provide SG_NUM_INFLIGHT_FRAMES buffers
1193 +     (only for GL and Metal, not D3D11). Providing multiple buffers for GL and
1194 +     Metal is necessary because sokol_gfx will rotate through them when calling
1195 +     sg_update_buffer() to prevent lock-stalls.
1196 + 
1197 +     Note that it is expected that immutable injected buffer have already been
1198 +     initialized with content, and the .content member must be 0!
1199 + 
1200 +     Also you need to call sg_reset_state_cache() after calling native 3D-API
1201 +     functions, and before calling any sokol_gfx function.
1202 +/
1203 extern(C) struct BufferDesc {
1204     uint _start_canary = 0;
1205     size_t size = 0;
1206     BufferUsage usage = {};
1207     Range data = {};
1208     const(char)* label = null;
1209     uint[2] gl_buffers = [0, 0];
1210     const(void)*[2] mtl_buffers = null;
1211     const(void)* d3d11_buffer = null;
1212     const(void)* wgpu_buffer = null;
1213     uint _end_canary = 0;
1214 }
1215 /++
1216 + sg_image_usage
1217 + 
1218 +     Describes the intended usage of an image object:
1219 + 
1220 +     .storage_image (default: false)
1221 +         the image can be used as parent resource of a storage-image-view,
1222 +         which allows compute shaders to write to the image in a compute
1223 +         pass (for read-only access in compute shaders bind the image
1224 +         via a texture view instead
1225 +     .color_attachment (default: false)
1226 +         the image can be used as parent resource of a color-attachment-view,
1227 +         which is then passed into sg_begin_pass via sg_pass.attachments.colors[]
1228 +         so that fragment shaders can render into the image
1229 +     .resolve_attachment (default: false)
1230 +         the image can be used as parent resource of a resolve-attachment-view,
1231 +         which is then passed into sg_begin_pass via sg_pass.attachments.resolves[]
1232 +         as target for an MSAA-resolve operation in sg_end_pass()
1233 +     .depth_stencil_attachment (default: false)
1234 +         the image can be used as parent resource of a depth-stencil-attachmnet-view
1235 +         which is then passes into sg_begin_pass via sg_pass.attachments.depth_stencil
1236 +         as depth-stencil-buffer
1237 +     .immutable (default: true)
1238 +         the image content cannot be updated from the CPU side
1239 +         (but may be updated by the GPU in a render- or compute-pass)
1240 +     .dynamic_update (default: false)
1241 +         the image content is updated infrequently by the CPU
1242 +     .stream_update (default: false)
1243 +         the image content is updated each frame by the CPU via
1244 + 
1245 +     Note that creating a texture view from the image to be used for
1246 +     texture-sampling in vertex-, fragment- or compute-shaders
1247 +     is always implicitly allowed.
1248 +/
1249 extern(C) struct ImageUsage {
1250     bool storage_image = false;
1251     bool color_attachment = false;
1252     bool resolve_attachment = false;
1253     bool depth_stencil_attachment = false;
1254     bool _immutable = false;
1255     bool dynamic_update = false;
1256     bool stream_update = false;
1257 }
1258 /++
1259 + sg_view_type
1260 + 
1261 +     Allows to query the type of a view object via the function sg_query_view_type()
1262 +/
1263 enum ViewType {
1264     Invalid,
1265     Storagebuffer,
1266     Storageimage,
1267     Texture,
1268     Colorattachment,
1269     Resolveattachment,
1270     Depthstencilattachment,
1271 }
1272 /++
1273 + sg_image_data
1274 + 
1275 +     Defines the content of an image through an array of sg_range structs, each
1276 +     range pointing to the pixel data for one mip-level. For array-, cubemap- and
1277 +     3D-images each mip-level contains all slice-surfaces for that mip-level in a
1278 +     single tightly packed memory block.
1279 + 
1280 +     The size of a single surface in a mip-level for a regular 2D texture
1281 +     can be computed via:
1282 + 
1283 +         sg_query_surface_pitch(pixel_format, mip_width, mip_height, 1);
1284 + 
1285 +     For array- and 3d-images the size of a single miplevel is:
1286 + 
1287 +         num_slices * sg_query_surface_pitch(pixel_format, mip_width, mip_height, 1);
1288 + 
1289 +     For cubemap-images the size of a single mip-level is:
1290 + 
1291 +         6 * sg_query_surface_pitch(pixel_format, mip_width, mip_height, 1);
1292 + 
1293 +     The order of cubemap-faces is in a mip-level data chunk is:
1294 + 
1295 +         [0] => +X
1296 +         [1] => -X
1297 +         [2] => +Y
1298 +         [3] => -Y
1299 +         [4] => +Z
1300 +         [5] => -Z
1301 +/
1302 extern(C) struct ImageData {
1303     Range[16] mip_levels = [];
1304 }
1305 /++
1306 + sg_image_desc
1307 + 
1308 +     Creation parameters for sg_image objects, used in the sg_make_image() call.
1309 + 
1310 +     The default configuration is:
1311 + 
1312 +     .type               SG_IMAGETYPE_2D
1313 +     .usage              .immutable = true
1314 +     .width              0 (must be set to >0)
1315 +     .height             0 (must be set to >0)
1316 +     .num_slices         1 (3D textures: depth; array textures: number of layers)
1317 +     .num_mipmaps        1
1318 +     .pixel_format       SG_PIXELFORMAT_RGBA8 for textures, or sg_desc.environment.defaults.color_format for render targets
1319 +     .sample_count       1 for textures, or sg_desc.environment.defaults.sample_count for render targets
1320 +     .data               an sg_image_data struct to define the initial content
1321 +     .label              0 (optional string label for trace hooks)
1322 + 
1323 +     Q: Why is the default sample_count for render targets identical with the
1324 +     "default sample count" from sg_desc.environment.defaults.sample_count?
1325 + 
1326 +     A: So that it matches the default sample count in pipeline objects. Even
1327 +     though it is a bit strange/confusing that offscreen render targets by default
1328 +     get the same sample count as 'default swapchains', but it's better that
1329 +     an offscreen render target created with default parameters matches
1330 +     a pipeline object created with default parameters.
1331 + 
1332 +     NOTE:
1333 + 
1334 +     Regular images used as texture binding with usage.immutable must be fully
1335 +     initialized by providing a valid .data member which points to initialization
1336 +     data.
1337 + 
1338 +     Images with usage.*_attachment or usage.storage_image must
1339 +     *not* be created with initial content. Be aware that the initial
1340 +     content of pass attachment and storage images is undefined
1341 +     (not guaranteed to be zeroed).
1342 + 
1343 +     ADVANCED TOPIC: Injecting native 3D-API textures:
1344 + 
1345 +     The following struct members allow to inject your own GL, Metal or D3D11
1346 +     textures into sokol_gfx:
1347 + 
1348 +     .gl_textures[SG_NUM_INFLIGHT_FRAMES]
1349 +     .mtl_textures[SG_NUM_INFLIGHT_FRAMES]
1350 +     .d3d11_texture
1351 +     .wgpu_texture
1352 + 
1353 +     For GL, you can also specify the texture target or leave it empty to use
1354 +     the default texture target for the image type (GL_TEXTURE_2D for
1355 +     SG_IMAGETYPE_2D etc)
1356 + 
1357 +     The same rules apply as for injecting native buffers (see sg_buffer_desc
1358 +     documentation for more details).
1359 +/
1360 extern(C) struct ImageDesc {
1361     uint _start_canary = 0;
1362     ImageType type = ImageType.Default;
1363     ImageUsage usage = {};
1364     int width = 0;
1365     int height = 0;
1366     int num_slices = 0;
1367     int num_mipmaps = 0;
1368     PixelFormat pixel_format = PixelFormat.Default;
1369     int sample_count = 0;
1370     ImageData data = {};
1371     const(char)* label = null;
1372     uint[2] gl_textures = [0, 0];
1373     uint gl_texture_target = 0;
1374     const(void)*[2] mtl_textures = null;
1375     const(void)* d3d11_texture = null;
1376     const(void)* wgpu_texture = null;
1377     uint _end_canary = 0;
1378 }
1379 /++
1380 + sg_sampler_desc
1381 + 
1382 +     Creation parameters for sg_sampler objects, used in the sg_make_sampler() call
1383 + 
1384 +     .min_filter:        SG_FILTER_NEAREST
1385 +     .mag_filter:        SG_FILTER_NEAREST
1386 +     .mipmap_filter      SG_FILTER_NEAREST
1387 +     .wrap_u:            SG_WRAP_REPEAT
1388 +     .wrap_v:            SG_WRAP_REPEAT
1389 +     .wrap_w:            SG_WRAP_REPEAT (only SG_IMAGETYPE_3D)
1390 +     .min_lod            0.0f
1391 +     .max_lod            FLT_MAX
1392 +     .border_color       SG_BORDERCOLOR_OPAQUE_BLACK
1393 +     .compare            SG_COMPAREFUNC_NEVER
1394 +     .max_anisotropy     1 (must be 1..16)
1395 +/
1396 extern(C) struct SamplerDesc {
1397     uint _start_canary = 0;
1398     Filter min_filter = Filter.Default;
1399     Filter mag_filter = Filter.Default;
1400     Filter mipmap_filter = Filter.Default;
1401     Wrap wrap_u = Wrap.Default;
1402     Wrap wrap_v = Wrap.Default;
1403     Wrap wrap_w = Wrap.Default;
1404     float min_lod = 0.0f;
1405     float max_lod = 0.0f;
1406     BorderColor border_color = BorderColor.Default;
1407     CompareFunc compare = CompareFunc.Default;
1408     uint max_anisotropy = 0;
1409     const(char)* label = null;
1410     uint gl_sampler = 0;
1411     const(void)* mtl_sampler = null;
1412     const(void)* d3d11_sampler = null;
1413     const(void)* wgpu_sampler = null;
1414     uint _end_canary = 0;
1415 }
1416 /++
1417 + sg_shader_desc
1418 + 
1419 +     Used as parameter of sg_make_shader() to create a shader object which
1420 +     communicates shader source or bytecode and shader interface
1421 +     reflection information to sokol-gfx.
1422 + 
1423 +     If you use sokol-shdc you can ignore the following information since
1424 +     the sg_shader_desc struct will be code-generated.
1425 + 
1426 +     Otherwise you need to provide the following information to the
1427 +     sg_make_shader() call:
1428 + 
1429 +     - a vertex- and fragment-shader function:
1430 +         - the shader source or bytecode
1431 +         - an optional entry point name
1432 +         - for D3D11: an optional compile target when source code is provided
1433 +           (the defaults are "vs_4_0" and "ps_4_0")
1434 + 
1435 +     - ...or alternatively, a compute function:
1436 +         - the shader source or bytecode
1437 +         - an optional entry point name
1438 +         - for D3D11: an optional compile target when source code is provided
1439 +           (the default is "cs_5_0")
1440 + 
1441 +     - vertex attributes required by some backends (not for compute shaders):
1442 +         - the vertex attribute base type (undefined, float, signed int, unsigned int),
1443 +           this information is only used in the validation layer to check that the
1444 +           pipeline object vertex formats are compatible with the input vertex attribute
1445 +           type used in the vertex shader. NOTE that the default base type
1446 +           'undefined' skips the validation layer check.
1447 +         - for the GL backend: optional vertex attribute names used for name lookup
1448 +         - for the D3D11 backend: semantic names and indices
1449 + 
1450 +     - only for compute shaders on the Metal backend:
1451 +         - the workgroup size aka 'threads per thread-group'
1452 + 
1453 +           In other 3D APIs this is declared in the shader code:
1454 +             - GLSL: `layout(local_size_x=x, local_size_y=y, local_size_y=z) in;`
1455 +             - HLSL: `[numthreads(x, y, z)]`
1456 +             - WGSL: `@workgroup_size(x, y, z)`
1457 +           ...but in Metal the workgroup size is declared on the CPU side
1458 + 
1459 +     - reflection information for each uniform block binding used by the shader:
1460 +         - the shader stage the uniform block appears in (SG_SHADERSTAGE_*)
1461 +         - the size in bytes of the uniform block
1462 +         - backend-specific bindslots:
1463 +             - HLSL: the constant buffer register `register(b0..7)`
1464 +             - MSL: the buffer attribute `[[buffer(0..7)]]`
1465 +             - WGSL: the binding in `@group(0) @binding(0..15)`
1466 +         - GLSL only: a description of the uniform block interior
1467 +             - the memory layout standard (SG_UNIFORMLAYOUT_*)
1468 +             - for each member in the uniform block:
1469 +                 - the member type (SG_UNIFORM_*)
1470 +                 - if the member is an array, the array count
1471 +                 - the member name
1472 + 
1473 +     - reflection information for each texture-, storage-buffer and
1474 +       storage-image bindings by the shader, each with an associated
1475 +       view type:
1476 +         - texture bindings => texture views
1477 +         - storage-buffer bindings => storage-buffer views
1478 +         - storage-image bindings => storage-image views
1479 + 
1480 +     - texture bindings must provide the following information:
1481 +         - the shader stage the texture binding appears in (SG_SHADERSTAGE_*)
1482 +         - the image type (SG_IMAGETYPE_*)
1483 +         - the image-sample type (SG_IMAGESAMPLETYPE_*)
1484 +         - whether the texture is multisampled
1485 +         - backend specific bindslots:
1486 +             - HLSL: the texture register `register(t0..31)`
1487 +             - MSL: the texture attribute `[[texture(0..31)]]`
1488 +             - WGSL: the binding in `@group(1) @binding(0..127)`
1489 + 
1490 +     - storage-buffer bindings must provide the following information:
1491 +         - the shader stage the storage buffer appears in (SG_SHADERSTAGE_*)
1492 +         - whether the storage buffer is readonly
1493 +         - backend specific bindslots:
1494 +             - HLSL:
1495 +                 - for storage buffer bindings: `register(t0..31)`
1496 +                 - for read/write storage buffer bindings: `register(u0..31)`
1497 +             - MSL: the buffer attribute `[[buffer(8..23)]]`
1498 +             - WGSL: the binding in `@group(1) @binding(0..127)`
1499 +             - GL: the binding in `layout(binding=0..sg_limits.max_storage_buffer_bindings_per_stage)`
1500 + 
1501 +     - storage-image bindings must provide the following information:
1502 +         - the shader stage (*must* be SG_SHADERSTAGE_COMPUTE)
1503 +         - whether the storage image is writeonly or readwrite (for readonly
1504 +           access use a regular texture binding instead)
1505 +         - the image type expected by the shader (SG_IMAGETYPE_*)
1506 +         - the access pixel format expected by the shader (SG_PIXELFORMAT_*),
1507 +           note that only a subset of pixel formats is allowed for storage image
1508 +           bindings
1509 +         - backend specific bindslots:
1510 +             - HLSL: the UAV register `register(u0..31)`
1511 +             - MSL: the texture attribute `[[texture(0..31)]]`
1512 +             - WGSL: the binding in `@group(1) @binding(0..127)`
1513 +             - GLSL: the binding in `layout(binding=0..sg_imits.max_storage_buffer_bindings_per_stage, [access_format])`
1514 + 
1515 +     - reflection information for each sampler used by the shader:
1516 +         - the shader stage the sampler appears in (SG_SHADERSTAGE_*)
1517 +         - the sampler type (SG_SAMPLERTYPE_*)
1518 +         - backend specific bindslots:
1519 +             - HLSL: the sampler register `register(s0..11)`
1520 +             - MSL: the sampler attribute `[[sampler(0..11)]]`
1521 +             - WGSL: the binding in `@group(0) @binding(0..127)`
1522 + 
1523 +     - reflection information for each texture-sampler pair used by
1524 +       the shader:
1525 +         - the shader stage (SG_SHADERSTAGE_*)
1526 +         - the texture's array index in the sg_shader_desc.views[] array
1527 +         - the sampler's array index in the sg_shader_desc.samplers[] array
1528 +         - GLSL only: the name of the combined image-sampler object
1529 + 
1530 +     The number and order of items in the sg_shader_desc.attrs[]
1531 +     array corresponds to the items in sg_pipeline_desc.layout.attrs.
1532 + 
1533 +         - sg_shader_desc.attrs[N] => sg_pipeline_desc.layout.attrs[N]
1534 + 
1535 +     NOTE that vertex attribute indices currently cannot have gaps.
1536 + 
1537 +     The items index in the sg_shader_desc.uniform_blocks[] array corresponds
1538 +     to the ub_slot arg in sg_apply_uniforms():
1539 + 
1540 +         - sg_shader_desc.uniform_blocks[N] => sg_apply_uniforms(N, ...)
1541 + 
1542 +     The items in the sg_shader_desc.views[] array directly map to
1543 +     the views in the sg_bindings.views[] array!
1544 + 
1545 +     For all GL backends, shader source-code must be provided. For D3D11 and Metal,
1546 +     either shader source-code or byte-code can be provided.
1547 + 
1548 +     NOTE that the uniform-block, view and sampler arrays may have gaps. This
1549 +     allows to use the same sg_bindings struct for different but related
1550 +     shader variations.
1551 + 
1552 +     For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded
1553 +     on demand. If this fails, shader creation will fail. When compiling HLSL
1554 +     source code, you can provide an optional target string via
1555 +     sg_shader_stage_desc.d3d11_target, the default target is "vs_4_0" for the
1556 +     vertex shader stage and "ps_4_0" for the pixel shader stage.
1557 +     You may optionally provide the file path to enable the default #include handler
1558 +     behavior when compiling source code.
1559 +/
1560 enum ShaderStage {
1561     None,
1562     Vertex,
1563     Fragment,
1564     Compute,
1565 }
1566 extern(C) struct ShaderFunction {
1567     const(char)* source = null;
1568     Range bytecode = {};
1569     const(char)* entry = null;
1570     const(char)* d3d11_target = null;
1571     const(char)* d3d11_filepath = null;
1572 }
1573 enum ShaderAttrBaseType {
1574     Undefined,
1575     Float,
1576     Sint,
1577     Uint,
1578 }
1579 extern(C) struct ShaderVertexAttr {
1580     ShaderAttrBaseType base_type = ShaderAttrBaseType.Undefined;
1581     const(char)* glsl_name = null;
1582     const(char)* hlsl_sem_name = null;
1583     ubyte hlsl_sem_index = 0;
1584 }
1585 extern(C) struct GlslShaderUniform {
1586     UniformType type = UniformType.Invalid;
1587     ushort array_count = 0;
1588     const(char)* glsl_name = null;
1589 }
1590 extern(C) struct ShaderUniformBlock {
1591     ShaderStage stage = ShaderStage.None;
1592     uint size = 0;
1593     ubyte hlsl_register_b_n = 0;
1594     ubyte msl_buffer_n = 0;
1595     ubyte wgsl_group0_binding_n = 0;
1596     ubyte spirv_set0_binding_n = 0;
1597     UniformLayout layout = UniformLayout.Default;
1598     GlslShaderUniform[16] glsl_uniforms = [];
1599 }
1600 extern(C) struct ShaderTextureView {
1601     ShaderStage stage = ShaderStage.None;
1602     ImageType image_type = ImageType.Default;
1603     ImageSampleType sample_type = ImageSampleType.Default;
1604     bool multisampled = false;
1605     ubyte hlsl_register_t_n = 0;
1606     ubyte msl_texture_n = 0;
1607     ubyte wgsl_group1_binding_n = 0;
1608     ubyte spirv_set1_binding_n = 0;
1609 }
1610 extern(C) struct ShaderStorageBufferView {
1611     ShaderStage stage = ShaderStage.None;
1612     bool readonly = false;
1613     ubyte hlsl_register_t_n = 0;
1614     ubyte hlsl_register_u_n = 0;
1615     ubyte msl_buffer_n = 0;
1616     ubyte wgsl_group1_binding_n = 0;
1617     ubyte spirv_set1_binding_n = 0;
1618     ubyte glsl_binding_n = 0;
1619 }
1620 extern(C) struct ShaderStorageImageView {
1621     ShaderStage stage = ShaderStage.None;
1622     ImageType image_type = ImageType.Default;
1623     PixelFormat access_format = PixelFormat.Default;
1624     bool writeonly = false;
1625     ubyte hlsl_register_u_n = 0;
1626     ubyte msl_texture_n = 0;
1627     ubyte wgsl_group1_binding_n = 0;
1628     ubyte spirv_set1_binding_n = 0;
1629     ubyte glsl_binding_n = 0;
1630 }
1631 extern(C) struct ShaderView {
1632     ShaderTextureView texture = {};
1633     ShaderStorageBufferView storage_buffer = {};
1634     ShaderStorageImageView storage_image = {};
1635 }
1636 extern(C) struct ShaderSampler {
1637     ShaderStage stage = ShaderStage.None;
1638     SamplerType sampler_type = SamplerType.Default;
1639     ubyte hlsl_register_s_n = 0;
1640     ubyte msl_sampler_n = 0;
1641     ubyte wgsl_group1_binding_n = 0;
1642     ubyte spirv_set1_binding_n = 0;
1643 }
1644 extern(C) struct ShaderTextureSamplerPair {
1645     ShaderStage stage = ShaderStage.None;
1646     ubyte view_slot = 0;
1647     ubyte sampler_slot = 0;
1648     const(char)* glsl_name = null;
1649 }
1650 extern(C) struct MtlShaderThreadsPerThreadgroup {
1651     int x = 0;
1652     int y = 0;
1653     int z = 0;
1654 }
1655 extern(C) struct ShaderDesc {
1656     uint _start_canary = 0;
1657     ShaderFunction vertex_func = {};
1658     ShaderFunction fragment_func = {};
1659     ShaderFunction compute_func = {};
1660     ShaderVertexAttr[16] attrs = [];
1661     ShaderUniformBlock[8] uniform_blocks = [];
1662     ShaderView[32] views = [];
1663     ShaderSampler[12] samplers = [];
1664     ShaderTextureSamplerPair[32] texture_sampler_pairs = [];
1665     MtlShaderThreadsPerThreadgroup mtl_threads_per_threadgroup = {};
1666     const(char)* label = null;
1667     uint _end_canary = 0;
1668 }
1669 /++
1670 + sg_pipeline_desc
1671 + 
1672 +     The sg_pipeline_desc struct defines all creation parameters for an
1673 +     sg_pipeline object, used as argument to the sg_make_pipeline() function:
1674 + 
1675 +     Pipeline objects come in two flavours:
1676 + 
1677 +     - render pipelines for use in render passes
1678 +     - compute pipelines for use in compute passes
1679 + 
1680 +     A compute pipeline only requires a compute shader object but no
1681 +     'render state', while a render pipeline requires a vertex/fragment shader
1682 +     object and additional render state declarations:
1683 + 
1684 +     - the vertex layout for all input vertex buffers
1685 +     - a shader object
1686 +     - the 3D primitive type (points, lines, triangles, ...)
1687 +     - the index type (none, 16- or 32-bit)
1688 +     - all the fixed-function-pipeline state (depth-, stencil-, blend-state, etc...)
1689 + 
1690 +     If the vertex data has no gaps between vertex components, you can omit
1691 +     the .layout.buffers[].stride and layout.attrs[].offset items (leave them
1692 +     default-initialized to 0), sokol-gfx will then compute the offsets and
1693 +     strides from the vertex component formats (.layout.attrs[].format).
1694 +     Please note that ALL vertex attribute offsets must be 0 in order for the
1695 +     automatic offset computation to kick in.
1696 + 
1697 +     Note that if you use vertex-pulling from storage buffers instead of
1698 +     fixed-function vertex input you can simply omit the entire nested .layout
1699 +     struct.
1700 + 
1701 +     The default configuration is as follows:
1702 + 
1703 +     .compute:               false (must be set to true for a compute pipeline)
1704 +     .shader:                0 (must be initialized with a valid sg_shader id!)
1705 +     .layout:
1706 +         .buffers[]:         vertex buffer layouts
1707 +             .stride:        0 (if no stride is given it will be computed)
1708 +             .step_func      SG_VERTEXSTEP_PER_VERTEX
1709 +             .step_rate      1
1710 +         .attrs[]:           vertex attribute declarations
1711 +             .buffer_index   0 the vertex buffer bind slot
1712 +             .offset         0 (offsets can be omitted if the vertex layout has no gaps)
1713 +             .format         SG_VERTEXFORMAT_INVALID (must be initialized!)
1714 +     .depth:
1715 +         .pixel_format:      sg_desc.context.depth_format
1716 +         .compare:           SG_COMPAREFUNC_ALWAYS
1717 +         .write_enabled:     false
1718 +         .bias:              0.0f
1719 +         .bias_slope_scale:  0.0f
1720 +         .bias_clamp:        0.0f
1721 +     .stencil:
1722 +         .enabled:           false
1723 +         .front/back:
1724 +             .compare:       SG_COMPAREFUNC_ALWAYS
1725 +             .fail_op:       SG_STENCILOP_KEEP
1726 +             .depth_fail_op: SG_STENCILOP_KEEP
1727 +             .pass_op:       SG_STENCILOP_KEEP
1728 +         .read_mask:         0
1729 +         .write_mask:        0
1730 +         .ref:               0
1731 +     .color_count            1
1732 +     .colors[0..color_count]
1733 +         .pixel_format       sg_desc.context.color_format
1734 +         .write_mask:        SG_COLORMASK_RGBA
1735 +         .blend:
1736 +             .enabled:           false
1737 +             .src_factor_rgb:    SG_BLENDFACTOR_ONE
1738 +             .dst_factor_rgb:    SG_BLENDFACTOR_ZERO
1739 +             .op_rgb:            SG_BLENDOP_ADD
1740 +             .src_factor_alpha:  SG_BLENDFACTOR_ONE
1741 +             .dst_factor_alpha:  SG_BLENDFACTOR_ZERO
1742 +             .op_alpha:          SG_BLENDOP_ADD
1743 +     .primitive_type:            SG_PRIMITIVETYPE_TRIANGLES
1744 +     .index_type:                SG_INDEXTYPE_NONE
1745 +     .cull_mode:                 SG_CULLMODE_NONE
1746 +     .face_winding:              SG_FACEWINDING_CW
1747 +     .sample_count:              sg_desc.context.sample_count
1748 +     .blend_color:               (sg_color) { 0.0f, 0.0f, 0.0f, 0.0f }
1749 +     .alpha_to_coverage_enabled: false
1750 +     .label  0       (optional string label for trace hooks)
1751 +/
1752 extern(C) struct VertexBufferLayoutState {
1753     int stride = 0;
1754     VertexStep step_func = VertexStep.Default;
1755     int step_rate = 0;
1756 }
1757 extern(C) struct VertexAttrState {
1758     int buffer_index = 0;
1759     int offset = 0;
1760     VertexFormat format = VertexFormat.Invalid;
1761 }
1762 extern(C) struct VertexLayoutState {
1763     VertexBufferLayoutState[8] buffers = [];
1764     VertexAttrState[16] attrs = [];
1765 }
1766 extern(C) struct StencilFaceState {
1767     CompareFunc compare = CompareFunc.Default;
1768     StencilOp fail_op = StencilOp.Default;
1769     StencilOp depth_fail_op = StencilOp.Default;
1770     StencilOp pass_op = StencilOp.Default;
1771 }
1772 extern(C) struct StencilState {
1773     bool enabled = false;
1774     StencilFaceState front = {};
1775     StencilFaceState back = {};
1776     ubyte read_mask = 0;
1777     ubyte write_mask = 0;
1778     ubyte _ref = 0;
1779 }
1780 extern(C) struct DepthState {
1781     PixelFormat pixel_format = PixelFormat.Default;
1782     CompareFunc compare = CompareFunc.Default;
1783     bool write_enabled = false;
1784     float bias = 0.0f;
1785     float bias_slope_scale = 0.0f;
1786     float bias_clamp = 0.0f;
1787 }
1788 extern(C) struct BlendState {
1789     bool enabled = false;
1790     BlendFactor src_factor_rgb = BlendFactor.Default;
1791     BlendFactor dst_factor_rgb = BlendFactor.Default;
1792     BlendOp op_rgb = BlendOp.Default;
1793     BlendFactor src_factor_alpha = BlendFactor.Default;
1794     BlendFactor dst_factor_alpha = BlendFactor.Default;
1795     BlendOp op_alpha = BlendOp.Default;
1796 }
1797 extern(C) struct ColorTargetState {
1798     PixelFormat pixel_format = PixelFormat.Default;
1799     ColorMask write_mask = ColorMask.Default;
1800     BlendState blend = {};
1801 }
1802 extern(C) struct PipelineDesc {
1803     uint _start_canary = 0;
1804     bool compute = false;
1805     Shader shader = {};
1806     VertexLayoutState layout = {};
1807     DepthState depth = {};
1808     StencilState stencil = {};
1809     int color_count = 0;
1810     ColorTargetState[8] colors = [];
1811     PrimitiveType primitive_type = PrimitiveType.Default;
1812     IndexType index_type = IndexType.Default;
1813     CullMode cull_mode = CullMode.Default;
1814     FaceWinding face_winding = FaceWinding.Default;
1815     int sample_count = 0;
1816     Color blend_color = {};
1817     bool alpha_to_coverage_enabled = false;
1818     const(char)* label = null;
1819     uint _end_canary = 0;
1820 }
1821 /++
1822 + sg_view_desc
1823 + 
1824 +     Creation params for sg_view objects, passed into sg_make_view() calls.
1825 + 
1826 +     View objects are passed into sg_apply_bindings() (for texture-, storage-buffer-
1827 +     and storage-image views), and sg_begin_pass() (for color-, resolve-
1828 +     and depth-stencil-attachment views).
1829 + 
1830 +     The view type is determined by initializing one of the sub-structs of
1831 +     sg_view_desc:
1832 + 
1833 +     .texture            a texture-view object will be created
1834 +         .image          the sg_image parent resource
1835 +         .mip_levels     optional mip-level range, keep zero-initialized for the
1836 +                         entire mipmap chain
1837 +             .base       the first mip level
1838 +             .count      number of mip levels, keeping this zero-initialized means
1839 +                         'all remaining mip levels'
1840 +         .slices         optional slice range, keep zero-initialized to include
1841 +                         all slices
1842 +             .base       the first slice
1843 +             .count      number of slices, keeping this zero-initializied means 'all remaining slices'
1844 + 
1845 +     .storage_buffer     a storage-buffer-view object will be created
1846 +         .buffer         the sg_buffer parent resource, must have been created
1847 +                         with `sg_buffer_desc.usage.storage_buffer = true`
1848 +         .offset         optional 256-byte aligned byte-offset into the buffer
1849 + 
1850 +     .storage_image      a storage-image-view object will be created
1851 +         .image          the sg_image parent resource, must have been created
1852 +                         with `sg_image_desc.usage.storage_image = true`
1853 +         .mip_level      selects the mip-level for the compute shader to write
1854 +         .slice          selects the slice for the compute shader to write
1855 + 
1856 +     .color_attachment   a color-attachment-view object will be created
1857 +         .image          the sg_image parent resource, must have been created
1858 +                         with `sg_image_desc.usage.color_attachment = true`
1859 +         .mip_level      selects the mip-level to render into
1860 +         .slice          selects the slice to render into
1861 + 
1862 +     .resolve_attachment a resolve-attachment-view object will be created
1863 +         .image          the sg_image parent resource, must have been created
1864 +                         with `sg_image_desc.usage.resolve_attachment = true`
1865 +         .mip_level      selects the mip-level to msaa-resolve into
1866 +         .slice          selects the slice to msaa-resolve into
1867 + 
1868 +     .depth_stencil_attachment   a depth-stencil-attachment-view object will be created
1869 +         .image          the sg_image parent resource, must have been created
1870 +                         with `sg_image_desc.usage.depth_stencil_attachment = true`
1871 +         .mip_level      selects the mip-level to render into
1872 +         .slice          selects the slice to render into
1873 +/
1874 extern(C) struct BufferViewDesc {
1875     Buffer buffer = {};
1876     int offset = 0;
1877 }
1878 extern(C) struct ImageViewDesc {
1879     Image image = {};
1880     int mip_level = 0;
1881     int slice = 0;
1882 }
1883 extern(C) struct TextureViewRange {
1884     int base = 0;
1885     int count = 0;
1886 }
1887 extern(C) struct TextureViewDesc {
1888     Image image = {};
1889     TextureViewRange mip_levels = {};
1890     TextureViewRange slices = {};
1891 }
1892 extern(C) struct ViewDesc {
1893     uint _start_canary = 0;
1894     TextureViewDesc texture = {};
1895     BufferViewDesc storage_buffer = {};
1896     ImageViewDesc storage_image = {};
1897     ImageViewDesc color_attachment = {};
1898     ImageViewDesc resolve_attachment = {};
1899     ImageViewDesc depth_stencil_attachment = {};
1900     const(char)* label = null;
1901     uint _end_canary = 0;
1902 }
1903 /++
1904 + sg_trace_hooks
1905 + 
1906 +     Installable callback functions to keep track of the sokol-gfx calls,
1907 +     this is useful for debugging, or keeping track of resource creation
1908 +     and destruction.
1909 + 
1910 +     Trace hooks are installed with sg_install_trace_hooks(), this returns
1911 +     another sg_trace_hooks struct with the previous set of
1912 +     trace hook function pointers. These should be invoked by the
1913 +     new trace hooks to form a proper call chain.
1914 +/
1915 extern(C) struct TraceHooks {
1916     void* user_data = null;
1917     extern(C) void function(void*) reset_state_cache = null;
1918     extern(C) void function(const BufferDesc*, Buffer, void*) make_buffer = null;
1919     extern(C) void function(const ImageDesc*, Image, void*) make_image = null;
1920     extern(C) void function(const SamplerDesc*, Sampler, void*) make_sampler = null;
1921     extern(C) void function(const ShaderDesc*, Shader, void*) make_shader = null;
1922     extern(C) void function(const PipelineDesc*, Pipeline, void*) make_pipeline = null;
1923     extern(C) void function(const ViewDesc*, View, void*) make_view = null;
1924     extern(C) void function(Buffer, void*) destroy_buffer = null;
1925     extern(C) void function(Image, void*) destroy_image = null;
1926     extern(C) void function(Sampler, void*) destroy_sampler = null;
1927     extern(C) void function(Shader, void*) destroy_shader = null;
1928     extern(C) void function(Pipeline, void*) destroy_pipeline = null;
1929     extern(C) void function(View, void*) destroy_view = null;
1930     extern(C) void function(Buffer, const Range*, void*) update_buffer = null;
1931     extern(C) void function(Image, const ImageData*, void*) update_image = null;
1932     extern(C) void function(Buffer, const Range*, int, void*) append_buffer = null;
1933     extern(C) void function(const Pass*, void*) begin_pass = null;
1934     extern(C) void function(int, int, int, int, bool, void*) apply_viewport = null;
1935     extern(C) void function(int, int, int, int, bool, void*) apply_scissor_rect = null;
1936     extern(C) void function(Pipeline, void*) apply_pipeline = null;
1937     extern(C) void function(const Bindings*, void*) apply_bindings = null;
1938     extern(C) void function(int, const Range*, void*) apply_uniforms = null;
1939     extern(C) void function(int, int, int, void*) draw = null;
1940     extern(C) void function(int, int, int, int, int, void*) draw_ex = null;
1941     extern(C) void function(int, int, int, void*) dispatch = null;
1942     extern(C) void function(void*) end_pass = null;
1943     extern(C) void function(void*) commit = null;
1944     extern(C) void function(Buffer, void*) alloc_buffer = null;
1945     extern(C) void function(Image, void*) alloc_image = null;
1946     extern(C) void function(Sampler, void*) alloc_sampler = null;
1947     extern(C) void function(Shader, void*) alloc_shader = null;
1948     extern(C) void function(Pipeline, void*) alloc_pipeline = null;
1949     extern(C) void function(View, void*) alloc_view = null;
1950     extern(C) void function(Buffer, void*) dealloc_buffer = null;
1951     extern(C) void function(Image, void*) dealloc_image = null;
1952     extern(C) void function(Sampler, void*) dealloc_sampler = null;
1953     extern(C) void function(Shader, void*) dealloc_shader = null;
1954     extern(C) void function(Pipeline, void*) dealloc_pipeline = null;
1955     extern(C) void function(View, void*) dealloc_view = null;
1956     extern(C) void function(Buffer, const BufferDesc*, void*) init_buffer = null;
1957     extern(C) void function(Image, const ImageDesc*, void*) init_image = null;
1958     extern(C) void function(Sampler, const SamplerDesc*, void*) init_sampler = null;
1959     extern(C) void function(Shader, const ShaderDesc*, void*) init_shader = null;
1960     extern(C) void function(Pipeline, const PipelineDesc*, void*) init_pipeline = null;
1961     extern(C) void function(View, const ViewDesc*, void*) init_view = null;
1962     extern(C) void function(Buffer, void*) uninit_buffer = null;
1963     extern(C) void function(Image, void*) uninit_image = null;
1964     extern(C) void function(Sampler, void*) uninit_sampler = null;
1965     extern(C) void function(Shader, void*) uninit_shader = null;
1966     extern(C) void function(Pipeline, void*) uninit_pipeline = null;
1967     extern(C) void function(View, void*) uninit_view = null;
1968     extern(C) void function(Buffer, void*) fail_buffer = null;
1969     extern(C) void function(Image, void*) fail_image = null;
1970     extern(C) void function(Sampler, void*) fail_sampler = null;
1971     extern(C) void function(Shader, void*) fail_shader = null;
1972     extern(C) void function(Pipeline, void*) fail_pipeline = null;
1973     extern(C) void function(View, void*) fail_view = null;
1974     extern(C) void function(const(char)*, void*) push_debug_group = null;
1975     extern(C) void function(void*) pop_debug_group = null;
1976 }
1977 /++
1978 + sg_buffer_info
1979 +     sg_image_info
1980 +     sg_sampler_info
1981 +     sg_shader_info
1982 +     sg_pipeline_info
1983 +     sg_view_info
1984 + 
1985 +     These structs contain various internal resource attributes which
1986 +     might be useful for debug-inspection. Please don't rely on the
1987 +     actual content of those structs too much, as they are quite closely
1988 +     tied to sokol_gfx.h internals and may change more frequently than
1989 +     the other public API elements.
1990 + 
1991 +     The *_info structs are used as the return values of the following functions:
1992 + 
1993 +     sg_query_buffer_info()
1994 +     sg_query_image_info()
1995 +     sg_query_sampler_info()
1996 +     sg_query_shader_info()
1997 +     sg_query_pipeline_info()
1998 +     sg_query_view_info()
1999 +/
2000 extern(C) struct SlotInfo {
2001     ResourceState state = ResourceState.Initial;
2002     uint res_id = 0;
2003     uint uninit_count = 0;
2004 }
2005 extern(C) struct BufferInfo {
2006     SlotInfo slot = {};
2007     uint update_frame_index = 0;
2008     uint append_frame_index = 0;
2009     int append_pos = 0;
2010     bool append_overflow = false;
2011     int num_slots = 0;
2012     int active_slot = 0;
2013 }
2014 extern(C) struct ImageInfo {
2015     SlotInfo slot = {};
2016     uint upd_frame_index = 0;
2017     int num_slots = 0;
2018     int active_slot = 0;
2019 }
2020 extern(C) struct SamplerInfo {
2021     SlotInfo slot = {};
2022 }
2023 extern(C) struct ShaderInfo {
2024     SlotInfo slot = {};
2025 }
2026 extern(C) struct PipelineInfo {
2027     SlotInfo slot = {};
2028 }
2029 extern(C) struct ViewInfo {
2030     SlotInfo slot = {};
2031 }
2032 /++
2033 + sg_stats
2034 + 
2035 +     Allows to track generic and backend-specific rendering stats,
2036 +     obtained via sg_query_stats().
2037 +/
2038 extern(C) struct FrameStatsGl {
2039     uint num_bind_buffer = 0;
2040     uint num_active_texture = 0;
2041     uint num_bind_texture = 0;
2042     uint num_bind_sampler = 0;
2043     uint num_bind_image_texture = 0;
2044     uint num_use_program = 0;
2045     uint num_render_state = 0;
2046     uint num_vertex_attrib_pointer = 0;
2047     uint num_vertex_attrib_divisor = 0;
2048     uint num_enable_vertex_attrib_array = 0;
2049     uint num_disable_vertex_attrib_array = 0;
2050     uint num_uniform = 0;
2051     uint num_memory_barriers = 0;
2052 }
2053 extern(C) struct FrameStatsD3d11Pass {
2054     uint num_om_set_render_targets = 0;
2055     uint num_clear_render_target_view = 0;
2056     uint num_clear_depth_stencil_view = 0;
2057     uint num_resolve_subresource = 0;
2058 }
2059 extern(C) struct FrameStatsD3d11Pipeline {
2060     uint num_rs_set_state = 0;
2061     uint num_om_set_depth_stencil_state = 0;
2062     uint num_om_set_blend_state = 0;
2063     uint num_ia_set_primitive_topology = 0;
2064     uint num_ia_set_input_layout = 0;
2065     uint num_vs_set_shader = 0;
2066     uint num_vs_set_constant_buffers = 0;
2067     uint num_ps_set_shader = 0;
2068     uint num_ps_set_constant_buffers = 0;
2069     uint num_cs_set_shader = 0;
2070     uint num_cs_set_constant_buffers = 0;
2071 }
2072 extern(C) struct FrameStatsD3d11Bindings {
2073     uint num_ia_set_vertex_buffers = 0;
2074     uint num_ia_set_index_buffer = 0;
2075     uint num_vs_set_shader_resources = 0;
2076     uint num_vs_set_samplers = 0;
2077     uint num_ps_set_shader_resources = 0;
2078     uint num_ps_set_samplers = 0;
2079     uint num_cs_set_shader_resources = 0;
2080     uint num_cs_set_samplers = 0;
2081     uint num_cs_set_unordered_access_views = 0;
2082 }
2083 extern(C) struct FrameStatsD3d11Uniforms {
2084     uint num_update_subresource = 0;
2085 }
2086 extern(C) struct FrameStatsD3d11Draw {
2087     uint num_draw_indexed_instanced = 0;
2088     uint num_draw_indexed = 0;
2089     uint num_draw_instanced = 0;
2090     uint num_draw = 0;
2091 }
2092 extern(C) struct FrameStatsD3d11 {
2093     FrameStatsD3d11Pass pass = {};
2094     FrameStatsD3d11Pipeline pipeline = {};
2095     FrameStatsD3d11Bindings bindings = {};
2096     FrameStatsD3d11Uniforms uniforms = {};
2097     FrameStatsD3d11Draw draw = {};
2098     uint num_map = 0;
2099     uint num_unmap = 0;
2100 }
2101 extern(C) struct FrameStatsMetalIdpool {
2102     uint num_added = 0;
2103     uint num_released = 0;
2104     uint num_garbage_collected = 0;
2105 }
2106 extern(C) struct FrameStatsMetalPipeline {
2107     uint num_set_blend_color = 0;
2108     uint num_set_cull_mode = 0;
2109     uint num_set_front_facing_winding = 0;
2110     uint num_set_stencil_reference_value = 0;
2111     uint num_set_depth_bias = 0;
2112     uint num_set_render_pipeline_state = 0;
2113     uint num_set_depth_stencil_state = 0;
2114 }
2115 extern(C) struct FrameStatsMetalBindings {
2116     uint num_set_vertex_buffer = 0;
2117     uint num_set_vertex_buffer_offset = 0;
2118     uint num_skip_redundant_vertex_buffer = 0;
2119     uint num_set_vertex_texture = 0;
2120     uint num_skip_redundant_vertex_texture = 0;
2121     uint num_set_vertex_sampler_state = 0;
2122     uint num_skip_redundant_vertex_sampler_state = 0;
2123     uint num_set_fragment_buffer = 0;
2124     uint num_set_fragment_buffer_offset = 0;
2125     uint num_skip_redundant_fragment_buffer = 0;
2126     uint num_set_fragment_texture = 0;
2127     uint num_skip_redundant_fragment_texture = 0;
2128     uint num_set_fragment_sampler_state = 0;
2129     uint num_skip_redundant_fragment_sampler_state = 0;
2130     uint num_set_compute_buffer = 0;
2131     uint num_set_compute_buffer_offset = 0;
2132     uint num_skip_redundant_compute_buffer = 0;
2133     uint num_set_compute_texture = 0;
2134     uint num_skip_redundant_compute_texture = 0;
2135     uint num_set_compute_sampler_state = 0;
2136     uint num_skip_redundant_compute_sampler_state = 0;
2137 }
2138 extern(C) struct FrameStatsMetalUniforms {
2139     uint num_set_vertex_buffer_offset = 0;
2140     uint num_set_fragment_buffer_offset = 0;
2141     uint num_set_compute_buffer_offset = 0;
2142 }
2143 extern(C) struct FrameStatsMetal {
2144     FrameStatsMetalIdpool idpool = {};
2145     FrameStatsMetalPipeline pipeline = {};
2146     FrameStatsMetalBindings bindings = {};
2147     FrameStatsMetalUniforms uniforms = {};
2148 }
2149 extern(C) struct FrameStatsWgpuUniforms {
2150     uint num_set_bindgroup = 0;
2151     uint size_write_buffer = 0;
2152 }
2153 extern(C) struct FrameStatsWgpuBindings {
2154     uint num_set_vertex_buffer = 0;
2155     uint num_skip_redundant_vertex_buffer = 0;
2156     uint num_set_index_buffer = 0;
2157     uint num_skip_redundant_index_buffer = 0;
2158     uint num_create_bindgroup = 0;
2159     uint num_discard_bindgroup = 0;
2160     uint num_set_bindgroup = 0;
2161     uint num_skip_redundant_bindgroup = 0;
2162     uint num_bindgroup_cache_hits = 0;
2163     uint num_bindgroup_cache_misses = 0;
2164     uint num_bindgroup_cache_collisions = 0;
2165     uint num_bindgroup_cache_invalidates = 0;
2166     uint num_bindgroup_cache_hash_vs_key_mismatch = 0;
2167 }
2168 extern(C) struct FrameStatsWgpu {
2169     FrameStatsWgpuUniforms uniforms = {};
2170     FrameStatsWgpuBindings bindings = {};
2171 }
2172 extern(C) struct FrameStatsVk {
2173     uint num_cmd_pipeline_barrier = 0;
2174     uint num_allocate_memory = 0;
2175     uint num_free_memory = 0;
2176     uint size_allocate_memory = 0;
2177     uint num_delete_queue_added = 0;
2178     uint num_delete_queue_collected = 0;
2179     uint num_cmd_copy_buffer = 0;
2180     uint num_cmd_copy_buffer_to_image = 0;
2181     uint num_cmd_set_descriptor_buffer_offsets = 0;
2182     uint size_descriptor_buffer_writes = 0;
2183 }
2184 extern(C) struct FrameResourceStats {
2185     uint allocated = 0;
2186     uint deallocated = 0;
2187     uint inited = 0;
2188     uint uninited = 0;
2189 }
2190 extern(C) struct TotalResourceStats {
2191     uint alive = 0;
2192     uint free = 0;
2193     uint allocated = 0;
2194     uint deallocated = 0;
2195     uint inited = 0;
2196     uint uninited = 0;
2197 }
2198 extern(C) struct TotalStats {
2199     TotalResourceStats buffers = {};
2200     TotalResourceStats images = {};
2201     TotalResourceStats samplers = {};
2202     TotalResourceStats views = {};
2203     TotalResourceStats shaders = {};
2204     TotalResourceStats pipelines = {};
2205 }
2206 extern(C) struct FrameStats {
2207     uint frame_index = 0;
2208     uint num_passes = 0;
2209     uint num_apply_viewport = 0;
2210     uint num_apply_scissor_rect = 0;
2211     uint num_apply_pipeline = 0;
2212     uint num_apply_bindings = 0;
2213     uint num_apply_uniforms = 0;
2214     uint num_draw = 0;
2215     uint num_draw_ex = 0;
2216     uint num_dispatch = 0;
2217     uint num_update_buffer = 0;
2218     uint num_append_buffer = 0;
2219     uint num_update_image = 0;
2220     uint size_apply_uniforms = 0;
2221     uint size_update_buffer = 0;
2222     uint size_append_buffer = 0;
2223     uint size_update_image = 0;
2224     FrameResourceStats buffers = {};
2225     FrameResourceStats images = {};
2226     FrameResourceStats samplers = {};
2227     FrameResourceStats views = {};
2228     FrameResourceStats shaders = {};
2229     FrameResourceStats pipelines = {};
2230     FrameStatsGl gl = {};
2231     FrameStatsD3d11 d3d11 = {};
2232     FrameStatsMetal metal = {};
2233     FrameStatsWgpu wgpu = {};
2234     FrameStatsVk vk = {};
2235 }
2236 extern(C) struct Stats {
2237     FrameStats prev_frame = {};
2238     FrameStats cur_frame = {};
2239     TotalStats total = {};
2240 }
2241 enum LogItem {
2242     Ok,
2243     Malloc_failed,
2244     Gl_texture_format_not_supported,
2245     Gl_3d_textures_not_supported,
2246     Gl_array_textures_not_supported,
2247     Gl_storagebuffer_glsl_binding_out_of_range,
2248     Gl_storageimage_glsl_binding_out_of_range,
2249     Gl_shader_compilation_failed,
2250     Gl_shader_linking_failed,
2251     Gl_vertex_attribute_not_found_in_shader,
2252     Gl_uniformblock_name_not_found_in_shader,
2253     Gl_image_sampler_name_not_found_in_shader,
2254     Gl_framebuffer_status_undefined,
2255     Gl_framebuffer_status_incomplete_attachment,
2256     Gl_framebuffer_status_incomplete_missing_attachment,
2257     Gl_framebuffer_status_unsupported,
2258     Gl_framebuffer_status_incomplete_multisample,
2259     Gl_framebuffer_status_unknown,
2260     D3d11_feature_level_0_detected,
2261     D3d11_create_buffer_failed,
2262     D3d11_create_buffer_srv_failed,
2263     D3d11_create_buffer_uav_failed,
2264     D3d11_create_depth_texture_unsupported_pixel_format,
2265     D3d11_create_depth_texture_failed,
2266     D3d11_create_2d_texture_unsupported_pixel_format,
2267     D3d11_create_2d_texture_failed,
2268     D3d11_create_2d_srv_failed,
2269     D3d11_create_3d_texture_unsupported_pixel_format,
2270     D3d11_create_3d_texture_failed,
2271     D3d11_create_3d_srv_failed,
2272     D3d11_create_msaa_texture_failed,
2273     D3d11_create_sampler_state_failed,
2274     D3d11_uniformblock_hlsl_register_b_out_of_range,
2275     D3d11_storagebuffer_hlsl_register_t_out_of_range,
2276     D3d11_storagebuffer_hlsl_register_u_out_of_range,
2277     D3d11_image_hlsl_register_t_out_of_range,
2278     D3d11_storageimage_hlsl_register_u_out_of_range,
2279     D3d11_sampler_hlsl_register_s_out_of_range,
2280     D3d11_load_d3dcompiler_47_dll_failed,
2281     D3d11_shader_compilation_failed,
2282     D3d11_shader_compilation_output,
2283     D3d11_create_constant_buffer_failed,
2284     D3d11_create_input_layout_failed,
2285     D3d11_create_rasterizer_state_failed,
2286     D3d11_create_depth_stencil_state_failed,
2287     D3d11_create_blend_state_failed,
2288     D3d11_create_rtv_failed,
2289     D3d11_create_dsv_failed,
2290     D3d11_create_uav_failed,
2291     D3d11_map_for_update_buffer_failed,
2292     D3d11_map_for_append_buffer_failed,
2293     D3d11_map_for_update_image_failed,
2294     Metal_create_buffer_failed,
2295     Metal_texture_format_not_supported,
2296     Metal_create_texture_failed,
2297     Metal_create_sampler_failed,
2298     Metal_shader_compilation_failed,
2299     Metal_shader_creation_failed,
2300     Metal_shader_compilation_output,
2301     Metal_shader_entry_not_found,
2302     Metal_uniformblock_msl_buffer_slot_out_of_range,
2303     Metal_storagebuffer_msl_buffer_slot_out_of_range,
2304     Metal_storageimage_msl_texture_slot_out_of_range,
2305     Metal_image_msl_texture_slot_out_of_range,
2306     Metal_sampler_msl_sampler_slot_out_of_range,
2307     Metal_create_cps_failed,
2308     Metal_create_cps_output,
2309     Metal_create_rps_failed,
2310     Metal_create_rps_output,
2311     Metal_create_dss_failed,
2312     Wgpu_bindgroups_pool_exhausted,
2313     Wgpu_bindgroupscache_size_greater_one,
2314     Wgpu_bindgroupscache_size_pow2,
2315     Wgpu_createbindgroup_failed,
2316     Wgpu_create_buffer_failed,
2317     Wgpu_create_texture_failed,
2318     Wgpu_create_texture_view_failed,
2319     Wgpu_create_sampler_failed,
2320     Wgpu_create_shader_module_failed,
2321     Wgpu_shader_create_bindgroup_layout_failed,
2322     Wgpu_uniformblock_wgsl_group0_binding_out_of_range,
2323     Wgpu_texture_wgsl_group1_binding_out_of_range,
2324     Wgpu_storagebuffer_wgsl_group1_binding_out_of_range,
2325     Wgpu_storageimage_wgsl_group1_binding_out_of_range,
2326     Wgpu_sampler_wgsl_group1_binding_out_of_range,
2327     Wgpu_create_pipeline_layout_failed,
2328     Wgpu_create_render_pipeline_failed,
2329     Wgpu_create_compute_pipeline_failed,
2330     Vulkan_required_extension_function_missing,
2331     Vulkan_alloc_device_memory_no_suitable_memory_type,
2332     Vulkan_allocate_memory_failed,
2333     Vulkan_alloc_buffer_device_memory_failed,
2334     Vulkan_alloc_image_device_memory_failed,
2335     Vulkan_delete_queue_exhausted,
2336     Vulkan_staging_create_buffer_failed,
2337     Vulkan_staging_allocate_memory_failed,
2338     Vulkan_staging_bind_buffer_memory_failed,
2339     Vulkan_staging_stream_buffer_overflow,
2340     Vulkan_create_shared_buffer_failed,
2341     Vulkan_allocate_shared_buffer_memory_failed,
2342     Vulkan_bind_shared_buffer_memory_failed,
2343     Vulkan_map_shared_buffer_memory_failed,
2344     Vulkan_create_buffer_failed,
2345     Vulkan_bind_buffer_memory_failed,
2346     Vulkan_create_image_failed,
2347     Vulkan_bind_image_memory_failed,
2348     Vulkan_create_shader_module_failed,
2349     Vulkan_uniformblock_spirv_set0_binding_out_of_range,
2350     Vulkan_texture_spirv_set1_binding_out_of_range,
2351     Vulkan_storagebuffer_spirv_set1_binding_out_of_range,
2352     Vulkan_storageimage_spirv_set1_binding_out_of_range,
2353     Vulkan_sampler_spirv_set1_binding_out_of_range,
2354     Vulkan_create_descriptor_set_layout_failed,
2355     Vulkan_shader_uniform_descriptor_set_size_vs_cache_size,
2356     Vulkan_create_pipeline_layout_failed,
2357     Vulkan_create_graphics_pipeline_failed,
2358     Vulkan_create_compute_pipeline_failed,
2359     Vulkan_create_image_view_failed,
2360     Vulkan_view_max_descriptor_size,
2361     Vulkan_create_sampler_failed,
2362     Vulkan_sampler_max_descriptor_size,
2363     Vulkan_wait_for_fence_failed,
2364     Vulkan_uniform_buffer_overflow,
2365     Vulkan_descriptor_buffer_overflow,
2366     Identical_commit_listener,
2367     Commit_listener_array_full,
2368     Trace_hooks_not_enabled,
2369     Dealloc_buffer_invalid_state,
2370     Dealloc_image_invalid_state,
2371     Dealloc_sampler_invalid_state,
2372     Dealloc_shader_invalid_state,
2373     Dealloc_pipeline_invalid_state,
2374     Dealloc_view_invalid_state,
2375     Init_buffer_invalid_state,
2376     Init_image_invalid_state,
2377     Init_sampler_invalid_state,
2378     Init_shader_invalid_state,
2379     Init_pipeline_invalid_state,
2380     Init_view_invalid_state,
2381     Uninit_buffer_invalid_state,
2382     Uninit_image_invalid_state,
2383     Uninit_sampler_invalid_state,
2384     Uninit_shader_invalid_state,
2385     Uninit_pipeline_invalid_state,
2386     Uninit_view_invalid_state,
2387     Fail_buffer_invalid_state,
2388     Fail_image_invalid_state,
2389     Fail_sampler_invalid_state,
2390     Fail_shader_invalid_state,
2391     Fail_pipeline_invalid_state,
2392     Fail_view_invalid_state,
2393     Buffer_pool_exhausted,
2394     Image_pool_exhausted,
2395     Sampler_pool_exhausted,
2396     Shader_pool_exhausted,
2397     Pipeline_pool_exhausted,
2398     View_pool_exhausted,
2399     Beginpass_too_many_color_attachments,
2400     Beginpass_too_many_resolve_attachments,
2401     Beginpass_attachments_alive,
2402     Draw_without_bindings,
2403     Shaderdesc_too_many_vertexstage_textures,
2404     Shaderdesc_too_many_fragmentstage_textures,
2405     Shaderdesc_too_many_computestage_textures,
2406     Shaderdesc_too_many_vertexstage_storagebuffers,
2407     Shaderdesc_too_many_fragmentstage_storagebuffers,
2408     Shaderdesc_too_many_computestage_storagebuffers,
2409     Shaderdesc_too_many_vertexstage_storageimages,
2410     Shaderdesc_too_many_fragmentstage_storageimages,
2411     Shaderdesc_too_many_computestage_storageimages,
2412     Shaderdesc_too_many_vertexstage_texturesamplerpairs,
2413     Shaderdesc_too_many_fragmentstage_texturesamplerpairs,
2414     Shaderdesc_too_many_computestage_texturesamplerpairs,
2415     Validate_bufferdesc_canary,
2416     Validate_bufferdesc_immutable_dynamic_stream,
2417     Validate_bufferdesc_separate_buffer_types,
2418     Validate_bufferdesc_expect_nonzero_size,
2419     Validate_bufferdesc_expect_matching_data_size,
2420     Validate_bufferdesc_expect_zero_data_size,
2421     Validate_bufferdesc_expect_no_data,
2422     Validate_bufferdesc_expect_data,
2423     Validate_bufferdesc_storagebuffer_supported,
2424     Validate_bufferdesc_storagebuffer_size_multiple_4,
2425     Validate_imagedata_nodata,
2426     Validate_imagedata_data_size,
2427     Validate_imagedesc_canary,
2428     Validate_imagedesc_immutable_dynamic_stream,
2429     Validate_imagedesc_imagetype_2d_numslices,
2430     Validate_imagedesc_imagetype_cube_numslices,
2431     Validate_imagedesc_imagetype_array_numslices,
2432     Validate_imagedesc_imagetype_3d_numslices,
2433     Validate_imagedesc_numslices,
2434     Validate_imagedesc_width,
2435     Validate_imagedesc_height,
2436     Validate_imagedesc_nonrt_pixelformat,
2437     Validate_imagedesc_msaa_but_no_attachment,
2438     Validate_imagedesc_depth_3d_image,
2439     Validate_imagedesc_attachment_expect_immutable,
2440     Validate_imagedesc_attachment_expect_no_data,
2441     Validate_imagedesc_attachment_pixelformat,
2442     Validate_imagedesc_attachment_resolve_expect_no_msaa,
2443     Validate_imagedesc_attachment_no_msaa_support,
2444     Validate_imagedesc_attachment_msaa_num_mipmaps,
2445     Validate_imagedesc_attachment_msaa_3d_image,
2446     Validate_imagedesc_attachment_msaa_cube_image,
2447     Validate_imagedesc_attachment_msaa_array_image,
2448     Validate_imagedesc_storageimage_pixelformat,
2449     Validate_imagedesc_storageimage_expect_no_msaa,
2450     Validate_imagedesc_injected_no_data,
2451     Validate_imagedesc_dynamic_no_data,
2452     Validate_imagedesc_compressed_immutable,
2453     Validate_samplerdesc_canary,
2454     Validate_samplerdesc_anistropic_requires_linear_filtering,
2455     Validate_shaderdesc_canary,
2456     Validate_shaderdesc_vertex_source,
2457     Validate_shaderdesc_fragment_source,
2458     Validate_shaderdesc_compute_source,
2459     Validate_shaderdesc_vertex_source_or_bytecode,
2460     Validate_shaderdesc_fragment_source_or_bytecode,
2461     Validate_shaderdesc_compute_source_or_bytecode,
2462     Validate_shaderdesc_invalid_shader_combo,
2463     Validate_shaderdesc_no_bytecode_size,
2464     Validate_shaderdesc_metal_threads_per_threadgroup_initialized,
2465     Validate_shaderdesc_metal_threads_per_threadgroup_multiple_32,
2466     Validate_shaderdesc_uniformblock_no_cont_members,
2467     Validate_shaderdesc_uniformblock_size_is_zero,
2468     Validate_shaderdesc_uniformblock_metal_buffer_slot_collision,
2469     Validate_shaderdesc_uniformblock_hlsl_register_b_collision,
2470     Validate_shaderdesc_uniformblock_wgsl_group0_binding_collision,
2471     Validate_shaderdesc_uniformblock_spirv_set0_binding_collision,
2472     Validate_shaderdesc_uniformblock_no_members,
2473     Validate_shaderdesc_uniformblock_uniform_glsl_name,
2474     Validate_shaderdesc_uniformblock_size_mismatch,
2475     Validate_shaderdesc_uniformblock_array_count,
2476     Validate_shaderdesc_uniformblock_std140_array_type,
2477     Validate_shaderdesc_view_storagebuffer_metal_buffer_slot_collision,
2478     Validate_shaderdesc_view_storagebuffer_hlsl_register_t_collision,
2479     Validate_shaderdesc_view_storagebuffer_hlsl_register_u_collision,
2480     Validate_shaderdesc_view_storagebuffer_glsl_binding_collision,
2481     Validate_shaderdesc_view_storagebuffer_wgsl_group1_binding_collision,
2482     Validate_shaderdesc_view_storagebuffer_spirv_set1_binding_collision,
2483     Validate_shaderdesc_view_storageimage_expect_compute_stage,
2484     Validate_shaderdesc_view_storageimage_metal_texture_slot_collision,
2485     Validate_shaderdesc_view_storageimage_hlsl_register_u_collision,
2486     Validate_shaderdesc_view_storageimage_glsl_binding_collision,
2487     Validate_shaderdesc_view_storageimage_wgsl_group1_binding_collision,
2488     Validate_shaderdesc_view_storageimage_spirv_set1_binding_collision,
2489     Validate_shaderdesc_view_texture_metal_texture_slot_collision,
2490     Validate_shaderdesc_view_texture_hlsl_register_t_collision,
2491     Validate_shaderdesc_view_texture_wgsl_group1_binding_collision,
2492     Validate_shaderdesc_view_texture_spirv_set1_binding_collision,
2493     Validate_shaderdesc_sampler_metal_sampler_slot_collision,
2494     Validate_shaderdesc_sampler_hlsl_register_s_collision,
2495     Validate_shaderdesc_sampler_wgsl_group1_binding_collision,
2496     Validate_shaderdesc_sampler_spirv_set1_binding_collision,
2497     Validate_shaderdesc_texture_sampler_pair_view_slot_out_of_range,
2498     Validate_shaderdesc_texture_sampler_pair_sampler_slot_out_of_range,
2499     Validate_shaderdesc_texture_sampler_pair_texture_stage_mismatch,
2500     Validate_shaderdesc_texture_sampler_pair_expect_texture_view,
2501     Validate_shaderdesc_texture_sampler_pair_sampler_stage_mismatch,
2502     Validate_shaderdesc_texture_sampler_pair_glsl_name,
2503     Validate_shaderdesc_nonfiltering_sampler_required,
2504     Validate_shaderdesc_comparison_sampler_required,
2505     Validate_shaderdesc_texview_not_referenced_by_texture_sampler_pairs,
2506     Validate_shaderdesc_sampler_not_referenced_by_texture_sampler_pairs,
2507     Validate_shaderdesc_attr_string_too_long,
2508     Validate_pipelinedesc_canary,
2509     Validate_pipelinedesc_shader,
2510     Validate_pipelinedesc_compute_shader_expected,
2511     Validate_pipelinedesc_no_compute_shader_expected,
2512     Validate_pipelinedesc_no_cont_attrs,
2513     Validate_pipelinedesc_attr_basetype_mismatch,
2514     Validate_pipelinedesc_layout_stride4,
2515     Validate_pipelinedesc_attr_semantics,
2516     Validate_pipelinedesc_shader_readonly_storagebuffers,
2517     Validate_pipelinedesc_blendop_minmax_requires_blendfactor_one,
2518     Validate_pipelinedesc_dual_source_blending_not_supported,
2519     Validate_viewdesc_canary,
2520     Validate_viewdesc_unique_viewtype,
2521     Validate_viewdesc_any_viewtype,
2522     Validate_viewdesc_resource_alive,
2523     Validate_viewdesc_resource_failed,
2524     Validate_viewdesc_storagebuffer_offset_vs_buffer_size,
2525     Validate_viewdesc_storagebuffer_offset_multiple_256,
2526     Validate_viewdesc_storagebuffer_usage,
2527     Validate_viewdesc_storageimage_usage,
2528     Validate_viewdesc_colorattachment_usage,
2529     Validate_viewdesc_resolveattachment_usage,
2530     Validate_viewdesc_depthstencilattachment_usage,
2531     Validate_viewdesc_image_miplevel,
2532     Validate_viewdesc_image_2d_slice,
2533     Validate_viewdesc_image_cubemap_slice,
2534     Validate_viewdesc_image_array_slice,
2535     Validate_viewdesc_image_3d_slice,
2536     Validate_viewdesc_texture_expect_no_msaa,
2537     Validate_viewdesc_texture_miplevels,
2538     Validate_viewdesc_texture_2d_slices,
2539     Validate_viewdesc_texture_cubemap_slices,
2540     Validate_viewdesc_texture_array_slices,
2541     Validate_viewdesc_texture_3d_slices,
2542     Validate_viewdesc_storageimage_pixelformat,
2543     Validate_viewdesc_colorattachment_pixelformat,
2544     Validate_viewdesc_depthstencilattachment_pixelformat,
2545     Validate_viewdesc_resolveattachment_samplecount,
2546     Validate_beginpass_canary,
2547     Validate_beginpass_computepass_expect_no_attachments,
2548     Validate_beginpass_swapchain_expect_width,
2549     Validate_beginpass_swapchain_expect_width_notset,
2550     Validate_beginpass_swapchain_expect_height,
2551     Validate_beginpass_swapchain_expect_height_notset,
2552     Validate_beginpass_swapchain_expect_samplecount,
2553     Validate_beginpass_swapchain_expect_samplecount_notset,
2554     Validate_beginpass_swapchain_expect_colorformat,
2555     Validate_beginpass_swapchain_expect_colorformat_notset,
2556     Validate_beginpass_swapchain_expect_depthformat_notset,
2557     Validate_beginpass_swapchain_metal_expect_currentdrawable,
2558     Validate_beginpass_swapchain_metal_expect_currentdrawable_notset,
2559     Validate_beginpass_swapchain_metal_expect_depthstenciltexture,
2560     Validate_beginpass_swapchain_metal_expect_depthstenciltexture_notset,
2561     Validate_beginpass_swapchain_metal_expect_msaacolortexture,
2562     Validate_beginpass_swapchain_metal_expect_msaacolortexture_notset,
2563     Validate_beginpass_swapchain_d3d11_expect_renderview,
2564     Validate_beginpass_swapchain_d3d11_expect_renderview_notset,
2565     Validate_beginpass_swapchain_d3d11_expect_resolveview,
2566     Validate_beginpass_swapchain_d3d11_expect_resolveview_notset,
2567     Validate_beginpass_swapchain_d3d11_expect_depthstencilview,
2568     Validate_beginpass_swapchain_d3d11_expect_depthstencilview_notset,
2569     Validate_beginpass_swapchain_wgpu_expect_renderview,
2570     Validate_beginpass_swapchain_wgpu_expect_renderview_notset,
2571     Validate_beginpass_swapchain_wgpu_expect_resolveview,
2572     Validate_beginpass_swapchain_wgpu_expect_resolveview_notset,
2573     Validate_beginpass_swapchain_wgpu_expect_depthstencilview,
2574     Validate_beginpass_swapchain_wgpu_expect_depthstencilview_notset,
2575     Validate_beginpass_swapchain_gl_expect_framebuffer_notset,
2576     Validate_beginpass_colorattachmentviews_continuous,
2577     Validate_beginpass_colorattachmentview_alive,
2578     Validate_beginpass_colorattachmentview_valid,
2579     Validate_beginpass_colorattachmentview_type,
2580     Validate_beginpass_colorattachmentview_image_alive,
2581     Validate_beginpass_colorattachmentview_image_valid,
2582     Validate_beginpass_colorattachmentview_sizes,
2583     Validate_beginpass_colorattachmentview_samplecount,
2584     Validate_beginpass_colorattachmentview_samplecounts_equal,
2585     Validate_beginpass_resolveattachmentview_no_colorattachmentview,
2586     Validate_beginpass_resolveattachmentview_alive,
2587     Validate_beginpass_resolveattachmentview_valid,
2588     Validate_beginpass_resolveattachmentview_type,
2589     Validate_beginpass_resolveattachmentview_image_alive,
2590     Validate_beginpass_resolveattachmentview_image_valid,
2591     Validate_beginpass_resolveattachmentview_sizes,
2592     Validate_beginpass_depthstencilattachmentviews_continuous,
2593     Validate_beginpass_depthstencilattachmentview_alive,
2594     Validate_beginpass_depthstencilattachmentview_valid,
2595     Validate_beginpass_depthstencilattachmentview_type,
2596     Validate_beginpass_depthstencilattachmentview_image_alive,
2597     Validate_beginpass_depthstencilattachmentview_image_valid,
2598     Validate_beginpass_depthstencilattachmentview_sizes,
2599     Validate_beginpass_depthstencilattachmentview_samplecount,
2600     Validate_beginpass_attachments_expected,
2601     Validate_avp_renderpass_expected,
2602     Validate_asr_renderpass_expected,
2603     Validate_apip_pipeline_valid_id,
2604     Validate_apip_pipeline_exists,
2605     Validate_apip_pipeline_valid,
2606     Validate_apip_pass_expected,
2607     Validate_apip_pipeline_shader_alive,
2608     Validate_apip_pipeline_shader_valid,
2609     Validate_apip_computepass_expected,
2610     Validate_apip_renderpass_expected,
2611     Validate_apip_swapchain_color_count,
2612     Validate_apip_swapchain_color_format,
2613     Validate_apip_swapchain_depth_format,
2614     Validate_apip_swapchain_sample_count,
2615     Validate_apip_attachments_alive,
2616     Validate_apip_colorattachments_count,
2617     Validate_apip_colorattachments_view_valid,
2618     Validate_apip_colorattachments_image_valid,
2619     Validate_apip_colorattachments_format,
2620     Validate_apip_depthstencilattachment_view_valid,
2621     Validate_apip_depthstencilattachment_image_valid,
2622     Validate_apip_depthstencilattachment_format,
2623     Validate_apip_attachment_sample_count,
2624     Validate_abnd_pass_expected,
2625     Validate_abnd_empty_bindings,
2626     Validate_abnd_no_pipeline,
2627     Validate_abnd_pipeline_alive,
2628     Validate_abnd_pipeline_valid,
2629     Validate_abnd_pipeline_shader_alive,
2630     Validate_abnd_pipeline_shader_valid,
2631     Validate_abnd_compute_expected_no_vbufs,
2632     Validate_abnd_compute_expected_no_ibuf,
2633     Validate_abnd_expected_vbuf,
2634     Validate_abnd_vbuf_alive,
2635     Validate_abnd_vbuf_usage,
2636     Validate_abnd_vbuf_overflow,
2637     Validate_abnd_expected_no_ibuf,
2638     Validate_abnd_expected_ibuf,
2639     Validate_abnd_ibuf_alive,
2640     Validate_abnd_ibuf_usage,
2641     Validate_abnd_ibuf_overflow,
2642     Validate_abnd_expected_view_binding,
2643     Validate_abnd_view_alive,
2644     Validate_abnd_expect_texview,
2645     Validate_abnd_expect_sbview,
2646     Validate_abnd_expect_simgview,
2647     Validate_abnd_texview_imagetype_mismatch,
2648     Validate_abnd_texview_expected_multisampled_image,
2649     Validate_abnd_texview_expected_non_multisampled_image,
2650     Validate_abnd_texview_expected_filterable_image,
2651     Validate_abnd_texview_expected_depth_image,
2652     Validate_abnd_sbview_readwrite_immutable,
2653     Validate_abnd_simgview_compute_pass_expected,
2654     Validate_abnd_simgview_imagetype_mismatch,
2655     Validate_abnd_simgview_accessformat,
2656     Validate_abnd_expected_sampler_binding,
2657     Validate_abnd_unexpected_sampler_compare_never,
2658     Validate_abnd_expected_sampler_compare_never,
2659     Validate_abnd_expected_nonfiltering_sampler,
2660     Validate_abnd_sampler_alive,
2661     Validate_abnd_sampler_valid,
2662     Validate_abnd_texture_binding_vs_depthstencil_attachment,
2663     Validate_abnd_texture_binding_vs_color_attachment,
2664     Validate_abnd_texture_binding_vs_resolve_attachment,
2665     Validate_abnd_texture_vs_storageimage_binding,
2666     Validate_au_pass_expected,
2667     Validate_au_no_pipeline,
2668     Validate_au_pipeline_alive,
2669     Validate_au_pipeline_valid,
2670     Validate_au_pipeline_shader_alive,
2671     Validate_au_pipeline_shader_valid,
2672     Validate_au_no_uniformblock_at_slot,
2673     Validate_au_size,
2674     Validate_draw_renderpass_expected,
2675     Validate_draw_baseelement_ge_zero,
2676     Validate_draw_numelements_ge_zero,
2677     Validate_draw_numinstances_ge_zero,
2678     Validate_draw_ex_renderpass_expected,
2679     Validate_draw_ex_baseelement_ge_zero,
2680     Validate_draw_ex_numelements_ge_zero,
2681     Validate_draw_ex_numinstances_ge_zero,
2682     Validate_draw_ex_baseinstance_ge_zero,
2683     Validate_draw_ex_basevertex_vs_indexed,
2684     Validate_draw_ex_baseinstance_vs_instanced,
2685     Validate_draw_ex_basevertex_not_supported,
2686     Validate_draw_ex_baseinstance_not_supported,
2687     Validate_draw_required_bindings_or_uniforms_missing,
2688     Validate_dispatch_computepass_expected,
2689     Validate_dispatch_numgroupsx,
2690     Validate_dispatch_numgroupsy,
2691     Validate_dispatch_numgroupsz,
2692     Validate_dispatch_required_bindings_or_uniforms_missing,
2693     Validate_updatebuf_usage,
2694     Validate_updatebuf_size,
2695     Validate_updatebuf_once,
2696     Validate_updatebuf_append,
2697     Validate_appendbuf_usage,
2698     Validate_appendbuf_size,
2699     Validate_appendbuf_update,
2700     Validate_updimg_usage,
2701     Validate_updimg_once,
2702     Validation_failed,
2703 }
2704 /++
2705 + sg_desc
2706 + 
2707 +     The sg_desc struct contains configuration values for sokol_gfx,
2708 +     it is used as parameter to the sg_setup() call.
2709 + 
2710 +     The default configuration is:
2711 + 
2712 +     .buffer_pool_size                   128
2713 +     .image_pool_size                    128
2714 +     .sampler_pool_size                  64
2715 +     .shader_pool_size                   32
2716 +     .pipeline_pool_size                 64
2717 +     .view_pool_size                     256
2718 +     .uniform_buffer_size                4 MB (4*1024*1024)
2719 +     .max_commit_listeners               1024
2720 +     .disable_validation                 false
2721 +     .metal.force_managed_storage_mode   false
2722 +     .metal.use_command_buffer_with_retained_references  false
2723 +     .wgpu.disable_bindgroups_cache      false
2724 +     .wgpu.bindgroups_cache_size         1024
2725 +     .vulkan.copy_staging_buffer_size    4 MB
2726 +     .vulkan.stream_staging_buffer_size  16 MB
2727 +     .vulkan.descriptor_buffer_size      16 MB
2728 + 
2729 +     .allocator.alloc_fn     0 (in this case, malloc() will be called)
2730 +     .allocator.free_fn      0 (in this case, free() will be called)
2731 +     .allocator.user_data    0
2732 + 
2733 +     .environment.defaults.color_format: default value depends on selected backend:
2734 +         all GL backends:    SG_PIXELFORMAT_RGBA8
2735 +         Metal and D3D11:    SG_PIXELFORMAT_BGRA8
2736 +         WebGPU:             *no default* (must be queried from WebGPU swapchain object)
2737 +     .environment.defaults.depth_format: SG_PIXELFORMAT_DEPTH_STENCIL
2738 +     .environment.defaults.sample_count: 1
2739 + 
2740 +     Metal specific:
2741 +         (NOTE: All Objective-C object references are transferred through
2742 +         a bridged cast (__bridge const void*) to sokol_gfx, which will use an
2743 +         unretained bridged cast (__bridge id<xxx>) to retrieve the Objective-C
2744 +         references back. Since the bridge cast is unretained, the caller
2745 +         must hold a strong reference to the Objective-C object until sg_setup()
2746 +         returns.
2747 + 
2748 +         .metal.force_managed_storage_mode
2749 +             when enabled, Metal buffers and texture resources are created in managed storage
2750 +             mode, otherwise sokol-gfx will decide whether to create buffers and
2751 +             textures in managed or shared storage mode (this is mainly a debugging option)
2752 +         .metal.use_command_buffer_with_retained_references
2753 +             when true, the sokol-gfx Metal backend will use Metal command buffers which
2754 +             bump the reference count of resource objects as long as they are inflight,
2755 +             this is slower than the default command-buffer-with-unretained-references
2756 +             method, this may be a workaround when confronted with lifetime validation
2757 +             errors from the Metal validation layer until a proper fix has been implemented
2758 +         .environment.metal.device
2759 +             a pointer to the MTLDevice object
2760 + 
2761 +     D3D11 specific:
2762 +         .environment.d3d11.device
2763 +             a pointer to the ID3D11Device object, this must have been created
2764 +             before sg_setup() is called
2765 +         .environment.d3d11.device_context
2766 +             a pointer to the ID3D11DeviceContext object
2767 +         .d3d11.shader_debugging
2768 +             set this to true to compile shaders which are provided as HLSL source
2769 +             code with debug information and without optimization, this allows
2770 +             shader debugging in tools like RenderDoc, to output source code
2771 +             instead of byte code from sokol-shdc, omit the `--binary` cmdline
2772 +             option
2773 + 
2774 +     WebGPU specific:
2775 +         .wgpu.disable_bindgroups_cache
2776 +             When this is true, the WebGPU backend will create and immediately
2777 +             release a BindGroup object in the sg_apply_bindings() call, only
2778 +             use this for debugging purposes.
2779 +         .wgpu.bindgroups_cache_size
2780 +             The size of the bindgroups cache for re-using BindGroup objects
2781 +             between sg_apply_bindings() calls. The smaller the cache size,
2782 +             the more likely are cache slot collisions which will cause
2783 +             a BindGroups object to be destroyed and a new one created.
2784 +             Use the information returned by sg_query_stats() to check
2785 +             if this is a frequent occurrence, and increase the cache size as
2786 +             needed (the default is 1024).
2787 +             NOTE: wgpu_bindgroups_cache_size must be a power-of-2 number!
2788 +         .environment.wgpu.device
2789 +             a WGPUDevice handle
2790 + 
2791 +     Vulkan specific:
2792 +         .vulkan.copy_staging_buffer_size
2793 +             Size of the staging buffer in bytes for uploading the initial
2794 +             content of buffers and images, and for updating
2795 +             .usage.dynamic_update resources. The default is 4 MB,
2796 +             bigger resource updates are split into multiple chunks
2797 +             of the staging buffer size
2798 +         .vulkan.stream_staging_buffer_size
2799 +             Size of the staging buffer in bytes for updating .usage.stream_update
2800 +             resources. The default is 16 MB. The size must be big enough
2801 +             to accomodate all update into .usage.stream_update resources.
2802 +             Any additional data will cause an error log message and
2803 +             incomplete rendering. Note that the actually allocated size
2804 +             will be twice as much because the stream-staging-buffer is
2805 +             double-buffered.
2806 +         .vulkan.descriptor_buffer_size
2807 +             Size of the descriptor-upload buffer in bytes. The default
2808 +             size is 16 bytes. The size must be big enough to accomodate
2809 +             all unifrom-block, view- and sampler-bindings in a single
2810 +             frame (assume a worst-case of 256 bytes per binding). Note
2811 +             that the actually allocated size will be twice as much
2812 +             because the descriptor-buffer is double-buffered.
2813 + 
2814 +     When using sokol_gfx.h and sokol_app.h together, consider using the
2815 +     helper function sglue_environment() in the sokol_glue.h header to
2816 +     initialize the sg_desc.environment nested struct. sglue_environment() returns
2817 +     a completely initialized sg_environment struct with information
2818 +     provided by sokol_app.h.
2819 +/
2820 extern(C) struct EnvironmentDefaults {
2821     PixelFormat color_format = PixelFormat.Default;
2822     PixelFormat depth_format = PixelFormat.Default;
2823     int sample_count = 0;
2824 }
2825 extern(C) struct MetalEnvironment {
2826     const(void)* device = null;
2827 }
2828 extern(C) struct D3d11Environment {
2829     const(void)* device = null;
2830     const(void)* device_context = null;
2831 }
2832 extern(C) struct WgpuEnvironment {
2833     const(void)* device = null;
2834 }
2835 extern(C) struct VulkanEnvironment {
2836     const(void)* instance = null;
2837     const(void)* physical_device = null;
2838     const(void)* device = null;
2839     const(void)* queue = null;
2840     uint queue_family_index = 0;
2841 }
2842 extern(C) struct Environment {
2843     EnvironmentDefaults defaults = {};
2844     MetalEnvironment metal = {};
2845     D3d11Environment d3d11 = {};
2846     WgpuEnvironment wgpu = {};
2847     VulkanEnvironment vulkan = {};
2848 }
2849 /++
2850 + sg_commit_listener
2851 + 
2852 +     Used with function sg_add_commit_listener() to add a callback
2853 +     which will be called in sg_commit(). This is useful for libraries
2854 +     building on top of sokol-gfx to be notified about when a frame
2855 +     ends (instead of having to guess, or add a manual 'new-frame'
2856 +     function.
2857 +/
2858 extern(C) struct CommitListener {
2859     extern(C) void function(void*) func = null;
2860     void* user_data = null;
2861 }
2862 /++
2863 + sg_allocator
2864 + 
2865 +     Used in sg_desc to provide custom memory-alloc and -free functions
2866 +     to sokol_gfx.h. If memory management should be overridden, both the
2867 +     alloc_fn and free_fn function must be provided (e.g. it's not valid to
2868 +     override one function but not the other).
2869 +/
2870 extern(C) struct Allocator {
2871     extern(C) void* function(size_t, void*) alloc_fn = null;
2872     extern(C) void function(void*, void*) free_fn = null;
2873     void* user_data = null;
2874 }
2875 /++
2876 + sg_logger
2877 + 
2878 +     Used in sg_desc to provide a logging function. Please be aware
2879 +     that without logging function, sokol-gfx will be completely
2880 +     silent, e.g. it will not report errors, warnings and
2881 +     validation layer messages. For maximum error verbosity,
2882 +     compile in debug mode (e.g. NDEBUG *not* defined) and provide a
2883 +     compatible logger function in the sg_setup() call
2884 +     (for instance the standard logging function from sokol_log.h).
2885 +/
2886 extern(C) struct Logger {
2887     extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null;
2888     void* user_data = null;
2889 }
2890 extern(C) struct D3d11Desc {
2891     bool shader_debugging = false;
2892 }
2893 extern(C) struct MetalDesc {
2894     bool force_managed_storage_mode = false;
2895     bool use_command_buffer_with_retained_references = false;
2896 }
2897 extern(C) struct WgpuDesc {
2898     bool disable_bindgroups_cache = false;
2899     int bindgroups_cache_size = 0;
2900 }
2901 extern(C) struct VulkanDesc {
2902     int copy_staging_buffer_size = 0;
2903     int stream_staging_buffer_size = 0;
2904     int descriptor_buffer_size = 0;
2905 }
2906 extern(C) struct Desc {
2907     uint _start_canary = 0;
2908     int buffer_pool_size = 0;
2909     int image_pool_size = 0;
2910     int sampler_pool_size = 0;
2911     int shader_pool_size = 0;
2912     int pipeline_pool_size = 0;
2913     int view_pool_size = 0;
2914     int uniform_buffer_size = 0;
2915     int max_commit_listeners = 0;
2916     bool disable_validation = false;
2917     bool enforce_portable_limits = false;
2918     D3d11Desc d3d11 = {};
2919     MetalDesc metal = {};
2920     WgpuDesc wgpu = {};
2921     VulkanDesc vulkan = {};
2922     Allocator allocator = {};
2923     Logger logger = {};
2924     Environment environment = {};
2925     uint _end_canary = 0;
2926 }
2927 /++
2928 + setup and misc functions
2929 +/
2930 extern(C) void sg_setup(const Desc* desc) @system @nogc nothrow pure;
2931 void setup(scope ref Desc desc) @trusted @nogc nothrow pure {
2932     sg_setup(&desc);
2933 }
2934 extern(C) void sg_shutdown() @system @nogc nothrow pure;
2935 void shutdown() @trusted @nogc nothrow pure {
2936     sg_shutdown();
2937 }
2938 extern(C) bool sg_isvalid() @system @nogc nothrow pure;
2939 bool isvalid() @trusted @nogc nothrow pure {
2940     return sg_isvalid();
2941 }
2942 extern(C) void sg_reset_state_cache() @system @nogc nothrow pure;
2943 void resetStateCache() @trusted @nogc nothrow pure {
2944     sg_reset_state_cache();
2945 }
2946 extern(C) TraceHooks sg_install_trace_hooks(const TraceHooks* trace_hooks) @system @nogc nothrow pure;
2947 TraceHooks installTraceHooks(scope ref TraceHooks trace_hooks) @trusted @nogc nothrow pure {
2948     return sg_install_trace_hooks(&trace_hooks);
2949 }
2950 extern(C) void sg_push_debug_group(const(char)* name) @system @nogc nothrow pure;
2951 void pushDebugGroup(const(char)* name) @trusted @nogc nothrow pure {
2952     sg_push_debug_group(name);
2953 }
2954 extern(C) void sg_pop_debug_group() @system @nogc nothrow pure;
2955 void popDebugGroup() @trusted @nogc nothrow pure {
2956     sg_pop_debug_group();
2957 }
2958 extern(C) bool sg_add_commit_listener(CommitListener listener) @system @nogc nothrow pure;
2959 bool addCommitListener(CommitListener listener) @trusted @nogc nothrow pure {
2960     return sg_add_commit_listener(listener);
2961 }
2962 extern(C) bool sg_remove_commit_listener(CommitListener listener) @system @nogc nothrow pure;
2963 bool removeCommitListener(CommitListener listener) @trusted @nogc nothrow pure {
2964     return sg_remove_commit_listener(listener);
2965 }
2966 /++
2967 + resource creation, destruction and updating
2968 +/
2969 extern(C) Buffer sg_make_buffer(const BufferDesc* desc) @system @nogc nothrow pure;
2970 Buffer makeBuffer(scope ref BufferDesc desc) @trusted @nogc nothrow pure {
2971     return sg_make_buffer(&desc);
2972 }
2973 extern(C) Image sg_make_image(const ImageDesc* desc) @system @nogc nothrow pure;
2974 Image makeImage(scope ref ImageDesc desc) @trusted @nogc nothrow pure {
2975     return sg_make_image(&desc);
2976 }
2977 extern(C) Sampler sg_make_sampler(const SamplerDesc* desc) @system @nogc nothrow pure;
2978 Sampler makeSampler(scope ref SamplerDesc desc) @trusted @nogc nothrow pure {
2979     return sg_make_sampler(&desc);
2980 }
2981 extern(C) Shader sg_make_shader(const ShaderDesc* desc) @system @nogc nothrow pure;
2982 Shader makeShader(scope ref ShaderDesc desc) @trusted @nogc nothrow pure {
2983     return sg_make_shader(&desc);
2984 }
2985 extern(C) Pipeline sg_make_pipeline(const PipelineDesc* desc) @system @nogc nothrow pure;
2986 Pipeline makePipeline(scope ref PipelineDesc desc) @trusted @nogc nothrow pure {
2987     return sg_make_pipeline(&desc);
2988 }
2989 extern(C) View sg_make_view(const ViewDesc* desc) @system @nogc nothrow pure;
2990 View makeView(scope ref ViewDesc desc) @trusted @nogc nothrow pure {
2991     return sg_make_view(&desc);
2992 }
2993 extern(C) void sg_destroy_buffer(Buffer buf) @system @nogc nothrow pure;
2994 void destroyBuffer(Buffer buf) @trusted @nogc nothrow pure {
2995     sg_destroy_buffer(buf);
2996 }
2997 extern(C) void sg_destroy_image(Image img) @system @nogc nothrow pure;
2998 void destroyImage(Image img) @trusted @nogc nothrow pure {
2999     sg_destroy_image(img);
3000 }
3001 extern(C) void sg_destroy_sampler(Sampler smp) @system @nogc nothrow pure;
3002 void destroySampler(Sampler smp) @trusted @nogc nothrow pure {
3003     sg_destroy_sampler(smp);
3004 }
3005 extern(C) void sg_destroy_shader(Shader shd) @system @nogc nothrow pure;
3006 void destroyShader(Shader shd) @trusted @nogc nothrow pure {
3007     sg_destroy_shader(shd);
3008 }
3009 extern(C) void sg_destroy_pipeline(Pipeline pip) @system @nogc nothrow pure;
3010 void destroyPipeline(Pipeline pip) @trusted @nogc nothrow pure {
3011     sg_destroy_pipeline(pip);
3012 }
3013 extern(C) void sg_destroy_view(View view) @system @nogc nothrow pure;
3014 void destroyView(View view) @trusted @nogc nothrow pure {
3015     sg_destroy_view(view);
3016 }
3017 extern(C) void sg_update_buffer(Buffer buf, const Range* data) @system @nogc nothrow pure;
3018 void updateBuffer(Buffer buf, scope ref Range data) @trusted @nogc nothrow pure {
3019     sg_update_buffer(buf, &data);
3020 }
3021 extern(C) void sg_update_image(Image img, const ImageData* data) @system @nogc nothrow pure;
3022 void updateImage(Image img, scope ref ImageData data) @trusted @nogc nothrow pure {
3023     sg_update_image(img, &data);
3024 }
3025 extern(C) int sg_append_buffer(Buffer buf, const Range* data) @system @nogc nothrow pure;
3026 int appendBuffer(Buffer buf, scope ref Range data) @trusted @nogc nothrow pure {
3027     return sg_append_buffer(buf, &data);
3028 }
3029 extern(C) bool sg_query_buffer_overflow(Buffer buf) @system @nogc nothrow pure;
3030 bool queryBufferOverflow(Buffer buf) @trusted @nogc nothrow pure {
3031     return sg_query_buffer_overflow(buf);
3032 }
3033 extern(C) bool sg_query_buffer_will_overflow(Buffer buf, size_t size) @system @nogc nothrow pure;
3034 bool queryBufferWillOverflow(Buffer buf, size_t size) @trusted @nogc nothrow pure {
3035     return sg_query_buffer_will_overflow(buf, size);
3036 }
3037 /++
3038 + render and compute functions
3039 +/
3040 extern(C) void sg_begin_pass(const Pass* pass) @system @nogc nothrow pure;
3041 void beginPass(scope ref Pass pass) @trusted @nogc nothrow pure {
3042     sg_begin_pass(&pass);
3043 }
3044 extern(C) void sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left) @system @nogc nothrow pure;
3045 void applyViewport(int x, int y, int width, int height, bool origin_top_left) @trusted @nogc nothrow pure {
3046     sg_apply_viewport(x, y, width, height, origin_top_left);
3047 }
3048 extern(C) void sg_apply_viewportf(float x, float y, float width, float height, bool origin_top_left) @system @nogc nothrow pure;
3049 void applyViewportf(float x, float y, float width, float height, bool origin_top_left) @trusted @nogc nothrow pure {
3050     sg_apply_viewportf(x, y, width, height, origin_top_left);
3051 }
3052 extern(C) void sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left) @system @nogc nothrow pure;
3053 void applyScissorRect(int x, int y, int width, int height, bool origin_top_left) @trusted @nogc nothrow pure {
3054     sg_apply_scissor_rect(x, y, width, height, origin_top_left);
3055 }
3056 extern(C) void sg_apply_scissor_rectf(float x, float y, float width, float height, bool origin_top_left) @system @nogc nothrow pure;
3057 void applyScissorRectf(float x, float y, float width, float height, bool origin_top_left) @trusted @nogc nothrow pure {
3058     sg_apply_scissor_rectf(x, y, width, height, origin_top_left);
3059 }
3060 extern(C) void sg_apply_pipeline(Pipeline pip) @system @nogc nothrow pure;
3061 void applyPipeline(Pipeline pip) @trusted @nogc nothrow pure {
3062     sg_apply_pipeline(pip);
3063 }
3064 extern(C) void sg_apply_bindings(const Bindings* bindings) @system @nogc nothrow pure;
3065 void applyBindings(scope ref Bindings bindings) @trusted @nogc nothrow pure {
3066     sg_apply_bindings(&bindings);
3067 }
3068 extern(C) void sg_apply_uniforms(uint ub_slot, const Range* data) @system @nogc nothrow pure;
3069 void applyUniforms(uint ub_slot, scope ref Range data) @trusted @nogc nothrow pure {
3070     sg_apply_uniforms(ub_slot, &data);
3071 }
3072 extern(C) void sg_draw(uint base_element, uint num_elements, uint num_instances) @system @nogc nothrow pure;
3073 void draw(uint base_element, uint num_elements, uint num_instances) @trusted @nogc nothrow pure {
3074     sg_draw(base_element, num_elements, num_instances);
3075 }
3076 extern(C) void sg_draw_ex(int base_element, int num_elements, int num_instances, int base_vertex, int base_instance) @system @nogc nothrow pure;
3077 void drawEx(int base_element, int num_elements, int num_instances, int base_vertex, int base_instance) @trusted @nogc nothrow pure {
3078     sg_draw_ex(base_element, num_elements, num_instances, base_vertex, base_instance);
3079 }
3080 extern(C) void sg_dispatch(uint num_groups_x, uint num_groups_y, uint num_groups_z) @system @nogc nothrow pure;
3081 void dispatch(uint num_groups_x, uint num_groups_y, uint num_groups_z) @trusted @nogc nothrow pure {
3082     sg_dispatch(num_groups_x, num_groups_y, num_groups_z);
3083 }
3084 extern(C) void sg_end_pass() @system @nogc nothrow pure;
3085 void endPass() @trusted @nogc nothrow pure {
3086     sg_end_pass();
3087 }
3088 extern(C) void sg_commit() @system @nogc nothrow pure;
3089 void commit() @trusted @nogc nothrow pure {
3090     sg_commit();
3091 }
3092 /++
3093 + getting information
3094 +/
3095 extern(C) Desc sg_query_desc() @system @nogc nothrow pure;
3096 Desc queryDesc() @trusted @nogc nothrow pure {
3097     return sg_query_desc();
3098 }
3099 extern(C) Backend sg_query_backend() @system @nogc nothrow pure;
3100 Backend queryBackend() @trusted @nogc nothrow pure {
3101     return sg_query_backend();
3102 }
3103 extern(C) Features sg_query_features() @system @nogc nothrow pure;
3104 Features queryFeatures() @trusted @nogc nothrow pure {
3105     return sg_query_features();
3106 }
3107 extern(C) Limits sg_query_limits() @system @nogc nothrow pure;
3108 Limits queryLimits() @trusted @nogc nothrow pure {
3109     return sg_query_limits();
3110 }
3111 extern(C) PixelformatInfo sg_query_pixelformat(PixelFormat fmt) @system @nogc nothrow pure;
3112 PixelformatInfo queryPixelformat(PixelFormat fmt) @trusted @nogc nothrow pure {
3113     return sg_query_pixelformat(fmt);
3114 }
3115 extern(C) int sg_query_row_pitch(PixelFormat fmt, int width, int row_align_bytes) @system @nogc nothrow pure;
3116 int queryRowPitch(PixelFormat fmt, int width, int row_align_bytes) @trusted @nogc nothrow pure {
3117     return sg_query_row_pitch(fmt, width, row_align_bytes);
3118 }
3119 extern(C) int sg_query_surface_pitch(PixelFormat fmt, int width, int height, int row_align_bytes) @system @nogc nothrow pure;
3120 int querySurfacePitch(PixelFormat fmt, int width, int height, int row_align_bytes) @trusted @nogc nothrow pure {
3121     return sg_query_surface_pitch(fmt, width, height, row_align_bytes);
3122 }
3123 /++
3124 + get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID)
3125 +/
3126 extern(C) ResourceState sg_query_buffer_state(Buffer buf) @system @nogc nothrow pure;
3127 ResourceState queryBufferState(Buffer buf) @trusted @nogc nothrow pure {
3128     return sg_query_buffer_state(buf);
3129 }
3130 extern(C) ResourceState sg_query_image_state(Image img) @system @nogc nothrow pure;
3131 ResourceState queryImageState(Image img) @trusted @nogc nothrow pure {
3132     return sg_query_image_state(img);
3133 }
3134 extern(C) ResourceState sg_query_sampler_state(Sampler smp) @system @nogc nothrow pure;
3135 ResourceState querySamplerState(Sampler smp) @trusted @nogc nothrow pure {
3136     return sg_query_sampler_state(smp);
3137 }
3138 extern(C) ResourceState sg_query_shader_state(Shader shd) @system @nogc nothrow pure;
3139 ResourceState queryShaderState(Shader shd) @trusted @nogc nothrow pure {
3140     return sg_query_shader_state(shd);
3141 }
3142 extern(C) ResourceState sg_query_pipeline_state(Pipeline pip) @system @nogc nothrow pure;
3143 ResourceState queryPipelineState(Pipeline pip) @trusted @nogc nothrow pure {
3144     return sg_query_pipeline_state(pip);
3145 }
3146 extern(C) ResourceState sg_query_view_state(View view) @system @nogc nothrow pure;
3147 ResourceState queryViewState(View view) @trusted @nogc nothrow pure {
3148     return sg_query_view_state(view);
3149 }
3150 /++
3151 + get runtime information about a resource
3152 +/
3153 extern(C) BufferInfo sg_query_buffer_info(Buffer buf) @system @nogc nothrow pure;
3154 BufferInfo queryBufferInfo(Buffer buf) @trusted @nogc nothrow pure {
3155     return sg_query_buffer_info(buf);
3156 }
3157 extern(C) ImageInfo sg_query_image_info(Image img) @system @nogc nothrow pure;
3158 ImageInfo queryImageInfo(Image img) @trusted @nogc nothrow pure {
3159     return sg_query_image_info(img);
3160 }
3161 extern(C) SamplerInfo sg_query_sampler_info(Sampler smp) @system @nogc nothrow pure;
3162 SamplerInfo querySamplerInfo(Sampler smp) @trusted @nogc nothrow pure {
3163     return sg_query_sampler_info(smp);
3164 }
3165 extern(C) ShaderInfo sg_query_shader_info(Shader shd) @system @nogc nothrow pure;
3166 ShaderInfo queryShaderInfo(Shader shd) @trusted @nogc nothrow pure {
3167     return sg_query_shader_info(shd);
3168 }
3169 extern(C) PipelineInfo sg_query_pipeline_info(Pipeline pip) @system @nogc nothrow pure;
3170 PipelineInfo queryPipelineInfo(Pipeline pip) @trusted @nogc nothrow pure {
3171     return sg_query_pipeline_info(pip);
3172 }
3173 extern(C) ViewInfo sg_query_view_info(View view) @system @nogc nothrow pure;
3174 ViewInfo queryViewInfo(View view) @trusted @nogc nothrow pure {
3175     return sg_query_view_info(view);
3176 }
3177 /++
3178 + get desc structs matching a specific resource (NOTE that not all creation attributes may be provided)
3179 +/
3180 extern(C) BufferDesc sg_query_buffer_desc(Buffer buf) @system @nogc nothrow pure;
3181 BufferDesc queryBufferDesc(Buffer buf) @trusted @nogc nothrow pure {
3182     return sg_query_buffer_desc(buf);
3183 }
3184 extern(C) ImageDesc sg_query_image_desc(Image img) @system @nogc nothrow pure;
3185 ImageDesc queryImageDesc(Image img) @trusted @nogc nothrow pure {
3186     return sg_query_image_desc(img);
3187 }
3188 extern(C) SamplerDesc sg_query_sampler_desc(Sampler smp) @system @nogc nothrow pure;
3189 SamplerDesc querySamplerDesc(Sampler smp) @trusted @nogc nothrow pure {
3190     return sg_query_sampler_desc(smp);
3191 }
3192 extern(C) ShaderDesc sg_query_shader_desc(Shader shd) @system @nogc nothrow pure;
3193 ShaderDesc queryShaderDesc(Shader shd) @trusted @nogc nothrow pure {
3194     return sg_query_shader_desc(shd);
3195 }
3196 extern(C) PipelineDesc sg_query_pipeline_desc(Pipeline pip) @system @nogc nothrow pure;
3197 PipelineDesc queryPipelineDesc(Pipeline pip) @trusted @nogc nothrow pure {
3198     return sg_query_pipeline_desc(pip);
3199 }
3200 extern(C) ViewDesc sg_query_view_desc(View view) @system @nogc nothrow pure;
3201 ViewDesc queryViewDesc(View view) @trusted @nogc nothrow pure {
3202     return sg_query_view_desc(view);
3203 }
3204 /++
3205 + get resource creation desc struct with their default values replaced
3206 +/
3207 extern(C) BufferDesc sg_query_buffer_defaults(const BufferDesc* desc) @system @nogc nothrow pure;
3208 BufferDesc queryBufferDefaults(scope ref BufferDesc desc) @trusted @nogc nothrow pure {
3209     return sg_query_buffer_defaults(&desc);
3210 }
3211 extern(C) ImageDesc sg_query_image_defaults(const ImageDesc* desc) @system @nogc nothrow pure;
3212 ImageDesc queryImageDefaults(scope ref ImageDesc desc) @trusted @nogc nothrow pure {
3213     return sg_query_image_defaults(&desc);
3214 }
3215 extern(C) SamplerDesc sg_query_sampler_defaults(const SamplerDesc* desc) @system @nogc nothrow pure;
3216 SamplerDesc querySamplerDefaults(scope ref SamplerDesc desc) @trusted @nogc nothrow pure {
3217     return sg_query_sampler_defaults(&desc);
3218 }
3219 extern(C) ShaderDesc sg_query_shader_defaults(const ShaderDesc* desc) @system @nogc nothrow pure;
3220 ShaderDesc queryShaderDefaults(scope ref ShaderDesc desc) @trusted @nogc nothrow pure {
3221     return sg_query_shader_defaults(&desc);
3222 }
3223 extern(C) PipelineDesc sg_query_pipeline_defaults(const PipelineDesc* desc) @system @nogc nothrow pure;
3224 PipelineDesc queryPipelineDefaults(scope ref PipelineDesc desc) @trusted @nogc nothrow pure {
3225     return sg_query_pipeline_defaults(&desc);
3226 }
3227 extern(C) ViewDesc sg_query_view_defaults(const ViewDesc* desc) @system @nogc nothrow pure;
3228 ViewDesc queryViewDefaults(scope ref ViewDesc desc) @trusted @nogc nothrow pure {
3229     return sg_query_view_defaults(&desc);
3230 }
3231 /++
3232 + assorted query functions
3233 +/
3234 extern(C) size_t sg_query_buffer_size(Buffer buf) @system @nogc nothrow pure;
3235 size_t queryBufferSize(Buffer buf) @trusted @nogc nothrow pure {
3236     return sg_query_buffer_size(buf);
3237 }
3238 extern(C) BufferUsage sg_query_buffer_usage(Buffer buf) @system @nogc nothrow pure;
3239 BufferUsage queryBufferUsage(Buffer buf) @trusted @nogc nothrow pure {
3240     return sg_query_buffer_usage(buf);
3241 }
3242 extern(C) ImageType sg_query_image_type(Image img) @system @nogc nothrow pure;
3243 ImageType queryImageType(Image img) @trusted @nogc nothrow pure {
3244     return sg_query_image_type(img);
3245 }
3246 extern(C) int sg_query_image_width(Image img) @system @nogc nothrow pure;
3247 int queryImageWidth(Image img) @trusted @nogc nothrow pure {
3248     return sg_query_image_width(img);
3249 }
3250 extern(C) int sg_query_image_height(Image img) @system @nogc nothrow pure;
3251 int queryImageHeight(Image img) @trusted @nogc nothrow pure {
3252     return sg_query_image_height(img);
3253 }
3254 extern(C) int sg_query_image_num_slices(Image img) @system @nogc nothrow pure;
3255 int queryImageNumSlices(Image img) @trusted @nogc nothrow pure {
3256     return sg_query_image_num_slices(img);
3257 }
3258 extern(C) int sg_query_image_num_mipmaps(Image img) @system @nogc nothrow pure;
3259 int queryImageNumMipmaps(Image img) @trusted @nogc nothrow pure {
3260     return sg_query_image_num_mipmaps(img);
3261 }
3262 extern(C) PixelFormat sg_query_image_pixelformat(Image img) @system @nogc nothrow pure;
3263 PixelFormat queryImagePixelformat(Image img) @trusted @nogc nothrow pure {
3264     return sg_query_image_pixelformat(img);
3265 }
3266 extern(C) ImageUsage sg_query_image_usage(Image img) @system @nogc nothrow pure;
3267 ImageUsage queryImageUsage(Image img) @trusted @nogc nothrow pure {
3268     return sg_query_image_usage(img);
3269 }
3270 extern(C) int sg_query_image_sample_count(Image img) @system @nogc nothrow pure;
3271 int queryImageSampleCount(Image img) @trusted @nogc nothrow pure {
3272     return sg_query_image_sample_count(img);
3273 }
3274 extern(C) ViewType sg_query_view_type(View view) @system @nogc nothrow pure;
3275 ViewType queryViewType(View view) @trusted @nogc nothrow pure {
3276     return sg_query_view_type(view);
3277 }
3278 extern(C) Image sg_query_view_image(View view) @system @nogc nothrow pure;
3279 Image queryViewImage(View view) @trusted @nogc nothrow pure {
3280     return sg_query_view_image(view);
3281 }
3282 extern(C) Buffer sg_query_view_buffer(View view) @system @nogc nothrow pure;
3283 Buffer queryViewBuffer(View view) @trusted @nogc nothrow pure {
3284     return sg_query_view_buffer(view);
3285 }
3286 /++
3287 + separate resource allocation and initialization (for async setup)
3288 +/
3289 extern(C) Buffer sg_alloc_buffer() @system @nogc nothrow pure;
3290 Buffer allocBuffer() @trusted @nogc nothrow pure {
3291     return sg_alloc_buffer();
3292 }
3293 extern(C) Image sg_alloc_image() @system @nogc nothrow pure;
3294 Image allocImage() @trusted @nogc nothrow pure {
3295     return sg_alloc_image();
3296 }
3297 extern(C) Sampler sg_alloc_sampler() @system @nogc nothrow pure;
3298 Sampler allocSampler() @trusted @nogc nothrow pure {
3299     return sg_alloc_sampler();
3300 }
3301 extern(C) Shader sg_alloc_shader() @system @nogc nothrow pure;
3302 Shader allocShader() @trusted @nogc nothrow pure {
3303     return sg_alloc_shader();
3304 }
3305 extern(C) Pipeline sg_alloc_pipeline() @system @nogc nothrow pure;
3306 Pipeline allocPipeline() @trusted @nogc nothrow pure {
3307     return sg_alloc_pipeline();
3308 }
3309 extern(C) View sg_alloc_view() @system @nogc nothrow pure;
3310 View allocView() @trusted @nogc nothrow pure {
3311     return sg_alloc_view();
3312 }
3313 extern(C) void sg_dealloc_buffer(Buffer buf) @system @nogc nothrow pure;
3314 void deallocBuffer(Buffer buf) @trusted @nogc nothrow pure {
3315     sg_dealloc_buffer(buf);
3316 }
3317 extern(C) void sg_dealloc_image(Image img) @system @nogc nothrow pure;
3318 void deallocImage(Image img) @trusted @nogc nothrow pure {
3319     sg_dealloc_image(img);
3320 }
3321 extern(C) void sg_dealloc_sampler(Sampler smp) @system @nogc nothrow pure;
3322 void deallocSampler(Sampler smp) @trusted @nogc nothrow pure {
3323     sg_dealloc_sampler(smp);
3324 }
3325 extern(C) void sg_dealloc_shader(Shader shd) @system @nogc nothrow pure;
3326 void deallocShader(Shader shd) @trusted @nogc nothrow pure {
3327     sg_dealloc_shader(shd);
3328 }
3329 extern(C) void sg_dealloc_pipeline(Pipeline pip) @system @nogc nothrow pure;
3330 void deallocPipeline(Pipeline pip) @trusted @nogc nothrow pure {
3331     sg_dealloc_pipeline(pip);
3332 }
3333 extern(C) void sg_dealloc_view(View view) @system @nogc nothrow pure;
3334 void deallocView(View view) @trusted @nogc nothrow pure {
3335     sg_dealloc_view(view);
3336 }
3337 extern(C) void sg_init_buffer(Buffer buf, const BufferDesc* desc) @system @nogc nothrow pure;
3338 void initBuffer(Buffer buf, scope ref BufferDesc desc) @trusted @nogc nothrow pure {
3339     sg_init_buffer(buf, &desc);
3340 }
3341 extern(C) void sg_init_image(Image img, const ImageDesc* desc) @system @nogc nothrow pure;
3342 void initImage(Image img, scope ref ImageDesc desc) @trusted @nogc nothrow pure {
3343     sg_init_image(img, &desc);
3344 }
3345 extern(C) void sg_init_sampler(Sampler smg, const SamplerDesc* desc) @system @nogc nothrow pure;
3346 void initSampler(Sampler smg, scope ref SamplerDesc desc) @trusted @nogc nothrow pure {
3347     sg_init_sampler(smg, &desc);
3348 }
3349 extern(C) void sg_init_shader(Shader shd, const ShaderDesc* desc) @system @nogc nothrow pure;
3350 void initShader(Shader shd, scope ref ShaderDesc desc) @trusted @nogc nothrow pure {
3351     sg_init_shader(shd, &desc);
3352 }
3353 extern(C) void sg_init_pipeline(Pipeline pip, const PipelineDesc* desc) @system @nogc nothrow pure;
3354 void initPipeline(Pipeline pip, scope ref PipelineDesc desc) @trusted @nogc nothrow pure {
3355     sg_init_pipeline(pip, &desc);
3356 }
3357 extern(C) void sg_init_view(View view, const ViewDesc* desc) @system @nogc nothrow pure;
3358 void initView(View view, scope ref ViewDesc desc) @trusted @nogc nothrow pure {
3359     sg_init_view(view, &desc);
3360 }
3361 extern(C) void sg_uninit_buffer(Buffer buf) @system @nogc nothrow pure;
3362 void uninitBuffer(Buffer buf) @trusted @nogc nothrow pure {
3363     sg_uninit_buffer(buf);
3364 }
3365 extern(C) void sg_uninit_image(Image img) @system @nogc nothrow pure;
3366 void uninitImage(Image img) @trusted @nogc nothrow pure {
3367     sg_uninit_image(img);
3368 }
3369 extern(C) void sg_uninit_sampler(Sampler smp) @system @nogc nothrow pure;
3370 void uninitSampler(Sampler smp) @trusted @nogc nothrow pure {
3371     sg_uninit_sampler(smp);
3372 }
3373 extern(C) void sg_uninit_shader(Shader shd) @system @nogc nothrow pure;
3374 void uninitShader(Shader shd) @trusted @nogc nothrow pure {
3375     sg_uninit_shader(shd);
3376 }
3377 extern(C) void sg_uninit_pipeline(Pipeline pip) @system @nogc nothrow pure;
3378 void uninitPipeline(Pipeline pip) @trusted @nogc nothrow pure {
3379     sg_uninit_pipeline(pip);
3380 }
3381 extern(C) void sg_uninit_view(View view) @system @nogc nothrow pure;
3382 void uninitView(View view) @trusted @nogc nothrow pure {
3383     sg_uninit_view(view);
3384 }
3385 extern(C) void sg_fail_buffer(Buffer buf) @system @nogc nothrow pure;
3386 void failBuffer(Buffer buf) @trusted @nogc nothrow pure {
3387     sg_fail_buffer(buf);
3388 }
3389 extern(C) void sg_fail_image(Image img) @system @nogc nothrow pure;
3390 void failImage(Image img) @trusted @nogc nothrow pure {
3391     sg_fail_image(img);
3392 }
3393 extern(C) void sg_fail_sampler(Sampler smp) @system @nogc nothrow pure;
3394 void failSampler(Sampler smp) @trusted @nogc nothrow pure {
3395     sg_fail_sampler(smp);
3396 }
3397 extern(C) void sg_fail_shader(Shader shd) @system @nogc nothrow pure;
3398 void failShader(Shader shd) @trusted @nogc nothrow pure {
3399     sg_fail_shader(shd);
3400 }
3401 extern(C) void sg_fail_pipeline(Pipeline pip) @system @nogc nothrow pure;
3402 void failPipeline(Pipeline pip) @trusted @nogc nothrow pure {
3403     sg_fail_pipeline(pip);
3404 }
3405 extern(C) void sg_fail_view(View view) @system @nogc nothrow pure;
3406 void failView(View view) @trusted @nogc nothrow pure {
3407     sg_fail_view(view);
3408 }
3409 /++
3410 + frame and total stats
3411 +/
3412 extern(C) void sg_enable_stats() @system @nogc nothrow pure;
3413 void enableStats() @trusted @nogc nothrow pure {
3414     sg_enable_stats();
3415 }
3416 extern(C) void sg_disable_stats() @system @nogc nothrow pure;
3417 void disableStats() @trusted @nogc nothrow pure {
3418     sg_disable_stats();
3419 }
3420 extern(C) bool sg_stats_enabled() @system @nogc nothrow pure;
3421 bool statsEnabled() @trusted @nogc nothrow pure {
3422     return sg_stats_enabled();
3423 }
3424 extern(C) Stats sg_query_stats() @system @nogc nothrow pure;
3425 Stats queryStats() @trusted @nogc nothrow pure {
3426     return sg_query_stats();
3427 }
3428 /++
3429 + Backend-specific structs and functions, these may come in handy for mixing
3430 +    sokol-gfx rendering with 'native backend' rendering functions.
3431 + 
3432 +    This group of functions will be expanded as needed.
3433 +/
3434 extern(C) struct D3d11BufferInfo {
3435     const(void)* buf = null;
3436 }
3437 extern(C) struct D3d11ImageInfo {
3438     const(void)* tex2d = null;
3439     const(void)* tex3d = null;
3440     const(void)* res = null;
3441 }
3442 extern(C) struct D3d11SamplerInfo {
3443     const(void)* smp = null;
3444 }
3445 extern(C) struct D3d11ShaderInfo {
3446     const(void)*[8] cbufs = null;
3447     const(void)* vs = null;
3448     const(void)* fs = null;
3449 }
3450 extern(C) struct D3d11PipelineInfo {
3451     const(void)* il = null;
3452     const(void)* rs = null;
3453     const(void)* dss = null;
3454     const(void)* bs = null;
3455 }
3456 extern(C) struct D3d11ViewInfo {
3457     const(void)* srv = null;
3458     const(void)* uav = null;
3459     const(void)* rtv = null;
3460     const(void)* dsv = null;
3461 }
3462 extern(C) struct MtlBufferInfo {
3463     const(void)*[2] buf = null;
3464     int active_slot = 0;
3465 }
3466 extern(C) struct MtlImageInfo {
3467     const(void)*[2] tex = null;
3468     int active_slot = 0;
3469 }
3470 extern(C) struct MtlSamplerInfo {
3471     const(void)* smp = null;
3472 }
3473 extern(C) struct MtlShaderInfo {
3474     const(void)* vertex_lib = null;
3475     const(void)* fragment_lib = null;
3476     const(void)* vertex_func = null;
3477     const(void)* fragment_func = null;
3478 }
3479 extern(C) struct MtlPipelineInfo {
3480     const(void)* rps = null;
3481     const(void)* dss = null;
3482 }
3483 extern(C) struct WgpuBufferInfo {
3484     const(void)* buf = null;
3485 }
3486 extern(C) struct WgpuImageInfo {
3487     const(void)* tex = null;
3488 }
3489 extern(C) struct WgpuSamplerInfo {
3490     const(void)* smp = null;
3491 }
3492 extern(C) struct WgpuShaderInfo {
3493     const(void)* vs_mod = null;
3494     const(void)* fs_mod = null;
3495     const(void)* bgl = null;
3496 }
3497 extern(C) struct WgpuPipelineInfo {
3498     const(void)* render_pipeline = null;
3499     const(void)* compute_pipeline = null;
3500 }
3501 extern(C) struct WgpuViewInfo {
3502     const(void)* view = null;
3503 }
3504 extern(C) struct GlBufferInfo {
3505     uint[2] buf = [0, 0];
3506     int active_slot = 0;
3507 }
3508 extern(C) struct GlImageInfo {
3509     uint[2] tex = [0, 0];
3510     uint tex_target = 0;
3511     int active_slot = 0;
3512 }
3513 extern(C) struct GlSamplerInfo {
3514     uint smp = 0;
3515 }
3516 extern(C) struct GlShaderInfo {
3517     uint prog = 0;
3518 }
3519 extern(C) struct GlViewInfo {
3520     uint[2] tex_view = [0, 0];
3521     uint msaa_render_buffer = 0;
3522     uint msaa_resolve_frame_buffer = 0;
3523 }
3524 /++
3525 + D3D11: return ID3D11Device
3526 +/
3527 extern(C) const(void)* sg_d3d11_device() @system @nogc nothrow pure;
3528 const(void)* d3d11Device() @trusted @nogc nothrow pure {
3529     return sg_d3d11_device();
3530 }
3531 /++
3532 + D3D11: return ID3D11DeviceContext
3533 +/
3534 extern(C) const(void)* sg_d3d11_device_context() @system @nogc nothrow pure;
3535 const(void)* d3d11DeviceContext() @trusted @nogc nothrow pure {
3536     return sg_d3d11_device_context();
3537 }
3538 /++
3539 + D3D11: get internal buffer resource objects
3540 +/
3541 extern(C) D3d11BufferInfo sg_d3d11_query_buffer_info(Buffer buf) @system @nogc nothrow pure;
3542 D3d11BufferInfo d3d11QueryBufferInfo(Buffer buf) @trusted @nogc nothrow pure {
3543     return sg_d3d11_query_buffer_info(buf);
3544 }
3545 /++
3546 + D3D11: get internal image resource objects
3547 +/
3548 extern(C) D3d11ImageInfo sg_d3d11_query_image_info(Image img) @system @nogc nothrow pure;
3549 D3d11ImageInfo d3d11QueryImageInfo(Image img) @trusted @nogc nothrow pure {
3550     return sg_d3d11_query_image_info(img);
3551 }
3552 /++
3553 + D3D11: get internal sampler resource objects
3554 +/
3555 extern(C) D3d11SamplerInfo sg_d3d11_query_sampler_info(Sampler smp) @system @nogc nothrow pure;
3556 D3d11SamplerInfo d3d11QuerySamplerInfo(Sampler smp) @trusted @nogc nothrow pure {
3557     return sg_d3d11_query_sampler_info(smp);
3558 }
3559 /++
3560 + D3D11: get internal shader resource objects
3561 +/
3562 extern(C) D3d11ShaderInfo sg_d3d11_query_shader_info(Shader shd) @system @nogc nothrow pure;
3563 D3d11ShaderInfo d3d11QueryShaderInfo(Shader shd) @trusted @nogc nothrow pure {
3564     return sg_d3d11_query_shader_info(shd);
3565 }
3566 /++
3567 + D3D11: get internal pipeline resource objects
3568 +/
3569 extern(C) D3d11PipelineInfo sg_d3d11_query_pipeline_info(Pipeline pip) @system @nogc nothrow pure;
3570 D3d11PipelineInfo d3d11QueryPipelineInfo(Pipeline pip) @trusted @nogc nothrow pure {
3571     return sg_d3d11_query_pipeline_info(pip);
3572 }
3573 /++
3574 + D3D11: get internal view resource objects
3575 +/
3576 extern(C) D3d11ViewInfo sg_d3d11_query_view_info(View view) @system @nogc nothrow pure;
3577 D3d11ViewInfo d3d11QueryViewInfo(View view) @trusted @nogc nothrow pure {
3578     return sg_d3d11_query_view_info(view);
3579 }
3580 /++
3581 + Metal: return __bridge-casted MTLDevice
3582 +/
3583 extern(C) const(void)* sg_mtl_device() @system @nogc nothrow pure;
3584 const(void)* mtlDevice() @trusted @nogc nothrow pure {
3585     return sg_mtl_device();
3586 }
3587 /++
3588 + Metal: return __bridge-casted MTLRenderCommandEncoder when inside render pass (otherwise zero)
3589 +/
3590 extern(C) const(void)* sg_mtl_render_command_encoder() @system @nogc nothrow pure;
3591 const(void)* mtlRenderCommandEncoder() @trusted @nogc nothrow pure {
3592     return sg_mtl_render_command_encoder();
3593 }
3594 /++
3595 + Metal: return __bridge-casted MTLComputeCommandEncoder when inside compute pass (otherwise zero)
3596 +/
3597 extern(C) const(void)* sg_mtl_compute_command_encoder() @system @nogc nothrow pure;
3598 const(void)* mtlComputeCommandEncoder() @trusted @nogc nothrow pure {
3599     return sg_mtl_compute_command_encoder();
3600 }
3601 /++
3602 + Metal: return __bridge-casted MTLCommandQueue
3603 +/
3604 extern(C) const(void)* sg_mtl_command_queue() @system @nogc nothrow pure;
3605 const(void)* mtlCommandQueue() @trusted @nogc nothrow pure {
3606     return sg_mtl_command_queue();
3607 }
3608 /++
3609 + Metal: get internal __bridge-casted buffer resource objects
3610 +/
3611 extern(C) MtlBufferInfo sg_mtl_query_buffer_info(Buffer buf) @system @nogc nothrow pure;
3612 MtlBufferInfo mtlQueryBufferInfo(Buffer buf) @trusted @nogc nothrow pure {
3613     return sg_mtl_query_buffer_info(buf);
3614 }
3615 /++
3616 + Metal: get internal __bridge-casted image resource objects
3617 +/
3618 extern(C) MtlImageInfo sg_mtl_query_image_info(Image img) @system @nogc nothrow pure;
3619 MtlImageInfo mtlQueryImageInfo(Image img) @trusted @nogc nothrow pure {
3620     return sg_mtl_query_image_info(img);
3621 }
3622 /++
3623 + Metal: get internal __bridge-casted sampler resource objects
3624 +/
3625 extern(C) MtlSamplerInfo sg_mtl_query_sampler_info(Sampler smp) @system @nogc nothrow pure;
3626 MtlSamplerInfo mtlQuerySamplerInfo(Sampler smp) @trusted @nogc nothrow pure {
3627     return sg_mtl_query_sampler_info(smp);
3628 }
3629 /++
3630 + Metal: get internal __bridge-casted shader resource objects
3631 +/
3632 extern(C) MtlShaderInfo sg_mtl_query_shader_info(Shader shd) @system @nogc nothrow pure;
3633 MtlShaderInfo mtlQueryShaderInfo(Shader shd) @trusted @nogc nothrow pure {
3634     return sg_mtl_query_shader_info(shd);
3635 }
3636 /++
3637 + Metal: get internal __bridge-casted pipeline resource objects
3638 +/
3639 extern(C) MtlPipelineInfo sg_mtl_query_pipeline_info(Pipeline pip) @system @nogc nothrow pure;
3640 MtlPipelineInfo mtlQueryPipelineInfo(Pipeline pip) @trusted @nogc nothrow pure {
3641     return sg_mtl_query_pipeline_info(pip);
3642 }
3643 /++
3644 + WebGPU: return WGPUDevice object
3645 +/
3646 extern(C) const(void)* sg_wgpu_device() @system @nogc nothrow pure;
3647 const(void)* wgpuDevice() @trusted @nogc nothrow pure {
3648     return sg_wgpu_device();
3649 }
3650 /++
3651 + WebGPU: return WGPUQueue object
3652 +/
3653 extern(C) const(void)* sg_wgpu_queue() @system @nogc nothrow pure;
3654 const(void)* wgpuQueue() @trusted @nogc nothrow pure {
3655     return sg_wgpu_queue();
3656 }
3657 /++
3658 + WebGPU: return this frame's WGPUCommandEncoder
3659 +/
3660 extern(C) const(void)* sg_wgpu_command_encoder() @system @nogc nothrow pure;
3661 const(void)* wgpuCommandEncoder() @trusted @nogc nothrow pure {
3662     return sg_wgpu_command_encoder();
3663 }
3664 /++
3665 + WebGPU: return WGPURenderPassEncoder of current pass (returns 0 when outside pass or in a compute pass)
3666 +/
3667 extern(C) const(void)* sg_wgpu_render_pass_encoder() @system @nogc nothrow pure;
3668 const(void)* wgpuRenderPassEncoder() @trusted @nogc nothrow pure {
3669     return sg_wgpu_render_pass_encoder();
3670 }
3671 /++
3672 + WebGPU: return WGPUComputePassEncoder of current pass (returns 0 when outside pass or in a render pass)
3673 +/
3674 extern(C) const(void)* sg_wgpu_compute_pass_encoder() @system @nogc nothrow pure;
3675 const(void)* wgpuComputePassEncoder() @trusted @nogc nothrow pure {
3676     return sg_wgpu_compute_pass_encoder();
3677 }
3678 /++
3679 + WebGPU: get internal buffer resource objects
3680 +/
3681 extern(C) WgpuBufferInfo sg_wgpu_query_buffer_info(Buffer buf) @system @nogc nothrow pure;
3682 WgpuBufferInfo wgpuQueryBufferInfo(Buffer buf) @trusted @nogc nothrow pure {
3683     return sg_wgpu_query_buffer_info(buf);
3684 }
3685 /++
3686 + WebGPU: get internal image resource objects
3687 +/
3688 extern(C) WgpuImageInfo sg_wgpu_query_image_info(Image img) @system @nogc nothrow pure;
3689 WgpuImageInfo wgpuQueryImageInfo(Image img) @trusted @nogc nothrow pure {
3690     return sg_wgpu_query_image_info(img);
3691 }
3692 /++
3693 + WebGPU: get internal sampler resource objects
3694 +/
3695 extern(C) WgpuSamplerInfo sg_wgpu_query_sampler_info(Sampler smp) @system @nogc nothrow pure;
3696 WgpuSamplerInfo wgpuQuerySamplerInfo(Sampler smp) @trusted @nogc nothrow pure {
3697     return sg_wgpu_query_sampler_info(smp);
3698 }
3699 /++
3700 + WebGPU: get internal shader resource objects
3701 +/
3702 extern(C) WgpuShaderInfo sg_wgpu_query_shader_info(Shader shd) @system @nogc nothrow pure;
3703 WgpuShaderInfo wgpuQueryShaderInfo(Shader shd) @trusted @nogc nothrow pure {
3704     return sg_wgpu_query_shader_info(shd);
3705 }
3706 /++
3707 + WebGPU: get internal pipeline resource objects
3708 +/
3709 extern(C) WgpuPipelineInfo sg_wgpu_query_pipeline_info(Pipeline pip) @system @nogc nothrow pure;
3710 WgpuPipelineInfo wgpuQueryPipelineInfo(Pipeline pip) @trusted @nogc nothrow pure {
3711     return sg_wgpu_query_pipeline_info(pip);
3712 }
3713 /++
3714 + WebGPU: get internal view resource objects
3715 +/
3716 extern(C) WgpuViewInfo sg_wgpu_query_view_info(View view) @system @nogc nothrow pure;
3717 WgpuViewInfo wgpuQueryViewInfo(View view) @trusted @nogc nothrow pure {
3718     return sg_wgpu_query_view_info(view);
3719 }
3720 /++
3721 + GL: get internal buffer resource objects
3722 +/
3723 extern(C) GlBufferInfo sg_gl_query_buffer_info(Buffer buf) @system @nogc nothrow pure;
3724 GlBufferInfo glQueryBufferInfo(Buffer buf) @trusted @nogc nothrow pure {
3725     return sg_gl_query_buffer_info(buf);
3726 }
3727 /++
3728 + GL: get internal image resource objects
3729 +/
3730 extern(C) GlImageInfo sg_gl_query_image_info(Image img) @system @nogc nothrow pure;
3731 GlImageInfo glQueryImageInfo(Image img) @trusted @nogc nothrow pure {
3732     return sg_gl_query_image_info(img);
3733 }
3734 /++
3735 + GL: get internal sampler resource objects
3736 +/
3737 extern(C) GlSamplerInfo sg_gl_query_sampler_info(Sampler smp) @system @nogc nothrow pure;
3738 GlSamplerInfo glQuerySamplerInfo(Sampler smp) @trusted @nogc nothrow pure {
3739     return sg_gl_query_sampler_info(smp);
3740 }
3741 /++
3742 + GL: get internal shader resource objects
3743 +/
3744 extern(C) GlShaderInfo sg_gl_query_shader_info(Shader shd) @system @nogc nothrow pure;
3745 GlShaderInfo glQueryShaderInfo(Shader shd) @trusted @nogc nothrow pure {
3746     return sg_gl_query_shader_info(shd);
3747 }
3748 /++
3749 + GL: get internal view resource objects
3750 +/
3751 extern(C) GlViewInfo sg_gl_query_view_info(View view) @system @nogc nothrow pure;
3752 GlViewInfo glQueryViewInfo(View view) @trusted @nogc nothrow pure {
3753     return sg_gl_query_view_info(view);
3754 }