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