Debian Codegraph @

demo/sokol/sokol_gfx.h

raw symbols SCIP
1 #cxx . . $ `<file>/demo/sokol/sokol_gfx.h`/pragma once
2 /*
3 sokol_gfx.h -- simple 3D API wrapper
4
5 Project URL: https://github.com/floooh/sokol
6
7 Do this:
8 #define SOKOL_IMPL
9 before you include this file in *one* C or C++ file to create the
10 implementation.
11
12 In the same place define one of the following to select the rendering
13 backend:
14 #define SOKOL_GLCORE33
15 #define SOKOL_GLES2
16 #define SOKOL_GLES3
17 #define SOKOL_D3D11
18 #define SOKOL_METAL
19 #define SOKOL_DUMMY_BACKEND
20
21 I.e. for the GL 3.3 Core Profile it should look like this:
22
23 #include ...
24 #include ...
25 #define SOKOL_IMPL
26 #define SOKOL_GLCORE33
27 #include "sokol_gfx.h"
28
29 The dummy backend replaces the platform-specific backend code with empty
30 stub functions. This is useful for writing tests that need to run on the
31 command line.
32
33 Optionally provide the following defines with your own implementations:
34
35 SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
36 SOKOL_MALLOC(s) - your own malloc function (default: malloc(s))
37 SOKOL_FREE(p) - your own free function (default: free(p))
38 SOKOL_LOG(msg) - your own logging function (default: puts(msg))
39 SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
40 SOKOL_API_DECL - public function declaration prefix (default: extern)
41 SOKOL_API_IMPL - public function implementation prefix (default: -)
42 SOKOL_TRACE_HOOKS - enable trace hook callbacks (search below for TRACE HOOKS)
43
44 If sokol_gfx.h is compiled as a DLL, define the following before
45 including the declaration or implementation:
46
47 SOKOL_DLL
48
49 On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
50 or __declspec(dllimport) as needed.
51
52 If you want to compile without deprecated structs and functions,
53 define:
54
55 SOKOL_NO_DEPRECATED
56
57 API usage validation macros:
58
59 SOKOL_VALIDATE_BEGIN() - begin a validation block (default:_sg_validate_begin())
60 SOKOL_VALIDATE(cond, err) - like assert but for API validation (default: _sg_validate(cond, err))
61 SOKOL_VALIDATE_END() - end a validation block, return true if all checks in block passed (default: bool _sg_validate())
62
63 If you don't want validation errors to be fatal, define SOKOL_VALIDATE_NON_FATAL,
64 be aware though that this may spam SOKOL_LOG messages.
65
66 Optionally define the following to force debug checks and validations
67 even in release mode:
68
69 SOKOL_DEBUG - by default this is defined if _DEBUG is defined
70
71
72 sokol_gfx DOES NOT:
73 ===================
74 - create a window or the 3D-API context/device, you must do this
75 before sokol_gfx is initialized, and pass any required information
76 (like 3D device pointers) to the sokol_gfx initialization call
77
78 - present the rendered frame, how this is done exactly usually depends
79 on how the window and 3D-API context/device was created
80
81 - provide a unified shader language, instead 3D-API-specific shader
82 source-code or shader-bytecode must be provided
83
84 For complete code examples using the various backend 3D-APIs, see:
85
86 https://github.com/floooh/sokol-samples
87
88 For an optional shader-cross-compile solution, see:
89
90 https://github.com/floooh/sokol-tools/blob/master/docs/sokol-shdc.md
91
92
93 STEP BY STEP
94 ============
95 --- to initialize sokol_gfx, after creating a window and a 3D-API
96 context/device, call:
97
98 sg_setup(const sg_desc*)
99
100 --- create resource objects (at least buffers, shaders and pipelines,
101 and optionally images and passes):
102
103 sg_buffer sg_make_buffer(const sg_buffer_desc*)
104 sg_image sg_make_image(const sg_image_desc*)
105 sg_shader sg_make_shader(const sg_shader_desc*)
106 sg_pipeline sg_make_pipeline(const sg_pipeline_desc*)
107 sg_pass sg_make_pass(const sg_pass_desc*)
108
109 --- start rendering to the default frame buffer with:
110
111 sg_begin_default_pass(const sg_pass_action* actions, int width, int height)
112
113 --- or start rendering to an offscreen framebuffer with:
114
115 sg_begin_pass(sg_pass pass, const sg_pass_action* actions)
116
117 --- set the pipeline state for the next draw call with:
118
119 sg_apply_pipeline(sg_pipeline pip)
120
121 --- fill an sg_bindings struct with the resource bindings for the next
122 draw call (1..N vertex buffers, 0 or 1 index buffer, 0..N image objects
123 to use as textures each on the vertex-shader- and fragment-shader-stage
124 and then call
125
126 sg_apply_bindings(const sg_bindings* bindings)
127
128 to update the resource bindings
129
130 --- optionally update shader uniform data with:
131
132 sg_apply_uniforms(sg_shader_stage stage, int ub_index, const void* data, int num_bytes)
133
134 --- kick off a draw call with:
135
136 sg_draw(int base_element, int num_elements, int num_instances)
137
138 --- finish the current rendering pass with:
139
140 sg_end_pass()
141
142 --- when done with the current frame, call
143
144 sg_commit()
145
146 --- at the end of your program, shutdown sokol_gfx with:
147
148 sg_shutdown()
149
150 --- if you need to destroy resources before sg_shutdown(), call:
151
152 sg_destroy_buffer(sg_buffer buf)
153 sg_destroy_image(sg_image img)
154 sg_destroy_shader(sg_shader shd)
155 sg_destroy_pipeline(sg_pipeline pip)
156 sg_destroy_pass(sg_pass pass)
157
158 --- to set a new viewport rectangle, call
159
160 sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left)
161
162 --- to set a new scissor rect, call:
163
164 sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left)
165
166 both sg_apply_viewport() and sg_apply_scissor_rect() must be called
167 inside a rendering pass
168
169 beginning a pass will reset the viewport to the size of the framebuffer used
170 in the new pass,
171
172 --- to update (overwrite) the content of buffer and image resources, call:
173
174 sg_update_buffer(sg_buffer buf, const void* ptr, int num_bytes)
175 sg_update_image(sg_image img, const sg_image_content* content)
176
177 Buffers and images to be updated must have been created with
178 SG_USAGE_DYNAMIC or SG_USAGE_STREAM
179
180 Only one update per frame is allowed for buffer and image resources.
181 The rationale is to have a simple countermeasure to avoid the CPU
182 scribbling over data the GPU is currently using, or the CPU having to
183 wait for the GPU
184
185 Buffer and image updates can be partial, as long as a rendering
186 operation only references the valid (updated) data in the
187 buffer or image.
188
189 --- to append a chunk of data to a buffer resource, call:
190
191 int sg_append_buffer(sg_buffer buf, const void* ptr, int num_bytes)
192
193 The difference to sg_update_buffer() is that sg_append_buffer()
194 can be called multiple times per frame to append new data to the
195 buffer piece by piece, optionally interleaved with draw calls referencing
196 the previously written data.
197
198 sg_append_buffer() returns a byte offset to the start of the
199 written data, this offset can be assigned to
200 sg_bindings.vertex_buffer_offsets[n] or
201 sg_bindings.index_buffer_offset
202
203 Code example:
204
205 for (...) {
206 const void* data = ...;
207 const int num_bytes = ...;
208 int offset = sg_append_buffer(buf, data, num_bytes);
209 bindings.vertex_buffer_offsets[0] = offset;
210 sg_apply_pipeline(pip);
211 sg_apply_bindings(&bindings);
212 sg_apply_uniforms(...);
213 sg_draw(...);
214 }
215
216 A buffer to be used with sg_append_buffer() must have been created
217 with SG_USAGE_DYNAMIC or SG_USAGE_STREAM.
218
219 If the application appends more data to the buffer then fits into
220 the buffer, the buffer will go into the "overflow" state for the
221 rest of the frame.
222
223 Any draw calls attempting to render an overflown buffer will be
224 silently dropped (in debug mode this will also result in a
225 validation error).
226
227 You can also check manually if a buffer is in overflow-state by calling
228
229 bool sg_query_buffer_overflow(sg_buffer buf)
230
231 --- to check for support of optional features:
232
233 bool sg_query_feature(sg_feature feature)
234
235 --- if you need to call into the underlying 3D-API directly, you must call:
236
237 sg_reset_state_cache()
238
239 ...before calling sokol_gfx functions again
240
241 --- you can inspect the original sg_desc structure handed to sg_setup()
242 by calling sg_query_desc(). This will return an sg_desc struct with
243 the default values patched in instead of any zero-initialized values
244
245 --- you can inspect various internal resource attributes via:
246
247 sg_buffer_info sg_query_buffer_info(sg_buffer buf)
248 sg_image_info sg_query_image_info(sg_image img)
249 sg_shader_info sg_query_shader_info(sg_shader shd)
250 sg_pipeline_info sg_query_pipeline_info(sg_pipeline pip)
251 sg_pass_info sg_query_pass_info(sg_pass pass)
252
253 ...please note that the returned info-structs are tied quite closely
254 to sokol_gfx.h internals, and may change more often than other
255 public API functions and structs.
256
257 --- you can ask at runtime what backend sokol_gfx.h has been compiled
258 for, or whether the GLES3 backend had to fall back to GLES2 with:
259
260 sg_backend sg_query_backend(void)
261
262 BACKEND-SPECIFIC TOPICS:
263 ========================
264 --- the GL backends need to know about the internal structure of uniform
265 blocks, and the texture sampler-name and -type:
266
267 typedef struct {
268 float mvp[16]; // model-view-projection matrix
269 float offset0[2]; // some 2D vectors
270 float offset1[2];
271 float offset2[2];
272 } params_t;
273
274 // uniform block structure and texture image definition in sg_shader_desc:
275 sg_shader_desc desc = {
276 // uniform block description (size and internal structure)
277 .vs.uniform_blocks[0] = {
278 .size = sizeof(params_t),
279 .uniforms = {
280 [0] = { .name="mvp", .type=SG_UNIFORMTYPE_MAT4 },
281 [1] = { .name="offset0", .type=SG_UNIFORMTYPE_VEC2 },
282 ...
283 }
284 },
285 // one texture on the fragment-shader-stage, GLES2/WebGL needs name and image type
286 .fs.images[0] = { .name="tex", .type=SG_IMAGETYPE_ARRAY }
287 ...
288 };
289
290 --- the Metal and D3D11 backends only need to know the size of uniform blocks,
291 not their internal member structure, and they only need to know
292 the type of a texture sampler, not its name:
293
294 sg_shader_desc desc = {
295 .vs.uniform_blocks[0].size = sizeof(params_t),
296 .fs.images[0].type = SG_IMAGETYPE_ARRAY,
297 ...
298 };
299
300 --- when creating a shader object, GLES2/WebGL need to know the vertex
301 attribute names as used in the vertex shader:
302
303 sg_shader_desc desc = {
304 .attrs = {
305 [0] = { .name="position" },
306 [1] = { .name="color1" }
307 }
308 };
309
310 The vertex attribute names provided when creating a shader will be
311 used later in sg_create_pipeline() for matching the vertex layout
312 to vertex shader inputs.
313
314 --- on D3D11 you need to provide a semantic name and semantic index in the
315 shader description struct instead (see the D3D11 documentation on
316 D3D11_INPUT_ELEMENT_DESC for details):
317
318 sg_shader_desc desc = {
319 .attrs = {
320 [0] = { .sem_name="POSITION", .sem_index=0 }
321 [1] = { .sem_name="COLOR", .sem_index=1 }
322 }
323 };
324
325 The provided semantic information will be used later in sg_create_pipeline()
326 to match the vertex layout to vertex shader inputs.
327
328 --- on Metal, GL 3.3 or GLES3/WebGL2, you don't need to provide an attribute
329 name or semantic name, since vertex attributes can be bound by their slot index
330 (this is mandatory in Metal, and optional in GL):
331
332 sg_pipeline_desc desc = {
333 .layout = {
334 .attrs = {
335 [0] = { .format=SG_VERTEXFORMAT_FLOAT3 },
336 [1] = { .format=SG_VERTEXFORMAT_FLOAT4 }
337 }
338 }
339 };
340
341 WORKING WITH CONTEXTS
342 =====================
343 sokol-gfx allows to switch between different rendering contexts and
344 associate resource objects with contexts. This is useful to
345 create GL applications that render into multiple windows.
346
347 A rendering context keeps track of all resources created while
348 the context is active. When the context is destroyed, all resources
349 "belonging to the context" are destroyed as well.
350
351 A default context will be created and activated implicitly in
352 sg_setup(), and destroyed in sg_shutdown(). So for a typical application
353 which *doesn't* use multiple contexts, nothing changes, and calling
354 the context functions isn't necessary.
355
356 Three functions have been added to work with contexts:
357
358 --- sg_context sg_setup_context():
359 This must be called once after a GL context has been created and
360 made active.
361
362 --- void sg_activate_context(sg_context ctx)
363 This must be called after making a different GL context active.
364 Apart from 3D-API-specific actions, the call to sg_activate_context()
365 will internally call sg_reset_state_cache().
366
367 --- void sg_discard_context(sg_context ctx)
368 This must be called right before a GL context is destroyed and
369 will destroy all resources associated with the context (that
370 have been created while the context was active) The GL context must be
371 active at the time sg_discard_context(sg_context ctx) is called.
372
373 Also note that resources (buffers, images, shaders and pipelines) must
374 only be used or destroyed while the same GL context is active that
375 was also active while the resource was created (an exception is
376 resource sharing on GL, such resources can be used while
377 another context is active, but must still be destroyed under
378 the same context that was active during creation).
379
380 For more information, check out the multiwindow-glfw sample:
381
382 https://github.com/floooh/sokol-samples/blob/master/glfw/multiwindow-glfw.c
383
384 TRACE HOOKS:
385 ============
386 sokol_gfx.h optionally allows to install "trace hook" callbacks for
387 each public API functions. When a public API function is called, and
388 a trace hook callback has been installed for this function, the
389 callback will be invoked with the parameters and result of the function.
390 This is useful for things like debugging- and profiling-tools, or
391 keeping track of resource creation and destruction.
392
393 To use the trace hook feature:
394
395 --- Define SOKOL_TRACE_HOOKS before including the implementation.
396
397 --- Setup an sg_trace_hooks structure with your callback function
398 pointers (keep all function pointers you're not interested
399 in zero-initialized), optionally set the user_data member
400 in the sg_trace_hooks struct.
401
402 --- Install the trace hooks by calling sg_install_trace_hooks(),
403 the return value of this function is another sg_trace_hooks
404 struct which contains the previously set of trace hooks.
405 You should keep this struct around, and call those previous
406 functions pointers from your own trace callbacks for proper
407 chaining.
408
409 As an example of how trace hooks are used, have a look at the
410 imgui/sokol_gfx_imgui.h header which implements a realtime
411 debugging UI for sokol_gfx.h on top of Dear ImGui.
412
413 A NOTE ON PORTABLE PACKED VERTEX FORMATS:
414 =========================================
415 There are two things to consider when using packed
416 vertex formats like UBYTE4, SHORT2, etc which need to work
417 across all backends:
418
419 - D3D11 can only convert *normalized* vertex formats to
420 floating point during vertex fetch, normalized formats
421 have a trailing 'N', and are "normalized" to a range
422 -1.0..+1.0 (for the signed formats) or 0.0..1.0 (for the
423 unsigned formats):
424
425 - SG_VERTEXFORMAT_BYTE4N
426 - SG_VERTEXFORMAT_UBYTE4N
427 - SG_VERTEXFORMAT_SHORT2N
428 - SG_VERTEXFORMAT_SHORT4N
429
430 D3D11 will not convert *non-normalized* vertex formats
431 to floating point vertex shader inputs, those can
432 only use the ivecn formats when D3D11 is used
433 as backend (GL and should Metal can use both formats)
434
435 - SG_VERTEXFORMAT_BYTE4,
436 - SG_VERTEXFORMAT_UBYTE4
437 - SG_VERTEXFORMAT_SHORT2
438 - SG_VERTEXFORMAT_SHORT4
439
440 - WebGL/GLES2 cannot use integer vertex shader inputs (int or ivecn)
441
442 - SG_VERTEXFORMAT_UINT10_N2 is not supported on WebGL/GLES2
443
444 So for a vertex input layout which works on all platforms, only use the following
445 vertex formats, and if needed "expand" the normalized vertex shader
446 inputs in the vertex shader by multiplying with 127.0, 255.0, 32767.0 or
447 65535.0:
448
449 - SG_VERTEXFORMAT_FLOAT,
450 - SG_VERTEXFORMAT_FLOAT2,
451 - SG_VERTEXFORMAT_FLOAT3,
452 - SG_VERTEXFORMAT_FLOAT4,
453 - SG_VERTEXFORMAT_BYTE4N,
454 - SG_VERTEXFORMAT_UBYTE4N,
455 - SG_VERTEXFORMAT_SHORT2N,
456 - SG_VERTEXFORMAT_SHORT4N,
457
458 TODO:
459 ====
460 - talk about asynchronous resource creation
461
462 zlib/libpng license
463
464 Copyright (c) 2018 Andre Weissflog
465
466 This software is provided 'as-is', without any express or implied warranty.
467 In no event will the authors be held liable for any damages arising from the
468 use of this software.
469
470 Permission is granted to anyone to use this software for any purpose,
471 including commercial applications, and to alter it and redistribute it
472 freely, subject to the following restrictions:
473
474 1. The origin of this software must not be misrepresented; you must not
475 claim that you wrote the original software. If you use this software in a
476 product, an acknowledgment in the product documentation would be
477 appreciated but is not required.
478
479 2. Altered source versions must be plainly marked as such, and must not
480 be misrepresented as being the original software.
481
482 3. This notice may not be removed or altered from any source
483 distribution.
484 */
485 #define SOKOL_GFX_INCLUDEDcxx . . $ `demo/sokol/sokol_gfx.h:485:9`! (1)
486 #include <stdint.h>
487 #include <stdbool.h>
488
489 #ifndef SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`!
490 #if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
491 #define SOKOL_API_DECL __declspec(dllexport)
492 #elif defined(_WIN32) && defined(SOKOL_DLL)
493 #define SOKOL_API_DECL __declspec(dllimport)
494 #else
495 #define SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! extern
496 #endif
497 #endif
498
499 #ifdef __cplusplus
500 extern "C" {
501 #endif
502
503 #ifdef _MSC_VER
504 #pragma warning(push)
505 #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */
506 #endif
507
508 /*
509 Resource id typedefs:
510
511 sg_buffer: vertex- and index-buffers
512 sg_image: textures and render targets
513 sg_shader: vertex- and fragment-shaders, uniform blocks
514 sg_pipeline: associated shader and vertex-layouts, and render states
515 sg_pass: a bundle of render targets and actions on them
516 sg_context: a 'context handle' for switching between 3D-API contexts
517
518 Instead of pointers, resource creation functions return a 32-bit
519 number which uniquely identifies the resource object.
520
521 The 32-bit resource id is split into a 16-bit pool index in the lower bits,
522 and a 16-bit 'unique counter' in the upper bits. The index allows fast
523 pool lookups, and combined with the unique-mask it allows to detect
524 'dangling accesses' (trying to use an object which no longer exists, and
525 its pool slot has been reused for a new object)
526
527 The resource ids are wrapped into a struct so that the compiler
528 can complain when the wrong resource type is used.
529 */
530 typedef struct sg_buffercxx . . $ sg_buffer# { uint32_tcxx . . $ uint32_t# idcxx . . $ sg_buffer#id.; } sg_buffercxx . . $ sg_buffer#;
531 typedef struct sg_imagecxx . . $ sg_image# { uint32_tcxx . . $ uint32_t# idcxx . . $ sg_image#id.; } sg_imagecxx . . $ sg_image#;
532 typedef struct sg_shadercxx . . $ sg_shader# { uint32_tcxx . . $ uint32_t# idcxx . . $ sg_shader#id.; } sg_shadercxx . . $ sg_shader#;
533 typedef struct sg_pipelinecxx . . $ sg_pipeline# { uint32_tcxx . . $ uint32_t# idcxx . . $ sg_pipeline#id.; } sg_pipelinecxx . . $ sg_pipeline#;
534 typedef struct sg_passcxx . . $ sg_pass# { uint32_tcxx . . $ uint32_t# idcxx . . $ sg_pass#id.; } sg_passcxx . . $ sg_pass#;
535 typedef struct sg_contextcxx . . $ sg_context# { uint32_tcxx . . $ uint32_t# idcxx . . $ sg_context#id.; } sg_contextcxx . . $ sg_context#;
536
537 /*
538 various compile-time constants
539
540 FIXME: it may make sense to convert some of those into defines so
541 that the user code can override them.
542 */
543 enumcxx . . $ $anonymous_type_ded6a5455d648ef8_0# {
544 SG_INVALID_IDcxx . . $ SG_INVALID_ID. = 0,
545 SG_NUM_SHADER_STAGEScxx . . $ SG_NUM_SHADER_STAGES. = 2,
546 SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES. = 2,
547 SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS. = 4,
548 SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS. = 4,
549 SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES. = 12,
550 SG_MAX_SHADERSTAGE_UBScxx . . $ SG_MAX_SHADERSTAGE_UBS. = 4,
551 SG_MAX_UB_MEMBERScxx . . $ SG_MAX_UB_MEMBERS. = 16,
552 SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES. = 16,
553 SG_MAX_MIPMAPScxx . . $ SG_MAX_MIPMAPS. = 16,
554 SG_MAX_TEXTUREARRAY_LAYERScxx . . $ SG_MAX_TEXTUREARRAY_LAYERS. = 128
555 };
556
557 /*
558 sg_backend
559
560 The active 3D-API backend, use the function sg_query_backend()
561 to get the currently active backend.
562
563 For returned value corresponds with the compile-time define to select
564 a backend, with the only exception of SOKOL_GLES3: this may
565 return SG_BACKEND_GLES2 if the backend has to fallback to GLES2 mode
566 because GLES3 isn't supported.
567 */
568 typedef enum sg_backendcxx . . $ sg_backend# {
569 SG_BACKEND_GLCORE33cxx . . $ SG_BACKEND_GLCORE33.,
570 SG_BACKEND_GLES2cxx . . $ SG_BACKEND_GLES2.,
571 SG_BACKEND_GLES3cxx . . $ SG_BACKEND_GLES3.,
572 SG_BACKEND_D3D11cxx . . $ SG_BACKEND_D3D11.,
573 SG_BACKEND_METAL_IOScxx . . $ SG_BACKEND_METAL_IOS.,
574 SG_BACKEND_METAL_MACOScxx . . $ SG_BACKEND_METAL_MACOS.,
575 SG_BACKEND_METAL_SIMULATORcxx . . $ SG_BACKEND_METAL_SIMULATOR.,
576 SG_BACKEND_DUMMYcxx . . $ SG_BACKEND_DUMMY.,
577 } sg_backendcxx . . $ sg_backend#;
578
579 /*
580 sg_feature
581
582 These are optional features, use the function
583 sg_query_feature() to check whether the feature is supported.
584 */
585 typedef enum sg_featurecxx . . $ sg_feature# {
586 SG_FEATURE_INSTANCINGcxx . . $ SG_FEATURE_INSTANCING.,
587 SG_FEATURE_TEXTURE_COMPRESSION_DXTcxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_DXT.,
588 SG_FEATURE_TEXTURE_COMPRESSION_PVRTCcxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_PVRTC.,
589 SG_FEATURE_TEXTURE_COMPRESSION_ATCcxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_ATC.,
590 SG_FEATURE_TEXTURE_COMPRESSION_ETC2cxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_ETC2.,
591 SG_FEATURE_TEXTURE_FLOATcxx . . $ SG_FEATURE_TEXTURE_FLOAT.,
592 SG_FEATURE_TEXTURE_HALF_FLOATcxx . . $ SG_FEATURE_TEXTURE_HALF_FLOAT.,
593 SG_FEATURE_ORIGIN_BOTTOM_LEFTcxx . . $ SG_FEATURE_ORIGIN_BOTTOM_LEFT.,
594 SG_FEATURE_ORIGIN_TOP_LEFTcxx . . $ SG_FEATURE_ORIGIN_TOP_LEFT.,
595 SG_FEATURE_MSAA_RENDER_TARGETScxx . . $ SG_FEATURE_MSAA_RENDER_TARGETS.,
596 SG_FEATURE_PACKED_VERTEX_FORMAT_10_2cxx . . $ SG_FEATURE_PACKED_VERTEX_FORMAT_10_2.,
597 SG_FEATURE_MULTIPLE_RENDER_TARGETcxx . . $ SG_FEATURE_MULTIPLE_RENDER_TARGET.,
598 SG_FEATURE_IMAGETYPE_3Dcxx . . $ SG_FEATURE_IMAGETYPE_3D.,
599 SG_FEATURE_IMAGETYPE_ARRAYcxx . . $ SG_FEATURE_IMAGETYPE_ARRAY.,
600
601 SG_NUM_FEATUREScxx . . $ SG_NUM_FEATURES.
602 } sg_featurecxx . . $ sg_feature#;
603
604 /*
605 sg_resource_state
606
607 The current state of a resource in its resource pool.
608 Resources start in the INITIAL state, which means the
609 pool slot is unoccupied and can be allocated. When a resource is
610 created, first an id is allocated, and the resource pool slot
611 is set to state ALLOC. After allocation, the resource is
612 initialized, which may result in the VALID or FAILED state. The
613 reason why allocation and initialization are separate is because
614 some resource types (e.g. buffers and images) might be asynchronously
615 initialized by the user application. If a resource which is not
616 in the VALID state is attempted to be used for rendering, rendering
617 operations will silently be dropped.
618
619 The special INVALID state is returned in sg_query_xxx_state() if no
620 resource object exists for the provided resource id.
621 */
622 typedef enum sg_resource_statecxx . . $ sg_resource_state# {
623 SG_RESOURCESTATE_INITIALcxx . . $ SG_RESOURCESTATE_INITIAL.,
624 SG_RESOURCESTATE_ALLOCcxx . . $ SG_RESOURCESTATE_ALLOC.,
625 SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.,
626 SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.,
627 SG_RESOURCESTATE_INVALIDcxx . . $ SG_RESOURCESTATE_INVALID.,
628 _SG_RESOURCESTATE_FORCE_U32cxx . . $ _SG_RESOURCESTATE_FORCE_U32. = 0x7FFFFFFF
629 } sg_resource_statecxx . . $ sg_resource_state#;
630
631 /*
632 sg_usage
633
634 A resource usage hint describing the update strategy of
635 buffers and images. This is used in the sg_buffer_desc.usage
636 and sg_image_desc.usage members when creating buffers
637 and images:
638
639 SG_USAGE_IMMUTABLE: the resource will never be updated with
640 new data, instead the data content of the
641 resource must be provided on creation
642 SG_USAGE_DYNAMIC: the resource will be updated infrequently
643 with new data (this could range from "once
644 after creation", to "quite often but not
645 every frame")
646 SG_USAGE_STREAM: the resource will be updated each frame
647 with new content
648
649 The rendering backends use this hint to prevent that the
650 CPU needs to wait for the GPU when attempting to update
651 a resource that might be currently accessed by the GPU.
652
653 Resource content is updated with the function sg_update_buffer() for
654 buffer objects, and sg_update_image() for image objects. Only
655 one update is allowed per frame and resource object. The
656 application must update all data required for rendering (this
657 means that the update data can be smaller than the resource size,
658 if only a part of the overall resource size is used for rendering,
659 you only need to make sure that the data that *is* used is valid.
660
661 The default usage is SG_USAGE_IMMUTABLE.
662 */
663 typedef enum sg_usagecxx . . $ sg_usage# {
664 _SG_USAGE_DEFAULTcxx . . $ _SG_USAGE_DEFAULT., /* value 0 reserved for default-init */
665 SG_USAGE_IMMUTABLEcxx . . $ SG_USAGE_IMMUTABLE.,
666 SG_USAGE_DYNAMICcxx . . $ SG_USAGE_DYNAMIC.,
667 SG_USAGE_STREAMcxx . . $ SG_USAGE_STREAM.,
668 _SG_USAGE_NUMcxx . . $ _SG_USAGE_NUM.,
669 _SG_USAGE_FORCE_U32cxx . . $ _SG_USAGE_FORCE_U32. = 0x7FFFFFFF
670 } sg_usagecxx . . $ sg_usage#;
671
672 /*
673 sg_buffer_type
674
675 This indicates whether a buffer contains vertex- or index-data,
676 used in the sg_buffer_desc.type member when creating a buffer.
677
678 The default value is SG_BUFFERTYPE_VERTEXBUFFER.
679 */
680 typedef enum sg_buffer_typecxx . . $ sg_buffer_type# {
681 _SG_BUFFERTYPE_DEFAULTcxx . . $ _SG_BUFFERTYPE_DEFAULT., /* value 0 reserved for default-init */
682 SG_BUFFERTYPE_VERTEXBUFFERcxx . . $ SG_BUFFERTYPE_VERTEXBUFFER.,
683 SG_BUFFERTYPE_INDEXBUFFERcxx . . $ SG_BUFFERTYPE_INDEXBUFFER.,
684 _SG_BUFFERTYPE_NUMcxx . . $ _SG_BUFFERTYPE_NUM.,
685 _SG_BUFFERTYPE_FORCE_U32cxx . . $ _SG_BUFFERTYPE_FORCE_U32. = 0x7FFFFFFF
686 } sg_buffer_typecxx . . $ sg_buffer_type#;
687
688 /*
689 sg_index_type
690
691 Indicates whether indexed rendering (fetching vertex-indices from an
692 index buffer) is used, and if yes, the index data type (16- or 32-bits).
693 This is used in the sg_pipeline_desc.index_type member when creating a
694 pipeline object.
695
696 The default index type is SG_INDEXTYPE_NONE.
697 */
698 typedef enum sg_index_typecxx . . $ sg_index_type# {
699 _SG_INDEXTYPE_DEFAULTcxx . . $ _SG_INDEXTYPE_DEFAULT., /* value 0 reserved for default-init */
700 SG_INDEXTYPE_NONEcxx . . $ SG_INDEXTYPE_NONE.,
701 SG_INDEXTYPE_UINT16cxx . . $ SG_INDEXTYPE_UINT16.,
702 SG_INDEXTYPE_UINT32cxx . . $ SG_INDEXTYPE_UINT32.,
703 _SG_INDEXTYPE_NUMcxx . . $ _SG_INDEXTYPE_NUM.,
704 _SG_INDEXTYPE_FORCE_U32cxx . . $ _SG_INDEXTYPE_FORCE_U32. = 0x7FFFFFFF
705 } sg_index_typecxx . . $ sg_index_type#;
706
707 /*
708 sg_image_type
709
710 Indicates the basic image type (2D-texture, cubemap, 3D-texture
711 or 2D-array-texture). 3D- and array-textures are not supported
712 on the GLES2/WebGL backend. The image type is used in the
713 sg_image_desc.type member when creating an image.
714
715 The default image type when creating an image is SG_IMAGETYPE_2D.
716 */
717 typedef enum sg_image_typecxx . . $ sg_image_type# {
718 _SG_IMAGETYPE_DEFAULTcxx . . $ _SG_IMAGETYPE_DEFAULT., /* value 0 reserved for default-init */
719 SG_IMAGETYPE_2Dcxx . . $ SG_IMAGETYPE_2D.,
720 SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE.,
721 SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D.,
722 SG_IMAGETYPE_ARRAYcxx . . $ SG_IMAGETYPE_ARRAY.,
723 _SG_IMAGETYPE_NUMcxx . . $ _SG_IMAGETYPE_NUM.,
724 _SG_IMAGETYPE_FORCE_U32cxx . . $ _SG_IMAGETYPE_FORCE_U32. = 0x7FFFFFFF
725 } sg_image_typecxx . . $ sg_image_type#;
726
727 /*
728 sg_cube_face
729
730 The cubemap faces. Use these as indices in the sg_image_desc.content
731 array.
732 */
733 typedef enum sg_cube_facecxx . . $ sg_cube_face# {
734 SG_CUBEFACE_POS_Xcxx . . $ SG_CUBEFACE_POS_X.,
735 SG_CUBEFACE_NEG_Xcxx . . $ SG_CUBEFACE_NEG_X.,
736 SG_CUBEFACE_POS_Ycxx . . $ SG_CUBEFACE_POS_Y.,
737 SG_CUBEFACE_NEG_Ycxx . . $ SG_CUBEFACE_NEG_Y.,
738 SG_CUBEFACE_POS_Zcxx . . $ SG_CUBEFACE_POS_Z.,
739 SG_CUBEFACE_NEG_Zcxx . . $ SG_CUBEFACE_NEG_Z.,
740 SG_CUBEFACE_NUMcxx . . $ SG_CUBEFACE_NUM.,
741 _SG_CUBEFACE_FORCE_U32cxx . . $ _SG_CUBEFACE_FORCE_U32. = 0x7FFFFFFF
742 } sg_cube_facecxx . . $ sg_cube_face#;
743
744 /*
745 sg_shader_stage
746
747 There are 2 shader stages: vertex- and fragment-shader-stage.
748 Each shader stage consists of:
749
750 - one slot for a shader function (provided as source- or byte-code)
751 - SG_MAX_SHADERSTAGE_UBS slots for uniform blocks
752 - SG_MAX_SHADERSTAGE_IMAGES slots for images used as textures by
753 the shader function
754 */
755 typedef enum sg_shader_stagecxx . . $ sg_shader_stage# {
756 SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS.,
757 SG_SHADERSTAGE_FScxx . . $ SG_SHADERSTAGE_FS.,
758 _SG_SHADERSTAGE_FORCE_U32cxx . . $ _SG_SHADERSTAGE_FORCE_U32. = 0x7FFFFFFF
759 } sg_shader_stagecxx . . $ sg_shader_stage#;
760
761 /*
762 sg_pixel_format
763
764 This is a common subset of useful and widely supported pixel formats. The
765 pixel format enum is mainly used when creating an image object in the
766 sg_image_desc.pixel_format member.
767
768 The default pixel format when creating an image is SG_PIXELFORMAT_RGBA8.
769 */
770 typedef enum sg_pixel_formatcxx . . $ sg_pixel_format# {
771 _SG_PIXELFORMAT_DEFAULTcxx . . $ _SG_PIXELFORMAT_DEFAULT., /* value 0 reserved for default-init */
772 SG_PIXELFORMAT_NONEcxx . . $ SG_PIXELFORMAT_NONE.,
773 SG_PIXELFORMAT_RGBA8cxx . . $ SG_PIXELFORMAT_RGBA8.,
774 SG_PIXELFORMAT_RGB8cxx . . $ SG_PIXELFORMAT_RGB8.,
775 SG_PIXELFORMAT_RGBA4cxx . . $ SG_PIXELFORMAT_RGBA4.,
776 SG_PIXELFORMAT_R5G6B5cxx . . $ SG_PIXELFORMAT_R5G6B5.,
777 SG_PIXELFORMAT_R5G5B5A1cxx . . $ SG_PIXELFORMAT_R5G5B5A1.,
778 SG_PIXELFORMAT_R10G10B10A2cxx . . $ SG_PIXELFORMAT_R10G10B10A2.,
779 SG_PIXELFORMAT_RGBA32Fcxx . . $ SG_PIXELFORMAT_RGBA32F.,
780 SG_PIXELFORMAT_RGBA16Fcxx . . $ SG_PIXELFORMAT_RGBA16F.,
781 SG_PIXELFORMAT_R32Fcxx . . $ SG_PIXELFORMAT_R32F.,
782 SG_PIXELFORMAT_R16Fcxx . . $ SG_PIXELFORMAT_R16F.,
783 SG_PIXELFORMAT_L8cxx . . $ SG_PIXELFORMAT_L8.,
784 SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.,
785 SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.,
786 SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.,
787 SG_PIXELFORMAT_DEPTHcxx . . $ SG_PIXELFORMAT_DEPTH.,
788 SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.,
789 SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.,
790 SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.,
791 SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.,
792 SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.,
793 SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.,
794 SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.,
795 _SG_PIXELFORMAT_NUMcxx . . $ _SG_PIXELFORMAT_NUM.,
796 _SG_PIXELFORMAT_FORCE_U32cxx . . $ _SG_PIXELFORMAT_FORCE_U32. = 0x7FFFFFFF
797 } sg_pixel_formatcxx . . $ sg_pixel_format#;
798
799 /*
800 sg_primitive_type
801
802 This is the common subset of 3D primitive types supported across all 3D
803 APIs. This is used in the sg_pipeline_desc.primitive_type member when
804 creating a pipeline object.
805
806 The default primitive type is SG_PRIMITIVETYPE_TRIANGLES.
807 */
808 typedef enum sg_primitive_typecxx . . $ sg_primitive_type# {
809 _SG_PRIMITIVETYPE_DEFAULTcxx . . $ _SG_PRIMITIVETYPE_DEFAULT., /* value 0 reserved for default-init */
810 SG_PRIMITIVETYPE_POINTScxx . . $ SG_PRIMITIVETYPE_POINTS.,
811 SG_PRIMITIVETYPE_LINEScxx . . $ SG_PRIMITIVETYPE_LINES.,
812 SG_PRIMITIVETYPE_LINE_STRIPcxx . . $ SG_PRIMITIVETYPE_LINE_STRIP.,
813 SG_PRIMITIVETYPE_TRIANGLEScxx . . $ SG_PRIMITIVETYPE_TRIANGLES.,
814 SG_PRIMITIVETYPE_TRIANGLE_STRIPcxx . . $ SG_PRIMITIVETYPE_TRIANGLE_STRIP.,
815 _SG_PRIMITIVETYPE_NUMcxx . . $ _SG_PRIMITIVETYPE_NUM.,
816 _SG_PRIMITIVETYPE_FORCE_U32cxx . . $ _SG_PRIMITIVETYPE_FORCE_U32. = 0x7FFFFFFF
817 } sg_primitive_typecxx . . $ sg_primitive_type#;
818
819 /*
820 sg_filter
821
822 The filtering mode when sampling a texture image. This is
823 used in the sg_image_desc.min_filter and sg_image_desc.mag_filter
824 members when creating an image object.
825
826 The default filter mode is SG_FILTER_NEAREST.
827 */
828 typedef enum sg_filtercxx . . $ sg_filter# {
829 _SG_FILTER_DEFAULTcxx . . $ _SG_FILTER_DEFAULT., /* value 0 reserved for default-init */
830 SG_FILTER_NEARESTcxx . . $ SG_FILTER_NEAREST.,
831 SG_FILTER_LINEARcxx . . $ SG_FILTER_LINEAR.,
832 SG_FILTER_NEAREST_MIPMAP_NEARESTcxx . . $ SG_FILTER_NEAREST_MIPMAP_NEAREST.,
833 SG_FILTER_NEAREST_MIPMAP_LINEARcxx . . $ SG_FILTER_NEAREST_MIPMAP_LINEAR.,
834 SG_FILTER_LINEAR_MIPMAP_NEARESTcxx . . $ SG_FILTER_LINEAR_MIPMAP_NEAREST.,
835 SG_FILTER_LINEAR_MIPMAP_LINEARcxx . . $ SG_FILTER_LINEAR_MIPMAP_LINEAR.,
836 _SG_FILTER_NUMcxx . . $ _SG_FILTER_NUM.,
837 _SG_FILTER_FORCE_U32cxx . . $ _SG_FILTER_FORCE_U32. = 0x7FFFFFFF
838 } sg_filtercxx . . $ sg_filter#;
839
840 /*
841 sg_wrap
842
843 The texture coordinates wrapping mode when sampling a texture
844 image. This is used in the sg_image_desc.wrap_u, .wrap_v
845 and .wrap_w members when creating an image.
846
847 The default wrap mode is SG_WRAP_REPEAT.
848 */
849 typedef enum sg_wrapcxx . . $ sg_wrap# {
850 _SG_WRAP_DEFAULTcxx . . $ _SG_WRAP_DEFAULT., /* value 0 reserved for default-init */
851 SG_WRAP_REPEATcxx . . $ SG_WRAP_REPEAT.,
852 SG_WRAP_CLAMP_TO_EDGEcxx . . $ SG_WRAP_CLAMP_TO_EDGE.,
853 SG_WRAP_MIRRORED_REPEATcxx . . $ SG_WRAP_MIRRORED_REPEAT.,
854 _SG_WRAP_NUMcxx . . $ _SG_WRAP_NUM.,
855 _SG_WRAP_FORCE_U32cxx . . $ _SG_WRAP_FORCE_U32. = 0x7FFFFFFF
856 } sg_wrapcxx . . $ sg_wrap#;
857
858 /*
859 sg_vertex_format
860
861 The data type of a vertex component. This is used to describe
862 the layout of vertex data when creating a pipeline object.
863 */
864 typedef enum sg_vertex_formatcxx . . $ sg_vertex_format# {
865 SG_VERTEXFORMAT_INVALIDcxx . . $ SG_VERTEXFORMAT_INVALID.,
866 SG_VERTEXFORMAT_FLOATcxx . . $ SG_VERTEXFORMAT_FLOAT.,
867 SG_VERTEXFORMAT_FLOAT2cxx . . $ SG_VERTEXFORMAT_FLOAT2.,
868 SG_VERTEXFORMAT_FLOAT3cxx . . $ SG_VERTEXFORMAT_FLOAT3.,
869 SG_VERTEXFORMAT_FLOAT4cxx . . $ SG_VERTEXFORMAT_FLOAT4.,
870 SG_VERTEXFORMAT_BYTE4cxx . . $ SG_VERTEXFORMAT_BYTE4.,
871 SG_VERTEXFORMAT_BYTE4Ncxx . . $ SG_VERTEXFORMAT_BYTE4N.,
872 SG_VERTEXFORMAT_UBYTE4cxx . . $ SG_VERTEXFORMAT_UBYTE4.,
873 SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.,
874 SG_VERTEXFORMAT_SHORT2cxx . . $ SG_VERTEXFORMAT_SHORT2.,
875 SG_VERTEXFORMAT_SHORT2Ncxx . . $ SG_VERTEXFORMAT_SHORT2N.,
876 SG_VERTEXFORMAT_SHORT4cxx . . $ SG_VERTEXFORMAT_SHORT4.,
877 SG_VERTEXFORMAT_SHORT4Ncxx . . $ SG_VERTEXFORMAT_SHORT4N.,
878 SG_VERTEXFORMAT_UINT10_N2cxx . . $ SG_VERTEXFORMAT_UINT10_N2.,
879 _SG_VERTEXFORMAT_NUMcxx . . $ _SG_VERTEXFORMAT_NUM.,
880 _SG_VERTEXFORMAT_FORCE_U32cxx . . $ _SG_VERTEXFORMAT_FORCE_U32. = 0x7FFFFFFF
881 } sg_vertex_formatcxx . . $ sg_vertex_format#;
882
883 /*
884 sg_vertex_step
885
886 Defines whether the input pointer of a vertex input stream is advanced
887 'per vertex' or 'per instance'. The default step-func is
888 SG_VERTEXSTEP_PER_VERTEX. SG_VERTEXSTEP_PER_INSTANCE is used with
889 instanced-rendering.
890
891 The vertex-step is part of the vertex-layout definition
892 when creating pipeline objects.
893 */
894 typedef enum sg_vertex_stepcxx . . $ sg_vertex_step# {
895 _SG_VERTEXSTEP_DEFAULTcxx . . $ _SG_VERTEXSTEP_DEFAULT., /* value 0 reserved for default-init */
896 SG_VERTEXSTEP_PER_VERTEXcxx . . $ SG_VERTEXSTEP_PER_VERTEX.,
897 SG_VERTEXSTEP_PER_INSTANCEcxx . . $ SG_VERTEXSTEP_PER_INSTANCE.,
898 _SG_VERTEXSTEP_NUMcxx . . $ _SG_VERTEXSTEP_NUM.,
899 _SG_VERTEXSTEP_FORCE_U32cxx . . $ _SG_VERTEXSTEP_FORCE_U32. = 0x7FFFFFFF
900 } sg_vertex_stepcxx . . $ sg_vertex_step#;
901
902 /*
903 sg_uniform_type
904
905 The data type of a uniform block member. This is used to
906 describe the internal layout of uniform blocks when creating
907 a shader object.
908 */
909 typedef enum sg_uniform_typecxx . . $ sg_uniform_type# {
910 SG_UNIFORMTYPE_INVALIDcxx . . $ SG_UNIFORMTYPE_INVALID.,
911 SG_UNIFORMTYPE_FLOATcxx . . $ SG_UNIFORMTYPE_FLOAT.,
912 SG_UNIFORMTYPE_FLOAT2cxx . . $ SG_UNIFORMTYPE_FLOAT2.,
913 SG_UNIFORMTYPE_FLOAT3cxx . . $ SG_UNIFORMTYPE_FLOAT3.,
914 SG_UNIFORMTYPE_FLOAT4cxx . . $ SG_UNIFORMTYPE_FLOAT4.,
915 SG_UNIFORMTYPE_MAT4cxx . . $ SG_UNIFORMTYPE_MAT4.,
916 _SG_UNIFORMTYPE_NUMcxx . . $ _SG_UNIFORMTYPE_NUM.,
917 _SG_UNIFORMTYPE_FORCE_U32cxx . . $ _SG_UNIFORMTYPE_FORCE_U32. = 0x7FFFFFFF
918 } sg_uniform_typecxx . . $ sg_uniform_type#;
919
920 /*
921 sg_cull_mode
922
923 The face-culling mode, this is used in the
924 sg_pipeline_desc.rasterizer.cull_mode member when creating a
925 pipeline object.
926
927 The default cull mode is SG_CULLMODE_NONE
928 */
929 typedef enum sg_cull_modecxx . . $ sg_cull_mode# {
930 _SG_CULLMODE_DEFAULTcxx . . $ _SG_CULLMODE_DEFAULT., /* value 0 reserved for default-init */
931 SG_CULLMODE_NONEcxx . . $ SG_CULLMODE_NONE.,
932 SG_CULLMODE_FRONTcxx . . $ SG_CULLMODE_FRONT.,
933 SG_CULLMODE_BACKcxx . . $ SG_CULLMODE_BACK.,
934 _SG_CULLMODE_NUMcxx . . $ _SG_CULLMODE_NUM.,
935 _SG_CULLMODE_FORCE_U32cxx . . $ _SG_CULLMODE_FORCE_U32. = 0x7FFFFFFF
936 } sg_cull_modecxx . . $ sg_cull_mode#;
937
938 /*
939 sg_face_winding
940
941 The vertex-winding rule that determines a front-facing primitive. This
942 is used in the member sg_pipeline_desc.rasterizer.face_winding
943 when creating a pipeline object.
944
945 The default winding is SG_FACEWINDING_CW (clockwise)
946 */
947 typedef enum sg_face_windingcxx . . $ sg_face_winding# {
948 _SG_FACEWINDING_DEFAULTcxx . . $ _SG_FACEWINDING_DEFAULT., /* value 0 reserved for default-init */
949 SG_FACEWINDING_CCWcxx . . $ SG_FACEWINDING_CCW.,
950 SG_FACEWINDING_CWcxx . . $ SG_FACEWINDING_CW.,
951 _SG_FACEWINDING_NUMcxx . . $ _SG_FACEWINDING_NUM.,
952 _SG_FACEWINDING_FORCE_U32cxx . . $ _SG_FACEWINDING_FORCE_U32. = 0x7FFFFFFF
953 } sg_face_windingcxx . . $ sg_face_winding#;
954
955 /*
956 sg_compare_func
957
958 The compare-function for depth- and stencil-ref tests.
959 This is used when creating pipeline objects in the members:
960
961 sg_pipeline_desc
962 .depth_stencil
963 .depth_compare_func
964 .stencil_front.compare_func
965 .stencil_back.compare_func
966
967 The default compare func for depth- and stencil-tests is
968 SG_COMPAREFUNC_ALWAYS.
969 */
970 typedef enum sg_compare_funccxx . . $ sg_compare_func# {
971 _SG_COMPAREFUNC_DEFAULTcxx . . $ _SG_COMPAREFUNC_DEFAULT., /* value 0 reserved for default-init */
972 SG_COMPAREFUNC_NEVERcxx . . $ SG_COMPAREFUNC_NEVER.,
973 SG_COMPAREFUNC_LESScxx . . $ SG_COMPAREFUNC_LESS.,
974 SG_COMPAREFUNC_EQUALcxx . . $ SG_COMPAREFUNC_EQUAL.,
975 SG_COMPAREFUNC_LESS_EQUALcxx . . $ SG_COMPAREFUNC_LESS_EQUAL.,
976 SG_COMPAREFUNC_GREATERcxx . . $ SG_COMPAREFUNC_GREATER.,
977 SG_COMPAREFUNC_NOT_EQUALcxx . . $ SG_COMPAREFUNC_NOT_EQUAL.,
978 SG_COMPAREFUNC_GREATER_EQUALcxx . . $ SG_COMPAREFUNC_GREATER_EQUAL.,
979 SG_COMPAREFUNC_ALWAYScxx . . $ SG_COMPAREFUNC_ALWAYS.,
980 _SG_COMPAREFUNC_NUMcxx . . $ _SG_COMPAREFUNC_NUM.,
981 _SG_COMPAREFUNC_FORCE_U32cxx . . $ _SG_COMPAREFUNC_FORCE_U32. = 0x7FFFFFFF
982 } sg_compare_funccxx . . $ sg_compare_func#;
983
984 /*
985 sg_stencil_op
986
987 The operation performed on a currently stored stencil-value when a
988 comparison test passes or fails. This is used when creating a pipeline
989 object in the members:
990
991 sg_pipeline_desc
992 .depth_stencil
993 .stencil_front
994 .fail_op
995 .depth_fail_op
996 .pass_op
997 .stencil_back
998 .fail_op
999 .depth_fail_op
1000 .pass_op
1001
1002 The default value is SG_STENCILOP_KEEP.
1003 */
1004 typedef enum sg_stencil_opcxx . . $ sg_stencil_op# {
1005 _SG_STENCILOP_DEFAULTcxx . . $ _SG_STENCILOP_DEFAULT., /* value 0 reserved for default-init */
1006 SG_STENCILOP_KEEPcxx . . $ SG_STENCILOP_KEEP.,
1007 SG_STENCILOP_ZEROcxx . . $ SG_STENCILOP_ZERO.,
1008 SG_STENCILOP_REPLACEcxx . . $ SG_STENCILOP_REPLACE.,
1009 SG_STENCILOP_INCR_CLAMPcxx . . $ SG_STENCILOP_INCR_CLAMP.,
1010 SG_STENCILOP_DECR_CLAMPcxx . . $ SG_STENCILOP_DECR_CLAMP.,
1011 SG_STENCILOP_INVERTcxx . . $ SG_STENCILOP_INVERT.,
1012 SG_STENCILOP_INCR_WRAPcxx . . $ SG_STENCILOP_INCR_WRAP.,
1013 SG_STENCILOP_DECR_WRAPcxx . . $ SG_STENCILOP_DECR_WRAP.,
1014 _SG_STENCILOP_NUMcxx . . $ _SG_STENCILOP_NUM.,
1015 _SG_STENCILOP_FORCE_U32cxx . . $ _SG_STENCILOP_FORCE_U32. = 0x7FFFFFFF
1016 } sg_stencil_opcxx . . $ sg_stencil_op#;
1017
1018 /*
1019 sg_blend_factor
1020
1021 The source and destination factors in blending operations.
1022 This is used in the following members when creating a pipeline object:
1023
1024 sg_pipeline_desc
1025 .blend
1026 .src_factor_rgb
1027 .dst_factor_rgb
1028 .src_factor_alpha
1029 .dst_factor_alpha
1030
1031 The default value is SG_BLENDFACTOR_ONE for source
1032 factors, and SG_BLENDFACTOR_ZERO for destination factors.
1033 */
1034 typedef enum sg_blend_factorcxx . . $ sg_blend_factor# {
1035 _SG_BLENDFACTOR_DEFAULTcxx . . $ _SG_BLENDFACTOR_DEFAULT., /* value 0 reserved for default-init */
1036 SG_BLENDFACTOR_ZEROcxx . . $ SG_BLENDFACTOR_ZERO.,
1037 SG_BLENDFACTOR_ONEcxx . . $ SG_BLENDFACTOR_ONE.,
1038 SG_BLENDFACTOR_SRC_COLORcxx . . $ SG_BLENDFACTOR_SRC_COLOR.,
1039 SG_BLENDFACTOR_ONE_MINUS_SRC_COLORcxx . . $ SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR.,
1040 SG_BLENDFACTOR_SRC_ALPHAcxx . . $ SG_BLENDFACTOR_SRC_ALPHA.,
1041 SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA.,
1042 SG_BLENDFACTOR_DST_COLORcxx . . $ SG_BLENDFACTOR_DST_COLOR.,
1043 SG_BLENDFACTOR_ONE_MINUS_DST_COLORcxx . . $ SG_BLENDFACTOR_ONE_MINUS_DST_COLOR.,
1044 SG_BLENDFACTOR_DST_ALPHAcxx . . $ SG_BLENDFACTOR_DST_ALPHA.,
1045 SG_BLENDFACTOR_ONE_MINUS_DST_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA.,
1046 SG_BLENDFACTOR_SRC_ALPHA_SATURATEDcxx . . $ SG_BLENDFACTOR_SRC_ALPHA_SATURATED.,
1047 SG_BLENDFACTOR_BLEND_COLORcxx . . $ SG_BLENDFACTOR_BLEND_COLOR.,
1048 SG_BLENDFACTOR_ONE_MINUS_BLEND_COLORcxx . . $ SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR.,
1049 SG_BLENDFACTOR_BLEND_ALPHAcxx . . $ SG_BLENDFACTOR_BLEND_ALPHA.,
1050 SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA.,
1051 _SG_BLENDFACTOR_NUMcxx . . $ _SG_BLENDFACTOR_NUM.,
1052 _SG_BLENDFACTOR_FORCE_U32cxx . . $ _SG_BLENDFACTOR_FORCE_U32. = 0x7FFFFFFF
1053 } sg_blend_factorcxx . . $ sg_blend_factor#;
1054
1055 /*
1056 sg_blend_op
1057
1058 Describes how the source and destination values are combined in the
1059 fragment blending operation. It is used in the following members when
1060 creating a pipeline object:
1061
1062 sg_pipeline_desc
1063 .blend
1064 .op_rgb
1065 .op_alpha
1066
1067 The default value is SG_BLENDOP_ADD.
1068 */
1069 typedef enum sg_blend_opcxx . . $ sg_blend_op# {
1070 _SG_BLENDOP_DEFAULTcxx . . $ _SG_BLENDOP_DEFAULT., /* value 0 reserved for default-init */
1071 SG_BLENDOP_ADDcxx . . $ SG_BLENDOP_ADD.,
1072 SG_BLENDOP_SUBTRACTcxx . . $ SG_BLENDOP_SUBTRACT.,
1073 SG_BLENDOP_REVERSE_SUBTRACTcxx . . $ SG_BLENDOP_REVERSE_SUBTRACT.,
1074 _SG_BLENDOP_NUMcxx . . $ _SG_BLENDOP_NUM.,
1075 _SG_BLENDOP_FORCE_U32cxx . . $ _SG_BLENDOP_FORCE_U32. = 0x7FFFFFFF
1076 } sg_blend_opcxx . . $ sg_blend_op#;
1077
1078 /*
1079 sg_color_mask
1080
1081 Selects the color channels when writing a fragment color to the
1082 framebuffer. This is used in the members
1083 sg_pipeline_desc.blend.color_write_mask when creating a pipeline object.
1084
1085 The default colormask is SG_COLORMASK_RGBA (write all colors channels)
1086 */
1087 typedef enum sg_color_maskcxx . . $ sg_color_mask# {
1088 _SG_COLORMASK_DEFAULTcxx . . $ _SG_COLORMASK_DEFAULT. = 0, /* value 0 reserved for default-init */
1089 SG_COLORMASK_NONEcxx . . $ SG_COLORMASK_NONE. = (0x10), /* special value for 'all channels disabled */
1090 SG_COLORMASK_Rcxx . . $ SG_COLORMASK_R. = (1<<0),
1091 SG_COLORMASK_Gcxx . . $ SG_COLORMASK_G. = (1<<1),
1092 SG_COLORMASK_Bcxx . . $ SG_COLORMASK_B. = (1<<2),
1093 SG_COLORMASK_Acxx . . $ SG_COLORMASK_A. = (1<<3),
1094 SG_COLORMASK_RGBcxx . . $ SG_COLORMASK_RGB. = 0x7,
1095 SG_COLORMASK_RGBAcxx . . $ SG_COLORMASK_RGBA. = 0xF,
1096 _SG_COLORMASK_FORCE_U32cxx . . $ _SG_COLORMASK_FORCE_U32. = 0x7FFFFFFF
1097 } sg_color_maskcxx . . $ sg_color_mask#;
1098
1099 /*
1100 sg_action
1101
1102 Defines what action should be performed at the start of a render pass:
1103
1104 SG_ACTION_CLEAR: clear the render target image
1105 SG_ACTION_LOAD: load the previous content of the render target image
1106 SG_ACTION_DONTCARE: leave the render target image content undefined
1107
1108 This is used in the sg_pass_action structure.
1109
1110 The default action for all pass attachments is SG_ACTION_CLEAR, with the
1111 clear color rgba = {0.5f, 0.5f, 0.5f, 1.0f], depth=1.0 and stencil=0.
1112
1113 If you want to override the default behaviour, it is important to not
1114 only set the clear color, but the 'action' field as well (as long as this
1115 is in its _SG_ACTION_DEFAULT, the value fields will be ignored).
1116 */
1117 typedef enum sg_actioncxx . . $ sg_action# {
1118 _SG_ACTION_DEFAULTcxx . . $ _SG_ACTION_DEFAULT.,
1119 SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.,
1120 SG_ACTION_LOADcxx . . $ SG_ACTION_LOAD.,
1121 SG_ACTION_DONTCAREcxx . . $ SG_ACTION_DONTCARE.,
1122 _SG_ACTION_NUMcxx . . $ _SG_ACTION_NUM.,
1123 _SG_ACTION_FORCE_U32cxx . . $ _SG_ACTION_FORCE_U32. = 0x7FFFFFFF
1124 } sg_actioncxx . . $ sg_action#;
1125
1126 /*
1127 sg_pass_action
1128
1129 The sg_pass_action struct defines the actions to be performed
1130 at the start of a rendering pass in the functions sg_begin_pass()
1131 and sg_begin_default_pass().
1132
1133 A separate action and clear values can be defined for each
1134 color attachment, and for the depth-stencil attachment.
1135
1136 The default clear values are defined by the macros:
1137
1138 - SG_DEFAULT_CLEAR_RED: 0.5f
1139 - SG_DEFAULT_CLEAR_GREEN: 0.5f
1140 - SG_DEFAULT_CLEAR_BLUE: 0.5f
1141 - SG_DEFAULT_CLEAR_ALPHA: 1.0f
1142 - SG_DEFAULT_CLEAR_DEPTH: 1.0f
1143 - SG_DEFAULT_CLEAR_STENCIL: 0
1144 */
1145 typedef struct sg_color_attachment_actioncxx . . $ sg_color_attachment_action# {
1146 sg_actioncxx . . $ sg_action# actioncxx . . $ sg_color_attachment_action#action.;
1147 float valcxx . . $ sg_color_attachment_action#val.[4];
1148 } sg_color_attachment_actioncxx . . $ sg_color_attachment_action#;
1149
1150 typedef struct sg_depth_attachment_actioncxx . . $ sg_depth_attachment_action# {
1151 sg_actioncxx . . $ sg_action# actioncxx . . $ sg_depth_attachment_action#action.;
1152 float valcxx . . $ sg_depth_attachment_action#val.;
1153 } sg_depth_attachment_actioncxx . . $ sg_depth_attachment_action#;
1154
1155 typedef struct sg_stencil_attachment_actioncxx . . $ sg_stencil_attachment_action# {
1156 sg_actioncxx . . $ sg_action# actioncxx . . $ sg_stencil_attachment_action#action.;
1157 uint8_tcxx . . $ uint8_t# valcxx . . $ sg_stencil_attachment_action#val.;
1158 } sg_stencil_attachment_actioncxx . . $ sg_stencil_attachment_action#;
1159
1160 typedef struct sg_pass_actioncxx . . $ sg_pass_action# {
1161 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_pass_action#_start_canary.;
1162 sg_color_attachment_actioncxx . . $ sg_color_attachment_action# colorscxx . . $ sg_pass_action#colors.[SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.];
1163 sg_depth_attachment_actioncxx . . $ sg_depth_attachment_action# depthcxx . . $ sg_pass_action#depth.;
1164 sg_stencil_attachment_actioncxx . . $ sg_stencil_attachment_action# stencilcxx . . $ sg_pass_action#stencil.;
1165 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_pass_action#_end_canary.;
1166 } sg_pass_actioncxx . . $ sg_pass_action#;
1167
1168 /*
1169 sg_bindings
1170
1171 The sg_bindings structure defines the resource binding slots
1172 of the sokol_gfx render pipeline, used as argument to the
1173 sg_apply_bindings() function.
1174
1175 A resource binding struct contains:
1176
1177 - 1..N vertex buffers
1178 - 0..N vertex buffer offsets
1179 - 0..1 index buffers
1180 - 0..1 index buffer offsets
1181 - 0..N vertex shader stage images
1182 - 0..N fragment shader stage images
1183
1184 The max number of vertex buffer and shader stage images
1185 are defined by the SG_MAX_SHADERSTAGE_BUFFERS and
1186 SG_MAX_SHADERSTAGE_IMAGES configuration constants.
1187
1188 The optional buffer offsets can be used to group different chunks
1189 of vertex- and/or index-data into the same buffer objects.
1190 */
1191 typedef struct sg_bindingscxx . . $ sg_bindings# {
1192 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_bindings#_start_canary.;
1193 sg_buffercxx . . $ sg_buffer# vertex_bufferscxx . . $ sg_bindings#vertex_buffers.[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
1194 int vertex_buffer_offsetscxx . . $ sg_bindings#vertex_buffer_offsets.[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
1195 sg_buffercxx . . $ sg_buffer# index_buffercxx . . $ sg_bindings#index_buffer.;
1196 int index_buffer_offsetcxx . . $ sg_bindings#index_buffer_offset.;
1197 sg_imagecxx . . $ sg_image# vs_imagescxx . . $ sg_bindings#vs_images.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
1198 sg_imagecxx . . $ sg_image# fs_imagescxx . . $ sg_bindings#fs_images.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
1199 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_bindings#_end_canary.;
1200 } sg_bindingscxx . . $ sg_bindings#;
1201
1202 /*
1203 sg_buffer_desc
1204
1205 Creation parameters for sg_buffer objects, used in the
1206 sg_make_buffer() call.
1207
1208 The default configuration is:
1209
1210 .size: 0 (this *must* be set to a valid size in bytes)
1211 .type: SG_BUFFERTYPE_VERTEXBUFFER
1212 .usage: SG_USAGE_IMMUTABLE
1213 .content 0
1214 .label 0 (optional string label for trace hooks)
1215
1216 The dbg_label will be ignored by sokol_gfx.h, it is only useful
1217 when hooking into sg_make_buffer() or sg_init_buffer() via
1218 the sg_install_trace_hook
1219
1220 ADVANCED TOPIC: Injecting native 3D-API buffers:
1221
1222 The following struct members allow to inject your own GL, Metal
1223 or D3D11 buffers into sokol_gfx:
1224
1225 .gl_buffers[SG_NUM_INFLIGHT_FRAMES]
1226 .mtl_buffers[SG_NUM_INFLIGHT_FRAMES]
1227 .d3d11_buffer
1228
1229 You must still provide all other members except the .content member, and
1230 these must match the creation parameters of the native buffers you
1231 provide. For SG_USAGE_IMMUTABLE, only provide a single native 3D-API
1232 buffer, otherwise you need to provide SG_NUM_INFLIGHT_FRAMES buffers
1233 (only for GL and Metal, not D3D11). Providing multiple buffers for GL and
1234 Metal is necessary because sokol_gfx will rotate through them when
1235 calling sg_update_buffer() to prevent lock-stalls.
1236
1237 Note that it is expected that immutable injected buffer have already been
1238 initialized with content, and the .content member must be 0!
1239
1240 Also you need to call sg_reset_state_cache() after calling native 3D-API
1241 functions, and before calling any sokol_gfx function.
1242 */
1243 typedef struct sg_buffer_desccxx . . $ sg_buffer_desc# {
1244 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_buffer_desc#_start_canary.;
1245 int sizecxx . . $ sg_buffer_desc#size.;
1246 sg_buffer_typecxx . . $ sg_buffer_type# typecxx . . $ sg_buffer_desc#type.;
1247 sg_usagecxx . . $ sg_usage# usagecxx . . $ sg_buffer_desc#usage.;
1248 const void* contentcxx . . $ sg_buffer_desc#content.;
1249 const char* labelcxx . . $ sg_buffer_desc#label.;
1250 /* GL specific */
1251 uint32_tcxx . . $ uint32_t# gl_bufferscxx . . $ sg_buffer_desc#gl_buffers.[SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.];
1252 /* Metal specific */
1253 const void* mtl_bufferscxx . . $ sg_buffer_desc#mtl_buffers.[SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.];
1254 /* D3D11 specific */
1255 const void* d3d11_buffercxx . . $ sg_buffer_desc#d3d11_buffer.;
1256 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_buffer_desc#_end_canary.;
1257 } sg_buffer_desccxx . . $ sg_buffer_desc#;
1258
1259 /*
1260 sg_subimage_content
1261
1262 Pointer to and size of a subimage-surface data, this is
1263 used to describe the initial content of immutable-usage images,
1264 or for updating a dynamic- or stream-usage images.
1265
1266 For 3D- or array-textures, one sg_subimage_content item
1267 describes an entire mipmap level consisting of all array- or
1268 3D-slices of the mipmap level. It is only possible to update
1269 an entire mipmap level, not parts of it.
1270 */
1271 typedef struct sg_subimage_contentcxx . . $ sg_subimage_content# {
1272 const void* ptrcxx . . $ sg_subimage_content#ptr.; /* pointer to subimage data */
1273 int sizecxx . . $ sg_subimage_content#size.; /* size in bytes of pointed-to subimage data */
1274 } sg_subimage_contentcxx . . $ sg_subimage_content#;
1275
1276 /*
1277 sg_image_content
1278
1279 Defines the content of an image through a 2D array
1280 of sg_subimage_content structs. The first array dimension
1281 is the cubemap face, and the second array dimension the
1282 mipmap level.
1283 */
1284 typedef struct sg_image_contentcxx . . $ sg_image_content# {
1285 sg_subimage_contentcxx . . $ sg_subimage_content# subimagecxx . . $ sg_image_content#subimage.[SG_CUBEFACE_NUMcxx . . $ SG_CUBEFACE_NUM.][SG_MAX_MIPMAPScxx . . $ SG_MAX_MIPMAPS.];
1286 } sg_image_contentcxx . . $ sg_image_content#;
1287
1288 /*
1289 sg_image_desc
1290
1291 Creation parameters for sg_image objects, used in the
1292 sg_make_image() call.
1293
1294 The default configuration is:
1295
1296 .type: SG_IMAGETYPE_2D
1297 .render_target: false
1298 .width 0 (must be set to >0)
1299 .height 0 (must be set to >0)
1300 .depth/.layers: 1
1301 .num_mipmaps: 1
1302 .usage: SG_USAGE_IMMUTABLE
1303 .pixel_format: SG_PIXELFORMAT_RGBA8
1304 .sample_count: 1 (only used in render_targets)
1305 .min_filter: SG_FILTER_NEAREST
1306 .mag_filter: SG_FILTER_NEAREST
1307 .wrap_u: SG_WRAP_REPEAT
1308 .wrap_v: SG_WRAP_REPEAT
1309 .wrap_w: SG_WRAP_REPEAT (only SG_IMAGETYPE_3D)
1310 .max_anisotropy 1 (must be 1..16)
1311 .min_lod 0.0f
1312 .max_lod FLT_MAX
1313 .content an sg_image_content struct to define the initial content
1314 .label 0 (optional string label for trace hooks)
1315
1316 SG_IMAGETYPE_ARRAY and SG_IMAGETYPE_3D are not supported on
1317 WebGL/GLES2, use sg_query_feature(SG_FEATURE_IMAGETYPE_ARRAY) and
1318 sg_query_feature(SG_FEATURE_IMAGETYPE_3D) at runtime to check
1319 if array- and 3D-textures are supported.
1320
1321 Images with usage SG_USAGE_IMMUTABLE must be fully initialized by
1322 providing a valid .content member which points to
1323 initialization data.
1324
1325 ADVANCED TOPIC: Injecting native 3D-API textures:
1326
1327 The following struct members allow to inject your own GL, Metal
1328 or D3D11 textures into sokol_gfx:
1329
1330 .gl_textures[SG_NUM_INFLIGHT_FRAMES]
1331 .mtl_textures[SG_NUM_INFLIGHT_FRAMES]
1332 .d3d11_texture
1333
1334 The same rules apply as for injecting native buffers
1335 (see sg_buffer_desc documentation for more details).
1336 */
1337 typedef struct sg_image_desccxx . . $ sg_image_desc# {
1338 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_image_desc#_start_canary.;
1339 sg_image_typecxx . . $ sg_image_type# typecxx . . $ sg_image_desc#type.;
1340 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! render_targetcxx . . $ sg_image_desc#render_target.;
1341 int widthcxx . . $ sg_image_desc#width.;
1342 int heightcxx . . $ sg_image_desc#height.;
1343 unioncxx . . $ sg_image_desc#$anonymous_type_1# {
1344 int depthcxx . . $ sg_image_desc#$anonymous_type_1#depth.;
1345 int layerscxx . . $ sg_image_desc#$anonymous_type_1#layers.;
1346 };
1347 int num_mipmapscxx . . $ sg_image_desc#num_mipmaps.;
1348 sg_usagecxx . . $ sg_usage# usagecxx . . $ sg_image_desc#usage.;
1349 sg_pixel_formatcxx . . $ sg_pixel_format# pixel_formatcxx . . $ sg_image_desc#pixel_format.;
1350 int sample_countcxx . . $ sg_image_desc#sample_count.;
1351 sg_filtercxx . . $ sg_filter# min_filtercxx . . $ sg_image_desc#min_filter.;
1352 sg_filtercxx . . $ sg_filter# mag_filtercxx . . $ sg_image_desc#mag_filter.;
1353 sg_wrapcxx . . $ sg_wrap# wrap_ucxx . . $ sg_image_desc#wrap_u.;
1354 sg_wrapcxx . . $ sg_wrap# wrap_vcxx . . $ sg_image_desc#wrap_v.;
1355 sg_wrapcxx . . $ sg_wrap# wrap_wcxx . . $ sg_image_desc#wrap_w.;
1356 uint32_tcxx . . $ uint32_t# max_anisotropycxx . . $ sg_image_desc#max_anisotropy.;
1357 float min_lodcxx . . $ sg_image_desc#min_lod.;
1358 float max_lodcxx . . $ sg_image_desc#max_lod.;
1359 sg_image_contentcxx . . $ sg_image_content# contentcxx . . $ sg_image_desc#content.;
1360 const char* labelcxx . . $ sg_image_desc#label.;
1361 /* GL specific */
1362 uint32_tcxx . . $ uint32_t# gl_texturescxx . . $ sg_image_desc#gl_textures.[SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.];
1363 /* Metal specific */
1364 const void* mtl_texturescxx . . $ sg_image_desc#mtl_textures.[SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.];
1365 /* D3D11 specific */
1366 const void* d3d11_texturecxx . . $ sg_image_desc#d3d11_texture.;
1367 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_image_desc#_end_canary.;
1368 } sg_image_desccxx . . $ sg_image_desc#;
1369
1370 /*
1371 sg_shader_desc
1372
1373 The structure sg_shader_desc defines all creation parameters
1374 for shader programs, used as input to the sg_make_shader() function:
1375
1376 - reflection information for vertex attributes (vertex shader inputs):
1377 - vertex attribute name (required for GLES2, optional for GLES3 and GL)
1378 - a semantic name and index (required for D3D11)
1379 - for each vertex- and fragment-shader-stage:
1380 - the shader source or bytecode
1381 - an optional entry function name
1382 - reflection info for each uniform block used by the shader stage:
1383 - the size of the uniform block in bytes
1384 - reflection info for each uniform block member (only required for GL backends):
1385 - member name
1386 - member type (SG_UNIFORMTYPE_xxx)
1387 - if the member is an array, the number of array items
1388 - reflection info for the texture images used by the shader stage:
1389 - the image type (SG_IMAGETYPE_xxx)
1390 - the name of the texture sampler (required for GLES2, optional everywhere else)
1391
1392 For all GL backends, shader source-code must be provided. For D3D11 and Metal,
1393 either shader source-code or byte-code can be provided.
1394
1395 For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded
1396 on demand. If this fails, shader creation will fail.
1397 */
1398 typedef struct sg_shader_attr_desccxx . . $ sg_shader_attr_desc# {
1399 const char* namecxx . . $ sg_shader_attr_desc#name.; /* GLSL vertex attribute name (only required for GLES2) */
1400 const char* sem_namecxx . . $ sg_shader_attr_desc#sem_name.; /* HLSL semantic name */
1401 int sem_indexcxx . . $ sg_shader_attr_desc#sem_index.; /* HLSL semantic index */
1402 } sg_shader_attr_desccxx . . $ sg_shader_attr_desc#;
1403
1404 typedef struct sg_shader_uniform_desccxx . . $ sg_shader_uniform_desc# {
1405 const char* namecxx . . $ sg_shader_uniform_desc#name.;
1406 sg_uniform_typecxx . . $ sg_uniform_type# typecxx . . $ sg_shader_uniform_desc#type.;
1407 int array_countcxx . . $ sg_shader_uniform_desc#array_count.;
1408 } sg_shader_uniform_desccxx . . $ sg_shader_uniform_desc#;
1409
1410 typedef struct sg_shader_uniform_block_desccxx . . $ sg_shader_uniform_block_desc# {
1411 int sizecxx . . $ sg_shader_uniform_block_desc#size.;
1412 sg_shader_uniform_desccxx . . $ sg_shader_uniform_desc# uniformscxx . . $ sg_shader_uniform_block_desc#uniforms.[SG_MAX_UB_MEMBERScxx . . $ SG_MAX_UB_MEMBERS.];
1413 } sg_shader_uniform_block_desccxx . . $ sg_shader_uniform_block_desc#;
1414
1415 typedef struct sg_shader_image_desccxx . . $ sg_shader_image_desc# {
1416 const char* namecxx . . $ sg_shader_image_desc#name.;
1417 sg_image_typecxx . . $ sg_image_type# typecxx . . $ sg_shader_image_desc#type.;
1418 } sg_shader_image_desccxx . . $ sg_shader_image_desc#;
1419
1420 typedef struct sg_shader_stage_desccxx . . $ sg_shader_stage_desc# {
1421 const char* sourcecxx . . $ sg_shader_stage_desc#source.;
1422 const uint8_tcxx . . $ uint8_t#* byte_codecxx . . $ sg_shader_stage_desc#byte_code.;
1423 int byte_code_sizecxx . . $ sg_shader_stage_desc#byte_code_size.;
1424 const char* entrycxx . . $ sg_shader_stage_desc#entry.;
1425 sg_shader_uniform_block_desccxx . . $ sg_shader_uniform_block_desc# uniform_blockscxx . . $ sg_shader_stage_desc#uniform_blocks.[SG_MAX_SHADERSTAGE_UBScxx . . $ SG_MAX_SHADERSTAGE_UBS.];
1426 sg_shader_image_desccxx . . $ sg_shader_image_desc# imagescxx . . $ sg_shader_stage_desc#images.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
1427 } sg_shader_stage_desccxx . . $ sg_shader_stage_desc#;
1428
1429 typedef struct sg_shader_desccxx . . $ sg_shader_desc# {
1430 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_shader_desc#_start_canary.;
1431 sg_shader_attr_desccxx . . $ sg_shader_attr_desc# attrscxx . . $ sg_shader_desc#attrs.[SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.];
1432 sg_shader_stage_desccxx . . $ sg_shader_stage_desc# vscxx . . $ sg_shader_desc#vs.;
1433 sg_shader_stage_desccxx . . $ sg_shader_stage_desc# fscxx . . $ sg_shader_desc#fs.;
1434 const char* labelcxx . . $ sg_shader_desc#label.;
1435 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_shader_desc#_end_canary.;
1436 } sg_shader_desccxx . . $ sg_shader_desc#;
1437
1438 /*
1439 sg_pipeline_desc
1440
1441 The sg_pipeline_desc struct defines all creation parameters
1442 for an sg_pipeline object, used as argument to the
1443 sg_make_pipeline() function:
1444
1445 - the vertex layout for all input vertex buffers
1446 - a shader object
1447 - the 3D primitive type (points, lines, triangles, ...)
1448 - the index type (none, 16- or 32-bit)
1449 - depth-stencil state
1450 - alpha-blending state
1451 - rasterizer state
1452
1453 If the vertex data has no gaps between vertex components, you can omit
1454 the .layout.buffers[].stride and layout.attrs[].offset items (leave them
1455 default-initialized to 0), sokol will then compute the offsets and strides
1456 from the vertex component formats (.layout.attrs[].offset). Please note
1457 that ALL vertex attribute offsets must be 0 in order for the the
1458 automatic offset computation to kick in.
1459
1460 The default configuration is as follows:
1461
1462 .layout:
1463 .buffers[]: vertex buffer layouts
1464 .stride: 0 (if no stride is given it will be computed)
1465 .step_func SG_VERTEXSTEP_PER_VERTEX
1466 .step_rate 1
1467 .attrs[]: vertex attribute declarations
1468 .buffer_index 0 the vertex buffer bind slot
1469 .offset 0 (offsets can be omitted if the vertex layout has no gaps)
1470 .format SG_VERTEXFORMAT_INVALID (must be initialized!)
1471 .shader: 0 (must be intilized with a valid sg_shader id!)
1472 .primitive_type: SG_PRIMITIVETYPE_TRIANGLES
1473 .index_type: SG_INDEXTYPE_NONE
1474 .depth_stencil:
1475 .stencil_front, .stencil_back:
1476 .fail_op: SG_STENCILOP_KEEP
1477 .depth_fail_op: SG_STENCILOP_KEEP
1478 .pass_op: SG_STENCILOP_KEEP
1479 .compare_func SG_COMPAREFUNC_ALWAYS
1480 .depth_compare_func: SG_COMPAREFUNC_ALWAYS
1481 .depth_write_enabled: false
1482 .stencil_enabled: false
1483 .stencil_read_mask: 0
1484 .stencil_write_mask: 0
1485 .stencil_ref: 0
1486 .blend:
1487 .enabled: false
1488 .src_factor_rgb: SG_BLENDFACTOR_ONE
1489 .dst_factor_rgb: SG_BLENDFACTOR_ZERO
1490 .op_rgb: SG_BLENDOP_ADD
1491 .src_factor_alpha: SG_BLENDFACTOR_ONE
1492 .dst_factor_alpha: SG_BLENDFACTOR_ZERO
1493 .op_alpha: SG_BLENDOP_ADD
1494 .color_write_mask: SG_COLORMASK_RGBA
1495 .color_attachment_count 1
1496 .color_format SG_PIXELFORMAT_RGBA8
1497 .depth_format SG_PIXELFORMAT_DEPTHSTENCIL
1498 .blend_color: { 0.0f, 0.0f, 0.0f, 0.0f }
1499 .rasterizer:
1500 .alpha_to_coverage_enabled: false
1501 .cull_mode: SG_CULLMODE_NONE
1502 .face_winding: SG_FACEWINDING_CW
1503 .sample_count: 1
1504 .depth_bias: 0.0f
1505 .depth_bias_slope_scale: 0.0f
1506 .depth_bias_clamp: 0.0f
1507 .label 0 (optional string label for trace hooks)
1508 */
1509 typedef struct sg_buffer_layout_desccxx . . $ sg_buffer_layout_desc# {
1510 int stridecxx . . $ sg_buffer_layout_desc#stride.;
1511 sg_vertex_stepcxx . . $ sg_vertex_step# step_funccxx . . $ sg_buffer_layout_desc#step_func.;
1512 int step_ratecxx . . $ sg_buffer_layout_desc#step_rate.;
1513 } sg_buffer_layout_desccxx . . $ sg_buffer_layout_desc#;
1514
1515 typedef struct sg_vertex_attr_desccxx . . $ sg_vertex_attr_desc# {
1516 int buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.;
1517 int offsetcxx . . $ sg_vertex_attr_desc#offset.;
1518 sg_vertex_formatcxx . . $ sg_vertex_format# formatcxx . . $ sg_vertex_attr_desc#format.;
1519 } sg_vertex_attr_desccxx . . $ sg_vertex_attr_desc#;
1520
1521 typedef struct sg_layout_desccxx . . $ sg_layout_desc# {
1522 sg_buffer_layout_desccxx . . $ sg_buffer_layout_desc# bufferscxx . . $ sg_layout_desc#buffers.[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
1523 sg_vertex_attr_desccxx . . $ sg_vertex_attr_desc# attrscxx . . $ sg_layout_desc#attrs.[SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.];
1524 } sg_layout_desccxx . . $ sg_layout_desc#;
1525
1526 typedef struct sg_stencil_statecxx . . $ sg_stencil_state# {
1527 sg_stencil_opcxx . . $ sg_stencil_op# fail_opcxx . . $ sg_stencil_state#fail_op.;
1528 sg_stencil_opcxx . . $ sg_stencil_op# depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op.;
1529 sg_stencil_opcxx . . $ sg_stencil_op# pass_opcxx . . $ sg_stencil_state#pass_op.;
1530 sg_compare_funccxx . . $ sg_compare_func# compare_funccxx . . $ sg_stencil_state#compare_func.;
1531 } sg_stencil_statecxx . . $ sg_stencil_state#;
1532
1533 typedef struct sg_depth_stencil_statecxx . . $ sg_depth_stencil_state# {
1534 sg_stencil_statecxx . . $ sg_stencil_state# stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front.;
1535 sg_stencil_statecxx . . $ sg_stencil_state# stencil_backcxx . . $ sg_depth_stencil_state#stencil_back.;
1536 sg_compare_funccxx . . $ sg_compare_func# depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func.;
1537 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled.;
1538 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! stencil_enabledcxx . . $ sg_depth_stencil_state#stencil_enabled.;
1539 uint8_tcxx . . $ uint8_t# stencil_read_maskcxx . . $ sg_depth_stencil_state#stencil_read_mask.;
1540 uint8_tcxx . . $ uint8_t# stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask.;
1541 uint8_tcxx . . $ uint8_t# stencil_refcxx . . $ sg_depth_stencil_state#stencil_ref.;
1542 } sg_depth_stencil_statecxx . . $ sg_depth_stencil_state#;
1543
1544 typedef struct sg_blend_statecxx . . $ sg_blend_state# {
1545 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! enabledcxx . . $ sg_blend_state#enabled.;
1546 sg_blend_factorcxx . . $ sg_blend_factor# src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb.;
1547 sg_blend_factorcxx . . $ sg_blend_factor# dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb.;
1548 sg_blend_opcxx . . $ sg_blend_op# op_rgbcxx . . $ sg_blend_state#op_rgb.;
1549 sg_blend_factorcxx . . $ sg_blend_factor# src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha.;
1550 sg_blend_factorcxx . . $ sg_blend_factor# dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha.;
1551 sg_blend_opcxx . . $ sg_blend_op# op_alphacxx . . $ sg_blend_state#op_alpha.;
1552 uint8_tcxx . . $ uint8_t# color_write_maskcxx . . $ sg_blend_state#color_write_mask.;
1553 int color_attachment_countcxx . . $ sg_blend_state#color_attachment_count.;
1554 sg_pixel_formatcxx . . $ sg_pixel_format# color_formatcxx . . $ sg_blend_state#color_format.;
1555 sg_pixel_formatcxx . . $ sg_pixel_format# depth_formatcxx . . $ sg_blend_state#depth_format.;
1556 float blend_colorcxx . . $ sg_blend_state#blend_color.[4];
1557 } sg_blend_statecxx . . $ sg_blend_state#;
1558
1559 typedef struct sg_rasterizer_statecxx . . $ sg_rasterizer_state# {
1560 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! alpha_to_coverage_enabledcxx . . $ sg_rasterizer_state#alpha_to_coverage_enabled.;
1561 sg_cull_modecxx . . $ sg_cull_mode# cull_modecxx . . $ sg_rasterizer_state#cull_mode.;
1562 sg_face_windingcxx . . $ sg_face_winding# face_windingcxx . . $ sg_rasterizer_state#face_winding.;
1563 int sample_countcxx . . $ sg_rasterizer_state#sample_count.;
1564 float depth_biascxx . . $ sg_rasterizer_state#depth_bias.;
1565 float depth_bias_slope_scalecxx . . $ sg_rasterizer_state#depth_bias_slope_scale.;
1566 float depth_bias_clampcxx . . $ sg_rasterizer_state#depth_bias_clamp.;
1567 } sg_rasterizer_statecxx . . $ sg_rasterizer_state#;
1568
1569 typedef struct sg_pipeline_desccxx . . $ sg_pipeline_desc# {
1570 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_pipeline_desc#_start_canary.;
1571 sg_layout_desccxx . . $ sg_layout_desc# layoutcxx . . $ sg_pipeline_desc#layout.;
1572 sg_shadercxx . . $ sg_shader# shadercxx . . $ sg_pipeline_desc#shader.;
1573 sg_primitive_typecxx . . $ sg_primitive_type# primitive_typecxx . . $ sg_pipeline_desc#primitive_type.;
1574 sg_index_typecxx . . $ sg_index_type# index_typecxx . . $ sg_pipeline_desc#index_type.;
1575 sg_depth_stencil_statecxx . . $ sg_depth_stencil_state# depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil.;
1576 sg_blend_statecxx . . $ sg_blend_state# blendcxx . . $ sg_pipeline_desc#blend.;
1577 sg_rasterizer_statecxx . . $ sg_rasterizer_state# rasterizercxx . . $ sg_pipeline_desc#rasterizer.;
1578 const char* labelcxx . . $ sg_pipeline_desc#label.;
1579 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_pipeline_desc#_end_canary.;
1580 } sg_pipeline_desccxx . . $ sg_pipeline_desc#;
1581
1582 /*
1583 sg_pass_desc
1584
1585 Creation parameters for an sg_pass object, used as argument
1586 to the sg_make_pass() function.
1587
1588 A pass object contains 1..4 color-attachments and none, or one,
1589 depth-stencil-attachment. Each attachment consists of
1590 an image, and two additional indices describing
1591 which subimage the pass will render: one mipmap index, and
1592 if the image is a cubemap, array-texture or 3D-texture, the
1593 face-index, array-layer or depth-slice.
1594
1595 Pass images must fulfill the following requirements:
1596
1597 All images must have:
1598 - been created as render target (sg_image_desc.render_target = true)
1599 - the same size
1600 - the same sample count
1601
1602 In addition, all color-attachment images must have the same
1603 pixel format.
1604 */
1605 typedef struct sg_attachment_desccxx . . $ sg_attachment_desc# {
1606 sg_imagecxx . . $ sg_image# imagecxx . . $ sg_attachment_desc#image.;
1607 int mip_levelcxx . . $ sg_attachment_desc#mip_level.;
1608 unioncxx . . $ sg_attachment_desc#$anonymous_type_2# {
1609 int facecxx . . $ sg_attachment_desc#$anonymous_type_2#face.;
1610 int layercxx . . $ sg_attachment_desc#$anonymous_type_2#layer.;
1611 int slicecxx . . $ sg_attachment_desc#$anonymous_type_2#slice.;
1612 };
1613 } sg_attachment_desccxx . . $ sg_attachment_desc#;
1614
1615 typedef struct sg_pass_desccxx . . $ sg_pass_desc# {
1616 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_pass_desc#_start_canary.;
1617 sg_attachment_desccxx . . $ sg_attachment_desc# color_attachmentscxx . . $ sg_pass_desc#color_attachments.[SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.];
1618 sg_attachment_desccxx . . $ sg_attachment_desc# depth_stencil_attachmentcxx . . $ sg_pass_desc#depth_stencil_attachment.;
1619 const char* labelcxx . . $ sg_pass_desc#label.;
1620 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_pass_desc#_end_canary.;
1621 } sg_pass_desccxx . . $ sg_pass_desc#;
1622
1623 /*
1624 sg_trace_hooks
1625
1626 Installable callback function to keep track of the sokol_gfx calls,
1627 this is useful for debugging, or keeping track of resource creation
1628 and destruction.
1629
1630 Trace hooks are installed with sg_install_trace_hooks(), this returns
1631 another sg_trace_hooks functions with the previous set of
1632 trace hook function pointers. These should be invoked by the
1633 new trace hooks to form a proper call chain.
1634 */
1635 typedef struct sg_trace_hookscxx . . $ sg_trace_hooks# {
1636 void* user_datacxx . . $ sg_trace_hooks#user_data.;
1637 void (*query_featurecxx . . $ sg_trace_hooks#query_feature.)(sg_featurecxx . . $ sg_feature# feature, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! result, void* user_data);
1638 void (*reset_state_cachecxx . . $ sg_trace_hooks#reset_state_cache.)(void* user_data);
1639 void (*make_buffercxx . . $ sg_trace_hooks#make_buffer.)(const sg_buffer_desccxx . . $ sg_buffer_desc#* desc, sg_buffercxx . . $ sg_buffer# result, void* user_data);
1640 void (*make_imagecxx . . $ sg_trace_hooks#make_image.)(const sg_image_desccxx . . $ sg_image_desc#* desc, sg_imagecxx . . $ sg_image# result, void* user_data);
1641 void (*make_shadercxx . . $ sg_trace_hooks#make_shader.)(const sg_shader_desccxx . . $ sg_shader_desc#* desc, sg_shadercxx . . $ sg_shader# result, void* user_data);
1642 void (*make_pipelinecxx . . $ sg_trace_hooks#make_pipeline.)(const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc, sg_pipelinecxx . . $ sg_pipeline# result, void* user_data);
1643 void (*make_passcxx . . $ sg_trace_hooks#make_pass.)(const sg_pass_desccxx . . $ sg_pass_desc#* desc, sg_passcxx . . $ sg_pass# result, void* user_data);
1644 void (*destroy_buffercxx . . $ sg_trace_hooks#destroy_buffer.)(sg_buffercxx . . $ sg_buffer# buf, void* user_data);
1645 void (*destroy_imagecxx . . $ sg_trace_hooks#destroy_image.)(sg_imagecxx . . $ sg_image# img, void* user_data);
1646 void (*destroy_shadercxx . . $ sg_trace_hooks#destroy_shader.)(sg_shadercxx . . $ sg_shader# shd, void* user_data);
1647 void (*destroy_pipelinecxx . . $ sg_trace_hooks#destroy_pipeline.)(sg_pipelinecxx . . $ sg_pipeline# pip, void* user_data);
1648 void (*destroy_passcxx . . $ sg_trace_hooks#destroy_pass.)(sg_passcxx . . $ sg_pass# pass, void* user_data);
1649 void (*update_buffercxx . . $ sg_trace_hooks#update_buffer.)(sg_buffercxx . . $ sg_buffer# buf, const void* data_ptr, int data_size, void* user_data);
1650 void (*update_imagecxx . . $ sg_trace_hooks#update_image.)(sg_imagecxx . . $ sg_image# img, const sg_image_contentcxx . . $ sg_image_content#* data, void* user_data);
1651 void (*append_buffercxx . . $ sg_trace_hooks#append_buffer.)(sg_buffercxx . . $ sg_buffer# buf, const void* data_ptr, int data_size, int result, void* user_data);
1652 void (*begin_default_passcxx . . $ sg_trace_hooks#begin_default_pass.)(const sg_pass_actioncxx . . $ sg_pass_action#* pass_action, int width, int height, void* user_data);
1653 void (*begin_passcxx . . $ sg_trace_hooks#begin_pass.)(sg_passcxx . . $ sg_pass# pass, const sg_pass_actioncxx . . $ sg_pass_action#* pass_action, void* user_data);
1654 void (*apply_viewportcxx . . $ sg_trace_hooks#apply_viewport.)(int x, int y, int width, int height, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left, void* user_data);
1655 void (*apply_scissor_rectcxx . . $ sg_trace_hooks#apply_scissor_rect.)(int x, int y, int width, int height, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left, void* user_data);
1656 void (*apply_pipelinecxx . . $ sg_trace_hooks#apply_pipeline.)(sg_pipelinecxx . . $ sg_pipeline# pip, void* user_data);
1657 void (*apply_bindingscxx . . $ sg_trace_hooks#apply_bindings.)(const sg_bindingscxx . . $ sg_bindings#* bindings, void* user_data);
1658 void (*apply_uniformscxx . . $ sg_trace_hooks#apply_uniforms.)(sg_shader_stagecxx . . $ sg_shader_stage# stage, int ub_index, const void* data, int num_bytes, void* user_data);
1659 void (*drawcxx . . $ sg_trace_hooks#draw.)(int base_element, int num_elements, int num_instances, void* user_data);
1660 void (*end_passcxx . . $ sg_trace_hooks#end_pass.)(void* user_data);
1661 void (*commitcxx . . $ sg_trace_hooks#commit.)(void* user_data);
1662 void (*alloc_buffercxx . . $ sg_trace_hooks#alloc_buffer.)(sg_buffercxx . . $ sg_buffer# result, void* user_data);
1663 void (*alloc_imagecxx . . $ sg_trace_hooks#alloc_image.)(sg_imagecxx . . $ sg_image# result, void* user_data);
1664 void (*alloc_shadercxx . . $ sg_trace_hooks#alloc_shader.)(sg_shadercxx . . $ sg_shader# result, void* user_data);
1665 void (*alloc_pipelinecxx . . $ sg_trace_hooks#alloc_pipeline.)(sg_pipelinecxx . . $ sg_pipeline# result, void* user_data);
1666 void (*alloc_passcxx . . $ sg_trace_hooks#alloc_pass.)(sg_passcxx . . $ sg_pass# result, void* user_data);
1667 void (*init_buffercxx . . $ sg_trace_hooks#init_buffer.)(sg_buffercxx . . $ sg_buffer# buf_id, const sg_buffer_desccxx . . $ sg_buffer_desc#* desc, void* user_data);
1668 void (*init_imagecxx . . $ sg_trace_hooks#init_image.)(sg_imagecxx . . $ sg_image# img_id, const sg_image_desccxx . . $ sg_image_desc#* desc, void* user_data);
1669 void (*init_shadercxx . . $ sg_trace_hooks#init_shader.)(sg_shadercxx . . $ sg_shader# shd_id, const sg_shader_desccxx . . $ sg_shader_desc#* desc, void* user_data);
1670 void (*init_pipelinecxx . . $ sg_trace_hooks#init_pipeline.)(sg_pipelinecxx . . $ sg_pipeline# pip_id, const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc, void* user_data);
1671 void (*init_passcxx . . $ sg_trace_hooks#init_pass.)(sg_passcxx . . $ sg_pass# pass_id, const sg_pass_desccxx . . $ sg_pass_desc#* desc, void* user_data);
1672 void (*fail_buffercxx . . $ sg_trace_hooks#fail_buffer.)(sg_buffercxx . . $ sg_buffer# buf_id, void* user_data);
1673 void (*fail_imagecxx . . $ sg_trace_hooks#fail_image.)(sg_imagecxx . . $ sg_image# img_id, void* user_data);
1674 void (*fail_shadercxx . . $ sg_trace_hooks#fail_shader.)(sg_shadercxx . . $ sg_shader# shd_id, void* user_data);
1675 void (*fail_pipelinecxx . . $ sg_trace_hooks#fail_pipeline.)(sg_pipelinecxx . . $ sg_pipeline# pip_id, void* user_data);
1676 void (*fail_passcxx . . $ sg_trace_hooks#fail_pass.)(sg_passcxx . . $ sg_pass# pass_id, void* user_data);
1677 void (*push_debug_groupcxx . . $ sg_trace_hooks#push_debug_group.)(const char* name, void* user_data);
1678 void (*pop_debug_groupcxx . . $ sg_trace_hooks#pop_debug_group.)(void* user_data);
1679 void (*err_buffer_pool_exhaustedcxx . . $ sg_trace_hooks#err_buffer_pool_exhausted.)(void* user_data);
1680 void (*err_image_pool_exhaustedcxx . . $ sg_trace_hooks#err_image_pool_exhausted.)(void* user_data);
1681 void (*err_shader_pool_exhaustedcxx . . $ sg_trace_hooks#err_shader_pool_exhausted.)(void* user_data);
1682 void (*err_pipeline_pool_exhaustedcxx . . $ sg_trace_hooks#err_pipeline_pool_exhausted.)(void* user_data);
1683 void (*err_pass_pool_exhaustedcxx . . $ sg_trace_hooks#err_pass_pool_exhausted.)(void* user_data);
1684 void (*err_context_mismatchcxx . . $ sg_trace_hooks#err_context_mismatch.)(void* user_data);
1685 void (*err_pass_invalidcxx . . $ sg_trace_hooks#err_pass_invalid.)(void* user_data);
1686 void (*err_draw_invalidcxx . . $ sg_trace_hooks#err_draw_invalid.)(void* user_data);
1687 void (*err_bindings_invalidcxx . . $ sg_trace_hooks#err_bindings_invalid.)(void* user_data);
1688 } sg_trace_hookscxx . . $ sg_trace_hooks#;
1689
1690 /*
1691 sg_buffer_info
1692 sg_image_info
1693 sg_shader_info
1694 sg_pipeline_info
1695 sg_pass_info
1696
1697 These structs contain various internal resource attributes which
1698 might be useful for debug-inspection. Please don't rely on the
1699 actual content of those structs too much, as they are quite closely
1700 tied to sokol_gfx.h internals and may change more frequently than
1701 the other public API elements.
1702
1703 The *_info structs are used as the return values of the following functions:
1704
1705 sg_query_buffer_info()
1706 sg_query_image_info()
1707 sg_query_shader_info()
1708 sg_query_pipeline_info()
1709 sg_query_pass_info()
1710 */
1711 typedef struct sg_slot_infocxx . . $ sg_slot_info# {
1712 sg_resource_statecxx . . $ sg_resource_state# statecxx . . $ sg_slot_info#state.; /* the current state of this resource slot */
1713 uint32_tcxx . . $ uint32_t# res_idcxx . . $ sg_slot_info#res_id.; /* type-neutral resource if (e.g. sg_buffer.id) */
1714 uint32_tcxx . . $ uint32_t# ctx_idcxx . . $ sg_slot_info#ctx_id.; /* the context this resource belongs to */
1715 } sg_slot_infocxx . . $ sg_slot_info#;
1716
1717 typedef struct sg_buffer_infocxx . . $ sg_buffer_info# {
1718 sg_slot_infocxx . . $ sg_slot_info# slotcxx . . $ sg_buffer_info#slot.; /* resource pool slot info */
1719 uint32_tcxx . . $ uint32_t# update_frame_indexcxx . . $ sg_buffer_info#update_frame_index.; /* frame index of last sg_update_buffer() */
1720 uint32_tcxx . . $ uint32_t# append_frame_indexcxx . . $ sg_buffer_info#append_frame_index.; /* frame index of last sg_append_buffer() */
1721 int append_poscxx . . $ sg_buffer_info#append_pos.; /* current position in buffer for sg_append_buffer() */
1722 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! append_overflowcxx . . $ sg_buffer_info#append_overflow.; /* is buffer in overflow state (due to sg_append_buffer) */
1723 int num_slotscxx . . $ sg_buffer_info#num_slots.; /* number of renaming-slots for dynamically updated buffers */
1724 int active_slotcxx . . $ sg_buffer_info#active_slot.; /* currently active write-slot for dynamically updated buffers */
1725 } sg_buffer_infocxx . . $ sg_buffer_info#;
1726
1727 typedef struct sg_image_infocxx . . $ sg_image_info# {
1728 sg_slot_infocxx . . $ sg_slot_info# slotcxx . . $ sg_image_info#slot.; /* resource pool slot info */
1729 uint32_tcxx . . $ uint32_t# upd_frame_indexcxx . . $ sg_image_info#upd_frame_index.; /* frame index of last sg_update_image() */
1730 int num_slotscxx . . $ sg_image_info#num_slots.; /* number of renaming-slots for dynamically updated images */
1731 int active_slotcxx . . $ sg_image_info#active_slot.; /* currently active write-slot for dynamically updated images */
1732 } sg_image_infocxx . . $ sg_image_info#;
1733
1734 typedef struct sg_shader_infocxx . . $ sg_shader_info# {
1735 sg_slot_infocxx . . $ sg_slot_info# slotcxx . . $ sg_shader_info#slot.; /* resoure pool slot info */
1736 } sg_shader_infocxx . . $ sg_shader_info#;
1737
1738 typedef struct sg_pipeline_infocxx . . $ sg_pipeline_info# {
1739 sg_slot_infocxx . . $ sg_slot_info# slotcxx . . $ sg_pipeline_info#slot.; /* resource pool slot info */
1740 } sg_pipeline_infocxx . . $ sg_pipeline_info#;
1741
1742 typedef struct sg_pass_infocxx . . $ sg_pass_info# {
1743 sg_slot_infocxx . . $ sg_slot_info# slotcxx . . $ sg_pass_info#slot.; /* resource pool slot info */
1744 } sg_pass_infocxx . . $ sg_pass_info#;
1745
1746 /*
1747 sg_desc
1748
1749 The sg_desc struct contains configuration values for sokol_gfx,
1750 it is used as parameter to the sg_setup() call.
1751
1752 The default configuration is:
1753
1754 .buffer_pool_size: 128
1755 .image_pool_size: 128
1756 .shader_pool_size: 32
1757 .pipeline_pool_size: 64
1758 .pass_pool_size: 16
1759 .context_pool_size: 16
1760
1761 GL specific:
1762 .gl_force_gles2
1763 if this is true the GL backend will act in "GLES2 fallback mode" even
1764 when compiled with SOKOL_GLES3, this is useful to fall back
1765 to traditional WebGL if a browser doesn't support a WebGL2 context
1766
1767 Metal specific:
1768 (NOTE: All Objective-C object references are transferred through
1769 a bridged (const void*) to sokol_gfx, which will use a unretained
1770 bridged cast (__bridged id<xxx>) to retrieve the Objective-C
1771 references back. Since the bridge cast is unretained, the caller
1772 must hold a strong reference to the Objective-C object for the
1773 duration of the sokol_gfx call!
1774
1775 .mtl_device
1776 a pointer to the MTLDevice object
1777 .mtl_renderpass_descriptor_cb
1778 a C callback function to obtain the MTLRenderPassDescriptor for the
1779 current frame when rendering to the default framebuffer, will be called
1780 in sg_begin_default_pass()
1781 .mtl_drawable_cb
1782 a C callback function to obtain a MTLDrawable for the current
1783 frame when rendering to the default framebuffer, will be called in
1784 sg_end_pass() of the default pass
1785 .mtl_global_uniform_buffer_size
1786 the size of the global uniform buffer in bytes, this must be big
1787 enough to hold all uniform block updates for a single frame,
1788 the default value is 4 MByte (4 * 1024 * 1024)
1789 .mtl_sampler_cache_size
1790 the number of slots in the sampler cache, the Metal backend
1791 will share texture samplers with the same state in this
1792 cache, the default value is 64
1793
1794 D3D11 specific:
1795 .d3d11_device
1796 a pointer to the ID3D11Device object, this must have been created
1797 before sg_setup() is called
1798 .d3d11_device_context
1799 a pointer to the ID3D11DeviceContext object
1800 .d3d11_render_target_view_cb
1801 a C callback function to obtain a pointer to the current
1802 ID3D11RenderTargetView object of the default framebuffer,
1803 this function will be called in sg_begin_pass() when rendering
1804 to the default framebuffer
1805 .d3d11_depth_stencil_view_cb
1806 a C callback function to obtain a pointer to the current
1807 ID3D11DepthStencilView object of the default framebuffer,
1808 this function will be called in sg_begin_pass() when rendering
1809 to the default framebuffer
1810 */
1811 typedef struct sg_desccxx . . $ sg_desc# {
1812 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_desc#_start_canary.;
1813 int buffer_pool_sizecxx . . $ sg_desc#buffer_pool_size.;
1814 int image_pool_sizecxx . . $ sg_desc#image_pool_size.;
1815 int shader_pool_sizecxx . . $ sg_desc#shader_pool_size.;
1816 int pipeline_pool_sizecxx . . $ sg_desc#pipeline_pool_size.;
1817 int pass_pool_sizecxx . . $ sg_desc#pass_pool_size.;
1818 int context_pool_sizecxx . . $ sg_desc#context_pool_size.;
1819 /* GL specific */
1820 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! gl_force_gles2cxx . . $ sg_desc#gl_force_gles2.;
1821 /* Metal-specific */
1822 const void* mtl_devicecxx . . $ sg_desc#mtl_device.;
1823 const void* (*mtl_renderpass_descriptor_cbcxx . . $ sg_desc#mtl_renderpass_descriptor_cb.)(void);
1824 const void* (*mtl_drawable_cbcxx . . $ sg_desc#mtl_drawable_cb.)(void);
1825 int mtl_global_uniform_buffer_sizecxx . . $ sg_desc#mtl_global_uniform_buffer_size.;
1826 int mtl_sampler_cache_sizecxx . . $ sg_desc#mtl_sampler_cache_size.;
1827 /* D3D11-specific */
1828 const void* d3d11_devicecxx . . $ sg_desc#d3d11_device.;
1829 const void* d3d11_device_contextcxx . . $ sg_desc#d3d11_device_context.;
1830 const void* (*d3d11_render_target_view_cbcxx . . $ sg_desc#d3d11_render_target_view_cb.)(void);
1831 const void* (*d3d11_depth_stencil_view_cbcxx . . $ sg_desc#d3d11_depth_stencil_view_cb.)(void);
1832 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_desc#_end_canary.;
1833 } sg_desccxx . . $ sg_desc#;
1834
1835 /* setup and misc functions */
1836 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_setupcxx . . $ sg_setup(14daf3ac2a73e58e).(const sg_desccxx . . $ sg_desc#* desc);
1837 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_shutdowncxx . . $ sg_shutdown(49f6e7a06ebc5aa8).(void);
1838 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sg_isvalidcxx . . $ sg_isvalid(c9857a73d68e59ba).(void);
1839 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_desccxx . . $ sg_desc# sg_query_desccxx . . $ sg_query_desc(2e490c611a485da0).(void);
1840 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_backendcxx . . $ sg_backend# sg_query_backendcxx . . $ sg_query_backend(4679d869a1a56231).(void);
1841 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sg_query_featurecxx . . $ sg_query_feature(11c85d13deabec9).(sg_featurecxx . . $ sg_feature# feature);
1842 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_reset_state_cachecxx . . $ sg_reset_state_cache(49f6e7a06ebc5aa8).(void);
1843 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_trace_hookscxx . . $ sg_trace_hooks# sg_install_trace_hookscxx . . $ sg_install_trace_hooks(1f7eed8ce62baf44).(const sg_trace_hookscxx . . $ sg_trace_hooks#* trace_hooks);
1844 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_push_debug_groupcxx . . $ sg_push_debug_group(85c52e162fed56f9).(const char* name);
1845 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_pop_debug_groupcxx . . $ sg_pop_debug_group(49f6e7a06ebc5aa8).(void);
1846
1847 /* resource creation, destruction and updating */
1848 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_buffercxx . . $ sg_buffer# sg_make_buffercxx . . $ sg_make_buffer(5efb77b03fd1b393).(const sg_buffer_desccxx . . $ sg_buffer_desc#* desc);
1849 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_imagecxx . . $ sg_image# sg_make_imagecxx . . $ sg_make_image(50a18bf9177d92a4).(const sg_image_desccxx . . $ sg_image_desc#* desc);
1850 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_shadercxx . . $ sg_shader# sg_make_shadercxx . . $ sg_make_shader(ab0d6bdcaa5aceeb).(const sg_shader_desccxx . . $ sg_shader_desc#* desc);
1851 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_pipelinecxx . . $ sg_pipeline# sg_make_pipelinecxx . . $ sg_make_pipeline(6e5e446a35687b83).(const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc);
1852 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_passcxx . . $ sg_pass# sg_make_passcxx . . $ sg_make_pass(73e6e246420afa25).(const sg_pass_desccxx . . $ sg_pass_desc#* desc);
1853 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_destroy_buffercxx . . $ sg_destroy_buffer(73b2a9b74a436b7).(sg_buffercxx . . $ sg_buffer# buf);
1854 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_destroy_imagecxx . . $ sg_destroy_image(a131ac04d927795).(sg_imagecxx . . $ sg_image# img);
1855 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_destroy_shadercxx . . $ sg_destroy_shader(c05267500f0c2b7f).(sg_shadercxx . . $ sg_shader# shd);
1856 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_destroy_pipelinecxx . . $ sg_destroy_pipeline(fa06e78c216ede9c).(sg_pipelinecxx . . $ sg_pipeline# pip);
1857 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_destroy_passcxx . . $ sg_destroy_pass(f6b4b2e9b04024b9).(sg_passcxx . . $ sg_pass# pass);
1858 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_update_buffercxx . . $ sg_update_buffer(5c59391e5d00dba1).(sg_buffercxx . . $ sg_buffer# buf, const void* data_ptr, int data_size);
1859 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_update_imagecxx . . $ sg_update_image(27fab29f9732cff3).(sg_imagecxx . . $ sg_image# img, const sg_image_contentcxx . . $ sg_image_content#* data);
1860 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! int sg_append_buffercxx . . $ sg_append_buffer(78466a5fc0ca5d1e).(sg_buffercxx . . $ sg_buffer# buf, const void* data_ptr, int data_size);
1861 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sg_query_buffer_overflowcxx . . $ sg_query_buffer_overflow(eb54ae0c35724bdb).(sg_buffercxx . . $ sg_buffer# buf);
1862
1863 /* get resource state (initial, alloc, valid, failed) */
1864 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_resource_statecxx . . $ sg_resource_state# sg_query_buffer_statecxx . . $ sg_query_buffer_state(66712bcf7f99879d).(sg_buffercxx . . $ sg_buffer# buf);
1865 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_resource_statecxx . . $ sg_resource_state# sg_query_image_statecxx . . $ sg_query_image_state(551db7248109e594).(sg_imagecxx . . $ sg_image# img);
1866 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_resource_statecxx . . $ sg_resource_state# sg_query_shader_statecxx . . $ sg_query_shader_state(646759dfe832451c).(sg_shadercxx . . $ sg_shader# shd);
1867 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_resource_statecxx . . $ sg_resource_state# sg_query_pipeline_statecxx . . $ sg_query_pipeline_state(f86b3dec1f91b880).(sg_pipelinecxx . . $ sg_pipeline# pip);
1868 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_resource_statecxx . . $ sg_resource_state# sg_query_pass_statecxx . . $ sg_query_pass_state(f0dc53719bffbf1a).(sg_passcxx . . $ sg_pass# pass);
1869
1870 /* rendering functions */
1871 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_begin_default_passcxx . . $ sg_begin_default_pass(2956e7fd84f328a).(const sg_pass_actioncxx . . $ sg_pass_action#* pass_action, int width, int height);
1872 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_begin_passcxx . . $ sg_begin_pass(99634fc39c654f7).(sg_passcxx . . $ sg_pass# pass, const sg_pass_actioncxx . . $ sg_pass_action#* pass_action);
1873 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_apply_viewportcxx . . $ sg_apply_viewport(d7a7761809021567).(int x, int y, int width, int height, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left);
1874 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_apply_scissor_rectcxx . . $ sg_apply_scissor_rect(d7a7761809021567).(int x, int y, int width, int height, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left);
1875 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_apply_pipelinecxx . . $ sg_apply_pipeline(fa06e78c216ede9c).(sg_pipelinecxx . . $ sg_pipeline# pip);
1876 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_apply_bindingscxx . . $ sg_apply_bindings(5f6aac639b109626).(const sg_bindingscxx . . $ sg_bindings#* bindings);
1877 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_apply_uniformscxx . . $ sg_apply_uniforms(d4a2e1eb7e556ec4).(sg_shader_stagecxx . . $ sg_shader_stage# stage, int ub_index, const void* data, int num_bytes);
1878 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_drawcxx . . $ sg_draw(b1146eedae1e1d0b).(int base_element, int num_elements, int num_instances);
1879 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_end_passcxx . . $ sg_end_pass(49f6e7a06ebc5aa8).(void);
1880 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_commitcxx . . $ sg_commit(49f6e7a06ebc5aa8).(void);
1881
1882 /* separate resource allocation and initialization (for async setup) */
1883 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_buffercxx . . $ sg_buffer# sg_alloc_buffercxx . . $ sg_alloc_buffer(210aeac7c490d744).(void);
1884 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_imagecxx . . $ sg_image# sg_alloc_imagecxx . . $ sg_alloc_image(c32329c31f7bd9e9).(void);
1885 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_shadercxx . . $ sg_shader# sg_alloc_shadercxx . . $ sg_alloc_shader(eddf85115a913590).(void);
1886 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_pipelinecxx . . $ sg_pipeline# sg_alloc_pipelinecxx . . $ sg_alloc_pipeline(4d9e1c814ee6f037).(void);
1887 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_passcxx . . $ sg_pass# sg_alloc_passcxx . . $ sg_alloc_pass(8fa2722a10bdd7a8).(void);
1888 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_init_buffercxx . . $ sg_init_buffer(199f42cf0ce34e9e).(sg_buffercxx . . $ sg_buffer# buf_id, const sg_buffer_desccxx . . $ sg_buffer_desc#* desc);
1889 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_init_imagecxx . . $ sg_init_image(b9ac7bf4077bbc85).(sg_imagecxx . . $ sg_image# img_id, const sg_image_desccxx . . $ sg_image_desc#* desc);
1890 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_init_shadercxx . . $ sg_init_shader(ffec3585d8638365).(sg_shadercxx . . $ sg_shader# shd_id, const sg_shader_desccxx . . $ sg_shader_desc#* desc);
1891 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_init_pipelinecxx . . $ sg_init_pipeline(92596deeb42817ed).(sg_pipelinecxx . . $ sg_pipeline# pip_id, const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc);
1892 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_init_passcxx . . $ sg_init_pass(5bf38153cc347fdc).(sg_passcxx . . $ sg_pass# pass_id, const sg_pass_desccxx . . $ sg_pass_desc#* desc);
1893 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_fail_buffercxx . . $ sg_fail_buffer(73b2a9b74a436b7).(sg_buffercxx . . $ sg_buffer# buf_id);
1894 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_fail_imagecxx . . $ sg_fail_image(a131ac04d927795).(sg_imagecxx . . $ sg_image# img_id);
1895 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_fail_shadercxx . . $ sg_fail_shader(c05267500f0c2b7f).(sg_shadercxx . . $ sg_shader# shd_id);
1896 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_fail_pipelinecxx . . $ sg_fail_pipeline(fa06e78c216ede9c).(sg_pipelinecxx . . $ sg_pipeline# pip_id);
1897 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_fail_passcxx . . $ sg_fail_pass(f6b4b2e9b04024b9).(sg_passcxx . . $ sg_pass# pass_id);
1898
1899 /* get internal resource attributes */
1900 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_buffer_infocxx . . $ sg_buffer_info# sg_query_buffer_infocxx . . $ sg_query_buffer_info(58b40c5336b41636).(sg_buffercxx . . $ sg_buffer# buf);
1901 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_image_infocxx . . $ sg_image_info# sg_query_image_infocxx . . $ sg_query_image_info(1621fed3a807c2b5).(sg_imagecxx . . $ sg_image# img);
1902 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! sg_shader_infocxx . . $ sg_shader_info# sg_query_shader_infocxx . . $ sg_query_shader_info(ec2feb25917f4482).(sg_shadercxx . . $ sg_shader# shd);
1903 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_pipeline_infocxx . . $ sg_pipeline_info# sg_query_pipeline_infocxx . . $ sg_query_pipeline_info(9302be6d1d2cb8fd).(sg_pipelinecxx . . $ sg_pipeline# pip);
1904 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_pass_infocxx . . $ sg_pass_info# sg_query_pass_infocxx . . $ sg_query_pass_info(cff05293a9a499e0).(sg_passcxx . . $ sg_pass# pass);
1905
1906 /* rendering contexts (optional) */
1907 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! sg_contextcxx . . $ sg_context# sg_setup_contextcxx . . $ sg_setup_context(ac4049b755bec9ae).(void);
1908 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_activate_contextcxx . . $ sg_activate_context(2d55baf387590aaf).(sg_contextcxx . . $ sg_context# ctx_id);
1909 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_gfx.h:495:9`! void sg_discard_contextcxx . . $ sg_discard_context(2d55baf387590aaf).(sg_contextcxx . . $ sg_context# ctx_id);
1910
1911 /* deprecated structs and functions */
1912 #ifndef SOKOL_NO_DEPRECATED
1913 typedef struct sg_draw_statecxx . . $ sg_draw_state# {
1914 uint32_tcxx . . $ uint32_t# _start_canarycxx . . $ sg_draw_state#_start_canary.;
1915 sg_pipelinecxx . . $ sg_pipeline# pipelinecxx . . $ sg_draw_state#pipeline.;
1916 sg_buffercxx . . $ sg_buffer# vertex_bufferscxx . . $ sg_draw_state#vertex_buffers.[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
1917 int vertex_buffer_offsetscxx . . $ sg_draw_state#vertex_buffer_offsets.[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
1918 sg_buffercxx . . $ sg_buffer# index_buffercxx . . $ sg_draw_state#index_buffer.;
1919 int index_buffer_offsetcxx . . $ sg_draw_state#index_buffer_offset.;
1920 sg_imagecxx . . $ sg_image# vs_imagescxx . . $ sg_draw_state#vs_images.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
1921 sg_imagecxx . . $ sg_image# fs_imagescxx . . $ sg_draw_state#fs_images.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
1922 uint32_tcxx . . $ uint32_t# _end_canarycxx . . $ sg_draw_state#_end_canary.;
1923 } sg_draw_statecxx . . $ sg_draw_state#;
1924 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_apply_draw_statecxx . . $ sg_apply_draw_state(d845a81d684dde96).(const sg_draw_statecxx . . $ sg_draw_state#* ds);
1925 SOKOL_API_DECLcxx . . $ `demo/sokol/sokol_app.h:405:9`! void sg_apply_uniform_blockcxx . . $ sg_apply_uniform_block(d4a2e1eb7e556ec4).(sg_shader_stagecxx . . $ sg_shader_stage# stage, int ub_index, const void* data, int num_bytes);
1926 #endif
1927
1928 #ifdef _MSC_VER
1929 #pragma warning(pop)
1930 #endif
1931 #ifdef __cplusplus
1932 } /* extern "C" */
1933 #endif
1934
1935 /*--- IMPLEMENTATION ---------------------------------------------------------*/
1936 #ifdef SOKOL_IMPLcxx . . $ `demo/sokol/sokol.c:1:9`!
1937 #define SOKOL_GFX_IMPL_INCLUDEDcxx . . $ `demo/sokol/sokol_gfx.h:1937:9`! (1)
1938
1939 #if !(defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!)||defined(SOKOL_GLES2)||defined(SOKOL_GLES3)||defined(SOKOL_D3D11)||defined(SOKOL_METAL)||defined(SOKOL_DUMMY_BACKEND))
1940 #error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL or SOKOL_DUMMY_BACKEND"
1941 #endif
1942 #include <string.h> /* memset */
1943 #include <float.h> /* FLT_MAX */
1944
1945 #ifndef SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`!
1946 #define SOKOL_API_IMPL
1947 #endif
1948 #ifndef SOKOL_DEBUG
1949 #ifndef NDEBUGcxx . . $ `<built-in>:414:9`!
1950 #define SOKOL_DEBUG (1)
1951 #endif
1952 #endif
1953 #ifndef SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!
1954 #include <assert.h>
1955 #define SOKOL_ASSERT(c) assert(c)
1956 #endif
1957 #ifndef SOKOL_VALIDATE_BEGIN
1958 #define SOKOL_VALIDATE_BEGINcxx . . $ `demo/sokol/sokol_gfx.h:1958:13`!() _sg_validate_begin()
1959 #endif
1960 #ifndef SOKOL_VALIDATE
1961 #define SOKOL_VALIDATEcxx . . $ `demo/sokol/sokol_gfx.h:1961:13`!(cond, err) _sg_validate((cond), err)
1962 #endif
1963 #ifndef SOKOL_VALIDATE_END
1964 #define SOKOL_VALIDATE_ENDcxx . . $ `demo/sokol/sokol_gfx.h:1964:13`!() _sg_validate_end()
1965 #endif
1966 #ifndef SOKOL_UNREACHABLE
1967 #define SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`! SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!)
1968 #endif
1969 #ifndef SOKOL_MALLOC
1970 #include <stdlib.h>
1971 #define SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(s) malloc(s)
1972 #define SOKOL_FREEcxx . . $ `demo/sokol/sokol_gfx.h:1972:13`!(p) free(p)
1973 #endif
1974 #ifndef SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!
1975 #ifdef SOKOL_DEBUG
1976 #include <stdio.h>
1977 #define SOKOL_LOG(s) { SOKOL_ASSERT(s); puts(s); }
1978 #else
1979 #define SOKOL_LOG(s)
1980 #endif
1981 #endif
1982
1983 #ifndef _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`!
1984 #if defined(__GNUC__)
1985 #define _SOKOL_PRIVATE __attribute__((unused)) static
1986 #else
1987 #define _SOKOL_PRIVATE static
1988 #endif
1989 #endif
1990
1991 #ifndef _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!
1992 #define _SOKOL_UNUSED(x) (void)(x)
1993 #endif
1994
1995 #if defined(SOKOL_TRACE_HOOKS)
1996 #define _SG_TRACE_ARGS(fn, ...) if (_sg.hooks.fn) { _sg.hooks.fn(__VA_ARGS__, _sg.hooks.user_data); }
1997 #define _SG_TRACE_NOARGS(fn) if (_sg.hooks.fn) { _sg.hooks.fn(_sg.hooks.user_data); }
1998 #else
1999 #define _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(fn, ...)
2000 #define _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(fn)
2001 #endif
2002
2003 /* default clear values */
2004 #ifndef SG_DEFAULT_CLEAR_RED
2005 #define SG_DEFAULT_CLEAR_REDcxx . . $ `demo/sokol/sokol_gfx.h:2005:9`! (0.5f)
2006 #endif
2007 #ifndef SG_DEFAULT_CLEAR_GREEN
2008 #define SG_DEFAULT_CLEAR_GREENcxx . . $ `demo/sokol/sokol_gfx.h:2008:9`! (0.5f)
2009 #endif
2010 #ifndef SG_DEFAULT_CLEAR_BLUE
2011 #define SG_DEFAULT_CLEAR_BLUEcxx . . $ `demo/sokol/sokol_gfx.h:2011:9`! (0.5f)
2012 #endif
2013 #ifndef SG_DEFAULT_CLEAR_ALPHA
2014 #define SG_DEFAULT_CLEAR_ALPHAcxx . . $ `demo/sokol/sokol_gfx.h:2014:9`! (1.0f)
2015 #endif
2016 #ifndef SG_DEFAULT_CLEAR_DEPTH
2017 #define SG_DEFAULT_CLEAR_DEPTHcxx . . $ `demo/sokol/sokol_gfx.h:2017:9`! (1.0f)
2018 #endif
2019 #ifndef SG_DEFAULT_CLEAR_STENCIL
2020 #define SG_DEFAULT_CLEAR_STENCILcxx . . $ `demo/sokol/sokol_gfx.h:2020:9`! (0)
2021 #endif
2022
2023 #if defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
2024 #ifndef GL_UNSIGNED_INT_2_10_10_10_REVcxx . . $ `<external>/11565930711847777359/gl.h:1463:9`!
2025 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
2026 #endif
2027 #ifndef GL_UNSIGNED_INT_24_8cxx . . $ `<external>/13868558256673015710/glext.h:982:9`!
2028 #define GL_UNSIGNED_INT_24_8 0x84FA
2029 #endif
2030 #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8442:9`!
2031 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
2032 #endif
2033 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8443:9`!
2034 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
2035 #endif
2036 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8384:9`!
2037 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
2038 #endif
2039 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8385:9`!
2040 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
2041 #endif
2042 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8386:9`!
2043 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
2044 #endif
2045 #ifndef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
2046 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2046:13`! 0x8C01
2047 #endif
2048 #ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
2049 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2049:13`! 0x8C00
2050 #endif
2051 #ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
2052 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2052:13`! 0x8C03
2053 #endif
2054 #ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
2055 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2055:13`! 0x8C02
2056 #endif
2057 #ifndef GL_COMPRESSED_RGB8_ETC2cxx . . $ `<external>/13868558256673015710/glext.h:2153:9`!
2058 #define GL_COMPRESSED_RGB8_ETC2 0x9274
2059 #endif
2060 #ifndef GL_COMPRESSED_SRGB8_ETC2cxx . . $ `<external>/13868558256673015710/glext.h:2154:9`!
2061 #define GL_COMPRESSED_SRGB8_ETC2 0x9275
2062 #endif
2063 #ifndef GL_DEPTH24_STENCIL8cxx . . $ `<external>/13868558256673015710/glext.h:983:9`!
2064 #define GL_DEPTH24_STENCIL8 0x88F0
2065 #endif
2066 #ifndef GL_HALF_FLOATcxx . . $ `<external>/13868558256673015710/glext.h:1065:9`!
2067 #define GL_HALF_FLOAT 0x140B
2068 #endif
2069 #ifndef GL_DEPTH_STENCILcxx . . $ `<external>/13868558256673015710/glext.h:981:9`!
2070 #define GL_DEPTH_STENCIL 0x84F9
2071 #endif
2072 #ifndef GL_LUMINANCEcxx . . $ `<external>/11565930711847777359/gl.h:450:9`!
2073 #define GL_LUMINANCE 0x1909
2074 #endif
2075 #ifdef SOKOL_GLES2
2076 # ifdef GL_ANGLE_instanced_arrays
2077 # define SOKOL_INSTANCING_ENABLED
2078 # define glDrawArraysInstanced(mode, first, count, instancecount) glDrawArraysInstancedANGLE(mode, first, count, instancecount)
2079 # define glDrawElementsInstanced(mode, count, type, indices, instancecount) glDrawElementsInstancedANGLE(mode, count, type, indices, instancecount)
2080 # define glVertexAttribDivisor(index, divisor) glVertexAttribDivisorANGLE(index, divisor)
2081 # elif defined(GL_EXT_draw_instanced) && defined(GL_EXT_instanced_arrays)
2082 # define SOKOL_INSTANCING_ENABLED
2083 # define glDrawArraysInstanced(mode, first, count, instancecount) glDrawArraysInstancedEXT(mode, first, count, instancecount)
2084 # define glDrawElementsInstanced(mode, count, type, indices, instancecount) glDrawElementsInstancedEXT(mode, count, type, indices, instancecount)
2085 # define glVertexAttribDivisor(index, divisor) glVertexAttribDivisorEXT(index, divisor)
2086 # else
2087 # define SOKOL_GLES2_INSTANCING_ERROR "Select GL_ANGLE_instanced_arrays or (GL_EXT_draw_instanced & GL_EXT_instanced_arrays) to enable instancing in GLES2"
2088 # define glDrawArraysInstanced(mode, first, count, instancecount) SOKOL_ASSERT(0 && SOKOL_GLES2_INSTANCING_ERROR)
2089 # define glDrawElementsInstanced(mode, count, type, indices, instancecount) SOKOL_ASSERT(0 && SOKOL_GLES2_INSTANCING_ERROR)
2090 # define glVertexAttribDivisor(index, divisor) SOKOL_ASSERT(0 && SOKOL_GLES2_INSTANCING_ERROR)
2091 # endif
2092 #else
2093 # define SOKOL_INSTANCING_ENABLEDcxx . . $ `demo/sokol/sokol_gfx.h:2093:16`!
2094 #endif
2095 #define _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!() { SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(glGetError() == GL_NO_ERRORcxx . . $ `<external>/11565930711847777359/gl.h:659:9`!); }
2096
2097 #elif defined(SOKOL_D3D11)
2098 #ifndef D3D11_NO_HELPERS
2099 #define D3D11_NO_HELPERS
2100 #endif
2101 #ifndef CINTERFACE
2102 #define CINTERFACE
2103 #endif
2104 #ifndef COBJMACROS
2105 #define COBJMACROS
2106 #endif
2107 #ifndef WIN32_LEAN_AND_MEAN
2108 #define WIN32_LEAN_AND_MEAN
2109 #endif
2110 #include <windows.h>
2111 #include <d3d11.h>
2112 #include <d3dcompiler.h>
2113 #if (defined(WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
2114 #pragma comment (lib, "WindowsApp.lib")
2115 #else
2116 #pragma comment (lib, "user32.lib")
2117 #pragma comment (lib, "dxgi.lib")
2118 #pragma comment (lib, "d3d11.lib")
2119 #pragma comment (lib, "dxguid.lib")
2120 #endif
2121 #elif defined(SOKOL_METAL)
2122 #if !__has_feature(objc_arc)
2123 #error "Please enable ARC when using the Metal backend"
2124 #endif
2125 #include <TargetConditionals.h>
2126 #import <Metal/Metal.h>
2127 #endif
2128
2129 #ifdef _MSC_VER
2130 #pragma warning(push)
2131 #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */
2132 #pragma warning(disable:4115) /* named type definition in parentheses */
2133 #pragma warning(disable:4505) /* unreferenced local function has been removed */
2134 #endif
2135
2136 /*=== PRIVATE DECLS ==========================================================*/
2137
2138 /* resource pool slots */
2139 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_3# {
2140 uint32_tcxx . . $ uint32_t# idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
2141 uint32_tcxx . . $ uint32_t# ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id.;
2142 sg_resource_statecxx . . $ sg_resource_state# statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
2143 } _sg_slot_tcxx . . $ _sg_slot_t#;
2144
2145 /* constants */
2146 enumcxx . . $ $anonymous_type_ded6a5455d648ef8_4# {
2147 _SG_STRING_SIZEcxx . . $ _SG_STRING_SIZE. = 16,
2148 _SG_SLOT_SHIFTcxx . . $ _SG_SLOT_SHIFT. = 16,
2149 _SG_SLOT_MASKcxx . . $ _SG_SLOT_MASK. = (1<<_SG_SLOT_SHIFTcxx . . $ _SG_SLOT_SHIFT.)-1,
2150 _SG_MAX_POOL_SIZEcxx . . $ _SG_MAX_POOL_SIZE. = (1<<_SG_SLOT_SHIFTcxx . . $ _SG_SLOT_SHIFT.),
2151 _SG_DEFAULT_BUFFER_POOL_SIZEcxx . . $ _SG_DEFAULT_BUFFER_POOL_SIZE. = 128,
2152 _SG_DEFAULT_IMAGE_POOL_SIZEcxx . . $ _SG_DEFAULT_IMAGE_POOL_SIZE. = 128,
2153 _SG_DEFAULT_SHADER_POOL_SIZEcxx . . $ _SG_DEFAULT_SHADER_POOL_SIZE. = 32,
2154 _SG_DEFAULT_PIPELINE_POOL_SIZEcxx . . $ _SG_DEFAULT_PIPELINE_POOL_SIZE. = 64,
2155 _SG_DEFAULT_PASS_POOL_SIZEcxx . . $ _SG_DEFAULT_PASS_POOL_SIZE. = 16,
2156 _SG_DEFAULT_CONTEXT_POOL_SIZEcxx . . $ _SG_DEFAULT_CONTEXT_POOL_SIZE. = 16,
2157 _SG_MTL_DEFAULT_UB_SIZEcxx . . $ _SG_MTL_DEFAULT_UB_SIZE. = 4 * 1024 * 1024,
2158 _SG_MTL_DEFAULT_SAMPLER_CACHE_CAPACITYcxx . . $ _SG_MTL_DEFAULT_SAMPLER_CACHE_CAPACITY. = 64,
2159 };
2160
2161 /* fixed-size string */
2162 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_5# {
2163 char bufcxx . . $ $anonymous_type_ded6a5455d648ef8_5#buf.[_SG_STRING_SIZEcxx . . $ _SG_STRING_SIZE.];
2164 } _sg_str_tcxx . . $ _sg_str_t#;
2165
2166 /* helper macros */
2167 #define _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(val, def) (((val) == 0) ? (def) : (val))
2168 #define _sg_def_fltcxx . . $ `demo/sokol/sokol_gfx.h:2168:9`!(val, def) (((val) == 0.0f) ? (def) : (val))
2169 #define _sg_mincxx . . $ `demo/sokol/sokol_gfx.h:2169:9`!(a,b) ((a<b)?a:b)
2170 #define _sg_maxcxx . . $ `demo/sokol/sokol_gfx.h:2170:9`!(a,b) ((a>b)?a:b)
2171 #define _sg_clampcxx . . $ `demo/sokol/sokol_gfx.h:2171:9`!(v,v0,v1) ((v<v0)?(v0):((v>v1)?(v1):(v)))
2172 #define _sg_fequalcxx . . $ `demo/sokol/sokol_gfx.h:2172:9`!(val,cmp,delta) (((val-cmp)> -delta)&&((val-cmp)<delta))
2173
2174 /*=== DUMMY BACKEND DECLARATIONS =============================================*/
2175 #if defined(SOKOL_DUMMY_BACKEND)
2176 typedef struct {
2177 _sg_slot_t slot;
2178 int size;
2179 int append_pos;
2180 bool append_overflow;
2181 sg_buffer_type type;
2182 sg_usage usage;
2183 uint32_t update_frame_index;
2184 uint32_t append_frame_index;
2185 int num_slots;
2186 int active_slot;
2187 } _sg_buffer_t;
2188
2189 typedef struct {
2190 _sg_slot_t slot;
2191 sg_image_type type;
2192 bool render_target;
2193 int width;
2194 int height;
2195 int depth;
2196 int num_mipmaps;
2197 sg_usage usage;
2198 sg_pixel_format pixel_format;
2199 int sample_count;
2200 sg_filter min_filter;
2201 sg_filter mag_filter;
2202 sg_wrap wrap_u;
2203 sg_wrap wrap_v;
2204 sg_wrap wrap_w;
2205 uint32_t max_anisotropy;
2206 uint32_t upd_frame_index;
2207 int num_slots;
2208 int active_slot;
2209 } _sg_image_t;
2210
2211 typedef struct {
2212 int size;
2213 } _sg_uniform_block_t;
2214
2215 typedef struct {
2216 sg_image_type type;
2217 } _sg_shader_image_t;
2218
2219 typedef struct {
2220 int num_uniform_blocks;
2221 int num_images;
2222 _sg_uniform_block_t uniform_blocks[SG_MAX_SHADERSTAGE_UBS];
2223 _sg_shader_image_t images[SG_MAX_SHADERSTAGE_IMAGES];
2224 } _sg_shader_stage_t;
2225
2226 typedef struct {
2227 _sg_slot_t slot;
2228 _sg_shader_stage_t stage[SG_NUM_SHADER_STAGES];
2229 } _sg_shader_t;
2230
2231 typedef struct {
2232 _sg_slot_t slot;
2233 _sg_shader_t* shader;
2234 sg_shader shader_id;
2235 bool vertex_layout_valid[SG_MAX_SHADERSTAGE_BUFFERS];
2236 int color_attachment_count;
2237 sg_pixel_format color_format;
2238 sg_pixel_format depth_format;
2239 int sample_count;
2240 float depth_bias;
2241 float depth_bias_slope_scale;
2242 float depth_bias_clamp;
2243 sg_index_type index_type;
2244 float blend_color[4];
2245 } _sg_pipeline_t;
2246
2247 typedef struct {
2248 _sg_image_t* image;
2249 sg_image image_id;
2250 int mip_level;
2251 int slice;
2252 } _sg_attachment_t;
2253
2254 typedef struct {
2255 _sg_slot_t slot;
2256 int num_color_atts;
2257 _sg_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS];
2258 _sg_attachment_t ds_att;
2259 } _sg_pass_t;
2260
2261 typedef struct {
2262 _sg_slot_t slot;
2263 } _sg_context_t;
2264
2265 /*== GL BACKEND DECLARATIONS =================================================*/
2266 #elif defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
2267 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_6# {
2268 _sg_slot_tcxx . . $ _sg_slot_t# slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot.;
2269 int sizecxx . . $ $anonymous_type_ded6a5455d648ef8_6#size.;
2270 int append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos.;
2271 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow.;
2272 sg_buffer_typecxx . . $ sg_buffer_type# typecxx . . $ $anonymous_type_ded6a5455d648ef8_6#type.;
2273 sg_usagecxx . . $ sg_usage# usagecxx . . $ $anonymous_type_ded6a5455d648ef8_6#usage.;
2274 uint32_tcxx . . $ uint32_t# update_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#update_frame_index.;
2275 uint32_tcxx . . $ uint32_t# append_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_frame_index.;
2276 int num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots.;
2277 int active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot.;
2278 GLuintcxx . . $ GLuint# gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.];
2279 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! ext_bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_6#ext_buffers.; /* if true, external buffers were injected with sg_buffer_desc.gl_buffers */
2280 } _sg_buffer_tcxx . . $ _sg_buffer_t#;
2281
2282 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_7# {
2283 _sg_slot_tcxx . . $ _sg_slot_t# slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot.;
2284 sg_image_typecxx . . $ sg_image_type# typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.;
2285 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! render_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#render_target.;
2286 int widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width.;
2287 int heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height.;
2288 int depthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#depth.;
2289 int num_mipmapscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_mipmaps.;
2290 sg_usagecxx . . $ sg_usage# usagecxx . . $ $anonymous_type_ded6a5455d648ef8_7#usage.;
2291 sg_pixel_formatcxx . . $ sg_pixel_format# pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.;
2292 int sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_7#sample_count.;
2293 sg_filtercxx . . $ sg_filter# min_filtercxx . . $ $anonymous_type_ded6a5455d648ef8_7#min_filter.;
2294 sg_filtercxx . . $ sg_filter# mag_filtercxx . . $ $anonymous_type_ded6a5455d648ef8_7#mag_filter.;
2295 sg_wrapcxx . . $ sg_wrap# wrap_ucxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_u.;
2296 sg_wrapcxx . . $ sg_wrap# wrap_vcxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_v.;
2297 sg_wrapcxx . . $ sg_wrap# wrap_wcxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_w.;
2298 uint32_tcxx . . $ uint32_t# max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_7#max_anisotropy.;
2299 GLenumcxx . . $ GLenum# gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target.;
2300 GLuintcxx . . $ GLuint# gl_depth_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_depth_render_buffer.;
2301 GLuintcxx . . $ GLuint# gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.;
2302 uint32_tcxx . . $ uint32_t# upd_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_7#upd_frame_index.;
2303 int num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots.;
2304 int active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot.;
2305 GLuintcxx . . $ GLuint# gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.];
2306 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! ext_texturescxx . . $ $anonymous_type_ded6a5455d648ef8_7#ext_textures.; /* if true, external textures were injected with sg_image_desc.gl_textures */
2307 } _sg_image_tcxx . . $ _sg_image_t#;
2308
2309 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_8# {
2310 GLintcxx . . $ GLint# gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc.;
2311 sg_uniform_typecxx . . $ sg_uniform_type# typecxx . . $ $anonymous_type_ded6a5455d648ef8_8#type.;
2312 uint8_tcxx . . $ uint8_t# countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count.;
2313 uint16_tcxx . . $ uint16_t# offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_8#offset.;
2314 } _sg_uniform_tcxx . . $ _sg_uniform_t#;
2315
2316 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_9# {
2317 int sizecxx . . $ $anonymous_type_ded6a5455d648ef8_9#size.;
2318 int num_uniformscxx . . $ $anonymous_type_ded6a5455d648ef8_9#num_uniforms.;
2319 _sg_uniform_tcxx . . $ _sg_uniform_t# uniformscxx . . $ $anonymous_type_ded6a5455d648ef8_9#uniforms.[SG_MAX_UB_MEMBERScxx . . $ SG_MAX_UB_MEMBERS.];
2320 } _sg_uniform_block_tcxx . . $ _sg_uniform_block_t#;
2321
2322 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_10# {
2323 sg_image_typecxx . . $ sg_image_type# typecxx . . $ $anonymous_type_ded6a5455d648ef8_10#type.;
2324 GLintcxx . . $ GLint# gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_loc.;
2325 int gl_tex_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_tex_slot.;
2326 } _sg_shader_image_tcxx . . $ _sg_shader_image_t#;
2327
2328 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_11# {
2329 _sg_str_tcxx . . $ _sg_str_t# namecxx . . $ $anonymous_type_ded6a5455d648ef8_11#name.;
2330 } _sg_shader_attr_tcxx . . $ _sg_shader_attr_t#;
2331
2332 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_12# {
2333 int num_uniform_blockscxx . . $ $anonymous_type_ded6a5455d648ef8_12#num_uniform_blocks.;
2334 int num_imagescxx . . $ $anonymous_type_ded6a5455d648ef8_12#num_images.;
2335 _sg_uniform_block_tcxx . . $ _sg_uniform_block_t# uniform_blockscxx . . $ $anonymous_type_ded6a5455d648ef8_12#uniform_blocks.[SG_MAX_SHADERSTAGE_UBScxx . . $ SG_MAX_SHADERSTAGE_UBS.];
2336 _sg_shader_image_tcxx . . $ _sg_shader_image_t# imagescxx . . $ $anonymous_type_ded6a5455d648ef8_12#images.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
2337 } _sg_shader_stage_tcxx . . $ _sg_shader_stage_t#;
2338
2339 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_13# {
2340 _sg_slot_tcxx . . $ _sg_slot_t# slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot.;
2341 GLuintcxx . . $ GLuint# gl_progcxx . . $ $anonymous_type_ded6a5455d648ef8_13#gl_prog.;
2342 _sg_shader_attr_tcxx . . $ _sg_shader_attr_t# attrscxx . . $ $anonymous_type_ded6a5455d648ef8_13#attrs.[SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.];
2343 _sg_shader_stage_tcxx . . $ _sg_shader_stage_t# stagecxx . . $ $anonymous_type_ded6a5455d648ef8_13#stage.[SG_NUM_SHADER_STAGEScxx . . $ SG_NUM_SHADER_STAGES.];
2344 } _sg_shader_tcxx . . $ _sg_shader_t#;
2345
2346 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_14# {
2347 int8_tcxx . . $ int8_t# vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index.; /* -1 if attr is not enabled */
2348 int8_tcxx . . $ int8_t# divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor.; /* -1 if not initialized */
2349 uint8_tcxx . . $ uint8_t# stridecxx . . $ $anonymous_type_ded6a5455d648ef8_14#stride.;
2350 uint8_tcxx . . $ uint8_t# sizecxx . . $ $anonymous_type_ded6a5455d648ef8_14#size.;
2351 uint8_tcxx . . $ uint8_t# normalizedcxx . . $ $anonymous_type_ded6a5455d648ef8_14#normalized.;
2352 int offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_14#offset.;
2353 GLenumcxx . . $ GLenum# typecxx . . $ $anonymous_type_ded6a5455d648ef8_14#type.;
2354 } _sg_gl_attr_tcxx . . $ _sg_gl_attr_t#;
2355
2356 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_15# {
2357 _sg_slot_tcxx . . $ _sg_slot_t# slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot.;
2358 _sg_shader_tcxx . . $ _sg_shader_t#* shadercxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader.;
2359 sg_shadercxx . . $ sg_shader# shader_idcxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader_id.;
2360 sg_primitive_typecxx . . $ sg_primitive_type# primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_15#primitive_type.;
2361 sg_index_typecxx . . $ sg_index_type# index_typecxx . . $ $anonymous_type_ded6a5455d648ef8_15#index_type.;
2362 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! vertex_layout_validcxx . . $ $anonymous_type_ded6a5455d648ef8_15#vertex_layout_valid.[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
2363 int color_attachment_countcxx . . $ $anonymous_type_ded6a5455d648ef8_15#color_attachment_count.;
2364 sg_pixel_formatcxx . . $ sg_pixel_format# color_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_15#color_format.;
2365 sg_pixel_formatcxx . . $ sg_pixel_format# depth_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_15#depth_format.;
2366 int sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_15#sample_count.;
2367 _sg_gl_attr_tcxx . . $ _sg_gl_attr_t# gl_attrscxx . . $ $anonymous_type_ded6a5455d648ef8_15#gl_attrs.[SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.];
2368 sg_depth_stencil_statecxx . . $ sg_depth_stencil_state# depth_stencilcxx . . $ $anonymous_type_ded6a5455d648ef8_15#depth_stencil.;
2369 sg_blend_statecxx . . $ sg_blend_state# blendcxx . . $ $anonymous_type_ded6a5455d648ef8_15#blend.;
2370 sg_rasterizer_statecxx . . $ sg_rasterizer_state# rastcxx . . $ $anonymous_type_ded6a5455d648ef8_15#rast.;
2371 } _sg_pipeline_tcxx . . $ _sg_pipeline_t#;
2372
2373 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_16# {
2374 _sg_image_tcxx . . $ _sg_image_t#* imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.;
2375 sg_imagecxx . . $ sg_image# image_idcxx . . $ $anonymous_type_ded6a5455d648ef8_16#image_id.;
2376 int mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level.;
2377 int slicecxx . . $ $anonymous_type_ded6a5455d648ef8_16#slice.;
2378 GLuintcxx . . $ GLuint# gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.;
2379 } _sg_attachment_tcxx . . $ _sg_attachment_t#;
2380
2381 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_17# {
2382 _sg_slot_tcxx . . $ _sg_slot_t# slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot.;
2383 GLuintcxx . . $ GLuint# gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.;
2384 int num_color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#num_color_atts.;
2385 _sg_attachment_tcxx . . $ _sg_attachment_t# color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.];
2386 _sg_attachment_tcxx . . $ _sg_attachment_t# ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att.;
2387 } _sg_pass_tcxx . . $ _sg_pass_t#;
2388
2389 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_18# {
2390 _sg_slot_tcxx . . $ _sg_slot_t# slotcxx . . $ $anonymous_type_ded6a5455d648ef8_18#slot.;
2391 #if !defined(SOKOL_GLES2)
2392 GLuintcxx . . $ GLuint# vaocxx . . $ $anonymous_type_ded6a5455d648ef8_18#vao.;
2393 #endif
2394 GLuintcxx . . $ GLuint# default_framebuffercxx . . $ $anonymous_type_ded6a5455d648ef8_18#default_framebuffer.;
2395 } _sg_context_tcxx . . $ _sg_context_t#;
2396
2397 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_19# {
2398 _sg_gl_attr_tcxx . . $ _sg_gl_attr_t# gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr.;
2399 GLuintcxx . . $ GLuint# gl_vbufcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_vbuf.;
2400 } _sg_gl_cache_attr_tcxx . . $ _sg_gl_cache_attr_t#;
2401
2402 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_20# {
2403 GLenumcxx . . $ GLenum# targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target.;
2404 GLuintcxx . . $ GLuint# texturecxx . . $ $anonymous_type_ded6a5455d648ef8_20#texture.;
2405 } _sg_gl_texture_bind_slotcxx . . $ _sg_gl_texture_bind_slot#;
2406
2407 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_21# {
2408 sg_depth_stencil_statecxx . . $ sg_depth_stencil_state# dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds.;
2409 sg_blend_statecxx . . $ sg_blend_state# blendcxx . . $ $anonymous_type_ded6a5455d648ef8_21#blend.;
2410 sg_rasterizer_statecxx . . $ sg_rasterizer_state# rastcxx . . $ $anonymous_type_ded6a5455d648ef8_21#rast.;
2411 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! polygon_offset_enabledcxx . . $ $anonymous_type_ded6a5455d648ef8_21#polygon_offset_enabled.;
2412 _sg_gl_cache_attr_tcxx . . $ _sg_gl_cache_attr_t# attrscxx . . $ $anonymous_type_ded6a5455d648ef8_21#attrs.[SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.];
2413 GLuintcxx . . $ GLuint# vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#vertex_buffer.;
2414 GLuintcxx . . $ GLuint# index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#index_buffer.;
2415 GLuintcxx . . $ GLuint# stored_vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_vertex_buffer.;
2416 GLuintcxx . . $ GLuint# stored_index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_index_buffer.;
2417 _sg_gl_texture_bind_slotcxx . . $ _sg_gl_texture_bind_slot# texturescxx . . $ $anonymous_type_ded6a5455d648ef8_21#textures.[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.];
2418 _sg_gl_texture_bind_slotcxx . . $ _sg_gl_texture_bind_slot# stored_texturecxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_texture.;
2419 int cur_ib_offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_ib_offset.;
2420 GLenumcxx . . $ GLenum# cur_primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_primitive_type.;
2421 GLenumcxx . . $ GLenum# cur_index_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_index_type.;
2422 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline.;
2423 sg_pipelinecxx . . $ sg_pipeline# cur_pipeline_idcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline_id.;
2424 } _sg_gl_state_cache_tcxx . . $ _sg_gl_state_cache_t#;
2425
2426 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_22# {
2427 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! validcxx . . $ $anonymous_type_ded6a5455d648ef8_22#valid.;
2428 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.;
2429 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! in_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#in_pass.;
2430 int cur_pass_widthcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_width.;
2431 int cur_pass_heightcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_height.;
2432 _sg_context_tcxx . . $ _sg_context_t#* cur_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_context.;
2433 _sg_pass_tcxx . . $ _sg_pass_t#* cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass.;
2434 sg_passcxx . . $ sg_pass# cur_pass_idcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_id.;
2435 _sg_gl_state_cache_tcxx . . $ _sg_gl_state_cache_t# cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache.;
2436 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_NUM_FEATUREScxx . . $ SG_NUM_FEATURES.];
2437 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! ext_anisotropiccxx . . $ $anonymous_type_ded6a5455d648ef8_22#ext_anisotropic.;
2438 GLintcxx . . $ GLint# max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_anisotropy.;
2439 GLintcxx . . $ GLint# max_combined_texture_image_unitscxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_combined_texture_image_units.;
2440 } _sg_gl_backend_tcxx . . $ _sg_gl_backend_t#;
2441
2442 /*== D3D11 BACKEND DECLARATIONS ==============================================*/
2443 #elif defined(SOKOL_D3D11)
2444
2445 typedef struct {
2446 _sg_slot_t slot;
2447 int size;
2448 int append_pos;
2449 bool append_overflow;
2450 sg_buffer_type type;
2451 sg_usage usage;
2452 uint32_t update_frame_index;
2453 uint32_t append_frame_index;
2454 ID3D11Buffer* d3d11_buf;
2455 } _sg_buffer_t;
2456
2457 typedef struct {
2458 _sg_slot_t slot;
2459 sg_image_type type;
2460 bool render_target;
2461 int width;
2462 int height;
2463 int depth;
2464 int num_mipmaps;
2465 sg_usage usage;
2466 sg_pixel_format pixel_format;
2467 int sample_count;
2468 sg_filter min_filter;
2469 sg_filter mag_filter;
2470 sg_wrap wrap_u;
2471 sg_wrap wrap_v;
2472 sg_wrap wrap_w;
2473 uint32_t max_anisotropy;
2474 uint32_t upd_frame_index;
2475 DXGI_FORMAT d3d11_format;
2476 ID3D11Texture2D* d3d11_tex2d;
2477 ID3D11Texture3D* d3d11_tex3d;
2478 ID3D11Texture2D* d3d11_texds;
2479 ID3D11Texture2D* d3d11_texmsaa;
2480 ID3D11ShaderResourceView* d3d11_srv;
2481 ID3D11SamplerState* d3d11_smp;
2482 } _sg_image_t;
2483
2484 typedef struct {
2485 int size;
2486 } _sg_uniform_block_t;
2487
2488 typedef struct {
2489 sg_image_type type;
2490 } _sg_shader_image_t;
2491
2492 typedef struct {
2493 _sg_str_t sem_name;
2494 int sem_index;
2495 } _sg_shader_attr_t;
2496
2497 typedef struct {
2498 int num_uniform_blocks;
2499 int num_images;
2500 _sg_shader_attr_t attrs[SG_MAX_VERTEX_ATTRIBUTES];
2501 _sg_uniform_block_t uniform_blocks[SG_MAX_SHADERSTAGE_UBS];
2502 _sg_shader_image_t images[SG_MAX_SHADERSTAGE_IMAGES];
2503 ID3D11Buffer* d3d11_cbs[SG_MAX_SHADERSTAGE_UBS];
2504 } _sg_shader_stage_t;
2505
2506 typedef struct {
2507 _sg_slot_t slot;
2508 _sg_shader_attr_t attrs[SG_MAX_VERTEX_ATTRIBUTES];
2509 _sg_shader_stage_t stage[SG_NUM_SHADER_STAGES];
2510 ID3D11VertexShader* d3d11_vs;
2511 ID3D11PixelShader* d3d11_fs;
2512 void* d3d11_vs_blob;
2513 int d3d11_vs_blob_length;
2514 } _sg_shader_t;
2515
2516 typedef struct {
2517 _sg_slot_t slot;
2518 _sg_shader_t* shader;
2519 sg_shader shader_id;
2520 sg_index_type index_type;
2521 bool vertex_layout_valid[SG_MAX_SHADERSTAGE_BUFFERS];
2522 int color_attachment_count;
2523 sg_pixel_format color_format;
2524 sg_pixel_format depth_format;
2525 int sample_count;
2526 float blend_color[4];
2527 UINT d3d11_stencil_ref;
2528 UINT d3d11_vb_strides[SG_MAX_SHADERSTAGE_BUFFERS];
2529 D3D_PRIMITIVE_TOPOLOGY d3d11_topology;
2530 DXGI_FORMAT d3d11_index_format;
2531 ID3D11InputLayout* d3d11_il;
2532 ID3D11RasterizerState* d3d11_rs;
2533 ID3D11DepthStencilState* d3d11_dss;
2534 ID3D11BlendState* d3d11_bs;
2535 } _sg_pipeline_t;
2536
2537 typedef struct {
2538 _sg_image_t* image;
2539 sg_image image_id;
2540 int mip_level;
2541 int slice;
2542 } _sg_attachment_t;
2543
2544 typedef struct {
2545 _sg_slot_t slot;
2546 int num_color_atts;
2547 _sg_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS];
2548 _sg_attachment_t ds_att;
2549 ID3D11RenderTargetView* d3d11_rtvs[SG_MAX_COLOR_ATTACHMENTS];
2550 ID3D11DepthStencilView* d3d11_dsv;
2551 } _sg_pass_t;
2552
2553 typedef struct {
2554 _sg_slot_t slot;
2555 } _sg_context_t;
2556
2557 typedef struct {
2558 bool valid;
2559 ID3D11Device* dev;
2560 ID3D11DeviceContext* ctx;
2561 const void* (*rtv_cb)(void);
2562 const void* (*dsv_cb)(void);
2563 bool in_pass;
2564 bool use_indexed_draw;
2565 int cur_width;
2566 int cur_height;
2567 int num_rtvs;
2568 _sg_pass_t* cur_pass;
2569 sg_pass cur_pass_id;
2570 _sg_pipeline_t* cur_pipeline;
2571 sg_pipeline cur_pipeline_id;
2572 ID3D11RenderTargetView* cur_rtvs[SG_MAX_COLOR_ATTACHMENTS];
2573 ID3D11DepthStencilView* cur_dsv;
2574 /* on-demand loaded d3dcompiler_47.dll handles */
2575 HINSTANCE d3dcompiler_dll;
2576 bool d3dcompiler_dll_load_failed;
2577 pD3DCompile D3DCompile_func;
2578 /* the following arrays are used for unbinding resources, they will always contain zeroes */
2579 ID3D11RenderTargetView* zero_rtvs[SG_MAX_COLOR_ATTACHMENTS];
2580 ID3D11Buffer* zero_vbs[SG_MAX_SHADERSTAGE_BUFFERS];
2581 UINT zero_vb_offsets[SG_MAX_SHADERSTAGE_BUFFERS];
2582 UINT zero_vb_strides[SG_MAX_SHADERSTAGE_BUFFERS];
2583 ID3D11Buffer* zero_cbs[SG_MAX_SHADERSTAGE_UBS];
2584 ID3D11ShaderResourceView* zero_srvs[SG_MAX_SHADERSTAGE_IMAGES];
2585 ID3D11SamplerState* zero_smps[SG_MAX_SHADERSTAGE_IMAGES];
2586 /* global subresourcedata array for texture updates */
2587 D3D11_SUBRESOURCE_DATA subres_data[SG_MAX_MIPMAPS * SG_MAX_TEXTUREARRAY_LAYERS];
2588 } _sg_d3d11_backend_t;
2589
2590 /*=== METAL BACKEND DECLARATIONS =============================================*/
2591 #elif defined(SOKOL_METAL)
2592
2593 enum {
2594 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
2595 _SG_MTL_UB_ALIGN = 256,
2596 #else
2597 _SG_MTL_UB_ALIGN = 16,
2598 #endif
2599 _SG_MTL_INVALID_SLOT_INDEX = 0
2600 };
2601
2602 /* note that there's a free-standing _sg_mtl_idpool NSMutableArray,
2603 this can't be part of a C struct before Xcode10.x
2604 */
2605 typedef struct {
2606 uint32_t frame_index; /* frame index at which it is safe to release this resource */
2607 uint32_t slot_index;
2608 } _sg_mtl_release_item_t;
2609
2610 typedef struct {
2611 uint32_t num_slots;
2612 uint32_t free_queue_top;
2613 uint32_t* free_queue;
2614 uint32_t release_queue_front;
2615 uint32_t release_queue_back;
2616 _sg_mtl_release_item_t* release_queue;
2617 } _sg_mtl_idpool_t;
2618
2619 /* Metal sampler cache */
2620 typedef struct {
2621 sg_filter min_filter;
2622 sg_filter mag_filter;
2623 sg_wrap wrap_u;
2624 sg_wrap wrap_v;
2625 sg_wrap wrap_w;
2626 uint32_t max_anisotropy;
2627 int min_lod; /* orig min/max_lod is float, this is int(min/max_lod*1000.0) */
2628 int max_lod;
2629 uint32_t mtl_sampler_state;
2630 } _sg_mtl_sampler_cache_item_t;
2631
2632 typedef struct {
2633 int capacity;
2634 int num_items;
2635 _sg_mtl_sampler_cache_item_t* items;
2636 } _sg_mtl_sampler_cache_t;
2637
2638 typedef struct {
2639 _sg_slot_t slot;
2640 int size;
2641 int append_pos;
2642 bool append_overflow;
2643 sg_buffer_type type;
2644 sg_usage usage;
2645 uint32_t update_frame_index;
2646 uint32_t append_frame_index;
2647 int num_slots;
2648 int active_slot;
2649 uint32_t mtl_buf[SG_NUM_INFLIGHT_FRAMES]; /* index intp _sg_mtl_pool */
2650 } _sg_buffer_t;
2651
2652 typedef struct {
2653 _sg_slot_t slot;
2654 sg_image_type type;
2655 bool render_target;
2656 int width;
2657 int height;
2658 int depth;
2659 int num_mipmaps;
2660 sg_usage usage;
2661 sg_pixel_format pixel_format;
2662 int sample_count;
2663 sg_filter min_filter;
2664 sg_filter mag_filter;
2665 sg_wrap wrap_u;
2666 sg_wrap wrap_v;
2667 sg_wrap wrap_w;
2668 uint32_t max_anisotropy;
2669 uint32_t upd_frame_index;
2670 int num_slots;
2671 int active_slot;
2672 uint32_t mtl_tex[SG_NUM_INFLIGHT_FRAMES];
2673 uint32_t mtl_depth_tex;
2674 uint32_t mtl_msaa_tex;
2675 uint32_t mtl_sampler_state;
2676 } _sg_image_t;
2677
2678 typedef struct {
2679 int size;
2680 } _sg_uniform_block_t;
2681
2682 typedef struct {
2683 sg_image_type type;
2684 } _sg_shader_image_t;
2685
2686 typedef struct {
2687 int num_uniform_blocks;
2688 int num_images;
2689 _sg_uniform_block_t uniform_blocks[SG_MAX_SHADERSTAGE_UBS];
2690 _sg_shader_image_t images[SG_MAX_SHADERSTAGE_IMAGES];
2691 uint32_t mtl_lib;
2692 uint32_t mtl_func;
2693 } _sg_shader_stage_t;
2694
2695 typedef struct {
2696 _sg_slot_t slot;
2697 _sg_shader_stage_t stage[SG_NUM_SHADER_STAGES];
2698 } _sg_shader_t;
2699
2700 typedef struct {
2701 _sg_slot_t slot;
2702 _sg_shader_t* shader;
2703 sg_shader shader_id;
2704 bool vertex_layout_valid[SG_MAX_SHADERSTAGE_BUFFERS];
2705 int color_attachment_count;
2706 sg_pixel_format color_format;
2707 sg_pixel_format depth_format;
2708 int sample_count;
2709 float depth_bias;
2710 float depth_bias_slope_scale;
2711 float depth_bias_clamp;
2712 MTLPrimitiveType mtl_prim_type;
2713 sg_index_type index_type;
2714 NSUInteger mtl_index_size;
2715 MTLIndexType mtl_index_type;
2716 MTLCullMode mtl_cull_mode;
2717 MTLWinding mtl_winding;
2718 float blend_color[4];
2719 uint32_t mtl_stencil_ref;
2720 uint32_t mtl_rps;
2721 uint32_t mtl_dss;
2722 } _sg_pipeline_t;
2723
2724 typedef struct {
2725 _sg_image_t* image;
2726 sg_image image_id;
2727 int mip_level;
2728 int slice;
2729 } _sg_attachment_t;
2730
2731 typedef struct {
2732 _sg_slot_t slot;
2733 int num_color_atts;
2734 _sg_attachment_t color_atts[SG_MAX_COLOR_ATTACHMENTS];
2735 _sg_attachment_t ds_att;
2736 } _sg_pass_t;
2737
2738 typedef struct {
2739 _sg_slot_t slot;
2740 } _sg_context_t;
2741
2742 /* resouce binding state cache */
2743 typedef struct {
2744 const _sg_pipeline_t* cur_pipeline;
2745 sg_pipeline cur_pipeline_id;
2746 const _sg_buffer_t* cur_indexbuffer;
2747 int cur_indexbuffer_offset;
2748 sg_buffer cur_indexbuffer_id;
2749 const _sg_buffer_t* cur_vertexbuffers[SG_MAX_SHADERSTAGE_BUFFERS];
2750 int cur_vertexbuffer_offsets[SG_MAX_SHADERSTAGE_BUFFERS];
2751 sg_buffer cur_vertexbuffer_ids[SG_MAX_SHADERSTAGE_BUFFERS];
2752 const _sg_image_t* cur_vs_images[SG_MAX_SHADERSTAGE_IMAGES];
2753 sg_image cur_vs_image_ids[SG_MAX_SHADERSTAGE_IMAGES];
2754 const _sg_image_t* cur_fs_images[SG_MAX_SHADERSTAGE_IMAGES];
2755 sg_image cur_fs_image_ids[SG_MAX_SHADERSTAGE_IMAGES];
2756 } _sg_mtl_state_cache_t;
2757
2758 typedef struct {
2759 bool valid;
2760 const void*(*renderpass_descriptor_cb)(void);
2761 const void*(*drawable_cb)(void);
2762 uint32_t frame_index;
2763 uint32_t cur_frame_rotate_index;
2764 uint32_t ub_size;
2765 uint32_t cur_ub_offset;
2766 uint8_t* cur_ub_base_ptr;
2767 bool in_pass;
2768 bool pass_valid;
2769 int cur_width;
2770 int cur_height;
2771 _sg_mtl_state_cache_t state_cache;
2772 _sg_mtl_sampler_cache_t sampler_cache;
2773 _sg_mtl_idpool_t idpool;
2774 } _sg_mtl_backend_t;
2775
2776 /* keep Objective-C 'smart data' in a separate static objects, these can't be in a C struct until Xcode10 or so */
2777 static NSMutableArray* _sg_mtl_idpool;
2778 static id<MTLDevice> _sg_mtl_device;
2779 static id<MTLCommandQueue> _sg_mtl_cmd_queue;
2780 static id<MTLCommandBuffer> _sg_mtl_cmd_buffer;
2781 static id<MTLBuffer> _sg_mtl_uniform_buffers[SG_NUM_INFLIGHT_FRAMES];
2782 static id<MTLRenderCommandEncoder> _sg_mtl_cmd_encoder;
2783 static dispatch_semaphore_t _sg_mtl_sem;
2784
2785 #endif /* SOKOL_METAL */
2786
2787 /*=== RESOURCE POOL DECLARATIONS =============================================*/
2788
2789 /* this *MUST* remain 0 */
2790 #define _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! (0)
2791
2792 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_23# {
2793 int sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
2794 int queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top.;
2795 uint32_tcxx . . $ uint32_t#* gen_ctrscxx . . $ $anonymous_type_ded6a5455d648ef8_23#gen_ctrs.;
2796 int* free_queuecxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue.;
2797 } _sg_pool_tcxx . . $ _sg_pool_t#;
2798
2799 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_24# {
2800 _sg_pool_tcxx . . $ _sg_pool_t# buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool.;
2801 _sg_pool_tcxx . . $ _sg_pool_t# image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool.;
2802 _sg_pool_tcxx . . $ _sg_pool_t# shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool.;
2803 _sg_pool_tcxx . . $ _sg_pool_t# pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool.;
2804 _sg_pool_tcxx . . $ _sg_pool_t# pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool.;
2805 _sg_pool_tcxx . . $ _sg_pool_t# context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool.;
2806 _sg_buffer_tcxx . . $ _sg_buffer_t#* bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.;
2807 _sg_image_tcxx . . $ _sg_image_t#* imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.;
2808 _sg_shader_tcxx . . $ _sg_shader_t#* shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.;
2809 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines.;
2810 _sg_pass_tcxx . . $ _sg_pass_t#* passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes.;
2811 _sg_context_tcxx . . $ _sg_context_t#* contextscxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts.;
2812 } _sg_pools_tcxx . . $ _sg_pools_t#;
2813
2814 /*=== VALIDATION LAYER DECLARATIONS ==========================================*/
2815 typedef enumcxx . . $ $anonymous_type_ded6a5455d648ef8_25# {
2816 /* special case 'validation was successful' */
2817 _SG_VALIDATE_SUCCESScxx . . $ _SG_VALIDATE_SUCCESS.,
2818
2819 /* buffer creation */
2820 _SG_VALIDATE_BUFFERDESC_CANARYcxx . . $ _SG_VALIDATE_BUFFERDESC_CANARY.,
2821 _SG_VALIDATE_BUFFERDESC_SIZEcxx . . $ _SG_VALIDATE_BUFFERDESC_SIZE.,
2822 _SG_VALIDATE_BUFFERDESC_CONTENTcxx . . $ _SG_VALIDATE_BUFFERDESC_CONTENT.,
2823 _SG_VALIDATE_BUFFERDESC_NO_CONTENTcxx . . $ _SG_VALIDATE_BUFFERDESC_NO_CONTENT.,
2824
2825 /* image creation */
2826 _SG_VALIDATE_IMAGEDESC_CANARYcxx . . $ _SG_VALIDATE_IMAGEDESC_CANARY.,
2827 _SG_VALIDATE_IMAGEDESC_WIDTHcxx . . $ _SG_VALIDATE_IMAGEDESC_WIDTH.,
2828 _SG_VALIDATE_IMAGEDESC_HEIGHTcxx . . $ _SG_VALIDATE_IMAGEDESC_HEIGHT.,
2829 _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMATcxx . . $ _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMAT.,
2830 _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMATcxx . . $ _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMAT.,
2831 _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RTcxx . . $ _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RT.,
2832 _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORTcxx . . $ _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT.,
2833 _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLEcxx . . $ _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLE.,
2834 _SG_VALIDATE_IMAGEDESC_RT_NO_CONTENTcxx . . $ _SG_VALIDATE_IMAGEDESC_RT_NO_CONTENT.,
2835 _SG_VALIDATE_IMAGEDESC_CONTENTcxx . . $ _SG_VALIDATE_IMAGEDESC_CONTENT.,
2836 _SG_VALIDATE_IMAGEDESC_NO_CONTENTcxx . . $ _SG_VALIDATE_IMAGEDESC_NO_CONTENT.,
2837
2838 /* shader creation */
2839 _SG_VALIDATE_SHADERDESC_CANARYcxx . . $ _SG_VALIDATE_SHADERDESC_CANARY.,
2840 _SG_VALIDATE_SHADERDESC_SOURCEcxx . . $ _SG_VALIDATE_SHADERDESC_SOURCE.,
2841 _SG_VALIDATE_SHADERDESC_BYTECODEcxx . . $ _SG_VALIDATE_SHADERDESC_BYTECODE.,
2842 _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODEcxx . . $ _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE.,
2843 _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZEcxx . . $ _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE.,
2844 _SG_VALIDATE_SHADERDESC_NO_CONT_UBScxx . . $ _SG_VALIDATE_SHADERDESC_NO_CONT_UBS.,
2845 _SG_VALIDATE_SHADERDESC_NO_CONT_IMGScxx . . $ _SG_VALIDATE_SHADERDESC_NO_CONT_IMGS.,
2846 _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERScxx . . $ _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS.,
2847 _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERScxx . . $ _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERS.,
2848 _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAMEcxx . . $ _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAME.,
2849 _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCHcxx . . $ _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCH.,
2850 _SG_VALIDATE_SHADERDESC_IMG_NAMEcxx . . $ _SG_VALIDATE_SHADERDESC_IMG_NAME.,
2851 _SG_VALIDATE_SHADERDESC_ATTR_NAMEScxx . . $ _SG_VALIDATE_SHADERDESC_ATTR_NAMES.,
2852 _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICScxx . . $ _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICS.,
2853 _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONGcxx . . $ _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG.,
2854
2855 /* pipeline creation */
2856 _SG_VALIDATE_PIPELINEDESC_CANARYcxx . . $ _SG_VALIDATE_PIPELINEDESC_CANARY.,
2857 _SG_VALIDATE_PIPELINEDESC_SHADERcxx . . $ _SG_VALIDATE_PIPELINEDESC_SHADER.,
2858 _SG_VALIDATE_PIPELINEDESC_NO_ATTRScxx . . $ _SG_VALIDATE_PIPELINEDESC_NO_ATTRS.,
2859 _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4cxx . . $ _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4.,
2860 _SG_VALIDATE_PIPELINEDESC_ATTR_NAMEcxx . . $ _SG_VALIDATE_PIPELINEDESC_ATTR_NAME.,
2861 _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICScxx . . $ _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICS.,
2862
2863 /* pass creation */
2864 _SG_VALIDATE_PASSDESC_CANARYcxx . . $ _SG_VALIDATE_PASSDESC_CANARY.,
2865 _SG_VALIDATE_PASSDESC_NO_COLOR_ATTScxx . . $ _SG_VALIDATE_PASSDESC_NO_COLOR_ATTS.,
2866 _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTScxx . . $ _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTS.,
2867 _SG_VALIDATE_PASSDESC_IMAGEcxx . . $ _SG_VALIDATE_PASSDESC_IMAGE.,
2868 _SG_VALIDATE_PASSDESC_MIPLEVELcxx . . $ _SG_VALIDATE_PASSDESC_MIPLEVEL.,
2869 _SG_VALIDATE_PASSDESC_FACEcxx . . $ _SG_VALIDATE_PASSDESC_FACE.,
2870 _SG_VALIDATE_PASSDESC_LAYERcxx . . $ _SG_VALIDATE_PASSDESC_LAYER.,
2871 _SG_VALIDATE_PASSDESC_SLICEcxx . . $ _SG_VALIDATE_PASSDESC_SLICE.,
2872 _SG_VALIDATE_PASSDESC_IMAGE_NO_RTcxx . . $ _SG_VALIDATE_PASSDESC_IMAGE_NO_RT.,
2873 _SG_VALIDATE_PASSDESC_COLOR_PIXELFORMATScxx . . $ _SG_VALIDATE_PASSDESC_COLOR_PIXELFORMATS.,
2874 _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMATcxx . . $ _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT.,
2875 _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMATcxx . . $ _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT.,
2876 _SG_VALIDATE_PASSDESC_IMAGE_SIZEScxx . . $ _SG_VALIDATE_PASSDESC_IMAGE_SIZES.,
2877 _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTScxx . . $ _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS.,
2878
2879 /* sg_begin_pass validation */
2880 _SG_VALIDATE_BEGINPASS_PASScxx . . $ _SG_VALIDATE_BEGINPASS_PASS.,
2881 _SG_VALIDATE_BEGINPASS_IMAGEcxx . . $ _SG_VALIDATE_BEGINPASS_IMAGE.,
2882
2883 /* sg_apply_pipeline validation */
2884 _SG_VALIDATE_APIP_PIPELINE_VALID_IDcxx . . $ _SG_VALIDATE_APIP_PIPELINE_VALID_ID.,
2885 _SG_VALIDATE_APIP_PIPELINE_EXISTScxx . . $ _SG_VALIDATE_APIP_PIPELINE_EXISTS.,
2886 _SG_VALIDATE_APIP_PIPELINE_VALIDcxx . . $ _SG_VALIDATE_APIP_PIPELINE_VALID.,
2887 _SG_VALIDATE_APIP_SHADER_EXISTScxx . . $ _SG_VALIDATE_APIP_SHADER_EXISTS.,
2888 _SG_VALIDATE_APIP_SHADER_VALIDcxx . . $ _SG_VALIDATE_APIP_SHADER_VALID.,
2889 _SG_VALIDATE_APIP_ATT_COUNTcxx . . $ _SG_VALIDATE_APIP_ATT_COUNT.,
2890 _SG_VALIDATE_APIP_COLOR_FORMATcxx . . $ _SG_VALIDATE_APIP_COLOR_FORMAT.,
2891 _SG_VALIDATE_APIP_DEPTH_FORMATcxx . . $ _SG_VALIDATE_APIP_DEPTH_FORMAT.,
2892 _SG_VALIDATE_APIP_SAMPLE_COUNTcxx . . $ _SG_VALIDATE_APIP_SAMPLE_COUNT.,
2893
2894 /* sg_apply_bindings validation */
2895 _SG_VALIDATE_ABND_PIPELINEcxx . . $ _SG_VALIDATE_ABND_PIPELINE.,
2896 _SG_VALIDATE_ABND_PIPELINE_EXISTScxx . . $ _SG_VALIDATE_ABND_PIPELINE_EXISTS.,
2897 _SG_VALIDATE_ABND_PIPELINE_VALIDcxx . . $ _SG_VALIDATE_ABND_PIPELINE_VALID.,
2898 _SG_VALIDATE_ABND_VBScxx . . $ _SG_VALIDATE_ABND_VBS.,
2899 _SG_VALIDATE_ABND_VB_EXISTScxx . . $ _SG_VALIDATE_ABND_VB_EXISTS.,
2900 _SG_VALIDATE_ABND_VB_TYPEcxx . . $ _SG_VALIDATE_ABND_VB_TYPE.,
2901 _SG_VALIDATE_ABND_VB_OVERFLOWcxx . . $ _SG_VALIDATE_ABND_VB_OVERFLOW.,
2902 _SG_VALIDATE_ABND_NO_IBcxx . . $ _SG_VALIDATE_ABND_NO_IB.,
2903 _SG_VALIDATE_ABND_IBcxx . . $ _SG_VALIDATE_ABND_IB.,
2904 _SG_VALIDATE_ABND_IB_EXISTScxx . . $ _SG_VALIDATE_ABND_IB_EXISTS.,
2905 _SG_VALIDATE_ABND_IB_TYPEcxx . . $ _SG_VALIDATE_ABND_IB_TYPE.,
2906 _SG_VALIDATE_ABND_IB_OVERFLOWcxx . . $ _SG_VALIDATE_ABND_IB_OVERFLOW.,
2907 _SG_VALIDATE_ABND_VS_IMGScxx . . $ _SG_VALIDATE_ABND_VS_IMGS.,
2908 _SG_VALIDATE_ABND_VS_IMG_EXISTScxx . . $ _SG_VALIDATE_ABND_VS_IMG_EXISTS.,
2909 _SG_VALIDATE_ABND_VS_IMG_TYPEScxx . . $ _SG_VALIDATE_ABND_VS_IMG_TYPES.,
2910 _SG_VALIDATE_ABND_FS_IMGScxx . . $ _SG_VALIDATE_ABND_FS_IMGS.,
2911 _SG_VALIDATE_ABND_FS_IMG_EXISTScxx . . $ _SG_VALIDATE_ABND_FS_IMG_EXISTS.,
2912 _SG_VALIDATE_ABND_FS_IMG_TYPEScxx . . $ _SG_VALIDATE_ABND_FS_IMG_TYPES.,
2913
2914 /* sg_apply_uniforms validation */
2915 _SG_VALIDATE_AUB_NO_PIPELINEcxx . . $ _SG_VALIDATE_AUB_NO_PIPELINE.,
2916 _SG_VALIDATE_AUB_NO_UB_AT_SLOTcxx . . $ _SG_VALIDATE_AUB_NO_UB_AT_SLOT.,
2917 _SG_VALIDATE_AUB_SIZEcxx . . $ _SG_VALIDATE_AUB_SIZE.,
2918
2919 /* sg_update_buffer validation */
2920 _SG_VALIDATE_UPDATEBUF_USAGEcxx . . $ _SG_VALIDATE_UPDATEBUF_USAGE.,
2921 _SG_VALIDATE_UPDATEBUF_SIZEcxx . . $ _SG_VALIDATE_UPDATEBUF_SIZE.,
2922 _SG_VALIDATE_UPDATEBUF_ONCEcxx . . $ _SG_VALIDATE_UPDATEBUF_ONCE.,
2923 _SG_VALIDATE_UPDATEBUF_APPENDcxx . . $ _SG_VALIDATE_UPDATEBUF_APPEND.,
2924
2925 /* sg_append_buffer validation */
2926 _SG_VALIDATE_APPENDBUF_USAGEcxx . . $ _SG_VALIDATE_APPENDBUF_USAGE.,
2927 _SG_VALIDATE_APPENDBUF_SIZEcxx . . $ _SG_VALIDATE_APPENDBUF_SIZE.,
2928 _SG_VALIDATE_APPENDBUF_UPDATEcxx . . $ _SG_VALIDATE_APPENDBUF_UPDATE.,
2929
2930 /* sg_update_image validation */
2931 _SG_VALIDATE_UPDIMG_USAGEcxx . . $ _SG_VALIDATE_UPDIMG_USAGE.,
2932 _SG_VALIDATE_UPDIMG_NOTENOUGHDATAcxx . . $ _SG_VALIDATE_UPDIMG_NOTENOUGHDATA.,
2933 _SG_VALIDATE_UPDIMG_SIZEcxx . . $ _SG_VALIDATE_UPDIMG_SIZE.,
2934 _SG_VALIDATE_UPDIMG_COMPRESSEDcxx . . $ _SG_VALIDATE_UPDIMG_COMPRESSED.,
2935 _SG_VALIDATE_UPDIMG_ONCEcxx . . $ _SG_VALIDATE_UPDIMG_ONCE.
2936 } _sg_validate_error_tcxx . . $ _sg_validate_error_t#;
2937
2938 /*=== GENERIC BACKEND STATE ==================================================*/
2939
2940 typedef structcxx . . $ $anonymous_type_ded6a5455d648ef8_26# {
2941 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#valid.;
2942 sg_desccxx . . $ sg_desc# desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc.; /* original desc with default values patched in */
2943 uint32_tcxx . . $ uint32_t# frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.;
2944 sg_contextcxx . . $ sg_context# active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context.;
2945 sg_passcxx . . $ sg_pass# cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pass.;
2946 sg_pipelinecxx . . $ sg_pipeline# cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pipeline.;
2947 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.;
2948 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! bindings_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#bindings_valid.;
2949 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid.;
2950 #if defined(SOKOL_DEBUG)
2951 _sg_validate_error_t validate_error;
2952 #endif
2953 _sg_pools_tcxx . . $ _sg_pools_t# poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools.;
2954 #if defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
2955 _sg_gl_backend_tcxx . . $ _sg_gl_backend_t# glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl.;
2956 #elif defined(SOKOL_METAL)
2957 _sg_mtl_backend_t mtl;
2958 #elif defined(SOKOL_D3D11)
2959 _sg_d3d11_backend_t d3d11;
2960 #endif
2961 #if defined(SOKOL_TRACE_HOOKS)
2962 sg_trace_hooks hooks;
2963 #endif
2964 } _sg_state_tcxx . . $ _sg_state_t#;
2965 static _sg_state_tcxx . . $ _sg_state_t# _sgcxx . . $ _sg.;
2966
2967 /*-- helper functions --------------------------------------------------------*/
2968
2969 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_stremptycxx . . $ _sg_strempty(2796537507365e48).(const _sg_str_tcxx . . $ _sg_str_t#* str) {
2970 return 0 == str->bufcxx . . $ $anonymous_type_ded6a5455d648ef8_5#buf.[0];
2971 }
2972
2973 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! const char* _sg_strptrcxx . . $ _sg_strptr(d90489c912418c0c).(const _sg_str_tcxx . . $ _sg_str_t#* str) {
2974 return &str->bufcxx . . $ $anonymous_type_ded6a5455d648ef8_5#buf.[0];
2975 }
2976
2977 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_strcpycxx . . $ _sg_strcpy(78720eca4aacfc00).(_sg_str_tcxx . . $ _sg_str_t#* dst, const char* src) {
2978 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(dst);
2979 if (src) {
2980 #if defined(_MSC_VER)
2981 strncpy_s(dst->buf, _SG_STRING_SIZE, src, (_SG_STRING_SIZE-1));
2982 #else
2983 strncpycxx . . $ strncpy(255158a415b673b0).(dst->bufcxx . . $ $anonymous_type_ded6a5455d648ef8_5#buf., src, _SG_STRING_SIZEcxx . . $ _SG_STRING_SIZE.);
2984 #endif
2985 dst->bufcxx . . $ $anonymous_type_ded6a5455d648ef8_5#buf.[_SG_STRING_SIZEcxx . . $ _SG_STRING_SIZE.-1] = 0;
2986 }
2987 else {
2988 memsetcxx . . $ memset(d1de1e4fb215f1c6).(dst->bufcxx . . $ $anonymous_type_ded6a5455d648ef8_5#buf., 0, _SG_STRING_SIZEcxx . . $ _SG_STRING_SIZE.);
2989 }
2990 }
2991
2992 /* return byte size of a vertex format */
2993 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_vertexformat_bytesizecxx . . $ _sg_vertexformat_bytesize(1303c1e179b3eed2).(sg_vertex_formatcxx . . $ sg_vertex_format# fmt) {
2994 switch (fmt) {
2995 case SG_VERTEXFORMAT_FLOATcxx . . $ SG_VERTEXFORMAT_FLOAT.: return 4;
2996 case SG_VERTEXFORMAT_FLOAT2cxx . . $ SG_VERTEXFORMAT_FLOAT2.: return 8;
2997 case SG_VERTEXFORMAT_FLOAT3cxx . . $ SG_VERTEXFORMAT_FLOAT3.: return 12;
2998 case SG_VERTEXFORMAT_FLOAT4cxx . . $ SG_VERTEXFORMAT_FLOAT4.: return 16;
2999 case SG_VERTEXFORMAT_BYTE4cxx . . $ SG_VERTEXFORMAT_BYTE4.: return 4;
3000 case SG_VERTEXFORMAT_BYTE4Ncxx . . $ SG_VERTEXFORMAT_BYTE4N.: return 4;
3001 case SG_VERTEXFORMAT_UBYTE4cxx . . $ SG_VERTEXFORMAT_UBYTE4.: return 4;
3002 case SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.: return 4;
3003 case SG_VERTEXFORMAT_SHORT2cxx . . $ SG_VERTEXFORMAT_SHORT2.: return 4;
3004 case SG_VERTEXFORMAT_SHORT2Ncxx . . $ SG_VERTEXFORMAT_SHORT2N.: return 4;
3005 case SG_VERTEXFORMAT_SHORT4cxx . . $ SG_VERTEXFORMAT_SHORT4.: return 8;
3006 case SG_VERTEXFORMAT_SHORT4Ncxx . . $ SG_VERTEXFORMAT_SHORT4N.: return 8;
3007 case SG_VERTEXFORMAT_UINT10_N2cxx . . $ SG_VERTEXFORMAT_UINT10_N2.: return 4;
3008 case SG_VERTEXFORMAT_INVALIDcxx . . $ SG_VERTEXFORMAT_INVALID.: return 0;
3009 default:
3010 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!;
3011 return -1;
3012 }
3013 }
3014
3015 /* return the byte size of a shader uniform */
3016 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_uniform_sizecxx . . $ _sg_uniform_size(87c0041b48ebc29b).(sg_uniform_typecxx . . $ sg_uniform_type# type, int count) {
3017 switch (type) {
3018 case SG_UNIFORMTYPE_INVALIDcxx . . $ SG_UNIFORMTYPE_INVALID.: return 0;
3019 case SG_UNIFORMTYPE_FLOATcxx . . $ SG_UNIFORMTYPE_FLOAT.: return 4 * count;
3020 case SG_UNIFORMTYPE_FLOAT2cxx . . $ SG_UNIFORMTYPE_FLOAT2.: return 8 * count;
3021 case SG_UNIFORMTYPE_FLOAT3cxx . . $ SG_UNIFORMTYPE_FLOAT3.: return 12 * count; /* FIXME: std140??? */
3022 case SG_UNIFORMTYPE_FLOAT4cxx . . $ SG_UNIFORMTYPE_FLOAT4.: return 16 * count;
3023 case SG_UNIFORMTYPE_MAT4cxx . . $ SG_UNIFORMTYPE_MAT4.: return 64 * count;
3024 default:
3025 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!;
3026 return -1;
3027 }
3028 }
3029
3030 /* return true if pixel format is a compressed format */
3031 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_is_compressed_pixel_formatcxx . . $ _sg_is_compressed_pixel_format(3296e3b3357c429b).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3032 switch (fmt) {
3033 case SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.:
3034 case SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.:
3035 case SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.:
3036 case SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.:
3037 case SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.:
3038 case SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.:
3039 case SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.:
3040 case SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.:
3041 case SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.:
3042 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
3043 default:
3044 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
3045 }
3046 }
3047
3048 /* return true if pixel format is a valid render target format */
3049 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_is_valid_rendertarget_color_formatcxx . . $ _sg_is_valid_rendertarget_color_format(3296e3b3357c429b).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3050 switch (fmt) {
3051 case SG_PIXELFORMAT_RGBA8cxx . . $ SG_PIXELFORMAT_RGBA8.:
3052 case SG_PIXELFORMAT_R10G10B10A2cxx . . $ SG_PIXELFORMAT_R10G10B10A2.:
3053 case SG_PIXELFORMAT_RGBA32Fcxx . . $ SG_PIXELFORMAT_RGBA32F.:
3054 case SG_PIXELFORMAT_RGBA16Fcxx . . $ SG_PIXELFORMAT_RGBA16F.:
3055 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
3056 default:
3057 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
3058 }
3059 }
3060
3061 /* return true if pixel format is a valid depth format */
3062 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_is_valid_rendertarget_depth_formatcxx . . $ _sg_is_valid_rendertarget_depth_format(3296e3b3357c429b).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3063 switch (fmt) {
3064 case SG_PIXELFORMAT_DEPTHcxx . . $ SG_PIXELFORMAT_DEPTH.:
3065 case SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.:
3066 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
3067 default:
3068 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
3069 }
3070 }
3071
3072 /* return true if pixel format is a depth-stencil format */
3073 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_is_depth_stencil_formatcxx . . $ _sg_is_depth_stencil_format(3296e3b3357c429b).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3074 /* FIXME: more depth stencil formats? */
3075 return (SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL. == fmt);
3076 }
3077
3078 /* return the bytes-per-pixel for a pixel format */
3079 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_pixelformat_bytesizecxx . . $ _sg_pixelformat_bytesize(a5527868c792dc17).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3080 switch (fmt) {
3081 case SG_PIXELFORMAT_RGBA32Fcxx . . $ SG_PIXELFORMAT_RGBA32F.:
3082 return 16;
3083 case SG_PIXELFORMAT_RGBA16Fcxx . . $ SG_PIXELFORMAT_RGBA16F.:
3084 return 8;
3085 case SG_PIXELFORMAT_RGBA8cxx . . $ SG_PIXELFORMAT_RGBA8.:
3086 case SG_PIXELFORMAT_R10G10B10A2cxx . . $ SG_PIXELFORMAT_R10G10B10A2.:
3087 case SG_PIXELFORMAT_R32Fcxx . . $ SG_PIXELFORMAT_R32F.:
3088 return 4;
3089 case SG_PIXELFORMAT_RGB8cxx . . $ SG_PIXELFORMAT_RGB8.:
3090 return 3;
3091 case SG_PIXELFORMAT_R5G5B5A1cxx . . $ SG_PIXELFORMAT_R5G5B5A1.:
3092 case SG_PIXELFORMAT_R5G6B5cxx . . $ SG_PIXELFORMAT_R5G6B5.:
3093 case SG_PIXELFORMAT_RGBA4cxx . . $ SG_PIXELFORMAT_RGBA4.:
3094 case SG_PIXELFORMAT_R16Fcxx . . $ SG_PIXELFORMAT_R16F.:
3095 return 2;
3096 case SG_PIXELFORMAT_L8cxx . . $ SG_PIXELFORMAT_L8.:
3097 return 1;
3098 default:
3099 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!;
3100 return 0;
3101 }
3102 }
3103
3104 /* return row pitch for an image */
3105 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_row_pitchcxx . . $ _sg_row_pitch(73780e93a30a580b).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt, int width) {
3106 int pitch;
3107 switch (fmt) {
3108 case SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.:
3109 case SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.:
3110 case SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.:
3111 pitch = ((width + 3) / 4) * 8;
3112 pitch = pitch < 8 ? 8 : pitch;
3113 break;
3114 case SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.:
3115 case SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.:
3116 pitch = ((width + 3) / 4) * 16;
3117 pitch = pitch < 16 ? 16 : pitch;
3118 break;
3119 case SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.:
3120 case SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.:
3121 {
3122 const int block_size = 4*4;
3123 const int bpp = 4;
3124 int width_blocks = width / 4;
3125 width_blocks = width_blocks < 2 ? 2 : width_blocks;
3126 pitch = width_blocks * ((block_size * bpp) / 8);
3127 }
3128 break;
3129 case SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.:
3130 case SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.:
3131 {
3132 const int block_size = 8*4;
3133 const int bpp = 2;
3134 int width_blocks = width / 4;
3135 width_blocks = width_blocks < 2 ? 2 : width_blocks;
3136 pitch = width_blocks * ((block_size * bpp) / 8);
3137 }
3138 break;
3139 default:
3140 pitch = width * _sg_pixelformat_bytesizecxx . . $ _sg_pixelformat_bytesize(a5527868c792dc17).(fmt);
3141 break;
3142 }
3143 return pitch;
3144 }
3145
3146 /* return pitch of a 2D subimage / texture slice */
3147 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_surface_pitchcxx . . $ _sg_surface_pitch(2dd56353d9825fb0).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt, int width, int height) {
3148 int num_rows = 0;
3149 switch (fmt) {
3150 case SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.:
3151 case SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.:
3152 case SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.:
3153 case SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.:
3154 case SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.:
3155 case SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.:
3156 case SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.:
3157 case SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.:
3158 case SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.:
3159 num_rows = ((height + 3) / 4);
3160 break;
3161 default:
3162 num_rows = height;
3163 break;
3164 }
3165 if (num_rows < 1) {
3166 num_rows = 1;
3167 }
3168 return num_rows * _sg_row_pitchcxx . . $ _sg_row_pitch(73780e93a30a580b).(fmt, width);
3169 }
3170
3171 /* resolve pass action defaults into a new pass action struct */
3172 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_resolve_default_pass_actioncxx . . $ _sg_resolve_default_pass_action(634902845d50ab70).(const sg_pass_actioncxx . . $ sg_pass_action#* from, sg_pass_actioncxx . . $ sg_pass_action#* to) {
3173 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(from && to);
3174 *to = *from;
3175 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
3176 if (to->colorscxx . . $ sg_pass_action#colors.[i].actioncxx . . $ sg_color_attachment_action#action. == _SG_ACTION_DEFAULTcxx . . $ _SG_ACTION_DEFAULT.) {
3177 to->colorscxx . . $ sg_pass_action#colors.[i].actioncxx . . $ sg_color_attachment_action#action. = SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.;
3178 to->colorscxx . . $ sg_pass_action#colors.[i].valcxx . . $ sg_color_attachment_action#val.[0] = SG_DEFAULT_CLEAR_REDcxx . . $ `demo/sokol/sokol_gfx.h:2005:9`!;
3179 to->colorscxx . . $ sg_pass_action#colors.[i].valcxx . . $ sg_color_attachment_action#val.[1] = SG_DEFAULT_CLEAR_GREENcxx . . $ `demo/sokol/sokol_gfx.h:2008:9`!;
3180 to->colorscxx . . $ sg_pass_action#colors.[i].valcxx . . $ sg_color_attachment_action#val.[2] = SG_DEFAULT_CLEAR_BLUEcxx . . $ `demo/sokol/sokol_gfx.h:2011:9`!;
3181 to->colorscxx . . $ sg_pass_action#colors.[i].valcxx . . $ sg_color_attachment_action#val.[3] = SG_DEFAULT_CLEAR_ALPHAcxx . . $ `demo/sokol/sokol_gfx.h:2014:9`!;
3182 }
3183 }
3184 if (to->depthcxx . . $ sg_pass_action#depth..actioncxx . . $ sg_depth_attachment_action#action. == _SG_ACTION_DEFAULTcxx . . $ _SG_ACTION_DEFAULT.) {
3185 to->depthcxx . . $ sg_pass_action#depth..actioncxx . . $ sg_depth_attachment_action#action. = SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.;
3186 to->depthcxx . . $ sg_pass_action#depth..valcxx . . $ sg_depth_attachment_action#val. = SG_DEFAULT_CLEAR_DEPTHcxx . . $ `demo/sokol/sokol_gfx.h:2017:9`!;
3187 }
3188 if (to->stencilcxx . . $ sg_pass_action#stencil..actioncxx . . $ sg_stencil_attachment_action#action. == _SG_ACTION_DEFAULTcxx . . $ _SG_ACTION_DEFAULT.) {
3189 to->stencilcxx . . $ sg_pass_action#stencil..actioncxx . . $ sg_stencil_attachment_action#action. = SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.;
3190 to->stencilcxx . . $ sg_pass_action#stencil..valcxx . . $ sg_stencil_attachment_action#val. = SG_DEFAULT_CLEAR_STENCILcxx . . $ `demo/sokol/sokol_gfx.h:2020:9`!;
3191 }
3192 }
3193
3194 /*== DUMMY BACKEND IMPL ======================================================*/
3195 #if defined(SOKOL_DUMMY_BACKEND)
3196
3197 _SOKOL_PRIVATE void _sg_setup_backend(const sg_desc* desc) {
3198 SOKOL_ASSERT(desc);
3199 _SOKOL_UNUSED(desc);
3200 }
3201
3202 _SOKOL_PRIVATE void _sg_discard_backend(void) {
3203 /* empty */
3204 }
3205
3206 _SOKOL_PRIVATE bool _sg_query_feature(sg_feature f) {
3207 _SOKOL_UNUSED(f);
3208 return true;
3209 }
3210
3211 _SOKOL_PRIVATE void _sg_reset_state_cache(void) {
3212 /* empty*/
3213 }
3214
3215 _SOKOL_PRIVATE sg_resource_state _sg_create_context(_sg_context_t* ctx) {
3216 SOKOL_ASSERT(ctx);
3217 _SOKOL_UNUSED(ctx);
3218 return SG_RESOURCESTATE_VALID;
3219 }
3220
3221 _SOKOL_PRIVATE void _sg_destroy_context(_sg_context_t* ctx) {
3222 SOKOL_ASSERT(ctx);
3223 _SOKOL_UNUSED(ctx);
3224 }
3225
3226 _SOKOL_PRIVATE void _sg_activate_context(_sg_context_t* ctx) {
3227 SOKOL_ASSERT(ctx);
3228 _SOKOL_UNUSED(ctx);
3229 }
3230
3231 _SOKOL_PRIVATE sg_resource_state _sg_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) {
3232 SOKOL_ASSERT(buf && desc);
3233 buf->size = desc->size;
3234 buf->append_pos = 0;
3235 buf->append_overflow = false;
3236 buf->type = desc->type;
3237 buf->usage = desc->usage;
3238 buf->update_frame_index = 0;
3239 buf->append_frame_index = 0;
3240 buf->num_slots = (buf->usage == SG_USAGE_IMMUTABLE) ? 1 : SG_NUM_INFLIGHT_FRAMES;
3241 buf->active_slot = 0;
3242 return SG_RESOURCESTATE_VALID;
3243 }
3244
3245 _SOKOL_PRIVATE void _sg_destroy_buffer(_sg_buffer_t* buf) {
3246 SOKOL_ASSERT(buf);
3247 _SOKOL_UNUSED(buf);
3248 }
3249
3250 _SOKOL_PRIVATE sg_resource_state _sg_create_image(_sg_image_t* img, const sg_image_desc* desc) {
3251 SOKOL_ASSERT(img && desc);
3252 img->type = desc->type;
3253 img->render_target = desc->render_target;
3254 img->width = desc->width;
3255 img->height = desc->height;
3256 img->depth = desc->depth;
3257 img->num_mipmaps = desc->num_mipmaps;
3258 img->usage = desc->usage;
3259 img->pixel_format = desc->pixel_format;
3260 img->sample_count = desc->sample_count;
3261 img->min_filter = desc->min_filter;
3262 img->mag_filter = desc->mag_filter;
3263 img->wrap_u = desc->wrap_u;
3264 img->wrap_v = desc->wrap_v;
3265 img->wrap_w = desc->wrap_w;
3266 img->max_anisotropy = desc->max_anisotropy;
3267 img->upd_frame_index = 0;
3268 img->num_slots = (img->usage == SG_USAGE_IMMUTABLE) ? 1 :SG_NUM_INFLIGHT_FRAMES;
3269 img->active_slot = 0;
3270 return SG_RESOURCESTATE_VALID;
3271 }
3272
3273 _SOKOL_PRIVATE void _sg_destroy_image(_sg_image_t* img) {
3274 SOKOL_ASSERT(img);
3275 _SOKOL_UNUSED(img);
3276 }
3277
3278 _SOKOL_PRIVATE sg_resource_state _sg_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) {
3279 SOKOL_ASSERT(shd && desc);
3280 /* uniform block sizes and image types */
3281 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) {
3282 const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS) ? &desc->vs : &desc->fs;
3283 _sg_shader_stage_t* stage = &shd->stage[stage_index];
3284 SOKOL_ASSERT(stage->num_uniform_blocks == 0);
3285 for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) {
3286 const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index];
3287 if (0 == ub_desc->size) {
3288 break;
3289 }
3290 _sg_uniform_block_t* ub = &stage->uniform_blocks[ub_index];
3291 ub->size = ub_desc->size;
3292 stage->num_uniform_blocks++;
3293 }
3294 SOKOL_ASSERT(stage->num_images == 0);
3295 for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) {
3296 const sg_shader_image_desc* img_desc = &stage_desc->images[img_index];
3297 if (img_desc->type == _SG_IMAGETYPE_DEFAULT) {
3298 break;
3299 }
3300 stage->images[img_index].type = img_desc->type;
3301 stage->num_images++;
3302 }
3303 }
3304 return SG_RESOURCESTATE_VALID;
3305 }
3306
3307 _SOKOL_PRIVATE void _sg_destroy_shader(_sg_shader_t* shd) {
3308 SOKOL_ASSERT(shd);
3309 _SOKOL_UNUSED(shd);
3310 }
3311
3312 _SOKOL_PRIVATE sg_resource_state _sg_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) {
3313 SOKOL_ASSERT(pip && desc);
3314 pip->shader = shd;
3315 pip->shader_id = desc->shader;
3316 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) {
3317 const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index];
3318 if (a_desc->format == SG_VERTEXFORMAT_INVALID) {
3319 break;
3320 }
3321 SOKOL_ASSERT((a_desc->buffer_index >= 0) && (a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS));
3322 pip->vertex_layout_valid[a_desc->buffer_index] = true;
3323 }
3324 pip->color_attachment_count = desc->blend.color_attachment_count;
3325 pip->color_format = desc->blend.color_format;
3326 pip->depth_format = desc->blend.depth_format;
3327 pip->sample_count = desc->rasterizer.sample_count;
3328 pip->depth_bias = desc->rasterizer.depth_bias;
3329 pip->depth_bias_slope_scale = desc->rasterizer.depth_bias_slope_scale;
3330 pip->depth_bias_clamp = desc->rasterizer.depth_bias_clamp;
3331 pip->index_type = desc->index_type;
3332 for (int i = 0; i < 4; i++) {
3333 pip->blend_color[i] = desc->blend.blend_color[i];
3334 }
3335 return SG_RESOURCESTATE_VALID;
3336 }
3337
3338 _SOKOL_PRIVATE void _sg_destroy_pipeline(_sg_pipeline_t* pip) {
3339 SOKOL_ASSERT(pip);
3340 _SOKOL_UNUSED(pip);
3341 }
3342
3343 _SOKOL_PRIVATE sg_resource_state _sg_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) {
3344 SOKOL_ASSERT(pass && desc);
3345 SOKOL_ASSERT(att_images && att_images[0]);
3346 /* copy image pointers and desc attributes */
3347 const sg_attachment_desc* att_desc;
3348 _sg_attachment_t* att;
3349 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
3350 SOKOL_ASSERT(0 == pass->color_atts[i].image);
3351 att_desc = &desc->color_attachments[i];
3352 if (att_desc->image.id != SG_INVALID_ID) {
3353 pass->num_color_atts++;
3354 SOKOL_ASSERT(att_images[i] && (att_images[i]->slot.id == att_desc->image.id));
3355 SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_images[i]->pixel_format));
3356 att = &pass->color_atts[i];
3357 SOKOL_ASSERT((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
3358 att->image = att_images[i];
3359 att->image_id = att_desc->image;
3360 att->mip_level = att_desc->mip_level;
3361 att->slice = att_desc->slice;
3362 }
3363 }
3364 SOKOL_ASSERT(0 == pass->ds_att.image);
3365 att_desc = &desc->depth_stencil_attachment;
3366 const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS;
3367 if (att_desc->image.id != SG_INVALID_ID) {
3368 SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id));
3369 SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->pixel_format));
3370 att = &pass->ds_att;
3371 SOKOL_ASSERT((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
3372 att->image = att_images[ds_img_index];
3373 att->image_id = att_desc->image;
3374 att->mip_level = att_desc->mip_level;
3375 att->slice = att_desc->slice;
3376 }
3377 return SG_RESOURCESTATE_VALID;
3378 }
3379
3380 _SOKOL_PRIVATE void _sg_destroy_pass(_sg_pass_t* pass) {
3381 SOKOL_ASSERT(pass);
3382 _SOKOL_UNUSED(pass);
3383 }
3384
3385 _SOKOL_PRIVATE void _sg_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) {
3386 SOKOL_ASSERT(action);
3387 _SOKOL_UNUSED(pass);
3388 _SOKOL_UNUSED(action);
3389 _SOKOL_UNUSED(w);
3390 _SOKOL_UNUSED(h);
3391 }
3392
3393 _SOKOL_PRIVATE void _sg_end_pass(void) {
3394 /* empty */
3395 }
3396
3397 _SOKOL_PRIVATE void _sg_commit(void) {
3398 /* empty */
3399 }
3400
3401 _SOKOL_PRIVATE void _sg_apply_viewport(int x, int y, int w, int h, bool origin_top_left) {
3402 _SOKOL_UNUSED(x);
3403 _SOKOL_UNUSED(y);
3404 _SOKOL_UNUSED(w);
3405 _SOKOL_UNUSED(h);
3406 _SOKOL_UNUSED(origin_top_left);
3407 }
3408
3409 _SOKOL_PRIVATE void _sg_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) {
3410 _SOKOL_UNUSED(x);
3411 _SOKOL_UNUSED(y);
3412 _SOKOL_UNUSED(w);
3413 _SOKOL_UNUSED(h);
3414 _SOKOL_UNUSED(origin_top_left);
3415 }
3416
3417 _SOKOL_PRIVATE void _sg_apply_pipeline(_sg_pipeline_t* pip) {
3418 SOKOL_ASSERT(pip);
3419 _SOKOL_UNUSED(pip);
3420 }
3421
3422 _SOKOL_PRIVATE void _sg_apply_bindings(
3423 _sg_pipeline_t* pip,
3424 _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs,
3425 _sg_buffer_t* ib, int ib_offset,
3426 _sg_image_t** vs_imgs, int num_vs_imgs,
3427 _sg_image_t** fs_imgs, int num_fs_imgs)
3428 {
3429 SOKOL_ASSERT(pip);
3430 SOKOL_ASSERT(vbs && vb_offsets);
3431 SOKOL_ASSERT(vs_imgs);
3432 SOKOL_ASSERT(fs_imgs);
3433 _SOKOL_UNUSED(pip);
3434 _SOKOL_UNUSED(vbs); _SOKOL_UNUSED(vb_offsets); _SOKOL_UNUSED(num_vbs);
3435 _SOKOL_UNUSED(ib); _SOKOL_UNUSED(ib_offset);
3436 _SOKOL_UNUSED(vs_imgs); _SOKOL_UNUSED(num_vs_imgs);
3437 _SOKOL_UNUSED(fs_imgs); _SOKOL_UNUSED(num_fs_imgs);
3438 }
3439
3440 _SOKOL_PRIVATE void _sg_apply_uniforms(sg_shader_stage stage_index, int ub_index, const void* data, int num_bytes) {
3441 SOKOL_ASSERT(data && (num_bytes > 0));
3442 SOKOL_ASSERT((stage_index >= 0) && ((int)stage_index < SG_NUM_SHADER_STAGES));
3443 SOKOL_ASSERT((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS));
3444 _SOKOL_UNUSED(stage_index);
3445 _SOKOL_UNUSED(ub_index);
3446 _SOKOL_UNUSED(data);
3447 _SOKOL_UNUSED(num_bytes);
3448 }
3449
3450 _SOKOL_PRIVATE void _sg_draw(int base_element, int num_elements, int num_instances) {
3451 _SOKOL_UNUSED(base_element);
3452 _SOKOL_UNUSED(num_elements);
3453 _SOKOL_UNUSED(num_instances);
3454 }
3455
3456 _SOKOL_PRIVATE void _sg_update_buffer(_sg_buffer_t* buf, const void* data, int data_size) {
3457 SOKOL_ASSERT(buf && data && (data_size > 0));
3458 _SOKOL_UNUSED(data);
3459 _SOKOL_UNUSED(data_size);
3460 if (++buf->active_slot >= buf->num_slots) {
3461 buf->active_slot = 0;
3462 }
3463 }
3464
3465 _SOKOL_PRIVATE void _sg_append_buffer(_sg_buffer_t* buf, const void* data, int data_size, bool new_frame) {
3466 SOKOL_ASSERT(buf && data && (data_size > 0));
3467 _SOKOL_UNUSED(data);
3468 _SOKOL_UNUSED(data_size);
3469 if (new_frame) {
3470 if (++buf->active_slot >= buf->num_slots) {
3471 buf->active_slot = 0;
3472 }
3473 }
3474 }
3475
3476 _SOKOL_PRIVATE void _sg_update_image(_sg_image_t* img, const sg_image_content* data) {
3477 SOKOL_ASSERT(img && data);
3478 _SOKOL_UNUSED(data);
3479 if (++img->active_slot >= img->num_slots) {
3480 img->active_slot = 0;
3481 }
3482 }
3483
3484 /*== GL BACKEND ==============================================================*/
3485 #elif defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
3486
3487 /*-- type translation --------------------------------------------------------*/
3488 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_buffer_targetcxx . . $ _sg_gl_buffer_target(49ff54eba56abf56).(sg_buffer_typecxx . . $ sg_buffer_type# t) {
3489 switch (t) {
3490 case SG_BUFFERTYPE_VERTEXBUFFERcxx . . $ SG_BUFFERTYPE_VERTEXBUFFER.: return GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`!;
3491 case SG_BUFFERTYPE_INDEXBUFFERcxx . . $ SG_BUFFERTYPE_INDEXBUFFER.: return GL_ELEMENT_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:459:9`!;
3492 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3493 }
3494 }
3495
3496 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_texture_targetcxx . . $ _sg_gl_texture_target(5d7eb9a7f9ae8a10).(sg_image_typecxx . . $ sg_image_type# t) {
3497 switch (t) {
3498 case SG_IMAGETYPE_2Dcxx . . $ SG_IMAGETYPE_2D.: return GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!;
3499 case SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE.: return GL_TEXTURE_CUBE_MAPcxx . . $ `<external>/11565930711847777359/gl.h:1752:9`!;
3500 #if !defined(SOKOL_GLES2)
3501 case SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D.: return GL_TEXTURE_3Dcxx . . $ `<external>/11565930711847777359/gl.h:1481:9`!;
3502 case SG_IMAGETYPE_ARRAYcxx . . $ SG_IMAGETYPE_ARRAY.: return GL_TEXTURE_2D_ARRAYcxx . . $ `<external>/13868558256673015710/glext.h:895:9`!;
3503 #endif
3504 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3505 }
3506 }
3507
3508 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_usagecxx . . $ _sg_gl_usage(ca3a1c046ebfa598).(sg_usagecxx . . $ sg_usage# u) {
3509 switch (u) {
3510 case SG_USAGE_IMMUTABLEcxx . . $ SG_USAGE_IMMUTABLE.: return GL_STATIC_DRAWcxx . . $ `<external>/13868558256673015710/glext.h:472:9`!;
3511 case SG_USAGE_DYNAMICcxx . . $ SG_USAGE_DYNAMIC.: return GL_DYNAMIC_DRAWcxx . . $ `<external>/13868558256673015710/glext.h:475:9`!;
3512 case SG_USAGE_STREAMcxx . . $ SG_USAGE_STREAM.: return GL_STREAM_DRAWcxx . . $ `<external>/13868558256673015710/glext.h:469:9`!;
3513 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3514 }
3515 }
3516
3517 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_shader_stagecxx . . $ _sg_gl_shader_stage(ee0e1eddd5358485).(sg_shader_stagecxx . . $ sg_shader_stage# stage) {
3518 switch (stage) {
3519 case SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS.: return GL_VERTEX_SHADERcxx . . $ `<external>/13868558256673015710/glext.h:581:9`!;
3520 case SG_SHADERSTAGE_FScxx . . $ SG_SHADERSTAGE_FS.: return GL_FRAGMENT_SHADERcxx . . $ `<external>/13868558256673015710/glext.h:580:9`!;
3521 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3522 }
3523 }
3524
3525 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLintcxx . . $ GLint# _sg_gl_vertexformat_sizecxx . . $ _sg_gl_vertexformat_size(1303c1e179b3eed2).(sg_vertex_formatcxx . . $ sg_vertex_format# fmt) {
3526 switch (fmt) {
3527 case SG_VERTEXFORMAT_FLOATcxx . . $ SG_VERTEXFORMAT_FLOAT.: return 1;
3528 case SG_VERTEXFORMAT_FLOAT2cxx . . $ SG_VERTEXFORMAT_FLOAT2.: return 2;
3529 case SG_VERTEXFORMAT_FLOAT3cxx . . $ SG_VERTEXFORMAT_FLOAT3.: return 3;
3530 case SG_VERTEXFORMAT_FLOAT4cxx . . $ SG_VERTEXFORMAT_FLOAT4.: return 4;
3531 case SG_VERTEXFORMAT_BYTE4cxx . . $ SG_VERTEXFORMAT_BYTE4.: return 4;
3532 case SG_VERTEXFORMAT_BYTE4Ncxx . . $ SG_VERTEXFORMAT_BYTE4N.: return 4;
3533 case SG_VERTEXFORMAT_UBYTE4cxx . . $ SG_VERTEXFORMAT_UBYTE4.: return 4;
3534 case SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.: return 4;
3535 case SG_VERTEXFORMAT_SHORT2cxx . . $ SG_VERTEXFORMAT_SHORT2.: return 2;
3536 case SG_VERTEXFORMAT_SHORT2Ncxx . . $ SG_VERTEXFORMAT_SHORT2N.: return 2;
3537 case SG_VERTEXFORMAT_SHORT4cxx . . $ SG_VERTEXFORMAT_SHORT4.: return 4;
3538 case SG_VERTEXFORMAT_SHORT4Ncxx . . $ SG_VERTEXFORMAT_SHORT4N.: return 4;
3539 case SG_VERTEXFORMAT_UINT10_N2cxx . . $ SG_VERTEXFORMAT_UINT10_N2.: return 4;
3540 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3541 }
3542 }
3543
3544 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_vertexformat_typecxx . . $ _sg_gl_vertexformat_type(bd32c1c4f42173fe).(sg_vertex_formatcxx . . $ sg_vertex_format# fmt) {
3545 switch (fmt) {
3546 case SG_VERTEXFORMAT_FLOATcxx . . $ SG_VERTEXFORMAT_FLOAT.:
3547 case SG_VERTEXFORMAT_FLOAT2cxx . . $ SG_VERTEXFORMAT_FLOAT2.:
3548 case SG_VERTEXFORMAT_FLOAT3cxx . . $ SG_VERTEXFORMAT_FLOAT3.:
3549 case SG_VERTEXFORMAT_FLOAT4cxx . . $ SG_VERTEXFORMAT_FLOAT4.:
3550 return GL_FLOATcxx . . $ `<external>/11565930711847777359/gl.h:149:9`!;
3551 case SG_VERTEXFORMAT_BYTE4cxx . . $ SG_VERTEXFORMAT_BYTE4.:
3552 case SG_VERTEXFORMAT_BYTE4Ncxx . . $ SG_VERTEXFORMAT_BYTE4N.:
3553 return GL_BYTEcxx . . $ `<external>/11565930711847777359/gl.h:143:9`!;
3554 case SG_VERTEXFORMAT_UBYTE4cxx . . $ SG_VERTEXFORMAT_UBYTE4.:
3555 case SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.:
3556 return GL_UNSIGNED_BYTEcxx . . $ `<external>/11565930711847777359/gl.h:144:9`!;
3557 case SG_VERTEXFORMAT_SHORT2cxx . . $ SG_VERTEXFORMAT_SHORT2.:
3558 case SG_VERTEXFORMAT_SHORT2Ncxx . . $ SG_VERTEXFORMAT_SHORT2N.:
3559 case SG_VERTEXFORMAT_SHORT4cxx . . $ SG_VERTEXFORMAT_SHORT4.:
3560 case SG_VERTEXFORMAT_SHORT4Ncxx . . $ SG_VERTEXFORMAT_SHORT4N.:
3561 return GL_SHORTcxx . . $ `<external>/11565930711847777359/gl.h:145:9`!;
3562 case SG_VERTEXFORMAT_UINT10_N2cxx . . $ SG_VERTEXFORMAT_UINT10_N2.:
3563 return GL_UNSIGNED_INT_2_10_10_10_REVcxx . . $ `<external>/11565930711847777359/gl.h:1463:9`!;
3564 default:
3565 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3566 }
3567 }
3568
3569 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLbooleancxx . . $ GLboolean# _sg_gl_vertexformat_normalizedcxx . . $ _sg_gl_vertexformat_normalized(bc7c4b45b00aa08c).(sg_vertex_formatcxx . . $ sg_vertex_format# fmt) {
3570 switch (fmt) {
3571 case SG_VERTEXFORMAT_BYTE4Ncxx . . $ SG_VERTEXFORMAT_BYTE4N.:
3572 case SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.:
3573 case SG_VERTEXFORMAT_SHORT2Ncxx . . $ SG_VERTEXFORMAT_SHORT2N.:
3574 case SG_VERTEXFORMAT_SHORT4Ncxx . . $ SG_VERTEXFORMAT_SHORT4N.:
3575 case SG_VERTEXFORMAT_UINT10_N2cxx . . $ SG_VERTEXFORMAT_UINT10_N2.:
3576 return GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!;
3577 default:
3578 return GL_FALSEcxx . . $ `<external>/11565930711847777359/gl.h:139:9`!;
3579 }
3580 }
3581
3582 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_primitive_typecxx . . $ _sg_gl_primitive_type(a61e21cb2eca1e09).(sg_primitive_typecxx . . $ sg_primitive_type# t) {
3583 switch (t) {
3584 case SG_PRIMITIVETYPE_POINTScxx . . $ SG_PRIMITIVETYPE_POINTS.: return GL_POINTScxx . . $ `<external>/11565930711847777359/gl.h:156:9`!;
3585 case SG_PRIMITIVETYPE_LINEScxx . . $ SG_PRIMITIVETYPE_LINES.: return GL_LINEScxx . . $ `<external>/11565930711847777359/gl.h:157:9`!;
3586 case SG_PRIMITIVETYPE_LINE_STRIPcxx . . $ SG_PRIMITIVETYPE_LINE_STRIP.: return GL_LINE_STRIPcxx . . $ `<external>/11565930711847777359/gl.h:159:9`!;
3587 case SG_PRIMITIVETYPE_TRIANGLEScxx . . $ SG_PRIMITIVETYPE_TRIANGLES.: return GL_TRIANGLEScxx . . $ `<external>/11565930711847777359/gl.h:160:9`!;
3588 case SG_PRIMITIVETYPE_TRIANGLE_STRIPcxx . . $ SG_PRIMITIVETYPE_TRIANGLE_STRIP.: return GL_TRIANGLE_STRIPcxx . . $ `<external>/11565930711847777359/gl.h:161:9`!;
3589 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3590 }
3591 }
3592
3593 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_index_typecxx . . $ _sg_gl_index_type(70b3963abd55fd2a).(sg_index_typecxx . . $ sg_index_type# t) {
3594 switch (t) {
3595 case SG_INDEXTYPE_NONEcxx . . $ SG_INDEXTYPE_NONE.: return 0;
3596 case SG_INDEXTYPE_UINT16cxx . . $ SG_INDEXTYPE_UINT16.: return GL_UNSIGNED_SHORTcxx . . $ `<external>/11565930711847777359/gl.h:146:9`!;
3597 case SG_INDEXTYPE_UINT32cxx . . $ SG_INDEXTYPE_UINT32.: return GL_UNSIGNED_INTcxx . . $ `<external>/11565930711847777359/gl.h:148:9`!;
3598 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3599 }
3600 }
3601
3602 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_compare_funccxx . . $ _sg_gl_compare_func(2deec0e3607cac).(sg_compare_funccxx . . $ sg_compare_func# cmp) {
3603 switch (cmp) {
3604 case SG_COMPAREFUNC_NEVERcxx . . $ SG_COMPAREFUNC_NEVER.: return GL_NEVERcxx . . $ `<external>/11565930711847777359/gl.h:259:9`!;
3605 case SG_COMPAREFUNC_LESScxx . . $ SG_COMPAREFUNC_LESS.: return GL_LESScxx . . $ `<external>/11565930711847777359/gl.h:260:9`!;
3606 case SG_COMPAREFUNC_EQUALcxx . . $ SG_COMPAREFUNC_EQUAL.: return GL_EQUALcxx . . $ `<external>/11565930711847777359/gl.h:261:9`!;
3607 case SG_COMPAREFUNC_LESS_EQUALcxx . . $ SG_COMPAREFUNC_LESS_EQUAL.: return GL_LEQUALcxx . . $ `<external>/11565930711847777359/gl.h:262:9`!;
3608 case SG_COMPAREFUNC_GREATERcxx . . $ SG_COMPAREFUNC_GREATER.: return GL_GREATERcxx . . $ `<external>/11565930711847777359/gl.h:263:9`!;
3609 case SG_COMPAREFUNC_NOT_EQUALcxx . . $ SG_COMPAREFUNC_NOT_EQUAL.: return GL_NOTEQUALcxx . . $ `<external>/11565930711847777359/gl.h:264:9`!;
3610 case SG_COMPAREFUNC_GREATER_EQUALcxx . . $ SG_COMPAREFUNC_GREATER_EQUAL.: return GL_GEQUALcxx . . $ `<external>/11565930711847777359/gl.h:265:9`!;
3611 case SG_COMPAREFUNC_ALWAYScxx . . $ SG_COMPAREFUNC_ALWAYS.: return GL_ALWAYScxx . . $ `<external>/11565930711847777359/gl.h:266:9`!;
3612 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3613 }
3614 }
3615
3616 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_stencil_opcxx . . $ _sg_gl_stencil_op(5b1cd35c1241aee).(sg_stencil_opcxx . . $ sg_stencil_op# op) {
3617 switch (op) {
3618 case SG_STENCILOP_KEEPcxx . . $ SG_STENCILOP_KEEP.: return GL_KEEPcxx . . $ `<external>/11565930711847777359/gl.h:425:9`!;
3619 case SG_STENCILOP_ZEROcxx . . $ SG_STENCILOP_ZERO.: return GL_ZEROcxx . . $ `<external>/11565930711847777359/gl.h:340:9`!;
3620 case SG_STENCILOP_REPLACEcxx . . $ SG_STENCILOP_REPLACE.: return GL_REPLACEcxx . . $ `<external>/11565930711847777359/gl.h:426:9`!;
3621 case SG_STENCILOP_INCR_CLAMPcxx . . $ SG_STENCILOP_INCR_CLAMP.: return GL_INCRcxx . . $ `<external>/11565930711847777359/gl.h:427:9`!;
3622 case SG_STENCILOP_DECR_CLAMPcxx . . $ SG_STENCILOP_DECR_CLAMP.: return GL_DECRcxx . . $ `<external>/11565930711847777359/gl.h:428:9`!;
3623 case SG_STENCILOP_INVERTcxx . . $ SG_STENCILOP_INVERT.: return GL_INVERTcxx . . $ `<external>/11565930711847777359/gl.h:401:9`!;
3624 case SG_STENCILOP_INCR_WRAPcxx . . $ SG_STENCILOP_INCR_WRAP.: return GL_INCR_WRAPcxx . . $ `<external>/13868558256673015710/glext.h:311:9`!;
3625 case SG_STENCILOP_DECR_WRAPcxx . . $ SG_STENCILOP_DECR_WRAP.: return GL_DECR_WRAPcxx . . $ `<external>/13868558256673015710/glext.h:312:9`!;
3626 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3627 }
3628 }
3629
3630 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_blend_factorcxx . . $ _sg_gl_blend_factor(46b9e0c28961cdc1).(sg_blend_factorcxx . . $ sg_blend_factor# f) {
3631 switch (f) {
3632 case SG_BLENDFACTOR_ZEROcxx . . $ SG_BLENDFACTOR_ZERO.: return GL_ZEROcxx . . $ `<external>/11565930711847777359/gl.h:340:9`!;
3633 case SG_BLENDFACTOR_ONEcxx . . $ SG_BLENDFACTOR_ONE.: return GL_ONEcxx . . $ `<external>/11565930711847777359/gl.h:341:9`!;
3634 case SG_BLENDFACTOR_SRC_COLORcxx . . $ SG_BLENDFACTOR_SRC_COLOR.: return GL_SRC_COLORcxx . . $ `<external>/11565930711847777359/gl.h:342:9`!;
3635 case SG_BLENDFACTOR_ONE_MINUS_SRC_COLORcxx . . $ SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR.: return GL_ONE_MINUS_SRC_COLORcxx . . $ `<external>/11565930711847777359/gl.h:343:9`!;
3636 case SG_BLENDFACTOR_SRC_ALPHAcxx . . $ SG_BLENDFACTOR_SRC_ALPHA.: return GL_SRC_ALPHAcxx . . $ `<external>/11565930711847777359/gl.h:344:9`!;
3637 case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA.: return GL_ONE_MINUS_SRC_ALPHAcxx . . $ `<external>/11565930711847777359/gl.h:345:9`!;
3638 case SG_BLENDFACTOR_DST_COLORcxx . . $ SG_BLENDFACTOR_DST_COLOR.: return GL_DST_COLORcxx . . $ `<external>/11565930711847777359/gl.h:348:9`!;
3639 case SG_BLENDFACTOR_ONE_MINUS_DST_COLORcxx . . $ SG_BLENDFACTOR_ONE_MINUS_DST_COLOR.: return GL_ONE_MINUS_DST_COLORcxx . . $ `<external>/11565930711847777359/gl.h:349:9`!;
3640 case SG_BLENDFACTOR_DST_ALPHAcxx . . $ SG_BLENDFACTOR_DST_ALPHA.: return GL_DST_ALPHAcxx . . $ `<external>/11565930711847777359/gl.h:346:9`!;
3641 case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA.: return GL_ONE_MINUS_DST_ALPHAcxx . . $ `<external>/11565930711847777359/gl.h:347:9`!;
3642 case SG_BLENDFACTOR_SRC_ALPHA_SATURATEDcxx . . $ SG_BLENDFACTOR_SRC_ALPHA_SATURATED.: return GL_SRC_ALPHA_SATURATEcxx . . $ `<external>/11565930711847777359/gl.h:350:9`!;
3643 case SG_BLENDFACTOR_BLEND_COLORcxx . . $ SG_BLENDFACTOR_BLEND_COLOR.: return GL_CONSTANT_COLORcxx . . $ `<external>/13868558256673015710/glext.h:341:9`!;
3644 case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLORcxx . . $ SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR.: return GL_ONE_MINUS_CONSTANT_COLORcxx . . $ `<external>/13868558256673015710/glext.h:342:9`!;
3645 case SG_BLENDFACTOR_BLEND_ALPHAcxx . . $ SG_BLENDFACTOR_BLEND_ALPHA.: return GL_CONSTANT_ALPHAcxx . . $ `<external>/13868558256673015710/glext.h:343:9`!;
3646 case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA.: return GL_ONE_MINUS_CONSTANT_ALPHAcxx . . $ `<external>/13868558256673015710/glext.h:344:9`!;
3647 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3648 }
3649 }
3650
3651 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_blend_opcxx . . $ _sg_gl_blend_op(5a0d0156c79469ed).(sg_blend_opcxx . . $ sg_blend_op# op) {
3652 switch (op) {
3653 case SG_BLENDOP_ADDcxx . . $ SG_BLENDOP_ADD.: return GL_FUNC_ADDcxx . . $ `<external>/13868558256673015710/glext.h:345:9`!;
3654 case SG_BLENDOP_SUBTRACTcxx . . $ SG_BLENDOP_SUBTRACT.: return GL_FUNC_SUBTRACTcxx . . $ `<external>/13868558256673015710/glext.h:347:9`!;
3655 case SG_BLENDOP_REVERSE_SUBTRACTcxx . . $ SG_BLENDOP_REVERSE_SUBTRACT.: return GL_FUNC_REVERSE_SUBTRACTcxx . . $ `<external>/13868558256673015710/glext.h:346:9`!;
3656 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3657 }
3658 }
3659
3660 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_filtercxx . . $ _sg_gl_filter(77eb28f52aae21f3).(sg_filtercxx . . $ sg_filter# f) {
3661 switch (f) {
3662 case SG_FILTER_NEARESTcxx . . $ SG_FILTER_NEAREST.: return GL_NEARESTcxx . . $ `<external>/11565930711847777359/gl.h:644:9`!;
3663 case SG_FILTER_LINEARcxx . . $ SG_FILTER_LINEAR.: return GL_LINEARcxx . . $ `<external>/11565930711847777359/gl.h:387:9`!;
3664 case SG_FILTER_NEAREST_MIPMAP_NEARESTcxx . . $ SG_FILTER_NEAREST_MIPMAP_NEAREST.: return GL_NEAREST_MIPMAP_NEARESTcxx . . $ `<external>/11565930711847777359/gl.h:633:9`!;
3665 case SG_FILTER_NEAREST_MIPMAP_LINEARcxx . . $ SG_FILTER_NEAREST_MIPMAP_LINEAR.: return GL_NEAREST_MIPMAP_LINEARcxx . . $ `<external>/11565930711847777359/gl.h:634:9`!;
3666 case SG_FILTER_LINEAR_MIPMAP_NEARESTcxx . . $ SG_FILTER_LINEAR_MIPMAP_NEAREST.: return GL_LINEAR_MIPMAP_NEARESTcxx . . $ `<external>/11565930711847777359/gl.h:635:9`!;
3667 case SG_FILTER_LINEAR_MIPMAP_LINEARcxx . . $ SG_FILTER_LINEAR_MIPMAP_LINEAR.: return GL_LINEAR_MIPMAP_LINEARcxx . . $ `<external>/11565930711847777359/gl.h:636:9`!;
3668 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3669 }
3670 }
3671
3672 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_wrapcxx . . $ _sg_gl_wrap(97db5587aa7df795).(sg_wrapcxx . . $ sg_wrap# w) {
3673 switch (w) {
3674 case SG_WRAP_CLAMP_TO_EDGEcxx . . $ SG_WRAP_CLAMP_TO_EDGE.: return GL_CLAMP_TO_EDGEcxx . . $ `<external>/11565930711847777359/gl.h:1447:9`!;
3675 case SG_WRAP_REPEATcxx . . $ SG_WRAP_REPEAT.: return GL_REPEATcxx . . $ `<external>/11565930711847777359/gl.h:645:9`!;
3676 case SG_WRAP_MIRRORED_REPEATcxx . . $ SG_WRAP_MIRRORED_REPEAT.: return GL_MIRRORED_REPEATcxx . . $ `<external>/13868558256673015710/glext.h:308:9`!;
3677 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3678 }
3679 }
3680
3681 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_teximage_typecxx . . $ _sg_gl_teximage_type(fef9f3d4b5a4d063).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3682 switch (fmt) {
3683 case SG_PIXELFORMAT_RGBA32Fcxx . . $ SG_PIXELFORMAT_RGBA32F.:
3684 case SG_PIXELFORMAT_R32Fcxx . . $ SG_PIXELFORMAT_R32F.:
3685 return GL_FLOATcxx . . $ `<external>/11565930711847777359/gl.h:149:9`!;
3686 case SG_PIXELFORMAT_RGBA16Fcxx . . $ SG_PIXELFORMAT_RGBA16F.:
3687 case SG_PIXELFORMAT_R16Fcxx . . $ SG_PIXELFORMAT_R16F.:
3688 return GL_HALF_FLOATcxx . . $ `<external>/13868558256673015710/glext.h:1065:9`!;
3689 case SG_PIXELFORMAT_RGBA8cxx . . $ SG_PIXELFORMAT_RGBA8.:
3690 case SG_PIXELFORMAT_RGB8cxx . . $ SG_PIXELFORMAT_RGB8.:
3691 case SG_PIXELFORMAT_L8cxx . . $ SG_PIXELFORMAT_L8.:
3692 return GL_UNSIGNED_BYTEcxx . . $ `<external>/11565930711847777359/gl.h:144:9`!;
3693 case SG_PIXELFORMAT_R10G10B10A2cxx . . $ SG_PIXELFORMAT_R10G10B10A2.:
3694 return GL_UNSIGNED_INT_2_10_10_10_REVcxx . . $ `<external>/11565930711847777359/gl.h:1463:9`!;
3695 case SG_PIXELFORMAT_R5G5B5A1cxx . . $ SG_PIXELFORMAT_R5G5B5A1.:
3696 return GL_UNSIGNED_SHORT_5_5_5_1cxx . . $ `<external>/11565930711847777359/gl.h:1458:9`!;
3697 case SG_PIXELFORMAT_R5G6B5cxx . . $ SG_PIXELFORMAT_R5G6B5.:
3698 return GL_UNSIGNED_SHORT_5_6_5cxx . . $ `<external>/11565930711847777359/gl.h:1454:9`!;
3699 case SG_PIXELFORMAT_RGBA4cxx . . $ SG_PIXELFORMAT_RGBA4.:
3700 return GL_UNSIGNED_SHORT_4_4_4_4cxx . . $ `<external>/11565930711847777359/gl.h:1456:9`!;
3701 case SG_PIXELFORMAT_DEPTHcxx . . $ SG_PIXELFORMAT_DEPTH.:
3702 /* FIXME */
3703 return GL_UNSIGNED_SHORTcxx . . $ `<external>/11565930711847777359/gl.h:146:9`!;
3704 case SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.:
3705 /* FIXME */
3706 return GL_UNSIGNED_INT_24_8cxx . . $ `<external>/13868558256673015710/glext.h:982:9`!;
3707 default:
3708 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3709 }
3710 }
3711
3712 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_teximage_formatcxx . . $ _sg_gl_teximage_format(fef9f3d4b5a4d063).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3713 switch (fmt) {
3714 case SG_PIXELFORMAT_NONEcxx . . $ SG_PIXELFORMAT_NONE.:
3715 return 0;
3716 case SG_PIXELFORMAT_RGBA8cxx . . $ SG_PIXELFORMAT_RGBA8.:
3717 case SG_PIXELFORMAT_R5G5B5A1cxx . . $ SG_PIXELFORMAT_R5G5B5A1.:
3718 case SG_PIXELFORMAT_RGBA4cxx . . $ SG_PIXELFORMAT_RGBA4.:
3719 case SG_PIXELFORMAT_RGBA32Fcxx . . $ SG_PIXELFORMAT_RGBA32F.:
3720 case SG_PIXELFORMAT_RGBA16Fcxx . . $ SG_PIXELFORMAT_RGBA16F.:
3721 case SG_PIXELFORMAT_R10G10B10A2cxx . . $ SG_PIXELFORMAT_R10G10B10A2.:
3722 return GL_RGBAcxx . . $ `<external>/11565930711847777359/gl.h:469:9`!;
3723 case SG_PIXELFORMAT_RGB8cxx . . $ SG_PIXELFORMAT_RGB8.:
3724 case SG_PIXELFORMAT_R5G6B5cxx . . $ SG_PIXELFORMAT_R5G6B5.:
3725 return GL_RGBcxx . . $ `<external>/11565930711847777359/gl.h:468:9`!;
3726 case SG_PIXELFORMAT_L8cxx . . $ SG_PIXELFORMAT_L8.:
3727 case SG_PIXELFORMAT_R32Fcxx . . $ SG_PIXELFORMAT_R32F.:
3728 case SG_PIXELFORMAT_R16Fcxx . . $ SG_PIXELFORMAT_R16F.:
3729 #if defined(SOKOL_GLES2)
3730 return GL_LUMINANCE;
3731 #else
3732 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
3733 return GL_LUMINANCEcxx . . $ `<external>/11565930711847777359/gl.h:450:9`!;
3734 }
3735 else {
3736 return GL_REDcxx . . $ `<external>/11565930711847777359/gl.h:446:9`!;
3737 }
3738 #endif
3739 case SG_PIXELFORMAT_DEPTHcxx . . $ SG_PIXELFORMAT_DEPTH.:
3740 return GL_DEPTH_COMPONENTcxx . . $ `<external>/11565930711847777359/gl.h:273:9`!;
3741 case SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.:
3742 return GL_DEPTH_STENCILcxx . . $ `<external>/13868558256673015710/glext.h:981:9`!;
3743 case SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.:
3744 return GL_COMPRESSED_RGBA_S3TC_DXT1_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8384:9`!;
3745 case SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.:
3746 return GL_COMPRESSED_RGBA_S3TC_DXT3_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8385:9`!;
3747 case SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.:
3748 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8386:9`!;
3749 case SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.:
3750 return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2046:13`!;
3751 case SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.:
3752 return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2049:13`!;
3753 case SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.:
3754 return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2052:13`!;
3755 case SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.:
3756 return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2055:13`!;
3757 case SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.:
3758 return GL_COMPRESSED_RGB8_ETC2cxx . . $ `<external>/13868558256673015710/glext.h:2153:9`!;
3759 case SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.:
3760 return GL_COMPRESSED_SRGB8_ETC2cxx . . $ `<external>/13868558256673015710/glext.h:2154:9`!;
3761 default:
3762 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3763 }
3764 }
3765
3766 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_teximage_internal_formatcxx . . $ _sg_gl_teximage_internal_format(fef9f3d4b5a4d063).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3767 #if defined(SOKOL_GLES2)
3768 return _sg_gl_teximage_format(fmt);
3769 #else
3770 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
3771 return _sg_gl_teximage_formatcxx . . $ _sg_gl_teximage_format(fef9f3d4b5a4d063).(fmt);
3772 }
3773 else {
3774 switch (fmt) {
3775 case SG_PIXELFORMAT_NONEcxx . . $ SG_PIXELFORMAT_NONE.:
3776 return 0;
3777 case SG_PIXELFORMAT_RGBA8cxx . . $ SG_PIXELFORMAT_RGBA8.:
3778 return GL_RGBA8cxx . . $ `<external>/11565930711847777359/gl.h:728:9`!;
3779 case SG_PIXELFORMAT_RGB8cxx . . $ SG_PIXELFORMAT_RGB8.:
3780 return GL_RGB8cxx . . $ `<external>/11565930711847777359/gl.h:721:9`!;
3781 case SG_PIXELFORMAT_RGBA4cxx . . $ SG_PIXELFORMAT_RGBA4.:
3782 return GL_RGBA4cxx . . $ `<external>/11565930711847777359/gl.h:726:9`!;
3783 case SG_PIXELFORMAT_R5G6B5cxx . . $ SG_PIXELFORMAT_R5G6B5.:
3784 #if defined(SOKOL_GLES3)
3785 return GL_RGB565;
3786 #else
3787 return GL_RGB5cxx . . $ `<external>/11565930711847777359/gl.h:720:9`!;
3788 #endif
3789 case SG_PIXELFORMAT_R5G5B5A1cxx . . $ SG_PIXELFORMAT_R5G5B5A1.:
3790 return GL_RGB5_A1cxx . . $ `<external>/11565930711847777359/gl.h:727:9`!;
3791 case SG_PIXELFORMAT_R10G10B10A2cxx . . $ SG_PIXELFORMAT_R10G10B10A2.:
3792 return GL_RGB10_A2cxx . . $ `<external>/11565930711847777359/gl.h:729:9`!;
3793 case SG_PIXELFORMAT_RGBA32Fcxx . . $ SG_PIXELFORMAT_RGBA32F.:
3794 return GL_RGBA32Fcxx . . $ `<external>/13868558256673015710/glext.h:882:9`!;
3795 case SG_PIXELFORMAT_RGBA16Fcxx . . $ SG_PIXELFORMAT_RGBA16F.:
3796 return GL_RGBA16Fcxx . . $ `<external>/13868558256673015710/glext.h:884:9`!;
3797 case SG_PIXELFORMAT_R32Fcxx . . $ SG_PIXELFORMAT_R32F.:
3798 return GL_R32Fcxx . . $ `<external>/13868558256673015710/glext.h:1083:9`!;
3799 case SG_PIXELFORMAT_R16Fcxx . . $ SG_PIXELFORMAT_R16F.:
3800 return GL_R16Fcxx . . $ `<external>/13868558256673015710/glext.h:1082:9`!;
3801 case SG_PIXELFORMAT_L8cxx . . $ SG_PIXELFORMAT_L8.:
3802 return GL_R8cxx . . $ `<external>/13868558256673015710/glext.h:1078:9`!;
3803 case SG_PIXELFORMAT_DEPTHcxx . . $ SG_PIXELFORMAT_DEPTH.:
3804 /* FIXME */
3805 return GL_DEPTH_COMPONENT16cxx . . $ `<external>/13868558256673015710/glext.h:305:9`!;
3806 case SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.:
3807 return GL_DEPTH24_STENCIL8cxx . . $ `<external>/13868558256673015710/glext.h:983:9`!;
3808 case SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.:
3809 return GL_COMPRESSED_RGBA_S3TC_DXT1_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8384:9`!;
3810 case SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.:
3811 return GL_COMPRESSED_RGBA_S3TC_DXT3_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8385:9`!;
3812 case SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.:
3813 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8386:9`!;
3814 case SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.:
3815 return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2046:13`!;
3816 case SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.:
3817 return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2049:13`!;
3818 case SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.:
3819 return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2052:13`!;
3820 case SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.:
3821 return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMGcxx . . $ `demo/sokol/sokol_gfx.h:2055:13`!;
3822 case SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.:
3823 return GL_COMPRESSED_RGB8_ETC2cxx . . $ `<external>/13868558256673015710/glext.h:2153:9`!;
3824 case SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.:
3825 return GL_COMPRESSED_SRGB8_ETC2cxx . . $ `<external>/13868558256673015710/glext.h:2154:9`!;
3826 default:
3827 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3828 }
3829 }
3830 #endif
3831 }
3832
3833 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_cubeface_targetcxx . . $ _sg_gl_cubeface_target(46cc46841198e427).(int face_index) {
3834 switch (face_index) {
3835 case 0: return GL_TEXTURE_CUBE_MAP_POSITIVE_Xcxx . . $ `<external>/11565930711847777359/gl.h:1754:9`!;
3836 case 1: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Xcxx . . $ `<external>/11565930711847777359/gl.h:1755:9`!;
3837 case 2: return GL_TEXTURE_CUBE_MAP_POSITIVE_Ycxx . . $ `<external>/11565930711847777359/gl.h:1756:9`!;
3838 case 3: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Ycxx . . $ `<external>/11565930711847777359/gl.h:1757:9`!;
3839 case 4: return GL_TEXTURE_CUBE_MAP_POSITIVE_Zcxx . . $ `<external>/11565930711847777359/gl.h:1758:9`!;
3840 case 5: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Zcxx . . $ `<external>/11565930711847777359/gl.h:1759:9`!;
3841 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3842 }
3843 }
3844
3845 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLenumcxx . . $ GLenum# _sg_gl_depth_attachment_formatcxx . . $ _sg_gl_depth_attachment_format(fef9f3d4b5a4d063).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
3846 switch (fmt) {
3847 case SG_PIXELFORMAT_DEPTHcxx . . $ SG_PIXELFORMAT_DEPTH.: return GL_DEPTH_COMPONENT16cxx . . $ `<external>/13868558256673015710/glext.h:305:9`!;
3848 case SG_PIXELFORMAT_DEPTHSTENCILcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.: return GL_DEPTH24_STENCIL8cxx . . $ `<external>/13868558256673015710/glext.h:983:9`!;
3849 default: SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!; return 0;
3850 }
3851 }
3852
3853 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_init_attrcxx . . $ _sg_gl_init_attr(236bf5fc5d0da97e).(_sg_gl_attr_tcxx . . $ _sg_gl_attr_t#* attr) {
3854 attr->vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index. = -1;
3855 attr->divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor. = -1;
3856 }
3857
3858 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_init_stencil_statecxx . . $ _sg_gl_init_stencil_state(53c617e882e82cbc).(sg_stencil_statecxx . . $ sg_stencil_state#* s) {
3859 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(s);
3860 s->fail_opcxx . . $ sg_stencil_state#fail_op. = SG_STENCILOP_KEEPcxx . . $ SG_STENCILOP_KEEP.;
3861 s->depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op. = SG_STENCILOP_KEEPcxx . . $ SG_STENCILOP_KEEP.;
3862 s->pass_opcxx . . $ sg_stencil_state#pass_op. = SG_STENCILOP_KEEPcxx . . $ SG_STENCILOP_KEEP.;
3863 s->compare_funccxx . . $ sg_stencil_state#compare_func. = SG_COMPAREFUNC_ALWAYScxx . . $ SG_COMPAREFUNC_ALWAYS.;
3864 }
3865
3866 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_init_depth_stencil_statecxx . . $ _sg_gl_init_depth_stencil_state(be549bbedd65273a).(sg_depth_stencil_statecxx . . $ sg_depth_stencil_state#* s) {
3867 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(s);
3868 _sg_gl_init_stencil_statecxx . . $ _sg_gl_init_stencil_state(53c617e882e82cbc).(&s->stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front.);
3869 _sg_gl_init_stencil_statecxx . . $ _sg_gl_init_stencil_state(53c617e882e82cbc).(&s->stencil_backcxx . . $ sg_depth_stencil_state#stencil_back.);
3870 s->depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func. = SG_COMPAREFUNC_ALWAYScxx . . $ SG_COMPAREFUNC_ALWAYS.;
3871 }
3872
3873 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_init_blend_statecxx . . $ _sg_gl_init_blend_state(2872c8f26efe14c4).(sg_blend_statecxx . . $ sg_blend_state#* s) {
3874 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(s);
3875 s->src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb. = SG_BLENDFACTOR_ONEcxx . . $ SG_BLENDFACTOR_ONE.;
3876 s->dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb. = SG_BLENDFACTOR_ZEROcxx . . $ SG_BLENDFACTOR_ZERO.;
3877 s->op_rgbcxx . . $ sg_blend_state#op_rgb. = SG_BLENDOP_ADDcxx . . $ SG_BLENDOP_ADD.;
3878 s->src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha. = SG_BLENDFACTOR_ONEcxx . . $ SG_BLENDFACTOR_ONE.;
3879 s->dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha. = SG_BLENDFACTOR_ZEROcxx . . $ SG_BLENDFACTOR_ZERO.;
3880 s->op_alphacxx . . $ sg_blend_state#op_alpha. = SG_BLENDOP_ADDcxx . . $ SG_BLENDOP_ADD.;
3881 s->color_write_maskcxx . . $ sg_blend_state#color_write_mask. = SG_COLORMASK_RGBAcxx . . $ SG_COLORMASK_RGBA.;
3882 }
3883
3884 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_init_rasterizer_statecxx . . $ _sg_gl_init_rasterizer_state(358219e382d3419e).(sg_rasterizer_statecxx . . $ sg_rasterizer_state#* s) {
3885 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(s);
3886 s->cull_modecxx . . $ sg_rasterizer_state#cull_mode. = SG_CULLMODE_NONEcxx . . $ SG_CULLMODE_NONE.;
3887 s->face_windingcxx . . $ sg_rasterizer_state#face_winding. = SG_FACEWINDING_CWcxx . . $ SG_FACEWINDING_CW.;
3888 s->sample_countcxx . . $ sg_rasterizer_state#sample_count. = 1;
3889 }
3890
3891 /*-- state cache implementation ----------------------------------------------*/
3892 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_clear_buffer_bindingscxx . . $ _sg_gl_clear_buffer_bindings(b45ddcbc8423892c).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! force) {
3893 if (force || (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#vertex_buffer. != 0)) {
3894 glBindBuffercxx . . $ glBindBuffer(b4d55b1286ff73e8).(GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`!, 0);
3895 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#vertex_buffer. = 0;
3896 }
3897 if (force || (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#index_buffer. != 0)) {
3898 glBindBuffercxx . . $ glBindBuffer(b4d55b1286ff73e8).(GL_ELEMENT_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:459:9`!, 0);
3899 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#index_buffer. = 0;
3900 }
3901 }
3902
3903 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(GLenumcxx . . $ GLenum# target, GLuintcxx . . $ GLuint# buffer) {
3904 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`! == target) || (GL_ELEMENT_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:459:9`! == target));
3905 if (target == GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`!) {
3906 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#vertex_buffer. != buffer) {
3907 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#vertex_buffer. = buffer;
3908 glBindBuffercxx . . $ glBindBuffer(b4d55b1286ff73e8).(target, buffer);
3909 }
3910 }
3911 else {
3912 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#index_buffer. != buffer) {
3913 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#index_buffer. = buffer;
3914 glBindBuffercxx . . $ glBindBuffer(b4d55b1286ff73e8).(target, buffer);
3915 }
3916 }
3917 }
3918
3919 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_store_buffer_bindingcxx . . $ _sg_gl_store_buffer_binding(cb2f890c2fdad230).(GLenumcxx . . $ GLenum# target) {
3920 if (target == GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`!) {
3921 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..stored_vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_vertex_buffer. = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#vertex_buffer.;
3922 }
3923 else {
3924 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..stored_index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_index_buffer. = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#index_buffer.;
3925 }
3926 }
3927
3928 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_restore_buffer_bindingcxx . . $ _sg_gl_restore_buffer_binding(cb2f890c2fdad230).(GLenumcxx . . $ GLenum# target) {
3929 if (target == GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`!) {
3930 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(target, _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..stored_vertex_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_vertex_buffer.);
3931 }
3932 else {
3933 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(target, _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..stored_index_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_index_buffer.);
3934 }
3935 }
3936
3937 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_clear_texture_bindingscxx . . $ _sg_gl_clear_texture_bindings(b45ddcbc8423892c).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! force) {
3938 for (int i = 0; (i < SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.) && (i < _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_combined_texture_image_unitscxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_combined_texture_image_units.); i++) {
3939 if (force || (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..texturescxx . . $ $anonymous_type_ded6a5455d648ef8_21#textures.[i].texturecxx . . $ $anonymous_type_ded6a5455d648ef8_20#texture. != 0)) {
3940 glActiveTexturecxx . . $ glActiveTexture(cb2f890c2fdad230).(GL_TEXTURE0cxx . . $ `<external>/11565930711847777359/gl.h:1714:9`! + i);
3941 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!, 0);
3942 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(GL_TEXTURE_CUBE_MAPcxx . . $ `<external>/11565930711847777359/gl.h:1752:9`!, 0);
3943 #if !defined(SOKOL_GLES2)
3944 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
3945 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(GL_TEXTURE_3Dcxx . . $ `<external>/11565930711847777359/gl.h:1481:9`!, 0);
3946 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(GL_TEXTURE_2D_ARRAYcxx . . $ `<external>/13868558256673015710/glext.h:895:9`!, 0);
3947 }
3948 #endif
3949 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..texturescxx . . $ $anonymous_type_ded6a5455d648ef8_21#textures.[i].targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target. = 0;
3950 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..texturescxx . . $ $anonymous_type_ded6a5455d648ef8_21#textures.[i].texturecxx . . $ $anonymous_type_ded6a5455d648ef8_20#texture. = 0;
3951 }
3952 }
3953 }
3954
3955 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_bind_texturecxx . . $ _sg_gl_bind_texture(2029de666eaec704).(int slot_index, GLenumcxx . . $ GLenum# target, GLuintcxx . . $ GLuint# texture) {
3956 /* it's valid to call this function with target=0 and/or texture=0
3957 target=0 will unbind the previous binding, texture=0 will clear
3958 the new binding
3959 */
3960 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(slot_index < SG_MAX_SHADERSTAGE_IMAGES);
3961 if (slot_index >= _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_combined_texture_image_unitscxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_combined_texture_image_units.) {
3962 return;
3963 }
3964 _sg_gl_texture_bind_slotcxx . . $ _sg_gl_texture_bind_slot#* slot = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..texturescxx . . $ $anonymous_type_ded6a5455d648ef8_21#textures.[slot_index];
3965 if ((slot->targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target. != target) || (slot->texturecxx . . $ $anonymous_type_ded6a5455d648ef8_20#texture. != texture)) {
3966 glActiveTexturecxx . . $ glActiveTexture(cb2f890c2fdad230).(GL_TEXTURE0cxx . . $ `<external>/11565930711847777359/gl.h:1714:9`! + slot_index);
3967 /* if the target has changed, clear the previous binding on that target */
3968 if ((target != slot->targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target.) && (slot->targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target. != 0)) {
3969 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(slot->targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target., 0);
3970 }
3971 /* apply new binding (texture can be 0 to unbind) */
3972 if (target != 0) {
3973 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(target, texture);
3974 }
3975 slot->targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target. = target;
3976 slot->texturecxx . . $ $anonymous_type_ded6a5455d648ef8_20#texture. = texture;
3977 }
3978 }
3979
3980 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_store_texture_bindingcxx . . $ _sg_gl_store_texture_binding(d4f767463ce0a6b3).(int slot_index) {
3981 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(slot_index < SG_MAX_SHADERSTAGE_IMAGES);
3982 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..stored_texturecxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_texture. = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..texturescxx . . $ $anonymous_type_ded6a5455d648ef8_21#textures.[slot_index];
3983 }
3984
3985 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_restore_texture_bindingcxx . . $ _sg_gl_restore_texture_binding(d4f767463ce0a6b3).(int slot_index) {
3986 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(slot_index < SG_MAX_SHADERSTAGE_IMAGES);
3987 const _sg_gl_texture_bind_slotcxx . . $ _sg_gl_texture_bind_slot#* slot = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..stored_texturecxx . . $ $anonymous_type_ded6a5455d648ef8_21#stored_texture.;
3988 _sg_gl_bind_texturecxx . . $ _sg_gl_bind_texture(2029de666eaec704).(slot_index, slot->targetcxx . . $ $anonymous_type_ded6a5455d648ef8_20#target., slot->texturecxx . . $ $anonymous_type_ded6a5455d648ef8_20#texture.);
3989 }
3990
3991 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_gl_reset_state_cachecxx . . $ _sg_gl_reset_state_cache(49f6e7a06ebc5aa8).(void) {
3992 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
3993 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache., 0, sizeof(_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache.));
3994 _sg_gl_clear_buffer_bindingscxx . . $ _sg_gl_clear_buffer_bindings(b45ddcbc8423892c).(truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!);
3995 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
3996 _sg_gl_clear_texture_bindingscxx . . $ _sg_gl_clear_texture_bindings(b45ddcbc8423892c).(truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!);
3997 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
3998 for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; i++) {
3999 _sg_gl_init_attrcxx . . $ _sg_gl_init_attr(236bf5fc5d0da97e).(&_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..attrscxx . . $ $anonymous_type_ded6a5455d648ef8_21#attrs.[i].gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr.);
4000 glDisableVertexAttribArraycxx . . $ glDisableVertexAttribArray(cb2f890c2fdad230).(i);
4001 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4002 }
4003 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_primitive_type. = GL_TRIANGLEScxx . . $ `<external>/11565930711847777359/gl.h:160:9`!;
4004
4005 /* depth-stencil state */
4006 _sg_gl_init_depth_stencil_statecxx . . $ _sg_gl_init_depth_stencil_state(be549bbedd65273a).(&_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds.);
4007 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_DEPTH_TESTcxx . . $ `<external>/11565930711847777359/gl.h:267:9`!);
4008 glDepthFunccxx . . $ glDepthFunc(cb2f890c2fdad230).(GL_ALWAYScxx . . $ `<external>/11565930711847777359/gl.h:266:9`!);
4009 glDepthMaskcxx . . $ glDepthMask(ac50b47256ae7414).(GL_FALSEcxx . . $ `<external>/11565930711847777359/gl.h:139:9`!);
4010 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_STENCIL_TESTcxx . . $ `<external>/11565930711847777359/gl.h:415:9`!);
4011 glStencilFunccxx . . $ glStencilFunc(c83e9f6c46f9406d).(GL_ALWAYScxx . . $ `<external>/11565930711847777359/gl.h:266:9`!, 0, 0);
4012 glStencilOpcxx . . $ glStencilOp(6df00707c193238d).(GL_KEEPcxx . . $ `<external>/11565930711847777359/gl.h:425:9`!, GL_KEEPcxx . . $ `<external>/11565930711847777359/gl.h:425:9`!, GL_KEEPcxx . . $ `<external>/11565930711847777359/gl.h:425:9`!);
4013 glStencilMaskcxx . . $ glStencilMask(cb2f890c2fdad230).(0);
4014
4015 /* blend state */
4016 _sg_gl_init_blend_statecxx . . $ _sg_gl_init_blend_state(2872c8f26efe14c4).(&_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..blendcxx . . $ $anonymous_type_ded6a5455d648ef8_21#blend.);
4017 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_BLENDcxx . . $ `<external>/11565930711847777359/gl.h:337:9`!);
4018 glBlendFuncSeparatecxx . . $ glBlendFuncSeparate(eda338842932bf2b).(GL_ONEcxx . . $ `<external>/11565930711847777359/gl.h:341:9`!, GL_ZEROcxx . . $ `<external>/11565930711847777359/gl.h:340:9`!, GL_ONEcxx . . $ `<external>/11565930711847777359/gl.h:341:9`!, GL_ZEROcxx . . $ `<external>/11565930711847777359/gl.h:340:9`!);
4019 glBlendEquationSeparatecxx . . $ glBlendEquationSeparate(b4d55b1286ff73e8).(GL_FUNC_ADDcxx . . $ `<external>/13868558256673015710/glext.h:345:9`!, GL_FUNC_ADDcxx . . $ `<external>/13868558256673015710/glext.h:345:9`!);
4020 glColorMaskcxx . . $ glColorMask(bfb537490240b335).(GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!, GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!, GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!, GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!);
4021 glBlendColorcxx . . $ glBlendColor(7e9a355db6148521).(0.0f, 0.0f, 0.0f, 0.0f);
4022
4023 /* rasterizer state */
4024 _sg_gl_init_rasterizer_statecxx . . $ _sg_gl_init_rasterizer_state(358219e382d3419e).(&_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..rastcxx . . $ $anonymous_type_ded6a5455d648ef8_21#rast.);
4025 glPolygonOffsetcxx . . $ glPolygonOffset(5102ef758adc0ae7).(0.0f, 0.0f);
4026 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_POLYGON_OFFSET_FILLcxx . . $ `<external>/11565930711847777359/gl.h:249:9`!);
4027 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_CULL_FACEcxx . . $ `<external>/11565930711847777359/gl.h:242:9`!);
4028 glFrontFacecxx . . $ glFrontFace(cb2f890c2fdad230).(GL_CWcxx . . $ `<external>/11565930711847777359/gl.h:234:9`!);
4029 glCullFacecxx . . $ glCullFace(cb2f890c2fdad230).(GL_BACKcxx . . $ `<external>/11565930711847777359/gl.h:237:9`!);
4030 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_SCISSOR_TESTcxx . . $ `<external>/11565930711847777359/gl.h:555:9`!);
4031 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_SAMPLE_ALPHA_TO_COVERAGEcxx . . $ `<external>/11565930711847777359/gl.h:1776:9`!);
4032 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_DITHERcxx . . $ `<external>/11565930711847777359/gl.h:467:9`!);
4033 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_POLYGON_OFFSET_FILLcxx . . $ `<external>/11565930711847777359/gl.h:249:9`!);
4034 #if defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!)
4035 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_MULTISAMPLEcxx . . $ `<external>/11565930711847777359/gl.h:1775:9`!);
4036 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_PROGRAM_POINT_SIZEcxx . . $ `<external>/13868558256673015710/glext.h:1376:9`!);
4037 #endif
4038 }
4039
4040 /*-- main GL backend state and functions -------------------------------------*/
4041
4042 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_setup_backendcxx . . $ _sg_setup_backend(14daf3ac2a73e58e).(const sg_desccxx . . $ sg_desc#* desc) {
4043 /* assumes that _sg.gl is already zero-initialized */
4044 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..validcxx . . $ $anonymous_type_ded6a5455d648ef8_22#valid. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4045 #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
4046 _sg.gl.gles2 = desc->gl_force_gles2;
4047 #else
4048 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(desc);
4049 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
4050 #endif
4051
4052 /* clear initial GL error state */
4053 #if defined(SOKOL_DEBUG)
4054 while (glGetError() != GL_NO_ERROR);
4055 #endif
4056
4057 /* initialize feature flags */
4058 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_ORIGIN_BOTTOM_LEFTcxx . . $ SG_FEATURE_ORIGIN_BOTTOM_LEFT.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4059 #if defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!)
4060 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_INSTANCINGcxx . . $ SG_FEATURE_INSTANCING.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4061 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_TEXTURE_FLOATcxx . . $ SG_FEATURE_TEXTURE_FLOAT.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4062 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_TEXTURE_HALF_FLOATcxx . . $ SG_FEATURE_TEXTURE_HALF_FLOAT.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4063 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_MSAA_RENDER_TARGETScxx . . $ SG_FEATURE_MSAA_RENDER_TARGETS.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4064 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_PACKED_VERTEX_FORMAT_10_2cxx . . $ SG_FEATURE_PACKED_VERTEX_FORMAT_10_2.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4065 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_MULTIPLE_RENDER_TARGETcxx . . $ SG_FEATURE_MULTIPLE_RENDER_TARGET.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4066 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_IMAGETYPE_3Dcxx . . $ SG_FEATURE_IMAGETYPE_3D.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4067 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_IMAGETYPE_ARRAYcxx . . $ SG_FEATURE_IMAGETYPE_ARRAY.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4068 GLintcxx . . $ GLint# num_ext = 0;
4069 glGetIntegervcxx . . $ glGetIntegerv(1740d062d6b6475a).(GL_NUM_EXTENSIONScxx . . $ `<external>/13868558256673015710/glext.h:877:9`!, &num_ext);
4070 for (int i = 0; i < num_ext; i++) {
4071 const char* ext = (const char*) glGetStringicxx . . $ glGetStringi(f3e0d75d7e950b64).(GL_EXTENSIONScxx . . $ `<external>/11565930711847777359/gl.h:656:9`!, i);
4072 if (ext) {
4073 if (strstrcxx . . $ strstr(a713fe7b9a57cf96).(ext, "_texture_compression_s3tc")) {
4074 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_TEXTURE_COMPRESSION_DXTcxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_DXT.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4075 continue;
4076 }
4077 else if (strstrcxx . . $ strstr(a713fe7b9a57cf96).(ext, "_texture_filter_anisotropic")) {
4078 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..ext_anisotropiccxx . . $ $anonymous_type_ded6a5455d648ef8_22#ext_anisotropic. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4079 continue;
4080 }
4081 }
4082 }
4083 #elif defined(SOKOL_GLES3)
4084 const char* ext = (const char*) glGetString(GL_EXTENSIONS);
4085 if (ext) {
4086 if (!_sg.gl.gles2) {
4087 _sg.gl.features[SG_FEATURE_INSTANCING] = true;
4088 _sg.gl.features[SG_FEATURE_TEXTURE_FLOAT] = true;
4089 _sg.gl.features[SG_FEATURE_TEXTURE_HALF_FLOAT] = true;
4090 _sg.gl.features[SG_FEATURE_IMAGETYPE_3D] = true;
4091 _sg.gl.features[SG_FEATURE_IMAGETYPE_ARRAY] = true;
4092 _sg.gl.features[SG_FEATURE_MSAA_RENDER_TARGETS] = true;
4093 _sg.gl.features[SG_FEATURE_PACKED_VERTEX_FORMAT_10_2] = true;
4094 _sg.gl.features[SG_FEATURE_MULTIPLE_RENDER_TARGET] = true;
4095 }
4096 else {
4097 _sg.gl.features[SG_FEATURE_INSTANCING] = strstr(ext, "_instanced_arrays");
4098 _sg.gl.features[SG_FEATURE_TEXTURE_FLOAT] = strstr(ext, "_texture_float");
4099 _sg.gl.features[SG_FEATURE_TEXTURE_HALF_FLOAT] = strstr(ext, "_texture_half_float");
4100 }
4101 _sg.gl.features[SG_FEATURE_TEXTURE_COMPRESSION_DXT] =
4102 strstr(ext, "_texture_compression_s3tc") ||
4103 strstr(ext, "_compressed_texture_s3tc") ||
4104 strstr(ext, "texture_compression_dxt1");
4105 _sg.gl.features[SG_FEATURE_TEXTURE_COMPRESSION_PVRTC] =
4106 strstr(ext, "_texture_compression_pvrtc") ||
4107 strstr(ext, "_compressed_texture_pvrtc");
4108 _sg.gl.features[SG_FEATURE_TEXTURE_COMPRESSION_ATC] =
4109 strstr(ext, "_compressed_texture_atc");
4110 _sg.gl.ext_anisotropic =
4111 strstr(ext, "_texture_filter_anisotropic");
4112 }
4113 #elif defined(SOKOL_GLES2)
4114 const char* ext = (const char*) glGetString(GL_EXTENSIONS);
4115 if (ext) {
4116 _sg.gl.features[SG_FEATURE_INSTANCING] =
4117 strstr(ext, "_instanced_arrays");
4118 _sg.gl.features[SG_FEATURE_TEXTURE_FLOAT] =
4119 strstr(ext, "_texture_float");
4120 _sg.gl.features[SG_FEATURE_TEXTURE_HALF_FLOAT] =
4121 strstr(ext, "_texture_half_float");
4122 _sg.gl.features[SG_FEATURE_TEXTURE_COMPRESSION_DXT] =
4123 strstr(ext, "_texture_compression_s3tc") ||
4124 strstr(ext, "_compressed_texture_s3tc") ||
4125 strstr(ext, "texture_compression_dxt1");
4126 _sg.gl.features[SG_FEATURE_TEXTURE_COMPRESSION_PVRTC] =
4127 strstr(ext, "_texture_compression_pvrtc") ||
4128 strstr(ext, "_compressed_texture_pvrtc");
4129 _sg.gl.features[SG_FEATURE_TEXTURE_COMPRESSION_ATC] =
4130 strstr(ext, "_compressed_texture_atc");
4131 _sg.gl.ext_anisotropic =
4132 strstr(ext, "_texture_filter_anisotropic");
4133 }
4134 #endif
4135 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_anisotropy. = 1;
4136 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..ext_anisotropiccxx . . $ $anonymous_type_ded6a5455d648ef8_22#ext_anisotropic.) {
4137 glGetIntegervcxx . . $ glGetIntegerv(1740d062d6b6475a).(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8443:9`!, &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_anisotropy.);
4138 }
4139 glGetIntegervcxx . . $ glGetIntegerv(1740d062d6b6475a).(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITScxx . . $ `<external>/13868558256673015710/glext.h:586:9`!, &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_combined_texture_image_unitscxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_combined_texture_image_units.);
4140 }
4141
4142 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_discard_backendcxx . . $ _sg_discard_backend(49f6e7a06ebc5aa8).(void) {
4143 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.valid);
4144 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..validcxx . . $ $anonymous_type_ded6a5455d648ef8_22#valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
4145 }
4146
4147 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_state_cachecxx . . $ _sg_reset_state_cache(49f6e7a06ebc5aa8).(void) {
4148 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_context.) {
4149 #if !defined(SOKOL_GLES2)
4150 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4151 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4152 glBindVertexArraycxx . . $ glBindVertexArray(cb2f890c2fdad230).(_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_context.->vaocxx . . $ $anonymous_type_ded6a5455d648ef8_18#vao.);
4153 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4154 }
4155 #endif
4156 _sg_gl_reset_state_cachecxx . . $ _sg_gl_reset_state_cache(49f6e7a06ebc5aa8).();
4157 }
4158 }
4159
4160 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_query_featurecxx . . $ _sg_query_feature(11c85d13deabec9).(sg_featurecxx . . $ sg_feature# f) {
4161 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((f>=0) && (f<SG_NUM_FEATURES));
4162 return _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[f];
4163 }
4164
4165 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_activate_contextcxx . . $ _sg_activate_context(5fcb436f3d2e1e3f).(_sg_context_tcxx . . $ _sg_context_t#* ctx) {
4166 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.valid);
4167 /* NOTE: ctx can be 0 to unset the current context */
4168 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_context. = ctx;
4169 _sg_reset_state_cachecxx . . $ _sg_reset_state_cache(49f6e7a06ebc5aa8).();
4170 }
4171
4172 /*-- GL backend resource creation and destruction ----------------------------*/
4173 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_resource_statecxx . . $ sg_resource_state# _sg_create_contextcxx . . $ _sg_create_context(d8db2a13df6d6f41).(_sg_context_tcxx . . $ _sg_context_t#* ctx) {
4174 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ctx);
4175 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(0 == ctx->default_framebuffer);
4176 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4177 glGetIntegervcxx . . $ glGetIntegerv(1740d062d6b6475a).(GL_FRAMEBUFFER_BINDINGcxx . . $ `<external>/13868558256673015710/glext.h:991:9`!, (GLintcxx . . $ GLint#*)&ctx->default_framebuffercxx . . $ $anonymous_type_ded6a5455d648ef8_18#default_framebuffer.);
4178 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4179 #if !defined(SOKOL_GLES2)
4180 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4181 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(0 == ctx->vao);
4182 glGenVertexArrayscxx . . $ glGenVertexArrays(e2a7cb9a6f2acdbc).(1, &ctx->vaocxx . . $ $anonymous_type_ded6a5455d648ef8_18#vao.);
4183 glBindVertexArraycxx . . $ glBindVertexArray(cb2f890c2fdad230).(ctx->vaocxx . . $ $anonymous_type_ded6a5455d648ef8_18#vao.);
4184 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4185 }
4186 #endif
4187 return SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.;
4188 }
4189
4190 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_contextcxx . . $ _sg_destroy_context(5fcb436f3d2e1e3f).(_sg_context_tcxx . . $ _sg_context_t#* ctx) {
4191 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ctx);
4192 #if !defined(SOKOL_GLES2)
4193 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4194 if (ctx->vaocxx . . $ $anonymous_type_ded6a5455d648ef8_18#vao.) {
4195 glDeleteVertexArrayscxx . . $ glDeleteVertexArrays(5becf8d0d67ba4cc).(1, &ctx->vaocxx . . $ $anonymous_type_ded6a5455d648ef8_18#vao.);
4196 }
4197 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4198 }
4199 #endif
4200 }
4201
4202 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_resource_statecxx . . $ sg_resource_state# _sg_create_buffercxx . . $ _sg_create_buffer(e4de7721254dd384).(_sg_buffer_tcxx . . $ _sg_buffer_t#* buf, const sg_buffer_desccxx . . $ sg_buffer_desc#* desc) {
4203 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf && desc);
4204 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4205 buf->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_6#size. = desc->sizecxx . . $ sg_buffer_desc#size.;
4206 buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos. = 0;
4207 buf->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
4208 buf->typecxx . . $ $anonymous_type_ded6a5455d648ef8_6#type. = desc->typecxx . . $ sg_buffer_desc#type.;
4209 buf->usagecxx . . $ $anonymous_type_ded6a5455d648ef8_6#usage. = desc->usagecxx . . $ sg_buffer_desc#usage.;
4210 buf->update_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#update_frame_index. = 0;
4211 buf->append_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_frame_index. = 0;
4212 buf->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots. = (buf->usagecxx . . $ $anonymous_type_ded6a5455d648ef8_6#usage. == SG_USAGE_IMMUTABLEcxx . . $ SG_USAGE_IMMUTABLE.) ? 1 : SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.;
4213 buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot. = 0;
4214 buf->ext_bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_6#ext_buffers. = (0 != desc->gl_bufferscxx . . $ sg_buffer_desc#gl_buffers.[0]);
4215 GLenumcxx . . $ GLenum# gl_target = _sg_gl_buffer_targetcxx . . $ _sg_gl_buffer_target(49ff54eba56abf56).(buf->typecxx . . $ $anonymous_type_ded6a5455d648ef8_6#type.);
4216 GLenumcxx . . $ GLenum# gl_usage = _sg_gl_usagecxx . . $ _sg_gl_usage(ca3a1c046ebfa598).(buf->usagecxx . . $ $anonymous_type_ded6a5455d648ef8_6#usage.);
4217 for (int slot = 0; slot < buf->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots.; slot++) {
4218 GLuintcxx . . $ GLuint# gl_buf = 0;
4219 if (buf->ext_bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_6#ext_buffers.) {
4220 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc->gl_buffers[slot]);
4221 gl_buf = desc->gl_bufferscxx . . $ sg_buffer_desc#gl_buffers.[slot];
4222 }
4223 else {
4224 glGenBufferscxx . . $ glGenBuffers(e2a7cb9a6f2acdbc).(1, &gl_buf);
4225 _sg_gl_store_buffer_bindingcxx . . $ _sg_gl_store_buffer_binding(cb2f890c2fdad230).(gl_target);
4226 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(gl_target, gl_buf);
4227 glBufferDatacxx . . $ glBufferData(3399298ed49618dc).(gl_target, buf->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_6#size., 0, gl_usage);
4228 if (buf->usagecxx . . $ $anonymous_type_ded6a5455d648ef8_6#usage. == SG_USAGE_IMMUTABLEcxx . . $ SG_USAGE_IMMUTABLE.) {
4229 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc->content);
4230 glBufferSubDatacxx . . $ glBufferSubData(5641a406ecdfaca9).(gl_target, 0, buf->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_6#size., desc->contentcxx . . $ sg_buffer_desc#content.);
4231 }
4232 _sg_gl_restore_buffer_bindingcxx . . $ _sg_gl_restore_buffer_binding(cb2f890c2fdad230).(gl_target);
4233 }
4234 buf->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[slot] = gl_buf;
4235 }
4236 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4237 return SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.;
4238 }
4239
4240 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_buffercxx . . $ _sg_destroy_buffer(62c890c9336ae806).(_sg_buffer_tcxx . . $ _sg_buffer_t#* buf) {
4241 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf);
4242 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4243 if (!buf->ext_bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_6#ext_buffers.) {
4244 for (int slot = 0; slot < buf->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots.; slot++) {
4245 if (buf->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[slot]) {
4246 glDeleteBufferscxx . . $ glDeleteBuffers(5becf8d0d67ba4cc).(1, &buf->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[slot]);
4247 }
4248 }
4249 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4250 }
4251 }
4252
4253 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_gl_supported_texture_formatcxx . . $ _sg_gl_supported_texture_format(3296e3b3357c429b).(sg_pixel_formatcxx . . $ sg_pixel_format# fmt) {
4254 switch (fmt) {
4255 case SG_PIXELFORMAT_DXT1cxx . . $ SG_PIXELFORMAT_DXT1.:
4256 case SG_PIXELFORMAT_DXT3cxx . . $ SG_PIXELFORMAT_DXT3.:
4257 case SG_PIXELFORMAT_DXT5cxx . . $ SG_PIXELFORMAT_DXT5.:
4258 return _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_TEXTURE_COMPRESSION_DXTcxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_DXT.];
4259 case SG_PIXELFORMAT_PVRTC2_RGBcxx . . $ SG_PIXELFORMAT_PVRTC2_RGB.:
4260 case SG_PIXELFORMAT_PVRTC4_RGBcxx . . $ SG_PIXELFORMAT_PVRTC4_RGB.:
4261 case SG_PIXELFORMAT_PVRTC2_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC2_RGBA.:
4262 case SG_PIXELFORMAT_PVRTC4_RGBAcxx . . $ SG_PIXELFORMAT_PVRTC4_RGBA.:
4263 return _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_TEXTURE_COMPRESSION_PVRTCcxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_PVRTC.];
4264 case SG_PIXELFORMAT_ETC2_RGB8cxx . . $ SG_PIXELFORMAT_ETC2_RGB8.:
4265 case SG_PIXELFORMAT_ETC2_SRGB8cxx . . $ SG_PIXELFORMAT_ETC2_SRGB8.:
4266 return _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_TEXTURE_COMPRESSION_ETC2cxx . . $ SG_FEATURE_TEXTURE_COMPRESSION_ETC2.];
4267 default:
4268 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4269 }
4270 }
4271
4272 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_resource_statecxx . . $ sg_resource_state# _sg_create_imagecxx . . $ _sg_create_image(f00e77058a114b81).(_sg_image_tcxx . . $ _sg_image_t#* img, const sg_image_desccxx . . $ sg_image_desc#* desc) {
4273 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img && desc);
4274 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4275 img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. = desc->typecxx . . $ sg_image_desc#type.;
4276 img->render_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#render_target. = desc->render_targetcxx . . $ sg_image_desc#render_target.;
4277 img->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width. = desc->widthcxx . . $ sg_image_desc#width.;
4278 img->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height. = desc->heightcxx . . $ sg_image_desc#height.;
4279 img->depthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#depth. = desc->depthcxx . . $ sg_image_desc#$anonymous_type_1#depth.;
4280 img->num_mipmapscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_mipmaps. = desc->num_mipmapscxx . . $ sg_image_desc#num_mipmaps.;
4281 img->usagecxx . . $ $anonymous_type_ded6a5455d648ef8_7#usage. = desc->usagecxx . . $ sg_image_desc#usage.;
4282 img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format. = desc->pixel_formatcxx . . $ sg_image_desc#pixel_format.;
4283 img->sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_7#sample_count. = desc->sample_countcxx . . $ sg_image_desc#sample_count.;
4284 img->min_filtercxx . . $ $anonymous_type_ded6a5455d648ef8_7#min_filter. = desc->min_filtercxx . . $ sg_image_desc#min_filter.;
4285 img->mag_filtercxx . . $ $anonymous_type_ded6a5455d648ef8_7#mag_filter. = desc->mag_filtercxx . . $ sg_image_desc#mag_filter.;
4286 img->wrap_ucxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_u. = desc->wrap_ucxx . . $ sg_image_desc#wrap_u.;
4287 img->wrap_vcxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_v. = desc->wrap_vcxx . . $ sg_image_desc#wrap_v.;
4288 img->wrap_wcxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_w. = desc->wrap_wcxx . . $ sg_image_desc#wrap_w.;
4289 img->max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_7#max_anisotropy. = desc->max_anisotropycxx . . $ sg_image_desc#max_anisotropy.;
4290 img->upd_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_7#upd_frame_index. = 0;
4291
4292 /* check if texture format is support */
4293 if (!_sg_gl_supported_texture_formatcxx . . $ _sg_gl_supported_texture_format(3296e3b3357c429b).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.)) {
4294 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("compressed texture format not supported by GL context\n");
4295 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4296 }
4297 /* check for optional texture types */
4298 if ((img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. == SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D.) && !_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_IMAGETYPE_3Dcxx . . $ SG_FEATURE_IMAGETYPE_3D.]) {
4299 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("3D textures not supported by GL context\n");
4300 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4301 }
4302 if ((img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. == SG_IMAGETYPE_ARRAYcxx . . $ SG_IMAGETYPE_ARRAY.) && !_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_IMAGETYPE_ARRAYcxx . . $ SG_FEATURE_IMAGETYPE_ARRAY.]) {
4303 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("array textures not supported by GL context\n");
4304 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4305 }
4306
4307 /* create 1 or 2 GL textures, depending on requested update strategy */
4308 img->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots. = (img->usagecxx . . $ $anonymous_type_ded6a5455d648ef8_7#usage. == SG_USAGE_IMMUTABLEcxx . . $ SG_USAGE_IMMUTABLE.) ? 1 : SG_NUM_INFLIGHT_FRAMEScxx . . $ SG_NUM_INFLIGHT_FRAMES.;
4309 img->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot. = 0;
4310 img->ext_texturescxx . . $ $anonymous_type_ded6a5455d648ef8_7#ext_textures. = (0 != desc->gl_texturescxx . . $ sg_image_desc#gl_textures.[0]);
4311
4312 #if !defined(SOKOL_GLES2)
4313 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! msaa = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
4314 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4315 msaa = (img->sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_7#sample_count. > 1) && (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_MSAA_RENDER_TARGETScxx . . $ SG_FEATURE_MSAA_RENDER_TARGETS.]);
4316 }
4317 #endif
4318
4319 if (_sg_is_valid_rendertarget_depth_formatcxx . . $ _sg_is_valid_rendertarget_depth_format(3296e3b3357c429b).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.)) {
4320 /* special case depth-stencil-buffer? */
4321 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((img->usage == SG_USAGE_IMMUTABLE) && (img->num_slots == 1));
4322 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(!img->ext_textures); /* cannot provide external texture for depth images */
4323 glGenRenderbufferscxx . . $ glGenRenderbuffers(e2a7cb9a6f2acdbc).(1, &img->gl_depth_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_depth_render_buffer.);
4324 glBindRenderbuffercxx . . $ glBindRenderbuffer(b4d55b1286ff73e8).(GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, img->gl_depth_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_depth_render_buffer.);
4325 GLenumcxx . . $ GLenum# gl_depth_format = _sg_gl_depth_attachment_formatcxx . . $ _sg_gl_depth_attachment_format(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
4326 #if !defined(SOKOL_GLES2)
4327 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. && msaa) {
4328 glRenderbufferStorageMultisamplecxx . . $ glRenderbufferStorageMultisample(b5f835bdd59c8f3a).(GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, img->sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_7#sample_count., gl_depth_format, img->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width., img->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height.);
4329 }
4330 else
4331 #endif
4332 {
4333 glRenderbufferStoragecxx . . $ glRenderbufferStorage(3869d588e734bd0e).(GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, gl_depth_format, img->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width., img->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height.);
4334 }
4335 }
4336 else {
4337 /* regular color texture */
4338 img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target. = _sg_gl_texture_targetcxx . . $ _sg_gl_texture_target(5d7eb9a7f9ae8a10).(img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.);
4339 const GLenumcxx . . $ GLenum# gl_internal_format = _sg_gl_teximage_internal_formatcxx . . $ _sg_gl_teximage_internal_format(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
4340
4341 /* if this is a MSAA render target, need to create a separate render buffer */
4342 #if !defined(SOKOL_GLES2)
4343 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. && img->render_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#render_target. && msaa) {
4344 glGenRenderbufferscxx . . $ glGenRenderbuffers(e2a7cb9a6f2acdbc).(1, &img->gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.);
4345 glBindRenderbuffercxx . . $ glBindRenderbuffer(b4d55b1286ff73e8).(GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, img->gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.);
4346 glRenderbufferStorageMultisamplecxx . . $ glRenderbufferStorageMultisample(b5f835bdd59c8f3a).(GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, img->sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_7#sample_count., gl_internal_format, img->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width., img->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height.);
4347 }
4348 #endif
4349
4350 if (img->ext_texturescxx . . $ $anonymous_type_ded6a5455d648ef8_7#ext_textures.) {
4351 /* inject externally GL textures */
4352 for (int slot = 0; slot < img->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots.; slot++) {
4353 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc->gl_textures[slot]);
4354 img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[slot] = desc->gl_texturescxx . . $ sg_image_desc#gl_textures.[slot];
4355 }
4356 }
4357 else {
4358 /* create our own GL texture(s) */
4359 const GLenumcxx . . $ GLenum# gl_format = _sg_gl_teximage_formatcxx . . $ _sg_gl_teximage_format(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
4360 const boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_compressed = _sg_is_compressed_pixel_formatcxx . . $ _sg_is_compressed_pixel_format(3296e3b3357c429b).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
4361 for (int slot = 0; slot < img->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots.; slot++) {
4362 glGenTexturescxx . . $ glGenTextures(e2a7cb9a6f2acdbc).(1, &img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[slot]);
4363 _sg_gl_store_texture_bindingcxx . . $ _sg_gl_store_texture_binding(d4f767463ce0a6b3).(0);
4364 _sg_gl_bind_texturecxx . . $ _sg_gl_bind_texture(2029de666eaec704).(0, img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[slot]);
4365 GLenumcxx . . $ GLenum# gl_min_filter = _sg_gl_filtercxx . . $ _sg_gl_filter(77eb28f52aae21f3).(img->min_filtercxx . . $ $anonymous_type_ded6a5455d648ef8_7#min_filter.);
4366 GLenumcxx . . $ GLenum# gl_mag_filter = _sg_gl_filtercxx . . $ _sg_gl_filter(77eb28f52aae21f3).(img->mag_filtercxx . . $ $anonymous_type_ded6a5455d648ef8_7#mag_filter.);
4367 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_MIN_FILTERcxx . . $ `<external>/11565930711847777359/gl.h:615:9`!, gl_min_filter);
4368 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_MAG_FILTERcxx . . $ `<external>/11565930711847777359/gl.h:614:9`!, gl_mag_filter);
4369 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..ext_anisotropiccxx . . $ $anonymous_type_ded6a5455d648ef8_22#ext_anisotropic. && (img->max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_7#max_anisotropy. > 1)) {
4370 GLintcxx . . $ GLint# max_aniso = (GLintcxx . . $ GLint#) img->max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_7#max_anisotropy.;
4371 if (max_aniso > _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_anisotropy.) {
4372 max_aniso = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..max_anisotropycxx . . $ $anonymous_type_ded6a5455d648ef8_22#max_anisotropy.;
4373 }
4374 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_MAX_ANISOTROPY_EXTcxx . . $ `<external>/13868558256673015710/glext.h:8442:9`!, max_aniso);
4375 }
4376 if (img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. == SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE.) {
4377 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_WRAP_Scxx . . $ `<external>/11565930711847777359/gl.h:612:9`!, GL_CLAMP_TO_EDGEcxx . . $ `<external>/11565930711847777359/gl.h:1447:9`!);
4378 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_WRAP_Tcxx . . $ `<external>/11565930711847777359/gl.h:613:9`!, GL_CLAMP_TO_EDGEcxx . . $ `<external>/11565930711847777359/gl.h:1447:9`!);
4379 }
4380 else {
4381 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_WRAP_Scxx . . $ `<external>/11565930711847777359/gl.h:612:9`!, _sg_gl_wrapcxx . . $ _sg_gl_wrap(97db5587aa7df795).(img->wrap_ucxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_u.));
4382 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_WRAP_Tcxx . . $ `<external>/11565930711847777359/gl.h:613:9`!, _sg_gl_wrapcxx . . $ _sg_gl_wrap(97db5587aa7df795).(img->wrap_vcxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_v.));
4383 #if !defined(SOKOL_GLES2)
4384 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. && (img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. == SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D.)) {
4385 glTexParametericxx . . $ glTexParameteri(95355335f66856b4).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_WRAP_Rcxx . . $ `<external>/11565930711847777359/gl.h:1484:9`!, _sg_gl_wrapcxx . . $ _sg_gl_wrap(97db5587aa7df795).(img->wrap_wcxx . . $ $anonymous_type_ded6a5455d648ef8_7#wrap_w.));
4386 }
4387 #endif
4388 }
4389 #if !defined(SOKOL_GLES2)
4390 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4391 /* GL spec has strange defaults for mipmap min/max lod: -1000 to +1000 */
4392 const float min_lod = _sg_clampcxx . . $ `demo/sokol/sokol_gfx.h:2171:9`!(desc->min_lod, 0.0f, 1000.0f);
4393 const float max_lod = _sg_clampcxx . . $ `demo/sokol/sokol_gfx.h:2171:9`!(desc->max_lod, 0.0f, 1000.0f);
4394 glTexParameterfcxx . . $ glTexParameterf(41e01b668b0c3b65).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_MIN_LODcxx . . $ `<external>/11565930711847777359/gl.h:1467:9`!, min_lod);
4395 glTexParameterfcxx . . $ glTexParameterf(41e01b668b0c3b65).(img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., GL_TEXTURE_MAX_LODcxx . . $ `<external>/11565930711847777359/gl.h:1468:9`!, max_lod);
4396 }
4397 #endif
4398 const int num_faces = img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. == SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE. ? 6 : 1;
4399 int data_index = 0;
4400 for (int face_index = 0; face_index < num_faces; face_index++) {
4401 for (int mip_index = 0; mip_index < img->num_mipmapscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_mipmaps.; mip_index++, data_index++) {
4402 GLenumcxx . . $ GLenum# gl_img_target = img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target.;
4403 if (SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) {
4404 gl_img_target = _sg_gl_cubeface_targetcxx . . $ _sg_gl_cubeface_target(46cc46841198e427).(face_index);
4405 }
4406 const GLvoidcxx . . $ GLvoid#* data_ptr = desc->contentcxx . . $ sg_image_desc#content..subimagecxx . . $ sg_image_content#subimage.[face_index][mip_index].ptrcxx . . $ sg_subimage_content#ptr.;
4407 const int data_size = desc->contentcxx . . $ sg_image_desc#content..subimagecxx . . $ sg_image_content#subimage.[face_index][mip_index].sizecxx . . $ sg_subimage_content#size.;
4408 int mip_width = img->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width. >> mip_index;
4409 if (mip_width == 0) {
4410 mip_width = 1;
4411 }
4412 int mip_height = img->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height. >> mip_index;
4413 if (mip_height == 0) {
4414 mip_height = 1;
4415 }
4416 if ((SG_IMAGETYPE_2Dcxx . . $ SG_IMAGETYPE_2D. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) || (SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.)) {
4417 if (is_compressed) {
4418 glCompressedTexImage2Dcxx . . $ glCompressedTexImage2D(1d0cef824157495b).(gl_img_target, mip_index, gl_internal_format,
4419 mip_width, mip_height, 0, data_size, data_ptr);
4420 }
4421 else {
4422 const GLenumcxx . . $ GLenum# gl_type = _sg_gl_teximage_typecxx . . $ _sg_gl_teximage_type(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
4423 glTexImage2Dcxx . . $ glTexImage2D(591ddf8a4d6292ac).(gl_img_target, mip_index, gl_internal_format,
4424 mip_width, mip_height, 0, gl_format, gl_type, data_ptr);
4425 }
4426 }
4427 #if !defined(SOKOL_GLES2)
4428 else if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. && ((SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) || (SG_IMAGETYPE_ARRAYcxx . . $ SG_IMAGETYPE_ARRAY. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.))) {
4429 int mip_depth = img->depthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#depth.;
4430 if (SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) {
4431 mip_depth >>= mip_index;
4432 }
4433 if (mip_depth == 0) {
4434 mip_depth = 1;
4435 }
4436 if (is_compressed) {
4437 glCompressedTexImage3Dcxx . . $ glCompressedTexImage3D(3e38d0e9303d4f43).(gl_img_target, mip_index, gl_internal_format,
4438 mip_width, mip_height, mip_depth, 0, data_size, data_ptr);
4439 }
4440 else {
4441 const GLenumcxx . . $ GLenum# gl_type = _sg_gl_teximage_typecxx . . $ _sg_gl_teximage_type(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
4442 glTexImage3Dcxx . . $ glTexImage3D(b7313c0be941b627).(gl_img_target, mip_index, gl_internal_format,
4443 mip_width, mip_height, mip_depth, 0, gl_format, gl_type, data_ptr);
4444 }
4445 }
4446 #endif
4447 }
4448 }
4449 _sg_gl_restore_texture_bindingcxx . . $ _sg_gl_restore_texture_binding(d4f767463ce0a6b3).(0);
4450 }
4451 }
4452 }
4453 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4454 return SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.;
4455 }
4456
4457 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_imagecxx . . $ _sg_destroy_image(a39f7d26f6734857).(_sg_image_tcxx . . $ _sg_image_t#* img) {
4458 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img);
4459 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4460 if (!img->ext_texturescxx . . $ $anonymous_type_ded6a5455d648ef8_7#ext_textures.) {
4461 for (int slot = 0; slot < img->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots.; slot++) {
4462 if (img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[slot]) {
4463 glDeleteTexturescxx . . $ glDeleteTextures(5becf8d0d67ba4cc).(1, &img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[slot]);
4464 }
4465 }
4466 }
4467 if (img->gl_depth_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_depth_render_buffer.) {
4468 glDeleteRenderbufferscxx . . $ glDeleteRenderbuffers(5becf8d0d67ba4cc).(1, &img->gl_depth_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_depth_render_buffer.);
4469 }
4470 if (img->gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.) {
4471 glDeleteRenderbufferscxx . . $ glDeleteRenderbuffers(5becf8d0d67ba4cc).(1, &img->gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.);
4472 }
4473 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4474 }
4475
4476 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! GLuintcxx . . $ GLuint# _sg_gl_compile_shadercxx . . $ _sg_gl_compile_shader(86c64b3ac5f626d0).(sg_shader_stagecxx . . $ sg_shader_stage# stage, const char* src) {
4477 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(src);
4478 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4479 GLuintcxx . . $ GLuint# gl_shd = glCreateShadercxx . . $ glCreateShader(2141b656ce2cc063).(_sg_gl_shader_stagecxx . . $ _sg_gl_shader_stage(ee0e1eddd5358485).(stage));
4480 glShaderSourcecxx . . $ glShaderSource(b9745c298ba34965).(gl_shd, 1, &src, 0);
4481 glCompileShadercxx . . $ glCompileShader(cb2f890c2fdad230).(gl_shd);
4482 GLintcxx . . $ GLint# compile_status = 0;
4483 glGetShaderivcxx . . $ glGetShaderiv(d56640de3ace938a).(gl_shd, GL_COMPILE_STATUScxx . . $ `<external>/13868558256673015710/glext.h:608:9`!, &compile_status);
4484 if (!compile_status) {
4485 /* compilation failed, log error and delete shader */
4486 GLintcxx . . $ GLint# log_len = 0;
4487 glGetShaderivcxx . . $ glGetShaderiv(d56640de3ace938a).(gl_shd, GL_INFO_LOG_LENGTHcxx . . $ `<external>/13868558256673015710/glext.h:611:9`!, &log_len);
4488 if (log_len > 0) {
4489 GLcharcxx . . $ GLchar#* log_buf = (GLcharcxx . . $ GLchar#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(log_len);
4490 glGetShaderInfoLogcxx . . $ glGetShaderInfoLog(f2fae77127325702).(gl_shd, log_len, &log_len, log_buf);
4491 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!(log_buf);
4492 SOKOL_FREEcxx . . $ `demo/sokol/sokol_gfx.h:1972:13`!(log_buf);
4493 }
4494 glDeleteShadercxx . . $ glDeleteShader(cb2f890c2fdad230).(gl_shd);
4495 gl_shd = 0;
4496 }
4497 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4498 return gl_shd;
4499 }
4500
4501 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_resource_statecxx . . $ sg_resource_state# _sg_create_shadercxx . . $ _sg_create_shader(ca3cb0aaa639e707).(_sg_shader_tcxx . . $ _sg_shader_t#* shd, const sg_shader_desccxx . . $ sg_shader_desc#* desc) {
4502 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd && desc);
4503 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(!shd->gl_prog);
4504 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4505
4506 /* copy vertex attribute names over, these are required for GLES2, and optional for GLES3 and GL3.x */
4507 for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; i++) {
4508 _sg_strcpycxx . . $ _sg_strcpy(78720eca4aacfc00).(&shd->attrscxx . . $ $anonymous_type_ded6a5455d648ef8_13#attrs.[i].namecxx . . $ $anonymous_type_ded6a5455d648ef8_11#name., desc->attrscxx . . $ sg_shader_desc#attrs.[i].namecxx . . $ sg_shader_attr_desc#name.);
4509 }
4510
4511 GLuintcxx . . $ GLuint# gl_vs = _sg_gl_compile_shadercxx . . $ _sg_gl_compile_shader(86c64b3ac5f626d0).(SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS., desc->vscxx . . $ sg_shader_desc#vs..sourcecxx . . $ sg_shader_stage_desc#source.);
4512 GLuintcxx . . $ GLuint# gl_fs = _sg_gl_compile_shadercxx . . $ _sg_gl_compile_shader(86c64b3ac5f626d0).(SG_SHADERSTAGE_FScxx . . $ SG_SHADERSTAGE_FS., desc->fscxx . . $ sg_shader_desc#fs..sourcecxx . . $ sg_shader_stage_desc#source.);
4513 if (!(gl_vs && gl_fs)) {
4514 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4515 }
4516 GLuintcxx . . $ GLuint# gl_prog = glCreateProgramcxx . . $ glCreateProgram(db52760e79bf9054).();
4517 glAttachShadercxx . . $ glAttachShader(b4d55b1286ff73e8).(gl_prog, gl_vs);
4518 glAttachShadercxx . . $ glAttachShader(b4d55b1286ff73e8).(gl_prog, gl_fs);
4519 glLinkProgramcxx . . $ glLinkProgram(cb2f890c2fdad230).(gl_prog);
4520 glDeleteShadercxx . . $ glDeleteShader(cb2f890c2fdad230).(gl_vs);
4521 glDeleteShadercxx . . $ glDeleteShader(cb2f890c2fdad230).(gl_fs);
4522 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4523
4524 GLintcxx . . $ GLint# link_status;
4525 glGetProgramivcxx . . $ glGetProgramiv(d56640de3ace938a).(gl_prog, GL_LINK_STATUScxx . . $ `<external>/13868558256673015710/glext.h:609:9`!, &link_status);
4526 if (!link_status) {
4527 GLintcxx . . $ GLint# log_len = 0;
4528 glGetProgramivcxx . . $ glGetProgramiv(d56640de3ace938a).(gl_prog, GL_INFO_LOG_LENGTHcxx . . $ `<external>/13868558256673015710/glext.h:611:9`!, &log_len);
4529 if (log_len > 0) {
4530 GLcharcxx . . $ GLchar#* log_buf = (GLcharcxx . . $ GLchar#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(log_len);
4531 glGetProgramInfoLogcxx . . $ glGetProgramInfoLog(f2fae77127325702).(gl_prog, log_len, &log_len, log_buf);
4532 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!(log_buf);
4533 SOKOL_FREEcxx . . $ `demo/sokol/sokol_gfx.h:1972:13`!(log_buf);
4534 }
4535 glDeleteProgramcxx . . $ glDeleteProgram(cb2f890c2fdad230).(gl_prog);
4536 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4537 }
4538 shd->gl_progcxx . . $ $anonymous_type_ded6a5455d648ef8_13#gl_prog. = gl_prog;
4539
4540 /* resolve uniforms */
4541 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4542 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGEScxx . . $ SG_NUM_SHADER_STAGES.; stage_index++) {
4543 const sg_shader_stage_desccxx . . $ sg_shader_stage_desc#* stage_desc = (stage_index == SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS.)? &desc->vscxx . . $ sg_shader_desc#vs. : &desc->fscxx . . $ sg_shader_desc#fs.;
4544 _sg_shader_stage_tcxx . . $ _sg_shader_stage_t#* stage = &shd->stagecxx . . $ $anonymous_type_ded6a5455d648ef8_13#stage.[stage_index];
4545 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(stage->num_uniform_blocks == 0);
4546 for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBScxx . . $ SG_MAX_SHADERSTAGE_UBS.; ub_index++) {
4547 const sg_shader_uniform_block_desccxx . . $ sg_shader_uniform_block_desc#* ub_desc = &stage_desc->uniform_blockscxx . . $ sg_shader_stage_desc#uniform_blocks.[ub_index];
4548 if (0 == ub_desc->sizecxx . . $ sg_shader_uniform_block_desc#size.) {
4549 break;
4550 }
4551 _sg_uniform_block_tcxx . . $ _sg_uniform_block_t#* ub = &stage->uniform_blockscxx . . $ $anonymous_type_ded6a5455d648ef8_12#uniform_blocks.[ub_index];
4552 ub->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_9#size. = ub_desc->sizecxx . . $ sg_shader_uniform_block_desc#size.;
4553 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ub->num_uniforms == 0);
4554 int cur_uniform_offset = 0;
4555 for (int u_index = 0; u_index < SG_MAX_UB_MEMBERScxx . . $ SG_MAX_UB_MEMBERS.; u_index++) {
4556 const sg_shader_uniform_desccxx . . $ sg_shader_uniform_desc#* u_desc = &ub_desc->uniformscxx . . $ sg_shader_uniform_block_desc#uniforms.[u_index];
4557 if (u_desc->typecxx . . $ sg_shader_uniform_desc#type. == SG_UNIFORMTYPE_INVALIDcxx . . $ SG_UNIFORMTYPE_INVALID.) {
4558 break;
4559 }
4560 _sg_uniform_tcxx . . $ _sg_uniform_t#* u = &ub->uniformscxx . . $ $anonymous_type_ded6a5455d648ef8_9#uniforms.[u_index];
4561 u->typecxx . . $ $anonymous_type_ded6a5455d648ef8_8#type. = u_desc->typecxx . . $ sg_shader_uniform_desc#type.;
4562 u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count. = (uint8_tcxx . . $ uint8_t#) u_desc->array_countcxx . . $ sg_shader_uniform_desc#array_count.;
4563 u->offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_8#offset. = (uint16_tcxx . . $ uint16_t#) cur_uniform_offset;
4564 cur_uniform_offset += _sg_uniform_sizecxx . . $ _sg_uniform_size(87c0041b48ebc29b).(u->typecxx . . $ $anonymous_type_ded6a5455d648ef8_8#type., u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count.);
4565 if (u_desc->namecxx . . $ sg_shader_uniform_desc#name.) {
4566 u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc. = glGetUniformLocationcxx . . $ glGetUniformLocation(dbfc9165c1ea8dea).(gl_prog, u_desc->namecxx . . $ sg_shader_uniform_desc#name.);
4567 }
4568 else {
4569 u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc. = u_index;
4570 }
4571 ub->num_uniformscxx . . $ $anonymous_type_ded6a5455d648ef8_9#num_uniforms.++;
4572 }
4573 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ub_desc->size == cur_uniform_offset);
4574 stage->num_uniform_blockscxx . . $ $anonymous_type_ded6a5455d648ef8_12#num_uniform_blocks.++;
4575 }
4576 }
4577
4578 /* resolve image locations */
4579 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4580 int gl_tex_slot = 0;
4581 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGEScxx . . $ SG_NUM_SHADER_STAGES.; stage_index++) {
4582 const sg_shader_stage_desccxx . . $ sg_shader_stage_desc#* stage_desc = (stage_index == SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS.)? &desc->vscxx . . $ sg_shader_desc#vs. : &desc->fscxx . . $ sg_shader_desc#fs.;
4583 _sg_shader_stage_tcxx . . $ _sg_shader_stage_t#* stage = &shd->stagecxx . . $ $anonymous_type_ded6a5455d648ef8_13#stage.[stage_index];
4584 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(stage->num_images == 0);
4585 for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.; img_index++) {
4586 const sg_shader_image_desccxx . . $ sg_shader_image_desc#* img_desc = &stage_desc->imagescxx . . $ sg_shader_stage_desc#images.[img_index];
4587 if (img_desc->typecxx . . $ sg_shader_image_desc#type. == _SG_IMAGETYPE_DEFAULTcxx . . $ _SG_IMAGETYPE_DEFAULT.) {
4588 break;
4589 }
4590 _sg_shader_image_tcxx . . $ _sg_shader_image_t#* img = &stage->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_12#images.[img_index];
4591 img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_10#type. = img_desc->typecxx . . $ sg_shader_image_desc#type.;
4592 img->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_loc. = img_index;
4593 if (img_desc->namecxx . . $ sg_shader_image_desc#name.) {
4594 img->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_loc. = glGetUniformLocationcxx . . $ glGetUniformLocation(dbfc9165c1ea8dea).(gl_prog, img_desc->namecxx . . $ sg_shader_image_desc#name.);
4595 }
4596 if (img->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_loc. != -1) {
4597 img->gl_tex_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_tex_slot. = gl_tex_slot++;
4598 }
4599 else {
4600 img->gl_tex_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_tex_slot. = -1;
4601 }
4602 stage->num_imagescxx . . $ $anonymous_type_ded6a5455d648ef8_12#num_images.++;
4603 }
4604 }
4605 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4606 return SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.;
4607 }
4608
4609 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_shadercxx . . $ _sg_destroy_shader(c330990de8bee88b).(_sg_shader_tcxx . . $ _sg_shader_t#* shd) {
4610 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd);
4611 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4612 if (shd->gl_progcxx . . $ $anonymous_type_ded6a5455d648ef8_13#gl_prog.) {
4613 glDeleteProgramcxx . . $ glDeleteProgram(cb2f890c2fdad230).(shd->gl_progcxx . . $ $anonymous_type_ded6a5455d648ef8_13#gl_prog.);
4614 }
4615 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4616 }
4617
4618 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_resource_statecxx . . $ sg_resource_state# _sg_create_pipelinecxx . . $ _sg_create_pipeline(de9bffdb94faaaa6).(_sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip, _sg_shader_tcxx . . $ _sg_shader_t#* shd, const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc) {
4619 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip && shd && desc);
4620 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(!pip->shader && pip->shader_id.id == SG_INVALID_ID);
4621 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc->shader.id == shd->slot.id);
4622 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd->gl_prog);
4623 pip->shadercxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader. = shd;
4624 pip->shader_idcxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader_id. = desc->shadercxx . . $ sg_pipeline_desc#shader.;
4625 pip->primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_15#primitive_type. = desc->primitive_typecxx . . $ sg_pipeline_desc#primitive_type.;
4626 pip->index_typecxx . . $ $anonymous_type_ded6a5455d648ef8_15#index_type. = desc->index_typecxx . . $ sg_pipeline_desc#index_type.;
4627 pip->color_attachment_countcxx . . $ $anonymous_type_ded6a5455d648ef8_15#color_attachment_count. = desc->blendcxx . . $ sg_pipeline_desc#blend..color_attachment_countcxx . . $ sg_blend_state#color_attachment_count.;
4628 pip->color_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_15#color_format. = desc->blendcxx . . $ sg_pipeline_desc#blend..color_formatcxx . . $ sg_blend_state#color_format.;
4629 pip->depth_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_15#depth_format. = desc->blendcxx . . $ sg_pipeline_desc#blend..depth_formatcxx . . $ sg_blend_state#depth_format.;
4630 pip->sample_countcxx . . $ $anonymous_type_ded6a5455d648ef8_15#sample_count. = desc->rasterizercxx . . $ sg_pipeline_desc#rasterizer..sample_countcxx . . $ sg_rasterizer_state#sample_count.;
4631 pip->depth_stencilcxx . . $ $anonymous_type_ded6a5455d648ef8_15#depth_stencil. = desc->depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil.;
4632 pip->blendcxx . . $ $anonymous_type_ded6a5455d648ef8_15#blend. = desc->blendcxx . . $ sg_pipeline_desc#blend.;
4633 pip->rastcxx . . $ $anonymous_type_ded6a5455d648ef8_15#rast. = desc->rasterizercxx . . $ sg_pipeline_desc#rasterizer.;
4634
4635 /* resolve vertex attributes */
4636 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; attr_index++) {
4637 pip->gl_attrscxx . . $ $anonymous_type_ded6a5455d648ef8_15#gl_attrs.[attr_index].vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index. = -1;
4638 }
4639 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; attr_index++) {
4640 const sg_vertex_attr_desccxx . . $ sg_vertex_attr_desc#* a_desc = &desc->layoutcxx . . $ sg_pipeline_desc#layout..attrscxx . . $ sg_layout_desc#attrs.[attr_index];
4641 if (a_desc->formatcxx . . $ sg_vertex_attr_desc#format. == SG_VERTEXFORMAT_INVALIDcxx . . $ SG_VERTEXFORMAT_INVALID.) {
4642 break;
4643 }
4644 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((a_desc->buffer_index >= 0) && (a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS));
4645 const sg_buffer_layout_desccxx . . $ sg_buffer_layout_desc#* l_desc = &desc->layoutcxx . . $ sg_pipeline_desc#layout..bufferscxx . . $ sg_layout_desc#buffers.[a_desc->buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.];
4646 const sg_vertex_stepcxx . . $ sg_vertex_step# step_func = l_desc->step_funccxx . . $ sg_buffer_layout_desc#step_func.;
4647 const int step_rate = l_desc->step_ratecxx . . $ sg_buffer_layout_desc#step_rate.;
4648 GLintcxx . . $ GLint# attr_loc = attr_index;
4649 if (!_sg_stremptycxx . . $ _sg_strempty(2796537507365e48).(&shd->attrscxx . . $ $anonymous_type_ded6a5455d648ef8_13#attrs.[attr_index].namecxx . . $ $anonymous_type_ded6a5455d648ef8_11#name.)) {
4650 attr_loc = glGetAttribLocationcxx . . $ glGetAttribLocation(dbfc9165c1ea8dea).(pip->shadercxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader.->gl_progcxx . . $ $anonymous_type_ded6a5455d648ef8_13#gl_prog., _sg_strptrcxx . . $ _sg_strptr(d90489c912418c0c).(&shd->attrscxx . . $ $anonymous_type_ded6a5455d648ef8_13#attrs.[attr_index].namecxx . . $ $anonymous_type_ded6a5455d648ef8_11#name.));
4651 }
4652 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(attr_loc < SG_MAX_VERTEX_ATTRIBUTES);
4653 if (attr_loc != -1) {
4654 _sg_gl_attr_tcxx . . $ _sg_gl_attr_t#* gl_attr = &pip->gl_attrscxx . . $ $anonymous_type_ded6a5455d648ef8_15#gl_attrs.[attr_loc];
4655 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_attr->vb_index == -1);
4656 gl_attr->vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index. = (int8_tcxx . . $ int8_t#) a_desc->buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.;
4657 if (step_func == SG_VERTEXSTEP_PER_VERTEXcxx . . $ SG_VERTEXSTEP_PER_VERTEX.) {
4658 gl_attr->divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor. = 0;
4659 }
4660 else {
4661 gl_attr->divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor. = (int8_tcxx . . $ int8_t#) step_rate;
4662 }
4663 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(l_desc->stride > 0);
4664 gl_attr->stridecxx . . $ $anonymous_type_ded6a5455d648ef8_14#stride. = (uint8_tcxx . . $ uint8_t#) l_desc->stridecxx . . $ sg_buffer_layout_desc#stride.;
4665 gl_attr->offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_14#offset. = a_desc->offsetcxx . . $ sg_vertex_attr_desc#offset.;
4666 gl_attr->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_14#size. = (uint8_tcxx . . $ uint8_t#) _sg_gl_vertexformat_sizecxx . . $ _sg_gl_vertexformat_size(1303c1e179b3eed2).(a_desc->formatcxx . . $ sg_vertex_attr_desc#format.);
4667 gl_attr->typecxx . . $ $anonymous_type_ded6a5455d648ef8_14#type. = _sg_gl_vertexformat_typecxx . . $ _sg_gl_vertexformat_type(bd32c1c4f42173fe).(a_desc->formatcxx . . $ sg_vertex_attr_desc#format.);
4668 gl_attr->normalizedcxx . . $ $anonymous_type_ded6a5455d648ef8_14#normalized. = _sg_gl_vertexformat_normalizedcxx . . $ _sg_gl_vertexformat_normalized(bc7c4b45b00aa08c).(a_desc->formatcxx . . $ sg_vertex_attr_desc#format.);
4669 pip->vertex_layout_validcxx . . $ $anonymous_type_ded6a5455d648ef8_15#vertex_layout_valid.[a_desc->buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.] = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4670 }
4671 else {
4672 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("Vertex attribute not found in shader: ");
4673 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!(_sg_strptr(&shd->attrs[attr_index].name));
4674 }
4675 }
4676 return SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.;
4677 }
4678
4679 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_pipelinecxx . . $ _sg_destroy_pipeline(ead8d739235dacd3).(_sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip) {
4680 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip);
4681 /* empty */
4682 }
4683
4684 /*
4685 _sg_create_pass
4686
4687 att_imgs must point to a _sg_image* att_imgs[SG_MAX_COLOR_ATTACHMENTS+1] array,
4688 first entries are the color attachment images (or nullptr), last entry
4689 is the depth-stencil image (or nullptr).
4690 */
4691 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_resource_statecxx . . $ sg_resource_state# _sg_create_passcxx . . $ _sg_create_pass(b0a912b01eaf11f1).(_sg_pass_tcxx . . $ _sg_pass_t#* pass, _sg_image_tcxx . . $ _sg_image_t#** att_images, const sg_pass_desccxx . . $ sg_pass_desc#* desc) {
4692 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass && att_images && desc);
4693 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(att_images && att_images[0]);
4694 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4695
4696 /* copy image pointers and desc attributes */
4697 const sg_attachment_desccxx . . $ sg_attachment_desc#* att_desc;
4698 _sg_attachment_tcxx . . $ _sg_attachment_t#* att;
4699 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4700 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(0 == pass->color_atts[i].image);
4701 att_desc = &desc->color_attachmentscxx . . $ sg_pass_desc#color_attachments.[i];
4702 if (att_desc->imagecxx . . $ sg_attachment_desc#image..idcxx . . $ sg_image#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
4703 pass->num_color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#num_color_atts.++;
4704 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(att_images[i] && (att_images[i]->slot.id == att_desc->image.id));
4705 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg_is_valid_rendertarget_color_format(att_images[i]->pixel_format));
4706 att = &pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i];
4707 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
4708 att->imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image. = att_images[i];
4709 att->image_idcxx . . $ $anonymous_type_ded6a5455d648ef8_16#image_id. = att_desc->imagecxx . . $ sg_attachment_desc#image.;
4710 att->mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level. = att_desc->mip_levelcxx . . $ sg_attachment_desc#mip_level.;
4711 att->slicecxx . . $ $anonymous_type_ded6a5455d648ef8_16#slice. = att_desc->slicecxx . . $ sg_attachment_desc#$anonymous_type_2#slice.;
4712 }
4713 }
4714 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(0 == pass->ds_att.image);
4715 att_desc = &desc->depth_stencil_attachmentcxx . . $ sg_pass_desc#depth_stencil_attachment.;
4716 const int ds_img_index = SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.;
4717 if (att_desc->imagecxx . . $ sg_attachment_desc#image..idcxx . . $ sg_image#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
4718 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id));
4719 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->pixel_format));
4720 att = &pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att.;
4721 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
4722 att->imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image. = att_images[ds_img_index];
4723 att->image_idcxx . . $ $anonymous_type_ded6a5455d648ef8_16#image_id. = att_desc->imagecxx . . $ sg_attachment_desc#image.;
4724 att->mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level. = att_desc->mip_levelcxx . . $ sg_attachment_desc#mip_level.;
4725 att->slicecxx . . $ $anonymous_type_ded6a5455d648ef8_16#slice. = att_desc->slicecxx . . $ sg_attachment_desc#$anonymous_type_2#slice.;
4726 }
4727
4728 /* store current framebuffer binding (restored at end of function) */
4729 GLuintcxx . . $ GLuint# gl_orig_fb;
4730 glGetIntegervcxx . . $ glGetIntegerv(1740d062d6b6475a).(GL_FRAMEBUFFER_BINDINGcxx . . $ `<external>/13868558256673015710/glext.h:991:9`!, (GLintcxx . . $ GLint#*)&gl_orig_fb);
4731
4732 /* create a framebuffer object */
4733 glGenFramebufferscxx . . $ glGenFramebuffers(e2a7cb9a6f2acdbc).(1, &pass->gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.);
4734 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, pass->gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.);
4735
4736 /* attach msaa render buffer or textures */
4737 const boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_msaa = (0 != att_images[0]->gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.);
4738 if (is_msaa) {
4739 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4740 const _sg_image_tcxx . . $ _sg_image_t#* att_img = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.;
4741 if (att_img) {
4742 const GLuintcxx . . $ GLuint# gl_render_buffer = att_img->gl_msaa_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_msaa_render_buffer.;
4743 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_render_buffer);
4744 glFramebufferRenderbuffercxx . . $ glFramebufferRenderbuffer(eda338842932bf2b).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`!+i, GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, gl_render_buffer);
4745 }
4746 }
4747 }
4748 else {
4749 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4750 const _sg_image_tcxx . . $ _sg_image_t#* att_img = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.;
4751 const int mip_level = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level.;
4752 const int slice = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].slicecxx . . $ $anonymous_type_ded6a5455d648ef8_16#slice.;
4753 if (att_img) {
4754 const GLuintcxx . . $ GLuint# gl_tex = att_img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[0];
4755 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_tex);
4756 const GLenumcxx . . $ GLenum# gl_att = GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`! + i;
4757 switch (att_img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) {
4758 case SG_IMAGETYPE_2Dcxx . . $ SG_IMAGETYPE_2D.:
4759 glFramebufferTexture2Dcxx . . $ glFramebufferTexture2D(6e32fb782344d276).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, gl_att, GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!, gl_tex, mip_level);
4760 break;
4761 case SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE.:
4762 glFramebufferTexture2Dcxx . . $ glFramebufferTexture2D(6e32fb782344d276).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, gl_att, _sg_gl_cubeface_targetcxx . . $ _sg_gl_cubeface_target(46cc46841198e427).(slice), gl_tex, mip_level);
4763 break;
4764 default:
4765 /* 3D- or array-texture */
4766 #if !defined(SOKOL_GLES2)
4767 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4768 glFramebufferTextureLayercxx . . $ glFramebufferTextureLayer(8edb35a34cd75e45).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, gl_att, gl_tex, mip_level, slice);
4769 }
4770 #endif
4771 break;
4772 }
4773 }
4774 }
4775 }
4776
4777 /* attach depth-stencil buffer to framebuffer */
4778 if (pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att..imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.) {
4779 const GLuintcxx . . $ GLuint# gl_render_buffer = pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att..imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->gl_depth_render_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_depth_render_buffer.;
4780 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_render_buffer);
4781 glFramebufferRenderbuffercxx . . $ glFramebufferRenderbuffer(eda338842932bf2b).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, GL_DEPTH_ATTACHMENTcxx . . $ `<external>/13868558256673015710/glext.h:1042:9`!, GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, gl_render_buffer);
4782 if (_sg_is_depth_stencil_formatcxx . . $ _sg_is_depth_stencil_format(3296e3b3357c429b).(pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att..imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.)) {
4783 glFramebufferRenderbuffercxx . . $ glFramebufferRenderbuffer(eda338842932bf2b).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, GL_STENCIL_ATTACHMENTcxx . . $ `<external>/13868558256673015710/glext.h:1043:9`!, GL_RENDERBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1045:9`!, gl_render_buffer);
4784 }
4785 }
4786
4787 /* check if framebuffer is complete */
4788 if (glCheckFramebufferStatuscxx . . $ glCheckFramebufferStatus(2141b656ce2cc063).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!) != GL_FRAMEBUFFER_COMPLETEcxx . . $ `<external>/13868558256673015710/glext.h:1003:9`!) {
4789 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("Framebuffer completeness check failed!\n");
4790 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4791 }
4792
4793 /* create MSAA resolve framebuffers if necessary */
4794 if (is_msaa) {
4795 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4796 att = &pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i];
4797 if (att->imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.) {
4798 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(0 == att->gl_msaa_resolve_buffer);
4799 glGenFramebufferscxx . . $ glGenFramebuffers(e2a7cb9a6f2acdbc).(1, &att->gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.);
4800 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, att->gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.);
4801 const GLuintcxx . . $ GLuint# gl_tex = att->imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[0];
4802 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_tex);
4803 switch (att->imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) {
4804 case SG_IMAGETYPE_2Dcxx . . $ SG_IMAGETYPE_2D.:
4805 glFramebufferTexture2Dcxx . . $ glFramebufferTexture2D(6e32fb782344d276).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`!,
4806 GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!, gl_tex, att->mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level.);
4807 break;
4808 case SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE.:
4809 glFramebufferTexture2Dcxx . . $ glFramebufferTexture2D(6e32fb782344d276).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`!,
4810 _sg_gl_cubeface_targetcxx . . $ _sg_gl_cubeface_target(46cc46841198e427).(att->slicecxx . . $ $anonymous_type_ded6a5455d648ef8_16#slice.), gl_tex, att->mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level.);
4811 break;
4812 default:
4813 #if !defined(SOKOL_GLES2)
4814 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4815 glFramebufferTextureLayercxx . . $ glFramebufferTextureLayer(8edb35a34cd75e45).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`!, gl_tex, att->mip_levelcxx . . $ $anonymous_type_ded6a5455d648ef8_16#mip_level., att->slicecxx . . $ $anonymous_type_ded6a5455d648ef8_16#slice.);
4816 }
4817 #endif
4818 break;
4819 }
4820 /* check if framebuffer is complete */
4821 if (glCheckFramebufferStatuscxx . . $ glCheckFramebufferStatus(2141b656ce2cc063).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!) != GL_FRAMEBUFFER_COMPLETEcxx . . $ `<external>/13868558256673015710/glext.h:1003:9`!) {
4822 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("Framebuffer completeness check failed (msaa resolve buffer)!\n");
4823 return SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
4824 }
4825 }
4826 }
4827 }
4828
4829 /* restore original framebuffer binding */
4830 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, gl_orig_fb);
4831 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4832 return SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.;
4833 }
4834
4835 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_passcxx . . $ _sg_destroy_pass(eae344a76fb8d519).(_sg_pass_tcxx . . $ _sg_pass_t#* pass) {
4836 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass);
4837 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4838 if (0 != pass->gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.) {
4839 glDeleteFramebufferscxx . . $ glDeleteFramebuffers(5becf8d0d67ba4cc).(1, &pass->gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.);
4840 }
4841 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4842 if (pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.) {
4843 glDeleteFramebufferscxx . . $ glDeleteFramebuffers(5becf8d0d67ba4cc).(1, &pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.);
4844 }
4845 }
4846 if (pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att..gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.) {
4847 glDeleteFramebufferscxx . . $ glDeleteFramebuffers(5becf8d0d67ba4cc).(1, &pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att..gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.);
4848 }
4849 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4850 }
4851
4852 /*-- GL backend rendering functions ------------------------------------------*/
4853 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_begin_passcxx . . $ _sg_begin_pass(473da010b9056ca5).(_sg_pass_tcxx . . $ _sg_pass_t#* pass, const sg_pass_actioncxx . . $ sg_pass_action#* action, int w, int h) {
4854 /* FIXME: what if a texture used as render target is still bound, should we
4855 unbind all currently bound textures in begin pass? */
4856 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(action);
4857 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(!_sg.gl.in_pass);
4858 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4859 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..in_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#in_pass. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4860 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass. = pass; /* can be 0 */
4861 if (pass) {
4862 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_idcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_id..idcxx . . $ sg_pass#id. = pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
4863 }
4864 else {
4865 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_idcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_id..idcxx . . $ sg_pass#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
4866 }
4867 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_widthcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_width. = w;
4868 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_heightcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_height. = h;
4869 if (pass) {
4870 /* offscreen pass */
4871 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass->gl_fb);
4872 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, pass->gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.);
4873 #if !defined(SOKOL_GLES2)
4874 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4875 GLenumcxx . . $ GLenum# att[SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.] = {
4876 GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`!,
4877 GL_COLOR_ATTACHMENT1cxx . . $ `<external>/13868558256673015710/glext.h:1011:9`!,
4878 GL_COLOR_ATTACHMENT2cxx . . $ `<external>/13868558256673015710/glext.h:1012:9`!,
4879 GL_COLOR_ATTACHMENT3cxx . . $ `<external>/13868558256673015710/glext.h:1013:9`!
4880 };
4881 int num_attrs = 0;
4882 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4883 if (pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[num_attrs].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.) {
4884 num_attrs++;
4885 }
4886 else {
4887 break;
4888 }
4889 }
4890 glDrawBufferscxx . . $ glDrawBuffers(5becf8d0d67ba4cc).(num_attrs, att);
4891 }
4892 #endif
4893 }
4894 else {
4895 /* default pass */
4896 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.cur_context);
4897 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_context.->default_framebuffercxx . . $ $anonymous_type_ded6a5455d648ef8_18#default_framebuffer.);
4898 }
4899 glViewportcxx . . $ glViewport(748afa4755bc9595).(0, 0, w, h);
4900 glScissorcxx . . $ glScissor(748afa4755bc9595).(0, 0, w, h);
4901 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! need_pip_cache_flush = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
4902 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..blendcxx . . $ $anonymous_type_ded6a5455d648ef8_21#blend..color_write_maskcxx . . $ sg_blend_state#color_write_mask. != SG_COLORMASK_RGBAcxx . . $ SG_COLORMASK_RGBA.) {
4903 need_pip_cache_flush = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4904 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..blendcxx . . $ $anonymous_type_ded6a5455d648ef8_21#blend..color_write_maskcxx . . $ sg_blend_state#color_write_mask. = SG_COLORMASK_RGBAcxx . . $ SG_COLORMASK_RGBA.;
4905 glColorMaskcxx . . $ glColorMask(bfb537490240b335).(GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!, GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!, GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!, GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!);
4906 }
4907 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds..depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled.) {
4908 need_pip_cache_flush = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4909 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds..depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4910 glDepthMaskcxx . . $ glDepthMask(ac50b47256ae7414).(GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`!);
4911 }
4912 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds..depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func. != SG_COMPAREFUNC_ALWAYScxx . . $ SG_COMPAREFUNC_ALWAYS.) {
4913 need_pip_cache_flush = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4914 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds..depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func. = SG_COMPAREFUNC_ALWAYScxx . . $ SG_COMPAREFUNC_ALWAYS.;
4915 glDepthFunccxx . . $ glDepthFunc(cb2f890c2fdad230).(GL_ALWAYScxx . . $ `<external>/11565930711847777359/gl.h:266:9`!);
4916 }
4917 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds..stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask. != 0xFF) {
4918 need_pip_cache_flush = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
4919 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds..stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask. = 0xFF;
4920 glStencilMaskcxx . . $ glStencilMask(cb2f890c2fdad230).(0xFF);
4921 }
4922 if (need_pip_cache_flush) {
4923 /* we messed with the state cache directly, need to clear cached
4924 pipeline to force re-evaluation in next sg_apply_pipeline() */
4925 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline. = 0;
4926 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipeline_idcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline_id..idcxx . . $ sg_pipeline#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
4927 }
4928 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! use_mrt_clear = (0 != pass);
4929 #if defined(SOKOL_GLES2)
4930 use_mrt_clear = false;
4931 #else
4932 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2.) {
4933 use_mrt_clear = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
4934 }
4935 #endif
4936 if (!use_mrt_clear) {
4937 GLbitfieldcxx . . $ GLbitfield# clear_mask = 0;
4938 if (action->colorscxx . . $ sg_pass_action#colors.[0].actioncxx . . $ sg_color_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) {
4939 clear_mask |= GL_COLOR_BUFFER_BITcxx . . $ `<external>/11565930711847777359/gl.h:682:9`!;
4940 const float* c = action->colorscxx . . $ sg_pass_action#colors.[0].valcxx . . $ sg_color_attachment_action#val.;
4941 glClearColorcxx . . $ glClearColor(7e9a355db6148521).(c[0], c[1], c[2], c[3]);
4942 }
4943 if (action->depthcxx . . $ sg_pass_action#depth..actioncxx . . $ sg_depth_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) {
4944 clear_mask |= GL_DEPTH_BUFFER_BITcxx . . $ `<external>/11565930711847777359/gl.h:676:9`!;
4945 #ifdef SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!
4946 glClearDepthcxx . . $ glClearDepth(ba8836b59fb42830).(action->depthcxx . . $ sg_pass_action#depth..valcxx . . $ sg_depth_attachment_action#val.);
4947 #else
4948 glClearDepthf(action->depth.val);
4949 #endif
4950 }
4951 if (action->stencilcxx . . $ sg_pass_action#stencil..actioncxx . . $ sg_stencil_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) {
4952 clear_mask |= GL_STENCIL_BUFFER_BITcxx . . $ `<external>/11565930711847777359/gl.h:678:9`!;
4953 glClearStencilcxx . . $ glClearStencil(d4f767463ce0a6b3).(action->stencilcxx . . $ sg_pass_action#stencil..valcxx . . $ sg_stencil_attachment_action#val.);
4954 }
4955 if (0 != clear_mask) {
4956 glClearcxx . . $ glClear(cb2f890c2fdad230).(clear_mask);
4957 }
4958 }
4959 #if !defined SOKOL_GLES2
4960 else {
4961 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass);
4962 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
4963 if (pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[i].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.) {
4964 if (action->colorscxx . . $ sg_pass_action#colors.[i].actioncxx . . $ sg_color_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) {
4965 glClearBufferfvcxx . . $ glClearBufferfv(552a7eae8dc1aa62).(GL_COLORcxx . . $ `<external>/11565930711847777359/gl.h:464:9`!, i, action->colorscxx . . $ sg_pass_action#colors.[i].valcxx . . $ sg_color_attachment_action#val.);
4966 }
4967 }
4968 else {
4969 break;
4970 }
4971 }
4972 if (pass->ds_attcxx . . $ $anonymous_type_ded6a5455d648ef8_17#ds_att..imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.) {
4973 if ((action->depthcxx . . $ sg_pass_action#depth..actioncxx . . $ sg_depth_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) && (action->stencilcxx . . $ sg_pass_action#stencil..actioncxx . . $ sg_stencil_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.)) {
4974 glClearBufferficxx . . $ glClearBufferfi(5ffa9893282f8c9b).(GL_DEPTH_STENCILcxx . . $ `<external>/13868558256673015710/glext.h:981:9`!, 0, action->depthcxx . . $ sg_pass_action#depth..valcxx . . $ sg_depth_attachment_action#val., action->stencilcxx . . $ sg_pass_action#stencil..valcxx . . $ sg_stencil_attachment_action#val.);
4975 }
4976 else if (action->depthcxx . . $ sg_pass_action#depth..actioncxx . . $ sg_depth_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) {
4977 glClearBufferfvcxx . . $ glClearBufferfv(552a7eae8dc1aa62).(GL_DEPTHcxx . . $ `<external>/11565930711847777359/gl.h:465:9`!, 0, &action->depthcxx . . $ sg_pass_action#depth..valcxx . . $ sg_depth_attachment_action#val.);
4978 }
4979 else if (action->stencilcxx . . $ sg_pass_action#stencil..actioncxx . . $ sg_stencil_attachment_action#action. == SG_ACTION_CLEARcxx . . $ SG_ACTION_CLEAR.) {
4980 GLuintcxx . . $ GLuint# val = action->stencilcxx . . $ sg_pass_action#stencil..valcxx . . $ sg_stencil_attachment_action#val.;
4981 glClearBufferuivcxx . . $ glClearBufferuiv(39eff0522c4bf59f).(GL_STENCILcxx . . $ `<external>/11565930711847777359/gl.h:466:9`!, 0, &val);
4982 }
4983 }
4984 }
4985 #endif
4986 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4987 }
4988
4989 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_end_passcxx . . $ _sg_end_pass(49f6e7a06ebc5aa8).(void) {
4990 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.in_pass);
4991 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
4992
4993 /* if this was an offscreen pass, and MSAA rendering was used, need
4994 to resolve into the pass images */
4995 #if !defined(SOKOL_GLES2)
4996 if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. && _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass.) {
4997 /* check if the pass object is still valid */
4998 const _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass.;
4999 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass->slot.id == _sg.gl.cur_pass_id.id);
5000 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_msaa = (0 != _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass.->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[0].gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.);
5001 if (is_msaa) {
5002 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass->gl_fb);
5003 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_READ_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:994:9`!, pass->gl_fbcxx . . $ $anonymous_type_ded6a5455d648ef8_17#gl_fb.);
5004 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass->color_atts[0].image);
5005 const int w = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[0].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width.;
5006 const int h = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[0].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height.;
5007 for (int att_index = 0; att_index < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; att_index++) {
5008 const _sg_attachment_tcxx . . $ _sg_attachment_t#* att = &pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[att_index];
5009 if (att->imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.) {
5010 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(att->gl_msaa_resolve_buffer);
5011 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_DRAW_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:995:9`!, att->gl_msaa_resolve_buffercxx . . $ $anonymous_type_ded6a5455d648ef8_16#gl_msaa_resolve_buffer.);
5012 glReadBuffercxx . . $ glReadBuffer(cb2f890c2fdad230).(GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`! + att_index);
5013 const GLenumcxx . . $ GLenum# gl_att = GL_COLOR_ATTACHMENT0cxx . . $ `<external>/13868558256673015710/glext.h:1010:9`!;
5014 glDrawBufferscxx . . $ glDrawBuffers(5becf8d0d67ba4cc).(1, &gl_att);
5015 glBlitFramebuffercxx . . $ glBlitFramebuffer(3f3cfd264f058b6e).(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BITcxx . . $ `<external>/11565930711847777359/gl.h:682:9`!, GL_NEARESTcxx . . $ `<external>/11565930711847777359/gl.h:644:9`!);
5016 }
5017 else {
5018 break;
5019 }
5020 }
5021 }
5022 }
5023 #endif
5024 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass. = 0;
5025 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_idcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_id..idcxx . . $ sg_pass#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
5026 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_widthcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_width. = 0;
5027 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_heightcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_height. = 0;
5028
5029 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.cur_context);
5030 glBindFramebuffercxx . . $ glBindFramebuffer(b4d55b1286ff73e8).(GL_FRAMEBUFFERcxx . . $ `<external>/13868558256673015710/glext.h:1044:9`!, _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_context.->default_framebuffercxx . . $ $anonymous_type_ded6a5455d648ef8_18#default_framebuffer.);
5031 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..in_passcxx . . $ $anonymous_type_ded6a5455d648ef8_22#in_pass. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
5032 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5033 }
5034
5035 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_apply_viewportcxx . . $ _sg_apply_viewport(d7a7761809021567).(int x, int y, int w, int h, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left) {
5036 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.in_pass);
5037 y = origin_top_left ? (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_heightcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_height. - (y+h)) : y;
5038 glViewportcxx . . $ glViewport(748afa4755bc9595).(x, y, w, h);
5039 }
5040
5041 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_apply_scissor_rectcxx . . $ _sg_apply_scissor_rect(d7a7761809021567).(int x, int y, int w, int h, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left) {
5042 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.in_pass);
5043 y = origin_top_left ? (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cur_pass_heightcxx . . $ $anonymous_type_ded6a5455d648ef8_22#cur_pass_height. - (y+h)) : y;
5044 glScissorcxx . . $ glScissor(748afa4755bc9595).(x, y, w, h);
5045 }
5046
5047 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_apply_pipelinecxx . . $ _sg_apply_pipeline(ead8d739235dacd3).(_sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip) {
5048 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip);
5049 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip->shader);
5050 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5051 if ((_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline. != pip) || (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipeline_idcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline_id..idcxx . . $ sg_pipeline#id. != pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.)) {
5052 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline. = pip;
5053 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipeline_idcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline_id..idcxx . . $ sg_pipeline#id. = pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
5054 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_primitive_type. = _sg_gl_primitive_typecxx . . $ _sg_gl_primitive_type(a61e21cb2eca1e09).(pip->primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_15#primitive_type.);
5055 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_index_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_index_type. = _sg_gl_index_typecxx . . $ _sg_gl_index_type(70b3963abd55fd2a).(pip->index_typecxx . . $ $anonymous_type_ded6a5455d648ef8_15#index_type.);
5056
5057 /* update depth-stencil state */
5058 const sg_depth_stencil_statecxx . . $ sg_depth_stencil_state#* new_ds = &pip->depth_stencilcxx . . $ $anonymous_type_ded6a5455d648ef8_15#depth_stencil.;
5059 sg_depth_stencil_statecxx . . $ sg_depth_stencil_state#* cache_ds = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..dscxx . . $ $anonymous_type_ded6a5455d648ef8_21#ds.;
5060 if (new_ds->depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func. != cache_ds->depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func.) {
5061 cache_ds->depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func. = new_ds->depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func.;
5062 glDepthFunccxx . . $ glDepthFunc(cb2f890c2fdad230).(_sg_gl_compare_funccxx . . $ _sg_gl_compare_func(2deec0e3607cac).(new_ds->depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func.));
5063 }
5064 if (new_ds->depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled. != cache_ds->depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled.) {
5065 cache_ds->depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled. = new_ds->depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled.;
5066 glDepthMaskcxx . . $ glDepthMask(ac50b47256ae7414).(new_ds->depth_write_enabledcxx . . $ sg_depth_stencil_state#depth_write_enabled.);
5067 }
5068 if (new_ds->stencil_enabledcxx . . $ sg_depth_stencil_state#stencil_enabled. != cache_ds->stencil_enabledcxx . . $ sg_depth_stencil_state#stencil_enabled.) {
5069 cache_ds->stencil_enabledcxx . . $ sg_depth_stencil_state#stencil_enabled. = new_ds->stencil_enabledcxx . . $ sg_depth_stencil_state#stencil_enabled.;
5070 if (new_ds->stencil_enabledcxx . . $ sg_depth_stencil_state#stencil_enabled.) glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_STENCIL_TESTcxx . . $ `<external>/11565930711847777359/gl.h:415:9`!);
5071 else glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_STENCIL_TESTcxx . . $ `<external>/11565930711847777359/gl.h:415:9`!);
5072 }
5073 if (new_ds->stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask. != cache_ds->stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask.) {
5074 cache_ds->stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask. = new_ds->stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask.;
5075 glStencilMaskcxx . . $ glStencilMask(cb2f890c2fdad230).(new_ds->stencil_write_maskcxx . . $ sg_depth_stencil_state#stencil_write_mask.);
5076 }
5077 for (int i = 0; i < 2; i++) {
5078 const sg_stencil_statecxx . . $ sg_stencil_state#* new_ss = (i==0)? &new_ds->stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front. : &new_ds->stencil_backcxx . . $ sg_depth_stencil_state#stencil_back.;
5079 sg_stencil_statecxx . . $ sg_stencil_state#* cache_ss = (i==0)? &cache_ds->stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front. : &cache_ds->stencil_backcxx . . $ sg_depth_stencil_state#stencil_back.;
5080 GLenumcxx . . $ GLenum# gl_face = (i==0)? GL_FRONTcxx . . $ `<external>/11565930711847777359/gl.h:236:9`! : GL_BACKcxx . . $ `<external>/11565930711847777359/gl.h:237:9`!;
5081 if ((new_ss->compare_funccxx . . $ sg_stencil_state#compare_func. != cache_ss->compare_funccxx . . $ sg_stencil_state#compare_func.) ||
5082 (new_ds->stencil_read_maskcxx . . $ sg_depth_stencil_state#stencil_read_mask. != cache_ds->stencil_read_maskcxx . . $ sg_depth_stencil_state#stencil_read_mask.) ||
5083 (new_ds->stencil_refcxx . . $ sg_depth_stencil_state#stencil_ref. != cache_ds->stencil_refcxx . . $ sg_depth_stencil_state#stencil_ref.))
5084 {
5085 cache_ss->compare_funccxx . . $ sg_stencil_state#compare_func. = new_ss->compare_funccxx . . $ sg_stencil_state#compare_func.;
5086 glStencilFuncSeparatecxx . . $ glStencilFuncSeparate(c6bb8984eadc87ea).(gl_face,
5087 _sg_gl_compare_funccxx . . $ _sg_gl_compare_func(2deec0e3607cac).(new_ss->compare_funccxx . . $ sg_stencil_state#compare_func.),
5088 new_ds->stencil_refcxx . . $ sg_depth_stencil_state#stencil_ref.,
5089 new_ds->stencil_read_maskcxx . . $ sg_depth_stencil_state#stencil_read_mask.);
5090 }
5091 if ((new_ss->fail_opcxx . . $ sg_stencil_state#fail_op. != cache_ss->fail_opcxx . . $ sg_stencil_state#fail_op.) ||
5092 (new_ss->depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op. != cache_ss->depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op.) ||
5093 (new_ss->pass_opcxx . . $ sg_stencil_state#pass_op. != cache_ss->pass_opcxx . . $ sg_stencil_state#pass_op.))
5094 {
5095 cache_ss->fail_opcxx . . $ sg_stencil_state#fail_op. = new_ss->fail_opcxx . . $ sg_stencil_state#fail_op.;
5096 cache_ss->depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op. = new_ss->depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op.;
5097 cache_ss->pass_opcxx . . $ sg_stencil_state#pass_op. = new_ss->pass_opcxx . . $ sg_stencil_state#pass_op.;
5098 glStencilOpSeparatecxx . . $ glStencilOpSeparate(eda338842932bf2b).(gl_face,
5099 _sg_gl_stencil_opcxx . . $ _sg_gl_stencil_op(5b1cd35c1241aee).(new_ss->fail_opcxx . . $ sg_stencil_state#fail_op.),
5100 _sg_gl_stencil_opcxx . . $ _sg_gl_stencil_op(5b1cd35c1241aee).(new_ss->depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op.),
5101 _sg_gl_stencil_opcxx . . $ _sg_gl_stencil_op(5b1cd35c1241aee).(new_ss->pass_opcxx . . $ sg_stencil_state#pass_op.));
5102 }
5103 }
5104 cache_ds->stencil_read_maskcxx . . $ sg_depth_stencil_state#stencil_read_mask. = new_ds->stencil_read_maskcxx . . $ sg_depth_stencil_state#stencil_read_mask.;
5105 cache_ds->stencil_refcxx . . $ sg_depth_stencil_state#stencil_ref. = new_ds->stencil_refcxx . . $ sg_depth_stencil_state#stencil_ref.;
5106
5107 /* update blend state */
5108 const sg_blend_statecxx . . $ sg_blend_state#* new_b = &pip->blendcxx . . $ $anonymous_type_ded6a5455d648ef8_15#blend.;
5109 sg_blend_statecxx . . $ sg_blend_state#* cache_b = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..blendcxx . . $ $anonymous_type_ded6a5455d648ef8_21#blend.;
5110 if (new_b->enabledcxx . . $ sg_blend_state#enabled. != cache_b->enabledcxx . . $ sg_blend_state#enabled.) {
5111 cache_b->enabledcxx . . $ sg_blend_state#enabled. = new_b->enabledcxx . . $ sg_blend_state#enabled.;
5112 if (new_b->enabledcxx . . $ sg_blend_state#enabled.) glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_BLENDcxx . . $ `<external>/11565930711847777359/gl.h:337:9`!);
5113 else glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_BLENDcxx . . $ `<external>/11565930711847777359/gl.h:337:9`!);
5114 }
5115 if ((new_b->src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb. != cache_b->src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb.) ||
5116 (new_b->dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb. != cache_b->dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb.) ||
5117 (new_b->src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha. != cache_b->src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha.) ||
5118 (new_b->dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha. != cache_b->dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha.))
5119 {
5120 cache_b->src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb. = new_b->src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb.;
5121 cache_b->dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb. = new_b->dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb.;
5122 cache_b->src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha. = new_b->src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha.;
5123 cache_b->dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha. = new_b->dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha.;
5124 glBlendFuncSeparatecxx . . $ glBlendFuncSeparate(eda338842932bf2b).(_sg_gl_blend_factorcxx . . $ _sg_gl_blend_factor(46b9e0c28961cdc1).(new_b->src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb.),
5125 _sg_gl_blend_factorcxx . . $ _sg_gl_blend_factor(46b9e0c28961cdc1).(new_b->dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb.),
5126 _sg_gl_blend_factorcxx . . $ _sg_gl_blend_factor(46b9e0c28961cdc1).(new_b->src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha.),
5127 _sg_gl_blend_factorcxx . . $ _sg_gl_blend_factor(46b9e0c28961cdc1).(new_b->dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha.));
5128 }
5129 if ((new_b->op_rgbcxx . . $ sg_blend_state#op_rgb. != cache_b->op_rgbcxx . . $ sg_blend_state#op_rgb.) || (new_b->op_alphacxx . . $ sg_blend_state#op_alpha. != cache_b->op_alphacxx . . $ sg_blend_state#op_alpha.)) {
5130 cache_b->op_rgbcxx . . $ sg_blend_state#op_rgb. = new_b->op_rgbcxx . . $ sg_blend_state#op_rgb.;
5131 cache_b->op_alphacxx . . $ sg_blend_state#op_alpha. = new_b->op_alphacxx . . $ sg_blend_state#op_alpha.;
5132 glBlendEquationSeparatecxx . . $ glBlendEquationSeparate(b4d55b1286ff73e8).(_sg_gl_blend_opcxx . . $ _sg_gl_blend_op(5a0d0156c79469ed).(new_b->op_rgbcxx . . $ sg_blend_state#op_rgb.), _sg_gl_blend_opcxx . . $ _sg_gl_blend_op(5a0d0156c79469ed).(new_b->op_alphacxx . . $ sg_blend_state#op_alpha.));
5133 }
5134 if (new_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask. != cache_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask.) {
5135 cache_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask. = new_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask.;
5136 glColorMaskcxx . . $ glColorMask(bfb537490240b335).((new_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask. & SG_COLORMASK_Rcxx . . $ SG_COLORMASK_R.) != 0,
5137 (new_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask. & SG_COLORMASK_Gcxx . . $ SG_COLORMASK_G.) != 0,
5138 (new_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask. & SG_COLORMASK_Bcxx . . $ SG_COLORMASK_B.) != 0,
5139 (new_b->color_write_maskcxx . . $ sg_blend_state#color_write_mask. & SG_COLORMASK_Acxx . . $ SG_COLORMASK_A.) != 0);
5140 }
5141 if (!_sg_fequalcxx . . $ `demo/sokol/sokol_gfx.h:2172:9`!(new_b->blend_color[0], cache_b->blend_color[0], 0.0001f) ||
5142 !_sg_fequalcxx . . $ sg_blend_state#blend_color.(new_b->blend_color[1], cache_b->blend_color[1], 0.0001f) ||
5143 !_sg_fequalcxx . . $ sg_blend_state#blend_color.(new_b->blend_color[2], cache_b->blend_color[2], 0.0001f) ||
5144 !_sg_fequalcxx . . $ sg_blend_state#blend_color.(new_b->blend_color[3], cache_b->blend_color[3], 0.0001f))
5145 {
5146 const float* bc = new_b->blend_colorcxx . . $ sg_blend_state#blend_color.;
5147 for (int i=0; i<4; i++) {
5148 cache_b->blend_colorcxx . . $ sg_blend_state#blend_color.[i] = bc[i];
5149 }
5150 glBlendColorcxx . . $ glBlendColor(7e9a355db6148521).(bc[0], bc[1], bc[2], bc[3]);
5151 }
5152
5153 /* update rasterizer state */
5154 const sg_rasterizer_statecxx . . $ sg_rasterizer_state#* new_r = &pip->rastcxx . . $ $anonymous_type_ded6a5455d648ef8_15#rast.;
5155 sg_rasterizer_statecxx . . $ sg_rasterizer_state#* cache_r = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..rastcxx . . $ $anonymous_type_ded6a5455d648ef8_21#rast.;
5156 if (new_r->cull_modecxx . . $ sg_rasterizer_state#cull_mode. != cache_r->cull_modecxx . . $ sg_rasterizer_state#cull_mode.) {
5157 cache_r->cull_modecxx . . $ sg_rasterizer_state#cull_mode. = new_r->cull_modecxx . . $ sg_rasterizer_state#cull_mode.;
5158 if (SG_CULLMODE_NONEcxx . . $ SG_CULLMODE_NONE. == new_r->cull_modecxx . . $ sg_rasterizer_state#cull_mode.) {
5159 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_CULL_FACEcxx . . $ `<external>/11565930711847777359/gl.h:242:9`!);
5160 }
5161 else {
5162 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_CULL_FACEcxx . . $ `<external>/11565930711847777359/gl.h:242:9`!);
5163 GLenumcxx . . $ GLenum# gl_mode = (SG_CULLMODE_FRONTcxx . . $ SG_CULLMODE_FRONT. == new_r->cull_modecxx . . $ sg_rasterizer_state#cull_mode.) ? GL_FRONTcxx . . $ `<external>/11565930711847777359/gl.h:236:9`! : GL_BACKcxx . . $ `<external>/11565930711847777359/gl.h:237:9`!;
5164 glCullFacecxx . . $ glCullFace(cb2f890c2fdad230).(gl_mode);
5165 }
5166 }
5167 if (new_r->face_windingcxx . . $ sg_rasterizer_state#face_winding. != cache_r->face_windingcxx . . $ sg_rasterizer_state#face_winding.) {
5168 cache_r->face_windingcxx . . $ sg_rasterizer_state#face_winding. = new_r->face_windingcxx . . $ sg_rasterizer_state#face_winding.;
5169 GLenumcxx . . $ GLenum# gl_winding = (SG_FACEWINDING_CWcxx . . $ SG_FACEWINDING_CW. == new_r->face_windingcxx . . $ sg_rasterizer_state#face_winding.) ? GL_CWcxx . . $ `<external>/11565930711847777359/gl.h:234:9`! : GL_CCWcxx . . $ `<external>/11565930711847777359/gl.h:235:9`!;
5170 glFrontFacecxx . . $ glFrontFace(cb2f890c2fdad230).(gl_winding);
5171 }
5172 if (new_r->alpha_to_coverage_enabledcxx . . $ sg_rasterizer_state#alpha_to_coverage_enabled. != cache_r->alpha_to_coverage_enabledcxx . . $ sg_rasterizer_state#alpha_to_coverage_enabled.) {
5173 cache_r->alpha_to_coverage_enabledcxx . . $ sg_rasterizer_state#alpha_to_coverage_enabled. = new_r->alpha_to_coverage_enabledcxx . . $ sg_rasterizer_state#alpha_to_coverage_enabled.;
5174 if (new_r->alpha_to_coverage_enabledcxx . . $ sg_rasterizer_state#alpha_to_coverage_enabled.) glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_SAMPLE_ALPHA_TO_COVERAGEcxx . . $ `<external>/11565930711847777359/gl.h:1776:9`!);
5175 else glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_SAMPLE_ALPHA_TO_COVERAGEcxx . . $ `<external>/11565930711847777359/gl.h:1776:9`!);
5176 }
5177 #ifdef SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!
5178 if (new_r->sample_countcxx . . $ sg_rasterizer_state#sample_count. != cache_r->sample_countcxx . . $ sg_rasterizer_state#sample_count.) {
5179 cache_r->sample_countcxx . . $ sg_rasterizer_state#sample_count. = new_r->sample_countcxx . . $ sg_rasterizer_state#sample_count.;
5180 if (new_r->sample_countcxx . . $ sg_rasterizer_state#sample_count. > 1) glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_MULTISAMPLEcxx . . $ `<external>/11565930711847777359/gl.h:1775:9`!);
5181 else glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_MULTISAMPLEcxx . . $ `<external>/11565930711847777359/gl.h:1775:9`!);
5182 }
5183 #endif
5184 if (!_sg_fequalcxx . . $ `demo/sokol/sokol_gfx.h:2172:9`!(new_r->depth_bias, cache_r->depth_bias, 0.000001f) ||
5185 !_sg_fequalcxx . . $ sg_rasterizer_state#depth_bias_slope_scale.(new_r->depth_bias_slope_scale, cache_r->depth_bias_slope_scale, 0.000001f))
5186 {
5187 /* according to ANGLE's D3D11 backend:
5188 D3D11 SlopeScaledDepthBias ==> GL polygonOffsetFactor
5189 D3D11 DepthBias ==> GL polygonOffsetUnits
5190 DepthBiasClamp has no meaning on GL
5191 */
5192 cache_r->depth_biascxx . . $ sg_rasterizer_state#depth_bias. = new_r->depth_biascxx . . $ sg_rasterizer_state#depth_bias.;
5193 cache_r->depth_bias_slope_scalecxx . . $ sg_rasterizer_state#depth_bias_slope_scale. = new_r->depth_bias_slope_scalecxx . . $ sg_rasterizer_state#depth_bias_slope_scale.;
5194 glPolygonOffsetcxx . . $ glPolygonOffset(5102ef758adc0ae7).(new_r->depth_bias_slope_scalecxx . . $ sg_rasterizer_state#depth_bias_slope_scale., new_r->depth_biascxx . . $ sg_rasterizer_state#depth_bias.);
5195 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! po_enabled = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
5196 if (_sg_fequalcxx . . $ sg_rasterizer_state#depth_bias.(new_r->depth_bias, 0.0f, 0.000001f) &&
5197 _sg_fequalcxx . . $ `demo/sokol/sokol_gfx.h:2172:9`!(new_r->depth_bias_slope_scale, 0.0f, 0.000001f))
5198 {
5199 po_enabled = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
5200 }
5201 if (po_enabled != _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..polygon_offset_enabledcxx . . $ $anonymous_type_ded6a5455d648ef8_21#polygon_offset_enabled.) {
5202 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..polygon_offset_enabledcxx . . $ $anonymous_type_ded6a5455d648ef8_21#polygon_offset_enabled. = po_enabled;
5203 if (po_enabled) glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_POLYGON_OFFSET_FILLcxx . . $ `<external>/11565930711847777359/gl.h:249:9`!);
5204 else glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_POLYGON_OFFSET_FILLcxx . . $ `<external>/11565930711847777359/gl.h:249:9`!);
5205 }
5206 }
5207
5208 /* bind shader program */
5209 glUseProgramcxx . . $ glUseProgram(cb2f890c2fdad230).(pip->shadercxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader.->gl_progcxx . . $ $anonymous_type_ded6a5455d648ef8_13#gl_prog.);
5210 }
5211 }
5212
5213 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_apply_bindingscxx . . $ _sg_apply_bindings(cf8aec0e05ceb70c).(
5214 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip,
5215 _sg_buffer_tcxx . . $ _sg_buffer_t#** vbs, const int* vb_offsets, int num_vbs,
5216 _sg_buffer_tcxx . . $ _sg_buffer_t#* ib, int ib_offset,
5217 _sg_image_tcxx . . $ _sg_image_t#** vs_imgs, int num_vs_imgs,
5218 _sg_image_tcxx . . $ _sg_image_t#** fs_imgs, int num_fs_imgs)
5219 {
5220 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip);
5221 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(num_fs_imgs);
5222 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(num_vs_imgs);
5223 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(num_vbs);
5224 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5225
5226 /* bind textures */
5227 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5228 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGEScxx . . $ SG_NUM_SHADER_STAGES.; stage_index++) {
5229 const _sg_shader_stage_tcxx . . $ _sg_shader_stage_t#* stage = &pip->shadercxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader.->stagecxx . . $ $anonymous_type_ded6a5455d648ef8_13#stage.[stage_index];
5230 _sg_image_tcxx . . $ _sg_image_t#** imgs = (stage_index == SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS.)? vs_imgs : fs_imgs;
5231 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(((stage_index == SG_SHADERSTAGE_VS)? num_vs_imgs : num_fs_imgs) == stage->num_images);
5232 for (int img_index = 0; img_index < stage->num_imagescxx . . $ $anonymous_type_ded6a5455d648ef8_12#num_images.; img_index++) {
5233 const _sg_shader_image_tcxx . . $ _sg_shader_image_t#* shd_img = &stage->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_12#images.[img_index];
5234 if (shd_img->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_loc. != -1) {
5235 _sg_image_tcxx . . $ _sg_image_t#* img = imgs[img_index];
5236 const GLuintcxx . . $ GLuint# gl_tex = img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[img->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot.];
5237 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img && img->gl_target);
5238 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((shd_img->gl_tex_slot != -1) && gl_tex);
5239 glUniform1icxx . . $ glUniform1i(3e454b8ccf442868).(shd_img->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_loc., shd_img->gl_tex_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_tex_slot.);
5240 _sg_gl_bind_texturecxx . . $ _sg_gl_bind_texture(2029de666eaec704).(shd_img->gl_tex_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_10#gl_tex_slot., img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., gl_tex);
5241 }
5242 }
5243 }
5244 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5245
5246 /* index buffer (can be 0) */
5247 const GLuintcxx . . $ GLuint# gl_ib = ib ? ib->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[ib->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot.] : 0;
5248 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(GL_ELEMENT_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:459:9`!, gl_ib);
5249 _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_ib_offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_ib_offset. = ib_offset;
5250
5251 /* vertex attributes */
5252 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; attr_index++) {
5253 _sg_gl_attr_tcxx . . $ _sg_gl_attr_t#* attr = &pip->gl_attrscxx . . $ $anonymous_type_ded6a5455d648ef8_15#gl_attrs.[attr_index];
5254 _sg_gl_cache_attr_tcxx . . $ _sg_gl_cache_attr_t#* cache_attr = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..attrscxx . . $ $anonymous_type_ded6a5455d648ef8_21#attrs.[attr_index];
5255 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! cache_attr_dirty = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
5256 int vb_offset = 0;
5257 GLuintcxx . . $ GLuint# gl_vb = 0;
5258 if (attr->vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index. >= 0) {
5259 /* attribute is enabled */
5260 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(attr->vb_index < num_vbs);
5261 _sg_buffer_tcxx . . $ _sg_buffer_t#* vb = vbs[attr->vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index.];
5262 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(vb);
5263 gl_vb = vb->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[vb->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot.];
5264 vb_offset = vb_offsets[attr->vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index.] + attr->offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_14#offset.;
5265 if ((gl_vb != cache_attr->gl_vbufcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_vbuf.) ||
5266 (attr->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_14#size. != cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_14#size.) ||
5267 (attr->typecxx . . $ $anonymous_type_ded6a5455d648ef8_14#type. != cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..typecxx . . $ $anonymous_type_ded6a5455d648ef8_14#type.) ||
5268 (attr->normalizedcxx . . $ $anonymous_type_ded6a5455d648ef8_14#normalized. != cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..normalizedcxx . . $ $anonymous_type_ded6a5455d648ef8_14#normalized.) ||
5269 (attr->stridecxx . . $ $anonymous_type_ded6a5455d648ef8_14#stride. != cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..stridecxx . . $ $anonymous_type_ded6a5455d648ef8_14#stride.) ||
5270 (vb_offset != cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_14#offset.) ||
5271 (cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor. != attr->divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor.))
5272 {
5273 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(GL_ARRAY_BUFFERcxx . . $ `<external>/13868558256673015710/glext.h:458:9`!, gl_vb);
5274 glVertexAttribPointercxx . . $ glVertexAttribPointer(53a168f9c9710f4c).(attr_index, attr->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_14#size., attr->typecxx . . $ $anonymous_type_ded6a5455d648ef8_14#type.,
5275 attr->normalizedcxx . . $ $anonymous_type_ded6a5455d648ef8_14#normalized., attr->stridecxx . . $ $anonymous_type_ded6a5455d648ef8_14#stride.,
5276 (const GLvoidcxx . . $ GLvoid#*)(GLintptrcxx . . $ GLintptr#)vb_offset);
5277 #ifdef SOKOL_INSTANCING_ENABLEDcxx . . $ `demo/sokol/sokol_gfx.h:2093:16`!
5278 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_INSTANCINGcxx . . $ SG_FEATURE_INSTANCING.]) {
5279 glVertexAttribDivisorcxx . . $ glVertexAttribDivisor(b4d55b1286ff73e8).(attr_index, attr->divisorcxx . . $ $anonymous_type_ded6a5455d648ef8_14#divisor.);
5280 }
5281 #endif
5282 cache_attr_dirty = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
5283 }
5284 if (cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index. == -1) {
5285 glEnableVertexAttribArraycxx . . $ glEnableVertexAttribArray(cb2f890c2fdad230).(attr_index);
5286 cache_attr_dirty = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
5287 }
5288 }
5289 else {
5290 /* attribute is disabled */
5291 if (cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..vb_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_14#vb_index. != -1) {
5292 glDisableVertexAttribArraycxx . . $ glDisableVertexAttribArray(cb2f890c2fdad230).(attr_index);
5293 cache_attr_dirty = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
5294 }
5295 }
5296 if (cache_attr_dirty) {
5297 cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr. = *attr;
5298 cache_attr->gl_attrcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_attr..offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_14#offset. = vb_offset;
5299 cache_attr->gl_vbufcxx . . $ $anonymous_type_ded6a5455d648ef8_19#gl_vbuf. = gl_vb;
5300 }
5301 }
5302 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5303 }
5304
5305 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_apply_uniformscxx . . $ _sg_apply_uniforms(d4a2e1eb7e556ec4).(sg_shader_stagecxx . . $ sg_shader_stage# stage_index, int ub_index, const void* data, int num_bytes) {
5306 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(num_bytes);
5307 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(data && (num_bytes > 0));
5308 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((stage_index >= 0) && ((int)stage_index < SG_NUM_SHADER_STAGES));
5309 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.cache.cur_pipeline);
5310 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.cache.cur_pipeline->slot.id == _sg.gl.cache.cur_pipeline_id.id);
5311 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_sg.gl.cache.cur_pipeline->shader->slot.id == _sg.gl.cache.cur_pipeline->shader_id.id);
5312 _sg_shader_stage_tcxx . . $ _sg_shader_stage_t#* stage = &_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_pipeline.->shadercxx . . $ $anonymous_type_ded6a5455d648ef8_15#shader.->stagecxx . . $ $anonymous_type_ded6a5455d648ef8_13#stage.[stage_index];
5313 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ub_index < stage->num_uniform_blocks);
5314 _sg_uniform_block_tcxx . . $ _sg_uniform_block_t#* ub = &stage->uniform_blockscxx . . $ $anonymous_type_ded6a5455d648ef8_12#uniform_blocks.[ub_index];
5315 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ub->size == num_bytes);
5316 for (int u_index = 0; u_index < ub->num_uniformscxx . . $ $anonymous_type_ded6a5455d648ef8_9#num_uniforms.; u_index++) {
5317 _sg_uniform_tcxx . . $ _sg_uniform_t#* u = &ub->uniformscxx . . $ $anonymous_type_ded6a5455d648ef8_9#uniforms.[u_index];
5318 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(u->type != SG_UNIFORMTYPE_INVALID);
5319 if (u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc. == -1) {
5320 continue;
5321 }
5322 GLfloatcxx . . $ GLfloat#* ptr = (GLfloatcxx . . $ GLfloat#*) (((uint8_tcxx . . $ uint8_t#*)data) + u->offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_8#offset.);
5323 switch (u->typecxx . . $ $anonymous_type_ded6a5455d648ef8_8#type.) {
5324 case SG_UNIFORMTYPE_INVALIDcxx . . $ SG_UNIFORMTYPE_INVALID.:
5325 break;
5326 case SG_UNIFORMTYPE_FLOATcxx . . $ SG_UNIFORMTYPE_FLOAT.:
5327 glUniform1fvcxx . . $ glUniform1fv(269012fc1b4ba7ac).(u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc., u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count., ptr);
5328 break;
5329 case SG_UNIFORMTYPE_FLOAT2cxx . . $ SG_UNIFORMTYPE_FLOAT2.:
5330 glUniform2fvcxx . . $ glUniform2fv(269012fc1b4ba7ac).(u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc., u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count., ptr);
5331 break;
5332 case SG_UNIFORMTYPE_FLOAT3cxx . . $ SG_UNIFORMTYPE_FLOAT3.:
5333 glUniform3fvcxx . . $ glUniform3fv(269012fc1b4ba7ac).(u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc., u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count., ptr);
5334 break;
5335 case SG_UNIFORMTYPE_FLOAT4cxx . . $ SG_UNIFORMTYPE_FLOAT4.:
5336 glUniform4fvcxx . . $ glUniform4fv(269012fc1b4ba7ac).(u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc., u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count., ptr);
5337 break;
5338 case SG_UNIFORMTYPE_MAT4cxx . . $ SG_UNIFORMTYPE_MAT4.:
5339 glUniformMatrix4fvcxx . . $ glUniformMatrix4fv(6ff70e03c1e0db28).(u->gl_loccxx . . $ $anonymous_type_ded6a5455d648ef8_8#gl_loc., u->countcxx . . $ $anonymous_type_ded6a5455d648ef8_8#count., GL_FALSEcxx . . $ `<external>/11565930711847777359/gl.h:139:9`!, ptr);
5340 break;
5341 default:
5342 SOKOL_UNREACHABLEcxx . . $ `demo/sokol/sokol_gfx.h:1967:13`!;
5343 break;
5344 }
5345 }
5346 }
5347
5348 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_drawcxx . . $ _sg_draw(b1146eedae1e1d0b).(int base_element, int num_elements, int num_instances) {
5349 const GLenumcxx . . $ GLenum# i_type = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_index_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_index_type.;
5350 const GLenumcxx . . $ GLenum# p_type = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_primitive_typecxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_primitive_type.;
5351 if (0 != i_type) {
5352 /* indexed rendering */
5353 const int i_size = (i_type == GL_UNSIGNED_SHORTcxx . . $ `<external>/11565930711847777359/gl.h:146:9`!) ? 2 : 4;
5354 const int ib_offset = _sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..cachecxx . . $ $anonymous_type_ded6a5455d648ef8_22#cache..cur_ib_offsetcxx . . $ $anonymous_type_ded6a5455d648ef8_21#cur_ib_offset.;
5355 const GLvoidcxx . . $ GLvoid#* indices = (const GLvoidcxx . . $ GLvoid#*)(GLintptrcxx . . $ GLintptr#)(base_element*i_size+ib_offset);
5356 if (num_instances == 1) {
5357 glDrawElementscxx . . $ glDrawElements(4413f7b83c322ec9).(p_type, num_elements, i_type, indices);
5358 }
5359 else {
5360 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_INSTANCINGcxx . . $ SG_FEATURE_INSTANCING.]) {
5361 glDrawElementsInstancedcxx . . $ glDrawElementsInstanced(aeccd37f3ecfe0).(p_type, num_elements, i_type, indices, num_instances);
5362 }
5363 }
5364 }
5365 else {
5366 /* non-indexed rendering */
5367 if (num_instances == 1) {
5368 glDrawArrayscxx . . $ glDrawArrays(8c880916ccadf15d).(p_type, base_element, num_elements);
5369 }
5370 else {
5371 if (_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..featurescxx . . $ $anonymous_type_ded6a5455d648ef8_22#features.[SG_FEATURE_INSTANCINGcxx . . $ SG_FEATURE_INSTANCING.]) {
5372 glDrawArraysInstancedcxx . . $ glDrawArraysInstanced(10de3014ec658f6e).(p_type, base_element, num_elements, num_instances);
5373 }
5374 }
5375 }
5376 }
5377
5378 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_commitcxx . . $ _sg_commit(49f6e7a06ebc5aa8).(void) {
5379 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(!_sg.gl.in_pass);
5380 /* "soft" clear bindings (only those that are actually bound) */
5381 _sg_gl_clear_buffer_bindingscxx . . $ _sg_gl_clear_buffer_bindings(b45ddcbc8423892c).(falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!);
5382 _sg_gl_clear_texture_bindingscxx . . $ _sg_gl_clear_texture_bindings(b45ddcbc8423892c).(falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!);
5383 }
5384
5385 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_update_buffercxx . . $ _sg_update_buffer(51a9894585396fe3).(_sg_buffer_tcxx . . $ _sg_buffer_t#* buf, const void* data_ptr, int data_size) {
5386 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf && data_ptr && (data_size > 0));
5387 /* only one update per buffer per frame allowed */
5388 if (++buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot. >= buf->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots.) {
5389 buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot. = 0;
5390 }
5391 GLenumcxx . . $ GLenum# gl_tgt = _sg_gl_buffer_targetcxx . . $ _sg_gl_buffer_target(49ff54eba56abf56).(buf->typecxx . . $ $anonymous_type_ded6a5455d648ef8_6#type.);
5392 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf->active_slot < SG_NUM_INFLIGHT_FRAMES);
5393 GLuintcxx . . $ GLuint# gl_buf = buf->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot.];
5394 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_buf);
5395 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5396 _sg_gl_store_buffer_bindingcxx . . $ _sg_gl_store_buffer_binding(cb2f890c2fdad230).(gl_tgt);
5397 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(gl_tgt, gl_buf);
5398 glBufferSubDatacxx . . $ glBufferSubData(5641a406ecdfaca9).(gl_tgt, 0, data_size, data_ptr);
5399 _sg_gl_restore_buffer_bindingcxx . . $ _sg_gl_restore_buffer_binding(cb2f890c2fdad230).(gl_tgt);
5400 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5401 }
5402
5403 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_append_buffercxx . . $ _sg_append_buffer(336344918ff6a016).(_sg_buffer_tcxx . . $ _sg_buffer_t#* buf, const void* data_ptr, int data_size, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! new_frame) {
5404 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf && data_ptr && (data_size > 0));
5405 if (new_frame) {
5406 if (++buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot. >= buf->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots.) {
5407 buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot. = 0;
5408 }
5409 }
5410 GLenumcxx . . $ GLenum# gl_tgt = _sg_gl_buffer_targetcxx . . $ _sg_gl_buffer_target(49ff54eba56abf56).(buf->typecxx . . $ $anonymous_type_ded6a5455d648ef8_6#type.);
5411 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf->active_slot < SG_NUM_INFLIGHT_FRAMES);
5412 GLuintcxx . . $ GLuint# gl_buf = buf->gl_bufcxx . . $ $anonymous_type_ded6a5455d648ef8_6#gl_buf.[buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot.];
5413 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(gl_buf);
5414 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5415 _sg_gl_store_buffer_bindingcxx . . $ _sg_gl_store_buffer_binding(cb2f890c2fdad230).(gl_tgt);
5416 _sg_gl_bind_buffercxx . . $ _sg_gl_bind_buffer(b4d55b1286ff73e8).(gl_tgt, gl_buf);
5417 glBufferSubDatacxx . . $ glBufferSubData(5641a406ecdfaca9).(gl_tgt, buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos., data_size, data_ptr);
5418 _sg_gl_restore_buffer_bindingcxx . . $ _sg_gl_restore_buffer_binding(cb2f890c2fdad230).(gl_tgt);
5419 _SG_GL_CHECK_ERRORcxx . . $ `demo/sokol/sokol_gfx.h:2095:13`!();
5420 }
5421
5422 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_update_imagecxx . . $ _sg_update_image(547060eb9520162c).(_sg_image_tcxx . . $ _sg_image_t#* img, const sg_image_contentcxx . . $ sg_image_content#* data) {
5423 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img && data);
5424 /* only one update per image per frame allowed */
5425 if (++img->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot. >= img->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots.) {
5426 img->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot. = 0;
5427 }
5428 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img->active_slot < SG_NUM_INFLIGHT_FRAMES);
5429 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(0 != img->gl_tex[img->active_slot]);
5430 _sg_gl_store_texture_bindingcxx . . $ _sg_gl_store_texture_binding(d4f767463ce0a6b3).(0);
5431 _sg_gl_bind_texturecxx . . $ _sg_gl_bind_texture(2029de666eaec704).(0, img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target., img->gl_texcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_tex.[img->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot.]);
5432 const GLenumcxx . . $ GLenum# gl_img_format = _sg_gl_teximage_formatcxx . . $ _sg_gl_teximage_format(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
5433 const GLenumcxx . . $ GLenum# gl_img_type = _sg_gl_teximage_typecxx . . $ _sg_gl_teximage_type(fef9f3d4b5a4d063).(img->pixel_formatcxx . . $ $anonymous_type_ded6a5455d648ef8_7#pixel_format.);
5434 const int num_faces = img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type. == SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE. ? 6 : 1;
5435 const int num_mips = img->num_mipmapscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_mipmaps.;
5436 for (int face_index = 0; face_index < num_faces; face_index++) {
5437 for (int mip_index = 0; mip_index < num_mips; mip_index++) {
5438 GLenumcxx . . $ GLenum# gl_img_target = img->gl_targetcxx . . $ $anonymous_type_ded6a5455d648ef8_7#gl_target.;
5439 if (SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) {
5440 gl_img_target = _sg_gl_cubeface_targetcxx . . $ _sg_gl_cubeface_target(46cc46841198e427).(face_index);
5441 }
5442 const GLvoidcxx . . $ GLvoid#* data_ptr = data->subimagecxx . . $ sg_image_content#subimage.[face_index][mip_index].ptrcxx . . $ sg_subimage_content#ptr.;
5443 int mip_width = img->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width. >> mip_index;
5444 if (mip_width == 0) {
5445 mip_width = 1;
5446 }
5447 int mip_height = img->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height. >> mip_index;
5448 if (mip_height == 0) {
5449 mip_height = 1;
5450 }
5451 if ((SG_IMAGETYPE_2Dcxx . . $ SG_IMAGETYPE_2D. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) || (SG_IMAGETYPE_CUBEcxx . . $ SG_IMAGETYPE_CUBE. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.)) {
5452 glTexSubImage2Dcxx . . $ glTexSubImage2D(591ddf8a4d6292ac).(gl_img_target, mip_index,
5453 0, 0,
5454 mip_width, mip_height,
5455 gl_img_format, gl_img_type,
5456 data_ptr);
5457 }
5458 #if !defined(SOKOL_GLES2)
5459 else if (!_sgcxx . . $ _sg..glcxx . . $ $anonymous_type_ded6a5455d648ef8_26#gl..gles2cxx . . $ $anonymous_type_ded6a5455d648ef8_22#gles2. && ((SG_IMAGETYPE_3Dcxx . . $ SG_IMAGETYPE_3D. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.) || (SG_IMAGETYPE_ARRAYcxx . . $ SG_IMAGETYPE_ARRAY. == img->typecxx . . $ $anonymous_type_ded6a5455d648ef8_7#type.))) {
5460 int mip_depth = img->depthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#depth. >> mip_index;
5461 if (mip_depth == 0) {
5462 mip_depth = 1;
5463 }
5464 glTexSubImage3Dcxx . . $ glTexSubImage3D(2da8118c211b9f86).(gl_img_target, mip_index,
5465 0, 0, 0,
5466 mip_width, mip_height, mip_depth,
5467 gl_img_format, gl_img_type,
5468 data_ptr);
5469
5470 }
5471 #endif
5472 }
5473 }
5474 _sg_gl_restore_texture_bindingcxx . . $ _sg_gl_restore_texture_binding(d4f767463ce0a6b3).(0);
5475 }
5476
5477 /*== D3D11 BACKEND IMPLEMENTATION ============================================*/
5478 #elif defined(SOKOL_D3D11)
5479
5480 /*-- enum translation functions ----------------------------------------------*/
5481 _SOKOL_PRIVATE D3D11_USAGE _sg_d3d11_usage(sg_usage usg) {
5482 switch (usg) {
5483 case SG_USAGE_IMMUTABLE:
5484 return D3D11_USAGE_IMMUTABLE;
5485 case SG_USAGE_DYNAMIC:
5486 case SG_USAGE_STREAM:
5487 return D3D11_USAGE_DYNAMIC;
5488 default:
5489 SOKOL_UNREACHABLE;
5490 return (D3D11_USAGE) 0;
5491 }
5492 }
5493
5494 _SOKOL_PRIVATE UINT _sg_d3d11_cpu_access_flags(sg_usage usg) {
5495 switch (usg) {
5496 case SG_USAGE_IMMUTABLE:
5497 return 0;
5498 case SG_USAGE_DYNAMIC:
5499 case SG_USAGE_STREAM:
5500 return D3D11_CPU_ACCESS_WRITE;
5501 default:
5502 SOKOL_UNREACHABLE;
5503 return 0;
5504 }
5505 }
5506
5507 _SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_texture_format(sg_pixel_format fmt) {
5508 /*
5509 NOTE: the following pixel formats are only supported on D3D11.1
5510 (we're running on D3D11.0):
5511 DXGI_FORMAT_B4G4R4A4_UNORM
5512 DXGI_FORMAT_B5G6R5_UNORM
5513 DXGI_FORMAT_B5G5R5A1_UNORM
5514 */
5515 switch (fmt) {
5516 case SG_PIXELFORMAT_RGBA8: return DXGI_FORMAT_R8G8B8A8_UNORM;
5517 case SG_PIXELFORMAT_R10G10B10A2: return DXGI_FORMAT_R10G10B10A2_UNORM;
5518 case SG_PIXELFORMAT_RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT;
5519 case SG_PIXELFORMAT_RGBA16F: return DXGI_FORMAT_R16G16B16A16_FLOAT;
5520 case SG_PIXELFORMAT_R32F: return DXGI_FORMAT_R32_FLOAT;
5521 case SG_PIXELFORMAT_R16F: return DXGI_FORMAT_R16_FLOAT;
5522 case SG_PIXELFORMAT_L8: return DXGI_FORMAT_R8_UNORM;
5523 case SG_PIXELFORMAT_DXT1: return DXGI_FORMAT_BC1_UNORM;
5524 case SG_PIXELFORMAT_DXT3: return DXGI_FORMAT_BC2_UNORM;
5525 case SG_PIXELFORMAT_DXT5: return DXGI_FORMAT_BC3_UNORM;
5526 default: return DXGI_FORMAT_UNKNOWN;
5527 };
5528 }
5529
5530 _SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_rendertarget_color_format(sg_pixel_format fmt) {
5531 switch (fmt) {
5532 case SG_PIXELFORMAT_RGBA8: return DXGI_FORMAT_R8G8B8A8_UNORM;
5533 case SG_PIXELFORMAT_RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT;
5534 case SG_PIXELFORMAT_RGBA16F: return DXGI_FORMAT_R16G16B16A16_FLOAT;
5535 case SG_PIXELFORMAT_R32F: return DXGI_FORMAT_R32_FLOAT;
5536 case SG_PIXELFORMAT_R16F: return DXGI_FORMAT_R16_FLOAT;
5537 case SG_PIXELFORMAT_L8: return DXGI_FORMAT_R8_UNORM;
5538 default: return DXGI_FORMAT_UNKNOWN;
5539 }
5540 }
5541
5542 _SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_rendertarget_depth_format(sg_pixel_format fmt) {
5543 switch (fmt) {
5544 case SG_PIXELFORMAT_DEPTH: return DXGI_FORMAT_D16_UNORM;
5545 case SG_PIXELFORMAT_DEPTHSTENCIL: return DXGI_FORMAT_D24_UNORM_S8_UINT;
5546 default: return DXGI_FORMAT_UNKNOWN;
5547 }
5548 }
5549
5550 _SOKOL_PRIVATE D3D11_PRIMITIVE_TOPOLOGY _sg_d3d11_primitive_topology(sg_primitive_type prim_type) {
5551 switch (prim_type) {
5552 case SG_PRIMITIVETYPE_POINTS: return D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
5553 case SG_PRIMITIVETYPE_LINES: return D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
5554 case SG_PRIMITIVETYPE_LINE_STRIP: return D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP;
5555 case SG_PRIMITIVETYPE_TRIANGLES: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
5556 case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
5557 default: SOKOL_UNREACHABLE; return (D3D11_PRIMITIVE_TOPOLOGY) 0;
5558 }
5559 }
5560
5561 _SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_index_format(sg_index_type index_type) {
5562 switch (index_type) {
5563 case SG_INDEXTYPE_NONE: return DXGI_FORMAT_UNKNOWN;
5564 case SG_INDEXTYPE_UINT16: return DXGI_FORMAT_R16_UINT;
5565 case SG_INDEXTYPE_UINT32: return DXGI_FORMAT_R32_UINT;
5566 default: SOKOL_UNREACHABLE; return (DXGI_FORMAT) 0;
5567 }
5568 }
5569
5570 _SOKOL_PRIVATE D3D11_FILTER _sg_d3d11_filter(sg_filter min_f, sg_filter mag_f, uint32_t max_anisotropy) {
5571 if (max_anisotropy > 1) {
5572 return D3D11_FILTER_ANISOTROPIC;
5573 }
5574 else if (mag_f == SG_FILTER_NEAREST) {
5575 switch (min_f) {
5576 case SG_FILTER_NEAREST:
5577 case SG_FILTER_NEAREST_MIPMAP_NEAREST:
5578 return D3D11_FILTER_MIN_MAG_MIP_POINT;
5579 case SG_FILTER_LINEAR:
5580 case SG_FILTER_LINEAR_MIPMAP_NEAREST:
5581 return D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT;
5582 case SG_FILTER_NEAREST_MIPMAP_LINEAR:
5583 return D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR;
5584 case SG_FILTER_LINEAR_MIPMAP_LINEAR:
5585 return D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR;
5586 default:
5587 SOKOL_UNREACHABLE; break;
5588 }
5589 }
5590 else if (mag_f == SG_FILTER_LINEAR) {
5591 switch (min_f) {
5592 case SG_FILTER_NEAREST:
5593 case SG_FILTER_NEAREST_MIPMAP_NEAREST:
5594 return D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT;
5595 case SG_FILTER_LINEAR:
5596 case SG_FILTER_LINEAR_MIPMAP_NEAREST:
5597 return D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
5598 case SG_FILTER_NEAREST_MIPMAP_LINEAR:
5599 return D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR;
5600 case SG_FILTER_LINEAR_MIPMAP_LINEAR:
5601 return D3D11_FILTER_MIN_MAG_MIP_LINEAR;
5602 default:
5603 SOKOL_UNREACHABLE; break;
5604 }
5605 }
5606 /* invalid value for mag filter */
5607 SOKOL_UNREACHABLE;
5608 return D3D11_FILTER_MIN_MAG_MIP_POINT;
5609 }
5610
5611 _SOKOL_PRIVATE D3D11_TEXTURE_ADDRESS_MODE _sg_d3d11_address_mode(sg_wrap m) {
5612 switch (m) {
5613 case SG_WRAP_REPEAT: return D3D11_TEXTURE_ADDRESS_WRAP;
5614 case SG_WRAP_CLAMP_TO_EDGE: return D3D11_TEXTURE_ADDRESS_CLAMP;
5615 case SG_WRAP_MIRRORED_REPEAT: return D3D11_TEXTURE_ADDRESS_MIRROR;
5616 default: SOKOL_UNREACHABLE; return (D3D11_TEXTURE_ADDRESS_MODE) 0;
5617 }
5618 }
5619
5620 _SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_vertex_format(sg_vertex_format fmt) {
5621 switch (fmt) {
5622 case SG_VERTEXFORMAT_FLOAT: return DXGI_FORMAT_R32_FLOAT;
5623 case SG_VERTEXFORMAT_FLOAT2: return DXGI_FORMAT_R32G32_FLOAT;
5624 case SG_VERTEXFORMAT_FLOAT3: return DXGI_FORMAT_R32G32B32_FLOAT;
5625 case SG_VERTEXFORMAT_FLOAT4: return DXGI_FORMAT_R32G32B32A32_FLOAT;
5626 case SG_VERTEXFORMAT_BYTE4: return DXGI_FORMAT_R8G8B8A8_SINT;
5627 case SG_VERTEXFORMAT_BYTE4N: return DXGI_FORMAT_R8G8B8A8_SNORM;
5628 case SG_VERTEXFORMAT_UBYTE4: return DXGI_FORMAT_R8G8B8A8_UINT;
5629 case SG_VERTEXFORMAT_UBYTE4N: return DXGI_FORMAT_R8G8B8A8_UNORM;
5630 case SG_VERTEXFORMAT_SHORT2: return DXGI_FORMAT_R16G16_SINT;
5631 case SG_VERTEXFORMAT_SHORT2N: return DXGI_FORMAT_R16G16_SNORM;
5632 case SG_VERTEXFORMAT_SHORT4: return DXGI_FORMAT_R16G16B16A16_SINT;
5633 case SG_VERTEXFORMAT_SHORT4N: return DXGI_FORMAT_R16G16B16A16_SNORM;
5634 case SG_VERTEXFORMAT_UINT10_N2: return DXGI_FORMAT_R10G10B10A2_UNORM;
5635 default: SOKOL_UNREACHABLE; return (DXGI_FORMAT) 0;
5636 }
5637 }
5638
5639 _SOKOL_PRIVATE D3D11_INPUT_CLASSIFICATION _sg_d3d11_input_classification(sg_vertex_step step) {
5640 switch (step) {
5641 case SG_VERTEXSTEP_PER_VERTEX: return D3D11_INPUT_PER_VERTEX_DATA;
5642 case SG_VERTEXSTEP_PER_INSTANCE: return D3D11_INPUT_PER_INSTANCE_DATA;
5643 default: SOKOL_UNREACHABLE; return (D3D11_INPUT_CLASSIFICATION) 0;
5644 }
5645 }
5646
5647 _SOKOL_PRIVATE D3D11_CULL_MODE _sg_d3d11_cull_mode(sg_cull_mode m) {
5648 switch (m) {
5649 case SG_CULLMODE_NONE: return D3D11_CULL_NONE;
5650 case SG_CULLMODE_FRONT: return D3D11_CULL_FRONT;
5651 case SG_CULLMODE_BACK: return D3D11_CULL_BACK;
5652 default: SOKOL_UNREACHABLE; return (D3D11_CULL_MODE) 0;
5653 }
5654 }
5655
5656 _SOKOL_PRIVATE D3D11_COMPARISON_FUNC _sg_d3d11_compare_func(sg_compare_func f) {
5657 switch (f) {
5658 case SG_COMPAREFUNC_NEVER: return D3D11_COMPARISON_NEVER;
5659 case SG_COMPAREFUNC_LESS: return D3D11_COMPARISON_LESS;
5660 case SG_COMPAREFUNC_EQUAL: return D3D11_COMPARISON_EQUAL;
5661 case SG_COMPAREFUNC_LESS_EQUAL: return D3D11_COMPARISON_LESS_EQUAL;
5662 case SG_COMPAREFUNC_GREATER: return D3D11_COMPARISON_GREATER;
5663 case SG_COMPAREFUNC_NOT_EQUAL: return D3D11_COMPARISON_NOT_EQUAL;
5664 case SG_COMPAREFUNC_GREATER_EQUAL: return D3D11_COMPARISON_GREATER_EQUAL;
5665 case SG_COMPAREFUNC_ALWAYS: return D3D11_COMPARISON_ALWAYS;
5666 default: SOKOL_UNREACHABLE; return (D3D11_COMPARISON_FUNC) 0;
5667 }
5668 }
5669
5670 _SOKOL_PRIVATE D3D11_STENCIL_OP _sg_d3d11_stencil_op(sg_stencil_op op) {
5671 switch (op) {
5672 case SG_STENCILOP_KEEP: return D3D11_STENCIL_OP_KEEP;
5673 case SG_STENCILOP_ZERO: return D3D11_STENCIL_OP_ZERO;
5674 case SG_STENCILOP_REPLACE: return D3D11_STENCIL_OP_REPLACE;
5675 case SG_STENCILOP_INCR_CLAMP: return D3D11_STENCIL_OP_INCR_SAT;
5676 case SG_STENCILOP_DECR_CLAMP: return D3D11_STENCIL_OP_DECR_SAT;
5677 case SG_STENCILOP_INVERT: return D3D11_STENCIL_OP_INVERT;
5678 case SG_STENCILOP_INCR_WRAP: return D3D11_STENCIL_OP_INCR;
5679 case SG_STENCILOP_DECR_WRAP: return D3D11_STENCIL_OP_DECR;
5680 default: SOKOL_UNREACHABLE; return (D3D11_STENCIL_OP) 0;
5681 }
5682 }
5683
5684 _SOKOL_PRIVATE D3D11_BLEND _sg_d3d11_blend_factor(sg_blend_factor f) {
5685 switch (f) {
5686 case SG_BLENDFACTOR_ZERO: return D3D11_BLEND_ZERO;
5687 case SG_BLENDFACTOR_ONE: return D3D11_BLEND_ONE;
5688 case SG_BLENDFACTOR_SRC_COLOR: return D3D11_BLEND_SRC_COLOR;
5689 case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return D3D11_BLEND_INV_SRC_COLOR;
5690 case SG_BLENDFACTOR_SRC_ALPHA: return D3D11_BLEND_SRC_ALPHA;
5691 case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return D3D11_BLEND_INV_SRC_ALPHA;
5692 case SG_BLENDFACTOR_DST_COLOR: return D3D11_BLEND_DEST_COLOR;
5693 case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return D3D11_BLEND_INV_DEST_COLOR;
5694 case SG_BLENDFACTOR_DST_ALPHA: return D3D11_BLEND_DEST_ALPHA;
5695 case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return D3D11_BLEND_INV_DEST_ALPHA;
5696 case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return D3D11_BLEND_SRC_ALPHA_SAT;
5697 case SG_BLENDFACTOR_BLEND_COLOR: return D3D11_BLEND_BLEND_FACTOR;
5698 case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return D3D11_BLEND_INV_BLEND_FACTOR;
5699 case SG_BLENDFACTOR_BLEND_ALPHA: return D3D11_BLEND_BLEND_FACTOR;
5700 case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return D3D11_BLEND_INV_BLEND_FACTOR;
5701 default: SOKOL_UNREACHABLE; return (D3D11_BLEND) 0;
5702 }
5703 }
5704
5705 _SOKOL_PRIVATE D3D11_BLEND_OP _sg_d3d11_blend_op(sg_blend_op op) {
5706 switch (op) {
5707 case SG_BLENDOP_ADD: return D3D11_BLEND_OP_ADD;
5708 case SG_BLENDOP_SUBTRACT: return D3D11_BLEND_OP_SUBTRACT;
5709 case SG_BLENDOP_REVERSE_SUBTRACT: return D3D11_BLEND_OP_REV_SUBTRACT;
5710 default: SOKOL_UNREACHABLE; return (D3D11_BLEND_OP) 0;
5711 }
5712 }
5713
5714 _SOKOL_PRIVATE UINT8 _sg_d3d11_color_write_mask(sg_color_mask m) {
5715 UINT8 res = 0;
5716 if (m & SG_COLORMASK_R) {
5717 res |= D3D11_COLOR_WRITE_ENABLE_RED;
5718 }
5719 if (m & SG_COLORMASK_G) {
5720 res |= D3D11_COLOR_WRITE_ENABLE_GREEN;
5721 }
5722 if (m & SG_COLORMASK_B) {
5723 res |= D3D11_COLOR_WRITE_ENABLE_BLUE;
5724 }
5725 if (m & SG_COLORMASK_A) {
5726 res |= D3D11_COLOR_WRITE_ENABLE_ALPHA;
5727 }
5728 return res;
5729 }
5730
5731 _SOKOL_PRIVATE void _sg_setup_backend(const sg_desc* desc) {
5732 /* assume _sg.d3d11 already is zero-initialized */
5733 SOKOL_ASSERT(desc);
5734 SOKOL_ASSERT(desc->d3d11_device);
5735 SOKOL_ASSERT(desc->d3d11_device_context);
5736 SOKOL_ASSERT(desc->d3d11_render_target_view_cb);
5737 SOKOL_ASSERT(desc->d3d11_depth_stencil_view_cb);
5738 SOKOL_ASSERT(desc->d3d11_render_target_view_cb != desc->d3d11_depth_stencil_view_cb);
5739 _sg.d3d11.valid = true;
5740 _sg.d3d11.dev = (ID3D11Device*) desc->d3d11_device;
5741 _sg.d3d11.ctx = (ID3D11DeviceContext*) desc->d3d11_device_context;
5742 _sg.d3d11.rtv_cb = desc->d3d11_render_target_view_cb;
5743 _sg.d3d11.dsv_cb = desc->d3d11_depth_stencil_view_cb;
5744 }
5745
5746 _SOKOL_PRIVATE void _sg_discard_backend(void) {
5747 SOKOL_ASSERT(_sg.d3d11.valid);
5748 _sg.d3d11.valid = false;
5749 }
5750
5751 _SOKOL_PRIVATE bool _sg_query_feature(sg_feature f) {
5752 switch (f) {
5753 case SG_FEATURE_INSTANCING:
5754 case SG_FEATURE_TEXTURE_COMPRESSION_DXT:
5755 case SG_FEATURE_TEXTURE_FLOAT:
5756 case SG_FEATURE_TEXTURE_HALF_FLOAT:
5757 case SG_FEATURE_ORIGIN_TOP_LEFT:
5758 case SG_FEATURE_MSAA_RENDER_TARGETS:
5759 case SG_FEATURE_MULTIPLE_RENDER_TARGET:
5760 case SG_FEATURE_IMAGETYPE_3D:
5761 case SG_FEATURE_IMAGETYPE_ARRAY:
5762 case SG_FEATURE_PACKED_VERTEX_FORMAT_10_2:
5763 return true;
5764 default:
5765 return false;
5766 }
5767 }
5768
5769 _SOKOL_PRIVATE void _sg_d3d11_clear_state(void) {
5770 /* clear all the device context state, so that resource refs don't keep stuck in the d3d device context */
5771 ID3D11DeviceContext_OMSetRenderTargets(_sg.d3d11.ctx, SG_MAX_COLOR_ATTACHMENTS, _sg.d3d11.zero_rtvs, NULL);
5772 ID3D11DeviceContext_RSSetState(_sg.d3d11.ctx, NULL);
5773 ID3D11DeviceContext_OMSetDepthStencilState(_sg.d3d11.ctx, NULL, 0);
5774 ID3D11DeviceContext_OMSetBlendState(_sg.d3d11.ctx, NULL, NULL, 0xFFFFFFFF);
5775 ID3D11DeviceContext_IASetVertexBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_BUFFERS, _sg.d3d11.zero_vbs, _sg.d3d11.zero_vb_strides, _sg.d3d11.zero_vb_offsets);
5776 ID3D11DeviceContext_IASetIndexBuffer(_sg.d3d11.ctx, NULL, DXGI_FORMAT_UNKNOWN, 0);
5777 ID3D11DeviceContext_IASetInputLayout(_sg.d3d11.ctx, NULL);
5778 ID3D11DeviceContext_VSSetShader(_sg.d3d11.ctx, NULL, NULL, 0);
5779 ID3D11DeviceContext_PSSetShader(_sg.d3d11.ctx, NULL, NULL, 0);
5780 ID3D11DeviceContext_VSSetConstantBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_UBS, _sg.d3d11.zero_cbs);
5781 ID3D11DeviceContext_PSSetConstantBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_UBS, _sg.d3d11.zero_cbs);
5782 ID3D11DeviceContext_VSSetShaderResources(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, _sg.d3d11.zero_srvs);
5783 ID3D11DeviceContext_PSSetShaderResources(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, _sg.d3d11.zero_srvs);
5784 ID3D11DeviceContext_VSSetSamplers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, _sg.d3d11.zero_smps);
5785 ID3D11DeviceContext_PSSetSamplers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, _sg.d3d11.zero_smps);
5786 }
5787
5788 _SOKOL_PRIVATE void _sg_reset_state_cache(void) {
5789 /* just clear the d3d11 device context state */
5790 _sg_d3d11_clear_state();
5791 }
5792
5793 _SOKOL_PRIVATE void _sg_activate_context(_sg_context_t* ctx) {
5794 _SOKOL_UNUSED(ctx);
5795 _sg_reset_state_cache();
5796 }
5797
5798 _SOKOL_PRIVATE sg_resource_state _sg_create_context(_sg_context_t* ctx) {
5799 SOKOL_ASSERT(ctx);
5800 _SOKOL_UNUSED(ctx);
5801 return SG_RESOURCESTATE_VALID;
5802 }
5803
5804 _SOKOL_PRIVATE void _sg_destroy_context(_sg_context_t* ctx) {
5805 SOKOL_ASSERT(ctx);
5806 _SOKOL_UNUSED(ctx);
5807 /* empty */
5808 }
5809
5810 _SOKOL_PRIVATE sg_resource_state _sg_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) {
5811 SOKOL_ASSERT(buf && desc);
5812 SOKOL_ASSERT(!buf->d3d11_buf);
5813 buf->size = desc->size;
5814 buf->append_pos = 0;
5815 buf->append_overflow = false;
5816 buf->type = desc->type;
5817 buf->usage = desc->usage;
5818 buf->update_frame_index = 0;
5819 buf->append_frame_index = 0;
5820 const bool injected = (0 != desc->d3d11_buffer);
5821 if (injected) {
5822 buf->d3d11_buf = (ID3D11Buffer*) desc->d3d11_buffer;
5823 ID3D11Buffer_AddRef(buf->d3d11_buf);
5824 }
5825 else {
5826 D3D11_BUFFER_DESC d3d11_desc;
5827 memset(&d3d11_desc, 0, sizeof(d3d11_desc));
5828 d3d11_desc.ByteWidth = buf->size;
5829 d3d11_desc.Usage = _sg_d3d11_usage(buf->usage);
5830 d3d11_desc.BindFlags = buf->type == SG_BUFFERTYPE_VERTEXBUFFER ? D3D11_BIND_VERTEX_BUFFER : D3D11_BIND_INDEX_BUFFER;
5831 d3d11_desc.CPUAccessFlags = _sg_d3d11_cpu_access_flags(buf->usage);
5832 D3D11_SUBRESOURCE_DATA* init_data_ptr = 0;
5833 D3D11_SUBRESOURCE_DATA init_data;
5834 memset(&init_data, 0, sizeof(init_data));
5835 if (buf->usage == SG_USAGE_IMMUTABLE) {
5836 SOKOL_ASSERT(desc->content);
5837 init_data.pSysMem = desc->content;
5838 init_data_ptr = &init_data;
5839 }
5840 HRESULT hr = ID3D11Device_CreateBuffer(_sg.d3d11.dev, &d3d11_desc, init_data_ptr, &buf->d3d11_buf);
5841 _SOKOL_UNUSED(hr);
5842 SOKOL_ASSERT(SUCCEEDED(hr) && buf->d3d11_buf);
5843 }
5844 return SG_RESOURCESTATE_VALID;
5845 }
5846
5847 _SOKOL_PRIVATE void _sg_destroy_buffer(_sg_buffer_t* buf) {
5848 SOKOL_ASSERT(buf);
5849 if (buf->d3d11_buf) {
5850 ID3D11Buffer_Release(buf->d3d11_buf);
5851 }
5852 }
5853
5854 _SOKOL_PRIVATE void _sg_d3d11_fill_subres_data(const _sg_image_t* img, const sg_image_content* content) {
5855 const int num_faces = (img->type == SG_IMAGETYPE_CUBE) ? 6:1;
5856 const int num_slices = (img->type == SG_IMAGETYPE_ARRAY) ? img->depth:1;
5857 int subres_index = 0;
5858 for (int face_index = 0; face_index < num_faces; face_index++) {
5859 for (int slice_index = 0; slice_index < num_slices; slice_index++) {
5860 for (int mip_index = 0; mip_index < img->num_mipmaps; mip_index++, subres_index++) {
5861 SOKOL_ASSERT(subres_index < (SG_MAX_MIPMAPS * SG_MAX_TEXTUREARRAY_LAYERS));
5862 D3D11_SUBRESOURCE_DATA* subres_data = &_sg.d3d11.subres_data[subres_index];
5863 const int mip_width = ((img->width>>mip_index)>0) ? img->width>>mip_index : 1;
5864 const int mip_height = ((img->height>>mip_index)>0) ? img->height>>mip_index : 1;
5865 const sg_subimage_content* subimg_content = &(content->subimage[face_index][mip_index]);
5866 const int slice_size = subimg_content->size / num_slices;
5867 const int slice_offset = slice_size * slice_index;
5868 const uint8_t* ptr = (const uint8_t*) subimg_content->ptr;
5869 subres_data->pSysMem = ptr + slice_offset;
5870 subres_data->SysMemPitch = _sg_row_pitch(img->pixel_format, mip_width);
5871 if (img->type == SG_IMAGETYPE_3D) {
5872 /* FIXME? const int mip_depth = ((img->depth>>mip_index)>0) ? img->depth>>mip_index : 1; */
5873 subres_data->SysMemSlicePitch = _sg_surface_pitch(img->pixel_format, mip_width, mip_height);
5874 }
5875 else {
5876 subres_data->SysMemSlicePitch = 0;
5877 }
5878 }
5879 }
5880 }
5881 }
5882
5883 _SOKOL_PRIVATE sg_resource_state _sg_create_image(_sg_image_t* img, const sg_image_desc* desc) {
5884 SOKOL_ASSERT(img && desc);
5885 SOKOL_ASSERT(!img->d3d11_tex2d && !img->d3d11_tex3d && !img->d3d11_texds && !img->d3d11_texmsaa);
5886 SOKOL_ASSERT(!img->d3d11_srv && !img->d3d11_smp);
5887 HRESULT hr;
5888
5889 img->type = desc->type;
5890 img->render_target = desc->render_target;
5891 img->width = desc->width;
5892 img->height = desc->height;
5893 img->depth = desc->depth;
5894 img->num_mipmaps = desc->num_mipmaps;
5895 img->usage = desc->usage;
5896 img->pixel_format = desc->pixel_format;
5897 img->sample_count = desc->sample_count;
5898 img->min_filter = desc->min_filter;
5899 img->mag_filter = desc->mag_filter;
5900 img->wrap_u = desc->wrap_u;
5901 img->wrap_v = desc->wrap_v;
5902 img->wrap_w = desc->wrap_w;
5903 img->max_anisotropy = desc->max_anisotropy;
5904 img->upd_frame_index = 0;
5905 const bool injected = (0 != desc->d3d11_texture);
5906 const bool msaa = (img->sample_count > 1);
5907
5908 /* special case depth-stencil buffer? */
5909 if (_sg_is_valid_rendertarget_depth_format(img->pixel_format)) {
5910 /* create only a depth-texture */
5911 SOKOL_ASSERT(!injected);
5912 img->d3d11_format = _sg_d3d11_rendertarget_depth_format(img->pixel_format);
5913 if (img->d3d11_format == DXGI_FORMAT_UNKNOWN) {
5914 /* trying to create a texture format that's not supported by D3D */
5915 SOKOL_LOG("trying to create a D3D11 depth-texture with unsupported pixel format\n");
5916 return SG_RESOURCESTATE_FAILED;
5917 }
5918 D3D11_TEXTURE2D_DESC d3d11_desc;
5919 memset(&d3d11_desc, 0, sizeof(d3d11_desc));
5920 d3d11_desc.Width = img->width;
5921 d3d11_desc.Height = img->height;
5922 d3d11_desc.MipLevels = 1;
5923 d3d11_desc.ArraySize = 1;
5924 d3d11_desc.Format = img->d3d11_format;
5925 d3d11_desc.Usage = D3D11_USAGE_DEFAULT;
5926 d3d11_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
5927 d3d11_desc.SampleDesc.Count = img->sample_count;
5928 d3d11_desc.SampleDesc.Quality = msaa ? D3D11_STANDARD_MULTISAMPLE_PATTERN : 0;
5929 hr = ID3D11Device_CreateTexture2D(_sg.d3d11.dev, &d3d11_desc, NULL, &img->d3d11_texds);
5930 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_texds);
5931 }
5932 else {
5933 /* create (or inject) color texture */
5934
5935 /* prepare initial content pointers */
5936 D3D11_SUBRESOURCE_DATA* init_data = 0;
5937 if (!injected && (img->usage == SG_USAGE_IMMUTABLE) && !img->render_target) {
5938 _sg_d3d11_fill_subres_data(img, &desc->content);
5939 init_data = _sg.d3d11.subres_data;
5940 }
5941 if (img->type != SG_IMAGETYPE_3D) {
5942 /* 2D-, cube- or array-texture */
5943 /* if this is an MSAA render target, the following texture will be the 'resolve-texture' */
5944 D3D11_TEXTURE2D_DESC d3d11_tex_desc;
5945 memset(&d3d11_tex_desc, 0, sizeof(d3d11_tex_desc));
5946 d3d11_tex_desc.Width = img->width;
5947 d3d11_tex_desc.Height = img->height;
5948 d3d11_tex_desc.MipLevels = img->num_mipmaps;
5949 switch (img->type) {
5950 case SG_IMAGETYPE_ARRAY: d3d11_tex_desc.ArraySize = img->depth; break;
5951 case SG_IMAGETYPE_CUBE: d3d11_tex_desc.ArraySize = 6; break;
5952 default: d3d11_tex_desc.ArraySize = 1; break;
5953 }
5954 d3d11_tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
5955 if (img->render_target) {
5956 img->d3d11_format = _sg_d3d11_rendertarget_color_format(img->pixel_format);
5957 d3d11_tex_desc.Format = img->d3d11_format;
5958 d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT;
5959 if (!msaa) {
5960 d3d11_tex_desc.BindFlags |= D3D11_BIND_RENDER_TARGET;
5961 }
5962 d3d11_tex_desc.CPUAccessFlags = 0;
5963 }
5964 else {
5965 img->d3d11_format = _sg_d3d11_texture_format(img->pixel_format);
5966 d3d11_tex_desc.Format = img->d3d11_format;
5967 d3d11_tex_desc.Usage = _sg_d3d11_usage(img->usage);
5968 d3d11_tex_desc.CPUAccessFlags = _sg_d3d11_cpu_access_flags(img->usage);
5969 }
5970 if (img->d3d11_format == DXGI_FORMAT_UNKNOWN) {
5971 /* trying to create a texture format that's not supported by D3D */
5972 SOKOL_LOG("trying to create a D3D11 texture with unsupported pixel format\n");
5973 return SG_RESOURCESTATE_FAILED;
5974 }
5975 d3d11_tex_desc.SampleDesc.Count = 1;
5976 d3d11_tex_desc.SampleDesc.Quality = 0;
5977 d3d11_tex_desc.MiscFlags = (img->type == SG_IMAGETYPE_CUBE) ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0;
5978 if (injected) {
5979 img->d3d11_tex2d = (ID3D11Texture2D*) desc->d3d11_texture;
5980 ID3D11Texture2D_AddRef(img->d3d11_tex2d);
5981 }
5982 else {
5983 hr = ID3D11Device_CreateTexture2D(_sg.d3d11.dev, &d3d11_tex_desc, init_data, &img->d3d11_tex2d);
5984 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_tex2d);
5985 }
5986
5987 /* shader-resource-view */
5988 D3D11_SHADER_RESOURCE_VIEW_DESC d3d11_srv_desc;
5989 memset(&d3d11_srv_desc, 0, sizeof(d3d11_srv_desc));
5990 d3d11_srv_desc.Format = d3d11_tex_desc.Format;
5991 switch (img->type) {
5992 case SG_IMAGETYPE_2D:
5993 d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
5994 d3d11_srv_desc.Texture2D.MipLevels = img->num_mipmaps;
5995 break;
5996 case SG_IMAGETYPE_CUBE:
5997 d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
5998 d3d11_srv_desc.TextureCube.MipLevels = img->num_mipmaps;
5999 break;
6000 case SG_IMAGETYPE_ARRAY:
6001 d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
6002 d3d11_srv_desc.Texture2DArray.MipLevels = img->num_mipmaps;
6003 d3d11_srv_desc.Texture2DArray.ArraySize = img->depth;
6004 break;
6005 default:
6006 SOKOL_UNREACHABLE; break;
6007 }
6008 hr = ID3D11Device_CreateShaderResourceView(_sg.d3d11.dev, (ID3D11Resource*)img->d3d11_tex2d, &d3d11_srv_desc, &img->d3d11_srv);
6009 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_srv);
6010 }
6011 else {
6012 /* 3D texture */
6013 D3D11_TEXTURE3D_DESC d3d11_tex_desc;
6014 memset(&d3d11_tex_desc, 0, sizeof(d3d11_tex_desc));
6015 d3d11_tex_desc.Width = img->width;
6016 d3d11_tex_desc.Height = img->height;
6017 d3d11_tex_desc.Depth = img->depth;
6018 d3d11_tex_desc.MipLevels = img->num_mipmaps;
6019 d3d11_tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
6020 if (img->render_target) {
6021 img->d3d11_format = _sg_d3d11_rendertarget_color_format(img->pixel_format);
6022 d3d11_tex_desc.Format = img->d3d11_format;
6023 d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT;
6024 if (!msaa) {
6025 d3d11_tex_desc.BindFlags |= D3D11_BIND_RENDER_TARGET;
6026 }
6027 d3d11_tex_desc.CPUAccessFlags = 0;
6028 }
6029 else {
6030 img->d3d11_format = _sg_d3d11_texture_format(img->pixel_format);
6031 d3d11_tex_desc.Format = img->d3d11_format;
6032 d3d11_tex_desc.Usage = _sg_d3d11_usage(img->usage);
6033 d3d11_tex_desc.CPUAccessFlags = _sg_d3d11_cpu_access_flags(img->usage);
6034 }
6035 if (img->d3d11_format == DXGI_FORMAT_UNKNOWN) {
6036 /* trying to create a texture format that's not supported by D3D */
6037 SOKOL_LOG("trying to create a D3D11 texture with unsupported pixel format\n");
6038 return SG_RESOURCESTATE_FAILED;
6039 }
6040 if (injected) {
6041 img->d3d11_tex3d = (ID3D11Texture3D*) desc->d3d11_texture;
6042 ID3D11Texture3D_AddRef(img->d3d11_tex3d);
6043 }
6044 else {
6045 hr = ID3D11Device_CreateTexture3D(_sg.d3d11.dev, &d3d11_tex_desc, init_data, &img->d3d11_tex3d);
6046 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_tex3d);
6047 }
6048
6049 /* shader resource view for 3d texture */
6050 D3D11_SHADER_RESOURCE_VIEW_DESC d3d11_srv_desc;
6051 memset(&d3d11_srv_desc, 0, sizeof(d3d11_srv_desc));
6052 d3d11_srv_desc.Format = d3d11_tex_desc.Format;
6053 d3d11_srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
6054 d3d11_srv_desc.Texture3D.MipLevels = img->num_mipmaps;
6055 hr = ID3D11Device_CreateShaderResourceView(_sg.d3d11.dev, (ID3D11Resource*)img->d3d11_tex3d, &d3d11_srv_desc, &img->d3d11_srv);
6056 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_srv);
6057 }
6058
6059 /* also need to create a separate MSAA render target texture? */
6060 if (msaa) {
6061 D3D11_TEXTURE2D_DESC d3d11_tex_desc;
6062 memset(&d3d11_tex_desc, 0, sizeof(d3d11_tex_desc));
6063 d3d11_tex_desc.Width = img->width;
6064 d3d11_tex_desc.Height = img->height;
6065 d3d11_tex_desc.MipLevels = 1;
6066 d3d11_tex_desc.ArraySize = 1;
6067 d3d11_tex_desc.Format = img->d3d11_format;
6068 d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT;
6069 d3d11_tex_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
6070 d3d11_tex_desc.CPUAccessFlags = 0;
6071 d3d11_tex_desc.SampleDesc.Count = img->sample_count;
6072 d3d11_tex_desc.SampleDesc.Quality = (UINT)D3D11_STANDARD_MULTISAMPLE_PATTERN;
6073 hr = ID3D11Device_CreateTexture2D(_sg.d3d11.dev, &d3d11_tex_desc, NULL, &img->d3d11_texmsaa);
6074 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_texmsaa);
6075 }
6076
6077 /* sampler state object, note D3D11 implements an internal shared-pool for sampler objects */
6078 D3D11_SAMPLER_DESC d3d11_smp_desc;
6079 memset(&d3d11_smp_desc, 0, sizeof(d3d11_smp_desc));
6080 d3d11_smp_desc.Filter = _sg_d3d11_filter(img->min_filter, img->mag_filter, img->max_anisotropy);
6081 d3d11_smp_desc.AddressU = _sg_d3d11_address_mode(img->wrap_u);
6082 d3d11_smp_desc.AddressV = _sg_d3d11_address_mode(img->wrap_v);
6083 d3d11_smp_desc.AddressW = _sg_d3d11_address_mode(img->wrap_w);
6084 d3d11_smp_desc.MaxAnisotropy = img->max_anisotropy;
6085 d3d11_smp_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
6086 d3d11_smp_desc.MinLOD = desc->min_lod;
6087 d3d11_smp_desc.MaxLOD = desc->max_lod;
6088 hr = ID3D11Device_CreateSamplerState(_sg.d3d11.dev, &d3d11_smp_desc, &img->d3d11_smp);
6089 SOKOL_ASSERT(SUCCEEDED(hr) && img->d3d11_smp);
6090 }
6091 return SG_RESOURCESTATE_VALID;
6092 }
6093
6094 _SOKOL_PRIVATE void _sg_destroy_image(_sg_image_t* img) {
6095 SOKOL_ASSERT(img);
6096 if (img->d3d11_tex2d) {
6097 ID3D11Texture2D_Release(img->d3d11_tex2d);
6098 }
6099 if (img->d3d11_tex3d) {
6100 ID3D11Texture3D_Release(img->d3d11_tex3d);
6101 }
6102 if (img->d3d11_texds) {
6103 ID3D11Texture2D_Release(img->d3d11_texds);
6104 }
6105 if (img->d3d11_texmsaa) {
6106 ID3D11Texture2D_Release(img->d3d11_texmsaa);
6107 }
6108 if (img->d3d11_srv) {
6109 ID3D11ShaderResourceView_Release(img->d3d11_srv);
6110 }
6111 if (img->d3d11_smp) {
6112 ID3D11SamplerState_Release(img->d3d11_smp);
6113 }
6114 }
6115
6116 _SOKOL_PRIVATE bool _sg_d3d11_load_d3dcompiler_dll(void) {
6117 /* on UWP, don't do anything (not tested) */
6118 #if (defined(WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
6119 return true;
6120 #else
6121 /* load DLL on demand */
6122 if ((0 == _sg.d3d11.d3dcompiler_dll) && !_sg.d3d11.d3dcompiler_dll_load_failed) {
6123 _sg.d3d11.d3dcompiler_dll = LoadLibraryA("d3dcompiler_47.dll");
6124 if (0 == _sg.d3d11.d3dcompiler_dll) {
6125 /* don't attempt to load missing DLL in the future */
6126 SOKOL_LOG("failed to load d3dcompiler_47.dll!\n");
6127 _sg.d3d11.d3dcompiler_dll_load_failed = true;
6128 return false;
6129 }
6130 /* look up function pointers */
6131 _sg.d3d11.D3DCompile_func = (pD3DCompile) GetProcAddress(_sg.d3d11.d3dcompiler_dll, "D3DCompile");
6132 SOKOL_ASSERT(_sg.d3d11.D3DCompile_func);
6133 }
6134 return 0 != _sg.d3d11.d3dcompiler_dll;
6135 #endif
6136 }
6137
6138 #if (defined(WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
6139 #define _sg_d3d11_D3DCompile D3DCompile
6140 #else
6141 #define _sg_d3d11_D3DCompile _sg.d3d11.D3DCompile_func
6142 #endif
6143
6144 _SOKOL_PRIVATE ID3DBlob* _sg_d3d11_compile_shader(const sg_shader_stage_desc* stage_desc, const char* target) {
6145 if (!_sg_d3d11_load_d3dcompiler_dll()) {
6146 return NULL;
6147 }
6148 ID3DBlob* output = NULL;
6149 ID3DBlob* errors = NULL;
6150 _sg_d3d11_D3DCompile(
6151 stage_desc->source, /* pSrcData */
6152 strlen(stage_desc->source), /* SrcDataSize */
6153 NULL, /* pSourceName */
6154 NULL, /* pDefines */
6155 NULL, /* pInclude */
6156 stage_desc->entry ? stage_desc->entry : "main", /* pEntryPoint */
6157 target, /* pTarget (vs_5_0 or ps_5_0) */
6158 D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR | D3DCOMPILE_OPTIMIZATION_LEVEL3, /* Flags1 */
6159 0, /* Flags2 */
6160 &output, /* ppCode */
6161 &errors); /* ppErrorMsgs */
6162 if (errors) {
6163 SOKOL_LOG((LPCSTR)ID3D10Blob_GetBufferPointer(errors));
6164 ID3D10Blob_Release(errors); errors = NULL;
6165 return NULL;
6166 }
6167 return output;
6168 }
6169
6170 #define _sg_d3d11_roundup(val, round_to) (((val)+((round_to)-1))&~((round_to)-1))
6171
6172 _SOKOL_PRIVATE sg_resource_state _sg_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) {
6173 SOKOL_ASSERT(shd && desc);
6174 SOKOL_ASSERT(!shd->d3d11_vs && !shd->d3d11_fs && !shd->d3d11_vs_blob);
6175 HRESULT hr;
6176 sg_resource_state result = SG_RESOURCESTATE_FAILED;
6177
6178 /* copy vertex attribute semantic names and indices */
6179 for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) {
6180 _sg_strcpy(&shd->attrs[i].sem_name, desc->attrs[i].sem_name);
6181 shd->attrs[i].sem_index = desc->attrs[i].sem_index;
6182 }
6183
6184 /* shader stage uniform blocks and image slots */
6185 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) {
6186 const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS) ? &desc->vs : &desc->fs;
6187 _sg_shader_stage_t* stage = &shd->stage[stage_index];
6188 SOKOL_ASSERT(stage->num_uniform_blocks == 0);
6189 for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) {
6190 const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index];
6191 if (0 == ub_desc->size) {
6192 break;
6193 }
6194 _sg_uniform_block_t* ub = &stage->uniform_blocks[ub_index];
6195 ub->size = ub_desc->size;
6196
6197 /* create a D3D constant buffer */
6198 SOKOL_ASSERT(!stage->d3d11_cbs[ub_index]);
6199 D3D11_BUFFER_DESC cb_desc;
6200 memset(&cb_desc, 0, sizeof(cb_desc));
6201 cb_desc.ByteWidth = _sg_d3d11_roundup(ub->size, 16);
6202 cb_desc.Usage = D3D11_USAGE_DEFAULT;
6203 cb_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
6204 hr = ID3D11Device_CreateBuffer(_sg.d3d11.dev, &cb_desc, NULL, &stage->d3d11_cbs[ub_index]);
6205 SOKOL_ASSERT(SUCCEEDED(hr) && stage->d3d11_cbs[ub_index]);
6206
6207 stage->num_uniform_blocks++;
6208 }
6209 SOKOL_ASSERT(stage->num_images == 0);
6210 for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) {
6211 const sg_shader_image_desc* img_desc = &stage_desc->images[img_index];
6212 if (img_desc->type == _SG_IMAGETYPE_DEFAULT) {
6213 break;
6214 }
6215 stage->images[img_index].type = img_desc->type;
6216 stage->num_images++;
6217 }
6218 }
6219
6220 const void* vs_ptr = 0, *fs_ptr = 0;
6221 SIZE_T vs_length = 0, fs_length = 0;
6222 ID3DBlob* vs_blob = 0, *fs_blob = 0;
6223 if (desc->vs.byte_code && desc->fs.byte_code) {
6224 /* create from byte code */
6225 vs_ptr = desc->vs.byte_code;
6226 fs_ptr = desc->fs.byte_code;
6227 vs_length = desc->vs.byte_code_size;
6228 fs_length = desc->fs.byte_code_size;
6229 }
6230 else {
6231 /* compile shader code */
6232 vs_blob = _sg_d3d11_compile_shader(&desc->vs, "vs_5_0");
6233 fs_blob = _sg_d3d11_compile_shader(&desc->fs, "ps_5_0");
6234 if (vs_blob && fs_blob) {
6235 vs_ptr = ID3D10Blob_GetBufferPointer(vs_blob);
6236 vs_length = ID3D10Blob_GetBufferSize(vs_blob);
6237 fs_ptr = ID3D10Blob_GetBufferPointer(fs_blob);
6238 fs_length = ID3D10Blob_GetBufferSize(fs_blob);
6239 }
6240 }
6241 if (vs_ptr && fs_ptr && (vs_length > 0) && (fs_length > 0)) {
6242 /* create the D3D vertex- and pixel-shader objects */
6243 hr = ID3D11Device_CreateVertexShader(_sg.d3d11.dev, vs_ptr, vs_length, NULL, &shd->d3d11_vs);
6244 SOKOL_ASSERT(SUCCEEDED(hr) && shd->d3d11_vs);
6245 hr = ID3D11Device_CreatePixelShader(_sg.d3d11.dev, fs_ptr, fs_length, NULL, &shd->d3d11_fs);
6246 SOKOL_ASSERT(SUCCEEDED(hr) && shd->d3d11_fs);
6247
6248 /* need to store the vertex shader byte code, this is needed later in sg_create_pipeline */
6249 shd->d3d11_vs_blob_length = (int)vs_length;
6250 shd->d3d11_vs_blob = SOKOL_MALLOC((int)vs_length);
6251 SOKOL_ASSERT(shd->d3d11_vs_blob);
6252 memcpy(shd->d3d11_vs_blob, vs_ptr, vs_length);
6253
6254 result = SG_RESOURCESTATE_VALID;
6255 }
6256 if (vs_blob) {
6257 ID3D10Blob_Release(vs_blob); vs_blob = 0;
6258 }
6259 if (fs_blob) {
6260 ID3D10Blob_Release(fs_blob); fs_blob = 0;
6261 }
6262 return result;
6263 }
6264
6265 _SOKOL_PRIVATE void _sg_destroy_shader(_sg_shader_t* shd) {
6266 SOKOL_ASSERT(shd);
6267 if (shd->d3d11_vs) {
6268 ID3D11VertexShader_Release(shd->d3d11_vs);
6269 }
6270 if (shd->d3d11_fs) {
6271 ID3D11PixelShader_Release(shd->d3d11_fs);
6272 }
6273 if (shd->d3d11_vs_blob) {
6274 SOKOL_FREE(shd->d3d11_vs_blob);
6275 }
6276 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) {
6277 _sg_shader_stage_t* stage = &shd->stage[stage_index];
6278 for (int ub_index = 0; ub_index < stage->num_uniform_blocks; ub_index++) {
6279 if (stage->d3d11_cbs[ub_index]) {
6280 ID3D11Buffer_Release(stage->d3d11_cbs[ub_index]);
6281 }
6282 }
6283 }
6284 }
6285
6286 _SOKOL_PRIVATE sg_resource_state _sg_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) {
6287 SOKOL_ASSERT(pip && shd && desc);
6288 SOKOL_ASSERT(desc->shader.id == shd->slot.id);
6289 SOKOL_ASSERT(shd->slot.state == SG_RESOURCESTATE_VALID);
6290 SOKOL_ASSERT(shd->d3d11_vs_blob && shd->d3d11_vs_blob_length > 0);
6291 SOKOL_ASSERT(!pip->d3d11_il && !pip->d3d11_rs && !pip->d3d11_dss && !pip->d3d11_bs);
6292 HRESULT hr;
6293
6294 pip->shader = shd;
6295 pip->shader_id = desc->shader;
6296 pip->index_type = desc->index_type;
6297 pip->color_attachment_count = desc->blend.color_attachment_count;
6298 pip->color_format = desc->blend.color_format;
6299 pip->depth_format = desc->blend.depth_format;
6300 pip->sample_count = desc->rasterizer.sample_count;
6301 pip->d3d11_index_format = _sg_d3d11_index_format(pip->index_type);
6302 pip->d3d11_topology = _sg_d3d11_primitive_topology(desc->primitive_type);
6303 for (int i = 0; i < 4; i++) {
6304 pip->blend_color[i] = desc->blend.blend_color[i];
6305 }
6306 pip->d3d11_stencil_ref = desc->depth_stencil.stencil_ref;
6307
6308 /* create input layout object */
6309 D3D11_INPUT_ELEMENT_DESC d3d11_comps[SG_MAX_VERTEX_ATTRIBUTES];
6310 memset(d3d11_comps, 0, sizeof(d3d11_comps));
6311 int attr_index = 0;
6312 for (; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) {
6313 const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index];
6314 if (a_desc->format == SG_VERTEXFORMAT_INVALID) {
6315 break;
6316 }
6317 SOKOL_ASSERT((a_desc->buffer_index >= 0) && (a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS));
6318 const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[a_desc->buffer_index];
6319 const sg_vertex_step step_func = l_desc->step_func;
6320 const int step_rate = l_desc->step_rate;
6321 D3D11_INPUT_ELEMENT_DESC* d3d11_comp = &d3d11_comps[attr_index];
6322 d3d11_comp->SemanticName = _sg_strptr(&shd->attrs[attr_index].sem_name);
6323 d3d11_comp->SemanticIndex = shd->attrs[attr_index].sem_index;
6324 d3d11_comp->Format = _sg_d3d11_vertex_format(a_desc->format);
6325 d3d11_comp->InputSlot = a_desc->buffer_index;
6326 d3d11_comp->AlignedByteOffset = a_desc->offset;
6327 d3d11_comp->InputSlotClass = _sg_d3d11_input_classification(step_func);
6328 if (SG_VERTEXSTEP_PER_INSTANCE == step_func) {
6329 d3d11_comp->InstanceDataStepRate = step_rate;
6330 }
6331 pip->vertex_layout_valid[a_desc->buffer_index] = true;
6332 }
6333 for (int layout_index = 0; layout_index < SG_MAX_SHADERSTAGE_BUFFERS; layout_index++) {
6334 if (pip->vertex_layout_valid[layout_index]) {
6335 const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[layout_index];
6336 SOKOL_ASSERT(l_desc->stride > 0);
6337 pip->d3d11_vb_strides[layout_index] = l_desc->stride;
6338 }
6339 else {
6340 pip->d3d11_vb_strides[layout_index] = 0;
6341 }
6342 }
6343 hr = ID3D11Device_CreateInputLayout(_sg.d3d11.dev,
6344 d3d11_comps, /* pInputElementDesc */
6345 attr_index, /* NumElements */
6346 shd->d3d11_vs_blob, /* pShaderByteCodeWithInputSignature */
6347 shd->d3d11_vs_blob_length, /* BytecodeLength */
6348 &pip->d3d11_il);
6349 SOKOL_ASSERT(SUCCEEDED(hr) && pip->d3d11_il);
6350
6351 /* create rasterizer state */
6352 D3D11_RASTERIZER_DESC rs_desc;
6353 memset(&rs_desc, 0, sizeof(rs_desc));
6354 rs_desc.FillMode = D3D11_FILL_SOLID;
6355 rs_desc.CullMode = _sg_d3d11_cull_mode(desc->rasterizer.cull_mode);
6356 rs_desc.FrontCounterClockwise = desc->rasterizer.face_winding == SG_FACEWINDING_CCW;
6357 rs_desc.DepthBias = (INT) desc->rasterizer.depth_bias;
6358 rs_desc.DepthBiasClamp = desc->rasterizer.depth_bias_clamp;
6359 rs_desc.SlopeScaledDepthBias = desc->rasterizer.depth_bias_slope_scale;
6360 rs_desc.DepthClipEnable = TRUE;
6361 rs_desc.ScissorEnable = TRUE;
6362 rs_desc.MultisampleEnable = desc->rasterizer.sample_count > 1;
6363 rs_desc.AntialiasedLineEnable = FALSE;
6364 hr = ID3D11Device_CreateRasterizerState(_sg.d3d11.dev, &rs_desc, &pip->d3d11_rs);
6365 SOKOL_ASSERT(SUCCEEDED(hr) && pip->d3d11_rs);
6366
6367 /* create depth-stencil state */
6368 D3D11_DEPTH_STENCIL_DESC dss_desc;
6369 memset(&dss_desc, 0, sizeof(dss_desc));
6370 dss_desc.DepthEnable = TRUE;
6371 dss_desc.DepthWriteMask = desc->depth_stencil.depth_write_enabled ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
6372 dss_desc.DepthFunc = _sg_d3d11_compare_func(desc->depth_stencil.depth_compare_func);
6373 dss_desc.StencilEnable = desc->depth_stencil.stencil_enabled;
6374 dss_desc.StencilReadMask = desc->depth_stencil.stencil_read_mask;
6375 dss_desc.StencilWriteMask = desc->depth_stencil.stencil_write_mask;
6376 const sg_stencil_state* sf = &desc->depth_stencil.stencil_front;
6377 dss_desc.FrontFace.StencilFailOp = _sg_d3d11_stencil_op(sf->fail_op);
6378 dss_desc.FrontFace.StencilDepthFailOp = _sg_d3d11_stencil_op(sf->depth_fail_op);
6379 dss_desc.FrontFace.StencilPassOp = _sg_d3d11_stencil_op(sf->pass_op);
6380 dss_desc.FrontFace.StencilFunc = _sg_d3d11_compare_func(sf->compare_func);
6381 const sg_stencil_state* sb = &desc->depth_stencil.stencil_back;
6382 dss_desc.BackFace.StencilFailOp = _sg_d3d11_stencil_op(sb->fail_op);
6383 dss_desc.BackFace.StencilDepthFailOp = _sg_d3d11_stencil_op(sb->depth_fail_op);
6384 dss_desc.BackFace.StencilPassOp = _sg_d3d11_stencil_op(sb->pass_op);
6385 dss_desc.BackFace.StencilFunc = _sg_d3d11_compare_func(sb->compare_func);
6386 hr = ID3D11Device_CreateDepthStencilState(_sg.d3d11.dev, &dss_desc, &pip->d3d11_dss);
6387 SOKOL_ASSERT(SUCCEEDED(hr) && pip->d3d11_dss);
6388
6389 /* create blend state */
6390 D3D11_BLEND_DESC bs_desc;
6391 memset(&bs_desc, 0, sizeof(bs_desc));
6392 bs_desc.AlphaToCoverageEnable = desc->rasterizer.alpha_to_coverage_enabled;
6393 bs_desc.IndependentBlendEnable = FALSE;
6394 bs_desc.RenderTarget[0].BlendEnable = desc->blend.enabled;
6395 bs_desc.RenderTarget[0].SrcBlend = _sg_d3d11_blend_factor(desc->blend.src_factor_rgb);
6396 bs_desc.RenderTarget[0].DestBlend = _sg_d3d11_blend_factor(desc->blend.dst_factor_rgb);
6397 bs_desc.RenderTarget[0].BlendOp = _sg_d3d11_blend_op(desc->blend.op_rgb);
6398 bs_desc.RenderTarget[0].SrcBlendAlpha = _sg_d3d11_blend_factor(desc->blend.src_factor_alpha);
6399 bs_desc.RenderTarget[0].DestBlendAlpha = _sg_d3d11_blend_factor(desc->blend.dst_factor_alpha);
6400 bs_desc.RenderTarget[0].BlendOpAlpha = _sg_d3d11_blend_op(desc->blend.op_alpha);
6401 bs_desc.RenderTarget[0].RenderTargetWriteMask = _sg_d3d11_color_write_mask((sg_color_mask)desc->blend.color_write_mask);
6402 hr = ID3D11Device_CreateBlendState(_sg.d3d11.dev, &bs_desc, &pip->d3d11_bs);
6403 SOKOL_ASSERT(SUCCEEDED(hr) && pip->d3d11_bs);
6404
6405 return SG_RESOURCESTATE_VALID;
6406 }
6407
6408 _SOKOL_PRIVATE void _sg_destroy_pipeline(_sg_pipeline_t* pip) {
6409 SOKOL_ASSERT(pip);
6410 if (pip->d3d11_il) {
6411 ID3D11InputLayout_Release(pip->d3d11_il);
6412 }
6413 if (pip->d3d11_rs) {
6414 ID3D11RasterizerState_Release(pip->d3d11_rs);
6415 }
6416 if (pip->d3d11_dss) {
6417 ID3D11DepthStencilState_Release(pip->d3d11_dss);
6418 }
6419 if (pip->d3d11_bs) {
6420 ID3D11BlendState_Release(pip->d3d11_bs);
6421 }
6422 }
6423
6424 _SOKOL_PRIVATE sg_resource_state _sg_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) {
6425 SOKOL_ASSERT(pass && desc);
6426 SOKOL_ASSERT(att_images && att_images[0]);
6427 SOKOL_ASSERT(_sg.d3d11.dev);
6428
6429 const sg_attachment_desc* att_desc;
6430 _sg_attachment_t* att;
6431 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
6432 SOKOL_ASSERT(0 == pass->color_atts[i].image);
6433 SOKOL_ASSERT(pass->d3d11_rtvs[i] == 0);
6434 att_desc = &desc->color_attachments[i];
6435 if (att_desc->image.id != SG_INVALID_ID) {
6436 pass->num_color_atts++;
6437 SOKOL_ASSERT(att_images[i] && (att_images[i]->slot.id == att_desc->image.id));
6438 SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_images[i]->pixel_format));
6439 att = &pass->color_atts[i];
6440 SOKOL_ASSERT((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
6441 att->image = att_images[i];
6442 att->image_id = att_desc->image;
6443 att->mip_level = att_desc->mip_level;
6444 att->slice = att_desc->slice;
6445
6446 /* create D3D11 render-target-view */
6447 ID3D11Resource* d3d11_res = 0;
6448 const bool is_msaa = att->image->sample_count > 1;
6449 D3D11_RENDER_TARGET_VIEW_DESC d3d11_rtv_desc;
6450 memset(&d3d11_rtv_desc, 0, sizeof(d3d11_rtv_desc));
6451 d3d11_rtv_desc.Format = att->image->d3d11_format;
6452 if ((att->image->type == SG_IMAGETYPE_2D) || is_msaa) {
6453 if (is_msaa) {
6454 d3d11_res = (ID3D11Resource*) att->image->d3d11_texmsaa;
6455 d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
6456 }
6457 else {
6458 d3d11_res = (ID3D11Resource*) att->image->d3d11_tex2d;
6459 d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
6460 d3d11_rtv_desc.Texture2D.MipSlice = att->mip_level;
6461 }
6462 }
6463 else if ((att->image->type == SG_IMAGETYPE_CUBE) || (att->image->type == SG_IMAGETYPE_ARRAY)) {
6464 d3d11_res = (ID3D11Resource*) att->image->d3d11_tex2d;
6465 d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
6466 d3d11_rtv_desc.Texture2DArray.MipSlice = att->mip_level;
6467 d3d11_rtv_desc.Texture2DArray.FirstArraySlice = att->slice;
6468 d3d11_rtv_desc.Texture2DArray.ArraySize = 1;
6469 }
6470 else {
6471 SOKOL_ASSERT(att->image->type == SG_IMAGETYPE_3D);
6472 d3d11_res = (ID3D11Resource*) att->image->d3d11_tex3d;
6473 d3d11_rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
6474 d3d11_rtv_desc.Texture3D.MipSlice = att->mip_level;
6475 d3d11_rtv_desc.Texture3D.FirstWSlice = att->slice;
6476 d3d11_rtv_desc.Texture3D.WSize = 1;
6477 }
6478 SOKOL_ASSERT(d3d11_res);
6479 HRESULT hr = ID3D11Device_CreateRenderTargetView(_sg.d3d11.dev, d3d11_res, &d3d11_rtv_desc, &pass->d3d11_rtvs[i]);
6480 _SOKOL_UNUSED(hr);
6481 SOKOL_ASSERT(SUCCEEDED(hr) && pass->d3d11_rtvs[i]);
6482 }
6483 }
6484
6485 /* optional depth-stencil image */
6486 SOKOL_ASSERT(0 == pass->ds_att.image);
6487 SOKOL_ASSERT(pass->d3d11_dsv == 0);
6488 att_desc = &desc->depth_stencil_attachment;
6489 const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS;
6490 if (att_desc->image.id != SG_INVALID_ID) {
6491 SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id));
6492 SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->pixel_format));
6493 att = &pass->ds_att;
6494 SOKOL_ASSERT((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
6495 att->image = att_images[ds_img_index];
6496 att->image_id = att_desc->image;
6497 att->mip_level = att_desc->mip_level;
6498 att->slice = att_desc->slice;
6499
6500 /* create D3D11 depth-stencil-view */
6501 D3D11_DEPTH_STENCIL_VIEW_DESC d3d11_dsv_desc;
6502 memset(&d3d11_dsv_desc, 0, sizeof(d3d11_dsv_desc));
6503 d3d11_dsv_desc.Format = att->image->d3d11_format;
6504 const bool is_msaa = att->image->sample_count > 1;
6505 if (is_msaa) {
6506 d3d11_dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
6507 }
6508 else {
6509 d3d11_dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
6510 }
6511 ID3D11Resource* d3d11_res = (ID3D11Resource*) att->image->d3d11_texds;
6512 SOKOL_ASSERT(d3d11_res);
6513 HRESULT hr = ID3D11Device_CreateDepthStencilView(_sg.d3d11.dev, d3d11_res, &d3d11_dsv_desc, &pass->d3d11_dsv);
6514 _SOKOL_UNUSED(hr);
6515 SOKOL_ASSERT(SUCCEEDED(hr) && pass->d3d11_dsv);
6516 }
6517 return SG_RESOURCESTATE_VALID;
6518 }
6519
6520 _SOKOL_PRIVATE void _sg_destroy_pass(_sg_pass_t* pass) {
6521 SOKOL_ASSERT(pass);
6522 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
6523 if (pass->d3d11_rtvs[i]) {
6524 ID3D11RenderTargetView_Release(pass->d3d11_rtvs[i]);
6525 }
6526 }
6527 if (pass->d3d11_dsv) {
6528 ID3D11DepthStencilView_Release(pass->d3d11_dsv);
6529 }
6530 }
6531
6532 _SOKOL_PRIVATE void _sg_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) {
6533 SOKOL_ASSERT(action);
6534 SOKOL_ASSERT(!_sg.d3d11.in_pass);
6535 _sg.d3d11.in_pass = true;
6536 _sg.d3d11.cur_width = w;
6537 _sg.d3d11.cur_height = h;
6538 if (pass) {
6539 _sg.d3d11.cur_pass = pass;
6540 _sg.d3d11.cur_pass_id.id = pass->slot.id;
6541 _sg.d3d11.num_rtvs = 0;
6542 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
6543 _sg.d3d11.cur_rtvs[i] = pass->d3d11_rtvs[i];
6544 if (_sg.d3d11.cur_rtvs[i]) {
6545 _sg.d3d11.num_rtvs++;
6546 }
6547 }
6548 _sg.d3d11.cur_dsv = pass->d3d11_dsv;
6549 }
6550 else {
6551 /* render to default frame buffer */
6552 _sg.d3d11.cur_pass = 0;
6553 _sg.d3d11.cur_pass_id.id = SG_INVALID_ID;
6554 _sg.d3d11.num_rtvs = 1;
6555 _sg.d3d11.cur_rtvs[0] = (ID3D11RenderTargetView*) _sg.d3d11.rtv_cb();
6556 for (int i = 1; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
6557 _sg.d3d11.cur_rtvs[i] = 0;
6558 }
6559 _sg.d3d11.cur_dsv = (ID3D11DepthStencilView*) _sg.d3d11.dsv_cb();
6560 SOKOL_ASSERT(_sg.d3d11.cur_rtvs[0] && _sg.d3d11.cur_dsv);
6561 }
6562 /* apply the render-target- and depth-stencil-views */
6563 ID3D11DeviceContext_OMSetRenderTargets(_sg.d3d11.ctx, SG_MAX_COLOR_ATTACHMENTS, _sg.d3d11.cur_rtvs, _sg.d3d11.cur_dsv);
6564
6565 /* set viewport and scissor rect to cover whole screen */
6566 D3D11_VIEWPORT vp;
6567 memset(&vp, 0, sizeof(vp));
6568 vp.Width = (FLOAT) w;
6569 vp.Height = (FLOAT) h;
6570 vp.MaxDepth = 1.0f;
6571 ID3D11DeviceContext_RSSetViewports(_sg.d3d11.ctx, 1, &vp);
6572 D3D11_RECT rect;
6573 rect.left = 0;
6574 rect.top = 0;
6575 rect.right = w;
6576 rect.bottom = h;
6577 ID3D11DeviceContext_RSSetScissorRects(_sg.d3d11.ctx, 1, &rect);
6578
6579 /* perform clear action */
6580 for (int i = 0; i < _sg.d3d11.num_rtvs; i++) {
6581 if (action->colors[i].action == SG_ACTION_CLEAR) {
6582 ID3D11DeviceContext_ClearRenderTargetView(_sg.d3d11.ctx, _sg.d3d11.cur_rtvs[i], action->colors[i].val);
6583 }
6584 }
6585 UINT ds_flags = 0;
6586 if (action->depth.action == SG_ACTION_CLEAR) {
6587 ds_flags |= D3D11_CLEAR_DEPTH;
6588 }
6589 if (action->stencil.action == SG_ACTION_CLEAR) {
6590 ds_flags |= D3D11_CLEAR_STENCIL;
6591 }
6592 if ((0 != ds_flags) && _sg.d3d11.cur_dsv) {
6593 ID3D11DeviceContext_ClearDepthStencilView(_sg.d3d11.ctx, _sg.d3d11.cur_dsv, ds_flags, action->depth.val, action->stencil.val);
6594 }
6595 }
6596
6597 /* D3D11CalcSubresource only exists for C++ */
6598 _SOKOL_PRIVATE UINT _sg_d3d11_calcsubresource(UINT mip_slice, UINT array_slice, UINT mip_levels) {
6599 return mip_slice + array_slice * mip_levels;
6600 }
6601
6602 _SOKOL_PRIVATE void _sg_end_pass(void) {
6603 SOKOL_ASSERT(_sg.d3d11.in_pass && _sg.d3d11.ctx);
6604 _sg.d3d11.in_pass = false;
6605
6606 /* need to resolve MSAA render target into texture? */
6607 if (_sg.d3d11.cur_pass) {
6608 SOKOL_ASSERT(_sg.d3d11.cur_pass->slot.id == _sg.d3d11.cur_pass_id.id);
6609 for (int i = 0; i < _sg.d3d11.num_rtvs; i++) {
6610 _sg_attachment_t* att = &_sg.d3d11.cur_pass->color_atts[i];
6611 SOKOL_ASSERT(att->image && (att->image->slot.id == att->image_id.id));
6612 if (att->image->sample_count > 1) {
6613 /* FIXME: support MSAA resolve into 3D texture */
6614 SOKOL_ASSERT(att->image->d3d11_tex2d && att->image->d3d11_texmsaa && !att->image->d3d11_tex3d);
6615 SOKOL_ASSERT(DXGI_FORMAT_UNKNOWN != att->image->d3d11_format);
6616 const _sg_image_t* img = att->image;
6617 UINT dst_subres = _sg_d3d11_calcsubresource(att->mip_level, att->slice, img->num_mipmaps);
6618 ID3D11DeviceContext_ResolveSubresource(_sg.d3d11.ctx,
6619 (ID3D11Resource*) img->d3d11_tex2d, /* pDstResource */
6620 dst_subres, /* DstSubresource */
6621 (ID3D11Resource*) img->d3d11_texmsaa, /* pSrcResource */
6622 0, /* SrcSubresource */
6623 img->d3d11_format);
6624 }
6625 }
6626 }
6627 _sg.d3d11.cur_pass = 0;
6628 _sg.d3d11.cur_pass_id.id = SG_INVALID_ID;
6629 _sg.d3d11.cur_pipeline = 0;
6630 _sg.d3d11.cur_pipeline_id.id = SG_INVALID_ID;
6631 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
6632 _sg.d3d11.cur_rtvs[i] = 0;
6633 }
6634 _sg.d3d11.cur_dsv = 0;
6635 _sg_d3d11_clear_state();
6636 }
6637
6638 _SOKOL_PRIVATE void _sg_apply_viewport(int x, int y, int w, int h, bool origin_top_left) {
6639 SOKOL_ASSERT(_sg.d3d11.ctx);
6640 SOKOL_ASSERT(_sg.d3d11.in_pass);
6641 D3D11_VIEWPORT vp;
6642 vp.TopLeftX = (FLOAT) x;
6643 vp.TopLeftY = (FLOAT) (origin_top_left ? y : (_sg.d3d11.cur_height - (y + h)));
6644 vp.Width = (FLOAT) w;
6645 vp.Height = (FLOAT) h;
6646 vp.MinDepth = 0.0f;
6647 vp.MaxDepth = 1.0f;
6648 ID3D11DeviceContext_RSSetViewports(_sg.d3d11.ctx, 1, &vp);
6649 }
6650
6651 _SOKOL_PRIVATE void _sg_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) {
6652 SOKOL_ASSERT(_sg.d3d11.ctx);
6653 SOKOL_ASSERT(_sg.d3d11.in_pass);
6654 D3D11_RECT rect;
6655 rect.left = x;
6656 rect.top = (origin_top_left ? y : (_sg.d3d11.cur_height - (y + h)));
6657 rect.right = x + w;
6658 rect.bottom = origin_top_left ? (y + h) : (_sg.d3d11.cur_height - y);
6659 ID3D11DeviceContext_RSSetScissorRects(_sg.d3d11.ctx, 1, &rect);
6660 }
6661
6662 _SOKOL_PRIVATE void _sg_apply_pipeline(_sg_pipeline_t* pip) {
6663 SOKOL_ASSERT(pip);
6664 SOKOL_ASSERT(pip->shader);
6665 SOKOL_ASSERT(_sg.d3d11.ctx);
6666 SOKOL_ASSERT(_sg.d3d11.in_pass);
6667 SOKOL_ASSERT(pip->d3d11_rs && pip->d3d11_bs && pip->d3d11_dss && pip->d3d11_il);
6668
6669 _sg.d3d11.cur_pipeline = pip;
6670 _sg.d3d11.cur_pipeline_id.id = pip->slot.id;
6671 _sg.d3d11.use_indexed_draw = (pip->d3d11_index_format != DXGI_FORMAT_UNKNOWN);
6672
6673 ID3D11DeviceContext_RSSetState(_sg.d3d11.ctx, pip->d3d11_rs);
6674 ID3D11DeviceContext_OMSetDepthStencilState(_sg.d3d11.ctx, pip->d3d11_dss, pip->d3d11_stencil_ref);
6675 ID3D11DeviceContext_OMSetBlendState(_sg.d3d11.ctx, pip->d3d11_bs, pip->blend_color, 0xFFFFFFFF);
6676 ID3D11DeviceContext_IASetPrimitiveTopology(_sg.d3d11.ctx, pip->d3d11_topology);
6677 ID3D11DeviceContext_IASetInputLayout(_sg.d3d11.ctx, pip->d3d11_il);
6678 ID3D11DeviceContext_VSSetShader(_sg.d3d11.ctx, pip->shader->d3d11_vs, NULL, 0);
6679 ID3D11DeviceContext_VSSetConstantBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_UBS, pip->shader->stage[SG_SHADERSTAGE_VS].d3d11_cbs);
6680 ID3D11DeviceContext_PSSetShader(_sg.d3d11.ctx, pip->shader->d3d11_fs, NULL, 0);
6681 ID3D11DeviceContext_PSSetConstantBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_UBS, pip->shader->stage[SG_SHADERSTAGE_FS].d3d11_cbs);
6682 }
6683
6684 _SOKOL_PRIVATE void _sg_apply_bindings(
6685 _sg_pipeline_t* pip,
6686 _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs,
6687 _sg_buffer_t* ib, int ib_offset,
6688 _sg_image_t** vs_imgs, int num_vs_imgs,
6689 _sg_image_t** fs_imgs, int num_fs_imgs)
6690 {
6691 SOKOL_ASSERT(pip);
6692 SOKOL_ASSERT(_sg.d3d11.ctx);
6693 SOKOL_ASSERT(_sg.d3d11.in_pass);
6694
6695 /* gather all the D3D11 resources into arrays */
6696 ID3D11Buffer* d3d11_ib = ib ? ib->d3d11_buf : 0;
6697 ID3D11Buffer* d3d11_vbs[SG_MAX_SHADERSTAGE_BUFFERS];
6698 UINT d3d11_vb_offsets[SG_MAX_SHADERSTAGE_BUFFERS];
6699 ID3D11ShaderResourceView* d3d11_vs_srvs[SG_MAX_SHADERSTAGE_IMAGES];
6700 ID3D11SamplerState* d3d11_vs_smps[SG_MAX_SHADERSTAGE_IMAGES];
6701 ID3D11ShaderResourceView* d3d11_fs_srvs[SG_MAX_SHADERSTAGE_IMAGES];
6702 ID3D11SamplerState* d3d11_fs_smps[SG_MAX_SHADERSTAGE_IMAGES];
6703 int i;
6704 for (i = 0; i < num_vbs; i++) {
6705 SOKOL_ASSERT(vbs[i]->d3d11_buf);
6706 d3d11_vbs[i] = vbs[i]->d3d11_buf;
6707 d3d11_vb_offsets[i] = vb_offsets[i];
6708 }
6709 for (; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) {
6710 d3d11_vbs[i] = 0;
6711 d3d11_vb_offsets[i] = 0;
6712 }
6713 for (i = 0; i < num_vs_imgs; i++) {
6714 SOKOL_ASSERT(vs_imgs[i]->d3d11_srv);
6715 SOKOL_ASSERT(vs_imgs[i]->d3d11_smp);
6716 d3d11_vs_srvs[i] = vs_imgs[i]->d3d11_srv;
6717 d3d11_vs_smps[i] = vs_imgs[i]->d3d11_smp;
6718 }
6719 for (; i < SG_MAX_SHADERSTAGE_IMAGES; i++) {
6720 d3d11_vs_srvs[i] = 0;
6721 d3d11_vs_smps[i] = 0;
6722 }
6723 for (i = 0; i < num_fs_imgs; i++) {
6724 SOKOL_ASSERT(fs_imgs[i]->d3d11_srv);
6725 SOKOL_ASSERT(fs_imgs[i]->d3d11_smp);
6726 d3d11_fs_srvs[i] = fs_imgs[i]->d3d11_srv;
6727 d3d11_fs_smps[i] = fs_imgs[i]->d3d11_smp;
6728 }
6729 for (; i < SG_MAX_SHADERSTAGE_IMAGES; i++) {
6730 d3d11_fs_srvs[i] = 0;
6731 d3d11_fs_smps[i] = 0;
6732 }
6733
6734 ID3D11DeviceContext_IASetVertexBuffers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_BUFFERS, d3d11_vbs, pip->d3d11_vb_strides, d3d11_vb_offsets);
6735 ID3D11DeviceContext_IASetIndexBuffer(_sg.d3d11.ctx, d3d11_ib, pip->d3d11_index_format, ib_offset);
6736 ID3D11DeviceContext_VSSetShaderResources(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_vs_srvs);
6737 ID3D11DeviceContext_VSSetSamplers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_vs_smps);
6738 ID3D11DeviceContext_PSSetShaderResources(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_fs_srvs);
6739 ID3D11DeviceContext_PSSetSamplers(_sg.d3d11.ctx, 0, SG_MAX_SHADERSTAGE_IMAGES, d3d11_fs_smps);
6740 }
6741
6742 _SOKOL_PRIVATE void _sg_apply_uniforms(sg_shader_stage stage_index, int ub_index, const void* data, int num_bytes) {
6743 _SOKOL_UNUSED(num_bytes);
6744 SOKOL_ASSERT(_sg.d3d11.ctx && _sg.d3d11.in_pass);
6745 SOKOL_ASSERT(data && (num_bytes > 0));
6746 SOKOL_ASSERT((stage_index >= 0) && (stage_index < SG_NUM_SHADER_STAGES));
6747 SOKOL_ASSERT((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS));
6748 SOKOL_ASSERT(_sg.d3d11.cur_pipeline && _sg.d3d11.cur_pipeline->slot.id == _sg.d3d11.cur_pipeline_id.id);
6749 SOKOL_ASSERT(_sg.d3d11.cur_pipeline->shader && _sg.d3d11.cur_pipeline->shader->slot.id == _sg.d3d11.cur_pipeline->shader_id.id);
6750 SOKOL_ASSERT(ub_index < _sg.d3d11.cur_pipeline->shader->stage[stage_index].num_uniform_blocks);
6751 SOKOL_ASSERT(num_bytes == _sg.d3d11.cur_pipeline->shader->stage[stage_index].uniform_blocks[ub_index].size);
6752 ID3D11Buffer* cb = _sg.d3d11.cur_pipeline->shader->stage[stage_index].d3d11_cbs[ub_index];
6753 SOKOL_ASSERT(cb);
6754 ID3D11DeviceContext_UpdateSubresource(_sg.d3d11.ctx, (ID3D11Resource*)cb, 0, NULL, data, 0, 0);
6755 }
6756
6757 _SOKOL_PRIVATE void _sg_draw(int base_element, int num_elements, int num_instances) {
6758 SOKOL_ASSERT(_sg.d3d11.in_pass);
6759 if (_sg.d3d11.use_indexed_draw) {
6760 if (1 == num_instances) {
6761 ID3D11DeviceContext_DrawIndexed(_sg.d3d11.ctx, num_elements, base_element, 0);
6762 }
6763 else {
6764 ID3D11DeviceContext_DrawIndexedInstanced(_sg.d3d11.ctx, num_elements, num_instances, base_element, 0, 0);
6765 }
6766 }
6767 else {
6768 if (1 == num_instances) {
6769 ID3D11DeviceContext_Draw(_sg.d3d11.ctx, num_elements, base_element);
6770 }
6771 else {
6772 ID3D11DeviceContext_DrawInstanced(_sg.d3d11.ctx, num_elements, num_instances, base_element, 0);
6773 }
6774 }
6775 }
6776
6777 _SOKOL_PRIVATE void _sg_commit(void) {
6778 SOKOL_ASSERT(!_sg.d3d11.in_pass);
6779 }
6780
6781 _SOKOL_PRIVATE void _sg_update_buffer(_sg_buffer_t* buf, const void* data_ptr, int data_size) {
6782 SOKOL_ASSERT(buf && data_ptr && (data_size > 0));
6783 SOKOL_ASSERT(_sg.d3d11.ctx);
6784 SOKOL_ASSERT(buf->d3d11_buf);
6785 D3D11_MAPPED_SUBRESOURCE d3d11_msr;
6786 HRESULT hr = ID3D11DeviceContext_Map(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11_buf, 0, D3D11_MAP_WRITE_DISCARD, 0, &d3d11_msr);
6787 _SOKOL_UNUSED(hr);
6788 SOKOL_ASSERT(SUCCEEDED(hr));
6789 memcpy(d3d11_msr.pData, data_ptr, data_size);
6790 ID3D11DeviceContext_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11_buf, 0);
6791 }
6792
6793 _SOKOL_PRIVATE void _sg_append_buffer(_sg_buffer_t* buf, const void* data_ptr, int data_size, bool new_frame) {
6794 SOKOL_ASSERT(buf && data_ptr && (data_size > 0));
6795 SOKOL_ASSERT(_sg.d3d11.ctx);
6796 SOKOL_ASSERT(buf->d3d11_buf);
6797 D3D11_MAP map_type = new_frame ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE;
6798 D3D11_MAPPED_SUBRESOURCE d3d11_msr;
6799 HRESULT hr = ID3D11DeviceContext_Map(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11_buf, 0, map_type, 0, &d3d11_msr);
6800 _SOKOL_UNUSED(hr);
6801 SOKOL_ASSERT(SUCCEEDED(hr));
6802 uint8_t* dst_ptr = (uint8_t*)d3d11_msr.pData + buf->append_pos;
6803 memcpy(dst_ptr, data_ptr, data_size);
6804 ID3D11DeviceContext_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11_buf, 0);
6805 }
6806
6807 _SOKOL_PRIVATE void _sg_update_image(_sg_image_t* img, const sg_image_content* data) {
6808 SOKOL_ASSERT(img && data);
6809 SOKOL_ASSERT(_sg.d3d11.ctx);
6810 SOKOL_ASSERT(img->d3d11_tex2d || img->d3d11_tex3d);
6811 ID3D11Resource* d3d11_res = 0;
6812 if (img->d3d11_tex3d) {
6813 d3d11_res = (ID3D11Resource*) img->d3d11_tex3d;
6814 }
6815 else {
6816 d3d11_res = (ID3D11Resource*) img->d3d11_tex2d;
6817 }
6818 SOKOL_ASSERT(d3d11_res);
6819 const int num_faces = (img->type == SG_IMAGETYPE_CUBE) ? 6:1;
6820 const int num_slices = (img->type == SG_IMAGETYPE_ARRAY) ? img->depth:1;
6821 int subres_index = 0;
6822 HRESULT hr;
6823 D3D11_MAPPED_SUBRESOURCE d3d11_msr;
6824 for (int face_index = 0; face_index < num_faces; face_index++) {
6825 for (int slice_index = 0; slice_index < num_slices; slice_index++) {
6826 for (int mip_index = 0; mip_index < img->num_mipmaps; mip_index++, subres_index++) {
6827 SOKOL_ASSERT(subres_index < (SG_MAX_MIPMAPS * SG_MAX_TEXTUREARRAY_LAYERS));
6828 const int mip_width = ((img->width>>mip_index)>0) ? img->width>>mip_index : 1;
6829 const int mip_height = ((img->height>>mip_index)>0) ? img->height>>mip_index : 1;
6830 const int src_pitch = _sg_row_pitch(img->pixel_format, mip_width);
6831 const sg_subimage_content* subimg_content = &(data->subimage[face_index][mip_index]);
6832 const int slice_size = subimg_content->size / num_slices;
6833 const int slice_offset = slice_size * slice_index;
6834 const uint8_t* slice_ptr = ((const uint8_t*)subimg_content->ptr) + slice_offset;
6835 hr = ID3D11DeviceContext_Map(_sg.d3d11.ctx, d3d11_res, subres_index, D3D11_MAP_WRITE_DISCARD, 0, &d3d11_msr);
6836 SOKOL_ASSERT(SUCCEEDED(hr));
6837 /* FIXME: need to handle difference in depth-pitch for 3D textures as well! */
6838 if (src_pitch == (int)d3d11_msr.RowPitch) {
6839 memcpy(d3d11_msr.pData, slice_ptr, slice_size);
6840 }
6841 else {
6842 SOKOL_ASSERT(src_pitch < (int)d3d11_msr.RowPitch);
6843 const uint8_t* src_ptr = slice_ptr;
6844 uint8_t* dst_ptr = (uint8_t*) d3d11_msr.pData;
6845 for (int row_index = 0; row_index < mip_height; row_index++) {
6846 memcpy(dst_ptr, src_ptr, src_pitch);
6847 src_ptr += src_pitch;
6848 dst_ptr += d3d11_msr.RowPitch;
6849 }
6850 }
6851 ID3D11DeviceContext_Unmap(_sg.d3d11.ctx, d3d11_res, subres_index);
6852 }
6853 }
6854 }
6855 }
6856
6857 /*== METAL BACKEND IMPLEMENTATION ============================================*/
6858 #elif defined(SOKOL_METAL)
6859
6860 /*-- enum translation functions ----------------------------------------------*/
6861 _SOKOL_PRIVATE MTLLoadAction _sg_mtl_load_action(sg_action a) {
6862 switch (a) {
6863 case SG_ACTION_CLEAR: return MTLLoadActionClear;
6864 case SG_ACTION_LOAD: return MTLLoadActionLoad;
6865 case SG_ACTION_DONTCARE: return MTLLoadActionDontCare;
6866 default: SOKOL_UNREACHABLE; return (MTLLoadAction)0;
6867 }
6868 }
6869
6870 _SOKOL_PRIVATE MTLResourceOptions _sg_mtl_buffer_resource_options(sg_usage usg) {
6871 switch (usg) {
6872 case SG_USAGE_IMMUTABLE:
6873 return MTLResourceStorageModeShared;
6874 case SG_USAGE_DYNAMIC:
6875 case SG_USAGE_STREAM:
6876 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
6877 return MTLCPUCacheModeWriteCombined|MTLResourceStorageModeManaged;
6878 #else
6879 return MTLCPUCacheModeWriteCombined;
6880 #endif
6881 default:
6882 SOKOL_UNREACHABLE;
6883 return 0;
6884 }
6885 }
6886
6887 _SOKOL_PRIVATE MTLVertexStepFunction _sg_mtl_step_function(sg_vertex_step step) {
6888 switch (step) {
6889 case SG_VERTEXSTEP_PER_VERTEX: return MTLVertexStepFunctionPerVertex;
6890 case SG_VERTEXSTEP_PER_INSTANCE: return MTLVertexStepFunctionPerInstance;
6891 default: SOKOL_UNREACHABLE; return (MTLVertexStepFunction)0;
6892 }
6893 }
6894
6895 _SOKOL_PRIVATE MTLVertexFormat _sg_mtl_vertex_format(sg_vertex_format fmt) {
6896 switch (fmt) {
6897 case SG_VERTEXFORMAT_FLOAT: return MTLVertexFormatFloat;
6898 case SG_VERTEXFORMAT_FLOAT2: return MTLVertexFormatFloat2;
6899 case SG_VERTEXFORMAT_FLOAT3: return MTLVertexFormatFloat3;
6900 case SG_VERTEXFORMAT_FLOAT4: return MTLVertexFormatFloat4;
6901 case SG_VERTEXFORMAT_BYTE4: return MTLVertexFormatChar4;
6902 case SG_VERTEXFORMAT_BYTE4N: return MTLVertexFormatChar4Normalized;
6903 case SG_VERTEXFORMAT_UBYTE4: return MTLVertexFormatUChar4;
6904 case SG_VERTEXFORMAT_UBYTE4N: return MTLVertexFormatUChar4Normalized;
6905 case SG_VERTEXFORMAT_SHORT2: return MTLVertexFormatShort2;
6906 case SG_VERTEXFORMAT_SHORT2N: return MTLVertexFormatShort2Normalized;
6907 case SG_VERTEXFORMAT_SHORT4: return MTLVertexFormatShort4;
6908 case SG_VERTEXFORMAT_SHORT4N: return MTLVertexFormatShort4Normalized;
6909 case SG_VERTEXFORMAT_UINT10_N2: return MTLVertexFormatUInt1010102Normalized;
6910 default: SOKOL_UNREACHABLE; return (MTLVertexFormat)0;
6911 }
6912 }
6913
6914 _SOKOL_PRIVATE MTLPrimitiveType _sg_mtl_primitive_type(sg_primitive_type t) {
6915 switch (t) {
6916 case SG_PRIMITIVETYPE_POINTS: return MTLPrimitiveTypePoint;
6917 case SG_PRIMITIVETYPE_LINES: return MTLPrimitiveTypeLine;
6918 case SG_PRIMITIVETYPE_LINE_STRIP: return MTLPrimitiveTypeLineStrip;
6919 case SG_PRIMITIVETYPE_TRIANGLES: return MTLPrimitiveTypeTriangle;
6920 case SG_PRIMITIVETYPE_TRIANGLE_STRIP: return MTLPrimitiveTypeTriangleStrip;
6921 default: SOKOL_UNREACHABLE; return (MTLPrimitiveType)0;
6922 }
6923 }
6924
6925 _SOKOL_PRIVATE MTLPixelFormat _sg_mtl_texture_format(sg_pixel_format fmt) {
6926 switch (fmt) {
6927 case SG_PIXELFORMAT_RGBA8: return MTLPixelFormatRGBA8Unorm;
6928 case SG_PIXELFORMAT_R10G10B10A2: return MTLPixelFormatRGB10A2Unorm;
6929 case SG_PIXELFORMAT_RGBA32F: return MTLPixelFormatRGBA32Float;
6930 case SG_PIXELFORMAT_RGBA16F: return MTLPixelFormatRGBA16Float;
6931 case SG_PIXELFORMAT_R32F: return MTLPixelFormatR32Float;
6932 case SG_PIXELFORMAT_R16F: return MTLPixelFormatR16Float;
6933 case SG_PIXELFORMAT_L8: return MTLPixelFormatR8Unorm;
6934 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
6935 case SG_PIXELFORMAT_DXT1: return MTLPixelFormatBC1_RGBA;
6936 case SG_PIXELFORMAT_DXT3: return MTLPixelFormatBC2_RGBA;
6937 case SG_PIXELFORMAT_DXT5: return MTLPixelFormatBC3_RGBA;
6938 #else
6939 case SG_PIXELFORMAT_PVRTC2_RGB: return MTLPixelFormatPVRTC_RGB_2BPP;
6940 case SG_PIXELFORMAT_PVRTC4_RGB: return MTLPixelFormatPVRTC_RGB_4BPP;
6941 case SG_PIXELFORMAT_PVRTC2_RGBA: return MTLPixelFormatPVRTC_RGBA_2BPP;
6942 case SG_PIXELFORMAT_PVRTC4_RGBA: return MTLPixelFormatPVRTC_RGBA_4BPP;
6943 case SG_PIXELFORMAT_ETC2_RGB8: return MTLPixelFormatETC2_RGB8;
6944 case SG_PIXELFORMAT_ETC2_SRGB8: return MTLPixelFormatETC2_RGB8_sRGB;
6945 #endif
6946 default: return MTLPixelFormatInvalid;
6947 }
6948 }
6949
6950 _SOKOL_PRIVATE MTLPixelFormat _sg_mtl_rendertarget_color_format(sg_pixel_format fmt) {
6951 switch (fmt) {
6952 case SG_PIXELFORMAT_RGBA8: return MTLPixelFormatBGRA8Unorm; /* not a bug */
6953 case SG_PIXELFORMAT_RGBA32F: return MTLPixelFormatRGBA32Float;
6954 case SG_PIXELFORMAT_RGBA16F: return MTLPixelFormatRGBA16Float;
6955 case SG_PIXELFORMAT_R10G10B10A2: return MTLPixelFormatRGB10A2Unorm;
6956 default: return MTLPixelFormatInvalid;
6957 }
6958 }
6959
6960 _SOKOL_PRIVATE MTLPixelFormat _sg_mtl_rendertarget_depth_format(sg_pixel_format fmt) {
6961 switch (fmt) {
6962 case SG_PIXELFORMAT_DEPTH:
6963 return MTLPixelFormatDepth32Float;
6964 case SG_PIXELFORMAT_DEPTHSTENCIL:
6965 /* NOTE: Depth24_Stencil8 isn't universally supported! */
6966 return MTLPixelFormatDepth32Float_Stencil8;
6967 default:
6968 return MTLPixelFormatInvalid;
6969 }
6970 }
6971
6972 _SOKOL_PRIVATE MTLPixelFormat _sg_mtl_rendertarget_stencil_format(sg_pixel_format fmt) {
6973 switch (fmt) {
6974 case SG_PIXELFORMAT_DEPTHSTENCIL:
6975 return MTLPixelFormatDepth32Float_Stencil8;
6976 default:
6977 return MTLPixelFormatInvalid;
6978 }
6979 }
6980
6981 _SOKOL_PRIVATE MTLColorWriteMask _sg_mtl_color_write_mask(sg_color_mask m) {
6982 MTLColorWriteMask mtl_mask = MTLColorWriteMaskNone;
6983 if (m & SG_COLORMASK_R) {
6984 mtl_mask |= MTLColorWriteMaskRed;
6985 }
6986 if (m & SG_COLORMASK_G) {
6987 mtl_mask |= MTLColorWriteMaskGreen;
6988 }
6989 if (m & SG_COLORMASK_B) {
6990 mtl_mask |= MTLColorWriteMaskBlue;
6991 }
6992 if (m & SG_COLORMASK_A) {
6993 mtl_mask |= MTLColorWriteMaskAlpha;
6994 }
6995 return mtl_mask;
6996 }
6997
6998 _SOKOL_PRIVATE MTLBlendOperation _sg_mtl_blend_op(sg_blend_op op) {
6999 switch (op) {
7000 case SG_BLENDOP_ADD: return MTLBlendOperationAdd;
7001 case SG_BLENDOP_SUBTRACT: return MTLBlendOperationSubtract;
7002 case SG_BLENDOP_REVERSE_SUBTRACT: return MTLBlendOperationReverseSubtract;
7003 default: SOKOL_UNREACHABLE; return (MTLBlendOperation)0;
7004 }
7005 }
7006
7007 _SOKOL_PRIVATE MTLBlendFactor _sg_mtl_blend_factor(sg_blend_factor f) {
7008 switch (f) {
7009 case SG_BLENDFACTOR_ZERO: return MTLBlendFactorZero;
7010 case SG_BLENDFACTOR_ONE: return MTLBlendFactorOne;
7011 case SG_BLENDFACTOR_SRC_COLOR: return MTLBlendFactorSourceColor;
7012 case SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR: return MTLBlendFactorOneMinusSourceColor;
7013 case SG_BLENDFACTOR_SRC_ALPHA: return MTLBlendFactorSourceAlpha;
7014 case SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: return MTLBlendFactorOneMinusSourceAlpha;
7015 case SG_BLENDFACTOR_DST_COLOR: return MTLBlendFactorDestinationColor;
7016 case SG_BLENDFACTOR_ONE_MINUS_DST_COLOR: return MTLBlendFactorOneMinusDestinationColor;
7017 case SG_BLENDFACTOR_DST_ALPHA: return MTLBlendFactorDestinationAlpha;
7018 case SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA: return MTLBlendFactorOneMinusDestinationAlpha;
7019 case SG_BLENDFACTOR_SRC_ALPHA_SATURATED: return MTLBlendFactorSourceAlphaSaturated;
7020 case SG_BLENDFACTOR_BLEND_COLOR: return MTLBlendFactorBlendColor;
7021 case SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR: return MTLBlendFactorOneMinusBlendColor;
7022 case SG_BLENDFACTOR_BLEND_ALPHA: return MTLBlendFactorBlendAlpha;
7023 case SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA: return MTLBlendFactorOneMinusBlendAlpha;
7024 default: SOKOL_UNREACHABLE; return (MTLBlendFactor)0;
7025 }
7026 }
7027
7028 _SOKOL_PRIVATE MTLCompareFunction _sg_mtl_compare_func(sg_compare_func f) {
7029 switch (f) {
7030 case SG_COMPAREFUNC_NEVER: return MTLCompareFunctionNever;
7031 case SG_COMPAREFUNC_LESS: return MTLCompareFunctionLess;
7032 case SG_COMPAREFUNC_EQUAL: return MTLCompareFunctionEqual;
7033 case SG_COMPAREFUNC_LESS_EQUAL: return MTLCompareFunctionLessEqual;
7034 case SG_COMPAREFUNC_GREATER: return MTLCompareFunctionGreater;
7035 case SG_COMPAREFUNC_NOT_EQUAL: return MTLCompareFunctionNotEqual;
7036 case SG_COMPAREFUNC_GREATER_EQUAL: return MTLCompareFunctionGreaterEqual;
7037 case SG_COMPAREFUNC_ALWAYS: return MTLCompareFunctionAlways;
7038 default: SOKOL_UNREACHABLE; return (MTLCompareFunction)0;
7039 }
7040 }
7041
7042 _SOKOL_PRIVATE MTLStencilOperation _sg_mtl_stencil_op(sg_stencil_op op) {
7043 switch (op) {
7044 case SG_STENCILOP_KEEP: return MTLStencilOperationKeep;
7045 case SG_STENCILOP_ZERO: return MTLStencilOperationZero;
7046 case SG_STENCILOP_REPLACE: return MTLStencilOperationReplace;
7047 case SG_STENCILOP_INCR_CLAMP: return MTLStencilOperationIncrementClamp;
7048 case SG_STENCILOP_DECR_CLAMP: return MTLStencilOperationDecrementClamp;
7049 case SG_STENCILOP_INVERT: return MTLStencilOperationInvert;
7050 case SG_STENCILOP_INCR_WRAP: return MTLStencilOperationIncrementWrap;
7051 case SG_STENCILOP_DECR_WRAP: return MTLStencilOperationDecrementWrap;
7052 default: SOKOL_UNREACHABLE; return (MTLStencilOperation)0;
7053 }
7054 }
7055
7056 _SOKOL_PRIVATE MTLCullMode _sg_mtl_cull_mode(sg_cull_mode m) {
7057 switch (m) {
7058 case SG_CULLMODE_NONE: return MTLCullModeNone;
7059 case SG_CULLMODE_FRONT: return MTLCullModeFront;
7060 case SG_CULLMODE_BACK: return MTLCullModeBack;
7061 default: SOKOL_UNREACHABLE; return (MTLCullMode)0;
7062 }
7063 }
7064
7065 _SOKOL_PRIVATE MTLWinding _sg_mtl_winding(sg_face_winding w) {
7066 switch (w) {
7067 case SG_FACEWINDING_CW: return MTLWindingClockwise;
7068 case SG_FACEWINDING_CCW: return MTLWindingCounterClockwise;
7069 default: SOKOL_UNREACHABLE; return (MTLWinding)0;
7070 }
7071 }
7072
7073 _SOKOL_PRIVATE MTLIndexType _sg_mtl_index_type(sg_index_type t) {
7074 switch (t) {
7075 case SG_INDEXTYPE_UINT16: return MTLIndexTypeUInt16;
7076 case SG_INDEXTYPE_UINT32: return MTLIndexTypeUInt32;
7077 default: SOKOL_UNREACHABLE; return (MTLIndexType)0;
7078 }
7079 }
7080
7081 _SOKOL_PRIVATE NSUInteger _sg_mtl_index_size(sg_index_type t) {
7082 switch (t) {
7083 case SG_INDEXTYPE_NONE: return 0;
7084 case SG_INDEXTYPE_UINT16: return 2;
7085 case SG_INDEXTYPE_UINT32: return 4;
7086 default: SOKOL_UNREACHABLE; return 0;
7087 }
7088 }
7089
7090 _SOKOL_PRIVATE MTLTextureType _sg_mtl_texture_type(sg_image_type t) {
7091 switch (t) {
7092 case SG_IMAGETYPE_2D: return MTLTextureType2D;
7093 case SG_IMAGETYPE_CUBE: return MTLTextureTypeCube;
7094 case SG_IMAGETYPE_3D: return MTLTextureType3D;
7095 case SG_IMAGETYPE_ARRAY: return MTLTextureType2DArray;
7096 default: SOKOL_UNREACHABLE; return (MTLTextureType)0;
7097 }
7098 }
7099
7100 _SOKOL_PRIVATE bool _sg_mtl_is_pvrtc(sg_pixel_format fmt) {
7101 switch (fmt) {
7102 case SG_PIXELFORMAT_PVRTC2_RGB:
7103 case SG_PIXELFORMAT_PVRTC2_RGBA:
7104 case SG_PIXELFORMAT_PVRTC4_RGB:
7105 case SG_PIXELFORMAT_PVRTC4_RGBA:
7106 return true;
7107 default:
7108 return false;
7109 }
7110 }
7111
7112 _SOKOL_PRIVATE MTLSamplerAddressMode _sg_mtl_address_mode(sg_wrap w) {
7113 switch (w) {
7114 case SG_WRAP_REPEAT: return MTLSamplerAddressModeRepeat;
7115 case SG_WRAP_CLAMP_TO_EDGE: return MTLSamplerAddressModeClampToEdge;
7116 case SG_WRAP_MIRRORED_REPEAT: return MTLSamplerAddressModeMirrorRepeat;
7117 default: SOKOL_UNREACHABLE; return (MTLSamplerAddressMode)0;
7118 }
7119 }
7120
7121 _SOKOL_PRIVATE MTLSamplerMinMagFilter _sg_mtl_minmag_filter(sg_filter f) {
7122 switch (f) {
7123 case SG_FILTER_NEAREST:
7124 case SG_FILTER_NEAREST_MIPMAP_NEAREST:
7125 case SG_FILTER_NEAREST_MIPMAP_LINEAR:
7126 return MTLSamplerMinMagFilterNearest;
7127 case SG_FILTER_LINEAR:
7128 case SG_FILTER_LINEAR_MIPMAP_NEAREST:
7129 case SG_FILTER_LINEAR_MIPMAP_LINEAR:
7130 return MTLSamplerMinMagFilterLinear;
7131 default:
7132 SOKOL_UNREACHABLE; return (MTLSamplerMinMagFilter)0;
7133 }
7134 }
7135
7136 _SOKOL_PRIVATE MTLSamplerMipFilter _sg_mtl_mip_filter(sg_filter f) {
7137 switch (f) {
7138 case SG_FILTER_NEAREST:
7139 case SG_FILTER_LINEAR:
7140 return MTLSamplerMipFilterNotMipmapped;
7141 case SG_FILTER_NEAREST_MIPMAP_NEAREST:
7142 case SG_FILTER_LINEAR_MIPMAP_NEAREST:
7143 return MTLSamplerMipFilterNearest;
7144 case SG_FILTER_NEAREST_MIPMAP_LINEAR:
7145 case SG_FILTER_LINEAR_MIPMAP_LINEAR:
7146 return MTLSamplerMipFilterLinear;
7147 default:
7148 SOKOL_UNREACHABLE; return (MTLSamplerMipFilter)0;
7149 }
7150 }
7151
7152 /*-- a pool for all Metal resource objects, with deferred release queue -------*/
7153
7154 _SOKOL_PRIVATE void _sg_mtl_init_pool(const sg_desc* desc) {
7155 _sg.mtl.idpool.num_slots = 2 *
7156 (
7157 2 * desc->buffer_pool_size +
7158 5 * desc->image_pool_size +
7159 4 * desc->shader_pool_size +
7160 2 * desc->pipeline_pool_size +
7161 desc->pass_pool_size
7162 );
7163 _sg_mtl_idpool = [NSMutableArray arrayWithCapacity:_sg.mtl.idpool.num_slots];
7164 NSNull* null = [NSNull null];
7165 for (uint32_t i = 0; i < _sg.mtl.idpool.num_slots; i++) {
7166 [_sg_mtl_idpool addObject:null];
7167 }
7168 SOKOL_ASSERT([_sg_mtl_idpool count] == _sg.mtl.idpool.num_slots);
7169 /* a queue of currently free slot indices */
7170 _sg.mtl.idpool.free_queue_top = 0;
7171 _sg.mtl.idpool.free_queue = (uint32_t*)SOKOL_MALLOC(_sg.mtl.idpool.num_slots * sizeof(uint32_t));
7172 /* pool slot 0 is reserved! */
7173 for (int i = _sg.mtl.idpool.num_slots-1; i >= 1; i--) {
7174 _sg.mtl.idpool.free_queue[_sg.mtl.idpool.free_queue_top++] = (uint32_t)i;
7175 }
7176 /* a circular queue which holds release items (frame index
7177 when a resource is to be released, and the resource's
7178 pool index
7179 */
7180 _sg.mtl.idpool.release_queue_front = 0;
7181 _sg.mtl.idpool.release_queue_back = 0;
7182 _sg.mtl.idpool.release_queue = (_sg_mtl_release_item_t*)SOKOL_MALLOC(_sg.mtl.idpool.num_slots * sizeof(_sg_mtl_release_item_t));
7183 for (uint32_t i = 0; i < _sg.mtl.idpool.num_slots; i++) {
7184 _sg.mtl.idpool.release_queue[i].frame_index = 0;
7185 _sg.mtl.idpool.release_queue[i].slot_index = _SG_MTL_INVALID_SLOT_INDEX;
7186 }
7187 }
7188
7189 _SOKOL_PRIVATE void _sg_mtl_destroy_pool(void) {
7190 SOKOL_FREE(_sg.mtl.idpool.release_queue); _sg.mtl.idpool.release_queue = 0;
7191 SOKOL_FREE(_sg.mtl.idpool.free_queue); _sg.mtl.idpool.free_queue = 0;
7192 _sg_mtl_idpool = nil;
7193 }
7194
7195 /* get a new free resource pool slot */
7196 _SOKOL_PRIVATE uint32_t _sg_mtl_alloc_pool_slot(void) {
7197 SOKOL_ASSERT(_sg.mtl.idpool.free_queue_top > 0);
7198 const uint32_t slot_index = _sg.mtl.idpool.free_queue[--_sg.mtl.idpool.free_queue_top];
7199 SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots));
7200 return slot_index;
7201 }
7202
7203 /* put a free resource pool slot back into the free-queue */
7204 _SOKOL_PRIVATE void _sg_mtl_free_pool_slot(uint32_t slot_index) {
7205 SOKOL_ASSERT(_sg.mtl.idpool.free_queue_top < _sg.mtl.idpool.num_slots);
7206 SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots));
7207 _sg.mtl.idpool.free_queue[_sg.mtl.idpool.free_queue_top++] = slot_index;
7208 }
7209
7210 /* add an MTLResource to the pool, return pool index or 0 if input was 'nil' */
7211 _SOKOL_PRIVATE uint32_t _sg_mtl_add_resource(id res) {
7212 if (nil == res) {
7213 return _SG_MTL_INVALID_SLOT_INDEX;
7214 }
7215 const uint32_t slot_index = _sg_mtl_alloc_pool_slot();
7216 SOKOL_ASSERT([NSNull null] == _sg_mtl_idpool[slot_index]);
7217 _sg_mtl_idpool[slot_index] = res;
7218 return slot_index;
7219 }
7220
7221 /* mark an MTLResource for release, this will put the resource into the
7222 deferred-release queue, and the resource will then be released N frames later,
7223 the special pool index 0 will be ignored (this means that a nil
7224 value was provided to _sg_mtl_add_resource()
7225 */
7226 _SOKOL_PRIVATE void _sg_mtl_release_resource(uint32_t frame_index, uint32_t slot_index) {
7227 if (slot_index == _SG_MTL_INVALID_SLOT_INDEX) {
7228 return;
7229 }
7230 SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots));
7231 SOKOL_ASSERT([NSNull null] != _sg_mtl_idpool[slot_index]);
7232 int release_index = _sg.mtl.idpool.release_queue_front++;
7233 if (_sg.mtl.idpool.release_queue_front >= _sg.mtl.idpool.num_slots) {
7234 /* wrap-around */
7235 _sg.mtl.idpool.release_queue_front = 0;
7236 }
7237 /* release queue full? */
7238 SOKOL_ASSERT(_sg.mtl.idpool.release_queue_front != _sg.mtl.idpool.release_queue_back);
7239 SOKOL_ASSERT(0 == _sg.mtl.idpool.release_queue[release_index].frame_index);
7240 const uint32_t safe_to_release_frame_index = frame_index + SG_NUM_INFLIGHT_FRAMES + 1;
7241 _sg.mtl.idpool.release_queue[release_index].frame_index = safe_to_release_frame_index;
7242 _sg.mtl.idpool.release_queue[release_index].slot_index = slot_index;
7243 }
7244
7245 /* run garbage-collection pass on all resources in the release-queue */
7246 _SOKOL_PRIVATE void _sg_mtl_garbage_collect(uint32_t frame_index) {
7247 while (_sg.mtl.idpool.release_queue_back != _sg.mtl.idpool.release_queue_front) {
7248 if (frame_index < _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].frame_index) {
7249 /* don't need to check further, release-items past this are too young */
7250 break;
7251 }
7252 /* safe to release this resource */
7253 const uint32_t slot_index = _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].slot_index;
7254 SOKOL_ASSERT((slot_index > 0) && (slot_index < _sg.mtl.idpool.num_slots));
7255 SOKOL_ASSERT(_sg_mtl_idpool[slot_index] != [NSNull null]);
7256 _sg_mtl_idpool[slot_index] = [NSNull null];
7257 /* put the now free pool index back on the free queue */
7258 _sg_mtl_free_pool_slot(slot_index);
7259 /* reset the release queue slot and advance the back index */
7260 _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].frame_index = 0;
7261 _sg.mtl.idpool.release_queue[_sg.mtl.idpool.release_queue_back].slot_index = _SG_MTL_INVALID_SLOT_INDEX;
7262 _sg.mtl.idpool.release_queue_back++;
7263 if (_sg.mtl.idpool.release_queue_back >= _sg.mtl.idpool.num_slots) {
7264 /* wrap-around */
7265 _sg.mtl.idpool.release_queue_back = 0;
7266 }
7267 }
7268 }
7269
7270 /*-- a very simple sampler cache -----------------------------------------------
7271
7272 since there's only a small number of different samplers, sampler objects
7273 will never be deleted (except on shutdown), and searching an identical
7274 sampler is a simple linear search
7275 */
7276 /* initialize the sampler cache */
7277 _SOKOL_PRIVATE void _sg_mtl_init_sampler_cache(const sg_desc* desc) {
7278 SOKOL_ASSERT(desc->mtl_sampler_cache_size > 0);
7279 _sg.mtl.sampler_cache.capacity = desc->mtl_sampler_cache_size;
7280 _sg.mtl.sampler_cache.num_items = 0;
7281 const int size = _sg.mtl.sampler_cache.capacity * sizeof(_sg_mtl_sampler_cache_item_t);
7282 _sg.mtl.sampler_cache.items = (_sg_mtl_sampler_cache_item_t*)SOKOL_MALLOC(size);
7283 memset(_sg.mtl.sampler_cache.items, 0, size);
7284 }
7285
7286 /* destroy the sampler cache, and release all sampler objects */
7287 _SOKOL_PRIVATE void _sg_mtl_destroy_sampler_cache(uint32_t frame_index) {
7288 SOKOL_ASSERT(_sg.mtl.sampler_cache.items);
7289 SOKOL_ASSERT(_sg.mtl.sampler_cache.num_items <= _sg.mtl.sampler_cache.capacity);
7290 for (int i = 0; i < _sg.mtl.sampler_cache.num_items; i++) {
7291 _sg_mtl_release_resource(frame_index, _sg.mtl.sampler_cache.items[i].mtl_sampler_state);
7292 }
7293 SOKOL_FREE(_sg.mtl.sampler_cache.items); _sg.mtl.sampler_cache.items = 0;
7294 _sg.mtl.sampler_cache.num_items = 0;
7295 _sg.mtl.sampler_cache.capacity = 0;
7296 }
7297
7298 /*
7299 create and add an MTLSamplerStateObject and return its resource pool index,
7300 reuse identical sampler state if one exists
7301 */
7302 _SOKOL_PRIVATE uint32_t _sg_mtl_create_sampler(id<MTLDevice> mtl_device, const sg_image_desc* img_desc) {
7303 SOKOL_ASSERT(img_desc);
7304 SOKOL_ASSERT(_sg.mtl.sampler_cache.items);
7305 /* sampler state cache is full */
7306 const sg_filter min_filter = img_desc->min_filter;
7307 const sg_filter mag_filter = img_desc->mag_filter;
7308 const sg_wrap wrap_u = img_desc->wrap_u;
7309 const sg_wrap wrap_v = img_desc->wrap_v;
7310 const sg_wrap wrap_w = img_desc->wrap_w;
7311 const uint32_t max_anisotropy = img_desc->max_anisotropy;
7312 /* convert floats to valid int for proper comparison */
7313 const int min_lod = (int)(img_desc->min_lod * 1000.0f);
7314 const int max_lod = (int)(_sg_clamp(img_desc->max_lod, 0.0f, 1000.0f) * 1000.0f);
7315 /* first try to find identical sampler, number of samplers will be small, so linear search is ok */
7316 for (int i = 0; i < _sg.mtl.sampler_cache.num_items; i++) {
7317 _sg_mtl_sampler_cache_item_t* item = &_sg.mtl.sampler_cache.items[i];
7318 if ((min_filter == item->min_filter) &&
7319 (mag_filter == item->mag_filter) &&
7320 (wrap_u == item->wrap_u) &&
7321 (wrap_v == item->wrap_v) &&
7322 (wrap_w == item->wrap_w) &&
7323 (max_anisotropy == item->max_anisotropy) &&
7324 (min_lod == item->min_lod) &&
7325 (max_lod == item->max_lod))
7326 {
7327 return item->mtl_sampler_state;
7328 }
7329 }
7330 /* fallthrough: need to create a new MTLSamplerState object */
7331 SOKOL_ASSERT(_sg.mtl.sampler_cache.num_items < _sg.mtl.sampler_cache.capacity);
7332 _sg_mtl_sampler_cache_item_t* new_item = &_sg.mtl.sampler_cache.items[_sg.mtl.sampler_cache.num_items++];
7333 new_item->min_filter = min_filter;
7334 new_item->mag_filter = mag_filter;
7335 new_item->wrap_u = wrap_u;
7336 new_item->wrap_v = wrap_v;
7337 new_item->wrap_w = wrap_w;
7338 new_item->min_lod = min_lod;
7339 new_item->max_lod = max_lod;
7340 new_item->max_anisotropy = max_anisotropy;
7341 MTLSamplerDescriptor* mtl_desc = [[MTLSamplerDescriptor alloc] init];
7342 mtl_desc.sAddressMode = _sg_mtl_address_mode(wrap_u);
7343 mtl_desc.tAddressMode = _sg_mtl_address_mode(wrap_v);
7344 if (SG_IMAGETYPE_3D == img_desc->type) {
7345 mtl_desc.rAddressMode = _sg_mtl_address_mode(wrap_w);
7346 }
7347 mtl_desc.minFilter = _sg_mtl_minmag_filter(min_filter);
7348 mtl_desc.magFilter = _sg_mtl_minmag_filter(mag_filter);
7349 mtl_desc.mipFilter = _sg_mtl_mip_filter(min_filter);
7350 mtl_desc.lodMinClamp = img_desc->min_lod;
7351 mtl_desc.lodMaxClamp = img_desc->max_lod;
7352 mtl_desc.maxAnisotropy = max_anisotropy;
7353 mtl_desc.normalizedCoordinates = YES;
7354 id<MTLSamplerState> mtl_sampler = [mtl_device newSamplerStateWithDescriptor:mtl_desc];
7355 new_item->mtl_sampler_state = _sg_mtl_add_resource(mtl_sampler);
7356 return new_item->mtl_sampler_state;
7357 }
7358
7359 /*-- a simple state cache for the resource bindings --------------------------*/
7360 _SOKOL_PRIVATE void _sg_mtl_clear_state_cache(void) {
7361 memset(&_sg.mtl.state_cache, 0, sizeof(_sg.mtl.state_cache));
7362 }
7363
7364 /*-- main Metal backend state and functions ----------------------------------*/
7365 _SOKOL_PRIVATE void _sg_setup_backend(const sg_desc* desc) {
7366 /* assume already zero-initialized */
7367 SOKOL_ASSERT(desc);
7368 SOKOL_ASSERT(desc->mtl_device);
7369 SOKOL_ASSERT(desc->mtl_renderpass_descriptor_cb);
7370 SOKOL_ASSERT(desc->mtl_drawable_cb);
7371 SOKOL_ASSERT(desc->mtl_global_uniform_buffer_size > 0);
7372 _sg_mtl_init_pool(desc);
7373 _sg_mtl_init_sampler_cache(desc);
7374 _sg_mtl_clear_state_cache();
7375 _sg.mtl.valid = true;
7376 _sg.mtl.renderpass_descriptor_cb = desc->mtl_renderpass_descriptor_cb;
7377 _sg.mtl.drawable_cb = desc->mtl_drawable_cb;
7378 _sg.mtl.frame_index = 1;
7379 _sg.mtl.ub_size = desc->mtl_global_uniform_buffer_size;
7380 _sg_mtl_sem = dispatch_semaphore_create(SG_NUM_INFLIGHT_FRAMES);
7381 _sg_mtl_device = (__bridge id<MTLDevice>) desc->mtl_device;
7382 _sg_mtl_cmd_queue = [_sg_mtl_device newCommandQueue];
7383 MTLResourceOptions res_opts = MTLResourceCPUCacheModeWriteCombined;
7384 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
7385 res_opts |= MTLResourceStorageModeManaged;
7386 #endif
7387 for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) {
7388 _sg_mtl_uniform_buffers[i] = [_sg_mtl_device
7389 newBufferWithLength:_sg.mtl.ub_size
7390 options:res_opts
7391 ];
7392 }
7393 }
7394
7395 _SOKOL_PRIVATE void _sg_discard_backend(void) {
7396 SOKOL_ASSERT(_sg.mtl.valid);
7397 /* wait for the last frame to finish */
7398 for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) {
7399 dispatch_semaphore_wait(_sg_mtl_sem, DISPATCH_TIME_FOREVER);
7400 }
7401 _sg_mtl_destroy_sampler_cache(_sg.mtl.frame_index);
7402 _sg_mtl_garbage_collect(_sg.mtl.frame_index + SG_NUM_INFLIGHT_FRAMES + 2);
7403 _sg_mtl_destroy_pool();
7404 _sg.mtl.valid = false;
7405 _sg_mtl_cmd_encoder = nil;
7406 _sg_mtl_cmd_buffer = nil;
7407 _sg_mtl_cmd_queue = nil;
7408 for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) {
7409 _sg_mtl_uniform_buffers[i] = nil;
7410 }
7411 _sg_mtl_device = nil;
7412 }
7413
7414 _SOKOL_PRIVATE bool _sg_query_feature(sg_feature f) {
7415 switch (f) {
7416 case SG_FEATURE_INSTANCING:
7417 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
7418 case SG_FEATURE_TEXTURE_COMPRESSION_DXT:
7419 #else
7420 case SG_FEATURE_TEXTURE_COMPRESSION_PVRTC:
7421 case SG_FEATURE_TEXTURE_COMPRESSION_ETC2:
7422 #endif
7423 case SG_FEATURE_TEXTURE_FLOAT:
7424 case SG_FEATURE_ORIGIN_TOP_LEFT:
7425 case SG_FEATURE_MSAA_RENDER_TARGETS:
7426 case SG_FEATURE_PACKED_VERTEX_FORMAT_10_2:
7427 case SG_FEATURE_MULTIPLE_RENDER_TARGET:
7428 case SG_FEATURE_IMAGETYPE_3D:
7429 case SG_FEATURE_IMAGETYPE_ARRAY:
7430 return true;
7431 default:
7432 return false;
7433 }
7434 }
7435
7436 _SOKOL_PRIVATE void _sg_reset_state_cache(void) {
7437 _sg_mtl_clear_state_cache();
7438 }
7439
7440 _SOKOL_PRIVATE sg_resource_state _sg_create_context(_sg_context_t* ctx) {
7441 SOKOL_ASSERT(ctx);
7442 _SOKOL_UNUSED(ctx);
7443 return SG_RESOURCESTATE_VALID;
7444 }
7445
7446 _SOKOL_PRIVATE void _sg_destroy_context(_sg_context_t* ctx) {
7447 SOKOL_ASSERT(ctx);
7448 _SOKOL_UNUSED(ctx);
7449 /* empty */
7450 }
7451
7452 _SOKOL_PRIVATE void _sg_activate_context(_sg_context_t* ctx) {
7453 _sg_reset_state_cache();
7454 }
7455
7456 _SOKOL_PRIVATE sg_resource_state _sg_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) {
7457 SOKOL_ASSERT(buf && desc);
7458 buf->size = desc->size;
7459 buf->append_pos = 0;
7460 buf->append_overflow = false;
7461 buf->type = desc->type;
7462 buf->usage = desc->usage;
7463 buf->update_frame_index = 0;
7464 buf->append_frame_index = 0;
7465 buf->num_slots = (buf->usage == SG_USAGE_IMMUTABLE) ? 1 : SG_NUM_INFLIGHT_FRAMES;
7466 buf->active_slot = 0;
7467 const bool injected = (0 != desc->mtl_buffers[0]);
7468 MTLResourceOptions mtl_options = _sg_mtl_buffer_resource_options(buf->usage);
7469 for (int slot = 0; slot < buf->num_slots; slot++) {
7470 id<MTLBuffer> mtl_buf;
7471 if (injected) {
7472 SOKOL_ASSERT(desc->mtl_buffers[slot]);
7473 mtl_buf = (__bridge id<MTLBuffer>) desc->mtl_buffers[slot];
7474 }
7475 else {
7476 if (buf->usage == SG_USAGE_IMMUTABLE) {
7477 SOKOL_ASSERT(desc->content);
7478 mtl_buf = [_sg_mtl_device newBufferWithBytes:desc->content length:buf->size options:mtl_options];
7479 }
7480 else {
7481 mtl_buf = [_sg_mtl_device newBufferWithLength:buf->size options:mtl_options];
7482 }
7483 }
7484 buf->mtl_buf[slot] = _sg_mtl_add_resource(mtl_buf);
7485 }
7486 return SG_RESOURCESTATE_VALID;
7487 }
7488
7489 _SOKOL_PRIVATE void _sg_destroy_buffer(_sg_buffer_t* buf) {
7490 SOKOL_ASSERT(buf);
7491 for (int slot = 0; slot < buf->num_slots; slot++) {
7492 /* it's valid to call release resource with '0' */
7493 _sg_mtl_release_resource(_sg.mtl.frame_index, buf->mtl_buf[slot]);
7494 }
7495 }
7496
7497 _SOKOL_PRIVATE void _sg_mtl_copy_image_content(const _sg_image_t* img, __unsafe_unretained id<MTLTexture> mtl_tex, const sg_image_content* content) {
7498 const int num_faces = (img->type == SG_IMAGETYPE_CUBE) ? 6:1;
7499 const int num_slices = (img->type == SG_IMAGETYPE_ARRAY) ? img->depth : 1;
7500 for (int face_index = 0; face_index < num_faces; face_index++) {
7501 for (int mip_index = 0; mip_index < img->num_mipmaps; mip_index++) {
7502 SOKOL_ASSERT(content->subimage[face_index][mip_index].ptr);
7503 SOKOL_ASSERT(content->subimage[face_index][mip_index].size > 0);
7504 const uint8_t* data_ptr = (const uint8_t*)content->subimage[face_index][mip_index].ptr;
7505 const int mip_width = _sg_max(img->width >> mip_index, 1);
7506 const int mip_height = _sg_max(img->height >> mip_index, 1);
7507 /* special case PVRTC formats: bytePerRow must be 0 */
7508 int bytes_per_row = 0;
7509 int bytes_per_slice = _sg_surface_pitch(img->pixel_format, mip_width, mip_height);
7510 if (!_sg_mtl_is_pvrtc(img->pixel_format)) {
7511 bytes_per_row = _sg_row_pitch(img->pixel_format, mip_width);
7512 }
7513 MTLRegion region;
7514 if (img->type == SG_IMAGETYPE_3D) {
7515 const int mip_depth = _sg_max(img->depth >> mip_index, 1);
7516 region = MTLRegionMake3D(0, 0, 0, mip_width, mip_height, mip_depth);
7517 /* FIXME: apparently the minimal bytes_per_image size for 3D texture
7518 is 4 KByte... somehow need to handle this */
7519 }
7520 else {
7521 region = MTLRegionMake2D(0, 0, mip_width, mip_height);
7522 }
7523 for (int slice_index = 0; slice_index < num_slices; slice_index++) {
7524 const int mtl_slice_index = (img->type == SG_IMAGETYPE_CUBE) ? face_index : slice_index;
7525 const int slice_offset = slice_index * bytes_per_slice;
7526 SOKOL_ASSERT((slice_offset + bytes_per_slice) <= (int)content->subimage[face_index][mip_index].size);
7527 [mtl_tex replaceRegion:region
7528 mipmapLevel:mip_index
7529 slice:mtl_slice_index
7530 withBytes:data_ptr + slice_offset
7531 bytesPerRow:bytes_per_row
7532 bytesPerImage:bytes_per_slice];
7533 }
7534 }
7535 }
7536 }
7537
7538 /*
7539 FIXME: METAL RESOURCE STORAGE MODE FOR macOS AND iOS
7540
7541 For immutable textures on macOS, the recommended procedure is to create
7542 a MTLStorageModeManaged texture with the immutable content first,
7543 and then use the GPU to blit the content into a MTLStorageModePrivate
7544 texture before the first use.
7545
7546 On iOS use the same one-time-blit procedure, but from a
7547 MTLStorageModeShared to a MTLStorageModePrivate texture.
7548
7549 It probably makes sense to handle this in a separate 'resource manager'
7550 with a recycable pool of blit-source-textures?
7551 */
7552
7553 /* initialize MTLTextureDescritor with common attributes */
7554 _SOKOL_PRIVATE bool _sg_mtl_init_texdesc_common(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) {
7555 mtl_desc.textureType = _sg_mtl_texture_type(img->type);
7556 if (img->render_target) {
7557 if (_sg_is_valid_rendertarget_color_format(img->pixel_format)) {
7558 mtl_desc.pixelFormat = _sg_mtl_rendertarget_color_format(img->pixel_format);
7559 }
7560 else {
7561 mtl_desc.pixelFormat = _sg_mtl_rendertarget_depth_format(img->pixel_format);
7562 }
7563 }
7564 else {
7565 mtl_desc.pixelFormat = _sg_mtl_texture_format(img->pixel_format);
7566 }
7567 if (MTLPixelFormatInvalid == mtl_desc.pixelFormat) {
7568 SOKOL_LOG("Unsupported texture pixel format!\n");
7569 return false;
7570 }
7571 mtl_desc.width = img->width;
7572 mtl_desc.height = img->height;
7573 if (SG_IMAGETYPE_3D == img->type) {
7574 mtl_desc.depth = img->depth;
7575 }
7576 else {
7577 mtl_desc.depth = 1;
7578 }
7579 mtl_desc.mipmapLevelCount = img->num_mipmaps;
7580 if (SG_IMAGETYPE_ARRAY == img->type) {
7581 mtl_desc.arrayLength = img->depth;
7582 }
7583 else {
7584 mtl_desc.arrayLength = 1;
7585 }
7586 mtl_desc.usage = MTLTextureUsageShaderRead;
7587 if (img->usage != SG_USAGE_IMMUTABLE) {
7588 mtl_desc.cpuCacheMode = MTLCPUCacheModeWriteCombined;
7589 }
7590 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
7591 /* macOS: use managed textures */
7592 mtl_desc.resourceOptions = MTLResourceStorageModeManaged;
7593 mtl_desc.storageMode = MTLStorageModeManaged;
7594 #else
7595 /* iOS: use CPU/GPU shared memory */
7596 mtl_desc.resourceOptions = MTLResourceStorageModeShared;
7597 mtl_desc.storageMode = MTLStorageModeShared;
7598 #endif
7599 return true;
7600 }
7601
7602 /* initialize MTLTextureDescritor with rendertarget attributes */
7603 _SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) {
7604 SOKOL_ASSERT(img->render_target);
7605 /* reset the cpuCacheMode to 'default' */
7606 mtl_desc.cpuCacheMode = MTLCPUCacheModeDefaultCache;
7607 /* render targets are only visible to the GPU */
7608 mtl_desc.resourceOptions = MTLResourceStorageModePrivate;
7609 mtl_desc.storageMode = MTLStorageModePrivate;
7610 /* non-MSAA render targets are shader-readable */
7611 mtl_desc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
7612 }
7613
7614 /* initialize MTLTextureDescritor with MSAA attributes */
7615 _SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt_msaa(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) {
7616 SOKOL_ASSERT(img->sample_count > 1);
7617 /* reset the cpuCacheMode to 'default' */
7618 mtl_desc.cpuCacheMode = MTLCPUCacheModeDefaultCache;
7619 /* render targets are only visible to the GPU */
7620 mtl_desc.resourceOptions = MTLResourceStorageModePrivate;
7621 mtl_desc.storageMode = MTLStorageModePrivate;
7622 /* MSAA render targets are not shader-readable (instead they are resolved) */
7623 mtl_desc.usage = MTLTextureUsageRenderTarget;
7624 mtl_desc.textureType = MTLTextureType2DMultisample;
7625 mtl_desc.depth = 1;
7626 mtl_desc.arrayLength = 1;
7627 mtl_desc.mipmapLevelCount = 1;
7628 mtl_desc.sampleCount = img->sample_count;
7629 }
7630
7631 _SOKOL_PRIVATE sg_resource_state _sg_create_image(_sg_image_t* img, const sg_image_desc* desc) {
7632 SOKOL_ASSERT(img && desc);
7633 img->type = desc->type;
7634 img->render_target = desc->render_target;
7635 img->width = desc->width;
7636 img->height = desc->height;
7637 img->depth = desc->depth;
7638 img->num_mipmaps = desc->num_mipmaps;
7639 img->usage = desc->usage;
7640 img->pixel_format = desc->pixel_format;
7641 img->sample_count = desc->sample_count;
7642 img->min_filter = desc->min_filter;
7643 img->mag_filter = desc->mag_filter;
7644 img->wrap_u = desc->wrap_u;
7645 img->wrap_v = desc->wrap_v;
7646 img->wrap_w = desc->wrap_w;
7647 img->max_anisotropy = desc->max_anisotropy;
7648 img->upd_frame_index = 0;
7649 img->num_slots = (img->usage == SG_USAGE_IMMUTABLE) ? 1 :SG_NUM_INFLIGHT_FRAMES;
7650 img->active_slot = 0;
7651 const bool injected = (0 != desc->mtl_textures[0]);
7652 const bool msaa = (img->sample_count > 1);
7653
7654 /* first initialize all Metal resource pool slots to 'empty' */
7655 for (int i = 0; i < SG_NUM_INFLIGHT_FRAMES; i++) {
7656 img->mtl_tex[i] = _sg_mtl_add_resource(nil);
7657 }
7658 img->mtl_sampler_state = _sg_mtl_add_resource(nil);
7659 img->mtl_depth_tex = _sg_mtl_add_resource(nil);
7660 img->mtl_msaa_tex = _sg_mtl_add_resource(nil);
7661
7662 /* initialize a Metal texture descriptor with common attributes */
7663 MTLTextureDescriptor* mtl_desc = [[MTLTextureDescriptor alloc] init];
7664 if (!_sg_mtl_init_texdesc_common(mtl_desc, img)) {
7665 return SG_RESOURCESTATE_FAILED;
7666 }
7667
7668 /* special case depth-stencil-buffer? */
7669 if (_sg_is_valid_rendertarget_depth_format(img->pixel_format)) {
7670 /* depth-stencil buffer texture must always be a render target */
7671 SOKOL_ASSERT(img->render_target);
7672 SOKOL_ASSERT(img->type == SG_IMAGETYPE_2D);
7673 SOKOL_ASSERT(img->num_mipmaps == 1);
7674 SOKOL_ASSERT(!injected);
7675 if (msaa) {
7676 _sg_mtl_init_texdesc_rt_msaa(mtl_desc, img);
7677 }
7678 else {
7679 _sg_mtl_init_texdesc_rt(mtl_desc, img);
7680 }
7681 id<MTLTexture> tex = [_sg_mtl_device newTextureWithDescriptor:mtl_desc];
7682 SOKOL_ASSERT(nil != tex);
7683 img->mtl_depth_tex = _sg_mtl_add_resource(tex);
7684 }
7685 else {
7686 /* create the color texture
7687 In case this is a render target without MSAA, add the relevant
7688 render-target descriptor attributes.
7689 In case this is a render target *with* MSAA, the color texture
7690 will serve as MSAA-resolve target (not as render target), and rendering
7691 will go into a separate render target texture of type
7692 MTLTextureType2DMultisample.
7693 */
7694 if (img->render_target && !msaa) {
7695 _sg_mtl_init_texdesc_rt(mtl_desc, img);
7696 }
7697 for (int slot = 0; slot < img->num_slots; slot++) {
7698 id<MTLTexture> tex;
7699 if (injected) {
7700 SOKOL_ASSERT(desc->mtl_textures[slot]);
7701 tex = (__bridge id<MTLTexture>) desc->mtl_textures[slot];
7702 }
7703 else {
7704 tex = [_sg_mtl_device newTextureWithDescriptor:mtl_desc];
7705 if ((img->usage == SG_USAGE_IMMUTABLE) && !img->render_target) {
7706 _sg_mtl_copy_image_content(img, tex, &desc->content);
7707 }
7708 }
7709 img->mtl_tex[slot] = _sg_mtl_add_resource(tex);
7710 }
7711
7712 /* if MSAA color render target, create an additional MSAA render-surface texture */
7713 if (img->render_target && msaa) {
7714 _sg_mtl_init_texdesc_rt_msaa(mtl_desc, img);
7715 id<MTLTexture> tex = [_sg_mtl_device newTextureWithDescriptor:mtl_desc];
7716 img->mtl_msaa_tex = _sg_mtl_add_resource(tex);
7717 }
7718
7719 /* create (possibly shared) sampler state */
7720 img->mtl_sampler_state = _sg_mtl_create_sampler(_sg_mtl_device, desc);
7721 }
7722 return SG_RESOURCESTATE_VALID;
7723 }
7724
7725 _SOKOL_PRIVATE void _sg_destroy_image(_sg_image_t* img) {
7726 SOKOL_ASSERT(img);
7727 /* it's valid to call release resource with a 'null resource' */
7728 for (int slot = 0; slot < img->num_slots; slot++) {
7729 _sg_mtl_release_resource(_sg.mtl.frame_index, img->mtl_tex[slot]);
7730 }
7731 _sg_mtl_release_resource(_sg.mtl.frame_index, img->mtl_depth_tex);
7732 _sg_mtl_release_resource(_sg.mtl.frame_index, img->mtl_msaa_tex);
7733 /* NOTE: sampler state objects are shared and not released until shutdown */
7734 }
7735
7736 _SOKOL_PRIVATE id<MTLLibrary> _sg_mtl_compile_library(const char* src) {
7737 NSError* err = NULL;
7738 id<MTLLibrary> lib = [_sg_mtl_device
7739 newLibraryWithSource:[NSString stringWithUTF8String:src]
7740 options:nil
7741 error:&err
7742 ];
7743 if (err) {
7744 SOKOL_LOG([err.localizedDescription UTF8String]);
7745 }
7746 return lib;
7747 }
7748
7749 _SOKOL_PRIVATE id<MTLLibrary> _sg_mtl_library_from_bytecode(const uint8_t* ptr, int num_bytes) {
7750 NSError* err = NULL;
7751 dispatch_data_t lib_data = dispatch_data_create(ptr, num_bytes, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
7752 id<MTLLibrary> lib = [_sg_mtl_device newLibraryWithData:lib_data error:&err];
7753 if (err) {
7754 SOKOL_LOG([err.localizedDescription UTF8String]);
7755 }
7756 return lib;
7757 }
7758
7759 _SOKOL_PRIVATE sg_resource_state _sg_create_shader(_sg_shader_t* shd, const sg_shader_desc* desc) {
7760 SOKOL_ASSERT(shd && desc);
7761
7762 /* uniform block sizes and image types */
7763 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) {
7764 const sg_shader_stage_desc* stage_desc = (stage_index == SG_SHADERSTAGE_VS) ? &desc->vs : &desc->fs;
7765 _sg_shader_stage_t* stage = &shd->stage[stage_index];
7766 SOKOL_ASSERT(stage->num_uniform_blocks == 0);
7767 for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) {
7768 const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index];
7769 if (0 == ub_desc->size) {
7770 break;
7771 }
7772 _sg_uniform_block_t* ub = &stage->uniform_blocks[ub_index];
7773 ub->size = ub_desc->size;
7774 stage->num_uniform_blocks++;
7775 }
7776 SOKOL_ASSERT(stage->num_images == 0);
7777 for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) {
7778 const sg_shader_image_desc* img_desc = &stage_desc->images[img_index];
7779 if (img_desc->type == _SG_IMAGETYPE_DEFAULT) {
7780 break;
7781 }
7782 stage->images[img_index].type = img_desc->type;
7783 stage->num_images++;
7784 }
7785 }
7786
7787 /* create metal libray objects and lookup entry functions */
7788 id<MTLLibrary> vs_lib;
7789 id<MTLLibrary> fs_lib;
7790 id<MTLFunction> vs_func;
7791 id<MTLFunction> fs_func;
7792 const char* vs_entry = desc->vs.entry;
7793 const char* fs_entry = desc->fs.entry;
7794 if (desc->vs.byte_code && desc->fs.byte_code) {
7795 /* separate byte code provided */
7796 vs_lib = _sg_mtl_library_from_bytecode(desc->vs.byte_code, desc->vs.byte_code_size);
7797 fs_lib = _sg_mtl_library_from_bytecode(desc->fs.byte_code, desc->fs.byte_code_size);
7798 if (nil == vs_lib || nil == fs_lib) {
7799 return SG_RESOURCESTATE_FAILED;
7800 }
7801 vs_func = [vs_lib newFunctionWithName:[NSString stringWithUTF8String:vs_entry]];
7802 fs_func = [fs_lib newFunctionWithName:[NSString stringWithUTF8String:fs_entry]];
7803 }
7804 else if (desc->vs.source && desc->fs.source) {
7805 /* separate sources provided */
7806 vs_lib = _sg_mtl_compile_library(desc->vs.source);
7807 fs_lib = _sg_mtl_compile_library(desc->fs.source);
7808 if (nil == vs_lib || nil == fs_lib) {
7809 return SG_RESOURCESTATE_FAILED;
7810 }
7811 vs_func = [vs_lib newFunctionWithName:[NSString stringWithUTF8String:vs_entry]];
7812 fs_func = [fs_lib newFunctionWithName:[NSString stringWithUTF8String:fs_entry]];
7813 }
7814 else {
7815 return SG_RESOURCESTATE_FAILED;
7816 }
7817 if (nil == vs_func) {
7818 SOKOL_LOG("vertex shader entry function not found\n");
7819 return SG_RESOURCESTATE_FAILED;
7820 }
7821 if (nil == fs_func) {
7822 SOKOL_LOG("fragment shader entry function not found\n");
7823 return SG_RESOURCESTATE_FAILED;
7824 }
7825 /* it is legal to call _sg_mtl_add_resource with a nil value, this will return a special 0xFFFFFFFF index */
7826 shd->stage[SG_SHADERSTAGE_VS].mtl_lib = _sg_mtl_add_resource(vs_lib);
7827 shd->stage[SG_SHADERSTAGE_FS].mtl_lib = _sg_mtl_add_resource(fs_lib);
7828 shd->stage[SG_SHADERSTAGE_VS].mtl_func = _sg_mtl_add_resource(vs_func);
7829 shd->stage[SG_SHADERSTAGE_FS].mtl_func = _sg_mtl_add_resource(fs_func);
7830 return SG_RESOURCESTATE_VALID;
7831 }
7832
7833 _SOKOL_PRIVATE void _sg_destroy_shader(_sg_shader_t* shd) {
7834 SOKOL_ASSERT(shd);
7835 /* it is valid to call _sg_mtl_release_resource with a 'null resource' */
7836 _sg_mtl_release_resource(_sg.mtl.frame_index, shd->stage[SG_SHADERSTAGE_VS].mtl_func);
7837 _sg_mtl_release_resource(_sg.mtl.frame_index, shd->stage[SG_SHADERSTAGE_VS].mtl_lib);
7838 _sg_mtl_release_resource(_sg.mtl.frame_index, shd->stage[SG_SHADERSTAGE_FS].mtl_func);
7839 _sg_mtl_release_resource(_sg.mtl.frame_index, shd->stage[SG_SHADERSTAGE_FS].mtl_lib);
7840 }
7841
7842 _SOKOL_PRIVATE sg_resource_state _sg_create_pipeline(_sg_pipeline_t* pip, _sg_shader_t* shd, const sg_pipeline_desc* desc) {
7843 SOKOL_ASSERT(pip && shd && desc);
7844 SOKOL_ASSERT(desc->shader.id == shd->slot.id);
7845
7846 pip->shader = shd;
7847 pip->shader_id = desc->shader;
7848 pip->color_attachment_count = desc->blend.color_attachment_count;
7849 pip->color_format = desc->blend.color_format;
7850 pip->depth_format = desc->blend.depth_format;
7851 pip->sample_count = desc->rasterizer.sample_count;
7852 pip->depth_bias = desc->rasterizer.depth_bias;
7853 pip->depth_bias_slope_scale = desc->rasterizer.depth_bias_slope_scale;
7854 pip->depth_bias_clamp = desc->rasterizer.depth_bias_clamp;
7855 sg_primitive_type prim_type = desc->primitive_type;
7856 pip->mtl_prim_type = _sg_mtl_primitive_type(prim_type);
7857 pip->index_type = desc->index_type;
7858 pip->mtl_index_size = _sg_mtl_index_size(pip->index_type);
7859 if (SG_INDEXTYPE_NONE != pip->index_type) {
7860 pip->mtl_index_type = _sg_mtl_index_type(pip->index_type);
7861 }
7862 pip->mtl_cull_mode = _sg_mtl_cull_mode(desc->rasterizer.cull_mode);
7863 pip->mtl_winding = _sg_mtl_winding(desc->rasterizer.face_winding);
7864 pip->mtl_stencil_ref = desc->depth_stencil.stencil_ref;
7865 for (int i = 0; i < 4; i++) {
7866 pip->blend_color[i] = desc->blend.blend_color[i];
7867 }
7868
7869 /* create vertex-descriptor */
7870 MTLVertexDescriptor* vtx_desc = [MTLVertexDescriptor vertexDescriptor];
7871 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) {
7872 const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index];
7873 if (a_desc->format == SG_VERTEXFORMAT_INVALID) {
7874 break;
7875 }
7876 SOKOL_ASSERT((a_desc->buffer_index >= 0) && (a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS));
7877 vtx_desc.attributes[attr_index].format = _sg_mtl_vertex_format(a_desc->format);
7878 vtx_desc.attributes[attr_index].offset = a_desc->offset;
7879 vtx_desc.attributes[attr_index].bufferIndex = a_desc->buffer_index + SG_MAX_SHADERSTAGE_UBS;
7880 pip->vertex_layout_valid[a_desc->buffer_index] = true;
7881 }
7882 for (int layout_index = 0; layout_index < SG_MAX_SHADERSTAGE_BUFFERS; layout_index++) {
7883 if (pip->vertex_layout_valid[layout_index]) {
7884 const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[layout_index];
7885 const int mtl_vb_slot = layout_index + SG_MAX_SHADERSTAGE_UBS;
7886 SOKOL_ASSERT(l_desc->stride > 0);
7887 vtx_desc.layouts[mtl_vb_slot].stride = l_desc->stride;
7888 vtx_desc.layouts[mtl_vb_slot].stepFunction = _sg_mtl_step_function(l_desc->step_func);
7889 vtx_desc.layouts[mtl_vb_slot].stepRate = l_desc->step_rate;
7890 }
7891 }
7892
7893 /* render-pipeline descriptor */
7894 MTLRenderPipelineDescriptor* rp_desc = [[MTLRenderPipelineDescriptor alloc] init];
7895 rp_desc.vertexDescriptor = vtx_desc;
7896 SOKOL_ASSERT(shd->stage[SG_SHADERSTAGE_VS].mtl_func != _SG_MTL_INVALID_SLOT_INDEX);
7897 rp_desc.vertexFunction = _sg_mtl_idpool[shd->stage[SG_SHADERSTAGE_VS].mtl_func];
7898 SOKOL_ASSERT(shd->stage[SG_SHADERSTAGE_FS].mtl_func != _SG_MTL_INVALID_SLOT_INDEX);
7899 rp_desc.fragmentFunction = _sg_mtl_idpool[shd->stage[SG_SHADERSTAGE_FS].mtl_func];
7900 rp_desc.sampleCount = desc->rasterizer.sample_count;
7901 rp_desc.alphaToCoverageEnabled = desc->rasterizer.alpha_to_coverage_enabled;
7902 rp_desc.alphaToOneEnabled = NO;
7903 rp_desc.rasterizationEnabled = YES;
7904 rp_desc.depthAttachmentPixelFormat = _sg_mtl_rendertarget_depth_format(desc->blend.depth_format);
7905 rp_desc.stencilAttachmentPixelFormat = _sg_mtl_rendertarget_stencil_format(desc->blend.depth_format);
7906 /* FIXME: this only works on macOS 10.13!
7907 for (int i = 0; i < (SG_MAX_SHADERSTAGE_UBS+SG_MAX_SHADERSTAGE_BUFFERS); i++) {
7908 rp_desc.vertexBuffers[i].mutability = MTLMutabilityImmutable;
7909 }
7910 for (int i = 0; i < SG_MAX_SHADERSTAGE_UBS; i++) {
7911 rp_desc.fragmentBuffers[i].mutability = MTLMutabilityImmutable;
7912 }
7913 */
7914 const int att_count = desc->blend.color_attachment_count;
7915 for (int i = 0; i < att_count; i++) {
7916 rp_desc.colorAttachments[i].pixelFormat = _sg_mtl_rendertarget_color_format(desc->blend.color_format);
7917 rp_desc.colorAttachments[i].writeMask = _sg_mtl_color_write_mask((sg_color_mask)desc->blend.color_write_mask);
7918 rp_desc.colorAttachments[i].blendingEnabled = desc->blend.enabled;
7919 rp_desc.colorAttachments[i].alphaBlendOperation = _sg_mtl_blend_op(desc->blend.op_alpha);
7920 rp_desc.colorAttachments[i].rgbBlendOperation = _sg_mtl_blend_op(desc->blend.op_rgb);
7921 rp_desc.colorAttachments[i].destinationAlphaBlendFactor = _sg_mtl_blend_factor(desc->blend.dst_factor_alpha);
7922 rp_desc.colorAttachments[i].destinationRGBBlendFactor = _sg_mtl_blend_factor(desc->blend.dst_factor_rgb);
7923 rp_desc.colorAttachments[i].sourceAlphaBlendFactor = _sg_mtl_blend_factor(desc->blend.src_factor_alpha);
7924 rp_desc.colorAttachments[i].sourceRGBBlendFactor = _sg_mtl_blend_factor(desc->blend.src_factor_rgb);
7925 }
7926 NSError* err = NULL;
7927 id<MTLRenderPipelineState> mtl_rps = [_sg_mtl_device newRenderPipelineStateWithDescriptor:rp_desc error:&err];
7928 if (nil == mtl_rps) {
7929 SOKOL_ASSERT(err);
7930 SOKOL_LOG([err.localizedDescription UTF8String]);
7931 return SG_RESOURCESTATE_FAILED;
7932 }
7933
7934 /* depth-stencil-state */
7935 MTLDepthStencilDescriptor* ds_desc = [[MTLDepthStencilDescriptor alloc] init];
7936 ds_desc.depthCompareFunction = _sg_mtl_compare_func(desc->depth_stencil.depth_compare_func);
7937 ds_desc.depthWriteEnabled = desc->depth_stencil.depth_write_enabled;
7938 if (desc->depth_stencil.stencil_enabled) {
7939 const sg_stencil_state* sb = &desc->depth_stencil.stencil_back;
7940 ds_desc.backFaceStencil = [[MTLStencilDescriptor alloc] init];
7941 ds_desc.backFaceStencil.stencilFailureOperation = _sg_mtl_stencil_op(sb->fail_op);
7942 ds_desc.backFaceStencil.depthFailureOperation = _sg_mtl_stencil_op(sb->depth_fail_op);
7943 ds_desc.backFaceStencil.depthStencilPassOperation = _sg_mtl_stencil_op(sb->pass_op);
7944 ds_desc.backFaceStencil.stencilCompareFunction = _sg_mtl_compare_func(sb->compare_func);
7945 ds_desc.backFaceStencil.readMask = desc->depth_stencil.stencil_read_mask;
7946 ds_desc.backFaceStencil.writeMask = desc->depth_stencil.stencil_write_mask;
7947 const sg_stencil_state* sf = &desc->depth_stencil.stencil_front;
7948 ds_desc.frontFaceStencil = [[MTLStencilDescriptor alloc] init];
7949 ds_desc.frontFaceStencil.stencilFailureOperation = _sg_mtl_stencil_op(sf->fail_op);
7950 ds_desc.frontFaceStencil.depthFailureOperation = _sg_mtl_stencil_op(sf->depth_fail_op);
7951 ds_desc.frontFaceStencil.depthStencilPassOperation = _sg_mtl_stencil_op(sf->pass_op);
7952 ds_desc.frontFaceStencil.stencilCompareFunction = _sg_mtl_compare_func(sf->compare_func);
7953 ds_desc.frontFaceStencil.readMask = desc->depth_stencil.stencil_read_mask;
7954 ds_desc.frontFaceStencil.writeMask = desc->depth_stencil.stencil_write_mask;
7955 }
7956 id<MTLDepthStencilState> mtl_dss = [_sg_mtl_device newDepthStencilStateWithDescriptor:ds_desc];
7957
7958 pip->mtl_rps = _sg_mtl_add_resource(mtl_rps);
7959 pip->mtl_dss = _sg_mtl_add_resource(mtl_dss);
7960 return SG_RESOURCESTATE_VALID;
7961 }
7962
7963 _SOKOL_PRIVATE void _sg_destroy_pipeline(_sg_pipeline_t* pip) {
7964 SOKOL_ASSERT(pip);
7965 /* it's valid to call release resource with a 'null resource' */
7966 _sg_mtl_release_resource(_sg.mtl.frame_index, pip->mtl_rps);
7967 _sg_mtl_release_resource(_sg.mtl.frame_index, pip->mtl_dss);
7968 }
7969
7970 _SOKOL_PRIVATE sg_resource_state _sg_create_pass(_sg_pass_t* pass, _sg_image_t** att_images, const sg_pass_desc* desc) {
7971 SOKOL_ASSERT(pass && desc);
7972 SOKOL_ASSERT(att_images && att_images[0]);
7973
7974 /* copy image pointers and desc attributes */
7975 const sg_attachment_desc* att_desc;
7976 _sg_attachment_t* att;
7977 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
7978 SOKOL_ASSERT(0 == pass->color_atts[i].image);
7979 att_desc = &desc->color_attachments[i];
7980 if (att_desc->image.id != SG_INVALID_ID) {
7981 pass->num_color_atts++;
7982 SOKOL_ASSERT(att_images[i] && (att_images[i]->slot.id == att_desc->image.id));
7983 SOKOL_ASSERT(_sg_is_valid_rendertarget_color_format(att_images[i]->pixel_format));
7984 att = &pass->color_atts[i];
7985 SOKOL_ASSERT((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
7986 att->image = att_images[i];
7987 att->image_id = att_desc->image;
7988 att->mip_level = att_desc->mip_level;
7989 att->slice = att_desc->slice;
7990 }
7991 }
7992 SOKOL_ASSERT(0 == pass->ds_att.image);
7993 att_desc = &desc->depth_stencil_attachment;
7994 const int ds_img_index = SG_MAX_COLOR_ATTACHMENTS;
7995 if (att_desc->image.id != SG_INVALID_ID) {
7996 SOKOL_ASSERT(att_images[ds_img_index] && (att_images[ds_img_index]->slot.id == att_desc->image.id));
7997 SOKOL_ASSERT(_sg_is_valid_rendertarget_depth_format(att_images[ds_img_index]->pixel_format));
7998 att = &pass->ds_att;
7999 SOKOL_ASSERT((att->image == 0) && (att->image_id.id == SG_INVALID_ID));
8000 att->image = att_images[ds_img_index];
8001 att->image_id = att_desc->image;
8002 att->mip_level = att_desc->mip_level;
8003 att->slice = att_desc->slice;
8004 }
8005 return SG_RESOURCESTATE_VALID;
8006 }
8007
8008 _SOKOL_PRIVATE void _sg_destroy_pass(_sg_pass_t* pass) {
8009 SOKOL_ASSERT(pass);
8010 _SOKOL_UNUSED(pass);
8011 }
8012
8013 _SOKOL_PRIVATE void _sg_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) {
8014 SOKOL_ASSERT(action);
8015 SOKOL_ASSERT(!_sg.mtl.in_pass);
8016 SOKOL_ASSERT(_sg_mtl_cmd_queue);
8017 SOKOL_ASSERT(!_sg_mtl_cmd_encoder);
8018 SOKOL_ASSERT(_sg.mtl.renderpass_descriptor_cb);
8019 _sg.mtl.in_pass = true;
8020 _sg.mtl.cur_width = w;
8021 _sg.mtl.cur_height = h;
8022 _sg_mtl_clear_state_cache();
8023
8024 /* if this is the first pass in the frame, create a command buffer */
8025 if (nil == _sg_mtl_cmd_buffer) {
8026 /* block until the oldest frame in flight has finished */
8027 dispatch_semaphore_wait(_sg_mtl_sem, DISPATCH_TIME_FOREVER);
8028 _sg_mtl_cmd_buffer = [_sg_mtl_cmd_queue commandBufferWithUnretainedReferences];
8029 }
8030
8031 /* if this is first pass in frame, get uniform buffer base pointer */
8032 if (0 == _sg.mtl.cur_ub_base_ptr) {
8033 _sg.mtl.cur_ub_base_ptr = (uint8_t*)[_sg_mtl_uniform_buffers[_sg.mtl.cur_frame_rotate_index] contents];
8034 }
8035
8036 /* initialize a render pass descriptor */
8037 MTLRenderPassDescriptor* pass_desc = nil;
8038 if (pass) {
8039 /* offscreen render pass */
8040 pass_desc = [MTLRenderPassDescriptor renderPassDescriptor];
8041 }
8042 else {
8043 /* default render pass, call user-provided callback to provide render pass descriptor */
8044 pass_desc = (__bridge MTLRenderPassDescriptor*) _sg.mtl.renderpass_descriptor_cb();
8045
8046 }
8047 if (pass_desc) {
8048 _sg.mtl.pass_valid = true;
8049 }
8050 else {
8051 /* default pass descriptor will not be valid if window is minimized,
8052 don't do any rendering in this case */
8053 _sg.mtl.pass_valid = false;
8054 return;
8055 }
8056 if (pass) {
8057 /* setup pass descriptor for offscreen rendering */
8058 SOKOL_ASSERT(pass->slot.state == SG_RESOURCESTATE_VALID);
8059 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
8060 const _sg_attachment_t* att = &pass->color_atts[i];
8061 if (0 == att->image) {
8062 break;
8063 }
8064 SOKOL_ASSERT(att->image->slot.state == SG_RESOURCESTATE_VALID);
8065 SOKOL_ASSERT(att->image->slot.id == att->image_id.id);
8066 const bool is_msaa = (att->image->sample_count > 1);
8067 pass_desc.colorAttachments[i].loadAction = _sg_mtl_load_action(action->colors[i].action);
8068 pass_desc.colorAttachments[i].storeAction = is_msaa ? MTLStoreActionMultisampleResolve : MTLStoreActionStore;
8069 const float* c = &(action->colors[i].val[0]);
8070 pass_desc.colorAttachments[i].clearColor = MTLClearColorMake(c[0], c[1], c[2], c[3]);
8071 if (is_msaa) {
8072 SOKOL_ASSERT(att->image->mtl_msaa_tex != _SG_MTL_INVALID_SLOT_INDEX);
8073 SOKOL_ASSERT(att->image->mtl_tex[att->image->active_slot] != _SG_MTL_INVALID_SLOT_INDEX);
8074 pass_desc.colorAttachments[i].texture = _sg_mtl_idpool[att->image->mtl_msaa_tex];
8075 pass_desc.colorAttachments[i].resolveTexture = _sg_mtl_idpool[att->image->mtl_tex[att->image->active_slot]];
8076 pass_desc.colorAttachments[i].resolveLevel = att->mip_level;
8077 switch (att->image->type) {
8078 case SG_IMAGETYPE_CUBE:
8079 case SG_IMAGETYPE_ARRAY:
8080 pass_desc.colorAttachments[i].resolveSlice = att->slice;
8081 break;
8082 case SG_IMAGETYPE_3D:
8083 pass_desc.colorAttachments[i].resolveDepthPlane = att->slice;
8084 break;
8085 default: break;
8086 }
8087 }
8088 else {
8089 SOKOL_ASSERT(att->image->mtl_tex[att->image->active_slot] != _SG_MTL_INVALID_SLOT_INDEX);
8090 pass_desc.colorAttachments[i].texture = _sg_mtl_idpool[att->image->mtl_tex[att->image->active_slot]];
8091 pass_desc.colorAttachments[i].level = att->mip_level;
8092 switch (att->image->type) {
8093 case SG_IMAGETYPE_CUBE:
8094 case SG_IMAGETYPE_ARRAY:
8095 pass_desc.colorAttachments[i].slice = att->slice;
8096 break;
8097 case SG_IMAGETYPE_3D:
8098 pass_desc.colorAttachments[i].depthPlane = att->slice;
8099 break;
8100 default: break;
8101 }
8102 }
8103 }
8104 if (0 != pass->ds_att.image) {
8105 const _sg_attachment_t* att = &pass->ds_att;
8106 SOKOL_ASSERT(att->image->slot.state == SG_RESOURCESTATE_VALID);
8107 SOKOL_ASSERT(att->image->slot.id == att->image_id.id);
8108 SOKOL_ASSERT(att->image->mtl_depth_tex != _SG_MTL_INVALID_SLOT_INDEX);
8109 pass_desc.depthAttachment.texture = _sg_mtl_idpool[att->image->mtl_depth_tex];
8110 pass_desc.depthAttachment.loadAction = _sg_mtl_load_action(action->depth.action);
8111 pass_desc.depthAttachment.clearDepth = action->depth.val;
8112 if (_sg_is_depth_stencil_format(att->image->pixel_format)) {
8113 pass_desc.stencilAttachment.texture = _sg_mtl_idpool[att->image->mtl_depth_tex];
8114 pass_desc.stencilAttachment.loadAction = _sg_mtl_load_action(action->stencil.action);
8115 pass_desc.stencilAttachment.clearStencil = action->stencil.val;
8116 }
8117 }
8118 }
8119 else {
8120 /* setup pass descriptor for default rendering */
8121 pass_desc.colorAttachments[0].loadAction = _sg_mtl_load_action(action->colors[0].action);
8122 const float* c = &(action->colors[0].val[0]);
8123 pass_desc.colorAttachments[0].clearColor = MTLClearColorMake(c[0], c[1], c[2], c[3]);
8124 pass_desc.depthAttachment.loadAction = _sg_mtl_load_action(action->depth.action);
8125 pass_desc.depthAttachment.clearDepth = action->depth.val;
8126 pass_desc.stencilAttachment.loadAction = _sg_mtl_load_action(action->stencil.action);
8127 pass_desc.stencilAttachment.clearStencil = action->stencil.val;
8128 }
8129
8130 /* create a render command encoder, this might return nil if window is minimized */
8131 _sg_mtl_cmd_encoder = [_sg_mtl_cmd_buffer renderCommandEncoderWithDescriptor:pass_desc];
8132 if (_sg_mtl_cmd_encoder == nil) {
8133 _sg.mtl.pass_valid = false;
8134 return;
8135 }
8136
8137 /* bind the global uniform buffer, this only happens once per pass */
8138 for (int slot = 0; slot < SG_MAX_SHADERSTAGE_UBS; slot++) {
8139 [_sg_mtl_cmd_encoder
8140 setVertexBuffer:_sg_mtl_uniform_buffers[_sg.mtl.cur_frame_rotate_index]
8141 offset:0
8142 atIndex:slot];
8143 [_sg_mtl_cmd_encoder
8144 setFragmentBuffer:_sg_mtl_uniform_buffers[_sg.mtl.cur_frame_rotate_index]
8145 offset:0
8146 atIndex:slot];
8147 }
8148 }
8149
8150 _SOKOL_PRIVATE void _sg_end_pass(void) {
8151 SOKOL_ASSERT(_sg.mtl.in_pass);
8152 _sg.mtl.in_pass = false;
8153 _sg.mtl.pass_valid = false;
8154 if (nil != _sg_mtl_cmd_encoder) {
8155 [_sg_mtl_cmd_encoder endEncoding];
8156 _sg_mtl_cmd_encoder = nil;
8157 }
8158 }
8159
8160 _SOKOL_PRIVATE void _sg_commit(void) {
8161 SOKOL_ASSERT(!_sg.mtl.in_pass);
8162 SOKOL_ASSERT(!_sg.mtl.pass_valid);
8163 SOKOL_ASSERT(_sg.mtl.drawable_cb);
8164 SOKOL_ASSERT(nil == _sg_mtl_cmd_encoder);
8165 SOKOL_ASSERT(nil != _sg_mtl_cmd_buffer);
8166
8167 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
8168 [_sg_mtl_uniform_buffers[_sg.mtl.cur_frame_rotate_index] didModifyRange:NSMakeRange(0, _sg.mtl.cur_ub_offset)];
8169 #endif
8170
8171 /* present, commit and signal semaphore when done */
8172 id<MTLDrawable> cur_drawable = (__bridge id<MTLDrawable>) _sg.mtl.drawable_cb();
8173 [_sg_mtl_cmd_buffer presentDrawable:cur_drawable];
8174 __block dispatch_semaphore_t sem = _sg_mtl_sem;
8175 [_sg_mtl_cmd_buffer addCompletedHandler:^(id<MTLCommandBuffer> cmd_buffer) {
8176 dispatch_semaphore_signal(sem);
8177 }];
8178 [_sg_mtl_cmd_buffer commit];
8179
8180 /* garbage-collect resources pending for release */
8181 _sg_mtl_garbage_collect(_sg.mtl.frame_index);
8182
8183 /* rotate uniform buffer slot */
8184 if (++_sg.mtl.cur_frame_rotate_index >= SG_NUM_INFLIGHT_FRAMES) {
8185 _sg.mtl.cur_frame_rotate_index = 0;
8186 }
8187 _sg.mtl.frame_index++;
8188 _sg.mtl.cur_ub_offset = 0;
8189 _sg.mtl.cur_ub_base_ptr = 0;
8190 _sg_mtl_cmd_buffer = nil;
8191 }
8192
8193 _SOKOL_PRIVATE void _sg_apply_viewport(int x, int y, int w, int h, bool origin_top_left) {
8194 SOKOL_ASSERT(_sg.mtl.in_pass);
8195 if (!_sg.mtl.pass_valid) {
8196 return;
8197 }
8198 SOKOL_ASSERT(_sg_mtl_cmd_encoder);
8199 MTLViewport vp;
8200 vp.originX = (double) x;
8201 vp.originY = (double) (origin_top_left ? y : (_sg.mtl.cur_height - (y + h)));
8202 vp.width = (double) w;
8203 vp.height = (double) h;
8204 vp.znear = 0.0;
8205 vp.zfar = 1.0;
8206 [_sg_mtl_cmd_encoder setViewport:vp];
8207 }
8208
8209 _SOKOL_PRIVATE void _sg_apply_scissor_rect(int x, int y, int w, int h, bool origin_top_left) {
8210 SOKOL_ASSERT(_sg.mtl.in_pass);
8211 if (!_sg.mtl.pass_valid) {
8212 return;
8213 }
8214 SOKOL_ASSERT(_sg_mtl_cmd_encoder);
8215 /* clip against framebuffer rect */
8216 x = _sg_min(_sg_max(0, x), _sg.mtl.cur_width-1);
8217 y = _sg_min(_sg_max(0, y), _sg.mtl.cur_height-1);
8218 if ((x + w) > _sg.mtl.cur_width) {
8219 w = _sg.mtl.cur_width - x;
8220 }
8221 if ((y + h) > _sg.mtl.cur_height) {
8222 h = _sg.mtl.cur_height - y;
8223 }
8224 w = _sg_max(w, 1);
8225 h = _sg_max(h, 1);
8226
8227 MTLScissorRect r;
8228 r.x = x;
8229 r.y = origin_top_left ? y : (_sg.mtl.cur_height - (y + h));
8230 r.width = w;
8231 r.height = h;
8232 [_sg_mtl_cmd_encoder setScissorRect:r];
8233 }
8234
8235 _SOKOL_PRIVATE void _sg_apply_pipeline(_sg_pipeline_t* pip) {
8236 SOKOL_ASSERT(pip);
8237 SOKOL_ASSERT(pip->shader);
8238 SOKOL_ASSERT(_sg.mtl.in_pass);
8239 if (!_sg.mtl.pass_valid) {
8240 return;
8241 }
8242 SOKOL_ASSERT(_sg_mtl_cmd_encoder);
8243
8244 if ((_sg.mtl.state_cache.cur_pipeline != pip) || (_sg.mtl.state_cache.cur_pipeline_id.id != pip->slot.id)) {
8245 _sg.mtl.state_cache.cur_pipeline = pip;
8246 _sg.mtl.state_cache.cur_pipeline_id.id = pip->slot.id;
8247 const float* c = pip->blend_color;
8248 [_sg_mtl_cmd_encoder setBlendColorRed:c[0] green:c[1] blue:c[2] alpha:c[3]];
8249 [_sg_mtl_cmd_encoder setCullMode:pip->mtl_cull_mode];
8250 [_sg_mtl_cmd_encoder setFrontFacingWinding:pip->mtl_winding];
8251 [_sg_mtl_cmd_encoder setStencilReferenceValue:pip->mtl_stencil_ref];
8252 [_sg_mtl_cmd_encoder setDepthBias:pip->depth_bias slopeScale:pip->depth_bias_slope_scale clamp:pip->depth_bias_clamp];
8253 SOKOL_ASSERT(pip->mtl_rps != _SG_MTL_INVALID_SLOT_INDEX);
8254 [_sg_mtl_cmd_encoder setRenderPipelineState:_sg_mtl_idpool[pip->mtl_rps]];
8255 SOKOL_ASSERT(pip->mtl_dss != _SG_MTL_INVALID_SLOT_INDEX);
8256 [_sg_mtl_cmd_encoder setDepthStencilState:_sg_mtl_idpool[pip->mtl_dss]];
8257 }
8258 }
8259
8260 _SOKOL_PRIVATE void _sg_apply_bindings(
8261 _sg_pipeline_t* pip,
8262 _sg_buffer_t** vbs, const int* vb_offsets, int num_vbs,
8263 _sg_buffer_t* ib, int ib_offset,
8264 _sg_image_t** vs_imgs, int num_vs_imgs,
8265 _sg_image_t** fs_imgs, int num_fs_imgs)
8266 {
8267 SOKOL_ASSERT(_sg.mtl.in_pass);
8268 if (!_sg.mtl.pass_valid) {
8269 return;
8270 }
8271 SOKOL_ASSERT(_sg_mtl_cmd_encoder);
8272
8273 /* store index buffer binding, this will be needed later in sg_draw() */
8274 _sg.mtl.state_cache.cur_indexbuffer = ib;
8275 _sg.mtl.state_cache.cur_indexbuffer_offset = ib_offset;
8276 if (ib) {
8277 SOKOL_ASSERT(pip->index_type != SG_INDEXTYPE_NONE);
8278 _sg.mtl.state_cache.cur_indexbuffer_id.id = ib->slot.id;
8279 }
8280 else {
8281 SOKOL_ASSERT(pip->index_type == SG_INDEXTYPE_NONE);
8282 _sg.mtl.state_cache.cur_indexbuffer_id.id = SG_INVALID_ID;
8283 }
8284
8285 /* apply vertex buffers */
8286 int slot;
8287 for (slot = 0; slot < num_vbs; slot++) {
8288 const _sg_buffer_t* vb = vbs[slot];
8289 if ((_sg.mtl.state_cache.cur_vertexbuffers[slot] != vb) ||
8290 (_sg.mtl.state_cache.cur_vertexbuffer_offsets[slot] != vb_offsets[slot]) ||
8291 (_sg.mtl.state_cache.cur_vertexbuffer_ids[slot].id != vb->slot.id))
8292 {
8293 _sg.mtl.state_cache.cur_vertexbuffers[slot] = vb;
8294 _sg.mtl.state_cache.cur_vertexbuffer_offsets[slot] = vb_offsets[slot];
8295 _sg.mtl.state_cache.cur_vertexbuffer_ids[slot].id = vb->slot.id;
8296 const NSUInteger mtl_slot = SG_MAX_SHADERSTAGE_UBS + slot;
8297 SOKOL_ASSERT(vb->mtl_buf[vb->active_slot] != _SG_MTL_INVALID_SLOT_INDEX);
8298 [_sg_mtl_cmd_encoder setVertexBuffer:_sg_mtl_idpool[vb->mtl_buf[vb->active_slot]]
8299 offset:vb_offsets[slot]
8300 atIndex:mtl_slot];
8301 }
8302 }
8303
8304 /* apply vertex shader images */
8305 for (slot = 0; slot < num_vs_imgs; slot++) {
8306 const _sg_image_t* img = vs_imgs[slot];
8307 if ((_sg.mtl.state_cache.cur_vs_images[slot] != img) || (_sg.mtl.state_cache.cur_vs_image_ids[slot].id != img->slot.id)) {
8308 _sg.mtl.state_cache.cur_vs_images[slot] = img;
8309 _sg.mtl.state_cache.cur_vs_image_ids[slot].id = img->slot.id;
8310 SOKOL_ASSERT(img->mtl_tex[img->active_slot] != _SG_MTL_INVALID_SLOT_INDEX);
8311 [_sg_mtl_cmd_encoder setVertexTexture:_sg_mtl_idpool[img->mtl_tex[img->active_slot]] atIndex:slot];
8312 SOKOL_ASSERT(img->mtl_sampler_state != _SG_MTL_INVALID_SLOT_INDEX);
8313 [_sg_mtl_cmd_encoder setVertexSamplerState:_sg_mtl_idpool[img->mtl_sampler_state] atIndex:slot];
8314 }
8315 }
8316
8317 /* apply fragment shader images */
8318 for (slot = 0; slot < num_fs_imgs; slot++) {
8319 const _sg_image_t* img = fs_imgs[slot];
8320 if ((_sg.mtl.state_cache.cur_fs_images[slot] != img) || (_sg.mtl.state_cache.cur_fs_image_ids[slot].id != img->slot.id)) {
8321 _sg.mtl.state_cache.cur_fs_images[slot] = img;
8322 _sg.mtl.state_cache.cur_fs_image_ids[slot].id = img->slot.id;
8323 SOKOL_ASSERT(img->mtl_tex[img->active_slot] != _SG_MTL_INVALID_SLOT_INDEX);
8324 [_sg_mtl_cmd_encoder setFragmentTexture:_sg_mtl_idpool[img->mtl_tex[img->active_slot]] atIndex:slot];
8325 SOKOL_ASSERT(img->mtl_sampler_state != _SG_MTL_INVALID_SLOT_INDEX);
8326 [_sg_mtl_cmd_encoder setFragmentSamplerState:_sg_mtl_idpool[img->mtl_sampler_state] atIndex:slot];
8327 }
8328 }
8329 }
8330
8331 #define _sg_mtl_roundup(val, round_to) (((val)+((round_to)-1))&~((round_to)-1))
8332
8333 _SOKOL_PRIVATE void _sg_apply_uniforms(sg_shader_stage stage_index, int ub_index, const void* data, int num_bytes) {
8334 SOKOL_ASSERT(_sg.mtl.in_pass);
8335 if (!_sg.mtl.pass_valid) {
8336 return;
8337 }
8338 SOKOL_ASSERT(_sg_mtl_cmd_encoder);
8339 SOKOL_ASSERT(data && (num_bytes > 0));
8340 SOKOL_ASSERT((stage_index >= 0) && ((int)stage_index < SG_NUM_SHADER_STAGES));
8341 SOKOL_ASSERT((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS));
8342 SOKOL_ASSERT((_sg.mtl.cur_ub_offset + num_bytes) <= _sg.mtl.ub_size);
8343 SOKOL_ASSERT((_sg.mtl.cur_ub_offset & (_SG_MTL_UB_ALIGN-1)) == 0);
8344 SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline && _sg.mtl.state_cache.cur_pipeline->shader);
8345 SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline->slot.id == _sg.mtl.state_cache.cur_pipeline_id.id);
8346 SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline->shader->slot.id == _sg.mtl.state_cache.cur_pipeline->shader_id.id);
8347 SOKOL_ASSERT(ub_index < _sg.mtl.state_cache.cur_pipeline->shader->stage[stage_index].num_uniform_blocks);
8348 SOKOL_ASSERT(num_bytes <= _sg.mtl.state_cache.cur_pipeline->shader->stage[stage_index].uniform_blocks[ub_index].size);
8349
8350 /* copy to global uniform buffer, record offset into cmd encoder, and advance offset */
8351 uint8_t* dst = &_sg.mtl.cur_ub_base_ptr[_sg.mtl.cur_ub_offset];
8352 memcpy(dst, data, num_bytes);
8353 if (stage_index == SG_SHADERSTAGE_VS) {
8354 [_sg_mtl_cmd_encoder setVertexBufferOffset:_sg.mtl.cur_ub_offset atIndex:ub_index];
8355 }
8356 else {
8357 [_sg_mtl_cmd_encoder setFragmentBufferOffset:_sg.mtl.cur_ub_offset atIndex:ub_index];
8358 }
8359 _sg.mtl.cur_ub_offset = _sg_mtl_roundup(_sg.mtl.cur_ub_offset + num_bytes, _SG_MTL_UB_ALIGN);
8360 }
8361
8362 _SOKOL_PRIVATE void _sg_draw(int base_element, int num_elements, int num_instances) {
8363 SOKOL_ASSERT(_sg.mtl.in_pass);
8364 if (!_sg.mtl.pass_valid) {
8365 return;
8366 }
8367 SOKOL_ASSERT(_sg_mtl_cmd_encoder);
8368 SOKOL_ASSERT(_sg.mtl.state_cache.cur_pipeline && (_sg.mtl.state_cache.cur_pipeline->slot.id == _sg.mtl.state_cache.cur_pipeline_id.id));
8369 if (SG_INDEXTYPE_NONE != _sg.mtl.state_cache.cur_pipeline->index_type) {
8370 /* indexed rendering */
8371 SOKOL_ASSERT(_sg.mtl.state_cache.cur_indexbuffer && (_sg.mtl.state_cache.cur_indexbuffer->slot.id == _sg.mtl.state_cache.cur_indexbuffer_id.id));
8372 const _sg_buffer_t* ib = _sg.mtl.state_cache.cur_indexbuffer;
8373 SOKOL_ASSERT(ib->mtl_buf[ib->active_slot] != _SG_MTL_INVALID_SLOT_INDEX);
8374 const NSUInteger index_buffer_offset = _sg.mtl.state_cache.cur_indexbuffer_offset +
8375 base_element * _sg.mtl.state_cache.cur_pipeline->mtl_index_size;
8376 [_sg_mtl_cmd_encoder drawIndexedPrimitives:_sg.mtl.state_cache.cur_pipeline->mtl_prim_type
8377 indexCount:num_elements
8378 indexType:_sg.mtl.state_cache.cur_pipeline->mtl_index_type
8379 indexBuffer:_sg_mtl_idpool[ib->mtl_buf[ib->active_slot]]
8380 indexBufferOffset:index_buffer_offset
8381 instanceCount:num_instances];
8382 }
8383 else {
8384 /* non-indexed rendering */
8385 [_sg_mtl_cmd_encoder drawPrimitives:_sg.mtl.state_cache.cur_pipeline->mtl_prim_type
8386 vertexStart:base_element
8387 vertexCount:num_elements
8388 instanceCount:num_instances];
8389 }
8390 }
8391
8392 _SOKOL_PRIVATE void _sg_update_buffer(_sg_buffer_t* buf, const void* data, int data_size) {
8393 SOKOL_ASSERT(buf && data && (data_size > 0));
8394 if (++buf->active_slot >= buf->num_slots) {
8395 buf->active_slot = 0;
8396 }
8397 __unsafe_unretained id<MTLBuffer> mtl_buf = _sg_mtl_idpool[buf->mtl_buf[buf->active_slot]];
8398 void* dst_ptr = [mtl_buf contents];
8399 memcpy(dst_ptr, data, data_size);
8400 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
8401 [mtl_buf didModifyRange:NSMakeRange(0, data_size)];
8402 #endif
8403 }
8404
8405 _SOKOL_PRIVATE void _sg_append_buffer(_sg_buffer_t* buf, const void* data, int data_size, bool new_frame) {
8406 SOKOL_ASSERT(buf && data && (data_size > 0));
8407 if (new_frame) {
8408 if (++buf->active_slot >= buf->num_slots) {
8409 buf->active_slot = 0;
8410 }
8411 }
8412 __unsafe_unretained id<MTLBuffer> mtl_buf = _sg_mtl_idpool[buf->mtl_buf[buf->active_slot]];
8413 uint8_t* dst_ptr = (uint8_t*) [mtl_buf contents];
8414 dst_ptr += buf->append_pos;
8415 memcpy(dst_ptr, data, data_size);
8416 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
8417 [mtl_buf didModifyRange:NSMakeRange(buf->append_pos, data_size)];
8418 #endif
8419 }
8420
8421 _SOKOL_PRIVATE void _sg_update_image(_sg_image_t* img, const sg_image_content* data) {
8422 SOKOL_ASSERT(img && data);
8423 if (++img->active_slot >= img->num_slots) {
8424 img->active_slot = 0;
8425 }
8426 __unsafe_unretained id<MTLTexture> mtl_tex = _sg_mtl_idpool[img->mtl_tex[img->active_slot]];
8427 _sg_mtl_copy_image_content(img, mtl_tex, data);
8428 }
8429
8430 #endif
8431
8432 /*== RESOURCE POOLS ==========================================================*/
8433
8434 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(_sg_pool_tcxx . . $ _sg_pool_t#* pool, int num) {
8435 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool && (num >= 1));
8436 /* slot 0 is reserved for the 'invalid id', so bump the pool size by 1 */
8437 pool->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size. = num + 1;
8438 pool->queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top. = 0;
8439 /* generation counters indexable by pool slot index, slot 0 is reserved */
8440 size_t gen_ctrs_size = sizeof(uint32_tcxx . . $ uint32_t#) * pool->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8441 pool->gen_ctrscxx . . $ $anonymous_type_ded6a5455d648ef8_23#gen_ctrs. = (uint32_tcxx . . $ uint32_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(gen_ctrs_size);
8442 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->gen_ctrs);
8443 memsetcxx . . $ memset(d1de1e4fb215f1c6).(pool->gen_ctrscxx . . $ $anonymous_type_ded6a5455d648ef8_23#gen_ctrs., 0, gen_ctrs_size);
8444 /* it's not a bug to only reserve 'num' here */
8445 pool->free_queuecxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue. = (int*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(sizeof(int)*num);
8446 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->free_queue);
8447 /* never allocate the zero-th pool item since the invalid id is 0 */
8448 for (int i = pool->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.-1; i >= 1; i--) {
8449 pool->free_queuecxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue.[pool->queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top.++] = i;
8450 }
8451 }
8452
8453 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(_sg_pool_tcxx . . $ _sg_pool_t#* pool) {
8454 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool);
8455 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->free_queue);
8456 SOKOL_FREEcxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue.(pool->free_queue);
8457 pool->free_queuecxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue. = 0;
8458 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->gen_ctrs);
8459 SOKOL_FREEcxx . . $ $anonymous_type_ded6a5455d648ef8_23#gen_ctrs.(pool->gen_ctrs);
8460 pool->gen_ctrscxx . . $ $anonymous_type_ded6a5455d648ef8_23#gen_ctrs. = 0;
8461 pool->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size. = 0;
8462 pool->queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top. = 0;
8463 }
8464
8465 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(_sg_pool_tcxx . . $ _sg_pool_t#* pool) {
8466 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool);
8467 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->free_queue);
8468 if (pool->queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top. > 0) {
8469 int slot_index = pool->free_queuecxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue.[--pool->queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top.];
8470 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > 0) && (slot_index < pool->size));
8471 return slot_index;
8472 }
8473 else {
8474 /* pool exhausted */
8475 return _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!;
8476 }
8477 }
8478
8479 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(_sg_pool_tcxx . . $ _sg_pool_t#* pool, int slot_index) {
8480 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < pool->size));
8481 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool);
8482 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->free_queue);
8483 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->queue_top < pool->size);
8484 #ifdef SOKOL_DEBUG
8485 /* debug check against double-free */
8486 for (int i = 0; i < pool->queue_top; i++) {
8487 SOKOL_ASSERT(pool->free_queue[i] != slot_index);
8488 }
8489 #endif
8490 pool->free_queuecxx . . $ $anonymous_type_ded6a5455d648ef8_23#free_queue.[pool->queue_topcxx . . $ $anonymous_type_ded6a5455d648ef8_23#queue_top.++] = slot_index;
8491 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool->queue_top <= (pool->size-1));
8492 }
8493
8494 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_buffercxx . . $ _sg_reset_buffer(62c890c9336ae806).(_sg_buffer_tcxx . . $ _sg_buffer_t#* buf) {
8495 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf);
8496 memsetcxx . . $ memset(d1de1e4fb215f1c6).(buf, 0, sizeof(_sg_buffer_tcxx . . $ _sg_buffer_t#));
8497 }
8498
8499 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_imagecxx . . $ _sg_reset_image(a39f7d26f6734857).(_sg_image_tcxx . . $ _sg_image_t#* img) {
8500 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img);
8501 memsetcxx . . $ memset(d1de1e4fb215f1c6).(img, 0, sizeof(_sg_image_tcxx . . $ _sg_image_t#));
8502 }
8503
8504 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_shadercxx . . $ _sg_reset_shader(c330990de8bee88b).(_sg_shader_tcxx . . $ _sg_shader_t#* shd) {
8505 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd);
8506 memsetcxx . . $ memset(d1de1e4fb215f1c6).(shd, 0, sizeof(_sg_shader_tcxx . . $ _sg_shader_t#));
8507 }
8508
8509 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_pipelinecxx . . $ _sg_reset_pipeline(ead8d739235dacd3).(_sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip) {
8510 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip);
8511 memsetcxx . . $ memset(d1de1e4fb215f1c6).(pip, 0, sizeof(_sg_pipeline_tcxx . . $ _sg_pipeline_t#));
8512 }
8513
8514 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_passcxx . . $ _sg_reset_pass(eae344a76fb8d519).(_sg_pass_tcxx . . $ _sg_pass_t#* pass) {
8515 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass);
8516 memsetcxx . . $ memset(d1de1e4fb215f1c6).(pass, 0, sizeof(_sg_pass_tcxx . . $ _sg_pass_t#));
8517 }
8518
8519 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_reset_contextcxx . . $ _sg_reset_context(5fcb436f3d2e1e3f).(_sg_context_tcxx . . $ _sg_context_t#* ctx) {
8520 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ctx);
8521 memsetcxx . . $ memset(d1de1e4fb215f1c6).(ctx, 0, sizeof(_sg_context_tcxx . . $ _sg_context_t#));
8522 }
8523
8524 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_setup_poolscxx . . $ _sg_setup_pools(68f03b631ad87475).(_sg_pools_tcxx . . $ _sg_pools_t#* p, const sg_desccxx . . $ sg_desc#* desc) {
8525 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p);
8526 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
8527 /* note: the pools here will have an additional item, since slot 0 is reserved */
8528 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->buffer_pool_size > 0) && (desc->buffer_pool_size < _SG_MAX_POOL_SIZE));
8529 _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(&p->buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool., desc->buffer_pool_sizecxx . . $ sg_desc#buffer_pool_size.);
8530 size_t buffer_pool_byte_size = sizeof(_sg_buffer_tcxx . . $ _sg_buffer_t#) * p->buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8531 p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers. = (_sg_buffer_tcxx . . $ _sg_buffer_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(buffer_pool_byte_size);
8532 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p->buffers);
8533 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers., 0, buffer_pool_byte_size);
8534
8535 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->image_pool_size > 0) && (desc->image_pool_size < _SG_MAX_POOL_SIZE));
8536 _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(&p->image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool., desc->image_pool_sizecxx . . $ sg_desc#image_pool_size.);
8537 size_t image_pool_byte_size = sizeof(_sg_image_tcxx . . $ _sg_image_t#) * p->image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8538 p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images. = (_sg_image_tcxx . . $ _sg_image_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(image_pool_byte_size);
8539 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p->images);
8540 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images., 0, image_pool_byte_size);
8541
8542 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->shader_pool_size > 0) && (desc->shader_pool_size < _SG_MAX_POOL_SIZE));
8543 _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(&p->shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool., desc->shader_pool_sizecxx . . $ sg_desc#shader_pool_size.);
8544 size_t shader_pool_byte_size = sizeof(_sg_shader_tcxx . . $ _sg_shader_t#) * p->shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8545 p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders. = (_sg_shader_tcxx . . $ _sg_shader_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(shader_pool_byte_size);
8546 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p->shaders);
8547 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders., 0, shader_pool_byte_size);
8548
8549 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->pipeline_pool_size > 0) && (desc->pipeline_pool_size < _SG_MAX_POOL_SIZE));
8550 _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(&p->pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool., desc->pipeline_pool_sizecxx . . $ sg_desc#pipeline_pool_size.);
8551 size_t pipeline_pool_byte_size = sizeof(_sg_pipeline_tcxx . . $ _sg_pipeline_t#) * p->pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8552 p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines. = (_sg_pipeline_tcxx . . $ _sg_pipeline_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(pipeline_pool_byte_size);
8553 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p->pipelines);
8554 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines., 0, pipeline_pool_byte_size);
8555
8556 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->pass_pool_size > 0) && (desc->pass_pool_size < _SG_MAX_POOL_SIZE));
8557 _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(&p->pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool., desc->pass_pool_sizecxx . . $ sg_desc#pass_pool_size.);
8558 size_t pass_pool_byte_size = sizeof(_sg_pass_tcxx . . $ _sg_pass_t#) * p->pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8559 p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes. = (_sg_pass_tcxx . . $ _sg_pass_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(pass_pool_byte_size);
8560 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p->passes);
8561 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes., 0, pass_pool_byte_size);
8562
8563 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->context_pool_size > 0) && (desc->context_pool_size < _SG_MAX_POOL_SIZE));
8564 _sg_init_poolcxx . . $ _sg_init_pool(5d8b2847f7c53527).(&p->context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool., desc->context_pool_sizecxx . . $ sg_desc#context_pool_size.);
8565 size_t context_pool_byte_size = sizeof(_sg_context_tcxx . . $ _sg_context_t#) * p->context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.;
8566 p->contextscxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts. = (_sg_context_tcxx . . $ _sg_context_t#*) SOKOL_MALLOCcxx . . $ `demo/sokol/sokol_gfx.h:1971:13`!(context_pool_byte_size);
8567 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p->contexts);
8568 memsetcxx . . $ memset(d1de1e4fb215f1c6).(p->contextscxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts., 0, context_pool_byte_size);
8569 }
8570
8571 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_discard_poolscxx . . $ _sg_discard_pools(464348b3c1da642).(_sg_pools_tcxx . . $ _sg_pools_t#* p) {
8572 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p);
8573 SOKOL_FREEcxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts.(p->contexts); p->contextscxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts. = 0;
8574 SOKOL_FREEcxx . . $ `demo/sokol/sokol_gfx.h:1972:13`!(p->passes); p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes. = 0;
8575 SOKOL_FREEcxx . . $ `demo/sokol/sokol_gfx.h:1972:13`!(p->pipelines); p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines. = 0;
8576 SOKOL_FREEcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.(p->shaders); p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders. = 0;
8577 SOKOL_FREEcxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.(p->images); p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images. = 0;
8578 SOKOL_FREEcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.(p->buffers); p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers. = 0;
8579 _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(&p->context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool.);
8580 _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(&p->pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool.);
8581 _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(&p->pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool.);
8582 _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(&p->shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool.);
8583 _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(&p->image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool.);
8584 _sg_discard_poolcxx . . $ _sg_discard_pool(a225fd6ab0b7ce43).(&p->buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool.);
8585 }
8586
8587 /* allocate the slot at slot_index:
8588 - bump the slot's generation counter
8589 - create a resource id from the generation counter and slot index
8590 - set the slot's id to this id
8591 - set the slot's state to ALLOC
8592 - return the resource id
8593 */
8594 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! uint32_tcxx . . $ uint32_t# _sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(_sg_pool_tcxx . . $ _sg_pool_t#* pool, _sg_slot_tcxx . . $ _sg_slot_t#* slot, int slot_index) {
8595 /* FIXME: add handling for an overflowing generation counter,
8596 for now, just overflow (another option is to disable
8597 the slot)
8598 */
8599 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pool && pool->gen_ctrs);
8600 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < pool->size));
8601 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot->state == SG_RESOURCESTATE_INITIAL) && (slot->id == SG_INVALID_ID));
8602 uint32_tcxx . . $ uint32_t# ctr = ++pool->gen_ctrscxx . . $ $anonymous_type_ded6a5455d648ef8_23#gen_ctrs.[slot_index];
8603 slot->idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. = (ctr<<_SG_SLOT_SHIFTcxx . . $ _SG_SLOT_SHIFT.)|(slot_index & _SG_SLOT_MASKcxx . . $ _SG_SLOT_MASK.);
8604 slot->statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_ALLOCcxx . . $ SG_RESOURCESTATE_ALLOC.;
8605 return slot->idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
8606 }
8607
8608 /* extract slot index from id */
8609 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! int _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(uint32_tcxx . . $ uint32_t# id) {
8610 int slot_index = (int) (id & _SG_SLOT_MASKcxx . . $ _SG_SLOT_MASK.);
8611 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index);
8612 return slot_index;
8613 }
8614
8615 /* returns pointer to resource by id without matching id check */
8616 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_buffer_tcxx . . $ _sg_buffer_t#* _sg_buffer_atcxx . . $ _sg_buffer_at(1bf69e7878de46de).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# buf_id) {
8617 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p && (SG_INVALID_ID != buf_id));
8618 int slot_index = _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(buf_id);
8619 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < p->buffer_pool.size));
8620 return &p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.[slot_index];
8621 }
8622
8623 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_image_tcxx . . $ _sg_image_t#* _sg_image_atcxx . . $ _sg_image_at(16f751d922939fe6).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# img_id) {
8624 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p && (SG_INVALID_ID != img_id));
8625 int slot_index = _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(img_id);
8626 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < p->image_pool.size));
8627 return &p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.[slot_index];
8628 }
8629
8630 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_shader_tcxx . . $ _sg_shader_t#* _sg_shader_atcxx . . $ _sg_shader_at(dc4288be9b8c0f4).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# shd_id) {
8631 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p && (SG_INVALID_ID != shd_id));
8632 int slot_index = _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(shd_id);
8633 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < p->shader_pool.size));
8634 return &p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.[slot_index];
8635 }
8636
8637 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_pipeline_tcxx . . $ _sg_pipeline_t#* _sg_pipeline_atcxx . . $ _sg_pipeline_at(7e13595ced88d4d3).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# pip_id) {
8638 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p && (SG_INVALID_ID != pip_id));
8639 int slot_index = _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(pip_id);
8640 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < p->pipeline_pool.size));
8641 return &p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines.[slot_index];
8642 }
8643
8644 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_pass_tcxx . . $ _sg_pass_t#* _sg_pass_atcxx . . $ _sg_pass_at(dc7c3142592aeadd).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# pass_id) {
8645 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p && (SG_INVALID_ID != pass_id));
8646 int slot_index = _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(pass_id);
8647 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < p->pass_pool.size));
8648 return &p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes.[slot_index];
8649 }
8650
8651 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_context_tcxx . . $ _sg_context_t#* _sg_context_atcxx . . $ _sg_context_at(f2667a16adbd72a2).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# context_id) {
8652 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p && (SG_INVALID_ID != context_id));
8653 int slot_index = _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(context_id);
8654 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((slot_index > _SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`!) && (slot_index < p->context_pool.size));
8655 return &p->contextscxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts.[slot_index];
8656 }
8657
8658 /* returns pointer to resource with matching id check, may return 0 */
8659 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_buffer_tcxx . . $ _sg_buffer_t#* _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# buf_id) {
8660 if (SG_INVALID_IDcxx . . $ SG_INVALID_ID. != buf_id) {
8661 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_buffer_atcxx . . $ _sg_buffer_at(1bf69e7878de46de).(p, buf_id);
8662 if (buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. == buf_id) {
8663 return buf;
8664 }
8665 }
8666 return 0;
8667 }
8668
8669 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_image_tcxx . . $ _sg_image_t#* _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# img_id) {
8670 if (SG_INVALID_IDcxx . . $ SG_INVALID_ID. != img_id) {
8671 _sg_image_tcxx . . $ _sg_image_t#* img = _sg_image_atcxx . . $ _sg_image_at(16f751d922939fe6).(p, img_id);
8672 if (img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. == img_id) {
8673 return img;
8674 }
8675 }
8676 return 0;
8677 }
8678
8679 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_shader_tcxx . . $ _sg_shader_t#* _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# shd_id) {
8680 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p);
8681 if (SG_INVALID_IDcxx . . $ SG_INVALID_ID. != shd_id) {
8682 _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_shader_atcxx . . $ _sg_shader_at(dc4288be9b8c0f4).(p, shd_id);
8683 if (shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. == shd_id) {
8684 return shd;
8685 }
8686 }
8687 return 0;
8688 }
8689
8690 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_pipeline_tcxx . . $ _sg_pipeline_t#* _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# pip_id) {
8691 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p);
8692 if (SG_INVALID_IDcxx . . $ SG_INVALID_ID. != pip_id) {
8693 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_pipeline_atcxx . . $ _sg_pipeline_at(7e13595ced88d4d3).(p, pip_id);
8694 if (pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. == pip_id) {
8695 return pip;
8696 }
8697 }
8698 return 0;
8699 }
8700
8701 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_pass_tcxx . . $ _sg_pass_t#* _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# pass_id) {
8702 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p);
8703 if (SG_INVALID_IDcxx . . $ SG_INVALID_ID. != pass_id) {
8704 _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_pass_atcxx . . $ _sg_pass_at(dc7c3142592aeadd).(p, pass_id);
8705 if (pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. == pass_id) {
8706 return pass;
8707 }
8708 }
8709 return 0;
8710 }
8711
8712 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! _sg_context_tcxx . . $ _sg_context_t#* _sg_lookup_contextcxx . . $ _sg_lookup_context(f2667a16adbd72a2).(const _sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# ctx_id) {
8713 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(p);
8714 if (SG_INVALID_IDcxx . . $ SG_INVALID_ID. != ctx_id) {
8715 _sg_context_tcxx . . $ _sg_context_t#* ctx = _sg_context_atcxx . . $ _sg_context_at(f2667a16adbd72a2).(p, ctx_id);
8716 if (ctx->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_18#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id. == ctx_id) {
8717 return ctx;
8718 }
8719 }
8720 return 0;
8721 }
8722
8723 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_destroy_all_resourcescxx . . $ _sg_destroy_all_resources(8765eb4fc17703da).(_sg_pools_tcxx . . $ _sg_pools_t#* p, uint32_tcxx . . $ uint32_t# ctx_id) {
8724 /* this is a bit dumb since it loops over all pool slots to
8725 find the occupied slots, on the other hand it is only ever
8726 executed at shutdown
8727 NOTE: ONLY EXECUTE THIS AT SHUTDOWN
8728 ...because the free queues will not be reset
8729 and the resource slots not be cleared!
8730 */
8731 for (int i = 1; i < p->buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.; i++) {
8732 if (p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == ctx_id) {
8733 sg_resource_statecxx . . $ sg_resource_state# state = p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
8734 if ((state == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) || (state == SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.)) {
8735 _sg_destroy_buffercxx . . $ _sg_destroy_buffer(62c890c9336ae806).(&p->bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.[i]);
8736 }
8737 }
8738 }
8739 for (int i = 1; i < p->image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.; i++) {
8740 if (p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == ctx_id) {
8741 sg_resource_statecxx . . $ sg_resource_state# state = p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
8742 if ((state == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) || (state == SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.)) {
8743 _sg_destroy_imagecxx . . $ _sg_destroy_image(a39f7d26f6734857).(&p->imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.[i]);
8744 }
8745 }
8746 }
8747 for (int i = 1; i < p->shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.; i++) {
8748 if (p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == ctx_id) {
8749 sg_resource_statecxx . . $ sg_resource_state# state = p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
8750 if ((state == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) || (state == SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.)) {
8751 _sg_destroy_shadercxx . . $ _sg_destroy_shader(c330990de8bee88b).(&p->shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.[i]);
8752 }
8753 }
8754 }
8755 for (int i = 1; i < p->pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.; i++) {
8756 if (p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == ctx_id) {
8757 sg_resource_statecxx . . $ sg_resource_state# state = p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
8758 if ((state == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) || (state == SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.)) {
8759 _sg_destroy_pipelinecxx . . $ _sg_destroy_pipeline(ead8d739235dacd3).(&p->pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines.[i]);
8760 }
8761 }
8762 }
8763 for (int i = 1; i < p->pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool..sizecxx . . $ $anonymous_type_ded6a5455d648ef8_23#size.; i++) {
8764 if (p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == ctx_id) {
8765 sg_resource_statecxx . . $ sg_resource_state# state = p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes.[i].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
8766 if ((state == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) || (state == SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.)) {
8767 _sg_destroy_passcxx . . $ _sg_destroy_pass(eae344a76fb8d519).(&p->passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes.[i]);
8768 }
8769 }
8770 }
8771 }
8772
8773 /*== VALIDATION LAYER ========================================================*/
8774 #if defined(SOKOL_DEBUG)
8775 /* return a human readable string for an _sg_validate_error */
8776 _SOKOL_PRIVATE const char* _sg_validate_string(_sg_validate_error_t err) {
8777 switch (err) {
8778 /* buffer creation validation errors */
8779 case _SG_VALIDATE_BUFFERDESC_CANARY: return "sg_buffer_desc not initialized";
8780 case _SG_VALIDATE_BUFFERDESC_SIZE: return "sg_buffer_desc.size cannot be 0";
8781 case _SG_VALIDATE_BUFFERDESC_CONTENT: return "immutable buffers must be initialized with content (sg_buffer_desc.content)";
8782 case _SG_VALIDATE_BUFFERDESC_NO_CONTENT: return "dynamic/stream usage buffers cannot be initialized with content";
8783
8784 /* image creation validation errros */
8785 case _SG_VALIDATE_IMAGEDESC_CANARY: return "sg_image_desc not initialized";
8786 case _SG_VALIDATE_IMAGEDESC_WIDTH: return "sg_image_desc.width must be > 0";
8787 case _SG_VALIDATE_IMAGEDESC_HEIGHT: return "sg_image_desc.height must be > 0";
8788 case _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMAT: return "invalid pixel format for render-target image";
8789 case _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMAT: return "invalid pixel format for non-render-target image";
8790 case _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RT: return "non-render-target images cannot be multisampled";
8791 case _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT: return "MSAA render targets not supported (SG_FEATURE_MSAA_RENDER_TARGETS)";
8792 case _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLE: return "render target images must be SG_USAGE_IMMUTABLE";
8793 case _SG_VALIDATE_IMAGEDESC_RT_NO_CONTENT: return "render target images cannot be initialized with content";
8794 case _SG_VALIDATE_IMAGEDESC_CONTENT: return "missing or invalid content for immutable image";
8795 case _SG_VALIDATE_IMAGEDESC_NO_CONTENT: return "dynamic/stream usage images cannot be initialized with content";
8796
8797 /* shader creation */
8798 case _SG_VALIDATE_SHADERDESC_CANARY: return "sg_shader_desc not initialized";
8799 case _SG_VALIDATE_SHADERDESC_SOURCE: return "shader source code required";
8800 case _SG_VALIDATE_SHADERDESC_BYTECODE: return "shader byte code required";
8801 case _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE: return "shader source or byte code required";
8802 case _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE: return "shader byte code length (in bytes) required";
8803 case _SG_VALIDATE_SHADERDESC_NO_CONT_UBS: return "shader uniform blocks must occupy continuous slots";
8804 case _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS: return "uniform block members must occupy continuous slots";
8805 case _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERS: return "GL backend requires uniform block member declarations";
8806 case _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAME: return "uniform block member name missing";
8807 case _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCH: return "size of uniform block members doesn't match uniform block size";
8808 case _SG_VALIDATE_SHADERDESC_NO_CONT_IMGS: return "shader images must occupy continuous slots";
8809 case _SG_VALIDATE_SHADERDESC_IMG_NAME: return "GL backend requires uniform block member names";
8810 case _SG_VALIDATE_SHADERDESC_ATTR_NAMES: return "GLES2 backend requires vertex attribute names";
8811 case _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICS: return "D3D11 backend requires vertex attribute semantics";
8812 case _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG: return "vertex attribute name/semantic string too long (max len 16)";
8813
8814 /* pipeline creation */
8815 case _SG_VALIDATE_PIPELINEDESC_CANARY: return "sg_pipeline_desc not initialized";
8816 case _SG_VALIDATE_PIPELINEDESC_SHADER: return "sg_pipeline_desc.shader missing or invalid";
8817 case _SG_VALIDATE_PIPELINEDESC_NO_ATTRS: return "sg_pipeline_desc.layout.attrs is empty or not continuous";
8818 case _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4: return "sg_pipeline_desc.layout.buffers[].stride must be multiple of 4";
8819 case _SG_VALIDATE_PIPELINEDESC_ATTR_NAME: return "GLES2/WebGL missing vertex attribute name in shader";
8820 case _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICS: return "D3D11 missing vertex attribute semantics in shader";
8821
8822 /* pass creation */
8823 case _SG_VALIDATE_PASSDESC_CANARY: return "sg_pass_desc not initialized";
8824 case _SG_VALIDATE_PASSDESC_NO_COLOR_ATTS: return "sg_pass_desc.color_attachments[0] must be valid";
8825 case _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTS: return "color attachments must occupy continuous slots";
8826 case _SG_VALIDATE_PASSDESC_IMAGE: return "pass attachment image is not valid";
8827 case _SG_VALIDATE_PASSDESC_MIPLEVEL: return "pass attachment mip level is bigger than image has mipmaps";
8828 case _SG_VALIDATE_PASSDESC_FACE: return "pass attachment image is cubemap, but face index is too big";
8829 case _SG_VALIDATE_PASSDESC_LAYER: return "pass attachment image is array texture, but layer index is too big";
8830 case _SG_VALIDATE_PASSDESC_SLICE: return "pass attachment image is 3d texture, but slice value is too big";
8831 case _SG_VALIDATE_PASSDESC_IMAGE_NO_RT: return "pass attachment image must be render targets";
8832 case _SG_VALIDATE_PASSDESC_COLOR_PIXELFORMATS: return "all pass color attachment images must have the same pixel format";
8833 case _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT: return "pass color-attachment images must have a renderable pixel format";
8834 case _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT: return "pass depth-attachment image must have depth pixel format";
8835 case _SG_VALIDATE_PASSDESC_IMAGE_SIZES: return "all pass attachments must have the same size";
8836 case _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS: return "all pass attachments must have the same sample count";
8837
8838 /* sg_begin_pass */
8839 case _SG_VALIDATE_BEGINPASS_PASS: return "sg_begin_pass: pass must be valid";
8840 case _SG_VALIDATE_BEGINPASS_IMAGE: return "sg_begin_pass: one or more attachment images are not valid";
8841
8842 /* sg_apply_pipeline */
8843 case _SG_VALIDATE_APIP_PIPELINE_VALID_ID: return "sg_apply_pipeline: invalid pipeline id provided";
8844 case _SG_VALIDATE_APIP_PIPELINE_EXISTS: return "sg_apply_pipeline: pipeline object no longer alive";
8845 case _SG_VALIDATE_APIP_PIPELINE_VALID: return "sg_apply_pipeline: pipeline object not in valid state";
8846 case _SG_VALIDATE_APIP_SHADER_EXISTS: return "sg_apply_pipeline: shader object no longer alive";
8847 case _SG_VALIDATE_APIP_SHADER_VALID: return "sg_apply_pipeline: shader object not in valid state";
8848 case _SG_VALIDATE_APIP_ATT_COUNT: return "sg_apply_pipeline: color_attachment_count in pipeline doesn't match number of pass color attachments";
8849 case _SG_VALIDATE_APIP_COLOR_FORMAT: return "sg_apply_pipeline: color_format in pipeline doesn't match pass color attachment pixel format";
8850 case _SG_VALIDATE_APIP_DEPTH_FORMAT: return "sg_apply_pipeline: depth_format in pipeline doesn't match pass depth attachment pixel format";
8851 case _SG_VALIDATE_APIP_SAMPLE_COUNT: return "sg_apply_pipeline: MSAA sample count in pipeline doesn't match render pass attachment sample count";
8852
8853 /* sg_apply_bindings */
8854 case _SG_VALIDATE_ABND_PIPELINE: return "sg_apply_bindings: must be called after sg_apply_pipeline";
8855 case _SG_VALIDATE_ABND_PIPELINE_EXISTS: return "sg_apply_bindings: currently applied pipeline object no longer alive";
8856 case _SG_VALIDATE_ABND_PIPELINE_VALID: return "sg_apply_bindings: currently applied pipeline object not in valid state";
8857 case _SG_VALIDATE_ABND_VBS: return "sg_apply_bindings: number of vertex buffers doesn't match number of pipeline vertex layouts";
8858 case _SG_VALIDATE_ABND_VB_EXISTS: return "sg_apply_bindings: vertex buffer no longer alive";
8859 case _SG_VALIDATE_ABND_VB_TYPE: return "sg_apply_bindings: buffer in vertex buffer slot is not a SG_BUFFERTYPE_VERTEXBUFFER";
8860 case _SG_VALIDATE_ABND_VB_OVERFLOW: return "sg_apply_bindings: buffer in vertex buffer slot is overflown";
8861 case _SG_VALIDATE_ABND_NO_IB: return "sg_apply_bindings: pipeline object defines indexed rendering, but no index buffer provided";
8862 case _SG_VALIDATE_ABND_IB: return "sg_apply_bindings: pipeline object defines non-indexed rendering, but index buffer provided";
8863 case _SG_VALIDATE_ABND_IB_EXISTS: return "sg_apply_bindings: index buffer no longer alive";
8864 case _SG_VALIDATE_ABND_IB_TYPE: return "sg_apply_bindings: buffer in index buffer slot is not a SG_BUFFERTYPE_INDEXBUFFER";
8865 case _SG_VALIDATE_ABND_IB_OVERFLOW: return "sg_apply_bindings: buffer in index buffer slot is overflown";
8866 case _SG_VALIDATE_ABND_VS_IMGS: return "sg_apply_bindings: vertex shader image count doesn't match sg_shader_desc";
8867 case _SG_VALIDATE_ABND_VS_IMG_EXISTS: return "sg_apply_bindings: vertex shader image no longer alive";
8868 case _SG_VALIDATE_ABND_VS_IMG_TYPES: return "sg_apply_bindings: one or more vertex shader image types don't match sg_shader_desc";
8869 case _SG_VALIDATE_ABND_FS_IMGS: return "sg_apply_bindings: fragment shader image count doesn't match sg_shader_desc";
8870 case _SG_VALIDATE_ABND_FS_IMG_EXISTS: return "sg_apply_bindings: fragment shader image no longer alive";
8871 case _SG_VALIDATE_ABND_FS_IMG_TYPES: return "sg_apply_bindings: one or more fragment shader image types don't match sg_shader_desc";
8872
8873 /* sg_apply_uniforms */
8874 case _SG_VALIDATE_AUB_NO_PIPELINE: return "sg_apply_uniforms: must be called after sg_apply_pipeline()";
8875 case _SG_VALIDATE_AUB_NO_UB_AT_SLOT: return "sg_apply_uniforms: no uniform block declaration at this shader stage UB slot";
8876 case _SG_VALIDATE_AUB_SIZE: return "sg_apply_uniforms: data size exceeds declared uniform block size";
8877
8878 /* sg_update_buffer */
8879 case _SG_VALIDATE_UPDATEBUF_USAGE: return "sg_update_buffer: cannot update immutable buffer";
8880 case _SG_VALIDATE_UPDATEBUF_SIZE: return "sg_update_buffer: update size is bigger than buffer size";
8881 case _SG_VALIDATE_UPDATEBUF_ONCE: return "sg_update_buffer: only one update allowed per buffer and frame";
8882 case _SG_VALIDATE_UPDATEBUF_APPEND: return "sg_update_buffer: cannot call sg_update_buffer and sg_append_buffer in same frame";
8883
8884 /* sg_append_buffer */
8885 case _SG_VALIDATE_APPENDBUF_USAGE: return "sg_append_buffer: cannot append to immutable buffer";
8886 case _SG_VALIDATE_APPENDBUF_SIZE: return "sg_append_buffer: overall appended size is bigger than buffer size";
8887 case _SG_VALIDATE_APPENDBUF_UPDATE: return "sg_append_buffer: cannot call sg_append_buffer and sg_update_buffer in same frame";
8888
8889 /* sg_update_image */
8890 case _SG_VALIDATE_UPDIMG_USAGE: return "sg_update_image: cannot update immutable image";
8891 case _SG_VALIDATE_UPDIMG_NOTENOUGHDATA: return "sg_update_image: not enough subimage data provided";
8892 case _SG_VALIDATE_UPDIMG_SIZE: return "sg_update_image: provided subimage data size too big";
8893 case _SG_VALIDATE_UPDIMG_COMPRESSED: return "sg_update_image: cannot update images with compressed format";
8894 case _SG_VALIDATE_UPDIMG_ONCE: return "sg_update_image: only one update allowed per image and frame";
8895
8896 default: return "unknown validation error";
8897 }
8898 }
8899 #endif /* defined(SOKOL_DEBUG) */
8900
8901 /*-- validation checks -------------------------------------------------------*/
8902 #if defined(SOKOL_DEBUG)
8903 _SOKOL_PRIVATE void _sg_validate_begin(void) {
8904 _sg.validate_error = _SG_VALIDATE_SUCCESS;
8905 }
8906
8907 _SOKOL_PRIVATE void _sg_validate(bool cond, _sg_validate_error_t err) {
8908 if (!cond) {
8909 _sg.validate_error = err;
8910 SOKOL_LOG(_sg_validate_string(err));
8911 }
8912 }
8913
8914 _SOKOL_PRIVATE bool _sg_validate_end(void) {
8915 if (_sg.validate_error != _SG_VALIDATE_SUCCESS) {
8916 #if !defined(SOKOL_VALIDATE_NON_FATAL)
8917 SOKOL_LOG("^^^^ VALIDATION FAILED, TERMINATING ^^^^");
8918 SOKOL_ASSERT(false);
8919 #endif
8920 return false;
8921 }
8922 else {
8923 return true;
8924 }
8925 }
8926 #endif
8927
8928 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_buffer_desccxx . . $ _sg_validate_buffer_desc(66537f8091a21ab7).(const sg_buffer_desccxx . . $ sg_buffer_desc#* desc) {
8929 #if !defined(SOKOL_DEBUG)
8930 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(desc);
8931 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
8932 #else
8933 SOKOL_ASSERT(desc);
8934 SOKOL_VALIDATE_BEGIN();
8935 SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_BUFFERDESC_CANARY);
8936 SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_BUFFERDESC_CANARY);
8937 SOKOL_VALIDATE(desc->size > 0, _SG_VALIDATE_BUFFERDESC_SIZE);
8938 bool ext = (0 != desc->gl_buffers[0]) || (0 != desc->mtl_buffers[0]) || (0 != desc->d3d11_buffer);
8939 if (!ext && (desc->usage == SG_USAGE_IMMUTABLE)) {
8940 SOKOL_VALIDATE(0 != desc->content, _SG_VALIDATE_BUFFERDESC_CONTENT);
8941 }
8942 else {
8943 SOKOL_VALIDATE(0 == desc->content, _SG_VALIDATE_BUFFERDESC_NO_CONTENT);
8944 }
8945 return SOKOL_VALIDATE_END();
8946 #endif
8947 }
8948
8949 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_image_desccxx . . $ _sg_validate_image_desc(b29e00c3664c9622).(const sg_image_desccxx . . $ sg_image_desc#* desc) {
8950 #if !defined(SOKOL_DEBUG)
8951 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(desc);
8952 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
8953 #else
8954 SOKOL_ASSERT(desc);
8955 SOKOL_VALIDATE_BEGIN();
8956 SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_IMAGEDESC_CANARY);
8957 SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_IMAGEDESC_CANARY);
8958 SOKOL_VALIDATE(desc->width > 0, _SG_VALIDATE_IMAGEDESC_WIDTH);
8959 SOKOL_VALIDATE(desc->height > 0, _SG_VALIDATE_IMAGEDESC_HEIGHT);
8960 const sg_pixel_format fmt = desc->pixel_format;
8961 const sg_usage usage = desc->usage;
8962 const bool ext = (0 != desc->gl_textures[0]) || (0 != desc->mtl_textures[0]) || (0 != desc->d3d11_texture);
8963 if (desc->render_target) {
8964 if (desc->sample_count > 1) {
8965 SOKOL_VALIDATE(_sg_query_feature(SG_FEATURE_MSAA_RENDER_TARGETS), _SG_VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT);
8966 }
8967 const bool valid_color_fmt = _sg_is_valid_rendertarget_color_format(fmt);
8968 const bool valid_depth_fmt = _sg_is_valid_rendertarget_depth_format(fmt);
8969 SOKOL_VALIDATE(valid_color_fmt || valid_depth_fmt, _SG_VALIDATE_IMAGEDESC_RT_PIXELFORMAT);
8970 SOKOL_VALIDATE(usage == SG_USAGE_IMMUTABLE, _SG_VALIDATE_IMAGEDESC_RT_IMMUTABLE);
8971 SOKOL_VALIDATE(desc->content.subimage[0][0].ptr==0, _SG_VALIDATE_IMAGEDESC_RT_NO_CONTENT);
8972 }
8973 else {
8974 SOKOL_VALIDATE(desc->sample_count <= 1, _SG_VALIDATE_IMAGEDESC_MSAA_BUT_NO_RT);
8975 const bool valid_nonrt_fmt = !_sg_is_valid_rendertarget_depth_format(fmt);
8976 SOKOL_VALIDATE(valid_nonrt_fmt, _SG_VALIDATE_IMAGEDESC_NONRT_PIXELFORMAT);
8977 /* FIXME: should use the same "expected size" computation as in _sg_validate_update_image() here */
8978 if (!ext && (usage == SG_USAGE_IMMUTABLE)) {
8979 const int num_faces = desc->type == SG_IMAGETYPE_CUBE ? 6:1;
8980 const int num_mips = desc->num_mipmaps;
8981 for (int face_index = 0; face_index < num_faces; face_index++) {
8982 for (int mip_index = 0; mip_index < num_mips; mip_index++) {
8983 const bool has_data = desc->content.subimage[face_index][mip_index].ptr != 0;
8984 const bool has_size = desc->content.subimage[face_index][mip_index].size > 0;
8985 SOKOL_VALIDATE(has_data && has_size, _SG_VALIDATE_IMAGEDESC_CONTENT);
8986 }
8987 }
8988 }
8989 else {
8990 for (int face_index = 0; face_index < SG_CUBEFACE_NUM; face_index++) {
8991 for (int mip_index = 0; mip_index < SG_MAX_MIPMAPS; mip_index++) {
8992 const bool no_data = 0 == desc->content.subimage[face_index][mip_index].ptr;
8993 const bool no_size = 0 == desc->content.subimage[face_index][mip_index].size;
8994 SOKOL_VALIDATE(no_data && no_size, _SG_VALIDATE_IMAGEDESC_NO_CONTENT);
8995 }
8996 }
8997 }
8998 }
8999 return SOKOL_VALIDATE_END();
9000 #endif
9001 }
9002
9003 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_shader_desccxx . . $ _sg_validate_shader_desc(fc94da840bdc5aae).(const sg_shader_desccxx . . $ sg_shader_desc#* desc) {
9004 #if !defined(SOKOL_DEBUG)
9005 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(desc);
9006 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9007 #else
9008 SOKOL_ASSERT(desc);
9009 SOKOL_VALIDATE_BEGIN();
9010 SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_SHADERDESC_CANARY);
9011 SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_SHADERDESC_CANARY);
9012 #if defined(SOKOL_GLES2)
9013 SOKOL_VALIDATE(0 != desc->attrs[0].name, _SG_VALIDATE_SHADERDESC_ATTR_NAMES);
9014 #elif defined(SOKOL_D3D11)
9015 SOKOL_VALIDATE(0 != desc->attrs[0].sem_name, _SG_VALIDATE_SHADERDESC_ATTR_SEMANTICS);
9016 #endif
9017 #if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
9018 /* on GL, must provide shader source code */
9019 SOKOL_VALIDATE(0 != desc->vs.source, _SG_VALIDATE_SHADERDESC_SOURCE);
9020 SOKOL_VALIDATE(0 != desc->fs.source, _SG_VALIDATE_SHADERDESC_SOURCE);
9021 #elif defined(SOKOL_METAL) || defined(SOKOL_D3D11)
9022 /* on Metal or D3D11, must provide shader source code or byte code */
9023 SOKOL_VALIDATE((0 != desc->vs.source)||(0 != desc->vs.byte_code), _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE);
9024 SOKOL_VALIDATE((0 != desc->fs.source)||(0 != desc->fs.byte_code), _SG_VALIDATE_SHADERDESC_SOURCE_OR_BYTECODE);
9025 #else
9026 /* Dummy Backend, don't require source or bytecode */
9027 #endif
9028 for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) {
9029 if (desc->attrs[i].name) {
9030 SOKOL_VALIDATE(strlen(desc->attrs[i].name) < _SG_STRING_SIZE, _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG);
9031 }
9032 if (desc->attrs[i].sem_name) {
9033 SOKOL_VALIDATE(strlen(desc->attrs[i].sem_name) < _SG_STRING_SIZE, _SG_VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG);
9034 }
9035 }
9036 /* if shader byte code, the size must also be provided */
9037 if (0 != desc->vs.byte_code) {
9038 SOKOL_VALIDATE(desc->vs.byte_code_size > 0, _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE);
9039 }
9040 if (0 != desc->fs.byte_code) {
9041 SOKOL_VALIDATE(desc->fs.byte_code_size > 0, _SG_VALIDATE_SHADERDESC_NO_BYTECODE_SIZE);
9042 }
9043 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGES; stage_index++) {
9044 const sg_shader_stage_desc* stage_desc = (stage_index == 0)? &desc->vs : &desc->fs;
9045 bool uniform_blocks_continuous = true;
9046 for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBS; ub_index++) {
9047 const sg_shader_uniform_block_desc* ub_desc = &stage_desc->uniform_blocks[ub_index];
9048 if (ub_desc->size > 0) {
9049 SOKOL_VALIDATE(uniform_blocks_continuous, _SG_VALIDATE_SHADERDESC_NO_CONT_UBS);
9050 bool uniforms_continuous = true;
9051 int uniform_offset = 0;
9052 int num_uniforms = 0;
9053 for (int u_index = 0; u_index < SG_MAX_UB_MEMBERS; u_index++) {
9054 const sg_shader_uniform_desc* u_desc = &ub_desc->uniforms[u_index];
9055 if (u_desc->type != SG_UNIFORMTYPE_INVALID) {
9056 SOKOL_VALIDATE(uniforms_continuous, _SG_VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS);
9057 #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
9058 SOKOL_VALIDATE(u_desc->name, _SG_VALIDATE_SHADERDESC_UB_MEMBER_NAME);
9059 #endif
9060 const int array_count = u_desc->array_count;
9061 uniform_offset += _sg_uniform_size(u_desc->type, array_count);
9062 num_uniforms++;
9063 }
9064 else {
9065 uniforms_continuous = false;
9066 }
9067 }
9068 #if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3)
9069 SOKOL_VALIDATE(uniform_offset == ub_desc->size, _SG_VALIDATE_SHADERDESC_UB_SIZE_MISMATCH);
9070 SOKOL_VALIDATE(num_uniforms > 0, _SG_VALIDATE_SHADERDESC_NO_UB_MEMBERS);
9071 #endif
9072 }
9073 else {
9074 uniform_blocks_continuous = false;
9075 }
9076 }
9077 bool images_continuous = true;
9078 for (int img_index = 0; img_index < SG_MAX_SHADERSTAGE_IMAGES; img_index++) {
9079 const sg_shader_image_desc* img_desc = &stage_desc->images[img_index];
9080 if (img_desc->type != _SG_IMAGETYPE_DEFAULT) {
9081 SOKOL_VALIDATE(images_continuous, _SG_VALIDATE_SHADERDESC_NO_CONT_IMGS);
9082 #if defined(SOKOL_GLES2)
9083 SOKOL_VALIDATE(img_desc->name, _SG_VALIDATE_SHADERDESC_IMG_NAME);
9084 #endif
9085 }
9086 else {
9087 images_continuous = false;
9088 }
9089 }
9090 }
9091 return SOKOL_VALIDATE_END();
9092 #endif
9093 }
9094
9095 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_pipeline_desccxx . . $ _sg_validate_pipeline_desc(259045f73f158fcd).(const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc) {
9096 #if !defined(SOKOL_DEBUG)
9097 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(desc);
9098 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9099 #else
9100 SOKOL_ASSERT(desc);
9101 SOKOL_VALIDATE_BEGIN();
9102 SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_PIPELINEDESC_CANARY);
9103 SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_PIPELINEDESC_CANARY);
9104 SOKOL_VALIDATE(desc->shader.id != SG_INVALID_ID, _SG_VALIDATE_PIPELINEDESC_SHADER);
9105 const _sg_shader_t* shd = _sg_lookup_shader(&_sg.pools, desc->shader.id);
9106 SOKOL_VALIDATE(shd && shd->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_PIPELINEDESC_SHADER);
9107 for (int buf_index = 0; buf_index < SG_MAX_SHADERSTAGE_BUFFERS; buf_index++) {
9108 const sg_buffer_layout_desc* l_desc = &desc->layout.buffers[buf_index];
9109 if (l_desc->stride == 0) {
9110 continue;
9111 }
9112 SOKOL_VALIDATE((l_desc->stride & 3) == 0, _SG_VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4);
9113 }
9114 SOKOL_VALIDATE(desc->layout.attrs[0].format != SG_VERTEXFORMAT_INVALID, _SG_VALIDATE_PIPELINEDESC_NO_ATTRS);
9115 bool attrs_cont = true;
9116 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTES; attr_index++) {
9117 const sg_vertex_attr_desc* a_desc = &desc->layout.attrs[attr_index];
9118 if (a_desc->format == SG_VERTEXFORMAT_INVALID) {
9119 attrs_cont = false;
9120 continue;
9121 }
9122 SOKOL_VALIDATE(attrs_cont, _SG_VALIDATE_PIPELINEDESC_NO_ATTRS);
9123 SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS);
9124 #if defined(SOKOL_GLES2)
9125 /* on GLES2, vertex attribute names must be provided */
9126 SOKOL_VALIDATE(!_sg_strempty(&shd->attrs[attr_index].name), _SG_VALIDATE_PIPELINEDESC_ATTR_NAME);
9127 #elif defined(SOKOL_D3D11)
9128 /* on D3D11, semantic names (and semantic indices) must be provided */
9129 SOKOL_VALIDATE(!_sg_strempty(&shd->attrs[attr_index].sem_name), _SG_VALIDATE_PIPELINEDESC_ATTR_SEMANTICS);
9130 #endif
9131 }
9132 return SOKOL_VALIDATE_END();
9133 #endif
9134 }
9135
9136 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_pass_desccxx . . $ _sg_validate_pass_desc(c625de270f1ab374).(const sg_pass_desccxx . . $ sg_pass_desc#* desc) {
9137 #if !defined(SOKOL_DEBUG)
9138 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(desc);
9139 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9140 #else
9141 SOKOL_ASSERT(desc);
9142 SOKOL_VALIDATE_BEGIN();
9143 SOKOL_VALIDATE(desc->_start_canary == 0, _SG_VALIDATE_PASSDESC_CANARY);
9144 SOKOL_VALIDATE(desc->_end_canary == 0, _SG_VALIDATE_PASSDESC_CANARY);
9145 bool atts_cont = true;
9146 sg_pixel_format color_fmt = SG_PIXELFORMAT_NONE;
9147 int width = -1, height = -1, sample_count = -1;
9148 for (int att_index = 0; att_index < SG_MAX_COLOR_ATTACHMENTS; att_index++) {
9149 const sg_attachment_desc* att = &desc->color_attachments[att_index];
9150 if (att->image.id == SG_INVALID_ID) {
9151 SOKOL_VALIDATE(att_index > 0, _SG_VALIDATE_PASSDESC_NO_COLOR_ATTS);
9152 atts_cont = false;
9153 continue;
9154 }
9155 SOKOL_VALIDATE(atts_cont, _SG_VALIDATE_PASSDESC_NO_CONT_COLOR_ATTS);
9156 const _sg_image_t* img = _sg_lookup_image(&_sg.pools, att->image.id);
9157 SOKOL_VALIDATE(img && img->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_PASSDESC_IMAGE);
9158 SOKOL_VALIDATE(att->mip_level < img->num_mipmaps, _SG_VALIDATE_PASSDESC_MIPLEVEL);
9159 if (img->type == SG_IMAGETYPE_CUBE) {
9160 SOKOL_VALIDATE(att->face < 6, _SG_VALIDATE_PASSDESC_FACE);
9161 }
9162 else if (img->type == SG_IMAGETYPE_ARRAY) {
9163 SOKOL_VALIDATE(att->layer < img->depth, _SG_VALIDATE_PASSDESC_LAYER);
9164 }
9165 else if (img->type == SG_IMAGETYPE_3D) {
9166 SOKOL_VALIDATE(att->slice < img->depth, _SG_VALIDATE_PASSDESC_SLICE);
9167 }
9168 SOKOL_VALIDATE(img->render_target, _SG_VALIDATE_PASSDESC_IMAGE_NO_RT);
9169 if (att_index == 0) {
9170 color_fmt = img->pixel_format;
9171 width = img->width >> att->mip_level;
9172 height = img->height >> att->mip_level;
9173 sample_count = img->sample_count;
9174 }
9175 else {
9176 SOKOL_VALIDATE(img->pixel_format == color_fmt, _SG_VALIDATE_PASSDESC_COLOR_PIXELFORMATS);
9177 SOKOL_VALIDATE(width == img->width >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES);
9178 SOKOL_VALIDATE(height == img->height >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES);
9179 SOKOL_VALIDATE(sample_count == img->sample_count, _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS);
9180 }
9181 SOKOL_VALIDATE(_sg_is_valid_rendertarget_color_format(img->pixel_format), _SG_VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT);
9182 }
9183 if (desc->depth_stencil_attachment.image.id != SG_INVALID_ID) {
9184 const sg_attachment_desc* att = &desc->depth_stencil_attachment;
9185 const _sg_image_t* img = _sg_lookup_image(&_sg.pools, att->image.id);
9186 SOKOL_VALIDATE(img && img->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_PASSDESC_IMAGE);
9187 SOKOL_VALIDATE(att->mip_level < img->num_mipmaps, _SG_VALIDATE_PASSDESC_MIPLEVEL);
9188 if (img->type == SG_IMAGETYPE_CUBE) {
9189 SOKOL_VALIDATE(att->face < 6, _SG_VALIDATE_PASSDESC_FACE);
9190 }
9191 else if (img->type == SG_IMAGETYPE_ARRAY) {
9192 SOKOL_VALIDATE(att->layer < img->depth, _SG_VALIDATE_PASSDESC_LAYER);
9193 }
9194 else if (img->type == SG_IMAGETYPE_3D) {
9195 SOKOL_VALIDATE(att->slice < img->depth, _SG_VALIDATE_PASSDESC_SLICE);
9196 }
9197 SOKOL_VALIDATE(img->render_target, _SG_VALIDATE_PASSDESC_IMAGE_NO_RT);
9198 SOKOL_VALIDATE(width == img->width >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES);
9199 SOKOL_VALIDATE(height == img->height >> att->mip_level, _SG_VALIDATE_PASSDESC_IMAGE_SIZES);
9200 SOKOL_VALIDATE(sample_count == img->sample_count, _SG_VALIDATE_PASSDESC_IMAGE_SAMPLE_COUNTS);
9201 SOKOL_VALIDATE(_sg_is_valid_rendertarget_depth_format(img->pixel_format), _SG_VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT);
9202 }
9203 return SOKOL_VALIDATE_END();
9204 #endif
9205 }
9206
9207 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_begin_passcxx . . $ _sg_validate_begin_pass(e51fdeb5efe2d9a4).(_sg_pass_tcxx . . $ _sg_pass_t#* pass) {
9208 #if !defined(SOKOL_DEBUG)
9209 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(pass);
9210 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9211 #else
9212 SOKOL_VALIDATE_BEGIN();
9213 SOKOL_VALIDATE(pass->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_BEGINPASS_PASS);
9214 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
9215 const _sg_attachment_t* att = &pass->color_atts[i];
9216 if (att->image) {
9217 SOKOL_VALIDATE(att->image->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_BEGINPASS_IMAGE);
9218 SOKOL_VALIDATE(att->image->slot.id == att->image_id.id, _SG_VALIDATE_BEGINPASS_IMAGE);
9219 }
9220 }
9221 if (pass->ds_att.image) {
9222 const _sg_attachment_t* att = &pass->ds_att;
9223 SOKOL_VALIDATE(att->image->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_BEGINPASS_IMAGE);
9224 SOKOL_VALIDATE(att->image->slot.id == att->image_id.id, _SG_VALIDATE_BEGINPASS_IMAGE);
9225 }
9226 return SOKOL_VALIDATE_END();
9227 #endif
9228 }
9229
9230 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_apply_pipelinecxx . . $ _sg_validate_apply_pipeline(a874b4146555fd8b).(sg_pipelinecxx . . $ sg_pipeline# pip_id) {
9231 #if !defined(SOKOL_DEBUG)
9232 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(pip_id);
9233 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9234 #else
9235 SOKOL_VALIDATE_BEGIN();
9236 /* the pipeline object must be alive and valid */
9237 SOKOL_VALIDATE(pip_id.id != SG_INVALID_ID, _SG_VALIDATE_APIP_PIPELINE_VALID_ID);
9238 const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, pip_id.id);
9239 SOKOL_VALIDATE(pip != 0, _SG_VALIDATE_APIP_PIPELINE_EXISTS);
9240 if (!pip) {
9241 return SOKOL_VALIDATE_END();
9242 }
9243 SOKOL_VALIDATE(pip->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_APIP_PIPELINE_VALID);
9244 /* the pipeline's shader must be alive and valid */
9245 SOKOL_ASSERT(pip->shader);
9246 SOKOL_VALIDATE(pip->shader->slot.id == pip->shader_id.id, _SG_VALIDATE_APIP_SHADER_EXISTS);
9247 SOKOL_VALIDATE(pip->shader->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_APIP_SHADER_VALID);
9248 /* check that pipeline attributes match current pass attributes */
9249 const _sg_pass_t* pass = _sg_lookup_pass(&_sg.pools, _sg.cur_pass.id);
9250 if (pass) {
9251 /* an offscreen pass */
9252 SOKOL_VALIDATE(pip->color_attachment_count == pass->num_color_atts, _SG_VALIDATE_APIP_ATT_COUNT);
9253 SOKOL_VALIDATE(pip->color_format == pass->color_atts[0].image->pixel_format, _SG_VALIDATE_APIP_COLOR_FORMAT);
9254 SOKOL_VALIDATE(pip->sample_count == pass->color_atts[0].image->sample_count, _SG_VALIDATE_APIP_SAMPLE_COUNT);
9255 if (pass->ds_att.image) {
9256 SOKOL_VALIDATE(pip->depth_format == pass->ds_att.image->pixel_format, _SG_VALIDATE_APIP_DEPTH_FORMAT);
9257 }
9258 else {
9259 SOKOL_VALIDATE(pip->depth_format == SG_PIXELFORMAT_NONE, _SG_VALIDATE_APIP_DEPTH_FORMAT);
9260 }
9261 }
9262 else {
9263 /* default pass */
9264 SOKOL_VALIDATE(pip->color_attachment_count == 1, _SG_VALIDATE_APIP_ATT_COUNT);
9265 SOKOL_VALIDATE(pip->color_format == SG_PIXELFORMAT_RGBA8, _SG_VALIDATE_APIP_COLOR_FORMAT);
9266 SOKOL_VALIDATE(pip->depth_format == SG_PIXELFORMAT_DEPTHSTENCIL, _SG_VALIDATE_APIP_DEPTH_FORMAT);
9267 /* FIXME: hmm, we don't know if the default framebuffer is multisampled here */
9268 }
9269 return SOKOL_VALIDATE_END();
9270 #endif
9271 }
9272
9273 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_apply_bindingscxx . . $ _sg_validate_apply_bindings(8dcd324f91fa1fd6).(const sg_bindingscxx . . $ sg_bindings#* bindings) {
9274 #if !defined(SOKOL_DEBUG)
9275 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(bindings);
9276 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9277 #else
9278 SOKOL_VALIDATE_BEGIN();
9279
9280 /* a pipeline object must have been applied */
9281 SOKOL_VALIDATE(_sg.cur_pipeline.id != SG_INVALID_ID, _SG_VALIDATE_ABND_PIPELINE);
9282 const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, _sg.cur_pipeline.id);
9283 SOKOL_VALIDATE(pip != 0, _SG_VALIDATE_ABND_PIPELINE_EXISTS);
9284 if (!pip) {
9285 return SOKOL_VALIDATE_END();
9286 }
9287 SOKOL_VALIDATE(pip->slot.state == SG_RESOURCESTATE_VALID, _SG_VALIDATE_ABND_PIPELINE_VALID);
9288 SOKOL_ASSERT(pip->shader);
9289
9290 /* has expected vertex buffers, and vertex buffers still exist */
9291 for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERS; i++) {
9292 if (bindings->vertex_buffers[i].id != SG_INVALID_ID) {
9293 SOKOL_VALIDATE(pip->vertex_layout_valid[i], _SG_VALIDATE_ABND_VBS);
9294 /* buffers in vertex-buffer-slots must be of type SG_BUFFERTYPE_VERTEXBUFFER */
9295 const _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, bindings->vertex_buffers[i].id);
9296 SOKOL_VALIDATE(buf != 0, _SG_VALIDATE_ABND_VB_EXISTS);
9297 if (buf && buf->slot.state == SG_RESOURCESTATE_VALID) {
9298 SOKOL_VALIDATE(SG_BUFFERTYPE_VERTEXBUFFER == buf->type, _SG_VALIDATE_ABND_VB_TYPE);
9299 SOKOL_VALIDATE(!buf->append_overflow, _SG_VALIDATE_ABND_VB_OVERFLOW);
9300 }
9301 }
9302 else {
9303 /* vertex buffer provided in a slot which has no vertex layout in pipeline */
9304 SOKOL_VALIDATE(!pip->vertex_layout_valid[i], _SG_VALIDATE_ABND_VBS);
9305 }
9306 }
9307
9308 /* index buffer expected or not, and index buffer still exists */
9309 if (pip->index_type == SG_INDEXTYPE_NONE) {
9310 /* pipeline defines non-indexed rendering, but index buffer provided */
9311 SOKOL_VALIDATE(bindings->index_buffer.id == SG_INVALID_ID, _SG_VALIDATE_ABND_IB);
9312 }
9313 else {
9314 /* pipeline defines indexed rendering, but no index buffer provided */
9315 SOKOL_VALIDATE(bindings->index_buffer.id != SG_INVALID_ID, _SG_VALIDATE_ABND_NO_IB);
9316 }
9317 if (bindings->index_buffer.id != SG_INVALID_ID) {
9318 /* buffer in index-buffer-slot must be of type SG_BUFFERTYPE_INDEXBUFFER */
9319 const _sg_buffer_t* buf = _sg_lookup_buffer(&_sg.pools, bindings->index_buffer.id);
9320 SOKOL_VALIDATE(buf != 0, _SG_VALIDATE_ABND_IB_EXISTS);
9321 if (buf && buf->slot.state == SG_RESOURCESTATE_VALID) {
9322 SOKOL_VALIDATE(SG_BUFFERTYPE_INDEXBUFFER == buf->type, _SG_VALIDATE_ABND_IB_TYPE);
9323 SOKOL_VALIDATE(!buf->append_overflow, _SG_VALIDATE_ABND_IB_OVERFLOW);
9324 }
9325 }
9326
9327 /* has expected vertex shader images */
9328 for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) {
9329 _sg_shader_stage_t* stage = &pip->shader->stage[SG_SHADERSTAGE_VS];
9330 if (bindings->vs_images[i].id != SG_INVALID_ID) {
9331 SOKOL_VALIDATE(i < stage->num_images, _SG_VALIDATE_ABND_VS_IMGS);
9332 const _sg_image_t* img = _sg_lookup_image(&_sg.pools, bindings->vs_images[i].id);
9333 SOKOL_VALIDATE(img != 0, _SG_VALIDATE_ABND_VS_IMG_EXISTS);
9334 if (img && img->slot.state == SG_RESOURCESTATE_VALID) {
9335 SOKOL_VALIDATE(img->type == stage->images[i].type, _SG_VALIDATE_ABND_VS_IMG_TYPES);
9336 }
9337 }
9338 else {
9339 SOKOL_VALIDATE(i >= stage->num_images, _SG_VALIDATE_ABND_VS_IMGS);
9340 }
9341 }
9342
9343 /* has expected fragment shader images */
9344 for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGES; i++) {
9345 _sg_shader_stage_t* stage = &pip->shader->stage[SG_SHADERSTAGE_FS];
9346 if (bindings->fs_images[i].id != SG_INVALID_ID) {
9347 SOKOL_VALIDATE(i < stage->num_images, _SG_VALIDATE_ABND_FS_IMGS);
9348 const _sg_image_t* img = _sg_lookup_image(&_sg.pools, bindings->fs_images[i].id);
9349 SOKOL_VALIDATE(img != 0, _SG_VALIDATE_ABND_FS_IMG_EXISTS);
9350 if (img && img->slot.state == SG_RESOURCESTATE_VALID) {
9351 SOKOL_VALIDATE(img->type == stage->images[i].type, _SG_VALIDATE_ABND_FS_IMG_TYPES);
9352 }
9353 }
9354 else {
9355 SOKOL_VALIDATE(i >= stage->num_images, _SG_VALIDATE_ABND_FS_IMGS);
9356 }
9357 }
9358 return SOKOL_VALIDATE_END();
9359 #endif
9360 }
9361
9362 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_apply_uniformscxx . . $ _sg_validate_apply_uniforms(10acfc1af4314cca).(sg_shader_stagecxx . . $ sg_shader_stage# stage_index, int ub_index, const void* data, int num_bytes) {
9363 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(data);
9364 #if !defined(SOKOL_DEBUG)
9365 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(stage_index);
9366 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(ub_index);
9367 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(num_bytes);
9368 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9369 #else
9370 SOKOL_ASSERT((stage_index == SG_SHADERSTAGE_VS) || (stage_index == SG_SHADERSTAGE_FS));
9371 SOKOL_ASSERT((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS));
9372 SOKOL_VALIDATE_BEGIN();
9373 SOKOL_VALIDATE(_sg.cur_pipeline.id != SG_INVALID_ID, _SG_VALIDATE_AUB_NO_PIPELINE);
9374 const _sg_pipeline_t* pip = _sg_lookup_pipeline(&_sg.pools, _sg.cur_pipeline.id);
9375 SOKOL_ASSERT(pip && (pip->slot.id == _sg.cur_pipeline.id));
9376 SOKOL_ASSERT(pip->shader && (pip->shader->slot.id == pip->shader_id.id));
9377
9378 /* check that there is a uniform block at 'stage' and 'ub_index' */
9379 const _sg_shader_stage_t* stage = &pip->shader->stage[stage_index];
9380 SOKOL_VALIDATE(ub_index < stage->num_uniform_blocks, _SG_VALIDATE_AUB_NO_UB_AT_SLOT);
9381
9382 /* check that the provided data size doesn't exceed the uniform block size */
9383 SOKOL_VALIDATE(num_bytes <= stage->uniform_blocks[ub_index].size, _SG_VALIDATE_AUB_SIZE);
9384
9385 return SOKOL_VALIDATE_END();
9386 #endif
9387 }
9388
9389 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_update_buffercxx . . $ _sg_validate_update_buffer(2ef69afab8bc583c).(const _sg_buffer_tcxx . . $ _sg_buffer_t#* buf, const void* data, int size) {
9390 #if !defined(SOKOL_DEBUG)
9391 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(buf);
9392 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(data);
9393 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(size);
9394 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9395 #else
9396 SOKOL_ASSERT(buf && data);
9397 SOKOL_VALIDATE_BEGIN();
9398 SOKOL_VALIDATE(buf->usage != SG_USAGE_IMMUTABLE, _SG_VALIDATE_UPDATEBUF_USAGE);
9399 SOKOL_VALIDATE(buf->size >= size, _SG_VALIDATE_UPDATEBUF_SIZE);
9400 SOKOL_VALIDATE(buf->update_frame_index != _sg.frame_index, _SG_VALIDATE_UPDATEBUF_ONCE);
9401 SOKOL_VALIDATE(buf->append_frame_index != _sg.frame_index, _SG_VALIDATE_UPDATEBUF_APPEND);
9402 return SOKOL_VALIDATE_END();
9403 #endif
9404 }
9405
9406 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_append_buffercxx . . $ _sg_validate_append_buffer(2ef69afab8bc583c).(const _sg_buffer_tcxx . . $ _sg_buffer_t#* buf, const void* data, int size) {
9407 #if !defined(SOKOL_DEBUG)
9408 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(buf);
9409 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(data);
9410 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(size);
9411 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9412 #else
9413 SOKOL_ASSERT(buf && data);
9414 SOKOL_VALIDATE_BEGIN();
9415 SOKOL_VALIDATE(buf->usage != SG_USAGE_IMMUTABLE, _SG_VALIDATE_APPENDBUF_USAGE);
9416 SOKOL_VALIDATE(buf->size >= (buf->append_pos+size), _SG_VALIDATE_APPENDBUF_SIZE);
9417 SOKOL_VALIDATE(buf->update_frame_index != _sg.frame_index, _SG_VALIDATE_APPENDBUF_UPDATE);
9418 return SOKOL_VALIDATE_END();
9419 #endif
9420 }
9421
9422 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! _sg_validate_update_imagecxx . . $ _sg_validate_update_image(6dae974cbdd2fbfd).(const _sg_image_tcxx . . $ _sg_image_t#* img, const sg_image_contentcxx . . $ sg_image_content#* data) {
9423 #if !defined(SOKOL_DEBUG)
9424 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(img);
9425 _SOKOL_UNUSEDcxx . . $ `demo/sokol/sokol_app.h:783:13`!(data);
9426 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9427 #else
9428 SOKOL_ASSERT(img && data);
9429 SOKOL_VALIDATE_BEGIN();
9430 SOKOL_VALIDATE(img->usage != SG_USAGE_IMMUTABLE, _SG_VALIDATE_UPDIMG_USAGE);
9431 SOKOL_VALIDATE(img->upd_frame_index != _sg.frame_index, _SG_VALIDATE_UPDIMG_ONCE);
9432 SOKOL_VALIDATE(!_sg_is_compressed_pixel_format(img->pixel_format), _SG_VALIDATE_UPDIMG_COMPRESSED);
9433 const int num_faces = (img->type == SG_IMAGETYPE_CUBE) ? 6 : 1;
9434 const int num_mips = img->num_mipmaps;
9435 for (int face_index = 0; face_index < num_faces; face_index++) {
9436 for (int mip_index = 0; mip_index < num_mips; mip_index++) {
9437 SOKOL_VALIDATE(0 != data->subimage[face_index][mip_index].ptr, _SG_VALIDATE_UPDIMG_NOTENOUGHDATA);
9438 const int mip_width = _sg_max(img->width >> mip_index, 1);
9439 const int mip_height = _sg_max(img->height >> mip_index, 1);
9440 const int bytes_per_slice = _sg_surface_pitch(img->pixel_format, mip_width, mip_height);
9441 const int expected_size = bytes_per_slice * img->depth;
9442 SOKOL_VALIDATE(data->subimage[face_index][mip_index].size <= expected_size, _SG_VALIDATE_UPDIMG_SIZE);
9443 }
9444 }
9445 return SOKOL_VALIDATE_END();
9446 #endif
9447 }
9448
9449 /*== fill in desc default values =============================================*/
9450 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_buffer_desccxx . . $ sg_buffer_desc# _sg_buffer_desc_defaultscxx . . $ _sg_buffer_desc_defaults(d4885e173a5d1258).(const sg_buffer_desccxx . . $ sg_buffer_desc#* desc) {
9451 sg_buffer_desccxx . . $ sg_buffer_desc# def = *desc;
9452 def.typecxx . . $ sg_buffer_desc#type. = _sg_defcxx . . $ sg_buffer_desc#type.(def.type, SG_BUFFERTYPE_VERTEXBUFFER);
9453 def.usagecxx . . $ sg_buffer_desc#usage. = _sg_defcxx . . $ sg_buffer_desc#usage.(def.usage, SG_USAGE_IMMUTABLE);
9454 return def;
9455 }
9456
9457 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_image_desccxx . . $ sg_image_desc# _sg_image_desc_defaultscxx . . $ _sg_image_desc_defaults(64e07389429933b6).(const sg_image_desccxx . . $ sg_image_desc#* desc) {
9458 sg_image_desccxx . . $ sg_image_desc# def = *desc;
9459 def.typecxx . . $ sg_image_desc#type. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.type, SG_IMAGETYPE_2D);
9460 def.depthcxx . . $ sg_image_desc#$anonymous_type_1#depth. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.depth, 1);
9461 def.num_mipmapscxx . . $ sg_image_desc#num_mipmaps. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.num_mipmaps, 1);
9462 def.usagecxx . . $ sg_image_desc#usage. = _sg_defcxx . . $ SG_USAGE_IMMUTABLE.(def.usage, SG_USAGE_IMMUTABLE);
9463 def.pixel_formatcxx . . $ sg_image_desc#pixel_format. = _sg_defcxx . . $ SG_PIXELFORMAT_RGBA8.(def.pixel_format, SG_PIXELFORMAT_RGBA8);
9464 def.sample_countcxx . . $ sg_image_desc#sample_count. = _sg_defcxx . . $ sg_image_desc#sample_count.(def.sample_count, 1);
9465 def.min_filtercxx . . $ sg_image_desc#min_filter. = _sg_defcxx . . $ sg_image_desc#min_filter.(def.min_filter, SG_FILTER_NEAREST);
9466 def.mag_filtercxx . . $ sg_image_desc#mag_filter. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.mag_filter, SG_FILTER_NEAREST);
9467 def.wrap_ucxx . . $ sg_image_desc#wrap_u. = _sg_defcxx . . $ SG_WRAP_REPEAT.(def.wrap_u, SG_WRAP_REPEAT);
9468 def.wrap_vcxx . . $ sg_image_desc#wrap_v. = _sg_defcxx . . $ sg_image_desc#wrap_v.(def.wrap_v, SG_WRAP_REPEAT);
9469 def.wrap_wcxx . . $ sg_image_desc#wrap_w. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.wrap_w, SG_WRAP_REPEAT);
9470 def.max_anisotropycxx . . $ sg_image_desc#max_anisotropy. = _sg_defcxx . . $ sg_image_desc#max_anisotropy.(def.max_anisotropy, 1);
9471 def.max_lodcxx . . $ sg_image_desc#max_lod. = _sg_def_fltcxx . . $ sg_image_desc#max_lod.(def.max_lod, FLT_MAXcxx . . $ `<external>/8223903785965736313/float.h:104:9`!);
9472 return def;
9473 }
9474
9475 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_shader_desccxx . . $ sg_shader_desc# _sg_shader_desc_defaultscxx . . $ _sg_shader_desc_defaults(d0f46a51a54240b4).(const sg_shader_desccxx . . $ sg_shader_desc#* desc) {
9476 sg_shader_desccxx . . $ sg_shader_desc# def = *desc;
9477 #if defined(SOKOL_METAL)
9478 def.vs.entry = _sg_def(def.vs.entry, "_main");
9479 def.fs.entry = _sg_def(def.fs.entry, "_main");
9480 #else
9481 def.vscxx . . $ sg_shader_desc#vs..entrycxx . . $ sg_shader_stage_desc#entry. = _sg_defcxx . . $ sg_shader_desc#vs.(def.vs.entry, "main");
9482 def.fscxx . . $ sg_shader_desc#fs..entrycxx . . $ sg_shader_stage_desc#entry. = _sg_defcxx . . $ sg_shader_desc#fs.(def.fs.entry, "main");
9483 #endif
9484 for (int stage_index = 0; stage_index < SG_NUM_SHADER_STAGEScxx . . $ SG_NUM_SHADER_STAGES.; stage_index++) {
9485 sg_shader_stage_desccxx . . $ sg_shader_stage_desc#* stage_desc = (stage_index == SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS.)? &def.vscxx . . $ sg_shader_desc#vs. : &def.fscxx . . $ sg_shader_desc#fs.;
9486 for (int ub_index = 0; ub_index < SG_MAX_SHADERSTAGE_UBScxx . . $ SG_MAX_SHADERSTAGE_UBS.; ub_index++) {
9487 sg_shader_uniform_block_desccxx . . $ sg_shader_uniform_block_desc#* ub_desc = &stage_desc->uniform_blockscxx . . $ sg_shader_stage_desc#uniform_blocks.[ub_index];
9488 if (0 == ub_desc->sizecxx . . $ sg_shader_uniform_block_desc#size.) {
9489 break;
9490 }
9491 for (int u_index = 0; u_index < SG_MAX_UB_MEMBERScxx . . $ SG_MAX_UB_MEMBERS.; u_index++) {
9492 sg_shader_uniform_desccxx . . $ sg_shader_uniform_desc#* u_desc = &ub_desc->uniformscxx . . $ sg_shader_uniform_block_desc#uniforms.[u_index];
9493 if (u_desc->typecxx . . $ sg_shader_uniform_desc#type. == SG_UNIFORMTYPE_INVALIDcxx . . $ SG_UNIFORMTYPE_INVALID.) {
9494 break;
9495 }
9496 u_desc->array_countcxx . . $ sg_shader_uniform_desc#array_count. = _sg_defcxx . . $ sg_shader_uniform_desc#array_count.(u_desc->array_count, 1);
9497 }
9498 }
9499 }
9500 return def;
9501 }
9502
9503 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_pipeline_desccxx . . $ sg_pipeline_desc# _sg_pipeline_desc_defaultscxx . . $ _sg_pipeline_desc_defaults(549abcde1cf96b9d).(const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc) {
9504 sg_pipeline_desccxx . . $ sg_pipeline_desc# def = *desc;
9505
9506 def.primitive_typecxx . . $ sg_pipeline_desc#primitive_type. = _sg_defcxx . . $ sg_pipeline_desc#primitive_type.(def.primitive_type, SG_PRIMITIVETYPE_TRIANGLES);
9507 def.index_typecxx . . $ sg_pipeline_desc#index_type. = _sg_defcxx . . $ SG_INDEXTYPE_NONE.(def.index_type, SG_INDEXTYPE_NONE);
9508
9509 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front..fail_opcxx . . $ sg_stencil_state#fail_op. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.depth_stencil.stencil_front.fail_op, SG_STENCILOP_KEEP);
9510 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front..depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op. = _sg_defcxx . . $ SG_STENCILOP_KEEP.(def.depth_stencil.stencil_front.depth_fail_op, SG_STENCILOP_KEEP);
9511 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front..pass_opcxx . . $ sg_stencil_state#pass_op. = _sg_defcxx . . $ sg_depth_stencil_state#stencil_front.(def.depth_stencil.stencil_front.pass_op, SG_STENCILOP_KEEP);
9512 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_frontcxx . . $ sg_depth_stencil_state#stencil_front..compare_funccxx . . $ sg_stencil_state#compare_func. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.depth_stencil.stencil_front.compare_func, SG_COMPAREFUNC_ALWAYS);
9513 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_backcxx . . $ sg_depth_stencil_state#stencil_back..fail_opcxx . . $ sg_stencil_state#fail_op. = _sg_defcxx . . $ sg_depth_stencil_state#stencil_back.(def.depth_stencil.stencil_back.fail_op, SG_STENCILOP_KEEP);
9514 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_backcxx . . $ sg_depth_stencil_state#stencil_back..depth_fail_opcxx . . $ sg_stencil_state#depth_fail_op. = _sg_defcxx . . $ sg_depth_stencil_state#stencil_back.(def.depth_stencil.stencil_back.depth_fail_op, SG_STENCILOP_KEEP);
9515 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_backcxx . . $ sg_depth_stencil_state#stencil_back..pass_opcxx . . $ sg_stencil_state#pass_op. = _sg_defcxx . . $ sg_depth_stencil_state#stencil_back.(def.depth_stencil.stencil_back.pass_op, SG_STENCILOP_KEEP);
9516 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..stencil_backcxx . . $ sg_depth_stencil_state#stencil_back..compare_funccxx . . $ sg_stencil_state#compare_func. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.depth_stencil.stencil_back.compare_func, SG_COMPAREFUNC_ALWAYS);
9517 def.depth_stencilcxx . . $ sg_pipeline_desc#depth_stencil..depth_compare_funccxx . . $ sg_depth_stencil_state#depth_compare_func. = _sg_defcxx . . $ sg_depth_stencil_state#depth_compare_func.(def.depth_stencil.depth_compare_func, SG_COMPAREFUNC_ALWAYS);
9518
9519 def.blendcxx . . $ sg_pipeline_desc#blend..src_factor_rgbcxx . . $ sg_blend_state#src_factor_rgb. = _sg_defcxx . . $ SG_BLENDFACTOR_ONE.(def.blend.src_factor_rgb, SG_BLENDFACTOR_ONE);
9520 def.blendcxx . . $ sg_pipeline_desc#blend..dst_factor_rgbcxx . . $ sg_blend_state#dst_factor_rgb. = _sg_defcxx . . $ sg_pipeline_desc#blend.(def.blend.dst_factor_rgb, SG_BLENDFACTOR_ZERO);
9521 def.blendcxx . . $ sg_pipeline_desc#blend..op_rgbcxx . . $ sg_blend_state#op_rgb. = _sg_defcxx . . $ sg_blend_state#op_rgb.(def.blend.op_rgb, SG_BLENDOP_ADD);
9522 def.blendcxx . . $ sg_pipeline_desc#blend..src_factor_alphacxx . . $ sg_blend_state#src_factor_alpha. = _sg_defcxx . . $ SG_BLENDFACTOR_ONE.(def.blend.src_factor_alpha, SG_BLENDFACTOR_ONE);
9523 def.blendcxx . . $ sg_pipeline_desc#blend..dst_factor_alphacxx . . $ sg_blend_state#dst_factor_alpha. = _sg_defcxx . . $ sg_pipeline_desc#blend.(def.blend.dst_factor_alpha, SG_BLENDFACTOR_ZERO);
9524 def.blendcxx . . $ sg_pipeline_desc#blend..op_alphacxx . . $ sg_blend_state#op_alpha. = _sg_defcxx . . $ sg_pipeline_desc#blend.(def.blend.op_alpha, SG_BLENDOP_ADD);
9525 if (def.blendcxx . . $ sg_pipeline_desc#blend..color_write_maskcxx . . $ sg_blend_state#color_write_mask. == SG_COLORMASK_NONEcxx . . $ SG_COLORMASK_NONE.) {
9526 def.blendcxx . . $ sg_pipeline_desc#blend..color_write_maskcxx . . $ sg_blend_state#color_write_mask. = 0;
9527 }
9528 else {
9529 def.blendcxx . . $ sg_pipeline_desc#blend..color_write_maskcxx . . $ sg_blend_state#color_write_mask. = (uint8_tcxx . . $ uint8_t#) _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!((sg_color_mask)def.blend.color_write_mask, SG_COLORMASK_RGBA);
9530 }
9531 def.blendcxx . . $ sg_pipeline_desc#blend..color_attachment_countcxx . . $ sg_blend_state#color_attachment_count. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(def.blend.color_attachment_count, 1);
9532 def.blendcxx . . $ sg_pipeline_desc#blend..color_formatcxx . . $ sg_blend_state#color_format. = _sg_defcxx . . $ SG_PIXELFORMAT_RGBA8.(def.blend.color_format, SG_PIXELFORMAT_RGBA8);
9533 def.blendcxx . . $ sg_pipeline_desc#blend..depth_formatcxx . . $ sg_blend_state#depth_format. = _sg_defcxx . . $ SG_PIXELFORMAT_DEPTHSTENCIL.(def.blend.depth_format, SG_PIXELFORMAT_DEPTHSTENCIL);
9534
9535 def.rasterizercxx . . $ sg_pipeline_desc#rasterizer..cull_modecxx . . $ sg_rasterizer_state#cull_mode. = _sg_defcxx . . $ sg_pipeline_desc#rasterizer.(def.rasterizer.cull_mode, SG_CULLMODE_NONE);
9536 def.rasterizercxx . . $ sg_pipeline_desc#rasterizer..face_windingcxx . . $ sg_rasterizer_state#face_winding. = _sg_defcxx . . $ sg_rasterizer_state#face_winding.(def.rasterizer.face_winding, SG_FACEWINDING_CW);
9537 def.rasterizercxx . . $ sg_pipeline_desc#rasterizer..sample_countcxx . . $ sg_rasterizer_state#sample_count. = _sg_defcxx . . $ sg_rasterizer_state#sample_count.(def.rasterizer.sample_count, 1);
9538
9539 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; attr_index++) {
9540 sg_vertex_attr_desccxx . . $ sg_vertex_attr_desc#* a_desc = &def.layoutcxx . . $ sg_pipeline_desc#layout..attrscxx . . $ sg_layout_desc#attrs.[attr_index];
9541 if (a_desc->formatcxx . . $ sg_vertex_attr_desc#format. == SG_VERTEXFORMAT_INVALIDcxx . . $ SG_VERTEXFORMAT_INVALID.) {
9542 break;
9543 }
9544 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((a_desc->buffer_index >= 0) && (a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS));
9545 sg_buffer_layout_desccxx . . $ sg_buffer_layout_desc#* b_desc = &def.layoutcxx . . $ sg_pipeline_desc#layout..bufferscxx . . $ sg_layout_desc#buffers.[a_desc->buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.];
9546 b_desc->step_funccxx . . $ sg_buffer_layout_desc#step_func. = _sg_defcxx . . $ sg_buffer_layout_desc#step_func.(b_desc->step_func, SG_VERTEXSTEP_PER_VERTEX);
9547 b_desc->step_ratecxx . . $ sg_buffer_layout_desc#step_rate. = _sg_defcxx . . $ `demo/sokol/sokol_gfx.h:2167:9`!(b_desc->step_rate, 1);
9548 }
9549
9550 /* resolve vertex layout strides and offsets */
9551 int auto_offset[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.];
9552 memsetcxx . . $ memset(d1de1e4fb215f1c6).(auto_offset, 0, sizeof(auto_offset));
9553 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! use_auto_offset = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9554 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; attr_index++) {
9555 /* to use computed offsets, *all* attr offsets must be 0 */
9556 if (def.layoutcxx . . $ sg_pipeline_desc#layout..attrscxx . . $ sg_layout_desc#attrs.[attr_index].offsetcxx . . $ sg_vertex_attr_desc#offset. != 0) {
9557 use_auto_offset = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
9558 }
9559 }
9560 for (int attr_index = 0; attr_index < SG_MAX_VERTEX_ATTRIBUTEScxx . . $ SG_MAX_VERTEX_ATTRIBUTES.; attr_index++) {
9561 sg_vertex_attr_desccxx . . $ sg_vertex_attr_desc#* a_desc = &def.layoutcxx . . $ sg_pipeline_desc#layout..attrscxx . . $ sg_layout_desc#attrs.[attr_index];
9562 if (a_desc->formatcxx . . $ sg_vertex_attr_desc#format. == SG_VERTEXFORMAT_INVALIDcxx . . $ SG_VERTEXFORMAT_INVALID.) {
9563 break;
9564 }
9565 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((a_desc->buffer_index >= 0) && (a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS));
9566 if (use_auto_offset) {
9567 a_desc->offsetcxx . . $ sg_vertex_attr_desc#offset. = auto_offset[a_desc->buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.];
9568 }
9569 auto_offset[a_desc->buffer_indexcxx . . $ sg_vertex_attr_desc#buffer_index.] += _sg_vertexformat_bytesizecxx . . $ _sg_vertexformat_bytesize(1303c1e179b3eed2).(a_desc->formatcxx . . $ sg_vertex_attr_desc#format.);
9570 }
9571 /* compute vertex strides if needed */
9572 for (int buf_index = 0; buf_index < SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.; buf_index++) {
9573 sg_buffer_layout_desccxx . . $ sg_buffer_layout_desc#* l_desc = &def.layoutcxx . . $ sg_pipeline_desc#layout..bufferscxx . . $ sg_layout_desc#buffers.[buf_index];
9574 if (l_desc->stridecxx . . $ sg_buffer_layout_desc#stride. == 0) {
9575 l_desc->stridecxx . . $ sg_buffer_layout_desc#stride. = auto_offset[buf_index];
9576 }
9577 }
9578
9579 return def;
9580 }
9581
9582 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_pass_desccxx . . $ sg_pass_desc# _sg_pass_desc_defaultscxx . . $ _sg_pass_desc_defaults(684617f2b81c1bcf).(const sg_pass_desccxx . . $ sg_pass_desc#* desc) {
9583 /* FIXME: no values to replace in sg_pass_desc? */
9584 sg_pass_desccxx . . $ sg_pass_desc# def = *desc;
9585 return def;
9586 }
9587
9588 /*== allocate/initialize resource private functions ==========================*/
9589 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_buffercxx . . $ sg_buffer# _sg_alloc_buffercxx . . $ _sg_alloc_buffer(210aeac7c490d744).(void) {
9590 sg_buffercxx . . $ sg_buffer# res;
9591 int slot_index = _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool.);
9592 if (_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index) {
9593 res.idcxx . . $ sg_buffer#id. = _sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool., &_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..bufferscxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffers.[slot_index].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot., slot_index);
9594 }
9595 else {
9596 /* pool is exhausted */
9597 res.idcxx . . $ sg_buffer#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9598 }
9599 return res;
9600 }
9601
9602 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_imagecxx . . $ sg_image# _sg_alloc_imagecxx . . $ _sg_alloc_image(c32329c31f7bd9e9).(void) {
9603 sg_imagecxx . . $ sg_image# res;
9604 int slot_index = _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool.);
9605 if (_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index) {
9606 res.idcxx . . $ sg_image#id. = _sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool., &_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..imagescxx . . $ $anonymous_type_ded6a5455d648ef8_24#images.[slot_index].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot., slot_index);
9607 }
9608 else {
9609 /* pool is exhausted */
9610 res.idcxx . . $ sg_image#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9611 }
9612 return res;
9613 }
9614
9615 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_shadercxx . . $ sg_shader# _sg_alloc_shadercxx . . $ _sg_alloc_shader(eddf85115a913590).(void) {
9616 sg_shadercxx . . $ sg_shader# res;
9617 int slot_index = _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool.);
9618 if (_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index) {
9619 res.idcxx . . $ sg_shader#id. = _sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool., &_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..shaderscxx . . $ $anonymous_type_ded6a5455d648ef8_24#shaders.[slot_index].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot., slot_index);
9620 }
9621 else {
9622 /* pool is exhausted */
9623 res.idcxx . . $ sg_shader#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9624 }
9625 return res;
9626 }
9627
9628 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_pipelinecxx . . $ sg_pipeline# _sg_alloc_pipelinecxx . . $ _sg_alloc_pipeline(4d9e1c814ee6f037).(void) {
9629 sg_pipelinecxx . . $ sg_pipeline# res;
9630 int slot_index = _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool.);
9631 if (_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index) {
9632 res.idcxx . . $ sg_pipeline#id. =_sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool., &_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pipelinescxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipelines.[slot_index].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot., slot_index);
9633 }
9634 else {
9635 /* pool is exhausted */
9636 res.idcxx . . $ sg_pipeline#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9637 }
9638 return res;
9639 }
9640
9641 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! sg_passcxx . . $ sg_pass# _sg_alloc_passcxx . . $ _sg_alloc_pass(8fa2722a10bdd7a8).(void) {
9642 sg_passcxx . . $ sg_pass# res;
9643 int slot_index = _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool.);
9644 if (_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index) {
9645 res.idcxx . . $ sg_pass#id. = _sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool., &_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..passescxx . . $ $anonymous_type_ded6a5455d648ef8_24#passes.[slot_index].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot., slot_index);
9646 }
9647 else {
9648 /* pool is exhausted */
9649 res.idcxx . . $ sg_pass#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9650 }
9651 return res;
9652 }
9653
9654 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_init_buffercxx . . $ _sg_init_buffer(199f42cf0ce34e9e).(sg_buffercxx . . $ sg_buffer# buf_id, const sg_buffer_desccxx . . $ sg_buffer_desc#* desc) {
9655 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf_id.id != SG_INVALID_ID && desc);
9656 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
9657 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf && buf->slot.state == SG_RESOURCESTATE_ALLOC);
9658 buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9659 if (_sg_validate_buffer_desccxx . . $ _sg_validate_buffer_desc(66537f8091a21ab7).(desc)) {
9660 buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = _sg_create_buffercxx . . $ _sg_create_buffer(e4de7721254dd384).(buf, desc);
9661 }
9662 else {
9663 buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9664 }
9665 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((buf->slot.state == SG_RESOURCESTATE_VALID)||(buf->slot.state == SG_RESOURCESTATE_FAILED));
9666 }
9667
9668 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_init_imagecxx . . $ _sg_init_image(b9ac7bf4077bbc85).(sg_imagecxx . . $ sg_image# img_id, const sg_image_desccxx . . $ sg_image_desc#* desc) {
9669 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img_id.id != SG_INVALID_ID && desc);
9670 _sg_image_tcxx . . $ _sg_image_t#* img = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., img_id.idcxx . . $ sg_image#id.);
9671 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img && img->slot.state == SG_RESOURCESTATE_ALLOC);
9672 img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9673 if (_sg_validate_image_desccxx . . $ _sg_validate_image_desc(b29e00c3664c9622).(desc)) {
9674 img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = _sg_create_imagecxx . . $ _sg_create_image(f00e77058a114b81).(img, desc);
9675 }
9676 else {
9677 img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9678 }
9679 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((img->slot.state == SG_RESOURCESTATE_VALID)||(img->slot.state == SG_RESOURCESTATE_FAILED));
9680 }
9681
9682 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_init_shadercxx . . $ _sg_init_shader(ffec3585d8638365).(sg_shadercxx . . $ sg_shader# shd_id, const sg_shader_desccxx . . $ sg_shader_desc#* desc) {
9683 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd_id.id != SG_INVALID_ID && desc);
9684 _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., shd_id.idcxx . . $ sg_shader#id.);
9685 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd && shd->slot.state == SG_RESOURCESTATE_ALLOC);
9686 shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9687 if (_sg_validate_shader_desccxx . . $ _sg_validate_shader_desc(fc94da840bdc5aae).(desc)) {
9688 shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = _sg_create_shadercxx . . $ _sg_create_shader(ca3cb0aaa639e707).(shd, desc);
9689 }
9690 else {
9691 shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9692 }
9693 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((shd->slot.state == SG_RESOURCESTATE_VALID)||(shd->slot.state == SG_RESOURCESTATE_FAILED));
9694 }
9695
9696 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_init_pipelinecxx . . $ _sg_init_pipeline(92596deeb42817ed).(sg_pipelinecxx . . $ sg_pipeline# pip_id, const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc) {
9697 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip_id.id != SG_INVALID_ID && desc);
9698 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pip_id.idcxx . . $ sg_pipeline#id.);
9699 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip && pip->slot.state == SG_RESOURCESTATE_ALLOC);
9700 pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9701 if (_sg_validate_pipeline_desccxx . . $ _sg_validate_pipeline_desc(259045f73f158fcd).(desc)) {
9702 _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., desc->shadercxx . . $ sg_pipeline_desc#shader..idcxx . . $ sg_shader#id.);
9703 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd && shd->slot.state == SG_RESOURCESTATE_VALID);
9704 pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = _sg_create_pipelinecxx . . $ _sg_create_pipeline(de9bffdb94faaaa6).(pip, shd, desc);
9705 }
9706 else {
9707 pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9708 }
9709 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((pip->slot.state == SG_RESOURCESTATE_VALID)||(pip->slot.state == SG_RESOURCESTATE_FAILED));
9710 }
9711
9712 _SOKOL_PRIVATEcxx . . $ `demo/sokol/sokol_app.h:777:17`! void _sg_init_passcxx . . $ _sg_init_pass(5bf38153cc347fdc).(sg_passcxx . . $ sg_pass# pass_id, const sg_pass_desccxx . . $ sg_pass_desc#* desc) {
9713 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass_id.id != SG_INVALID_ID && desc);
9714 _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pass_id.idcxx . . $ sg_pass#id.);
9715 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass && pass->slot.state == SG_RESOURCESTATE_ALLOC);
9716 pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9717 if (_sg_validate_pass_desccxx . . $ _sg_validate_pass_desc(c625de270f1ab374).(desc)) {
9718 /* lookup pass attachment image pointers */
9719 _sg_image_tcxx . . $ _sg_image_t#* att_imgs[SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS. + 1];
9720 for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.; i++) {
9721 if (desc->color_attachmentscxx . . $ sg_pass_desc#color_attachments.[i].imagecxx . . $ sg_attachment_desc#image..idcxx . . $ sg_image#id.) {
9722 att_imgs[i] = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., desc->color_attachmentscxx . . $ sg_pass_desc#color_attachments.[i].imagecxx . . $ sg_attachment_desc#image..idcxx . . $ sg_image#id.);
9723 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(att_imgs[i] && att_imgs[i]->slot.state == SG_RESOURCESTATE_VALID);
9724 }
9725 else {
9726 att_imgs[i] = 0;
9727 }
9728 }
9729 const int ds_att_index = SG_MAX_COLOR_ATTACHMENTScxx . . $ SG_MAX_COLOR_ATTACHMENTS.;
9730 if (desc->depth_stencil_attachmentcxx . . $ sg_pass_desc#depth_stencil_attachment..imagecxx . . $ sg_attachment_desc#image..idcxx . . $ sg_image#id.) {
9731 att_imgs[ds_att_index] = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., desc->depth_stencil_attachmentcxx . . $ sg_pass_desc#depth_stencil_attachment..imagecxx . . $ sg_attachment_desc#image..idcxx . . $ sg_image#id.);
9732 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(att_imgs[ds_att_index] && att_imgs[ds_att_index]->slot.state == SG_RESOURCESTATE_VALID);
9733 }
9734 else {
9735 att_imgs[ds_att_index] = 0;
9736 }
9737 pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = _sg_create_passcxx . . $ _sg_create_pass(b0a912b01eaf11f1).(pass, att_imgs, desc);
9738 }
9739 else {
9740 pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9741 }
9742 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((pass->slot.state == SG_RESOURCESTATE_VALID)||(pass->slot.state == SG_RESOURCESTATE_FAILED));
9743 }
9744
9745 /*== PUBLIC API FUNCTIONS ====================================================*/
9746 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_setupcxx . . $ sg_setup(14daf3ac2a73e58e).(const sg_desccxx . . $ sg_desc#* desc) {
9747 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
9748 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((desc->_start_canary == 0) && (desc->_end_canary == 0));
9749 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&_sgcxx . . $ _sg., 0, sizeof(_sgcxx . . $ _sg.));
9750 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc. = *desc;
9751
9752 /* replace zero-init items with their default values */
9753 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..buffer_pool_sizecxx . . $ sg_desc#buffer_pool_size. = _sg_defcxx . . $ _SG_DEFAULT_BUFFER_POOL_SIZE.(_sg.desc.buffer_pool_size, _SG_DEFAULT_BUFFER_POOL_SIZE);
9754 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..image_pool_sizecxx . . $ sg_desc#image_pool_size. = _sg_defcxx . . $ sg_desc#image_pool_size.(_sg.desc.image_pool_size, _SG_DEFAULT_IMAGE_POOL_SIZE);
9755 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..shader_pool_sizecxx . . $ sg_desc#shader_pool_size. = _sg_defcxx . . $ _SG_DEFAULT_SHADER_POOL_SIZE.(_sg.desc.shader_pool_size, _SG_DEFAULT_SHADER_POOL_SIZE);
9756 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..pipeline_pool_sizecxx . . $ sg_desc#pipeline_pool_size. = _sg_defcxx . . $ sg_desc#pipeline_pool_size.(_sg.desc.pipeline_pool_size, _SG_DEFAULT_PIPELINE_POOL_SIZE);
9757 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..pass_pool_sizecxx . . $ sg_desc#pass_pool_size. = _sg_defcxx . . $ _sg.(_sg.desc.pass_pool_size, _SG_DEFAULT_PASS_POOL_SIZE);
9758 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..context_pool_sizecxx . . $ sg_desc#context_pool_size. = _sg_defcxx . . $ _sg.(_sg.desc.context_pool_size, _SG_DEFAULT_CONTEXT_POOL_SIZE);
9759 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..mtl_global_uniform_buffer_sizecxx . . $ sg_desc#mtl_global_uniform_buffer_size. = _sg_defcxx . . $ _SG_MTL_DEFAULT_UB_SIZE.(_sg.desc.mtl_global_uniform_buffer_size, _SG_MTL_DEFAULT_UB_SIZE);
9760 _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc..mtl_sampler_cache_sizecxx . . $ sg_desc#mtl_sampler_cache_size. = _sg_defcxx . . $ _sg.(_sg.desc.mtl_sampler_cache_size, _SG_MTL_DEFAULT_SAMPLER_CACHE_CAPACITY);
9761
9762 _sg_setup_poolscxx . . $ _sg_setup_pools(68f03b631ad87475).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., &_sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc.);
9763 _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index. = 1;
9764 _sg_setup_backendcxx . . $ _sg_setup_backend(14daf3ac2a73e58e).(&_sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc.);
9765 sg_setup_contextcxx . . $ sg_setup_context(ac4049b755bec9ae).();
9766 _sgcxx . . $ _sg..validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#valid. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
9767 }
9768
9769 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_shutdowncxx . . $ sg_shutdown(49f6e7a06ebc5aa8).(void) {
9770 /* can only delete resources for the currently set context here, if multiple
9771 contexts are used, the app code must take care of properly releasing them
9772 (since only the app code can switch between 3D-API contexts)
9773 */
9774 if (_sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
9775 _sg_context_tcxx . . $ _sg_context_t#* ctx = _sg_lookup_contextcxx . . $ _sg_lookup_context(f2667a16adbd72a2).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.);
9776 if (ctx) {
9777 _sg_destroy_all_resourcescxx . . $ _sg_destroy_all_resources(8765eb4fc17703da).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.);
9778 _sg_destroy_contextcxx . . $ _sg_destroy_context(5fcb436f3d2e1e3f).(ctx);
9779 }
9780 }
9781 _sg_discard_backendcxx . . $ _sg_discard_backend(49f6e7a06ebc5aa8).();
9782 _sg_discard_poolscxx . . $ _sg_discard_pools(464348b3c1da642).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools.);
9783 _sgcxx . . $ _sg..validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
9784 }
9785
9786 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sg_isvalidcxx . . $ sg_isvalid(c9857a73d68e59ba).(void) {
9787 return _sgcxx . . $ _sg..validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#valid.;
9788 }
9789
9790 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_desccxx . . $ sg_desc# sg_query_desccxx . . $ sg_query_desc(2e490c611a485da0).(void) {
9791 return _sgcxx . . $ _sg..desccxx . . $ $anonymous_type_ded6a5455d648ef8_26#desc.;
9792 }
9793
9794 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_backendcxx . . $ sg_backend# sg_query_backendcxx . . $ sg_query_backend(4679d869a1a56231).(void) {
9795 #if defined(SOKOL_GLCORE33cxx . . $ `demo/sokol/sokol.h:2:9`!)
9796 return SG_BACKEND_GLCORE33cxx . . $ SG_BACKEND_GLCORE33.;
9797 #elif defined(SOKOL_GLES2)
9798 return SG_BACKEND_GLES2;
9799 #elif defined(SOKOL_GLES3)
9800 return _sg.gl.gles2 ? SG_BACKEND_GLES2 : SG_BACKEND_GLES3;
9801 #elif defined(SOKOL_D3D11)
9802 return SG_BACKEND_D3D11;
9803 #elif defined(SOKOL_METAL)
9804 #if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
9805 return SG_BACKEND_METAL_MACOS;
9806 #else
9807 #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
9808 return SG_BACKEND_METAL_SIMULATOR;
9809 #else
9810 return SG_BACKEND_METAL_IOS;
9811 #endif
9812 #endif
9813 #elif defined(SOKOL_DUMMY_BACKEND)
9814 return SG_BACKEND_DUMMY;
9815 #endif
9816 }
9817
9818 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sg_query_featurecxx . . $ sg_query_feature(11c85d13deabec9).(sg_featurecxx . . $ sg_feature# f) {
9819 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! res = _sg_query_featurecxx . . $ _sg_query_feature(11c85d13deabec9).(f);
9820 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(query_feature, f, res);
9821 return res;
9822 }
9823
9824 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_contextcxx . . $ sg_context# sg_setup_contextcxx . . $ sg_setup_context(ac4049b755bec9ae).(void) {
9825 sg_contextcxx . . $ sg_context# res;
9826 int slot_index = _sg_pool_alloc_indexcxx . . $ _sg_pool_alloc_index(13b35af250726afc).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool.);
9827 if (_SG_INVALID_SLOT_INDEXcxx . . $ `demo/sokol/sokol_gfx.h:2790:9`! != slot_index) {
9828 res.idcxx . . $ sg_context#id. = _sg_slot_alloccxx . . $ _sg_slot_alloc(98d2e81a10b84bd8).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool., &_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..contextscxx . . $ $anonymous_type_ded6a5455d648ef8_24#contexts.[slot_index].slotcxx . . $ $anonymous_type_ded6a5455d648ef8_18#slot., slot_index);
9829 _sg_context_tcxx . . $ _sg_context_t#* ctx = _sg_context_atcxx . . $ _sg_context_at(f2667a16adbd72a2).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., res.idcxx . . $ sg_context#id.);
9830 ctx->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_18#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = _sg_create_contextcxx . . $ _sg_create_context(d8db2a13df6d6f41).(ctx);
9831 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ctx->slot.state == SG_RESOURCESTATE_VALID);
9832 _sg_activate_contextcxx . . $ _sg_activate_context(5fcb436f3d2e1e3f).(ctx);
9833 }
9834 else {
9835 /* pool is exhausted */
9836 res.idcxx . . $ sg_context#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9837 }
9838 _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context. = res;
9839 return res;
9840 }
9841
9842 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_discard_contextcxx . . $ sg_discard_context(2d55baf387590aaf).(sg_contextcxx . . $ sg_context# ctx_id) {
9843 _sg_destroy_all_resourcescxx . . $ _sg_destroy_all_resources(8765eb4fc17703da).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., ctx_id.idcxx . . $ sg_context#id.);
9844 _sg_context_tcxx . . $ _sg_context_t#* ctx = _sg_lookup_contextcxx . . $ _sg_lookup_context(f2667a16adbd72a2).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., ctx_id.idcxx . . $ sg_context#id.);
9845 if (ctx) {
9846 _sg_destroy_contextcxx . . $ _sg_destroy_context(5fcb436f3d2e1e3f).(ctx);
9847 _sg_reset_contextcxx . . $ _sg_reset_context(5fcb436f3d2e1e3f).(ctx);
9848 _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..context_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#context_pool., _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(ctx_id.idcxx . . $ sg_context#id.));
9849 }
9850 _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
9851 _sg_activate_contextcxx . . $ _sg_activate_context(5fcb436f3d2e1e3f).(0);
9852 }
9853
9854 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_activate_contextcxx . . $ sg_activate_context(2d55baf387590aaf).(sg_contextcxx . . $ sg_context# ctx_id) {
9855 _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context. = ctx_id;
9856 _sg_context_tcxx . . $ _sg_context_t#* ctx = _sg_lookup_contextcxx . . $ _sg_lookup_context(f2667a16adbd72a2).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., ctx_id.idcxx . . $ sg_context#id.);
9857 /* NOTE: ctx can be 0 here if the context is no longer valid */
9858 _sg_activate_contextcxx . . $ _sg_activate_context(5fcb436f3d2e1e3f).(ctx);
9859 }
9860
9861 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_trace_hookscxx . . $ sg_trace_hooks# sg_install_trace_hookscxx . . $ sg_install_trace_hooks(1f7eed8ce62baf44).(const sg_trace_hookscxx . . $ sg_trace_hooks#* trace_hooks) {
9862 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(trace_hooks);
9863 #if defined(SOKOL_TRACE_HOOKS)
9864 sg_trace_hooks old_hooks = _sg.hooks;
9865 _sg.hooks = *trace_hooks;
9866 #else
9867 static sg_trace_hookscxx . . $ sg_trace_hooks# old_hooks;
9868 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("sg_install_trace_hooks() called, but SG_TRACE_HOOKS is not defined!");
9869 #endif
9870 return old_hooks;
9871 }
9872
9873 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_buffercxx . . $ sg_buffer# sg_alloc_buffercxx . . $ sg_alloc_buffer(210aeac7c490d744).(void) {
9874 sg_buffercxx . . $ sg_buffer# res = _sg_alloc_buffercxx . . $ _sg_alloc_buffer(210aeac7c490d744).();
9875 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(alloc_buffer, res);
9876 return res;
9877 }
9878
9879 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_imagecxx . . $ sg_image# sg_alloc_imagecxx . . $ sg_alloc_image(c32329c31f7bd9e9).(void) {
9880 sg_imagecxx . . $ sg_image# res = _sg_alloc_imagecxx . . $ _sg_alloc_image(c32329c31f7bd9e9).();
9881 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(alloc_image, res);
9882 return res;
9883 }
9884
9885 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_shadercxx . . $ sg_shader# sg_alloc_shadercxx . . $ sg_alloc_shader(eddf85115a913590).(void) {
9886 sg_shadercxx . . $ sg_shader# res = _sg_alloc_shadercxx . . $ _sg_alloc_shader(eddf85115a913590).();
9887 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(alloc_shader, res);
9888 return res;
9889 }
9890
9891 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_pipelinecxx . . $ sg_pipeline# sg_alloc_pipelinecxx . . $ sg_alloc_pipeline(4d9e1c814ee6f037).(void) {
9892 sg_pipelinecxx . . $ sg_pipeline# res = _sg_alloc_pipelinecxx . . $ _sg_alloc_pipeline(4d9e1c814ee6f037).();
9893 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(alloc_pipeline, res);
9894 return res;
9895 }
9896
9897 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_passcxx . . $ sg_pass# sg_alloc_passcxx . . $ sg_alloc_pass(8fa2722a10bdd7a8).(void) {
9898 sg_passcxx . . $ sg_pass# res = _sg_alloc_passcxx . . $ _sg_alloc_pass(8fa2722a10bdd7a8).();
9899 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(alloc_pass, res);
9900 return res;
9901 }
9902
9903 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_init_buffercxx . . $ sg_init_buffer(199f42cf0ce34e9e).(sg_buffercxx . . $ sg_buffer# buf_id, const sg_buffer_desccxx . . $ sg_buffer_desc#* desc) {
9904 sg_buffer_desccxx . . $ sg_buffer_desc# desc_def = _sg_buffer_desc_defaultscxx . . $ _sg_buffer_desc_defaults(d4885e173a5d1258).(desc);
9905 _sg_init_buffercxx . . $ _sg_init_buffer(199f42cf0ce34e9e).(buf_id, &desc_def);
9906 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(init_buffer, buf_id, &desc_def);
9907 }
9908
9909 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_init_imagecxx . . $ sg_init_image(b9ac7bf4077bbc85).(sg_imagecxx . . $ sg_image# img_id, const sg_image_desccxx . . $ sg_image_desc#* desc) {
9910 sg_image_desccxx . . $ sg_image_desc# desc_def = _sg_image_desc_defaultscxx . . $ _sg_image_desc_defaults(64e07389429933b6).(desc);
9911 _sg_init_imagecxx . . $ _sg_init_image(b9ac7bf4077bbc85).(img_id, &desc_def);
9912 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(init_image, img_id, &desc_def);
9913 }
9914
9915 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_init_shadercxx . . $ sg_init_shader(ffec3585d8638365).(sg_shadercxx . . $ sg_shader# shd_id, const sg_shader_desccxx . . $ sg_shader_desc#* desc) {
9916 sg_shader_desccxx . . $ sg_shader_desc# desc_def = _sg_shader_desc_defaultscxx . . $ _sg_shader_desc_defaults(d0f46a51a54240b4).(desc);
9917 _sg_init_shadercxx . . $ _sg_init_shader(ffec3585d8638365).(shd_id, &desc_def);
9918 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(init_shader, shd_id, &desc_def);
9919 }
9920
9921 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_init_pipelinecxx . . $ sg_init_pipeline(92596deeb42817ed).(sg_pipelinecxx . . $ sg_pipeline# pip_id, const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc) {
9922 sg_pipeline_desccxx . . $ sg_pipeline_desc# desc_def = _sg_pipeline_desc_defaultscxx . . $ _sg_pipeline_desc_defaults(549abcde1cf96b9d).(desc);
9923 _sg_init_pipelinecxx . . $ _sg_init_pipeline(92596deeb42817ed).(pip_id, &desc_def);
9924 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(init_pipeline, pip_id, &desc_def);
9925 }
9926
9927 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_init_passcxx . . $ sg_init_pass(5bf38153cc347fdc).(sg_passcxx . . $ sg_pass# pass_id, const sg_pass_desccxx . . $ sg_pass_desc#* desc) {
9928 sg_pass_desccxx . . $ sg_pass_desc# desc_def = _sg_pass_desc_defaultscxx . . $ _sg_pass_desc_defaults(684617f2b81c1bcf).(desc);
9929 _sg_init_passcxx . . $ _sg_init_pass(5bf38153cc347fdc).(pass_id, &desc_def);
9930 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(init_pass, pass_id, &desc_def);
9931 }
9932
9933 /*-- set allocated resource to failed state ----------------------------------*/
9934 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_fail_buffercxx . . $ sg_fail_buffer(73b2a9b74a436b7).(sg_buffercxx . . $ sg_buffer# buf_id) {
9935 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf_id.id != SG_INVALID_ID);
9936 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
9937 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf && buf->slot.state == SG_RESOURCESTATE_ALLOC);
9938 buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9939 buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9940 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(fail_buffer, buf_id);
9941 }
9942
9943 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_fail_imagecxx . . $ sg_fail_image(a131ac04d927795).(sg_imagecxx . . $ sg_image# img_id) {
9944 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img_id.id != SG_INVALID_ID);
9945 _sg_image_tcxx . . $ _sg_image_t#* img = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., img_id.idcxx . . $ sg_image#id.);
9946 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img && img->slot.state == SG_RESOURCESTATE_ALLOC);
9947 img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9948 img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9949 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(fail_image, img_id);
9950 }
9951
9952 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_fail_shadercxx . . $ sg_fail_shader(c05267500f0c2b7f).(sg_shadercxx . . $ sg_shader# shd_id) {
9953 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd_id.id != SG_INVALID_ID);
9954 _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., shd_id.idcxx . . $ sg_shader#id.);
9955 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(shd && shd->slot.state == SG_RESOURCESTATE_ALLOC);
9956 shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9957 shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9958 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(fail_shader, shd_id);
9959 }
9960
9961 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_fail_pipelinecxx . . $ sg_fail_pipeline(fa06e78c216ede9c).(sg_pipelinecxx . . $ sg_pipeline# pip_id) {
9962 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip_id.id != SG_INVALID_ID);
9963 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pip_id.idcxx . . $ sg_pipeline#id.);
9964 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip && pip->slot.state == SG_RESOURCESTATE_ALLOC);
9965 pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9966 pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9967 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(fail_pipeline, pip_id);
9968 }
9969
9970 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_fail_passcxx . . $ sg_fail_pass(f6b4b2e9b04024b9).(sg_passcxx . . $ sg_pass# pass_id) {
9971 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass_id.id != SG_INVALID_ID);
9972 _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pass_id.idcxx . . $ sg_pass#id.);
9973 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass && pass->slot.state == SG_RESOURCESTATE_ALLOC);
9974 pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. = _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.;
9975 pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. = SG_RESOURCESTATE_FAILEDcxx . . $ SG_RESOURCESTATE_FAILED.;
9976 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(fail_pass, pass_id);
9977 }
9978
9979 /*-- get resource state */
9980 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_resource_statecxx . . $ sg_resource_state# sg_query_buffer_statecxx . . $ sg_query_buffer_state(66712bcf7f99879d).(sg_buffercxx . . $ sg_buffer# buf_id) {
9981 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
9982 sg_resource_statecxx . . $ sg_resource_state# res = buf ? buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. : SG_RESOURCESTATE_INVALIDcxx . . $ SG_RESOURCESTATE_INVALID.;
9983 return res;
9984 }
9985
9986 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_resource_statecxx . . $ sg_resource_state# sg_query_image_statecxx . . $ sg_query_image_state(551db7248109e594).(sg_imagecxx . . $ sg_image# img_id) {
9987 _sg_image_tcxx . . $ _sg_image_t#* img = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., img_id.idcxx . . $ sg_image#id.);
9988 sg_resource_statecxx . . $ sg_resource_state# res = img ? img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. : SG_RESOURCESTATE_INVALIDcxx . . $ SG_RESOURCESTATE_INVALID.;
9989 return res;
9990 }
9991
9992 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_resource_statecxx . . $ sg_resource_state# sg_query_shader_statecxx . . $ sg_query_shader_state(646759dfe832451c).(sg_shadercxx . . $ sg_shader# shd_id) {
9993 _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., shd_id.idcxx . . $ sg_shader#id.);
9994 sg_resource_statecxx . . $ sg_resource_state# res = shd ? shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. : SG_RESOURCESTATE_INVALIDcxx . . $ SG_RESOURCESTATE_INVALID.;
9995 return res;
9996 }
9997
9998 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_resource_statecxx . . $ sg_resource_state# sg_query_pipeline_statecxx . . $ sg_query_pipeline_state(f86b3dec1f91b880).(sg_pipelinecxx . . $ sg_pipeline# pip_id) {
9999 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pip_id.idcxx . . $ sg_pipeline#id.);
10000 sg_resource_statecxx . . $ sg_resource_state# res = pip ? pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. : SG_RESOURCESTATE_INVALIDcxx . . $ SG_RESOURCESTATE_INVALID.;
10001 return res;
10002 }
10003
10004 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_resource_statecxx . . $ sg_resource_state# sg_query_pass_statecxx . . $ sg_query_pass_state(f0dc53719bffbf1a).(sg_passcxx . . $ sg_pass# pass_id) {
10005 _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pass_id.idcxx . . $ sg_pass#id.);
10006 sg_resource_statecxx . . $ sg_resource_state# res = pass ? pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. : SG_RESOURCESTATE_INVALIDcxx . . $ SG_RESOURCESTATE_INVALID.;
10007 return res;
10008 }
10009
10010 /*-- allocate and initialize resource ----------------------------------------*/
10011 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_buffercxx . . $ sg_buffer# sg_make_buffercxx . . $ sg_make_buffer(5efb77b03fd1b393).(const sg_buffer_desccxx . . $ sg_buffer_desc#* desc) {
10012 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
10013 sg_buffer_desccxx . . $ sg_buffer_desc# desc_def = _sg_buffer_desc_defaultscxx . . $ _sg_buffer_desc_defaults(d4885e173a5d1258).(desc);
10014 sg_buffercxx . . $ sg_buffer# buf_id = _sg_alloc_buffercxx . . $ _sg_alloc_buffer(210aeac7c490d744).();
10015 if (buf_id.idcxx . . $ sg_buffer#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
10016 _sg_init_buffercxx . . $ _sg_init_buffer(199f42cf0ce34e9e).(buf_id, &desc_def);
10017 }
10018 else {
10019 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("buffer pool exhausted!");
10020 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_buffer_pool_exhausted);
10021 }
10022 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(make_buffer, &desc_def, buf_id);
10023 return buf_id;
10024 }
10025
10026 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_imagecxx . . $ sg_image# sg_make_imagecxx . . $ sg_make_image(50a18bf9177d92a4).(const sg_image_desccxx . . $ sg_image_desc#* desc) {
10027 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
10028 sg_image_desccxx . . $ sg_image_desc# desc_def = _sg_image_desc_defaultscxx . . $ _sg_image_desc_defaults(64e07389429933b6).(desc);
10029 sg_imagecxx . . $ sg_image# img_id = _sg_alloc_imagecxx . . $ _sg_alloc_image(c32329c31f7bd9e9).();
10030 if (img_id.idcxx . . $ sg_image#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
10031 _sg_init_imagecxx . . $ _sg_init_image(b9ac7bf4077bbc85).(img_id, &desc_def);
10032 }
10033 else {
10034 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("image pool exhausted!");
10035 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_image_pool_exhausted);
10036 }
10037 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(make_image, &desc_def, img_id);
10038 return img_id;
10039 }
10040
10041 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_shadercxx . . $ sg_shader# sg_make_shadercxx . . $ sg_make_shader(ab0d6bdcaa5aceeb).(const sg_shader_desccxx . . $ sg_shader_desc#* desc) {
10042 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
10043 sg_shader_desccxx . . $ sg_shader_desc# desc_def = _sg_shader_desc_defaultscxx . . $ _sg_shader_desc_defaults(d0f46a51a54240b4).(desc);
10044 sg_shadercxx . . $ sg_shader# shd_id = _sg_alloc_shadercxx . . $ _sg_alloc_shader(eddf85115a913590).();
10045 if (shd_id.idcxx . . $ sg_shader#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
10046 _sg_init_shadercxx . . $ _sg_init_shader(ffec3585d8638365).(shd_id, &desc_def);
10047 }
10048 else {
10049 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("shader pool exhausted!");
10050 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_shader_pool_exhausted);
10051 }
10052 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(make_shader, &desc_def, shd_id);
10053 return shd_id;
10054 }
10055
10056 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_pipelinecxx . . $ sg_pipeline# sg_make_pipelinecxx . . $ sg_make_pipeline(6e5e446a35687b83).(const sg_pipeline_desccxx . . $ sg_pipeline_desc#* desc) {
10057 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
10058 sg_pipeline_desccxx . . $ sg_pipeline_desc# desc_def = _sg_pipeline_desc_defaultscxx . . $ _sg_pipeline_desc_defaults(549abcde1cf96b9d).(desc);
10059 sg_pipelinecxx . . $ sg_pipeline# pip_id = _sg_alloc_pipelinecxx . . $ _sg_alloc_pipeline(4d9e1c814ee6f037).();
10060 if (pip_id.idcxx . . $ sg_pipeline#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
10061 _sg_init_pipelinecxx . . $ _sg_init_pipeline(92596deeb42817ed).(pip_id, &desc_def);
10062 }
10063 else {
10064 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("pipeline pool exhausted!");
10065 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pipeline_pool_exhausted);
10066 }
10067 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(make_pipeline, &desc_def, pip_id);
10068 return pip_id;
10069 }
10070
10071 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_passcxx . . $ sg_pass# sg_make_passcxx . . $ sg_make_pass(73e6e246420afa25).(const sg_pass_desccxx . . $ sg_pass_desc#* desc) {
10072 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(desc);
10073 sg_pass_desccxx . . $ sg_pass_desc# desc_def = _sg_pass_desc_defaultscxx . . $ _sg_pass_desc_defaults(684617f2b81c1bcf).(desc);
10074 sg_passcxx . . $ sg_pass# pass_id = _sg_alloc_passcxx . . $ _sg_alloc_pass(8fa2722a10bdd7a8).();
10075 if (pass_id.idcxx . . $ sg_pass#id. != SG_INVALID_IDcxx . . $ SG_INVALID_ID.) {
10076 _sg_init_passcxx . . $ _sg_init_pass(5bf38153cc347fdc).(pass_id, &desc_def);
10077 }
10078 else {
10079 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("pass pool exhausted!");
10080 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_pool_exhausted);
10081 }
10082 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(make_pass, &desc_def, pass_id);
10083 return pass_id;
10084 }
10085
10086 /*-- destroy resource --------------------------------------------------------*/
10087 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_destroy_buffercxx . . $ sg_destroy_buffer(73b2a9b74a436b7).(sg_buffercxx . . $ sg_buffer# buf_id) {
10088 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(destroy_buffer, buf_id);
10089 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
10090 if (buf) {
10091 if (buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.) {
10092 _sg_destroy_buffercxx . . $ _sg_destroy_buffer(62c890c9336ae806).(buf);
10093 _sg_reset_buffercxx . . $ _sg_reset_buffer(62c890c9336ae806).(buf);
10094 _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..buffer_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#buffer_pool., _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(buf_id.idcxx . . $ sg_buffer#id.));
10095 }
10096 else {
10097 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("sg_destroy_buffer: active context mismatch (must be same as for creation)");
10098 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_context_mismatch);
10099 }
10100 }
10101 }
10102
10103 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_destroy_imagecxx . . $ sg_destroy_image(a131ac04d927795).(sg_imagecxx . . $ sg_image# img_id) {
10104 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(destroy_image, img_id);
10105 _sg_image_tcxx . . $ _sg_image_t#* img = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., img_id.idcxx . . $ sg_image#id.);
10106 if (img) {
10107 if (img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.) {
10108 _sg_destroy_imagecxx . . $ _sg_destroy_image(a39f7d26f6734857).(img);
10109 _sg_reset_imagecxx . . $ _sg_reset_image(a39f7d26f6734857).(img);
10110 _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..image_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#image_pool., _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(img_id.idcxx . . $ sg_image#id.));
10111 }
10112 else {
10113 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("sg_destroy_image: active context mismatch (must be same as for creation)");
10114 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_context_mismatch);
10115 }
10116 }
10117 }
10118
10119 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_destroy_shadercxx . . $ sg_destroy_shader(c05267500f0c2b7f).(sg_shadercxx . . $ sg_shader# shd_id) {
10120 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(destroy_shader, shd_id);
10121 _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., shd_id.idcxx . . $ sg_shader#id.);
10122 if (shd) {
10123 if (shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.) {
10124 _sg_destroy_shadercxx . . $ _sg_destroy_shader(c330990de8bee88b).(shd);
10125 _sg_reset_shadercxx . . $ _sg_reset_shader(c330990de8bee88b).(shd);
10126 _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..shader_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#shader_pool., _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(shd_id.idcxx . . $ sg_shader#id.));
10127 }
10128 else {
10129 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("sg_destroy_shader: active context mismatch (must be same as for creation)");
10130 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_context_mismatch);
10131 }
10132 }
10133 }
10134
10135 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_destroy_pipelinecxx . . $ sg_destroy_pipeline(fa06e78c216ede9c).(sg_pipelinecxx . . $ sg_pipeline# pip_id) {
10136 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(destroy_pipeline, pip_id);
10137 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pip_id.idcxx . . $ sg_pipeline#id.);
10138 if (pip) {
10139 if (pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.) {
10140 _sg_destroy_pipelinecxx . . $ _sg_destroy_pipeline(ead8d739235dacd3).(pip);
10141 _sg_reset_pipelinecxx . . $ _sg_reset_pipeline(ead8d739235dacd3).(pip);
10142 _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pipeline_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pipeline_pool., _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(pip_id.idcxx . . $ sg_pipeline#id.));
10143 }
10144 else {
10145 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("sg_destroy_pipeline: active context mismatch (must be same as for creation)");
10146 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_context_mismatch);
10147 }
10148 }
10149 }
10150
10151 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_destroy_passcxx . . $ sg_destroy_pass(f6b4b2e9b04024b9).(sg_passcxx . . $ sg_pass# pass_id) {
10152 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(destroy_pass, pass_id);
10153 _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pass_id.idcxx . . $ sg_pass#id.);
10154 if (pass) {
10155 if (pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id. == _sgcxx . . $ _sg..active_contextcxx . . $ $anonymous_type_ded6a5455d648ef8_26#active_context..idcxx . . $ sg_context#id.) {
10156 _sg_destroy_passcxx . . $ _sg_destroy_pass(eae344a76fb8d519).(pass);
10157 _sg_reset_passcxx . . $ _sg_reset_pass(eae344a76fb8d519).(pass);
10158 _sg_pool_free_indexcxx . . $ _sg_pool_free_index(5d8b2847f7c53527).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools..pass_poolcxx . . $ $anonymous_type_ded6a5455d648ef8_24#pass_pool., _sg_slot_indexcxx . . $ _sg_slot_index(4c679297bf94b9eb).(pass_id.idcxx . . $ sg_pass#id.));
10159 }
10160 else {
10161 SOKOL_LOGcxx . . $ `demo/sokol/sokol_app.h:768:17`!("sg_destroy_pass: active context mismatch (must be same as for creation)");
10162 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_context_mismatch);
10163 }
10164 }
10165 }
10166
10167 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_begin_default_passcxx . . $ sg_begin_default_pass(2956e7fd84f328a).(const sg_pass_actioncxx . . $ sg_pass_action#* pass_action, int width, int height) {
10168 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass_action);
10169 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((pass_action->_start_canary == 0) && (pass_action->_end_canary == 0));
10170 sg_pass_actioncxx . . $ sg_pass_action# pa;
10171 _sg_resolve_default_pass_actioncxx . . $ _sg_resolve_default_pass_action(634902845d50ab70).(pass_action, &pa);
10172 _sgcxx . . $ _sg..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pass..idcxx . . $ sg_pass#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
10173 _sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
10174 _sg_begin_passcxx . . $ _sg_begin_pass(473da010b9056ca5).(0, &pa, width, height);
10175 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(begin_default_pass, pass_action, width, height);
10176 }
10177
10178 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_begin_passcxx . . $ sg_begin_pass(99634fc39c654f7).(sg_passcxx . . $ sg_pass# pass_id, const sg_pass_actioncxx . . $ sg_pass_action#* pass_action) {
10179 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pass_action);
10180 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((pass_action->_start_canary == 0) && (pass_action->_end_canary == 0));
10181 _sgcxx . . $ _sg..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pass. = pass_id;
10182 _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pass_id.idcxx . . $ sg_pass#id.);
10183 if (pass && _sg_validate_begin_passcxx . . $ _sg_validate_begin_pass(e51fdeb5efe2d9a4).(pass)) {
10184 _sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
10185 sg_pass_actioncxx . . $ sg_pass_action# pa;
10186 _sg_resolve_default_pass_actioncxx . . $ _sg_resolve_default_pass_action(634902845d50ab70).(pass_action, &pa);
10187 const int w = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[0].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->widthcxx . . $ $anonymous_type_ded6a5455d648ef8_7#width.;
10188 const int h = pass->color_attscxx . . $ $anonymous_type_ded6a5455d648ef8_17#color_atts.[0].imagecxx . . $ $anonymous_type_ded6a5455d648ef8_16#image.->heightcxx . . $ $anonymous_type_ded6a5455d648ef8_7#height.;
10189 _sg_begin_passcxx . . $ _sg_begin_pass(473da010b9056ca5).(pass, &pa, w, h);
10190 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(begin_pass, pass_id, pass_action);
10191 }
10192 else {
10193 _sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10194 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10195 }
10196 }
10197
10198 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_viewportcxx . . $ sg_apply_viewport(d7a7761809021567).(int x, int y, int width, int height, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left) {
10199 if (!_sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.) {
10200 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10201 return;
10202 }
10203 _sg_apply_viewportcxx . . $ _sg_apply_viewport(d7a7761809021567).(x, y, width, height, origin_top_left);
10204 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(apply_viewport, x, y, width, height, origin_top_left);
10205 }
10206
10207 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_scissor_rectcxx . . $ sg_apply_scissor_rect(d7a7761809021567).(int x, int y, int width, int height, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! origin_top_left) {
10208 if (!_sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.) {
10209 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10210 return;
10211 }
10212 _sg_apply_scissor_rectcxx . . $ _sg_apply_scissor_rect(d7a7761809021567).(x, y, width, height, origin_top_left);
10213 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(apply_scissor_rect, x, y, width, height, origin_top_left);
10214 }
10215
10216 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_pipelinecxx . . $ sg_apply_pipeline(fa06e78c216ede9c).(sg_pipelinecxx . . $ sg_pipeline# pip_id) {
10217 _sgcxx . . $ _sg..bindings_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#bindings_valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10218 if (!_sg_validate_apply_pipelinecxx . . $ _sg_validate_apply_pipeline(a874b4146555fd8b).(pip_id)) {
10219 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10220 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_draw_invalid);
10221 return;
10222 }
10223 if (!_sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.) {
10224 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10225 return;
10226 }
10227 _sgcxx . . $ _sg..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pipeline. = pip_id;
10228 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pip_id.idcxx . . $ sg_pipeline#id.);
10229 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip);
10230 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. = (SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID. == pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.);
10231 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip->shader && (pip->shader->slot.id == pip->shader_id.id));
10232 _sg_apply_pipelinecxx . . $ _sg_apply_pipeline(ead8d739235dacd3).(pip);
10233 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(apply_pipeline, pip_id);
10234 }
10235
10236 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_bindingscxx . . $ sg_apply_bindings(5f6aac639b109626).(const sg_bindingscxx . . $ sg_bindings#* bindings) {
10237 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(bindings);
10238 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((bindings->_start_canary == 0) && (bindings->_end_canary==0));
10239 if (!_sg_validate_apply_bindingscxx . . $ _sg_validate_apply_bindings(8dcd324f91fa1fd6).(bindings)) {
10240 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10241 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_draw_invalid);
10242 return;
10243 }
10244 _sgcxx . . $ _sg..bindings_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#bindings_valid. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
10245
10246 _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., _sgcxx . . $ _sg..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pipeline..idcxx . . $ sg_pipeline#id.);
10247 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(pip);
10248
10249 _sg_buffer_tcxx . . $ _sg_buffer_t#* vbs[SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.] = { 0 };
10250 int num_vbs = 0;
10251 for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.; i++, num_vbs++) {
10252 if (bindings->vertex_bufferscxx . . $ sg_bindings#vertex_buffers.[i].idcxx . . $ sg_buffer#id.) {
10253 vbs[i] = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., bindings->vertex_bufferscxx . . $ sg_bindings#vertex_buffers.[i].idcxx . . $ sg_buffer#id.);
10254 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(vbs[i]);
10255 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. &= (SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID. == vbs[i]->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.);
10256 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. &= !vbs[i]->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow.;
10257 }
10258 else {
10259 break;
10260 }
10261 }
10262
10263 _sg_buffer_tcxx . . $ _sg_buffer_t#* ib = 0;
10264 if (bindings->index_buffercxx . . $ sg_bindings#index_buffer..idcxx . . $ sg_buffer#id.) {
10265 ib = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., bindings->index_buffercxx . . $ sg_bindings#index_buffer..idcxx . . $ sg_buffer#id.);
10266 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ib);
10267 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. &= (SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID. == ib->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.);
10268 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. &= !ib->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow.;
10269 }
10270
10271 _sg_image_tcxx . . $ _sg_image_t#* vs_imgs[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.] = { 0 };
10272 int num_vs_imgs = 0;
10273 for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.; i++, num_vs_imgs++) {
10274 if (bindings->vs_imagescxx . . $ sg_bindings#vs_images.[i].idcxx . . $ sg_image#id.) {
10275 vs_imgs[i] = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., bindings->vs_imagescxx . . $ sg_bindings#vs_images.[i].idcxx . . $ sg_image#id.);
10276 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(vs_imgs[i]);
10277 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. &= (SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID. == vs_imgs[i]->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.);
10278 }
10279 else {
10280 break;
10281 }
10282 }
10283
10284 _sg_image_tcxx . . $ _sg_image_t#* fs_imgs[SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.] = { 0 };
10285 int num_fs_imgs = 0;
10286 for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.; i++, num_fs_imgs++) {
10287 if (bindings->fs_imagescxx . . $ sg_bindings#fs_images.[i].idcxx . . $ sg_image#id.) {
10288 fs_imgs[i] = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., bindings->fs_imagescxx . . $ sg_bindings#fs_images.[i].idcxx . . $ sg_image#id.);
10289 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(fs_imgs[i]);
10290 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. &= (SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID. == fs_imgs[i]->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.);
10291 }
10292 else {
10293 break;
10294 }
10295 }
10296 if (_sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid.) {
10297 const int* vb_offsets = bindings->vertex_buffer_offsetscxx . . $ sg_bindings#vertex_buffer_offsets.;
10298 int ib_offset = bindings->index_buffer_offsetcxx . . $ sg_bindings#index_buffer_offset.;
10299 _sg_apply_bindingscxx . . $ _sg_apply_bindings(cf8aec0e05ceb70c).(pip, vbs, vb_offsets, num_vbs, ib, ib_offset, vs_imgs, num_vs_imgs, fs_imgs, num_fs_imgs);
10300 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(apply_bindings, bindings);
10301 }
10302 else {
10303 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_draw_invalid);
10304 }
10305 }
10306
10307 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_uniformscxx . . $ sg_apply_uniforms(d4a2e1eb7e556ec4).(sg_shader_stagecxx . . $ sg_shader_stage# stage, int ub_index, const void* data, int num_bytes) {
10308 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((stage == SG_SHADERSTAGE_VS) || (stage == SG_SHADERSTAGE_FS));
10309 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((ub_index >= 0) && (ub_index < SG_MAX_SHADERSTAGE_UBS));
10310 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(data && (num_bytes > 0));
10311 if (!_sg_validate_apply_uniformscxx . . $ _sg_validate_apply_uniforms(10acfc1af4314cca).(stage, ub_index, data, num_bytes)) {
10312 _sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10313 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_draw_invalid);
10314 return;
10315 }
10316 if (!_sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.) {
10317 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10318 return;
10319 }
10320 if (!_sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid.) {
10321 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_draw_invalid);
10322 }
10323 _sg_apply_uniformscxx . . $ _sg_apply_uniforms(d4a2e1eb7e556ec4).(stage, ub_index, data, num_bytes);
10324 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(apply_uniforms, stage, ub_index, data, num_bytes);
10325 }
10326
10327 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_drawcxx . . $ sg_draw(b1146eedae1e1d0b).(int base_element, int num_elements, int num_instances) {
10328 #if defined(SOKOL_DEBUG)
10329 if (!_sg.bindings_valid) {
10330 SOKOL_LOG("attempting to draw without resource bindings");
10331 }
10332 #endif
10333 if (!_sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.) {
10334 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10335 return;
10336 }
10337 if (!_sgcxx . . $ _sg..next_draw_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#next_draw_valid.) {
10338 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_draw_invalid);
10339 return;
10340 }
10341 if (!_sgcxx . . $ _sg..bindings_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#bindings_valid.) {
10342 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_bindings_invalid);
10343 return;
10344 }
10345 _sg_drawcxx . . $ _sg_draw(b1146eedae1e1d0b).(base_element, num_elements, num_instances);
10346 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(draw, base_element, num_elements, num_instances);
10347 }
10348
10349 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_end_passcxx . . $ sg_end_pass(49f6e7a06ebc5aa8).(void) {
10350 if (!_sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid.) {
10351 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(err_pass_invalid);
10352 return;
10353 }
10354 _sg_end_passcxx . . $ _sg_end_pass(49f6e7a06ebc5aa8).();
10355 _sgcxx . . $ _sg..cur_passcxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pass..idcxx . . $ sg_pass#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
10356 _sgcxx . . $ _sg..cur_pipelinecxx . . $ $anonymous_type_ded6a5455d648ef8_26#cur_pipeline..idcxx . . $ sg_pipeline#id. = SG_INVALID_IDcxx . . $ SG_INVALID_ID.;
10357 _sgcxx . . $ _sg..pass_validcxx . . $ $anonymous_type_ded6a5455d648ef8_26#pass_valid. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10358 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(end_pass);
10359 }
10360
10361 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_commitcxx . . $ sg_commit(49f6e7a06ebc5aa8).(void) {
10362 _sg_commitcxx . . $ _sg_commit(49f6e7a06ebc5aa8).();
10363 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(commit);
10364 _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.++;
10365 }
10366
10367 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_reset_state_cachecxx . . $ sg_reset_state_cache(49f6e7a06ebc5aa8).(void) {
10368 _sg_reset_state_cachecxx . . $ _sg_reset_state_cache(49f6e7a06ebc5aa8).();
10369 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(reset_state_cache);
10370 }
10371
10372 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_update_buffercxx . . $ sg_update_buffer(5c59391e5d00dba1).(sg_buffercxx . . $ sg_buffer# buf_id, const void* data, int num_bytes) {
10373 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
10374 if ((num_bytes > 0) && buf && (buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.)) {
10375 if (_sg_validate_update_buffercxx . . $ _sg_validate_update_buffer(2ef69afab8bc583c).(buf, data, num_bytes)) {
10376 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(num_bytes <= buf->size);
10377 /* only one update allowed per buffer and frame */
10378 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf->update_frame_index != _sg.frame_index);
10379 /* update and append on same buffer in same frame not allowed */
10380 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf->append_frame_index != _sg.frame_index);
10381 _sg_update_buffercxx . . $ _sg_update_buffer(51a9894585396fe3).(buf, data, num_bytes);
10382 buf->update_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#update_frame_index. = _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.;
10383 }
10384 }
10385 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(update_buffer, buf_id, data, num_bytes);
10386 }
10387
10388 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! int sg_append_buffercxx . . $ sg_append_buffer(78466a5fc0ca5d1e).(sg_buffercxx . . $ sg_buffer# buf_id, const void* data, int num_bytes) {
10389 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
10390 int result;
10391 if (buf) {
10392 /* rewind append cursor in a new frame */
10393 if (buf->append_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_frame_index. != _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.) {
10394 buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos. = 0;
10395 buf->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10396 }
10397 if ((buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos. + num_bytes) > buf->sizecxx . . $ $anonymous_type_ded6a5455d648ef8_6#size.) {
10398 buf->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
10399 }
10400 const int start_pos = buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos.;
10401 if (buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) {
10402 if (_sg_validate_append_buffercxx . . $ _sg_validate_append_buffer(2ef69afab8bc583c).(buf, data, num_bytes)) {
10403 if (!buf->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow. && (num_bytes > 0)) {
10404 /* update and append on same buffer in same frame not allowed */
10405 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(buf->update_frame_index != _sg.frame_index);
10406 _sg_append_buffercxx . . $ _sg_append_buffer(336344918ff6a016).(buf, data, num_bytes, buf->append_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_frame_index. != _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.);
10407 buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos. += num_bytes;
10408 buf->append_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_frame_index. = _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.;
10409 }
10410 }
10411 }
10412 result = start_pos;
10413 }
10414 else {
10415 /* FIXME: should we return -1 here? */
10416 result = 0;
10417 }
10418 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(append_buffer, buf_id, data, num_bytes, result);
10419 return result;
10420 }
10421
10422 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sg_query_buffer_overflowcxx . . $ sg_query_buffer_overflow(eb54ae0c35724bdb).(sg_buffercxx . . $ sg_buffer# buf_id) {
10423 _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
10424 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! result = buf ? buf->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow. : falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
10425 return result;
10426 }
10427
10428 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_update_imagecxx . . $ sg_update_image(27fab29f9732cff3).(sg_imagecxx . . $ sg_image# img_id, const sg_image_contentcxx . . $ sg_image_content#* data) {
10429 _sg_image_tcxx . . $ _sg_image_t#* img = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., img_id.idcxx . . $ sg_image#id.);
10430 if (img && img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state. == SG_RESOURCESTATE_VALIDcxx . . $ SG_RESOURCESTATE_VALID.) {
10431 if (_sg_validate_update_imagecxx . . $ _sg_validate_update_image(6dae974cbdd2fbfd).(img, data)) {
10432 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(img->upd_frame_index != _sg.frame_index);
10433 _sg_update_imagecxx . . $ _sg_update_image(547060eb9520162c).(img, data);
10434 img->upd_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_7#upd_frame_index. = _sgcxx . . $ _sg..frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_26#frame_index.;
10435 }
10436 }
10437 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(update_image, img_id, data);
10438 }
10439
10440 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_push_debug_groupcxx . . $ sg_push_debug_group(85c52e162fed56f9).(const char* name) {
10441 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(name);
10442 _SG_TRACE_ARGScxx . . $ `demo/sokol/sokol_gfx.h:1999:9`!(push_debug_group, name);
10443 }
10444
10445 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_pop_debug_groupcxx . . $ sg_pop_debug_group(49f6e7a06ebc5aa8).(void) {
10446 _SG_TRACE_NOARGScxx . . $ `demo/sokol/sokol_gfx.h:2000:9`!(pop_debug_group);
10447 }
10448
10449 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_buffer_infocxx . . $ sg_buffer_info# sg_query_buffer_infocxx . . $ sg_query_buffer_info(58b40c5336b41636).(sg_buffercxx . . $ sg_buffer# buf_id) {
10450 sg_buffer_infocxx . . $ sg_buffer_info# info;
10451 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&info, 0, sizeof(info));
10452 const _sg_buffer_tcxx . . $ _sg_buffer_t#* buf = _sg_lookup_buffercxx . . $ _sg_lookup_buffer(1bf69e7878de46de).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., buf_id.idcxx . . $ sg_buffer#id.);
10453 if (buf) {
10454 info.slotcxx . . $ sg_buffer_info#slot..statecxx . . $ sg_slot_info#state. = buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
10455 info.slotcxx . . $ sg_buffer_info#slot..res_idcxx . . $ sg_slot_info#res_id. = buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
10456 info.slotcxx . . $ sg_buffer_info#slot..ctx_idcxx . . $ sg_slot_info#ctx_id. = buf->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id.;
10457 info.update_frame_indexcxx . . $ sg_buffer_info#update_frame_index. = buf->update_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#update_frame_index.;
10458 info.append_frame_indexcxx . . $ sg_buffer_info#append_frame_index. = buf->append_frame_indexcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_frame_index.;
10459 info.append_poscxx . . $ sg_buffer_info#append_pos. = buf->append_poscxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_pos.;
10460 info.append_overflowcxx . . $ sg_buffer_info#append_overflow. = buf->append_overflowcxx . . $ $anonymous_type_ded6a5455d648ef8_6#append_overflow.;
10461 #if defined(SOKOL_D3D11)
10462 info.num_slots = 1;
10463 info.active_slot = 0;
10464 #else
10465 info.num_slotscxx . . $ sg_buffer_info#num_slots. = buf->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_6#num_slots.;
10466 info.active_slotcxx . . $ sg_buffer_info#active_slot. = buf->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_6#active_slot.;
10467 #endif
10468 }
10469 return info;
10470 }
10471
10472 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_image_infocxx . . $ sg_image_info# sg_query_image_infocxx . . $ sg_query_image_info(1621fed3a807c2b5).(sg_imagecxx . . $ sg_image# img_id) {
10473 sg_image_infocxx . . $ sg_image_info# info;
10474 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&info, 0, sizeof(info));
10475 const _sg_image_tcxx . . $ _sg_image_t#* img = _sg_lookup_imagecxx . . $ _sg_lookup_image(16f751d922939fe6).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., img_id.idcxx . . $ sg_image#id.);
10476 if (img) {
10477 info.slotcxx . . $ sg_image_info#slot..statecxx . . $ sg_slot_info#state. = img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
10478 info.slotcxx . . $ sg_image_info#slot..res_idcxx . . $ sg_slot_info#res_id. = img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
10479 info.slotcxx . . $ sg_image_info#slot..ctx_idcxx . . $ sg_slot_info#ctx_id. = img->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id.;
10480 #if defined(SOKOL_D3D11)
10481 info.num_slots = 1;
10482 info.active_slot = 0;
10483 #else
10484 info.num_slotscxx . . $ sg_image_info#num_slots. = img->num_slotscxx . . $ $anonymous_type_ded6a5455d648ef8_7#num_slots.;
10485 info.active_slotcxx . . $ sg_image_info#active_slot. = img->active_slotcxx . . $ $anonymous_type_ded6a5455d648ef8_7#active_slot.;
10486 #endif
10487 }
10488 return info;
10489 }
10490
10491 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_shader_infocxx . . $ sg_shader_info# sg_query_shader_infocxx . . $ sg_query_shader_info(ec2feb25917f4482).(sg_shadercxx . . $ sg_shader# shd_id) {
10492 sg_shader_infocxx . . $ sg_shader_info# info;
10493 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&info, 0, sizeof(info));
10494 const _sg_shader_tcxx . . $ _sg_shader_t#* shd = _sg_lookup_shadercxx . . $ _sg_lookup_shader(dc4288be9b8c0f4).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., shd_id.idcxx . . $ sg_shader#id.);
10495 if (shd) {
10496 info.slotcxx . . $ sg_shader_info#slot..statecxx . . $ sg_slot_info#state. = shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
10497 info.slotcxx . . $ sg_shader_info#slot..res_idcxx . . $ sg_slot_info#res_id. = shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
10498 info.slotcxx . . $ sg_shader_info#slot..ctx_idcxx . . $ sg_slot_info#ctx_id. = shd->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_13#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id.;
10499 }
10500 return info;
10501 }
10502
10503 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_pipeline_infocxx . . $ sg_pipeline_info# sg_query_pipeline_infocxx . . $ sg_query_pipeline_info(9302be6d1d2cb8fd).(sg_pipelinecxx . . $ sg_pipeline# pip_id) {
10504 sg_pipeline_infocxx . . $ sg_pipeline_info# info;
10505 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&info, 0, sizeof(info));
10506 const _sg_pipeline_tcxx . . $ _sg_pipeline_t#* pip = _sg_lookup_pipelinecxx . . $ _sg_lookup_pipeline(7e13595ced88d4d3).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pip_id.idcxx . . $ sg_pipeline#id.);
10507 if (pip) {
10508 info.slotcxx . . $ sg_pipeline_info#slot..statecxx . . $ sg_slot_info#state. = pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
10509 info.slotcxx . . $ sg_pipeline_info#slot..res_idcxx . . $ sg_slot_info#res_id. = pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
10510 info.slotcxx . . $ sg_pipeline_info#slot..ctx_idcxx . . $ sg_slot_info#ctx_id. = pip->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_15#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id.;
10511 }
10512 return info;
10513 }
10514
10515 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! sg_pass_infocxx . . $ sg_pass_info# sg_query_pass_infocxx . . $ sg_query_pass_info(cff05293a9a499e0).(sg_passcxx . . $ sg_pass# pass_id) {
10516 sg_pass_infocxx . . $ sg_pass_info# info;
10517 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&info, 0, sizeof(info));
10518 const _sg_pass_tcxx . . $ _sg_pass_t#* pass = _sg_lookup_passcxx . . $ _sg_lookup_pass(dc7c3142592aeadd).(&_sgcxx . . $ _sg..poolscxx . . $ $anonymous_type_ded6a5455d648ef8_26#pools., pass_id.idcxx . . $ sg_pass#id.);
10519 if (pass) {
10520 info.slotcxx . . $ sg_pass_info#slot..statecxx . . $ sg_slot_info#state. = pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..statecxx . . $ $anonymous_type_ded6a5455d648ef8_3#state.;
10521 info.slotcxx . . $ sg_pass_info#slot..res_idcxx . . $ sg_slot_info#res_id. = pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#id.;
10522 info.slotcxx . . $ sg_pass_info#slot..ctx_idcxx . . $ sg_slot_info#ctx_id. = pass->slotcxx . . $ $anonymous_type_ded6a5455d648ef8_17#slot..ctx_idcxx . . $ $anonymous_type_ded6a5455d648ef8_3#ctx_id.;
10523 }
10524 return info;
10525 }
10526
10527 /*--- DEPRECATED ---*/
10528 #ifndef SOKOL_NO_DEPRECATED
10529 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_draw_statecxx . . $ sg_apply_draw_state(d845a81d684dde96).(const sg_draw_statecxx . . $ sg_draw_state#* ds) {
10530 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!(ds);
10531 SOKOL_ASSERTcxx . . $ `demo/sokol/sokol_app.h:747:13`!((ds->_start_canary==0) && (ds->_end_canary==0));
10532 sg_apply_pipelinecxx . . $ sg_apply_pipeline(fa06e78c216ede9c).(ds->pipelinecxx . . $ sg_draw_state#pipeline.);
10533 sg_bindingscxx . . $ sg_bindings# bindings;
10534 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&bindings, 0, sizeof(bindings));
10535 for (int i = 0; i < SG_MAX_SHADERSTAGE_BUFFERScxx . . $ SG_MAX_SHADERSTAGE_BUFFERS.; i++) {
10536 bindings.vertex_bufferscxx . . $ sg_bindings#vertex_buffers.[i] = ds->vertex_bufferscxx . . $ sg_draw_state#vertex_buffers.[i];
10537 bindings.vertex_buffer_offsetscxx . . $ sg_bindings#vertex_buffer_offsets.[i] = ds->vertex_buffer_offsetscxx . . $ sg_draw_state#vertex_buffer_offsets.[i];
10538 }
10539 bindings.index_buffercxx . . $ sg_bindings#index_buffer. = ds->index_buffercxx . . $ sg_draw_state#index_buffer.;
10540 bindings.index_buffer_offsetcxx . . $ sg_bindings#index_buffer_offset. = ds->index_buffer_offsetcxx . . $ sg_draw_state#index_buffer_offset.;
10541 for (int i = 0; i < SG_MAX_SHADERSTAGE_IMAGEScxx . . $ SG_MAX_SHADERSTAGE_IMAGES.; i++) {
10542 bindings.vs_imagescxx . . $ sg_bindings#vs_images.[i] = ds->vs_imagescxx . . $ sg_draw_state#vs_images.[i];
10543 bindings.fs_imagescxx . . $ sg_bindings#fs_images.[i] = ds->fs_imagescxx . . $ sg_draw_state#fs_images.[i];
10544 }
10545 sg_apply_bindingscxx . . $ sg_apply_bindings(5f6aac639b109626).(&bindings);
10546 }
10547
10548 SOKOL_API_IMPLcxx . . $ `demo/sokol/sokol_app.h:738:13`! void sg_apply_uniform_blockcxx . . $ sg_apply_uniform_block(d4a2e1eb7e556ec4).(sg_shader_stagecxx . . $ sg_shader_stage# stage, int ub_index, const void* data, int num_bytes) {
10549 sg_apply_uniformscxx . . $ sg_apply_uniforms(d4a2e1eb7e556ec4).(stage, ub_index, data, num_bytes);
10550 }
10551 #endif
10552
10553 #ifdef _MSC_VER
10554 #pragma warning(pop)
10555 #endif
10556
10557 #endif /* SOKOL_IMPL */