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