v2 / vlib / sokol / gfx / gfx_structs.c.v
983 lines · 803 sloc · 23.79 KB · 6c710c0b07df2d9824cda86d0ac59ffc2088e23d
Raw
1module gfx
2
3// C.sg_desc describes
4pub struct C.sg_desc {
5pub mut:
6 _start_canary u32
7 buffer_pool_size int
8 image_pool_size int
9 sampler_pool_size int
10 shader_pool_size int
11 pipeline_pool_size int
12 attachments_pool_size int
13 uniform_buffer_size int
14 max_commit_listeners int
15 disable_validation bool // disable validation layer even in debug mode, useful for tests
16 mtl_force_managed_storage_mode bool // for debugging: use Metal managed storage mode for resources even with UMA
17 mtl_use_command_buffer_with_retained_references bool // Metal: use a managed MTLCommandBuffer which ref-counts used resources
18 wgpu_disable_bindgroups_cache bool // set to true to disable the WebGPU backend BindGroup cache
19 wgpu_bindgroups_cache_size int // number of slots in the WebGPU bindgroup cache (must be 2^N)
20 allocator C.sg_allocator
21 logger C.sg_logger // optional log function override
22 environment C.sg_environment
23 _end_canary u32
24}
25
26pub type Desc = C.sg_desc
27
28pub struct C.sg_color_target_state {
29pub mut:
30 pixel_format PixelFormat
31 write_mask ColorMask
32 blend BlendState
33}
34
35pub type ColorTargetState = C.sg_color_target_state
36
37pub struct C.sg_pipeline_desc {
38pub mut:
39 shader Shader
40 layout VertexLayoutState
41 depth DepthState
42 stencil StencilState
43 color_count int
44 colors [4]ColorTargetState // C.SG_MAX_COLOR_ATTACHMENTS
45 primitive_type PrimitiveType
46 index_type IndexType
47 cull_mode CullMode
48 face_winding FaceWinding
49 sample_count int
50 blend_color Color
51 alpha_to_coverage_enabled bool
52 label &char = &char(unsafe { nil })
53}
54
55pub type PipelineDesc = C.sg_pipeline_desc
56
57pub struct C.sg_pipeline_info {
58pub:
59 slot SlotInfo
60}
61
62pub type PipelineInfo = C.sg_pipeline_info
63
64pub struct C.sg_pipeline {
65pub:
66 id u32
67}
68
69pub type Pipeline = C.sg_pipeline
70
71pub fn (mut p C.sg_pipeline) free() {
72 C.sg_destroy_pipeline(*p)
73}
74
75pub struct C.sg_attachments {
76 id u32
77}
78
79// Attachments represents data that can be attached to a render pass.
80// See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
81pub type Attachments = C.sg_attachments
82
83// free frees the resources occupied by the struct
84pub fn (mut a C.sg_attachments) free() {
85 C.sg_destroy_attachments(*a)
86}
87
88pub struct C.sg_attachment_desc {
89pub mut:
90 image Image
91 mip_level int
92 slice int
93}
94
95pub type AttachmentDesc = C.sg_attachment_desc
96
97pub struct C.sg_attachments_desc {
98pub mut:
99 _start_canary u32
100 colors [4]AttachmentDesc
101 resolves [4]AttachmentDesc
102 depth_stencil AttachmentDesc
103 label &char = unsafe { nil }
104 _end_canary u32
105}
106
107pub type AttachmentsDesc = C.sg_attachments_desc
108
109pub struct C.sg_attachments_info {
110pub mut:
111 slot SlotInfo // resource pool slot info
112}
113
114pub type AttachmentsInfo = C.sg_attachments_info
115
116pub struct C.sg_bindings {
117pub mut:
118 _start_canary u32
119 vertex_buffers [8]Buffer
120 vertex_buffer_offsets [8]int
121 index_buffer Buffer
122 index_buffer_offset int
123 vs StageBindings
124 fs StageBindings
125 _end_canary u32
126 // vs_images [8]Image // old
127 // fs_images [8]Image // old
128}
129
130pub type Bindings = C.sg_bindings
131
132pub fn (mut b Bindings) set_vert_image(index int, img Image) {
133 b.vs.images[index] = img
134}
135
136pub fn (mut b Bindings) set_frag_image(index int, img Image) {
137 b.fs.images[index] = img
138}
139
140pub fn (b &Bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int) {
141 range := Range{
142 ptr: data
143 size: usize(element_size * element_count)
144 }
145 C.sg_update_buffer(b.vertex_buffers[index], &range)
146}
147
148pub fn (b &Bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int {
149 range := Range{
150 ptr: data
151 size: usize(element_size * element_count)
152 }
153 return C.sg_append_buffer(b.vertex_buffers[index], &range)
154}
155
156pub fn (b &Bindings) update_index_buffer(data voidptr, element_size int, element_count int) {
157 range := Range{
158 ptr: data
159 size: usize(element_size * element_count)
160 }
161 C.sg_update_buffer(b.index_buffer, &range)
162}
163
164pub fn (b &Bindings) append_index_buffer(data voidptr, element_size int, element_count int) int {
165 range := Range{
166 ptr: data
167 size: usize(element_size * element_count)
168 }
169 return C.sg_append_buffer(b.index_buffer, &range)
170}
171
172pub struct C.sg_stage_bindings {
173pub mut:
174 images [12]Image
175 samplers [8]Sampler
176 storage_buffers [8]Buffer
177}
178
179pub type StageBindings = C.sg_stage_bindings
180
181@[heap]
182pub struct C.sg_shader_desc {
183pub mut:
184 attrs [16]ShaderAttrDesc
185 vs ShaderStageDesc
186 fs ShaderStageDesc
187 label &char
188}
189
190pub type ShaderDesc = C.sg_shader_desc
191
192pub fn (mut desc C.sg_shader_desc) set_vert_src(src string) &ShaderDesc {
193 desc.vs.source = &char(src.str)
194 return desc
195}
196
197pub fn (mut desc C.sg_shader_desc) set_frag_src(src string) &ShaderDesc {
198 desc.fs.source = &char(src.str)
199 return desc
200}
201
202pub fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &ShaderDesc {
203 // desc.vs.images[index].name = &char(name.str)
204 desc.vs.images[index].image_type = ._2d
205 return desc
206}
207
208pub fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &ShaderDesc {
209 // desc.fs.images[index].name = &char(name.str)
210 desc.fs.images[index].image_type = ._2d
211 return desc
212}
213
214pub fn (mut desc C.sg_shader_desc) set_vert_uniform_block_size(block_index int, size usize) &ShaderDesc {
215 desc.vs.uniform_blocks[block_index].size = size
216 return desc
217}
218
219pub fn (mut desc C.sg_shader_desc) set_frag_uniform_block_size(block_index int, size usize) &ShaderDesc {
220 desc.fs.uniform_blocks[block_index].size = size
221 return desc
222}
223
224pub fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, typ UniformType,
225 array_count int) &ShaderDesc {
226 desc.vs.uniform_blocks[block_index].uniforms[uniform_index].name = &char(name.str)
227 desc.vs.uniform_blocks[block_index].uniforms[uniform_index].type = typ
228 desc.vs.uniform_blocks[block_index].uniforms[uniform_index].array_count = array_count
229 return desc
230}
231
232pub fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, typ UniformType,
233 array_count int) &ShaderDesc {
234 desc.fs.uniform_blocks[block_index].uniforms[uniform_index].name = &char(name.str)
235 desc.fs.uniform_blocks[block_index].uniforms[uniform_index].type = typ
236 desc.fs.uniform_blocks[block_index].uniforms[uniform_index].array_count = array_count
237 return desc
238}
239
240pub fn (desc &ShaderDesc) make_shader() Shader {
241 return C.sg_make_shader(desc)
242}
243
244pub struct C.sg_shader_attr_desc {
245pub mut:
246 name &char // GLSL vertex attribute name (only required for GLES2)
247 sem_name &char // HLSL semantic name
248 sem_index int // HLSL semantic index
249}
250
251pub type ShaderAttrDesc = C.sg_shader_attr_desc
252
253pub struct C.sg_shader_stage_desc {
254pub mut:
255 source &char
256 bytecode Range
257 entry &char
258 d3d11_target &char
259 uniform_blocks [4]ShaderUniformBlockDesc
260 storage_buffers [8]ShaderStorageBufferDesc
261 images [12]ShaderImageDesc
262 samplers [8]ShaderSamplerDesc
263 image_sampler_pairs [12]ShaderImageSamplerPairDesc
264}
265
266pub type ShaderStageDesc = C.sg_shader_stage_desc
267
268pub fn (mut desc ShaderStageDesc) set_image(index int, name string) ShaderStageDesc {
269 // desc.images[index].name = &char(name.str)
270 desc.images[index].image_type = ._2d
271 return *desc
272}
273
274pub struct C.sg_shader_uniform_block_desc {
275pub mut:
276 size usize
277 layout UniformLayout
278 uniforms [16]ShaderUniformDesc
279}
280
281pub type ShaderUniformBlockDesc = C.sg_shader_uniform_block_desc
282
283pub struct C.sg_shader_uniform_desc {
284pub mut:
285 name &char
286 type UniformType
287 array_count int
288}
289
290pub type ShaderUniformDesc = C.sg_shader_uniform_desc
291
292pub struct C.sg_shader_image_desc {
293pub mut:
294 used bool
295 multisampled bool
296 // name &char
297 image_type ImageType
298 sample_type ImageSampleType
299}
300
301pub type ShaderImageDesc = C.sg_shader_image_desc
302
303pub struct C.sg_shader_storage_buffer_desc {
304pub mut:
305 used bool
306 readonly bool
307}
308
309pub type ShaderStorageBufferDesc = C.sg_shader_storage_buffer_desc
310
311pub struct C.sg_shader_sampler_desc {
312pub mut:
313 used bool
314 sampler_type SamplerType
315}
316
317pub type ShaderSamplerDesc = C.sg_shader_sampler_desc
318
319pub struct C.sg_shader_image_sampler_pair_desc {
320pub mut:
321 used bool
322 image_slot int
323 sampler_slot int
324 glsl_name &char
325}
326
327pub type ShaderImageSamplerPairDesc = C.sg_shader_image_sampler_pair_desc
328
329pub struct C.sg_shader_info {
330pub:
331 slot SlotInfo
332}
333
334pub type ShaderInfo = C.sg_shader_info
335
336pub struct C.sg_range {
337pub mut:
338 ptr voidptr
339 size usize
340}
341
342pub type Range = C.sg_range
343
344pub struct C.sg_color {
345pub mut:
346 r f32
347 g f32
348 b f32
349 a f32
350}
351
352pub type Color = C.sg_color
353
354pub struct C.sg_shader {
355pub:
356 id u32
357}
358
359pub type Shader = C.sg_shader
360
361pub fn (mut s Shader) free() {
362 C.sg_destroy_shader(*s)
363}
364
365@[typedef]
366pub struct C.sg_frame_stats_gl {
367 num_bind_buffer u32
368 num_active_texture u32
369 num_bind_texture u32
370 num_bind_sampler u32
371 num_use_program u32
372 num_render_state u32
373 num_vertex_attrib_pointer u32
374 num_vertex_attrib_divisor u32
375 num_enable_vertex_attrib_array u32
376 num_disable_vertex_attrib_array u32
377 num_uniform u32
378}
379
380pub type FrameStatsGL = C.sg_frame_stats_gl
381
382@[typedef]
383pub struct C.sg_frame_stats_d3d11_pass {
384 num_om_set_render_targets u32
385 num_clear_render_target_view u32
386 num_clear_depth_stencil_view u32
387 num_resolve_subresource u32
388}
389
390pub type FrameStatsD3D11Pass = C.sg_frame_stats_d3d11_pass
391
392@[typedef]
393pub struct C.sg_frame_stats_d3d11_pipeline {
394 num_rs_set_state u32
395 num_om_set_depth_stencil_state u32
396 num_om_set_blend_state u32
397 num_ia_set_primitive_topology u32
398 num_ia_set_input_layout u32
399 num_vs_set_shader u32
400 num_vs_set_constant_buffers u32
401 num_ps_set_shader u32
402 num_ps_set_constant_buffers u32
403}
404
405pub type FrameStatsD3D11Pipeline = C.sg_frame_stats_d3d11_pipeline
406
407@[typedef]
408pub struct C.sg_frame_stats_d3d11_bindings {
409 num_ia_set_vertex_buffers u32
410 num_ia_set_index_buffer u32
411 num_vs_set_shader_resources u32
412 num_ps_set_shader_resources u32
413 num_vs_set_samplers u32
414 num_ps_set_samplers u32
415}
416
417pub type FrameStatsD3D11Bindings = C.sg_frame_stats_d3d11_bindings
418
419@[typedef]
420pub struct C.sg_frame_stats_d3d11_uniforms {
421 num_update_subresource u32
422}
423
424pub type FrameStatsD3D11Uniforms = C.sg_frame_stats_d3d11_uniforms
425
426@[typedef]
427pub struct C.sg_frame_stats_d3d11_draw {
428 num_draw_indexed_instanced u32
429 num_draw_indexed u32
430 num_draw_instanced u32
431 num_draw u32
432}
433
434pub type FrameStatsD3D11Draw = C.sg_frame_stats_d3d11_draw
435
436@[typedef]
437pub struct C.sg_frame_stats_d3d11 {
438 pass FrameStatsD3D11Pass
439 pipeline FrameStatsD3D11Pipeline
440 bindings FrameStatsD3D11Bindings
441 uniforms FrameStatsD3D11Uniforms
442 draw FrameStatsD3D11Draw
443 num_map u32
444 num_unmap u32
445}
446
447pub type FrameStatsD3D11 = C.sg_frame_stats_d3d11
448
449@[typedef]
450pub struct C.sg_frame_stats_metal_idpool {
451 num_added u32
452 num_released u32
453 num_garbage_collected u32
454}
455
456pub type FrameStatsMetalIdpool = C.sg_frame_stats_metal_idpool
457
458@[typedef]
459pub struct C.sg_frame_stats_metal_pipeline {
460 num_set_blend_color u32
461 num_set_cull_mode u32
462 num_set_front_facing_winding u32
463 num_set_stencil_reference_value u32
464 num_set_depth_bias u32
465 num_set_render_pipeline_state u32
466 num_set_depth_stencil_state u32
467}
468
469pub type FrameStatsMetalPipeline = C.sg_frame_stats_metal_pipeline
470
471@[typedef]
472pub struct C.sg_frame_stats_metal_bindings {
473 num_set_vertex_buffer u32
474 num_set_vertex_texture u32
475 num_set_vertex_sampler_state u32
476 num_set_fragment_buffer u32
477 num_set_fragment_texture u32
478 num_set_fragment_sampler_state u32
479}
480
481pub type FrameStatsMetalBindings = C.sg_frame_stats_metal_bindings
482
483@[typedef]
484pub struct C.sg_frame_stats_metal_uniforms {
485 num_set_vertex_buffer_offset u32
486 num_set_fragment_buffer_offset u32
487}
488
489pub type FrameStatsMetalUniforms = C.sg_frame_stats_metal_uniforms
490
491@[typedef]
492pub struct C.sg_frame_stats_metal {
493 idpool FrameStatsMetalIdpool
494 pipeline FrameStatsMetalPipeline
495 bindings FrameStatsMetalBindings
496 uniforms FrameStatsMetalUniforms
497}
498
499pub type FrameStatsMetal = C.sg_frame_stats_metal
500
501@[typedef]
502pub struct C.sg_frame_stats_wgpu_uniforms {
503 num_set_bindgroup u32
504 size_write_buffer u32
505}
506
507pub type FrameStatsWGPUUniforms = C.sg_frame_stats_wgpu_uniforms
508
509@[typedef]
510pub struct C.sg_frame_stats_wgpu_bindings {
511 num_set_vertex_buffer u32
512 num_skip_redundant_vertex_buffer u32
513 num_set_index_buffer u32
514 num_skip_redundant_index_buffer u32
515 num_create_bindgroup u32
516 num_discard_bindgroup u32
517 num_set_bindgroup u32
518 num_skip_redundant_bindgroup u32
519 num_bindgroup_cache_hits u32
520 num_bindgroup_cache_misses u32
521 num_bindgroup_cache_collisions u32
522 num_bindgroup_cache_hash_vs_key_mismatch u32
523}
524
525pub type FrameStatsWGPUBindings = C.sg_frame_stats_wgpu_bindings
526
527@[typedef]
528pub struct C.sg_frame_stats_wgpu {
529 uniforms FrameStatsWGPUUniforms
530 bindings FrameStatsWGPUBindings
531}
532
533pub type FrameStatsWGPU = C.sg_frame_stats_wgpu
534
535@[typedef]
536pub struct C.sg_frame_stats {
537 frame_index u32 // current frame counter, starts at 0
538
539 num_passes u32
540 num_apply_viewport u32
541 num_apply_scissor_rect u32
542 num_apply_pipeline u32
543 num_apply_bindings u32
544 num_apply_uniforms u32
545 num_draw u32
546 num_update_buffer u32
547 num_append_buffer u32
548 num_update_image u32
549
550 size_apply_uniforms u32
551 size_update_buffer u32
552 size_append_buffer u32
553 size_update_image u32
554
555 gl FrameStatsGL
556 d3d11 FrameStatsD3D11
557 metal FrameStatsMetal
558 wgpu FrameStatsWGPU
559}
560
561pub type FrameStats = C.sg_frame_stats
562
563pub struct C.sg_pass_action {
564pub mut:
565 colors [4]ColorAttachmentAction
566 depth DepthAttachmentAction
567 stencil StencilAttachmentAction
568}
569
570pub type PassAction = C.sg_pass_action
571
572@[typedef]
573pub struct C.sg_metal_swapchain {
574pub mut:
575 current_drawable voidptr
576 depth_stencil_texture voidptr // MTLTexture
577 msaa_color_texture voidptr // MTLTexture
578}
579
580pub type MetalSwapchain = C.sg_metal_swapchain
581
582@[typedef]
583pub struct C.sg_d3d11_swapchain {
584pub mut:
585 render_view voidptr // ID3D11RenderTargetView
586 resolve_view voidptr // ID3D11RenderTargetView
587 depth_stencil_view voidptr // ID3D11DepthStencilView
588}
589
590pub type D3d11Swapchain = C.sg_d3d11_swapchain
591
592@[typedef]
593pub struct C.sg_wgpu_swapchain {
594pub mut:
595 render_view voidptr // WGPUTextureView
596 resolve_view voidptr // WGPUTextureView
597 depth_stencil_view voidptr // WGPUTextureView
598}
599
600pub type WgpuSwapchain = C.sg_wgpu_swapchain
601
602@[typedef]
603pub struct C.sg_gl_swapchain {
604pub mut:
605 framebuffer u32
606}
607
608pub type GlSwapchain = C.sg_gl_swapchain
609
610@[typedef]
611pub struct C.sg_swapchain {
612pub mut:
613 width int
614 height int
615 sample_count int
616 color_format PixelFormat
617 depth_format PixelFormat
618 metal MetalSwapchain
619 d3d11 D3d11Swapchain
620 wgpu WgpuSwapchain
621 gl GlSwapchain
622}
623
624pub type Swapchain = C.sg_swapchain
625
626@[typedef]
627pub struct C.sg_pass {
628pub mut:
629 _start_canary u32
630 action PassAction
631 attachments Attachments
632 swapchain Swapchain
633 label &char = unsafe { nil }
634 _end_canary u32
635}
636
637pub type Pass = C.sg_pass
638
639pub struct C.sg_buffer_desc {
640pub mut:
641 size usize
642 type BufferType
643 usage Usage
644 data Range
645 label &char
646 // backend-specific resources
647 gl_buffers [2]u32
648 mtl_buffers [2]voidptr
649 d3d11_buffer voidptr
650 wgpu_buffer voidptr
651}
652
653pub type BufferDesc = C.sg_buffer_desc
654
655pub struct C.sg_slot_info {
656 state ResourceState
657 res_id u32
658 ctx_id u32
659}
660
661pub type SlotInfo = C.sg_slot_info
662
663pub struct C.sg_buffer_info {
664pub:
665 slot SlotInfo
666 update_frame_index u32
667 append_frame_index u32
668 append_pos int
669 append_overflow bool
670 num_slots int
671 active_slot int
672}
673
674pub type BufferInfo = C.sg_buffer_info
675
676pub struct C.sg_buffer {
677 id u32
678}
679
680pub type Buffer = C.sg_buffer
681
682pub fn (mut b Buffer) free() {
683 C.sg_destroy_buffer(*b)
684}
685
686pub struct C.sg_image_desc {
687pub mut:
688 type ImageType
689 render_target bool
690 width int
691 height int
692 num_slices int
693 num_mipmaps int
694 usage Usage
695 pixel_format PixelFormat
696 sample_count int
697 // min_filter Filter
698 // mag_filter Filter
699 // wrap_u Wrap
700 // wrap_v Wrap
701 // wrap_w Wrap
702 // border_color BorderColor
703 // max_anisotropy u32
704 // min_lod f32
705 // max_lod f32
706 data ImageData
707 label &char
708 // backend-specific resources
709 gl_textures [2]u32
710 gl_texture_target u32
711 mtl_textures [2]voidptr
712 d3d11_texture voidptr
713 d3d11_shader_resource_view voidptr
714 wgpu_texture voidptr
715}
716
717pub type ImageDesc = C.sg_image_desc
718
719pub struct C.sg_sampler_desc {
720 min_filter Filter
721 mag_filter Filter
722 mipmap_filter Filter
723 wrap_u Wrap
724 wrap_v Wrap
725 wrap_w Wrap
726 min_lod f32
727 max_lod f32
728 border_color BorderColor
729 compare CompareFunc
730 max_anisotropy u32
731 label &char
732 // backend-specific resources
733 gl_sampler u32
734 mtl_sampler voidptr
735 d3d11_sampler voidptr
736 wgpu_sampler voidptr
737}
738
739pub type SamplerDesc = C.sg_sampler_desc
740
741pub struct C.sg_image_info {
742pub mut:
743 slot SlotInfo // resource pool slot info
744 upd_frame_index u32 // frame index of last sg_update_image()
745 num_slots int // number of renaming-slots for dynamically updated images
746 active_slot int // currently active write-slot for dynamically updated images
747}
748
749pub type ImageInfo = C.sg_image_info
750
751pub struct C.sg_image {
752pub mut:
753 id u32
754}
755
756pub type Image = C.sg_image
757
758pub fn (mut i Image) free() {
759 C.sg_destroy_image(*i)
760}
761
762pub struct C.sg_sampler {
763pub mut:
764 id u32
765}
766
767pub type Sampler = C.sg_sampler
768
769pub const sg_cubeface_num = 6
770
771pub const sg_max_mipmaps = 16
772
773pub struct C.sg_image_data {
774pub mut:
775 subimage [sg_cubeface_num][sg_max_mipmaps]Range
776}
777
778pub type ImageData = C.sg_image_data
779
780pub struct C.sg_features {
781pub:
782 origin_top_left bool // framebuffer and texture origin is in top left corner
783 image_clamp_to_border bool // border color and clamp-to-border UV-wrap mode is supported
784 mrt_independent_blend_state bool // multiple-render-target rendering can use per-render-target blend state
785 mrt_independent_write_mask bool // multiple-render-target rendering can use per-render-target color write masks
786 storage_buffer bool // storage buffers are supported
787}
788
789pub type Features = C.sg_features
790
791pub struct C.sg_limits {
792pub:
793 max_image_size_2d int // max width/height of SG_IMAGETYPE_2D images
794 max_image_size_cube int // max width/height of SG_IMAGETYPE_CUBE images
795 max_image_size_3d int // max width/height/depth of SG_IMAGETYPE_3D images
796 max_image_size_array int // max width/height pf SG_IMAGETYPE_ARRAY images
797 max_image_array_layers int // max number of layers in SG_IMAGETYPE_ARRAY images
798 max_vertex_attrs int // <= SG_MAX_VERTEX_ATTRIBUTES (only on some GLES2 impls)
799 gl_max_vertex_uniform_components int // <= GL_MAX_VERTEX_UNIFORM_COMPONENTS (only on GL backends)
800 gl_max_combined_texture_image_units int // <= GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (only on GL backends)
801}
802
803pub type Limits = C.sg_limits
804
805pub struct C.sg_vertex_layout_state {
806pub mut:
807 buffers [8]VertexBufferLayoutState
808 attrs [16]VertexAttrDesc
809}
810
811pub type VertexLayoutState = C.sg_vertex_layout_state
812
813pub struct C.sg_vertex_buffer_layout_state {
814pub mut:
815 stride int
816 step_func VertexStep
817 step_rate int
818}
819
820pub type VertexBufferLayoutState = C.sg_vertex_buffer_layout_state
821
822pub struct C.sg_vertex_attr_state {
823pub mut:
824 buffer_index int
825 offset int
826 format VertexFormat
827}
828
829pub type VertexAttrDesc = C.sg_vertex_attr_state
830
831pub struct C.sg_stencil_state {
832 enabled bool
833 front StencilFaceState
834 back StencilFaceState
835 read_mask u8
836 write_mask u8
837 ref u8
838}
839
840pub type StencilState = C.sg_stencil_state
841
842pub struct C.sg_depth_state {
843 pixel_format PixelFormat
844 compare CompareFunc
845 write_enabled bool
846 bias f32
847 bias_slope_scale f32
848 bias_clamp f32
849}
850
851pub type DepthState = C.sg_depth_state
852
853pub struct C.sg_stencil_face_state {
854 compare CompareFunc
855 fail_op StencilOp
856 depth_fail_op StencilOp
857 pass_op StencilOp
858}
859
860pub type StencilFaceState = C.sg_stencil_face_state
861
862pub struct C.sg_blend_state {
863pub mut:
864 enabled bool
865 src_factor_rgb BlendFactor
866 dst_factor_rgb BlendFactor
867 op_rgb BlendOp
868 src_factor_alpha BlendFactor
869 dst_factor_alpha BlendFactor
870 op_alpha BlendOp
871}
872
873pub type BlendState = C.sg_blend_state
874
875pub struct C.sg_color_attachment_action {
876pub mut:
877 load_action LoadAction
878 store_action StoreAction
879 clear_value Color
880}
881
882pub type ColorAttachmentAction = C.sg_color_attachment_action
883
884/*
885pub fn (mut action C.sg_color_attachment_action) set_color_values(r, g, b, a f32) {
886 action.val[0] = r
887 action.val[1] = g
888 action.val[2] = b
889 action.val[3] = a
890}
891*/
892pub struct C.sg_depth_attachment_action {
893pub mut:
894 load_action LoadAction
895 store_action StoreAction
896 clear_value f32
897}
898
899pub type DepthAttachmentAction = C.sg_depth_attachment_action
900
901pub struct C.sg_stencil_attachment_action {
902pub mut:
903 load_action LoadAction
904 store_action StoreAction
905 clear_value u8
906}
907
908pub type StencilAttachmentAction = C.sg_stencil_attachment_action
909
910pub struct C.sg_pixelformat_info {
911pub:
912 sample bool // pixel format can be sampled in shaders
913 filter bool // pixel format can be sampled with filtering
914 render bool // pixel format can be used as render target
915 blend bool // alpha-blending is supported
916 msaa bool // pixel format can be used as MSAA render target
917 depth bool // pixel format is a depth format
918}
919
920pub type PixelFormatInfo = C.sg_pixelformat_info
921
922@[typedef]
923pub struct C.sg_environment_defaults {
924pub mut:
925 color_format PixelFormat
926 depth_format PixelFormat
927 sample_count int
928}
929
930pub type EnvironmentDefaults = C.sg_environment_defaults
931
932@[typedef]
933pub struct C.sg_metal_environment {
934pub mut:
935 device voidptr
936}
937
938pub type MetalEnvironment = C.sg_metal_environment
939
940@[typedef]
941pub struct C.sg_d3d11_environment {
942pub mut:
943 device voidptr
944 device_context voidptr
945}
946
947pub type D3d11Environment = C.sg_d3d11_environment
948
949@[typedef]
950pub struct C.sg_wgpu_environment {
951pub mut:
952 device voidptr
953}
954
955pub type WgpuEnvironment = C.sg_wgpu_environment
956
957@[typedef]
958pub struct C.sg_environment {
959pub mut:
960 defaults EnvironmentDefaults
961 metal MetalEnvironment
962 d3d11 D3d11Environment
963 wgpu WgpuEnvironment
964}
965
966pub type Environment = C.sg_environment
967
968// C.sg_commit_listener is used with sg_add_commit_listener, to add a callback,
969// which will be called in sg_commit(). This is useful for libraries building
970// on top of sokol-gfx to be notified about when a frame ends (instead of having
971// to guess, or add a manual 'new-frame' function).
972pub struct C.sg_commit_listener {
973pub:
974 func fn (user_data voidptr)
975 user_data voidptr
976}
977
978pub type CommitListener = C.sg_commit_listener
979
980pub struct C.sg_trace_hooks {}
981
982// pub struct C.sg_resource_state {} enum
983pub struct C.sg_sampler_info {}
984