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