SDL 3.0
SDL_gpu.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/* WIKI CATEGORY: GPU */
23
24/**
25 * # CategoryGPU
26 *
27 * The GPU API offers a cross-platform way for apps to talk to modern graphics
28 * hardware. It offers both 3D graphics and compute support, in the style of
29 * Metal, Vulkan, and Direct3D 12.
30 *
31 * A basic workflow might be something like this:
32 *
33 * The app creates a GPU device with SDL_CreateGPUDevice(), and assigns it to
34 * a window with SDL_ClaimWindowForGPUDevice()--although strictly speaking you
35 * can render offscreen entirely, perhaps for image processing, and not use a
36 * window at all.
37 *
38 * Next the app prepares static data (things that are created once and used
39 * over and over). For example:
40 *
41 * - Shaders (programs that run on the GPU): use SDL_CreateGPUShader().
42 * - Vertex buffers (arrays of geometry data) and other data rendering will
43 * need: use SDL_UploadToGPUBuffer().
44 * - Textures (images): use SDL_UploadToGPUTexture().
45 * - Samplers (how textures should be read from): use SDL_CreateGPUSampler().
46 * - Render pipelines (precalculated rendering state): use
47 * SDL_CreateGPUGraphicsPipeline()
48 *
49 * To render, the app creates one or more command buffers, with
50 * SDL_AcquireGPUCommandBuffer(). Command buffers collect rendering
51 * instructions that will be submitted to the GPU in batch. Complex scenes can
52 * use multiple command buffers, maybe configured across multiple threads in
53 * parallel, as long as they are submitted in the correct order, but many apps
54 * will just need one command buffer per frame.
55 *
56 * Rendering can happen to a texture (what other APIs call a "render target")
57 * or it can happen to the swapchain texture (which is just a special texture
58 * that represents a window's contents). The app can use
59 * SDL_AcquireGPUSwapchainTexture() to render to the window.
60 *
61 * Rendering actually happens in a Render Pass, which is encoded into a
62 * command buffer. One can encode multiple render passes (or alternate between
63 * render and compute passes) in a single command buffer, but many apps might
64 * simply need a single render pass in a single command buffer. Render Passes
65 * can render to up to four color textures and one depth texture
66 * simultaneously. If the set of textures being rendered to needs to change,
67 * the Render Pass must be ended and a new one must be begun.
68 *
69 * The app calls SDL_BeginGPURenderPass(). Then it sets states it needs for
70 * each draw:
71 *
72 * - SDL_BindGPUGraphicsPipeline()
73 * - SDL_SetGPUViewport()
74 * - SDL_BindGPUVertexBuffers()
75 * - SDL_BindGPUVertexSamplers()
76 * - etc
77 *
78 * Then, make the actual draw commands with these states:
79 *
80 * - SDL_DrawGPUPrimitives()
81 * - SDL_DrawGPUPrimitivesIndirect()
82 * - SDL_DrawGPUIndexedPrimitivesIndirect()
83 * - etc
84 *
85 * After all the drawing commands for a pass are complete, the app should call
86 * SDL_EndGPURenderPass(). Once a render pass ends all render-related state is
87 * reset.
88 *
89 * The app can begin new Render Passes and make new draws in the same command
90 * buffer until the entire scene is rendered.
91 *
92 * Once all of the render commands for the scene are complete, the app calls
93 * SDL_SubmitGPUCommandBuffer() to send it to the GPU for processing.
94 *
95 * If the app needs to read back data from texture or buffers, the API has an
96 * efficient way of doing this, provided that the app is willing to tolerate
97 * some latency. When the app uses SDL_DownloadFromGPUTexture() or
98 * SDL_DownloadFromGPUBuffer(), submitting the command buffer with
99 * SDL_SubmitGPUCommandBufferAndAcquireFence() will return a fence handle that
100 * the app can poll or wait on in a thread. Once the fence indicates that the
101 * command buffer is done processing, it is safe to read the downloaded data.
102 * Make sure to call SDL_ReleaseGPUFence() when done with the fence.
103 *
104 * The API also has "compute" support. The app calls SDL_BeginGPUComputePass()
105 * with compute-writeable textures and/or buffers, which can be written to in
106 * a compute shader. Then it sets states it needs for the compute dispatches:
107 *
108 * - SDL_BindGPUComputePipeline()
109 * - SDL_BindGPUComputeStorageBuffers()
110 * - SDL_BindGPUComputeStorageTextures()
111 *
112 * Then, dispatch compute work:
113 *
114 * - SDL_DispatchGPUCompute()
115 *
116 * For advanced users, this opens up powerful GPU-driven workflows.
117 *
118 * Graphics and compute pipelines require the use of shaders, which as
119 * mentioned above are small programs executed on the GPU. Each backend
120 * (Vulkan, Metal, D3D12) requires a different shader format. When the app
121 * creates the GPU device, the app lets the device know which shader formats
122 * the app can provide. It will then select the appropriate backend depending
123 * on the available shader formats and the backends available on the platform.
124 * When creating shaders, the app must provide the correct shader format for
125 * the selected backend. If you would like to learn more about why the API
126 * works this way, there is a detailed
127 * [blog post](https://moonside.games/posts/layers-all-the-way-down/)
128 * explaining this situation.
129 *
130 * It is optimal for apps to pre-compile the shader formats they might use,
131 * but for ease of use SDL provides a separate project,
132 * [SDL_shadercross](https://github.com/libsdl-org/SDL_shadercross)
133 * , for performing runtime shader cross-compilation.
134 *
135 * This is an extremely quick overview that leaves out several important
136 * details. Already, though, one can see that GPU programming can be quite
137 * complex! If you just need simple 2D graphics, the
138 * [Render API](https://wiki.libsdl.org/SDL3/CategoryRender)
139 * is much easier to use but still hardware-accelerated. That said, even for
140 * 2D applications the performance benefits and expressiveness of the GPU API
141 * are significant.
142 *
143 * The GPU API targets a feature set with a wide range of hardware support and
144 * ease of portability. It is designed so that the app won't have to branch
145 * itself by querying feature support. If you need cutting-edge features with
146 * limited hardware support, this API is probably not for you.
147 *
148 * Examples demonstrating proper usage of this API can be found
149 * [here](https://github.com/TheSpydog/SDL_gpu_examples)
150 * .
151 *
152 * ## FAQ
153 *
154 * **Question: When are you adding more advanced features, like ray tracing or
155 * mesh shaders?**
156 *
157 * Answer: We don't have immediate plans to add more bleeding-edge features,
158 * but we certainly might in the future, when these features prove worthwhile,
159 * and reasonable to implement across several platforms and underlying APIs.
160 * So while these things are not in the "never" category, they are definitely
161 * not "near future" items either.
162 */
163
164#ifndef SDL_gpu_h_
165#define SDL_gpu_h_
166
167#include <SDL3/SDL_stdinc.h>
168#include <SDL3/SDL_pixels.h>
169#include <SDL3/SDL_properties.h>
170#include <SDL3/SDL_rect.h>
171#include <SDL3/SDL_surface.h>
172#include <SDL3/SDL_video.h>
173
174#include <SDL3/SDL_begin_code.h>
175#ifdef __cplusplus
176extern "C" {
177#endif /* __cplusplus */
178
179/* Type Declarations */
180
181/**
182 * An opaque handle representing the SDL_GPU context.
183 *
184 * \since This struct is available since SDL 3.1.3
185 */
187
188/**
189 * An opaque handle representing a buffer.
190 *
191 * Used for vertices, indices, indirect draw commands, and general compute
192 * data.
193 *
194 * \since This struct is available since SDL 3.1.3
195 *
196 * \sa SDL_CreateGPUBuffer
197 * \sa SDL_SetGPUBufferName
198 * \sa SDL_UploadToGPUBuffer
199 * \sa SDL_DownloadFromGPUBuffer
200 * \sa SDL_CopyGPUBufferToBuffer
201 * \sa SDL_BindGPUVertexBuffers
202 * \sa SDL_BindGPUIndexBuffer
203 * \sa SDL_BindGPUVertexStorageBuffers
204 * \sa SDL_BindGPUFragmentStorageBuffers
205 * \sa SDL_DrawGPUPrimitivesIndirect
206 * \sa SDL_DrawGPUIndexedPrimitivesIndirect
207 * \sa SDL_BindGPUComputeStorageBuffers
208 * \sa SDL_DispatchGPUComputeIndirect
209 * \sa SDL_ReleaseGPUBuffer
210 */
212
213/**
214 * An opaque handle representing a transfer buffer.
215 *
216 * Used for transferring data to and from the device.
217 *
218 * \since This struct is available since SDL 3.1.3
219 *
220 * \sa SDL_CreateGPUTransferBuffer
221 * \sa SDL_MapGPUTransferBuffer
222 * \sa SDL_UnmapGPUTransferBuffer
223 * \sa SDL_UploadToGPUBuffer
224 * \sa SDL_UploadToGPUTexture
225 * \sa SDL_DownloadFromGPUBuffer
226 * \sa SDL_DownloadFromGPUTexture
227 * \sa SDL_ReleaseGPUTransferBuffer
228 */
230
231/**
232 * An opaque handle representing a texture.
233 *
234 * \since This struct is available since SDL 3.1.3
235 *
236 * \sa SDL_CreateGPUTexture
237 * \sa SDL_SetGPUTextureName
238 * \sa SDL_UploadToGPUTexture
239 * \sa SDL_DownloadFromGPUTexture
240 * \sa SDL_CopyGPUTextureToTexture
241 * \sa SDL_BindGPUVertexSamplers
242 * \sa SDL_BindGPUVertexStorageTextures
243 * \sa SDL_BindGPUFragmentSamplers
244 * \sa SDL_BindGPUFragmentStorageTextures
245 * \sa SDL_BindGPUComputeStorageTextures
246 * \sa SDL_GenerateMipmapsForGPUTexture
247 * \sa SDL_BlitGPUTexture
248 * \sa SDL_ReleaseGPUTexture
249 */
251
252/**
253 * An opaque handle representing a sampler.
254 *
255 * \since This struct is available since SDL 3.1.3
256 *
257 * \sa SDL_CreateGPUSampler
258 * \sa SDL_BindGPUVertexSamplers
259 * \sa SDL_BindGPUFragmentSamplers
260 * \sa SDL_ReleaseGPUSampler
261 */
263
264/**
265 * An opaque handle representing a compiled shader object.
266 *
267 * \since This struct is available since SDL 3.1.3
268 *
269 * \sa SDL_CreateGPUShader
270 * \sa SDL_CreateGPUGraphicsPipeline
271 * \sa SDL_ReleaseGPUShader
272 */
274
275/**
276 * An opaque handle representing a compute pipeline.
277 *
278 * Used during compute passes.
279 *
280 * \since This struct is available since SDL 3.1.3
281 *
282 * \sa SDL_CreateGPUComputePipeline
283 * \sa SDL_BindGPUComputePipeline
284 * \sa SDL_ReleaseGPUComputePipeline
285 */
287
288/**
289 * An opaque handle representing a graphics pipeline.
290 *
291 * Used during render passes.
292 *
293 * \since This struct is available since SDL 3.1.3
294 *
295 * \sa SDL_CreateGPUGraphicsPipeline
296 * \sa SDL_BindGPUGraphicsPipeline
297 * \sa SDL_ReleaseGPUGraphicsPipeline
298 */
300
301/**
302 * An opaque handle representing a command buffer.
303 *
304 * Most state is managed via command buffers. When setting state using a
305 * command buffer, that state is local to the command buffer.
306 *
307 * Commands only begin execution on the GPU once SDL_SubmitGPUCommandBuffer is
308 * called. Once the command buffer is submitted, it is no longer valid to use
309 * it.
310 *
311 * Command buffers are executed in submission order. If you submit command
312 * buffer A and then command buffer B all commands in A will begin executing
313 * before any command in B begins executing.
314 *
315 * In multi-threading scenarios, you should only access a command buffer on
316 * the thread you acquired it from.
317 *
318 * \since This struct is available since SDL 3.1.3
319 *
320 * \sa SDL_AcquireGPUCommandBuffer
321 * \sa SDL_SubmitGPUCommandBuffer
322 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
323 */
325
326/**
327 * An opaque handle representing a render pass.
328 *
329 * This handle is transient and should not be held or referenced after
330 * SDL_EndGPURenderPass is called.
331 *
332 * \since This struct is available since SDL 3.1.3
333 *
334 * \sa SDL_BeginGPURenderPass
335 * \sa SDL_EndGPURenderPass
336 */
338
339/**
340 * An opaque handle representing a compute pass.
341 *
342 * This handle is transient and should not be held or referenced after
343 * SDL_EndGPUComputePass is called.
344 *
345 * \since This struct is available since SDL 3.1.3
346 *
347 * \sa SDL_BeginGPUComputePass
348 * \sa SDL_EndGPUComputePass
349 */
351
352/**
353 * An opaque handle representing a copy pass.
354 *
355 * This handle is transient and should not be held or referenced after
356 * SDL_EndGPUCopyPass is called.
357 *
358 * \since This struct is available since SDL 3.1.3
359 *
360 * \sa SDL_BeginGPUCopyPass
361 * \sa SDL_EndGPUCopyPass
362 */
364
365/**
366 * An opaque handle representing a fence.
367 *
368 * \since This struct is available since SDL 3.1.3
369 *
370 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
371 * \sa SDL_QueryGPUFence
372 * \sa SDL_WaitForGPUFences
373 * \sa SDL_ReleaseGPUFence
374 */
376
377/**
378 * Specifies the primitive topology of a graphics pipeline.
379 *
380 * \since This enum is available since SDL 3.1.3
381 *
382 * \sa SDL_CreateGPUGraphicsPipeline
383 */
385{
386 SDL_GPU_PRIMITIVETYPE_TRIANGLELIST, /**< A series of separate triangles. */
387 SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP, /**< A series of connected triangles. */
388 SDL_GPU_PRIMITIVETYPE_LINELIST, /**< A series of separate lines. */
389 SDL_GPU_PRIMITIVETYPE_LINESTRIP, /**< A series of connected lines. */
390 SDL_GPU_PRIMITIVETYPE_POINTLIST /**< A series of separate points. */
392
393/**
394 * Specifies how the contents of a texture attached to a render pass are
395 * treated at the beginning of the render pass.
396 *
397 * \since This enum is available since SDL 3.1.3
398 *
399 * \sa SDL_BeginGPURenderPass
400 */
401typedef enum SDL_GPULoadOp
402{
403 SDL_GPU_LOADOP_LOAD, /**< The previous contents of the texture will be preserved. */
404 SDL_GPU_LOADOP_CLEAR, /**< The contents of the texture will be cleared to a color. */
405 SDL_GPU_LOADOP_DONT_CARE /**< The previous contents of the texture need not be preserved. The contents will be undefined. */
407
408/**
409 * Specifies how the contents of a texture attached to a render pass are
410 * treated at the end of the render pass.
411 *
412 * \since This enum is available since SDL 3.1.3
413 *
414 * \sa SDL_BeginGPURenderPass
415 */
416typedef enum SDL_GPUStoreOp
417{
418 SDL_GPU_STOREOP_STORE, /**< The contents generated during the render pass will be written to memory. */
419 SDL_GPU_STOREOP_DONT_CARE, /**< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */
420 SDL_GPU_STOREOP_RESOLVE, /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture may then be discarded and will be undefined. */
421 SDL_GPU_STOREOP_RESOLVE_AND_STORE /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture will be written to memory. */
423
424/**
425 * Specifies the size of elements in an index buffer.
426 *
427 * \since This enum is available since SDL 3.1.3
428 *
429 * \sa SDL_CreateGPUGraphicsPipeline
430 */
432{
433 SDL_GPU_INDEXELEMENTSIZE_16BIT, /**< The index elements are 16-bit. */
434 SDL_GPU_INDEXELEMENTSIZE_32BIT /**< The index elements are 32-bit. */
436
437/**
438 * Specifies the pixel format of a texture.
439 *
440 * Texture format support varies depending on driver, hardware, and usage
441 * flags. In general, you should use SDL_GPUTextureSupportsFormat to query if
442 * a format is supported before using it. However, there are a few guaranteed
443 * formats.
444 *
445 * FIXME: Check universal support for 32-bit component formats FIXME: Check
446 * universal support for SIMULTANEOUS_READ_WRITE
447 *
448 * For SAMPLER usage, the following formats are universally supported:
449 *
450 * - R8G8B8A8_UNORM
451 * - B8G8R8A8_UNORM
452 * - R8_UNORM
453 * - R8_SNORM
454 * - R8G8_UNORM
455 * - R8G8_SNORM
456 * - R8G8B8A8_SNORM
457 * - R16_FLOAT
458 * - R16G16_FLOAT
459 * - R16G16B16A16_FLOAT
460 * - R32_FLOAT
461 * - R32G32_FLOAT
462 * - R32G32B32A32_FLOAT
463 * - R11G11B10_UFLOAT
464 * - R8G8B8A8_UNORM_SRGB
465 * - B8G8R8A8_UNORM_SRGB
466 * - D16_UNORM
467 *
468 * For COLOR_TARGET usage, the following formats are universally supported:
469 *
470 * - R8G8B8A8_UNORM
471 * - B8G8R8A8_UNORM
472 * - R8_UNORM
473 * - R16_FLOAT
474 * - R16G16_FLOAT
475 * - R16G16B16A16_FLOAT
476 * - R32_FLOAT
477 * - R32G32_FLOAT
478 * - R32G32B32A32_FLOAT
479 * - R8_UINT
480 * - R8G8_UINT
481 * - R8G8B8A8_UINT
482 * - R16_UINT
483 * - R16G16_UINT
484 * - R16G16B16A16_UINT
485 * - R8_INT
486 * - R8G8_INT
487 * - R8G8B8A8_INT
488 * - R16_INT
489 * - R16G16_INT
490 * - R16G16B16A16_INT
491 * - R8G8B8A8_UNORM_SRGB
492 * - B8G8R8A8_UNORM_SRGB
493 *
494 * For STORAGE usages, the following formats are universally supported:
495 *
496 * - R8G8B8A8_UNORM
497 * - R8G8B8A8_SNORM
498 * - R16G16B16A16_FLOAT
499 * - R32_FLOAT
500 * - R32G32_FLOAT
501 * - R32G32B32A32_FLOAT
502 * - R8G8B8A8_UINT
503 * - R16G16B16A16_UINT
504 * - R8G8B8A8_INT
505 * - R16G16B16A16_INT
506 *
507 * For DEPTH_STENCIL_TARGET usage, the following formats are universally
508 * supported:
509 *
510 * - D16_UNORM
511 * - Either (but not necessarily both!) D24_UNORM or D32_SFLOAT
512 * - Either (but not necessarily both!) D24_UNORM_S8_UINT or
513 * D32_SFLOAT_S8_UINT
514 *
515 * Unless D16_UNORM is sufficient for your purposes, always check which of
516 * D24/D32 is supported before creating a depth-stencil texture!
517 *
518 * \since This enum is available since SDL 3.1.3
519 *
520 * \sa SDL_CreateGPUTexture
521 * \sa SDL_GPUTextureSupportsFormat
522 */
524{
526
527 /* Unsigned Normalized Float Color Formats */
540 /* Compressed Unsigned Normalized Float Color Formats */
547 /* Compressed Signed Float Color Formats */
549 /* Compressed Unsigned Float Color Formats */
551 /* Signed Normalized Float Color Formats */
558 /* Signed Float Color Formats */
565 /* Unsigned Float Color Formats */
567 /* Unsigned Integer Color Formats */
577 /* Signed Integer Color Formats */
587 /* SRGB Unsigned Normalized Color Formats */
590 /* Compressed SRGB Unsigned Normalized Color Formats */
595 /* Depth Formats */
601 /* Compressed ASTC Normalized Float Color Formats*/
616 /* Compressed SRGB ASTC Normalized Float Color Formats*/
631 /* Compressed ASTC Signed Float Color Formats*/
647
648/**
649 * Specifies how a texture is intended to be used by the client.
650 *
651 * A texture must have at least one usage flag. Note that some usage flag
652 * combinations are invalid.
653 *
654 * With regards to compute storage usage, READ | WRITE means that you can have
655 * shader A that only writes into the texture and shader B that only reads
656 * from the texture and bind the same texture to either shader respectively.
657 * SIMULTANEOUS means that you can do reads and writes within the same shader
658 * or compute pass. It also implies that atomic ops can be used, since those
659 * are read-modify-write operations. If you use SIMULTANEOUS, you are
660 * responsible for avoiding data races, as there is no data synchronization
661 * within a compute pass. Note that SIMULTANEOUS usage is only supported by a
662 * limited number of texture formats.
663 *
664 * \since This datatype is available since SDL 3.1.3
665 *
666 * \sa SDL_CreateGPUTexture
667 */
669
670#define SDL_GPU_TEXTUREUSAGE_SAMPLER (1u << 0) /**< Texture supports sampling. */
671#define SDL_GPU_TEXTUREUSAGE_COLOR_TARGET (1u << 1) /**< Texture is a color render target. */
672#define SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET (1u << 2) /**< Texture is a depth stencil target. */
673#define SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Texture supports storage reads in graphics stages. */
674#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Texture supports storage reads in the compute stage. */
675#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Texture supports storage writes in the compute stage. */
676#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE (1u << 6) /**< Texture supports reads and writes in the same compute shader. This is NOT equivalent to READ | WRITE. */
677
678/**
679 * Specifies the type of a texture.
680 *
681 * \since This enum is available since SDL 3.1.3
682 *
683 * \sa SDL_CreateGPUTexture
684 */
686{
687 SDL_GPU_TEXTURETYPE_2D, /**< The texture is a 2-dimensional image. */
688 SDL_GPU_TEXTURETYPE_2D_ARRAY, /**< The texture is a 2-dimensional array image. */
689 SDL_GPU_TEXTURETYPE_3D, /**< The texture is a 3-dimensional image. */
690 SDL_GPU_TEXTURETYPE_CUBE, /**< The texture is a cube image. */
691 SDL_GPU_TEXTURETYPE_CUBE_ARRAY /**< The texture is a cube array image. */
693
694/**
695 * Specifies the sample count of a texture.
696 *
697 * Used in multisampling. Note that this value only applies when the texture
698 * is used as a render target.
699 *
700 * \since This enum is available since SDL 3.1.3
701 *
702 * \sa SDL_CreateGPUTexture
703 * \sa SDL_GPUTextureSupportsSampleCount
704 */
706{
707 SDL_GPU_SAMPLECOUNT_1, /**< No multisampling. */
708 SDL_GPU_SAMPLECOUNT_2, /**< MSAA 2x */
709 SDL_GPU_SAMPLECOUNT_4, /**< MSAA 4x */
710 SDL_GPU_SAMPLECOUNT_8 /**< MSAA 8x */
712
713
714/**
715 * Specifies the face of a cube map.
716 *
717 * Can be passed in as the layer field in texture-related structs.
718 *
719 * \since This enum is available since SDL 3.1.3
720 */
730
731/**
732 * Specifies how a buffer is intended to be used by the client.
733 *
734 * A buffer must have at least one usage flag. Note that some usage flag
735 * combinations are invalid.
736 *
737 * Unlike textures, READ | WRITE can be used for simultaneous read-write
738 * usage. The same data synchronization concerns as textures apply.
739 *
740 * \since This datatype is available since SDL 3.1.3
741 *
742 * \sa SDL_CreateGPUBuffer
743 */
745
746#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */
747#define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */
748#define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */
749#define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */
750#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */
751#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */
752
753/**
754 * Specifies how a transfer buffer is intended to be used by the client.
755 *
756 * Note that mapping and copying FROM an upload transfer buffer or TO a
757 * download transfer buffer is undefined behavior.
758 *
759 * \since This enum is available since SDL 3.1.3
760 *
761 * \sa SDL_CreateGPUTransferBuffer
762 */
768
769/**
770 * Specifies which stage a shader program corresponds to.
771 *
772 * \since This enum is available since SDL 3.1.3
773 *
774 * \sa SDL_CreateGPUShader
775 */
781
782/**
783 * Specifies the format of shader code.
784 *
785 * Each format corresponds to a specific backend that accepts it.
786 *
787 * \since This datatype is available since SDL 3.1.3
788 *
789 * \sa SDL_CreateGPUShader
790 */
792
793#define SDL_GPU_SHADERFORMAT_INVALID 0
794#define SDL_GPU_SHADERFORMAT_PRIVATE (1u << 0) /**< Shaders for NDA'd platforms. */
795#define SDL_GPU_SHADERFORMAT_SPIRV (1u << 1) /**< SPIR-V shaders for Vulkan. */
796#define SDL_GPU_SHADERFORMAT_DXBC (1u << 2) /**< DXBC SM5_1 shaders for D3D12. */
797#define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL SM6_0 shaders for D3D12. */
798#define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */
799#define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */
800
801/**
802 * Specifies the format of a vertex attribute.
803 *
804 * \since This enum is available since SDL 3.1.3
805 *
806 * \sa SDL_CreateGPUGraphicsPipeline
807 */
809{
811
812 /* 32-bit Signed Integers */
817
818 /* 32-bit Unsigned Integers */
823
824 /* 32-bit Floats */
829
830 /* 8-bit Signed Integers */
833
834 /* 8-bit Unsigned Integers */
837
838 /* 8-bit Signed Normalized */
841
842 /* 8-bit Unsigned Normalized */
845
846 /* 16-bit Signed Integers */
849
850 /* 16-bit Unsigned Integers */
853
854 /* 16-bit Signed Normalized */
857
858 /* 16-bit Unsigned Normalized */
861
862 /* 16-bit Floats */
866
867/**
868 * Specifies the rate at which vertex attributes are pulled from buffers.
869 *
870 * \since This enum is available since SDL 3.1.3
871 *
872 * \sa SDL_CreateGPUGraphicsPipeline
873 */
875{
876 SDL_GPU_VERTEXINPUTRATE_VERTEX, /**< Attribute addressing is a function of the vertex index. */
877 SDL_GPU_VERTEXINPUTRATE_INSTANCE /**< Attribute addressing is a function of the instance index. */
879
880/**
881 * Specifies the fill mode of the graphics pipeline.
882 *
883 * \since This enum is available since SDL 3.1.3
884 *
885 * \sa SDL_CreateGPUGraphicsPipeline
886 */
887typedef enum SDL_GPUFillMode
888{
889 SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */
890 SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */
892
893/**
894 * Specifies the facing direction in which triangle faces will be culled.
895 *
896 * \since This enum is available since SDL 3.1.3
897 *
898 * \sa SDL_CreateGPUGraphicsPipeline
899 */
900typedef enum SDL_GPUCullMode
901{
902 SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */
903 SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */
904 SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */
906
907/**
908 * Specifies the vertex winding that will cause a triangle to be determined to
909 * be front-facing.
910 *
911 * \since This enum is available since SDL 3.1.3
912 *
913 * \sa SDL_CreateGPUGraphicsPipeline
914 */
916{
917 SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */
918 SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */
920
921/**
922 * Specifies a comparison operator for depth, stencil and sampler operations.
923 *
924 * \since This enum is available since SDL 3.1.3
925 *
926 * \sa SDL_CreateGPUGraphicsPipeline
927 */
929{
931 SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */
932 SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */
933 SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */
934 SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */
935 SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */
936 SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */
937 SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evalutes reference >= test. */
938 SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */
940
941/**
942 * Specifies what happens to a stored stencil value if stencil tests fail or
943 * pass.
944 *
945 * \since This enum is available since SDL 3.1.3
946 *
947 * \sa SDL_CreateGPUGraphicsPipeline
948 */
950{
952 SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */
953 SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */
954 SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */
955 SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */
956 SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */
957 SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */
958 SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */
959 SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */
961
962/**
963 * Specifies the operator to be used when pixels in a render target are
964 * blended with existing pixels in the texture.
965 *
966 * The source color is the value written by the fragment shader. The
967 * destination color is the value currently existing in the texture.
968 *
969 * \since This enum is available since SDL 3.1.3
970 *
971 * \sa SDL_CreateGPUGraphicsPipeline
972 */
973typedef enum SDL_GPUBlendOp
974{
976 SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */
977 SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */
978 SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */
979 SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */
980 SDL_GPU_BLENDOP_MAX /**< max(source, destination) */
982
983/**
984 * Specifies a blending factor to be used when pixels in a render target are
985 * blended with existing pixels in the texture.
986 *
987 * The source color is the value written by the fragment shader. The
988 * destination color is the value currently existing in the texture.
989 *
990 * \since This enum is available since SDL 3.1.3
991 *
992 * \sa SDL_CreateGPUGraphicsPipeline
993 */
1011
1012/**
1013 * Specifies which color components are written in a graphics pipeline.
1014 *
1015 * \since This datatype is available since SDL 3.1.3
1016 *
1017 * \sa SDL_CreateGPUGraphicsPipeline
1018 */
1020
1021#define SDL_GPU_COLORCOMPONENT_R (1u << 0) /**< the red component */
1022#define SDL_GPU_COLORCOMPONENT_G (1u << 1) /**< the green component */
1023#define SDL_GPU_COLORCOMPONENT_B (1u << 2) /**< the blue component */
1024#define SDL_GPU_COLORCOMPONENT_A (1u << 3) /**< the alpha component */
1025
1026/**
1027 * Specifies a filter operation used by a sampler.
1028 *
1029 * \since This enum is available since SDL 3.1.3
1030 *
1031 * \sa SDL_CreateGPUSampler
1032 */
1033typedef enum SDL_GPUFilter
1034{
1035 SDL_GPU_FILTER_NEAREST, /**< Point filtering. */
1036 SDL_GPU_FILTER_LINEAR /**< Linear filtering. */
1038
1039/**
1040 * Specifies a mipmap mode used by a sampler.
1041 *
1042 * \since This enum is available since SDL 3.1.3
1043 *
1044 * \sa SDL_CreateGPUSampler
1045 */
1051
1052/**
1053 * Specifies behavior of texture sampling when the coordinates exceed the 0-1
1054 * range.
1055 *
1056 * \since This enum is available since SDL 3.1.3
1057 *
1058 * \sa SDL_CreateGPUSampler
1059 */
1061{
1062 SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */
1063 SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */
1064 SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */
1066
1067/**
1068 * Specifies the timing that will be used to present swapchain textures to the
1069 * OS.
1070 *
1071 * VSYNC mode will always be supported. IMMEDIATE and MAILBOX modes may not be
1072 * supported on certain systems.
1073 *
1074 * It is recommended to query SDL_WindowSupportsGPUPresentMode after claiming
1075 * the window if you wish to change the present mode to IMMEDIATE or MAILBOX.
1076 *
1077 * - VSYNC: Waits for vblank before presenting. No tearing is possible. If
1078 * there is a pending image to present, the new image is enqueued for
1079 * presentation. Disallows tearing at the cost of visual latency.
1080 * - IMMEDIATE: Immediately presents. Lowest latency option, but tearing may
1081 * occur.
1082 * - MAILBOX: Waits for vblank before presenting. No tearing is possible. If
1083 * there is a pending image to present, the pending image is replaced by the
1084 * new image. Similar to VSYNC, but with reduced visual latency.
1085 *
1086 * \since This enum is available since SDL 3.1.3
1087 *
1088 * \sa SDL_SetGPUSwapchainParameters
1089 * \sa SDL_WindowSupportsGPUPresentMode
1090 * \sa SDL_AcquireGPUSwapchainTexture
1091 */
1098
1099/**
1100 * Specifies the texture format and colorspace of the swapchain textures.
1101 *
1102 * SDR will always be supported. Other compositions may not be supported on
1103 * certain systems.
1104 *
1105 * It is recommended to query SDL_WindowSupportsGPUSwapchainComposition after
1106 * claiming the window if you wish to change the swapchain composition from
1107 * SDR.
1108 *
1109 * - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in nonlinear sRGB
1110 * encoding.
1111 * - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are in
1112 * nonlinear sRGB encoding.
1113 * - HDR_EXTENDED_LINEAR: R16G16B16A16_SFLOAT swapchain. Pixel values are in
1114 * extended linear encoding.
1115 * - HDR10_ST2048: A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in
1116 * PQ ST2048 encoding.
1117 *
1118 * \since This enum is available since SDL 3.1.3
1119 *
1120 * \sa SDL_SetGPUSwapchainParameters
1121 * \sa SDL_WindowSupportsGPUSwapchainComposition
1122 * \sa SDL_AcquireGPUSwapchainTexture
1123 */
1131
1132/* Structures */
1133
1134/**
1135 * A structure specifying a viewport.
1136 *
1137 * \since This struct is available since SDL 3.1.3
1138 *
1139 * \sa SDL_SetGPUViewport
1140 */
1141typedef struct SDL_GPUViewport
1142{
1143 float x; /**< The left offset of the viewport. */
1144 float y; /**< The top offset of the viewport. */
1145 float w; /**< The width of the viewport. */
1146 float h; /**< The height of the viewport. */
1147 float min_depth; /**< The minimum depth of the viewport. */
1148 float max_depth; /**< The maximum depth of the viewport. */
1150
1151/**
1152 * A structure specifying parameters related to transferring data to or from a
1153 * texture.
1154 *
1155 * \since This struct is available since SDL 3.1.3
1156 *
1157 * \sa SDL_UploadToGPUTexture
1158 * \sa SDL_DownloadFromGPUTexture
1159 */
1161{
1162 SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */
1163 Uint32 offset; /**< The starting byte of the image data in the transfer buffer. */
1164 Uint32 pixels_per_row; /**< The number of pixels from one row to the next. */
1165 Uint32 rows_per_layer; /**< The number of rows from one layer/depth-slice to the next. */
1167
1168/**
1169 * A structure specifying a location in a transfer buffer.
1170 *
1171 * Used when transferring buffer data to or from a transfer buffer.
1172 *
1173 * \since This struct is available since SDL 3.1.3
1174 *
1175 * \sa SDL_UploadToGPUBuffer
1176 * \sa SDL_DownloadFromGPUBuffer
1177 */
1179{
1180 SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */
1181 Uint32 offset; /**< The starting byte of the buffer data in the transfer buffer. */
1183
1184/**
1185 * A structure specifying a location in a texture.
1186 *
1187 * Used when copying data from one texture to another.
1188 *
1189 * \since This struct is available since SDL 3.1.3
1190 *
1191 * \sa SDL_CopyGPUTextureToTexture
1192 */
1194{
1195 SDL_GPUTexture *texture; /**< The texture used in the copy operation. */
1196 Uint32 mip_level; /**< The mip level index of the location. */
1197 Uint32 layer; /**< The layer index of the location. */
1198 Uint32 x; /**< The left offset of the location. */
1199 Uint32 y; /**< The top offset of the location. */
1200 Uint32 z; /**< The front offset of the location. */
1202
1203/**
1204 * A structure specifying a region of a texture.
1205 *
1206 * Used when transferring data to or from a texture.
1207 *
1208 * \since This struct is available since SDL 3.1.3
1209 *
1210 * \sa SDL_UploadToGPUTexture
1211 * \sa SDL_DownloadFromGPUTexture
1212 */
1214{
1215 SDL_GPUTexture *texture; /**< The texture used in the copy operation. */
1216 Uint32 mip_level; /**< The mip level index to transfer. */
1217 Uint32 layer; /**< The layer index to transfer. */
1218 Uint32 x; /**< The left offset of the region. */
1219 Uint32 y; /**< The top offset of the region. */
1220 Uint32 z; /**< The front offset of the region. */
1221 Uint32 w; /**< The width of the region. */
1222 Uint32 h; /**< The height of the region. */
1223 Uint32 d; /**< The depth of the region. */
1225
1226/**
1227 * A structure specifying a region of a texture used in the blit operation.
1228 *
1229 * \since This struct is available since SDL 3.1.3
1230 *
1231 * \sa SDL_BlitGPUTexture
1232 */
1233typedef struct SDL_GPUBlitRegion
1234{
1235 SDL_GPUTexture *texture; /**< The texture. */
1236 Uint32 mip_level; /**< The mip level index of the region. */
1237 Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */
1238 Uint32 x; /**< The left offset of the region. */
1239 Uint32 y; /**< The top offset of the region. */
1240 Uint32 w; /**< The width of the region. */
1241 Uint32 h; /**< The height of the region. */
1243
1244/**
1245 * A structure specifying a location in a buffer.
1246 *
1247 * Used when copying data between buffers.
1248 *
1249 * \since This struct is available since SDL 3.1.3
1250 *
1251 * \sa SDL_CopyGPUBufferToBuffer
1252 */
1254{
1255 SDL_GPUBuffer *buffer; /**< The buffer. */
1256 Uint32 offset; /**< The starting byte within the buffer. */
1258
1259/**
1260 * A structure specifying a region of a buffer.
1261 *
1262 * Used when transferring data to or from buffers.
1263 *
1264 * \since This struct is available since SDL 3.1.3
1265 *
1266 * \sa SDL_UploadToGPUBuffer
1267 * \sa SDL_DownloadFromGPUBuffer
1268 */
1270{
1271 SDL_GPUBuffer *buffer; /**< The buffer. */
1272 Uint32 offset; /**< The starting byte within the buffer. */
1273 Uint32 size; /**< The size in bytes of the region. */
1275
1276/**
1277 * A structure specifying the parameters of an indirect draw command.
1278 *
1279 * Note that the `first_vertex` and `first_instance` parameters are NOT
1280 * compatible with built-in vertex/instance ID variables in shaders (for
1281 * example, SV_VertexID). If your shader depends on these variables, the
1282 * correlating draw call parameter MUST be 0.
1283 *
1284 * \since This struct is available since SDL 3.1.3
1285 *
1286 * \sa SDL_DrawGPUPrimitivesIndirect
1287 */
1289{
1290 Uint32 num_vertices; /**< The number of vertices to draw. */
1291 Uint32 num_instances; /**< The number of instances to draw. */
1292 Uint32 first_vertex; /**< The index of the first vertex to draw. */
1293 Uint32 first_instance; /**< The ID of the first instance to draw. */
1295
1296/**
1297 * A structure specifying the parameters of an indexed indirect draw command.
1298 *
1299 * Note that the `first_vertex` and `first_instance` parameters are NOT
1300 * compatible with built-in vertex/instance ID variables in shaders (for
1301 * example, SV_VertexID). If your shader depends on these variables, the
1302 * correlating draw call parameter MUST be 0.
1303 *
1304 * \since This struct is available since SDL 3.1.3
1305 *
1306 * \sa SDL_DrawGPUIndexedPrimitivesIndirect
1307 */
1309{
1310 Uint32 num_indices; /**< The number of indices to draw per instance. */
1311 Uint32 num_instances; /**< The number of instances to draw. */
1312 Uint32 first_index; /**< The base index within the index buffer. */
1313 Sint32 vertex_offset; /**< The value added to the vertex index before indexing into the vertex buffer. */
1314 Uint32 first_instance; /**< The ID of the first instance to draw. */
1316
1317/**
1318 * A structure specifying the parameters of an indexed dispatch command.
1319 *
1320 * \since This struct is available since SDL 3.1.3
1321 *
1322 * \sa SDL_DispatchGPUComputeIndirect
1323 */
1325{
1326 Uint32 groupcount_x; /**< The number of local workgroups to dispatch in the X dimension. */
1327 Uint32 groupcount_y; /**< The number of local workgroups to dispatch in the Y dimension. */
1328 Uint32 groupcount_z; /**< The number of local workgroups to dispatch in the Z dimension. */
1330
1331/* State structures */
1332
1333/**
1334 * A structure specifying the parameters of a sampler.
1335 *
1336 * \since This function is available since SDL 3.1.3
1337 *
1338 * \sa SDL_CreateGPUSampler
1339 */
1341{
1342 SDL_GPUFilter min_filter; /**< The minification filter to apply to lookups. */
1343 SDL_GPUFilter mag_filter; /**< The magnification filter to apply to lookups. */
1344 SDL_GPUSamplerMipmapMode mipmap_mode; /**< The mipmap filter to apply to lookups. */
1345 SDL_GPUSamplerAddressMode address_mode_u; /**< The addressing mode for U coordinates outside [0, 1). */
1346 SDL_GPUSamplerAddressMode address_mode_v; /**< The addressing mode for V coordinates outside [0, 1). */
1347 SDL_GPUSamplerAddressMode address_mode_w; /**< The addressing mode for W coordinates outside [0, 1). */
1348 float mip_lod_bias; /**< The bias to be added to mipmap LOD calculation. */
1349 float max_anisotropy; /**< The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored. */
1350 SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */
1351 float min_lod; /**< Clamps the minimum of the computed LOD value. */
1352 float max_lod; /**< Clamps the maximum of the computed LOD value. */
1353 bool enable_anisotropy; /**< true to enable anisotropic filtering. */
1354 bool enable_compare; /**< true to enable comparison against a reference value during lookups. */
1357
1358 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1360
1361/**
1362 * A structure specifying the parameters of vertex buffers used in a graphics
1363 * pipeline.
1364 *
1365 * When you call SDL_BindGPUVertexBuffers, you specify the binding slots of
1366 * the vertex buffers. For example if you called SDL_BindGPUVertexBuffers with
1367 * a first_slot of 2 and num_bindings of 3, the binding slots 2, 3, 4 would be
1368 * used by the vertex buffers you pass in.
1369 *
1370 * Vertex attributes are linked to buffers via the buffer_slot field of
1371 * SDL_GPUVertexAttribute. For example, if an attribute has a buffer_slot of
1372 * 0, then that attribute belongs to the vertex buffer bound at slot 0.
1373 *
1374 * \since This struct is available since SDL 3.1.3
1375 *
1376 * \sa SDL_GPUVertexAttribute
1377 * \sa SDL_GPUVertexInputState
1378 */
1380{
1381 Uint32 slot; /**< The binding slot of the vertex buffer. */
1382 Uint32 pitch; /**< The byte pitch between consecutive elements of the vertex buffer. */
1383 SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */
1384 Uint32 instance_step_rate; /**< The number of instances to draw using the same per-instance data before advancing in the instance buffer by one element. Ignored unless input_rate is SDL_GPU_VERTEXINPUTRATE_INSTANCE */
1386
1387/**
1388 * A structure specifying a vertex attribute.
1389 *
1390 * All vertex attribute locations provided to an SDL_GPUVertexInputState must
1391 * be unique.
1392 *
1393 * \since This struct is available since SDL 3.1.3
1394 *
1395 * \sa SDL_GPUVertexBufferDescription
1396 * \sa SDL_GPUVertexInputState
1397 */
1399{
1400 Uint32 location; /**< The shader input location index. */
1401 Uint32 buffer_slot; /**< The binding slot of the associated vertex buffer. */
1402 SDL_GPUVertexElementFormat format; /**< The size and type of the attribute data. */
1403 Uint32 offset; /**< The byte offset of this attribute relative to the start of the vertex element. */
1405
1406/**
1407 * A structure specifying the parameters of a graphics pipeline vertex input
1408 * state.
1409 *
1410 * \since This struct is available since SDL 3.1.3
1411 *
1412 * \sa SDL_GPUGraphicsPipelineCreateInfo
1413 */
1415{
1416 const SDL_GPUVertexBufferDescription *vertex_buffer_descriptions; /**< A pointer to an array of vertex buffer descriptions. */
1417 Uint32 num_vertex_buffers; /**< The number of vertex buffer descriptions in the above array. */
1418 const SDL_GPUVertexAttribute *vertex_attributes; /**< A pointer to an array of vertex attribute descriptions. */
1419 Uint32 num_vertex_attributes; /**< The number of vertex attribute descriptions in the above array. */
1421
1422/**
1423 * A structure specifying the stencil operation state of a graphics pipeline.
1424 *
1425 * \since This struct is available since SDL 3.1.3
1426 *
1427 * \sa SDL_GPUDepthStencilState
1428 */
1430{
1431 SDL_GPUStencilOp fail_op; /**< The action performed on samples that fail the stencil test. */
1432 SDL_GPUStencilOp pass_op; /**< The action performed on samples that pass the depth and stencil tests. */
1433 SDL_GPUStencilOp depth_fail_op; /**< The action performed on samples that pass the stencil test and fail the depth test. */
1434 SDL_GPUCompareOp compare_op; /**< The comparison operator used in the stencil test. */
1436
1437/**
1438 * A structure specifying the blend state of a color target.
1439 *
1440 * \since This struct is available since SDL 3.1.3
1441 *
1442 * \sa SDL_GPUColorTargetDescription
1443 */
1445{
1446 SDL_GPUBlendFactor src_color_blendfactor; /**< The value to be multiplied by the source RGB value. */
1447 SDL_GPUBlendFactor dst_color_blendfactor; /**< The value to be multiplied by the destination RGB value. */
1448 SDL_GPUBlendOp color_blend_op; /**< The blend operation for the RGB components. */
1449 SDL_GPUBlendFactor src_alpha_blendfactor; /**< The value to be multiplied by the source alpha. */
1450 SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */
1451 SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */
1452 SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */
1453 bool enable_blend; /**< Whether blending is enabled for the color target. */
1454 bool enable_color_write_mask; /**< Whether the color write mask is enabled. */
1458
1459
1460/**
1461 * A structure specifying code and metadata for creating a shader object.
1462 *
1463 * \since This struct is available since SDL 3.1.3
1464 *
1465 * \sa SDL_CreateGPUShader
1466 */
1468{
1469 size_t code_size; /**< The size in bytes of the code pointed to. */
1470 const Uint8 *code; /**< A pointer to shader code. */
1471 const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */
1472 SDL_GPUShaderFormat format; /**< The format of the shader code. */
1473 SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */
1474 Uint32 num_samplers; /**< The number of samplers defined in the shader. */
1475 Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */
1476 Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */
1477 Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */
1478
1479 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1481
1482/**
1483 * A structure specifying the parameters of a texture.
1484 *
1485 * Usage flags can be bitwise OR'd together for combinations of usages. Note
1486 * that certain usage combinations are invalid, for example SAMPLER and
1487 * GRAPHICS_STORAGE.
1488 *
1489 * \since This struct is available since SDL 3.1.3
1490 *
1491 * \sa SDL_CreateGPUTexture
1492 */
1494{
1495 SDL_GPUTextureType type; /**< The base dimensionality of the texture. */
1496 SDL_GPUTextureFormat format; /**< The pixel format of the texture. */
1497 SDL_GPUTextureUsageFlags usage; /**< How the texture is intended to be used by the client. */
1498 Uint32 width; /**< The width of the texture. */
1499 Uint32 height; /**< The height of the texture. */
1500 Uint32 layer_count_or_depth; /**< The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. */
1501 Uint32 num_levels; /**< The number of mip levels in the texture. */
1502 SDL_GPUSampleCount sample_count; /**< The number of samples per texel. Only applies if the texture is used as a render target. */
1503
1504 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1506
1507#define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r"
1508#define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT "SDL.gpu.createtexture.d3d12.clear.g"
1509#define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT "SDL.gpu.createtexture.d3d12.clear.b"
1510#define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT "SDL.gpu.createtexture.d3d12.clear.a"
1511#define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.createtexture.d3d12.clear.depth"
1512#define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8 "SDL.gpu.createtexture.d3d12.clear.stencil"
1513
1514/**
1515 * A structure specifying the parameters of a buffer.
1516 *
1517 * Usage flags can be bitwise OR'd together for combinations of usages. Note
1518 * that certain combinations are invalid, for example VERTEX and INDEX.
1519 *
1520 * \since This struct is available since SDL 3.1.3
1521 *
1522 * \sa SDL_CreateGPUBuffer
1523 */
1525{
1526 SDL_GPUBufferUsageFlags usage; /**< How the buffer is intended to be used by the client. */
1527 Uint32 size; /**< The size in bytes of the buffer. */
1528
1529 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1531
1532/**
1533 * A structure specifying the parameters of a transfer buffer.
1534 *
1535 * \since This struct is available since SDL 3.1.3
1536 *
1537 * \sa SDL_CreateGPUTransferBuffer
1538 */
1540{
1541 SDL_GPUTransferBufferUsage usage; /**< How the transfer buffer is intended to be used by the client. */
1542 Uint32 size; /**< The size in bytes of the transfer buffer. */
1543
1544 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1546
1547/* Pipeline state structures */
1548
1549/**
1550 * A structure specifying the parameters of the graphics pipeline rasterizer
1551 * state.
1552 *
1553 * NOTE: Some backend APIs (D3D11/12) will enable depth clamping even if
1554 * enable_depth_clip is true. If you rely on this clamp+clip behavior,
1555 * consider enabling depth clip and then manually clamping depth in your
1556 * fragment shaders on Metal and Vulkan.
1557 *
1558 * \since This struct is available since SDL 3.1.3
1559 *
1560 * \sa SDL_GPUGraphicsPipelineCreateInfo
1561 */
1563{
1564 SDL_GPUFillMode fill_mode; /**< Whether polygons will be filled in or drawn as lines. */
1565 SDL_GPUCullMode cull_mode; /**< The facing direction in which triangles will be culled. */
1566 SDL_GPUFrontFace front_face; /**< The vertex winding that will cause a triangle to be determined as front-facing. */
1567 float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */
1568 float depth_bias_clamp; /**< The maximum depth bias of a fragment. */
1569 float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */
1570 bool enable_depth_bias; /**< true to bias fragment depth values. */
1571 bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */
1575
1576/**
1577 * A structure specifying the parameters of the graphics pipeline multisample
1578 * state.
1579 *
1580 * \since This struct is available since SDL 3.1.3
1581 *
1582 * \sa SDL_GPUGraphicsPipelineCreateInfo
1583 */
1585{
1586 SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */
1587 Uint32 sample_mask; /**< Determines which samples get updated in the render targets. Treated as 0xFFFFFFFF if enable_mask is false. */
1588 bool enable_mask; /**< Enables sample masking. */
1593
1594/**
1595 * A structure specifying the parameters of the graphics pipeline depth
1596 * stencil state.
1597 *
1598 * \since This struct is available since SDL 3.1.3
1599 *
1600 * \sa SDL_GPUGraphicsPipelineCreateInfo
1601 */
1603{
1604 SDL_GPUCompareOp compare_op; /**< The comparison operator used for depth testing. */
1605 SDL_GPUStencilOpState back_stencil_state; /**< The stencil op state for back-facing triangles. */
1606 SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */
1607 Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */
1608 Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */
1609 bool enable_depth_test; /**< true enables the depth test. */
1610 bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */
1611 bool enable_stencil_test; /**< true enables the stencil test. */
1616
1617/**
1618 * A structure specifying the parameters of color targets used in a graphics
1619 * pipeline.
1620 *
1621 * \since This struct is available since SDL 3.1.3
1622 *
1623 * \sa SDL_GPUGraphicsPipelineTargetInfo
1624 */
1626{
1627 SDL_GPUTextureFormat format; /**< The pixel format of the texture to be used as a color target. */
1628 SDL_GPUColorTargetBlendState blend_state; /**< The blend state to be used for the color target. */
1630
1631/**
1632 * A structure specifying the descriptions of render targets used in a
1633 * graphics pipeline.
1634 *
1635 * \since This struct is available since SDL 3.1.3
1636 *
1637 * \sa SDL_GPUGraphicsPipelineCreateInfo
1638 */
1640{
1641 const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */
1642 Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */
1643 SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */
1644 bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */
1649
1650/**
1651 * A structure specifying the parameters of a graphics pipeline state.
1652 *
1653 * \since This struct is available since SDL 3.1.3
1654 *
1655 * \sa SDL_CreateGPUGraphicsPipeline
1656 */
1658{
1659 SDL_GPUShader *vertex_shader; /**< The vertex shader used by the graphics pipeline. */
1660 SDL_GPUShader *fragment_shader; /**< The fragment shader used by the graphics pipeline. */
1661 SDL_GPUVertexInputState vertex_input_state; /**< The vertex layout of the graphics pipeline. */
1662 SDL_GPUPrimitiveType primitive_type; /**< The primitive topology of the graphics pipeline. */
1663 SDL_GPURasterizerState rasterizer_state; /**< The rasterizer state of the graphics pipeline. */
1664 SDL_GPUMultisampleState multisample_state; /**< The multisample state of the graphics pipeline. */
1665 SDL_GPUDepthStencilState depth_stencil_state; /**< The depth-stencil state of the graphics pipeline. */
1666 SDL_GPUGraphicsPipelineTargetInfo target_info; /**< Formats and blend modes for the render targets of the graphics pipeline. */
1667
1668 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1670
1671/**
1672 * A structure specifying the parameters of a compute pipeline state.
1673 *
1674 * \since This struct is available since SDL 3.1.3
1675 *
1676 * \sa SDL_CreateGPUComputePipeline
1677 */
1679{
1680 size_t code_size; /**< The size in bytes of the compute shader code pointed to. */
1681 const Uint8 *code; /**< A pointer to compute shader code. */
1682 const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */
1683 SDL_GPUShaderFormat format; /**< The format of the compute shader code. */
1684 Uint32 num_samplers; /**< The number of samplers defined in the shader. */
1685 Uint32 num_readonly_storage_textures; /**< The number of readonly storage textures defined in the shader. */
1686 Uint32 num_readonly_storage_buffers; /**< The number of readonly storage buffers defined in the shader. */
1687 Uint32 num_readwrite_storage_textures; /**< The number of read-write storage textures defined in the shader. */
1688 Uint32 num_readwrite_storage_buffers; /**< The number of read-write storage buffers defined in the shader. */
1689 Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */
1690 Uint32 threadcount_x; /**< The number of threads in the X dimension. This should match the value in the shader. */
1691 Uint32 threadcount_y; /**< The number of threads in the Y dimension. This should match the value in the shader. */
1692 Uint32 threadcount_z; /**< The number of threads in the Z dimension. This should match the value in the shader. */
1693
1694 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1696
1697/**
1698 * A structure specifying the parameters of a color target used by a render
1699 * pass.
1700 *
1701 * The load_op field determines what is done with the texture at the beginning
1702 * of the render pass.
1703 *
1704 * - LOAD: Loads the data currently in the texture. Not recommended for
1705 * multisample textures as it requires significant memory bandwidth.
1706 * - CLEAR: Clears the texture to a single color.
1707 * - DONT_CARE: The driver will do whatever it wants with the texture memory.
1708 * This is a good option if you know that every single pixel will be touched
1709 * in the render pass.
1710 *
1711 * The store_op field determines what is done with the color results of the
1712 * render pass.
1713 *
1714 * - STORE: Stores the results of the render pass in the texture. Not
1715 * recommended for multisample textures as it requires significant memory
1716 * bandwidth.
1717 * - DONT_CARE: The driver will do whatever it wants with the texture memory.
1718 * This is often a good option for depth/stencil textures.
1719 * - RESOLVE: Resolves a multisample texture into resolve_texture, which must
1720 * have a sample count of 1. Then the driver may discard the multisample
1721 * texture memory. This is the most performant method of resolving a
1722 * multisample target.
1723 * - RESOLVE_AND_STORE: Resolves a multisample texture into the
1724 * resolve_texture, which must have a sample count of 1. Then the driver
1725 * stores the multisample texture's contents. Not recommended as it requires
1726 * significant memory bandwidth.
1727 *
1728 * \since This struct is available since SDL 3.1.3
1729 *
1730 * \sa SDL_BeginGPURenderPass
1731 */
1733{
1734 SDL_GPUTexture *texture; /**< The texture that will be used as a color target by a render pass. */
1735 Uint32 mip_level; /**< The mip level to use as a color target. */
1736 Uint32 layer_or_depth_plane; /**< The layer index or depth plane to use as a color target. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */
1737 SDL_FColor clear_color; /**< The color to clear the color target to at the start of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */
1738 SDL_GPULoadOp load_op; /**< What is done with the contents of the color target at the beginning of the render pass. */
1739 SDL_GPUStoreOp store_op; /**< What is done with the results of the render pass. */
1740 SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */
1741 Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */
1742 Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */
1743 bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */
1744 bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */
1748
1749/**
1750 * A structure specifying the parameters of a depth-stencil target used by a
1751 * render pass.
1752 *
1753 * The load_op field determines what is done with the depth contents of the
1754 * texture at the beginning of the render pass.
1755 *
1756 * - LOAD: Loads the depth values currently in the texture.
1757 * - CLEAR: Clears the texture to a single depth.
1758 * - DONT_CARE: The driver will do whatever it wants with the memory. This is
1759 * a good option if you know that every single pixel will be touched in the
1760 * render pass.
1761 *
1762 * The store_op field determines what is done with the depth results of the
1763 * render pass.
1764 *
1765 * - STORE: Stores the depth results in the texture.
1766 * - DONT_CARE: The driver will do whatever it wants with the depth results.
1767 * This is often a good option for depth/stencil textures that don't need to
1768 * be reused again.
1769 *
1770 * The stencil_load_op field determines what is done with the stencil contents
1771 * of the texture at the beginning of the render pass.
1772 *
1773 * - LOAD: Loads the stencil values currently in the texture.
1774 * - CLEAR: Clears the stencil values to a single value.
1775 * - DONT_CARE: The driver will do whatever it wants with the memory. This is
1776 * a good option if you know that every single pixel will be touched in the
1777 * render pass.
1778 *
1779 * The stencil_store_op field determines what is done with the stencil results
1780 * of the render pass.
1781 *
1782 * - STORE: Stores the stencil results in the texture.
1783 * - DONT_CARE: The driver will do whatever it wants with the stencil results.
1784 * This is often a good option for depth/stencil textures that don't need to
1785 * be reused again.
1786 *
1787 * Note that depth/stencil targets do not support multisample resolves.
1788 *
1789 * \since This struct is available since SDL 3.1.3
1790 *
1791 * \sa SDL_BeginGPURenderPass
1792 */
1794{
1795 SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */
1796 float clear_depth; /**< The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */
1797 SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */
1798 SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */
1799 SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */
1800 SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */
1801 bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */
1802 Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */
1806
1807/**
1808 * A structure containing parameters for a blit command.
1809 *
1810 * \since This struct is available since SDL 3.1.3
1811 *
1812 * \sa SDL_BlitGPUTexture
1813 */
1814typedef struct SDL_GPUBlitInfo {
1815 SDL_GPUBlitRegion source; /**< The source region for the blit. */
1816 SDL_GPUBlitRegion destination; /**< The destination region for the blit. */
1817 SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */
1818 SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */
1819 SDL_FlipMode flip_mode; /**< The flip mode for the source region. */
1820 SDL_GPUFilter filter; /**< The filter mode used when blitting. */
1821 bool cycle; /**< true cycles the destination texture if it is already bound. */
1826
1827/* Binding structs */
1828
1829/**
1830 * A structure specifying parameters in a buffer binding call.
1831 *
1832 * \since This struct is available since SDL 3.1.3
1833 *
1834 * \sa SDL_BindGPUVertexBuffers
1835 * \sa SDL_BindGPUIndexBuffer
1836 */
1838{
1839 SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffer. */
1840 Uint32 offset; /**< The starting byte of the data to bind in the buffer. */
1842
1843/**
1844 * A structure specifying parameters in a sampler binding call.
1845 *
1846 * \since This struct is available since SDL 3.1.3
1847 *
1848 * \sa SDL_BindGPUVertexSamplers
1849 * \sa SDL_BindGPUFragmentSamplers
1850 */
1852{
1853 SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. */
1854 SDL_GPUSampler *sampler; /**< The sampler to bind. */
1856
1857/**
1858 * A structure specifying parameters related to binding buffers in a compute
1859 * pass.
1860 *
1861 * \since This struct is available since SDL 3.1.3
1862 *
1863 * \sa SDL_BeginGPUComputePass
1864 */
1866{
1867 SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE. */
1868 bool cycle; /**< true cycles the buffer if it is already bound. */
1873
1874/**
1875 * A structure specifying parameters related to binding textures in a compute
1876 * pass.
1877 *
1878 * \since This struct is available since SDL 3.1.3
1879 *
1880 * \sa SDL_BeginGPUComputePass
1881 */
1883{
1884 SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE. */
1885 Uint32 mip_level; /**< The mip level index to bind. */
1886 Uint32 layer; /**< The layer index to bind. */
1887 bool cycle; /**< true cycles the texture if it is already bound. */
1892
1893/* Functions */
1894
1895/* Device */
1896
1897/**
1898 * Checks for GPU runtime support.
1899 *
1900 * \param format_flags a bitflag indicating which shader formats the app is
1901 * able to provide.
1902 * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
1903 * driver.
1904 * \returns true if supported, false otherwise.
1905 *
1906 * \since This function is available since SDL 3.1.3.
1907 *
1908 * \sa SDL_CreateGPUDevice
1909 */
1910extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsShaderFormats(
1911 SDL_GPUShaderFormat format_flags,
1912 const char *name);
1913
1914/**
1915 * Checks for GPU runtime support.
1916 *
1917 * \param props the properties to use.
1918 * \returns true if supported, false otherwise.
1919 *
1920 * \since This function is available since SDL 3.1.3.
1921 *
1922 * \sa SDL_CreateGPUDeviceWithProperties
1923 */
1924extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties(
1925 SDL_PropertiesID props);
1926
1927/**
1928 * Creates a GPU context.
1929 *
1930 * \param format_flags a bitflag indicating which shader formats the app is
1931 * able to provide.
1932 * \param debug_mode enable debug mode properties and validations.
1933 * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
1934 * driver.
1935 * \returns a GPU context on success or NULL on failure; call SDL_GetError()
1936 * for more information.
1937 *
1938 * \since This function is available since SDL 3.1.3.
1939 *
1940 * \sa SDL_GetGPUShaderFormats
1941 * \sa SDL_GetGPUDeviceDriver
1942 * \sa SDL_DestroyGPUDevice
1943 * \sa SDL_GPUSupportsShaderFormats
1944 */
1945extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDevice(
1946 SDL_GPUShaderFormat format_flags,
1947 bool debug_mode,
1948 const char *name);
1949
1950/**
1951 * Creates a GPU context.
1952 *
1953 * These are the supported properties:
1954 *
1955 * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN`: enable debug mode
1956 * properties and validations, defaults to true.
1957 * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer
1958 * energy efficiency over maximum GPU performance, defaults to false.
1959 * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to
1960 * use, if a specific one is desired.
1961 *
1962 * These are the current shader format properties:
1963 *
1964 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN`: The app is able to
1965 * provide shaders for an NDA platform.
1966 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN`: The app is able to
1967 * provide SPIR-V shaders if applicable.
1968 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN`: The app is able to
1969 * provide DXBC shaders if applicable
1970 * `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN`: The app is able to
1971 * provide DXIL shaders if applicable.
1972 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN`: The app is able to
1973 * provide MSL shaders if applicable.
1974 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to
1975 * provide Metal shader libraries if applicable.
1976 *
1977 * With the D3D12 renderer:
1978 *
1979 * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to
1980 * use for all vertex semantics, default is "TEXCOORD".
1981 *
1982 * \param props the properties to use.
1983 * \returns a GPU context on success or NULL on failure; call SDL_GetError()
1984 * for more information.
1985 *
1986 * \since This function is available since SDL 3.1.3.
1987 *
1988 * \sa SDL_GetGPUShaderFormats
1989 * \sa SDL_GetGPUDeviceDriver
1990 * \sa SDL_DestroyGPUDevice
1991 * \sa SDL_GPUSupportsProperties
1992 */
1994 SDL_PropertiesID props);
1995
1996#define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode"
1997#define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower"
1998#define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name"
1999#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private"
2000#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv"
2001#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc"
2002#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil"
2003#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl"
2004#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib"
2005#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
2006
2007/**
2008 * Destroys a GPU context previously returned by SDL_CreateGPUDevice.
2009 *
2010 * \param device a GPU Context to destroy.
2011 *
2012 * \since This function is available since SDL 3.1.3.
2013 *
2014 * \sa SDL_CreateGPUDevice
2015 */
2016extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device);
2017
2018/**
2019 * Get the number of GPU drivers compiled into SDL.
2020 *
2021 * \returns the number of built in GPU drivers.
2022 *
2023 * \since This function is available since SDL 3.1.3.
2024 *
2025 * \sa SDL_GetGPUDriver
2026 */
2027extern SDL_DECLSPEC int SDLCALL SDL_GetNumGPUDrivers(void);
2028
2029/**
2030 * Get the name of a built in GPU driver.
2031 *
2032 * The GPU drivers are presented in the order in which they are normally
2033 * checked during initialization.
2034 *
2035 * The names of drivers are all simple, low-ASCII identifiers, like "vulkan",
2036 * "metal" or "direct3d12". These never have Unicode characters, and are not
2037 * meant to be proper names.
2038 *
2039 * \param index the index of a GPU driver.
2040 * \returns the name of the GPU driver with the given **index**.
2041 *
2042 * \since This function is available since SDL 3.1.3.
2043 *
2044 * \sa SDL_GetNumGPUDrivers
2045 */
2046extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index);
2047
2048/**
2049 * Returns the name of the backend used to create this GPU context.
2050 *
2051 * \param device a GPU context to query.
2052 * \returns the name of the device's driver, or NULL on error.
2053 *
2054 * \since This function is available since SDL 3.1.3.
2055 */
2056extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device);
2057
2058/**
2059 * Returns the supported shader formats for this GPU context.
2060 *
2061 * \param device a GPU context to query.
2062 * \returns a bitflag indicating which shader formats the driver is able to
2063 * consume.
2064 *
2065 * \since This function is available since SDL 3.1.3.
2066 */
2067extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device);
2068
2069/* State Creation */
2070
2071/**
2072 * Creates a pipeline object to be used in a compute workflow.
2073 *
2074 * Shader resource bindings must be authored to follow a particular order
2075 * depending on the shader format.
2076 *
2077 * For SPIR-V shaders, use the following resource sets:
2078 *
2079 * - 0: Sampled textures, followed by read-only storage textures, followed by
2080 * read-only storage buffers
2081 * - 1: Write-only storage textures, followed by write-only storage buffers
2082 * - 2: Uniform buffers
2083 *
2084 * For DXBC and DXIL shaders, use the following register order:
2085 *
2086 * - (t[n], space0): Sampled textures, followed by read-only storage textures,
2087 * followed by read-only storage buffers
2088 * - (u[n], space1): Write-only storage textures, followed by write-only
2089 * storage buffers
2090 * - (b[n], space2): Uniform buffers
2091 *
2092 * For MSL/metallib, use the following order:
2093 *
2094 * - [[buffer]]: Uniform buffers, followed by write-only storage buffers,
2095 * followed by write-only storage buffers
2096 * - [[texture]]: Sampled textures, followed by read-only storage textures,
2097 * followed by write-only storage textures
2098 *
2099 * \param device a GPU Context.
2100 * \param createinfo a struct describing the state of the compute pipeline to
2101 * create.
2102 * \returns a compute pipeline object on success, or NULL on failure; call
2103 * SDL_GetError() for more information.
2104 *
2105 * \since This function is available since SDL 3.1.3.
2106 *
2107 * \sa SDL_BindGPUComputePipeline
2108 * \sa SDL_ReleaseGPUComputePipeline
2109 */
2111 SDL_GPUDevice *device,
2112 const SDL_GPUComputePipelineCreateInfo *createinfo);
2113
2114/**
2115 * Creates a pipeline object to be used in a graphics workflow.
2116 *
2117 * \param device a GPU Context.
2118 * \param createinfo a struct describing the state of the graphics pipeline to
2119 * create.
2120 * \returns a graphics pipeline object on success, or NULL on failure; call
2121 * SDL_GetError() for more information.
2122 *
2123 * \since This function is available since SDL 3.1.3.
2124 *
2125 * \sa SDL_CreateGPUShader
2126 * \sa SDL_BindGPUGraphicsPipeline
2127 * \sa SDL_ReleaseGPUGraphicsPipeline
2128 */
2130 SDL_GPUDevice *device,
2131 const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
2132
2133/**
2134 * Creates a sampler object to be used when binding textures in a graphics
2135 * workflow.
2136 *
2137 * \param device a GPU Context.
2138 * \param createinfo a struct describing the state of the sampler to create.
2139 * \returns a sampler object on success, or NULL on failure; call
2140 * SDL_GetError() for more information.
2141 *
2142 * \since This function is available since SDL 3.1.3.
2143 *
2144 * \sa SDL_BindGPUVertexSamplers
2145 * \sa SDL_BindGPUFragmentSamplers
2146 * \sa SDL_ReleaseGPUSampler
2147 */
2148extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(
2149 SDL_GPUDevice *device,
2150 const SDL_GPUSamplerCreateInfo *createinfo);
2151
2152/**
2153 * Creates a shader to be used when creating a graphics pipeline.
2154 *
2155 * Shader resource bindings must be authored to follow a particular order
2156 * depending on the shader format.
2157 *
2158 * For SPIR-V shaders, use the following resource sets:
2159 *
2160 * For vertex shaders:
2161 *
2162 * - 0: Sampled textures, followed by storage textures, followed by storage
2163 * buffers
2164 * - 1: Uniform buffers
2165 *
2166 * For fragment shaders:
2167 *
2168 * - 2: Sampled textures, followed by storage textures, followed by storage
2169 * buffers
2170 * - 3: Uniform buffers
2171 *
2172 * For DXBC and DXIL shaders, use the following register order:
2173 *
2174 * For vertex shaders:
2175 *
2176 * - (t[n], space0): Sampled textures, followed by storage textures, followed
2177 * by storage buffers
2178 * - (s[n], space0): Samplers with indices corresponding to the sampled
2179 * textures
2180 * - (b[n], space1): Uniform buffers
2181 *
2182 * For pixel shaders:
2183 *
2184 * - (t[n], space2): Sampled textures, followed by storage textures, followed
2185 * by storage buffers
2186 * - (s[n], space2): Samplers with indices corresponding to the sampled
2187 * textures
2188 * - (b[n], space3): Uniform buffers
2189 *
2190 * For MSL/metallib, use the following order:
2191 *
2192 * - [[texture]]: Sampled textures, followed by storage textures
2193 * - [[sampler]]: Samplers with indices corresponding to the sampled textures
2194 * - [[buffer]]: Uniform buffers, followed by storage buffers. Vertex buffer 0
2195 * is bound at [[buffer(14)]], vertex buffer 1 at [[buffer(15)]], and so on.
2196 * Rather than manually authoring vertex buffer indices, use the
2197 * [[stage_in]] attribute which will automatically use the vertex input
2198 * information from the SDL_GPUGraphicsPipeline.
2199 *
2200 * \param device a GPU Context.
2201 * \param createinfo a struct describing the state of the shader to create.
2202 * \returns a shader object on success, or NULL on failure; call
2203 * SDL_GetError() for more information.
2204 *
2205 * \since This function is available since SDL 3.1.3.
2206 *
2207 * \sa SDL_CreateGPUGraphicsPipeline
2208 * \sa SDL_ReleaseGPUShader
2209 */
2210extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader(
2211 SDL_GPUDevice *device,
2212 const SDL_GPUShaderCreateInfo *createinfo);
2213
2214/**
2215 * Creates a texture object to be used in graphics or compute workflows.
2216 *
2217 * The contents of this texture are undefined until data is written to the
2218 * texture.
2219 *
2220 * Note that certain combinations of usage flags are invalid. For example, a
2221 * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags.
2222 *
2223 * If you request a sample count higher than the hardware supports, the
2224 * implementation will automatically fall back to the highest available sample
2225 * count.
2226 *
2227 * \param device a GPU Context.
2228 * \param createinfo a struct describing the state of the texture to create.
2229 * \returns a texture object on success, or NULL on failure; call
2230 * SDL_GetError() for more information.
2231 *
2232 * \since This function is available since SDL 3.1.3.
2233 *
2234 * \sa SDL_UploadToGPUTexture
2235 * \sa SDL_DownloadFromGPUTexture
2236 * \sa SDL_BindGPUVertexSamplers
2237 * \sa SDL_BindGPUVertexStorageTextures
2238 * \sa SDL_BindGPUFragmentSamplers
2239 * \sa SDL_BindGPUFragmentStorageTextures
2240 * \sa SDL_BindGPUComputeStorageTextures
2241 * \sa SDL_BlitGPUTexture
2242 * \sa SDL_ReleaseGPUTexture
2243 * \sa SDL_GPUTextureSupportsFormat
2244 */
2245extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture(
2246 SDL_GPUDevice *device,
2247 const SDL_GPUTextureCreateInfo *createinfo);
2248
2249/**
2250 * Creates a buffer object to be used in graphics or compute workflows.
2251 *
2252 * The contents of this buffer are undefined until data is written to the
2253 * buffer.
2254 *
2255 * Note that certain combinations of usage flags are invalid. For example, a
2256 * buffer cannot have both the VERTEX and INDEX flags.
2257 *
2258 * \param device a GPU Context.
2259 * \param createinfo a struct describing the state of the buffer to create.
2260 * \returns a buffer object on success, or NULL on failure; call
2261 * SDL_GetError() for more information.
2262 *
2263 * \since This function is available since SDL 3.1.3.
2264 *
2265 * \sa SDL_SetGPUBufferName
2266 * \sa SDL_UploadToGPUBuffer
2267 * \sa SDL_DownloadFromGPUBuffer
2268 * \sa SDL_CopyGPUBufferToBuffer
2269 * \sa SDL_BindGPUVertexBuffers
2270 * \sa SDL_BindGPUIndexBuffer
2271 * \sa SDL_BindGPUVertexStorageBuffers
2272 * \sa SDL_BindGPUFragmentStorageBuffers
2273 * \sa SDL_DrawGPUPrimitivesIndirect
2274 * \sa SDL_DrawGPUIndexedPrimitivesIndirect
2275 * \sa SDL_BindGPUComputeStorageBuffers
2276 * \sa SDL_DispatchGPUComputeIndirect
2277 * \sa SDL_ReleaseGPUBuffer
2278 */
2279extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer(
2280 SDL_GPUDevice *device,
2281 const SDL_GPUBufferCreateInfo *createinfo);
2282
2283/**
2284 * Creates a transfer buffer to be used when uploading to or downloading from
2285 * graphics resources.
2286 *
2287 * Download buffers can be particularly expensive to create, so it is good
2288 * practice to reuse them if data will be downloaded regularly.
2289 *
2290 * \param device a GPU Context.
2291 * \param createinfo a struct describing the state of the transfer buffer to
2292 * create.
2293 * \returns a transfer buffer on success, or NULL on failure; call
2294 * SDL_GetError() for more information.
2295 *
2296 * \since This function is available since SDL 3.1.3.
2297 *
2298 * \sa SDL_UploadToGPUBuffer
2299 * \sa SDL_DownloadFromGPUBuffer
2300 * \sa SDL_UploadToGPUTexture
2301 * \sa SDL_DownloadFromGPUTexture
2302 * \sa SDL_ReleaseGPUTransferBuffer
2303 */
2305 SDL_GPUDevice *device,
2306 const SDL_GPUTransferBufferCreateInfo *createinfo);
2307
2308/* Debug Naming */
2309
2310/**
2311 * Sets an arbitrary string constant to label a buffer.
2312 *
2313 * Useful for debugging.
2314 *
2315 * \param device a GPU Context.
2316 * \param buffer a buffer to attach the name to.
2317 * \param text a UTF-8 string constant to mark as the name of the buffer.
2318 *
2319 * \since This function is available since SDL 3.1.3.
2320 */
2321extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName(
2322 SDL_GPUDevice *device,
2323 SDL_GPUBuffer *buffer,
2324 const char *text);
2325
2326/**
2327 * Sets an arbitrary string constant to label a texture.
2328 *
2329 * Useful for debugging.
2330 *
2331 * \param device a GPU Context.
2332 * \param texture a texture to attach the name to.
2333 * \param text a UTF-8 string constant to mark as the name of the texture.
2334 *
2335 * \since This function is available since SDL 3.1.3.
2336 */
2337extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName(
2338 SDL_GPUDevice *device,
2339 SDL_GPUTexture *texture,
2340 const char *text);
2341
2342/**
2343 * Inserts an arbitrary string label into the command buffer callstream.
2344 *
2345 * Useful for debugging.
2346 *
2347 * \param command_buffer a command buffer.
2348 * \param text a UTF-8 string constant to insert as the label.
2349 *
2350 * \since This function is available since SDL 3.1.3.
2351 */
2352extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
2353 SDL_GPUCommandBuffer *command_buffer,
2354 const char *text);
2355
2356/**
2357 * Begins a debug group with an arbitary name.
2358 *
2359 * Used for denoting groups of calls when viewing the command buffer
2360 * callstream in a graphics debugging tool.
2361 *
2362 * Each call to SDL_PushGPUDebugGroup must have a corresponding call to
2363 * SDL_PopGPUDebugGroup.
2364 *
2365 * On some backends (e.g. Metal), pushing a debug group during a
2366 * render/blit/compute pass will create a group that is scoped to the native
2367 * pass rather than the command buffer. For best results, if you push a debug
2368 * group during a pass, always pop it in the same pass.
2369 *
2370 * \param command_buffer a command buffer.
2371 * \param name a UTF-8 string constant that names the group.
2372 *
2373 * \since This function is available since SDL 3.1.3.
2374 *
2375 * \sa SDL_PopGPUDebugGroup
2376 */
2377extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup(
2378 SDL_GPUCommandBuffer *command_buffer,
2379 const char *name);
2380
2381/**
2382 * Ends the most-recently pushed debug group.
2383 *
2384 * \param command_buffer a command buffer.
2385 *
2386 * \since This function is available since SDL 3.1.3.
2387 *
2388 * \sa SDL_PushGPUDebugGroup
2389 */
2390extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup(
2391 SDL_GPUCommandBuffer *command_buffer);
2392
2393/* Disposal */
2394
2395/**
2396 * Frees the given texture as soon as it is safe to do so.
2397 *
2398 * You must not reference the texture after calling this function.
2399 *
2400 * \param device a GPU context.
2401 * \param texture a texture to be destroyed.
2402 *
2403 * \since This function is available since SDL 3.1.3.
2404 */
2405extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture(
2406 SDL_GPUDevice *device,
2407 SDL_GPUTexture *texture);
2408
2409/**
2410 * Frees the given sampler as soon as it is safe to do so.
2411 *
2412 * You must not reference the sampler after calling this function.
2413 *
2414 * \param device a GPU context.
2415 * \param sampler a sampler to be destroyed.
2416 *
2417 * \since This function is available since SDL 3.1.3.
2418 */
2419extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler(
2420 SDL_GPUDevice *device,
2421 SDL_GPUSampler *sampler);
2422
2423/**
2424 * Frees the given buffer as soon as it is safe to do so.
2425 *
2426 * You must not reference the buffer after calling this function.
2427 *
2428 * \param device a GPU context.
2429 * \param buffer a buffer to be destroyed.
2430 *
2431 * \since This function is available since SDL 3.1.3.
2432 */
2433extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer(
2434 SDL_GPUDevice *device,
2435 SDL_GPUBuffer *buffer);
2436
2437/**
2438 * Frees the given transfer buffer as soon as it is safe to do so.
2439 *
2440 * You must not reference the transfer buffer after calling this function.
2441 *
2442 * \param device a GPU context.
2443 * \param transfer_buffer a transfer buffer to be destroyed.
2444 *
2445 * \since This function is available since SDL 3.1.3.
2446 */
2447extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer(
2448 SDL_GPUDevice *device,
2449 SDL_GPUTransferBuffer *transfer_buffer);
2450
2451/**
2452 * Frees the given compute pipeline as soon as it is safe to do so.
2453 *
2454 * You must not reference the compute pipeline after calling this function.
2455 *
2456 * \param device a GPU context.
2457 * \param compute_pipeline a compute pipeline to be destroyed.
2458 *
2459 * \since This function is available since SDL 3.1.3.
2460 */
2461extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline(
2462 SDL_GPUDevice *device,
2463 SDL_GPUComputePipeline *compute_pipeline);
2464
2465/**
2466 * Frees the given shader as soon as it is safe to do so.
2467 *
2468 * You must not reference the shader after calling this function.
2469 *
2470 * \param device a GPU context.
2471 * \param shader a shader to be destroyed.
2472 *
2473 * \since This function is available since SDL 3.1.3.
2474 */
2475extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader(
2476 SDL_GPUDevice *device,
2477 SDL_GPUShader *shader);
2478
2479/**
2480 * Frees the given graphics pipeline as soon as it is safe to do so.
2481 *
2482 * You must not reference the graphics pipeline after calling this function.
2483 *
2484 * \param device a GPU context.
2485 * \param graphics_pipeline a graphics pipeline to be destroyed.
2486 *
2487 * \since This function is available since SDL 3.1.3.
2488 */
2489extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline(
2490 SDL_GPUDevice *device,
2491 SDL_GPUGraphicsPipeline *graphics_pipeline);
2492
2493/**
2494 * Acquire a command buffer.
2495 *
2496 * This command buffer is managed by the implementation and should not be
2497 * freed by the user. The command buffer may only be used on the thread it was
2498 * acquired on. The command buffer should be submitted on the thread it was
2499 * acquired on.
2500 *
2501 * \param device a GPU context.
2502 * \returns a command buffer, or NULL on failure; call SDL_GetError() for more
2503 * information.
2504 *
2505 * \since This function is available since SDL 3.1.3.
2506 *
2507 * \sa SDL_SubmitGPUCommandBuffer
2508 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
2509 */
2511 SDL_GPUDevice *device);
2512
2513/*
2514 * UNIFORM DATA
2515 *
2516 * Uniforms are for passing data to shaders.
2517 * The uniform data will be constant across all executions of the shader.
2518 *
2519 * There are 4 available uniform slots per shader stage (vertex, fragment, compute).
2520 * Uniform data pushed to a slot on a stage keeps its value throughout the command buffer
2521 * until you call the relevant Push function on that slot again.
2522 *
2523 * For example, you could write your vertex shaders to read a camera matrix from uniform binding slot 0,
2524 * push the camera matrix at the start of the command buffer, and that data will be used for every
2525 * subsequent draw call.
2526 *
2527 * It is valid to push uniform data during a render or compute pass.
2528 *
2529 * Uniforms are best for pushing small amounts of data.
2530 * If you are pushing more than a matrix or two per call you should consider using a storage buffer instead.
2531 */
2532
2533/**
2534 * Pushes data to a vertex uniform slot on the command buffer.
2535 *
2536 * Subsequent draw calls will use this uniform data.
2537 *
2538 * \param command_buffer a command buffer.
2539 * \param slot_index the vertex uniform slot to push data to.
2540 * \param data client data to write.
2541 * \param length the length of the data to write.
2542 *
2543 * \since This function is available since SDL 3.1.3.
2544 */
2545extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData(
2546 SDL_GPUCommandBuffer *command_buffer,
2547 Uint32 slot_index,
2548 const void *data,
2549 Uint32 length);
2550
2551/**
2552 * Pushes data to a fragment uniform slot on the command buffer.
2553 *
2554 * Subsequent draw calls will use this uniform data.
2555 *
2556 * \param command_buffer a command buffer.
2557 * \param slot_index the fragment uniform slot to push data to.
2558 * \param data client data to write.
2559 * \param length the length of the data to write.
2560 *
2561 * \since This function is available since SDL 3.1.3.
2562 */
2563extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData(
2564 SDL_GPUCommandBuffer *command_buffer,
2565 Uint32 slot_index,
2566 const void *data,
2567 Uint32 length);
2568
2569/**
2570 * Pushes data to a uniform slot on the command buffer.
2571 *
2572 * Subsequent draw calls will use this uniform data.
2573 *
2574 * \param command_buffer a command buffer.
2575 * \param slot_index the uniform slot to push data to.
2576 * \param data client data to write.
2577 * \param length the length of the data to write.
2578 *
2579 * \since This function is available since SDL 3.1.3.
2580 */
2581extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData(
2582 SDL_GPUCommandBuffer *command_buffer,
2583 Uint32 slot_index,
2584 const void *data,
2585 Uint32 length);
2586
2587/*
2588 * A NOTE ON CYCLING
2589 *
2590 * When using a command buffer, operations do not occur immediately -
2591 * they occur some time after the command buffer is submitted.
2592 *
2593 * When a resource is used in a pending or active command buffer, it is considered to be "bound".
2594 * When a resource is no longer used in any pending or active command buffers, it is considered to be "unbound".
2595 *
2596 * If data resources are bound, it is unspecified when that data will be unbound
2597 * unless you acquire a fence when submitting the command buffer and wait on it.
2598 * However, this doesn't mean you need to track resource usage manually.
2599 *
2600 * All of the functions and structs that involve writing to a resource have a "cycle" bool.
2601 * GPUTransferBuffer, GPUBuffer, and GPUTexture all effectively function as ring buffers on internal resources.
2602 * When cycle is true, if the resource is bound, the cycle rotates to the next unbound internal resource,
2603 * or if none are available, a new one is created.
2604 * This means you don't have to worry about complex state tracking and synchronization as long as cycling is correctly employed.
2605 *
2606 * For example: you can call MapTransferBuffer, write texture data, UnmapTransferBuffer, and then UploadToTexture.
2607 * The next time you write texture data to the transfer buffer, if you set the cycle param to true, you don't have
2608 * to worry about overwriting any data that is not yet uploaded.
2609 *
2610 * Another example: If you are using a texture in a render pass every frame, this can cause a data dependency between frames.
2611 * If you set cycle to true in the SDL_GPUColorTargetInfo struct, you can prevent this data dependency.
2612 *
2613 * Cycling will never undefine already bound data.
2614 * When cycling, all data in the resource is considered to be undefined for subsequent commands until that data is written again.
2615 * You must take care not to read undefined data.
2616 *
2617 * Note that when cycling a texture, the entire texture will be cycled,
2618 * even if only part of the texture is used in the call,
2619 * so you must consider the entire texture to contain undefined data after cycling.
2620 *
2621 * You must also take care not to overwrite a section of data that has been referenced in a command without cycling first.
2622 * It is OK to overwrite unreferenced data in a bound resource without cycling,
2623 * but overwriting a section of data that has already been referenced will produce unexpected results.
2624 */
2625
2626/* Graphics State */
2627
2628/**
2629 * Begins a render pass on a command buffer.
2630 *
2631 * A render pass consists of a set of texture subresources (or depth slices in
2632 * the 3D texture case) which will be rendered to during the render pass,
2633 * along with corresponding clear values and load/store operations. All
2634 * operations related to graphics pipelines must take place inside of a render
2635 * pass. A default viewport and scissor state are automatically set when this
2636 * is called. You cannot begin another render pass, or begin a compute pass or
2637 * copy pass until you have ended the render pass.
2638 *
2639 * \param command_buffer a command buffer.
2640 * \param color_target_infos an array of texture subresources with
2641 * corresponding clear values and load/store ops.
2642 * \param num_color_targets the number of color targets in the
2643 * color_target_infos array.
2644 * \param depth_stencil_target_info a texture subresource with corresponding
2645 * clear value and load/store ops, may be
2646 * NULL.
2647 * \returns a render pass handle.
2648 *
2649 * \since This function is available since SDL 3.1.3.
2650 *
2651 * \sa SDL_EndGPURenderPass
2652 */
2653extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(
2654 SDL_GPUCommandBuffer *command_buffer,
2655 const SDL_GPUColorTargetInfo *color_target_infos,
2656 Uint32 num_color_targets,
2657 const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
2658
2659/**
2660 * Binds a graphics pipeline on a render pass to be used in rendering.
2661 *
2662 * A graphics pipeline must be bound before making any draw calls.
2663 *
2664 * \param render_pass a render pass handle.
2665 * \param graphics_pipeline the graphics pipeline to bind.
2666 *
2667 * \since This function is available since SDL 3.1.3.
2668 */
2669extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline(
2670 SDL_GPURenderPass *render_pass,
2671 SDL_GPUGraphicsPipeline *graphics_pipeline);
2672
2673/**
2674 * Sets the current viewport state on a command buffer.
2675 *
2676 * \param render_pass a render pass handle.
2677 * \param viewport the viewport to set.
2678 *
2679 * \since This function is available since SDL 3.1.3.
2680 */
2681extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport(
2682 SDL_GPURenderPass *render_pass,
2683 const SDL_GPUViewport *viewport);
2684
2685/**
2686 * Sets the current scissor state on a command buffer.
2687 *
2688 * \param render_pass a render pass handle.
2689 * \param scissor the scissor area to set.
2690 *
2691 * \since This function is available since SDL 3.1.3.
2692 */
2693extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor(
2694 SDL_GPURenderPass *render_pass,
2695 const SDL_Rect *scissor);
2696
2697/**
2698 * Sets the current blend constants on a command buffer.
2699 *
2700 * \param render_pass a render pass handle.
2701 * \param blend_constants the blend constant color.
2702 *
2703 * \since This function is available since SDL 3.1.3.
2704 *
2705 * \sa SDL_GPU_BLENDFACTOR_CONSTANT_COLOR
2706 * \sa SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR
2707 */
2708extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBlendConstants(
2709 SDL_GPURenderPass *render_pass,
2710 SDL_FColor blend_constants);
2711
2712/**
2713 * Sets the current stencil reference value on a command buffer.
2714 *
2715 * \param render_pass a render pass handle.
2716 * \param reference the stencil reference value to set.
2717 *
2718 * \since This function is available since SDL 3.1.3.
2719 */
2720extern SDL_DECLSPEC void SDLCALL SDL_SetGPUStencilReference(
2721 SDL_GPURenderPass *render_pass,
2722 Uint8 reference);
2723
2724/**
2725 * Binds vertex buffers on a command buffer for use with subsequent draw
2726 * calls.
2727 *
2728 * \param render_pass a render pass handle.
2729 * \param first_slot the vertex buffer slot to begin binding from.
2730 * \param bindings an array of SDL_GPUBufferBinding structs containing vertex
2731 * buffers and offset values.
2732 * \param num_bindings the number of bindings in the bindings array.
2733 *
2734 * \since This function is available since SDL 3.1.3.
2735 */
2736extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(
2737 SDL_GPURenderPass *render_pass,
2738 Uint32 first_slot,
2739 const SDL_GPUBufferBinding *bindings,
2740 Uint32 num_bindings);
2741
2742/**
2743 * Binds an index buffer on a command buffer for use with subsequent draw
2744 * calls.
2745 *
2746 * \param render_pass a render pass handle.
2747 * \param binding a pointer to a struct containing an index buffer and offset.
2748 * \param index_element_size whether the index values in the buffer are 16- or
2749 * 32-bit.
2750 *
2751 * \since This function is available since SDL 3.1.3.
2752 */
2753extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer(
2754 SDL_GPURenderPass *render_pass,
2755 const SDL_GPUBufferBinding *binding,
2756 SDL_GPUIndexElementSize index_element_size);
2757
2758/**
2759 * Binds texture-sampler pairs for use on the vertex shader.
2760 *
2761 * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
2762 *
2763 * \param render_pass a render pass handle.
2764 * \param first_slot the vertex sampler slot to begin binding from.
2765 * \param texture_sampler_bindings an array of texture-sampler binding
2766 * structs.
2767 * \param num_bindings the number of texture-sampler pairs to bind from the
2768 * array.
2769 *
2770 * \since This function is available since SDL 3.1.3.
2771 */
2772extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(
2773 SDL_GPURenderPass *render_pass,
2774 Uint32 first_slot,
2775 const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
2776 Uint32 num_bindings);
2777
2778/**
2779 * Binds storage textures for use on the vertex shader.
2780 *
2781 * These textures must have been created with
2782 * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ.
2783 *
2784 * \param render_pass a render pass handle.
2785 * \param first_slot the vertex storage texture slot to begin binding from.
2786 * \param storage_textures an array of storage textures.
2787 * \param num_bindings the number of storage texture to bind from the array.
2788 *
2789 * \since This function is available since SDL 3.1.3.
2790 */
2791extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures(
2792 SDL_GPURenderPass *render_pass,
2793 Uint32 first_slot,
2794 SDL_GPUTexture *const *storage_textures,
2795 Uint32 num_bindings);
2796
2797/**
2798 * Binds storage buffers for use on the vertex shader.
2799 *
2800 * These buffers must have been created with
2801 * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ.
2802 *
2803 * \param render_pass a render pass handle.
2804 * \param first_slot the vertex storage buffer slot to begin binding from.
2805 * \param storage_buffers an array of buffers.
2806 * \param num_bindings the number of buffers to bind from the array.
2807 *
2808 * \since This function is available since SDL 3.1.3.
2809 */
2810extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers(
2811 SDL_GPURenderPass *render_pass,
2812 Uint32 first_slot,
2813 SDL_GPUBuffer *const *storage_buffers,
2814 Uint32 num_bindings);
2815
2816/**
2817 * Binds texture-sampler pairs for use on the fragment shader.
2818 *
2819 * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
2820 *
2821 * \param render_pass a render pass handle.
2822 * \param first_slot the fragment sampler slot to begin binding from.
2823 * \param texture_sampler_bindings an array of texture-sampler binding
2824 * structs.
2825 * \param num_bindings the number of texture-sampler pairs to bind from the
2826 * array.
2827 *
2828 * \since This function is available since SDL 3.1.3.
2829 */
2830extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(
2831 SDL_GPURenderPass *render_pass,
2832 Uint32 first_slot,
2833 const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
2834 Uint32 num_bindings);
2835
2836/**
2837 * Binds storage textures for use on the fragment shader.
2838 *
2839 * These textures must have been created with
2840 * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ.
2841 *
2842 * \param render_pass a render pass handle.
2843 * \param first_slot the fragment storage texture slot to begin binding from.
2844 * \param storage_textures an array of storage textures.
2845 * \param num_bindings the number of storage textures to bind from the array.
2846 *
2847 * \since This function is available since SDL 3.1.3.
2848 */
2849extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(
2850 SDL_GPURenderPass *render_pass,
2851 Uint32 first_slot,
2852 SDL_GPUTexture *const *storage_textures,
2853 Uint32 num_bindings);
2854
2855/**
2856 * Binds storage buffers for use on the fragment shader.
2857 *
2858 * These buffers must have been created with
2859 * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ.
2860 *
2861 * \param render_pass a render pass handle.
2862 * \param first_slot the fragment storage buffer slot to begin binding from.
2863 * \param storage_buffers an array of storage buffers.
2864 * \param num_bindings the number of storage buffers to bind from the array.
2865 *
2866 * \since This function is available since SDL 3.1.3.
2867 */
2868extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(
2869 SDL_GPURenderPass *render_pass,
2870 Uint32 first_slot,
2871 SDL_GPUBuffer *const *storage_buffers,
2872 Uint32 num_bindings);
2873
2874/* Drawing */
2875
2876/**
2877 * Draws data using bound graphics state with an index buffer and instancing
2878 * enabled.
2879 *
2880 * You must not call this function before binding a graphics pipeline.
2881 *
2882 * Note that the `first_vertex` and `first_instance` parameters are NOT
2883 * compatible with built-in vertex/instance ID variables in shaders (for
2884 * example, SV_VertexID). If your shader depends on these variables, the
2885 * correlating draw call parameter MUST be 0.
2886 *
2887 * \param render_pass a render pass handle.
2888 * \param num_indices the number of indices to draw per instance.
2889 * \param num_instances the number of instances to draw.
2890 * \param first_index the starting index within the index buffer.
2891 * \param vertex_offset value added to vertex index before indexing into the
2892 * vertex buffer.
2893 * \param first_instance the ID of the first instance to draw.
2894 *
2895 * \since This function is available since SDL 3.1.3.
2896 */
2897extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives(
2898 SDL_GPURenderPass *render_pass,
2899 Uint32 num_indices,
2900 Uint32 num_instances,
2901 Uint32 first_index,
2902 Sint32 vertex_offset,
2903 Uint32 first_instance);
2904
2905/**
2906 * Draws data using bound graphics state.
2907 *
2908 * You must not call this function before binding a graphics pipeline.
2909 *
2910 * Note that the `first_vertex` and `first_instance` parameters are NOT
2911 * compatible with built-in vertex/instance ID variables in shaders (for
2912 * example, SV_VertexID). If your shader depends on these variables, the
2913 * correlating draw call parameter MUST be 0.
2914 *
2915 * \param render_pass a render pass handle.
2916 * \param num_vertices the number of vertices to draw.
2917 * \param num_instances the number of instances that will be drawn.
2918 * \param first_vertex the index of the first vertex to draw.
2919 * \param first_instance the ID of the first instance to draw.
2920 *
2921 * \since This function is available since SDL 3.1.3.
2922 */
2923extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives(
2924 SDL_GPURenderPass *render_pass,
2925 Uint32 num_vertices,
2926 Uint32 num_instances,
2927 Uint32 first_vertex,
2928 Uint32 first_instance);
2929
2930/**
2931 * Draws data using bound graphics state and with draw parameters set from a
2932 * buffer.
2933 *
2934 * The buffer must consist of tightly-packed draw parameter sets that each
2935 * match the layout of SDL_GPUIndirectDrawCommand. You must not call this
2936 * function before binding a graphics pipeline.
2937 *
2938 * \param render_pass a render pass handle.
2939 * \param buffer a buffer containing draw parameters.
2940 * \param offset the offset to start reading from the draw buffer.
2941 * \param draw_count the number of draw parameter sets that should be read
2942 * from the draw buffer.
2943 *
2944 * \since This function is available since SDL 3.1.3.
2945 */
2946extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect(
2947 SDL_GPURenderPass *render_pass,
2948 SDL_GPUBuffer *buffer,
2949 Uint32 offset,
2950 Uint32 draw_count);
2951
2952/**
2953 * Draws data using bound graphics state with an index buffer enabled and with
2954 * draw parameters set from a buffer.
2955 *
2956 * The buffer must consist of tightly-packed draw parameter sets that each
2957 * match the layout of SDL_GPUIndexedIndirectDrawCommand. You must not call
2958 * this function before binding a graphics pipeline.
2959 *
2960 * \param render_pass a render pass handle.
2961 * \param buffer a buffer containing draw parameters.
2962 * \param offset the offset to start reading from the draw buffer.
2963 * \param draw_count the number of draw parameter sets that should be read
2964 * from the draw buffer.
2965 *
2966 * \since This function is available since SDL 3.1.3.
2967 */
2968extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect(
2969 SDL_GPURenderPass *render_pass,
2970 SDL_GPUBuffer *buffer,
2971 Uint32 offset,
2972 Uint32 draw_count);
2973
2974/**
2975 * Ends the given render pass.
2976 *
2977 * All bound graphics state on the render pass command buffer is unset. The
2978 * render pass handle is now invalid.
2979 *
2980 * \param render_pass a render pass handle.
2981 *
2982 * \since This function is available since SDL 3.1.3.
2983 */
2984extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass(
2985 SDL_GPURenderPass *render_pass);
2986
2987/* Compute Pass */
2988
2989/**
2990 * Begins a compute pass on a command buffer.
2991 *
2992 * A compute pass is defined by a set of texture subresources and buffers that
2993 * may be written to by compute pipelines. These textures and buffers must
2994 * have been created with the COMPUTE_STORAGE_WRITE bit or the
2995 * COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE bit. If you do not create a texture
2996 * with COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE, you must not read from the
2997 * texture in the compute pass. All operations related to compute pipelines
2998 * must take place inside of a compute pass. You must not begin another
2999 * compute pass, or a render pass or copy pass before ending the compute pass.
3000 *
3001 * A VERY IMPORTANT NOTE - Reads and writes in compute passes are NOT
3002 * implicitly synchronized. This means you may cause data races by both
3003 * reading and writing a resource region in a compute pass, or by writing
3004 * multiple times to a resource region. If your compute work depends on
3005 * reading the completed output from a previous dispatch, you MUST end the
3006 * current compute pass and begin a new one before you can safely access the
3007 * data. Otherwise you will receive unexpected results. Reading and writing a
3008 * texture in the same compute pass is only supported by specific texture
3009 * formats. Make sure you check the format support!
3010 *
3011 * \param command_buffer a command buffer.
3012 * \param storage_texture_bindings an array of writeable storage texture
3013 * binding structs.
3014 * \param num_storage_texture_bindings the number of storage textures to bind
3015 * from the array.
3016 * \param storage_buffer_bindings an array of writeable storage buffer binding
3017 * structs.
3018 * \param num_storage_buffer_bindings the number of storage buffers to bind
3019 * from the array.
3020 * \returns a compute pass handle.
3021 *
3022 * \since This function is available since SDL 3.1.3.
3023 *
3024 * \sa SDL_EndGPUComputePass
3025 */
3026extern SDL_DECLSPEC SDL_GPUComputePass *SDLCALL SDL_BeginGPUComputePass(
3027 SDL_GPUCommandBuffer *command_buffer,
3028 const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings,
3029 Uint32 num_storage_texture_bindings,
3030 const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings,
3031 Uint32 num_storage_buffer_bindings);
3032
3033/**
3034 * Binds a compute pipeline on a command buffer for use in compute dispatch.
3035 *
3036 * \param compute_pass a compute pass handle.
3037 * \param compute_pipeline a compute pipeline to bind.
3038 *
3039 * \since This function is available since SDL 3.1.3.
3040 */
3041extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline(
3042 SDL_GPUComputePass *compute_pass,
3043 SDL_GPUComputePipeline *compute_pipeline);
3044
3045/**
3046 * Binds texture-sampler pairs for use on the compute shader.
3047 *
3048 * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
3049 *
3050 * \param compute_pass a compute pass handle.
3051 * \param first_slot the compute sampler slot to begin binding from.
3052 * \param texture_sampler_bindings an array of texture-sampler binding
3053 * structs.
3054 * \param num_bindings the number of texture-sampler bindings to bind from the
3055 * array.
3056 *
3057 * \since This function is available since SDL 3.1.3.
3058 */
3059extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers(
3060 SDL_GPUComputePass *compute_pass,
3061 Uint32 first_slot,
3062 const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
3063 Uint32 num_bindings);
3064
3065/**
3066 * Binds storage textures as readonly for use on the compute pipeline.
3067 *
3068 * These textures must have been created with
3069 * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ.
3070 *
3071 * \param compute_pass a compute pass handle.
3072 * \param first_slot the compute storage texture slot to begin binding from.
3073 * \param storage_textures an array of storage textures.
3074 * \param num_bindings the number of storage textures to bind from the array.
3075 *
3076 * \since This function is available since SDL 3.1.3.
3077 */
3078extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(
3079 SDL_GPUComputePass *compute_pass,
3080 Uint32 first_slot,
3081 SDL_GPUTexture *const *storage_textures,
3082 Uint32 num_bindings);
3083
3084/**
3085 * Binds storage buffers as readonly for use on the compute pipeline.
3086 *
3087 * These buffers must have been created with
3088 * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ.
3089 *
3090 * \param compute_pass a compute pass handle.
3091 * \param first_slot the compute storage buffer slot to begin binding from.
3092 * \param storage_buffers an array of storage buffer binding structs.
3093 * \param num_bindings the number of storage buffers to bind from the array.
3094 *
3095 * \since This function is available since SDL 3.1.3.
3096 */
3097extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(
3098 SDL_GPUComputePass *compute_pass,
3099 Uint32 first_slot,
3100 SDL_GPUBuffer *const *storage_buffers,
3101 Uint32 num_bindings);
3102
3103/**
3104 * Dispatches compute work.
3105 *
3106 * You must not call this function before binding a compute pipeline.
3107 *
3108 * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
3109 * the dispatches write to the same resource region as each other, there is no
3110 * guarantee of which order the writes will occur. If the write order matters,
3111 * you MUST end the compute pass and begin another one.
3112 *
3113 * \param compute_pass a compute pass handle.
3114 * \param groupcount_x number of local workgroups to dispatch in the X
3115 * dimension.
3116 * \param groupcount_y number of local workgroups to dispatch in the Y
3117 * dimension.
3118 * \param groupcount_z number of local workgroups to dispatch in the Z
3119 * dimension.
3120 *
3121 * \since This function is available since SDL 3.1.3.
3122 */
3123extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute(
3124 SDL_GPUComputePass *compute_pass,
3125 Uint32 groupcount_x,
3126 Uint32 groupcount_y,
3127 Uint32 groupcount_z);
3128
3129/**
3130 * Dispatches compute work with parameters set from a buffer.
3131 *
3132 * The buffer layout should match the layout of
3133 * SDL_GPUIndirectDispatchCommand. You must not call this function before
3134 * binding a compute pipeline.
3135 *
3136 * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
3137 * the dispatches write to the same resource region as each other, there is no
3138 * guarantee of which order the writes will occur. If the write order matters,
3139 * you MUST end the compute pass and begin another one.
3140 *
3141 * \param compute_pass a compute pass handle.
3142 * \param buffer a buffer containing dispatch parameters.
3143 * \param offset the offset to start reading from the dispatch buffer.
3144 *
3145 * \since This function is available since SDL 3.1.3.
3146 */
3147extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect(
3148 SDL_GPUComputePass *compute_pass,
3149 SDL_GPUBuffer *buffer,
3150 Uint32 offset);
3151
3152/**
3153 * Ends the current compute pass.
3154 *
3155 * All bound compute state on the command buffer is unset. The compute pass
3156 * handle is now invalid.
3157 *
3158 * \param compute_pass a compute pass handle.
3159 *
3160 * \since This function is available since SDL 3.1.3.
3161 */
3162extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(
3163 SDL_GPUComputePass *compute_pass);
3164
3165/* TransferBuffer Data */
3166
3167/**
3168 * Maps a transfer buffer into application address space.
3169 *
3170 * You must unmap the transfer buffer before encoding upload commands.
3171 *
3172 * \param device a GPU context.
3173 * \param transfer_buffer a transfer buffer.
3174 * \param cycle if true, cycles the transfer buffer if it is already bound.
3175 * \returns the address of the mapped transfer buffer memory, or NULL on
3176 * failure; call SDL_GetError() for more information.
3177 *
3178 * \since This function is available since SDL 3.1.3.
3179 */
3180extern SDL_DECLSPEC void *SDLCALL SDL_MapGPUTransferBuffer(
3181 SDL_GPUDevice *device,
3182 SDL_GPUTransferBuffer *transfer_buffer,
3183 bool cycle);
3184
3185/**
3186 * Unmaps a previously mapped transfer buffer.
3187 *
3188 * \param device a GPU context.
3189 * \param transfer_buffer a previously mapped transfer buffer.
3190 *
3191 * \since This function is available since SDL 3.1.3.
3192 */
3193extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer(
3194 SDL_GPUDevice *device,
3195 SDL_GPUTransferBuffer *transfer_buffer);
3196
3197/* Copy Pass */
3198
3199/**
3200 * Begins a copy pass on a command buffer.
3201 *
3202 * All operations related to copying to or from buffers or textures take place
3203 * inside a copy pass. You must not begin another copy pass, or a render pass
3204 * or compute pass before ending the copy pass.
3205 *
3206 * \param command_buffer a command buffer.
3207 * \returns a copy pass handle.
3208 *
3209 * \since This function is available since SDL 3.1.3.
3210 */
3211extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass(
3212 SDL_GPUCommandBuffer *command_buffer);
3213
3214/**
3215 * Uploads data from a transfer buffer to a texture.
3216 *
3217 * The upload occurs on the GPU timeline. You may assume that the upload has
3218 * finished in subsequent commands.
3219 *
3220 * You must align the data in the transfer buffer to a multiple of the texel
3221 * size of the texture format.
3222 *
3223 * \param copy_pass a copy pass handle.
3224 * \param source the source transfer buffer with image layout information.
3225 * \param destination the destination texture region.
3226 * \param cycle if true, cycles the texture if the texture is bound, otherwise
3227 * overwrites the data.
3228 *
3229 * \since This function is available since SDL 3.1.3.
3230 */
3231extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture(
3232 SDL_GPUCopyPass *copy_pass,
3233 const SDL_GPUTextureTransferInfo *source,
3234 const SDL_GPUTextureRegion *destination,
3235 bool cycle);
3236
3237/* Uploads data from a TransferBuffer to a Buffer. */
3238
3239/**
3240 * Uploads data from a transfer buffer to a buffer.
3241 *
3242 * The upload occurs on the GPU timeline. You may assume that the upload has
3243 * finished in subsequent commands.
3244 *
3245 * \param copy_pass a copy pass handle.
3246 * \param source the source transfer buffer with offset.
3247 * \param destination the destination buffer with offset and size.
3248 * \param cycle if true, cycles the buffer if it is already bound, otherwise
3249 * overwrites the data.
3250 *
3251 * \since This function is available since SDL 3.1.3.
3252 */
3253extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer(
3254 SDL_GPUCopyPass *copy_pass,
3255 const SDL_GPUTransferBufferLocation *source,
3256 const SDL_GPUBufferRegion *destination,
3257 bool cycle);
3258
3259/**
3260 * Performs a texture-to-texture copy.
3261 *
3262 * This copy occurs on the GPU timeline. You may assume the copy has finished
3263 * in subsequent commands.
3264 *
3265 * \param copy_pass a copy pass handle.
3266 * \param source a source texture region.
3267 * \param destination a destination texture region.
3268 * \param w the width of the region to copy.
3269 * \param h the height of the region to copy.
3270 * \param d the depth of the region to copy.
3271 * \param cycle if true, cycles the destination texture if the destination
3272 * texture is bound, otherwise overwrites the data.
3273 *
3274 * \since This function is available since SDL 3.1.3.
3275 */
3276extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture(
3277 SDL_GPUCopyPass *copy_pass,
3278 const SDL_GPUTextureLocation *source,
3279 const SDL_GPUTextureLocation *destination,
3280 Uint32 w,
3281 Uint32 h,
3282 Uint32 d,
3283 bool cycle);
3284
3285/* Copies data from a buffer to a buffer. */
3286
3287/**
3288 * Performs a buffer-to-buffer copy.
3289 *
3290 * This copy occurs on the GPU timeline. You may assume the copy has finished
3291 * in subsequent commands.
3292 *
3293 * \param copy_pass a copy pass handle.
3294 * \param source the buffer and offset to copy from.
3295 * \param destination the buffer and offset to copy to.
3296 * \param size the length of the buffer to copy.
3297 * \param cycle if true, cycles the destination buffer if it is already bound,
3298 * otherwise overwrites the data.
3299 *
3300 * \since This function is available since SDL 3.1.3.
3301 */
3302extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer(
3303 SDL_GPUCopyPass *copy_pass,
3304 const SDL_GPUBufferLocation *source,
3305 const SDL_GPUBufferLocation *destination,
3306 Uint32 size,
3307 bool cycle);
3308
3309/**
3310 * Copies data from a texture to a transfer buffer on the GPU timeline.
3311 *
3312 * This data is not guaranteed to be copied until the command buffer fence is
3313 * signaled.
3314 *
3315 * \param copy_pass a copy pass handle.
3316 * \param source the source texture region.
3317 * \param destination the destination transfer buffer with image layout
3318 * information.
3319 *
3320 * \since This function is available since SDL 3.1.3.
3321 */
3322extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture(
3323 SDL_GPUCopyPass *copy_pass,
3324 const SDL_GPUTextureRegion *source,
3325 const SDL_GPUTextureTransferInfo *destination);
3326
3327/**
3328 * Copies data from a buffer to a transfer buffer on the GPU timeline.
3329 *
3330 * This data is not guaranteed to be copied until the command buffer fence is
3331 * signaled.
3332 *
3333 * \param copy_pass a copy pass handle.
3334 * \param source the source buffer with offset and size.
3335 * \param destination the destination transfer buffer with offset.
3336 *
3337 * \since This function is available since SDL 3.1.3.
3338 */
3339extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer(
3340 SDL_GPUCopyPass *copy_pass,
3341 const SDL_GPUBufferRegion *source,
3342 const SDL_GPUTransferBufferLocation *destination);
3343
3344/**
3345 * Ends the current copy pass.
3346 *
3347 * \param copy_pass a copy pass handle.
3348 *
3349 * \since This function is available since SDL 3.1.3.
3350 */
3351extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass(
3352 SDL_GPUCopyPass *copy_pass);
3353
3354/**
3355 * Generates mipmaps for the given texture.
3356 *
3357 * This function must not be called inside of any pass.
3358 *
3359 * \param command_buffer a command_buffer.
3360 * \param texture a texture with more than 1 mip level.
3361 *
3362 * \since This function is available since SDL 3.1.3.
3363 */
3364extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(
3365 SDL_GPUCommandBuffer *command_buffer,
3366 SDL_GPUTexture *texture);
3367
3368/**
3369 * Blits from a source texture region to a destination texture region.
3370 *
3371 * This function must not be called inside of any pass.
3372 *
3373 * \param command_buffer a command buffer.
3374 * \param info the blit info struct containing the blit parameters.
3375 *
3376 * \since This function is available since SDL 3.1.3.
3377 */
3378extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
3379 SDL_GPUCommandBuffer *command_buffer,
3380 const SDL_GPUBlitInfo *info);
3381
3382/* Submission/Presentation */
3383
3384/**
3385 * Determines whether a swapchain composition is supported by the window.
3386 *
3387 * The window must be claimed before calling this function.
3388 *
3389 * \param device a GPU context.
3390 * \param window an SDL_Window.
3391 * \param swapchain_composition the swapchain composition to check.
3392 * \returns true if supported, false if unsupported.
3393 *
3394 * \since This function is available since SDL 3.1.3.
3395 *
3396 * \sa SDL_ClaimWindowForGPUDevice
3397 */
3398extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition(
3399 SDL_GPUDevice *device,
3400 SDL_Window *window,
3401 SDL_GPUSwapchainComposition swapchain_composition);
3402
3403/**
3404 * Determines whether a presentation mode is supported by the window.
3405 *
3406 * The window must be claimed before calling this function.
3407 *
3408 * \param device a GPU context.
3409 * \param window an SDL_Window.
3410 * \param present_mode the presentation mode to check.
3411 * \returns true if supported, false if unsupported.
3412 *
3413 * \since This function is available since SDL 3.1.3.
3414 *
3415 * \sa SDL_ClaimWindowForGPUDevice
3416 */
3417extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUPresentMode(
3418 SDL_GPUDevice *device,
3419 SDL_Window *window,
3420 SDL_GPUPresentMode present_mode);
3421
3422/**
3423 * Claims a window, creating a swapchain structure for it.
3424 *
3425 * This must be called before SDL_AcquireGPUSwapchainTexture is called using
3426 * the window. You should only call this function from the thread that created
3427 * the window.
3428 *
3429 * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and
3430 * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain
3431 * parameters, you must call SDL_SetGPUSwapchainParameters after claiming the
3432 * window.
3433 *
3434 * \param device a GPU context.
3435 * \param window an SDL_Window.
3436 * \returns true on success, or false on failure; call SDL_GetError() for more
3437 * information.
3438 *
3439 * \threadsafety This function should only be called from the thread that
3440 * created the window.
3441 *
3442 * \since This function is available since SDL 3.1.3.
3443 *
3444 * \sa SDL_AcquireGPUSwapchainTexture
3445 * \sa SDL_ReleaseWindowFromGPUDevice
3446 * \sa SDL_WindowSupportsGPUPresentMode
3447 * \sa SDL_WindowSupportsGPUSwapchainComposition
3448 */
3449extern SDL_DECLSPEC bool SDLCALL SDL_ClaimWindowForGPUDevice(
3450 SDL_GPUDevice *device,
3451 SDL_Window *window);
3452
3453/**
3454 * Unclaims a window, destroying its swapchain structure.
3455 *
3456 * \param device a GPU context.
3457 * \param window an SDL_Window that has been claimed.
3458 *
3459 * \since This function is available since SDL 3.1.3.
3460 *
3461 * \sa SDL_ClaimWindowForGPUDevice
3462 */
3463extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice(
3464 SDL_GPUDevice *device,
3465 SDL_Window *window);
3466
3467/**
3468 * Changes the swapchain parameters for the given claimed window.
3469 *
3470 * This function will fail if the requested present mode or swapchain
3471 * composition are unsupported by the device. Check if the parameters are
3472 * supported via SDL_WindowSupportsGPUPresentMode /
3473 * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function.
3474 *
3475 * SDL_GPU_PRESENTMODE_VSYNC and SDL_GPU_SWAPCHAINCOMPOSITION_SDR are always
3476 * supported.
3477 *
3478 * \param device a GPU context.
3479 * \param window an SDL_Window that has been claimed.
3480 * \param swapchain_composition the desired composition of the swapchain.
3481 * \param present_mode the desired present mode for the swapchain.
3482 * \returns true if successful, false on error; call SDL_GetError() for more
3483 * information.
3484 *
3485 * \since This function is available since SDL 3.1.3.
3486 *
3487 * \sa SDL_WindowSupportsGPUPresentMode
3488 * \sa SDL_WindowSupportsGPUSwapchainComposition
3489 */
3490extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUSwapchainParameters(
3491 SDL_GPUDevice *device,
3492 SDL_Window *window,
3493 SDL_GPUSwapchainComposition swapchain_composition,
3494 SDL_GPUPresentMode present_mode);
3495
3496/**
3497 * Configures the maximum allowed number of frames in flight.
3498 *
3499 * The default value when the device is created is 2. This means that after
3500 * you have submitted 2 frames for presentation, if the GPU has not finished
3501 * working on the first frame, SDL_AcquireGPUSwapchainTexture() will fill the
3502 * swapchain texture pointer with NULL, and
3503 * SDL_WaitAndAcquireGPUSwapchainTexture() will block.
3504 *
3505 * Higher values increase throughput at the expense of visual latency. Lower
3506 * values decrease visual latency at the expense of throughput.
3507 *
3508 * Note that calling this function will stall and flush the command queue to
3509 * prevent synchronization issues.
3510 *
3511 * The minimum value of allowed frames in flight is 1, and the maximum is 3.
3512 *
3513 * \param device a GPU context.
3514 * \param allowed_frames_in_flight the maximum number of frames that can be
3515 * pending on the GPU.
3516 * \returns true if successful, false on error; call SDL_GetError() for more
3517 * information.
3518 *
3519 * \since This function is available since SDL 3.2.0.
3520 */
3521extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUAllowedFramesInFlight(
3522 SDL_GPUDevice *device,
3523 Uint32 allowed_frames_in_flight);
3524
3525/**
3526 * Obtains the texture format of the swapchain for the given window.
3527 *
3528 * Note that this format can change if the swapchain parameters change.
3529 *
3530 * \param device a GPU context.
3531 * \param window an SDL_Window that has been claimed.
3532 * \returns the texture format of the swapchain.
3533 *
3534 * \since This function is available since SDL 3.1.3.
3535 */
3537 SDL_GPUDevice *device,
3538 SDL_Window *window);
3539
3540/**
3541 * Acquire a texture to use in presentation.
3542 *
3543 * When a swapchain texture is acquired on a command buffer, it will
3544 * automatically be submitted for presentation when the command buffer is
3545 * submitted. The swapchain texture should only be referenced by the command
3546 * buffer used to acquire it.
3547 *
3548 * This function will fill the swapchain texture handle with NULL if too many
3549 * frames are in flight. This is not an error. The best practice is to call
3550 * SDL_CancelGPUCommandBuffer if the swapchain texture handle is NULL to avoid
3551 * enqueuing needless work on the GPU.
3552 *
3553 * The swapchain texture is managed by the implementation and must not be
3554 * freed by the user. You MUST NOT call this function from any thread other
3555 * than the one that created the window.
3556 *
3557 * \param command_buffer a command buffer.
3558 * \param window a window that has been claimed.
3559 * \param swapchain_texture a pointer filled in with a swapchain texture
3560 * handle.
3561 * \param swapchain_texture_width a pointer filled in with the swapchain
3562 * texture width, may be NULL.
3563 * \param swapchain_texture_height a pointer filled in with the swapchain
3564 * texture height, may be NULL.
3565 * \returns true on success, false on error; call SDL_GetError() for more
3566 * information.
3567 *
3568 * \threadsafety This function should only be called from the thread that
3569 * created the window.
3570 *
3571 * \since This function is available since SDL 3.1.3.
3572 *
3573 * \sa SDL_ClaimWindowForGPUDevice
3574 * \sa SDL_SubmitGPUCommandBuffer
3575 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3576 * \sa SDL_CancelGPUCommandBuffer
3577 * \sa SDL_GetWindowSizeInPixels
3578 * \sa SDL_WaitForGPUSwapchain
3579 * \sa SDL_SetGPUAllowedFramesInFlight
3580 */
3581extern SDL_DECLSPEC bool SDLCALL SDL_AcquireGPUSwapchainTexture(
3582 SDL_GPUCommandBuffer *command_buffer,
3583 SDL_Window *window,
3584 SDL_GPUTexture **swapchain_texture,
3585 Uint32 *swapchain_texture_width,
3586 Uint32 *swapchain_texture_height);
3587
3588/**
3589 * Blocks the thread until a swapchain texture is available to be acquired.
3590 *
3591 * \param device a GPU context.
3592 * \param window a window that has been claimed.
3593 * \returns true on success, false on failure; call SDL_GetError() for more
3594 * information.
3595 *
3596 * \threadsafety This function should only be called from the thread that
3597 * created the window.
3598 *
3599 * \since This function is available since SDL 3.2.0.
3600 *
3601 * \sa SDL_AcquireGPUSwapchainTexture
3602 * \sa SDL_SetGPUAllowedFramesInFlight
3603 */
3604extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUSwapchain(
3605 SDL_GPUDevice *device,
3606 SDL_Window *window);
3607
3608/**
3609 * Blocks the thread until a swapchain texture is available to be acquired,
3610 * and then acquires it.
3611 *
3612 * When a swapchain texture is acquired on a command buffer, it will
3613 * automatically be submitted for presentation when the command buffer is
3614 * submitted. The swapchain texture should only be referenced by the command
3615 * buffer used to acquire it. It is an error to call
3616 * SDL_CancelGPUCommandBuffer() after a swapchain texture is acquired.
3617 *
3618 * The swapchain texture is managed by the implementation and must not be
3619 * freed by the user. You MUST NOT call this function from any thread other
3620 * than the one that created the window.
3621 *
3622 * \param command_buffer a command buffer.
3623 * \param window a window that has been claimed.
3624 * \param swapchain_texture a pointer filled in with a swapchain texture
3625 * handle.
3626 * \param swapchain_texture_width a pointer filled in with the swapchain
3627 * texture width, may be NULL.
3628 * \param swapchain_texture_height a pointer filled in with the swapchain
3629 * texture height, may be NULL.
3630 * \returns true on success, false on error; call SDL_GetError() for more
3631 * information.
3632 *
3633 * \threadsafety This function should only be called from the thread that
3634 * created the window.
3635 *
3636 * \since This function is available since SDL 3.2.0.
3637 *
3638 * \sa SDL_SubmitGPUCommandBuffer
3639 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3640 */
3641extern SDL_DECLSPEC bool SDLCALL SDL_WaitAndAcquireGPUSwapchainTexture(
3642 SDL_GPUCommandBuffer *command_buffer,
3643 SDL_Window *window,
3644 SDL_GPUTexture **swapchain_texture,
3645 Uint32 *swapchain_texture_width,
3646 Uint32 *swapchain_texture_height);
3647
3648/**
3649 * Submits a command buffer so its commands can be processed on the GPU.
3650 *
3651 * It is invalid to use the command buffer after this is called.
3652 *
3653 * This must be called from the thread the command buffer was acquired on.
3654 *
3655 * All commands in the submission are guaranteed to begin executing before any
3656 * command in a subsequent submission begins executing.
3657 *
3658 * \param command_buffer a command buffer.
3659 * \returns true on success, false on failure; call SDL_GetError() for more
3660 * information.
3661 *
3662 * \since This function is available since SDL 3.1.3.
3663 *
3664 * \sa SDL_AcquireGPUCommandBuffer
3665 * \sa SDL_AcquireGPUSwapchainTexture
3666 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3667 */
3668extern SDL_DECLSPEC bool SDLCALL SDL_SubmitGPUCommandBuffer(
3669 SDL_GPUCommandBuffer *command_buffer);
3670
3671/**
3672 * Submits a command buffer so its commands can be processed on the GPU, and
3673 * acquires a fence associated with the command buffer.
3674 *
3675 * You must release this fence when it is no longer needed or it will cause a
3676 * leak. It is invalid to use the command buffer after this is called.
3677 *
3678 * This must be called from the thread the command buffer was acquired on.
3679 *
3680 * All commands in the submission are guaranteed to begin executing before any
3681 * command in a subsequent submission begins executing.
3682 *
3683 * \param command_buffer a command buffer.
3684 * \returns a fence associated with the command buffer, or NULL on failure;
3685 * call SDL_GetError() for more information.
3686 *
3687 * \since This function is available since SDL 3.1.3.
3688 *
3689 * \sa SDL_AcquireGPUCommandBuffer
3690 * \sa SDL_AcquireGPUSwapchainTexture
3691 * \sa SDL_SubmitGPUCommandBuffer
3692 * \sa SDL_ReleaseGPUFence
3693 */
3695 SDL_GPUCommandBuffer *command_buffer);
3696
3697/**
3698 * Cancels a command buffer.
3699 *
3700 * None of the enqueued commands are executed.
3701 *
3702 * This must be called from the thread the command buffer was acquired on.
3703 *
3704 * You must not reference the command buffer after calling this function. It
3705 * is an error to call this function after a swapchain texture has been
3706 * acquired.
3707 *
3708 * \param command_buffer a command buffer.
3709 * \returns true on success, false on error; call SDL_GetError() for more
3710 * information.
3711 *
3712 * \since This function is available since SDL 3.1.6.
3713 *
3714 * \sa SDL_AcquireGPUCommandBuffer
3715 * \sa SDL_AcquireGPUSwapchainTexture
3716 */
3717extern SDL_DECLSPEC bool SDLCALL SDL_CancelGPUCommandBuffer(
3718 SDL_GPUCommandBuffer *command_buffer);
3719
3720/**
3721 * Blocks the thread until the GPU is completely idle.
3722 *
3723 * \param device a GPU context.
3724 * \returns true on success, false on failure; call SDL_GetError() for more
3725 * information.
3726 *
3727 * \since This function is available since SDL 3.1.3.
3728 *
3729 * \sa SDL_WaitForGPUFences
3730 */
3731extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUIdle(
3732 SDL_GPUDevice *device);
3733
3734/**
3735 * Blocks the thread until the given fences are signaled.
3736 *
3737 * \param device a GPU context.
3738 * \param wait_all if 0, wait for any fence to be signaled, if 1, wait for all
3739 * fences to be signaled.
3740 * \param fences an array of fences to wait on.
3741 * \param num_fences the number of fences in the fences array.
3742 * \returns true on success, false on failure; call SDL_GetError() for more
3743 * information.
3744 *
3745 * \since This function is available since SDL 3.1.3.
3746 *
3747 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3748 * \sa SDL_WaitForGPUIdle
3749 */
3750extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUFences(
3751 SDL_GPUDevice *device,
3752 bool wait_all,
3753 SDL_GPUFence *const *fences,
3754 Uint32 num_fences);
3755
3756/**
3757 * Checks the status of a fence.
3758 *
3759 * \param device a GPU context.
3760 * \param fence a fence.
3761 * \returns true if the fence is signaled, false if it is not.
3762 *
3763 * \since This function is available since SDL 3.1.3.
3764 *
3765 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3766 */
3767extern SDL_DECLSPEC bool SDLCALL SDL_QueryGPUFence(
3768 SDL_GPUDevice *device,
3769 SDL_GPUFence *fence);
3770
3771/**
3772 * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence.
3773 *
3774 * \param device a GPU context.
3775 * \param fence a fence.
3776 *
3777 * \since This function is available since SDL 3.1.3.
3778 *
3779 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3780 */
3781extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence(
3782 SDL_GPUDevice *device,
3783 SDL_GPUFence *fence);
3784
3785/* Format Info */
3786
3787/**
3788 * Obtains the texel block size for a texture format.
3789 *
3790 * \param format the texture format you want to know the texel size of.
3791 * \returns the texel block size of the texture format.
3792 *
3793 * \since This function is available since SDL 3.1.3.
3794 *
3795 * \sa SDL_UploadToGPUTexture
3796 */
3797extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize(
3798 SDL_GPUTextureFormat format);
3799
3800/**
3801 * Determines whether a texture format is supported for a given type and
3802 * usage.
3803 *
3804 * \param device a GPU context.
3805 * \param format the texture format to check.
3806 * \param type the type of texture (2D, 3D, Cube).
3807 * \param usage a bitmask of all usage scenarios to check.
3808 * \returns whether the texture format is supported for this type and usage.
3809 *
3810 * \since This function is available since SDL 3.1.3.
3811 */
3812extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsFormat(
3813 SDL_GPUDevice *device,
3814 SDL_GPUTextureFormat format,
3815 SDL_GPUTextureType type,
3817
3818/**
3819 * Determines if a sample count for a texture format is supported.
3820 *
3821 * \param device a GPU context.
3822 * \param format the texture format to check.
3823 * \param sample_count the sample count to check.
3824 * \returns a hardware-specific version of min(preferred, possible).
3825 *
3826 * \since This function is available since SDL 3.1.3.
3827 */
3828extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsSampleCount(
3829 SDL_GPUDevice *device,
3830 SDL_GPUTextureFormat format,
3831 SDL_GPUSampleCount sample_count);
3832
3833/**
3834 * Calculate the size in bytes of a texture format with dimensions.
3835 *
3836 * \param format a texture format.
3837 * \param width width in pixels.
3838 * \param height height in pixels.
3839 * \param depth_or_layer_count depth for 3D textures or layer count otherwise.
3840 * \returns the size of a texture with this format and dimensions.
3841 *
3842 * \since This function is available since SDL 3.1.6.
3843 */
3844extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize(
3845 SDL_GPUTextureFormat format,
3846 Uint32 width,
3847 Uint32 height,
3848 Uint32 depth_or_layer_count);
3849
3850#ifdef SDL_PLATFORM_GDK
3851
3852/**
3853 * Call this to suspend GPU operation on Xbox when you receive the
3854 * SDL_EVENT_DID_ENTER_BACKGROUND event.
3855 *
3856 * Do NOT call any SDL_GPU functions after calling this function! This must
3857 * also be called before calling SDL_GDKSuspendComplete.
3858 *
3859 * \param device a GPU context.
3860 *
3861 * \since This function is available since SDL 3.1.3.
3862 *
3863 * \sa SDL_AddEventWatch
3864 */
3865extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device);
3866
3867/**
3868 * Call this to resume GPU operation on Xbox when you receive the
3869 * SDL_EVENT_WILL_ENTER_FOREGROUND event.
3870 *
3871 * When resuming, this function MUST be called before calling any other
3872 * SDL_GPU functions.
3873 *
3874 * \param device a GPU context.
3875 *
3876 * \since This function is available since SDL 3.1.3.
3877 *
3878 * \sa SDL_AddEventWatch
3879 */
3880extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device);
3881
3882#endif /* SDL_PLATFORM_GDK */
3883
3884#ifdef __cplusplus
3885}
3886#endif /* __cplusplus */
3887#include <SDL3/SDL_close_code.h>
3888
3889#endif /* SDL_gpu_h_ */
void SDL_BindGPUComputeStorageTextures(SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings)
void SDL_EndGPUComputePass(SDL_GPUComputePass *compute_pass)
void SDL_DestroyGPUDevice(SDL_GPUDevice *device)
SDL_GPUSampleCount
Definition SDL_gpu.h:706
@ SDL_GPU_SAMPLECOUNT_2
Definition SDL_gpu.h:708
@ SDL_GPU_SAMPLECOUNT_8
Definition SDL_gpu.h:710
@ SDL_GPU_SAMPLECOUNT_1
Definition SDL_gpu.h:707
@ SDL_GPU_SAMPLECOUNT_4
Definition SDL_gpu.h:709
SDL_GPUTransferBuffer * SDL_CreateGPUTransferBuffer(SDL_GPUDevice *device, const SDL_GPUTransferBufferCreateInfo *createinfo)
SDL_GPUCubeMapFace
Definition SDL_gpu.h:722
@ SDL_GPU_CUBEMAPFACE_NEGATIVEY
Definition SDL_gpu.h:726
@ SDL_GPU_CUBEMAPFACE_POSITIVEY
Definition SDL_gpu.h:725
@ SDL_GPU_CUBEMAPFACE_NEGATIVEX
Definition SDL_gpu.h:724
@ SDL_GPU_CUBEMAPFACE_NEGATIVEZ
Definition SDL_gpu.h:728
@ SDL_GPU_CUBEMAPFACE_POSITIVEX
Definition SDL_gpu.h:723
@ SDL_GPU_CUBEMAPFACE_POSITIVEZ
Definition SDL_gpu.h:727
SDL_GPUDevice * SDL_CreateGPUDevice(SDL_GPUShaderFormat format_flags, bool debug_mode, const char *name)
void SDL_EndGPURenderPass(SDL_GPURenderPass *render_pass)
void SDL_ReleaseGPUComputePipeline(SDL_GPUDevice *device, SDL_GPUComputePipeline *compute_pipeline)
struct SDL_GPUTransferBuffer SDL_GPUTransferBuffer
Definition SDL_gpu.h:229
void SDL_PushGPUDebugGroup(SDL_GPUCommandBuffer *command_buffer, const char *name)
SDL_GPUFrontFace
Definition SDL_gpu.h:916
@ SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE
Definition SDL_gpu.h:917
@ SDL_GPU_FRONTFACE_CLOCKWISE
Definition SDL_gpu.h:918
SDL_GPUDevice * SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
SDL_GPUVertexInputRate
Definition SDL_gpu.h:875
@ SDL_GPU_VERTEXINPUTRATE_INSTANCE
Definition SDL_gpu.h:877
@ SDL_GPU_VERTEXINPUTRATE_VERTEX
Definition SDL_gpu.h:876
bool SDL_GPUTextureSupportsFormat(SDL_GPUDevice *device, SDL_GPUTextureFormat format, SDL_GPUTextureType type, SDL_GPUTextureUsageFlags usage)
SDL_GPUTexture * SDL_CreateGPUTexture(SDL_GPUDevice *device, const SDL_GPUTextureCreateInfo *createinfo)
bool SDL_SubmitGPUCommandBuffer(SDL_GPUCommandBuffer *command_buffer)
SDL_GPUPrimitiveType
Definition SDL_gpu.h:385
@ SDL_GPU_PRIMITIVETYPE_TRIANGLELIST
Definition SDL_gpu.h:386
@ SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP
Definition SDL_gpu.h:387
@ SDL_GPU_PRIMITIVETYPE_POINTLIST
Definition SDL_gpu.h:390
@ SDL_GPU_PRIMITIVETYPE_LINESTRIP
Definition SDL_gpu.h:389
@ SDL_GPU_PRIMITIVETYPE_LINELIST
Definition SDL_gpu.h:388
void SDL_DownloadFromGPUBuffer(SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferRegion *source, const SDL_GPUTransferBufferLocation *destination)
SDL_GPUShader * SDL_CreateGPUShader(SDL_GPUDevice *device, const SDL_GPUShaderCreateInfo *createinfo)
void SDL_PushGPUFragmentUniformData(SDL_GPUCommandBuffer *command_buffer, Uint32 slot_index, const void *data, Uint32 length)
SDL_GPUCommandBuffer * SDL_AcquireGPUCommandBuffer(SDL_GPUDevice *device)
void SDL_EndGPUCopyPass(SDL_GPUCopyPass *copy_pass)
bool SDL_CancelGPUCommandBuffer(SDL_GPUCommandBuffer *command_buffer)
Uint32 SDL_GPUShaderFormat
Definition SDL_gpu.h:791
void SDL_SetGPUTextureName(SDL_GPUDevice *device, SDL_GPUTexture *texture, const char *text)
struct SDL_GPURenderPass SDL_GPURenderPass
Definition SDL_gpu.h:337
SDL_GPUFillMode
Definition SDL_gpu.h:888
@ SDL_GPU_FILLMODE_FILL
Definition SDL_gpu.h:889
@ SDL_GPU_FILLMODE_LINE
Definition SDL_gpu.h:890
SDL_GPUCopyPass * SDL_BeginGPUCopyPass(SDL_GPUCommandBuffer *command_buffer)
SDL_GPUIndexElementSize
Definition SDL_gpu.h:432
@ SDL_GPU_INDEXELEMENTSIZE_16BIT
Definition SDL_gpu.h:433
@ SDL_GPU_INDEXELEMENTSIZE_32BIT
Definition SDL_gpu.h:434
void SDL_PopGPUDebugGroup(SDL_GPUCommandBuffer *command_buffer)
void SDL_BindGPUVertexStorageTextures(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings)
SDL_GPUBlendFactor
Definition SDL_gpu.h:995
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
Definition SDL_gpu.h:1004
@ SDL_GPU_BLENDFACTOR_CONSTANT_COLOR
Definition SDL_gpu.h:1007
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR
Definition SDL_gpu.h:1002
@ SDL_GPU_BLENDFACTOR_INVALID
Definition SDL_gpu.h:996
@ SDL_GPU_BLENDFACTOR_DST_ALPHA
Definition SDL_gpu.h:1005
@ SDL_GPU_BLENDFACTOR_ZERO
Definition SDL_gpu.h:997
@ SDL_GPU_BLENDFACTOR_DST_COLOR
Definition SDL_gpu.h:1001
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA
Definition SDL_gpu.h:1006
@ SDL_GPU_BLENDFACTOR_SRC_ALPHA
Definition SDL_gpu.h:1003
@ SDL_GPU_BLENDFACTOR_SRC_COLOR
Definition SDL_gpu.h:999
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR
Definition SDL_gpu.h:1000
@ SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE
Definition SDL_gpu.h:1009
@ SDL_GPU_BLENDFACTOR_ONE
Definition SDL_gpu.h:998
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR
Definition SDL_gpu.h:1008
const char * SDL_GetGPUDriver(int index)
SDL_GPUCullMode
Definition SDL_gpu.h:901
@ SDL_GPU_CULLMODE_FRONT
Definition SDL_gpu.h:903
@ SDL_GPU_CULLMODE_NONE
Definition SDL_gpu.h:902
@ SDL_GPU_CULLMODE_BACK
Definition SDL_gpu.h:904
void SDL_CopyGPUBufferToBuffer(SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferLocation *source, const SDL_GPUBufferLocation *destination, Uint32 size, bool cycle)
void SDL_InsertGPUDebugLabel(SDL_GPUCommandBuffer *command_buffer, const char *text)
bool SDL_WaitForGPUIdle(SDL_GPUDevice *device)
SDL_GPUStoreOp
Definition SDL_gpu.h:417
@ SDL_GPU_STOREOP_RESOLVE_AND_STORE
Definition SDL_gpu.h:421
@ SDL_GPU_STOREOP_STORE
Definition SDL_gpu.h:418
@ SDL_GPU_STOREOP_DONT_CARE
Definition SDL_gpu.h:419
@ SDL_GPU_STOREOP_RESOLVE
Definition SDL_gpu.h:420
SDL_GPUShaderFormat SDL_GetGPUShaderFormats(SDL_GPUDevice *device)
void SDL_BindGPUFragmentStorageTextures(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings)
void SDL_DispatchGPUComputeIndirect(SDL_GPUComputePass *compute_pass, SDL_GPUBuffer *buffer, Uint32 offset)
SDL_GPUSamplerMipmapMode
Definition SDL_gpu.h:1047
@ SDL_GPU_SAMPLERMIPMAPMODE_NEAREST
Definition SDL_gpu.h:1048
@ SDL_GPU_SAMPLERMIPMAPMODE_LINEAR
Definition SDL_gpu.h:1049
bool SDL_ClaimWindowForGPUDevice(SDL_GPUDevice *device, SDL_Window *window)
struct SDL_GPUSampler SDL_GPUSampler
Definition SDL_gpu.h:262
struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer
Definition SDL_gpu.h:324
SDL_GPULoadOp
Definition SDL_gpu.h:402
@ SDL_GPU_LOADOP_DONT_CARE
Definition SDL_gpu.h:405
@ SDL_GPU_LOADOP_CLEAR
Definition SDL_gpu.h:404
@ SDL_GPU_LOADOP_LOAD
Definition SDL_gpu.h:403
SDL_GPUStencilOp
Definition SDL_gpu.h:950
@ SDL_GPU_STENCILOP_DECREMENT_AND_WRAP
Definition SDL_gpu.h:959
@ SDL_GPU_STENCILOP_ZERO
Definition SDL_gpu.h:953
@ SDL_GPU_STENCILOP_KEEP
Definition SDL_gpu.h:952
@ SDL_GPU_STENCILOP_INVERT
Definition SDL_gpu.h:957
@ SDL_GPU_STENCILOP_REPLACE
Definition SDL_gpu.h:954
@ SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP
Definition SDL_gpu.h:956
@ SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP
Definition SDL_gpu.h:955
@ SDL_GPU_STENCILOP_INCREMENT_AND_WRAP
Definition SDL_gpu.h:958
@ SDL_GPU_STENCILOP_INVALID
Definition SDL_gpu.h:951
struct SDL_GPUFence SDL_GPUFence
Definition SDL_gpu.h:375
Uint32 SDL_GPUTextureFormatTexelBlockSize(SDL_GPUTextureFormat format)
SDL_GPUBlendOp
Definition SDL_gpu.h:974
@ SDL_GPU_BLENDOP_MIN
Definition SDL_gpu.h:979
@ SDL_GPU_BLENDOP_INVALID
Definition SDL_gpu.h:975
@ SDL_GPU_BLENDOP_MAX
Definition SDL_gpu.h:980
@ SDL_GPU_BLENDOP_REVERSE_SUBTRACT
Definition SDL_gpu.h:978
@ SDL_GPU_BLENDOP_SUBTRACT
Definition SDL_gpu.h:977
@ SDL_GPU_BLENDOP_ADD
Definition SDL_gpu.h:976
void SDL_DrawGPUPrimitives(SDL_GPURenderPass *render_pass, Uint32 num_vertices, Uint32 num_instances, Uint32 first_vertex, Uint32 first_instance)
bool SDL_WindowSupportsGPUPresentMode(SDL_GPUDevice *device, SDL_Window *window, SDL_GPUPresentMode present_mode)
int SDL_GetNumGPUDrivers(void)
void SDL_ReleaseGPUSampler(SDL_GPUDevice *device, SDL_GPUSampler *sampler)
void SDL_GenerateMipmapsForGPUTexture(SDL_GPUCommandBuffer *command_buffer, SDL_GPUTexture *texture)
void SDL_BindGPUComputeStorageBuffers(SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings)
SDL_GPUGraphicsPipeline * SDL_CreateGPUGraphicsPipeline(SDL_GPUDevice *device, const SDL_GPUGraphicsPipelineCreateInfo *createinfo)
Uint8 SDL_GPUColorComponentFlags
Definition SDL_gpu.h:1019
SDL_GPUSampler * SDL_CreateGPUSampler(SDL_GPUDevice *device, const SDL_GPUSamplerCreateInfo *createinfo)
void SDL_SetGPUStencilReference(SDL_GPURenderPass *render_pass, Uint8 reference)
struct SDL_GPUGraphicsPipeline SDL_GPUGraphicsPipeline
Definition SDL_gpu.h:299
void SDL_SetGPUBlendConstants(SDL_GPURenderPass *render_pass, SDL_FColor blend_constants)
void SDL_DispatchGPUCompute(SDL_GPUComputePass *compute_pass, Uint32 groupcount_x, Uint32 groupcount_y, Uint32 groupcount_z)
bool SDL_WindowSupportsGPUSwapchainComposition(SDL_GPUDevice *device, SDL_Window *window, SDL_GPUSwapchainComposition swapchain_composition)
void SDL_ReleaseGPUTexture(SDL_GPUDevice *device, SDL_GPUTexture *texture)
void SDL_UnmapGPUTransferBuffer(SDL_GPUDevice *device, SDL_GPUTransferBuffer *transfer_buffer)
void SDL_PushGPUVertexUniformData(SDL_GPUCommandBuffer *command_buffer, Uint32 slot_index, const void *data, Uint32 length)
SDL_GPUVertexElementFormat
Definition SDL_gpu.h:809
@ SDL_GPU_VERTEXELEMENTFORMAT_INT4
Definition SDL_gpu.h:816
@ SDL_GPU_VERTEXELEMENTFORMAT_INT
Definition SDL_gpu.h:813
@ SDL_GPU_VERTEXELEMENTFORMAT_INVALID
Definition SDL_gpu.h:810
@ SDL_GPU_VERTEXELEMENTFORMAT_HALF2
Definition SDL_gpu.h:863
@ SDL_GPU_VERTEXELEMENTFORMAT_BYTE2
Definition SDL_gpu.h:831
@ SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4
Definition SDL_gpu.h:836
@ SDL_GPU_VERTEXELEMENTFORMAT_USHORT4
Definition SDL_gpu.h:852
@ SDL_GPU_VERTEXELEMENTFORMAT_INT2
Definition SDL_gpu.h:814
@ SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM
Definition SDL_gpu.h:839
@ SDL_GPU_VERTEXELEMENTFORMAT_UINT2
Definition SDL_gpu.h:820
@ SDL_GPU_VERTEXELEMENTFORMAT_BYTE4
Definition SDL_gpu.h:832
@ SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM
Definition SDL_gpu.h:855
@ SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4
Definition SDL_gpu.h:828
@ SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM
Definition SDL_gpu.h:843
@ SDL_GPU_VERTEXELEMENTFORMAT_UINT3
Definition SDL_gpu.h:821
@ SDL_GPU_VERTEXELEMENTFORMAT_UINT
Definition SDL_gpu.h:819
@ SDL_GPU_VERTEXELEMENTFORMAT_UINT4
Definition SDL_gpu.h:822
@ SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM
Definition SDL_gpu.h:859
@ SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3
Definition SDL_gpu.h:827
@ SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2
Definition SDL_gpu.h:835
@ SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2
Definition SDL_gpu.h:826
@ SDL_GPU_VERTEXELEMENTFORMAT_SHORT4
Definition SDL_gpu.h:848
@ SDL_GPU_VERTEXELEMENTFORMAT_FLOAT
Definition SDL_gpu.h:825
@ SDL_GPU_VERTEXELEMENTFORMAT_SHORT2
Definition SDL_gpu.h:847
@ SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM
Definition SDL_gpu.h:840
@ SDL_GPU_VERTEXELEMENTFORMAT_HALF4
Definition SDL_gpu.h:864
@ SDL_GPU_VERTEXELEMENTFORMAT_USHORT2
Definition SDL_gpu.h:851
@ SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM
Definition SDL_gpu.h:844
@ SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM
Definition SDL_gpu.h:856
@ SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM
Definition SDL_gpu.h:860
@ SDL_GPU_VERTEXELEMENTFORMAT_INT3
Definition SDL_gpu.h:815
void SDL_BindGPUComputeSamplers(SDL_GPUComputePass *compute_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings)
void SDL_ReleaseGPUShader(SDL_GPUDevice *device, SDL_GPUShader *shader)
void SDL_BlitGPUTexture(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUBlitInfo *info)
struct SDL_GPUComputePipeline SDL_GPUComputePipeline
Definition SDL_gpu.h:286
SDL_GPURenderPass * SDL_BeginGPURenderPass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUColorTargetInfo *color_target_infos, Uint32 num_color_targets, const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info)
void SDL_BindGPUComputePipeline(SDL_GPUComputePass *compute_pass, SDL_GPUComputePipeline *compute_pipeline)
struct SDL_GPUTexture SDL_GPUTexture
Definition SDL_gpu.h:250
void SDL_ReleaseGPUBuffer(SDL_GPUDevice *device, SDL_GPUBuffer *buffer)
Uint32 SDL_GPUTextureUsageFlags
Definition SDL_gpu.h:668
void SDL_ReleaseGPUFence(SDL_GPUDevice *device, SDL_GPUFence *fence)
Uint32 SDL_GPUBufferUsageFlags
Definition SDL_gpu.h:744
SDL_GPUComputePass * SDL_BeginGPUComputePass(SDL_GPUCommandBuffer *command_buffer, const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings, Uint32 num_storage_texture_bindings, const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings, Uint32 num_storage_buffer_bindings)
SDL_GPUPresentMode
Definition SDL_gpu.h:1093
@ SDL_GPU_PRESENTMODE_VSYNC
Definition SDL_gpu.h:1094
@ SDL_GPU_PRESENTMODE_IMMEDIATE
Definition SDL_gpu.h:1095
@ SDL_GPU_PRESENTMODE_MAILBOX
Definition SDL_gpu.h:1096
void SDL_BindGPUVertexBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUBufferBinding *bindings, Uint32 num_bindings)
void SDL_CopyGPUTextureToTexture(SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureLocation *source, const SDL_GPUTextureLocation *destination, Uint32 w, Uint32 h, Uint32 d, bool cycle)
void SDL_BindGPUIndexBuffer(SDL_GPURenderPass *render_pass, const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize index_element_size)
SDL_GPUBuffer * SDL_CreateGPUBuffer(SDL_GPUDevice *device, const SDL_GPUBufferCreateInfo *createinfo)
void SDL_UploadToGPUBuffer(SDL_GPUCopyPass *copy_pass, const SDL_GPUTransferBufferLocation *source, const SDL_GPUBufferRegion *destination, bool cycle)
bool SDL_WaitAndAcquireGPUSwapchainTexture(SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, SDL_GPUTexture **swapchain_texture, Uint32 *swapchain_texture_width, Uint32 *swapchain_texture_height)
bool SDL_GPUTextureSupportsSampleCount(SDL_GPUDevice *device, SDL_GPUTextureFormat format, SDL_GPUSampleCount sample_count)
bool SDL_SetGPUAllowedFramesInFlight(SDL_GPUDevice *device, Uint32 allowed_frames_in_flight)
bool SDL_AcquireGPUSwapchainTexture(SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, SDL_GPUTexture **swapchain_texture, Uint32 *swapchain_texture_width, Uint32 *swapchain_texture_height)
struct SDL_GPUBuffer SDL_GPUBuffer
Definition SDL_gpu.h:211
SDL_GPUCompareOp
Definition SDL_gpu.h:929
@ SDL_GPU_COMPAREOP_NEVER
Definition SDL_gpu.h:931
@ SDL_GPU_COMPAREOP_INVALID
Definition SDL_gpu.h:930
@ SDL_GPU_COMPAREOP_GREATER
Definition SDL_gpu.h:935
@ SDL_GPU_COMPAREOP_LESS
Definition SDL_gpu.h:932
@ SDL_GPU_COMPAREOP_GREATER_OR_EQUAL
Definition SDL_gpu.h:937
@ SDL_GPU_COMPAREOP_ALWAYS
Definition SDL_gpu.h:938
@ SDL_GPU_COMPAREOP_LESS_OR_EQUAL
Definition SDL_gpu.h:934
@ SDL_GPU_COMPAREOP_NOT_EQUAL
Definition SDL_gpu.h:936
@ SDL_GPU_COMPAREOP_EQUAL
Definition SDL_gpu.h:933
void SDL_BindGPUVertexSamplers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings)
struct SDL_GPUCopyPass SDL_GPUCopyPass
Definition SDL_gpu.h:363
bool SDL_WaitForGPUFences(SDL_GPUDevice *device, bool wait_all, SDL_GPUFence *const *fences, Uint32 num_fences)
SDL_GPUComputePipeline * SDL_CreateGPUComputePipeline(SDL_GPUDevice *device, const SDL_GPUComputePipelineCreateInfo *createinfo)
bool SDL_QueryGPUFence(SDL_GPUDevice *device, SDL_GPUFence *fence)
SDL_GPUFence * SDL_SubmitGPUCommandBufferAndAcquireFence(SDL_GPUCommandBuffer *command_buffer)
void SDL_DrawGPUIndexedPrimitives(SDL_GPURenderPass *render_pass, Uint32 num_indices, Uint32 num_instances, Uint32 first_index, Sint32 vertex_offset, Uint32 first_instance)
SDL_GPUFilter
Definition SDL_gpu.h:1034
@ SDL_GPU_FILTER_NEAREST
Definition SDL_gpu.h:1035
@ SDL_GPU_FILTER_LINEAR
Definition SDL_gpu.h:1036
SDL_GPUTransferBufferUsage
Definition SDL_gpu.h:764
@ SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
Definition SDL_gpu.h:766
@ SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD
Definition SDL_gpu.h:765
void SDL_DrawGPUPrimitivesIndirect(SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 draw_count)
void SDL_BindGPUGraphicsPipeline(SDL_GPURenderPass *render_pass, SDL_GPUGraphicsPipeline *graphics_pipeline)
void SDL_SetGPUViewport(SDL_GPURenderPass *render_pass, const SDL_GPUViewport *viewport)
struct SDL_GPUShader SDL_GPUShader
Definition SDL_gpu.h:273
SDL_GPUTextureFormat SDL_GetGPUSwapchainTextureFormat(SDL_GPUDevice *device, SDL_Window *window)
bool SDL_SetGPUSwapchainParameters(SDL_GPUDevice *device, SDL_Window *window, SDL_GPUSwapchainComposition swapchain_composition, SDL_GPUPresentMode present_mode)
SDL_GPUSwapchainComposition
Definition SDL_gpu.h:1125
@ SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048
Definition SDL_gpu.h:1129
@ SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR
Definition SDL_gpu.h:1127
@ SDL_GPU_SWAPCHAINCOMPOSITION_SDR
Definition SDL_gpu.h:1126
@ SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR
Definition SDL_gpu.h:1128
void SDL_PushGPUComputeUniformData(SDL_GPUCommandBuffer *command_buffer, Uint32 slot_index, const void *data, Uint32 length)
bool SDL_WaitForGPUSwapchain(SDL_GPUDevice *device, SDL_Window *window)
void SDL_SetGPUScissor(SDL_GPURenderPass *render_pass, const SDL_Rect *scissor)
void SDL_ReleaseGPUTransferBuffer(SDL_GPUDevice *device, SDL_GPUTransferBuffer *transfer_buffer)
SDL_GPUShaderStage
Definition SDL_gpu.h:777
@ SDL_GPU_SHADERSTAGE_FRAGMENT
Definition SDL_gpu.h:779
@ SDL_GPU_SHADERSTAGE_VERTEX
Definition SDL_gpu.h:778
void SDL_ReleaseWindowFromGPUDevice(SDL_GPUDevice *device, SDL_Window *window)
void SDL_SetGPUBufferName(SDL_GPUDevice *device, SDL_GPUBuffer *buffer, const char *text)
void SDL_BindGPUFragmentStorageBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings)
const char * SDL_GetGPUDeviceDriver(SDL_GPUDevice *device)
SDL_GPUTextureType
Definition SDL_gpu.h:686
@ SDL_GPU_TEXTURETYPE_CUBE_ARRAY
Definition SDL_gpu.h:691
@ SDL_GPU_TEXTURETYPE_3D
Definition SDL_gpu.h:689
@ SDL_GPU_TEXTURETYPE_CUBE
Definition SDL_gpu.h:690
@ SDL_GPU_TEXTURETYPE_2D
Definition SDL_gpu.h:687
@ SDL_GPU_TEXTURETYPE_2D_ARRAY
Definition SDL_gpu.h:688
void SDL_UploadToGPUTexture(SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureTransferInfo *source, const SDL_GPUTextureRegion *destination, bool cycle)
Uint32 SDL_CalculateGPUTextureFormatSize(SDL_GPUTextureFormat format, Uint32 width, Uint32 height, Uint32 depth_or_layer_count)
void SDL_DrawGPUIndexedPrimitivesIndirect(SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 draw_count)
void SDL_BindGPUFragmentSamplers(SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings)
SDL_GPUSamplerAddressMode
Definition SDL_gpu.h:1061
@ SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT
Definition SDL_gpu.h:1063
@ SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE
Definition SDL_gpu.h:1064
@ SDL_GPU_SAMPLERADDRESSMODE_REPEAT
Definition SDL_gpu.h:1062
void SDL_ReleaseGPUGraphicsPipeline(SDL_GPUDevice *device, SDL_GPUGraphicsPipeline *graphics_pipeline)
SDL_GPUTextureFormat
Definition SDL_gpu.h:524
@ SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM
Definition SDL_gpu.h:539
@ SDL_GPU_TEXTUREFORMAT_D16_UNORM
Definition SDL_gpu.h:596
@ SDL_GPU_TEXTUREFORMAT_R16G16_INT
Definition SDL_gpu.h:582
@ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT
Definition SDL_gpu.h:573
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x6_FLOAT
Definition SDL_gpu.h:641
@ SDL_GPU_TEXTUREFORMAT_R8_UINT
Definition SDL_gpu.h:568
@ SDL_GPU_TEXTUREFORMAT_R8G8_SNORM
Definition SDL_gpu.h:553
@ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM
Definition SDL_gpu.h:534
@ SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM
Definition SDL_gpu.h:604
@ SDL_GPU_TEXTUREFORMAT_A8_UNORM
Definition SDL_gpu.h:528
@ SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT
Definition SDL_gpu.h:548
@ SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM_SRGB
Definition SDL_gpu.h:621
@ SDL_GPU_TEXTUREFORMAT_R16_UINT
Definition SDL_gpu.h:571
@ SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM
Definition SDL_gpu.h:602
@ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM
Definition SDL_gpu.h:557
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM
Definition SDL_gpu.h:610
@ SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM
Definition SDL_gpu.h:545
@ SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM
Definition SDL_gpu.h:605
@ SDL_GPU_TEXTUREFORMAT_R32_INT
Definition SDL_gpu.h:584
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x6_FLOAT
Definition SDL_gpu.h:638
@ SDL_GPU_TEXTUREFORMAT_R16_INT
Definition SDL_gpu.h:581
@ SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT
Definition SDL_gpu.h:576
@ SDL_GPU_TEXTUREFORMAT_R32G32_INT
Definition SDL_gpu.h:585
@ SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM
Definition SDL_gpu.h:544
@ SDL_GPU_TEXTUREFORMAT_ASTC_12x10_FLOAT
Definition SDL_gpu.h:644
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM_SRGB
Definition SDL_gpu.h:625
@ SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT
Definition SDL_gpu.h:563
@ SDL_GPU_TEXTUREFORMAT_R32_UINT
Definition SDL_gpu.h:574
@ SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM_SRGB
Definition SDL_gpu.h:620
@ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB
Definition SDL_gpu.h:588
@ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM
Definition SDL_gpu.h:554
@ SDL_GPU_TEXTUREFORMAT_R16_UNORM
Definition SDL_gpu.h:532
@ SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT
Definition SDL_gpu.h:600
@ SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT
Definition SDL_gpu.h:550
@ SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM
Definition SDL_gpu.h:546
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM
Definition SDL_gpu.h:611
@ SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM
Definition SDL_gpu.h:542
@ SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT
Definition SDL_gpu.h:564
@ SDL_GPU_TEXTUREFORMAT_ASTC_6x6_FLOAT
Definition SDL_gpu.h:636
@ SDL_GPU_TEXTUREFORMAT_R8_SNORM
Definition SDL_gpu.h:552
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x8_FLOAT
Definition SDL_gpu.h:639
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM_SRGB
Definition SDL_gpu.h:628
@ SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB
Definition SDL_gpu.h:591
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM_SRGB
Definition SDL_gpu.h:624
@ SDL_GPU_TEXTUREFORMAT_R8_UNORM
Definition SDL_gpu.h:529
@ SDL_GPU_TEXTUREFORMAT_D24_UNORM
Definition SDL_gpu.h:597
@ SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB
Definition SDL_gpu.h:592
@ SDL_GPU_TEXTUREFORMAT_INVALID
Definition SDL_gpu.h:525
@ SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM_SRGB
Definition SDL_gpu.h:617
@ SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM_SRGB
Definition SDL_gpu.h:619
@ SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT
Definition SDL_gpu.h:645
@ SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM_SRGB
Definition SDL_gpu.h:618
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x8_FLOAT
Definition SDL_gpu.h:642
@ SDL_GPU_TEXTUREFORMAT_ASTC_5x4_FLOAT
Definition SDL_gpu.h:633
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x5_FLOAT
Definition SDL_gpu.h:637
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM_SRGB
Definition SDL_gpu.h:623
@ SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM
Definition SDL_gpu.h:543
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM
Definition SDL_gpu.h:613
@ SDL_GPU_TEXTUREFORMAT_R16G16_SNORM
Definition SDL_gpu.h:556
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM
Definition SDL_gpu.h:608
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x10_FLOAT
Definition SDL_gpu.h:643
@ SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM
Definition SDL_gpu.h:538
@ SDL_GPU_TEXTUREFORMAT_R8G8_INT
Definition SDL_gpu.h:579
@ SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM
Definition SDL_gpu.h:603
@ SDL_GPU_TEXTUREFORMAT_D32_FLOAT
Definition SDL_gpu.h:598
@ SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT
Definition SDL_gpu.h:586
@ SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM
Definition SDL_gpu.h:614
@ SDL_GPU_TEXTUREFORMAT_ASTC_4x4_FLOAT
Definition SDL_gpu.h:632
@ SDL_GPU_TEXTUREFORMAT_R8_INT
Definition SDL_gpu.h:578
@ SDL_GPU_TEXTUREFORMAT_R8G8_UINT
Definition SDL_gpu.h:569
@ SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT
Definition SDL_gpu.h:560
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM
Definition SDL_gpu.h:612
@ SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM
Definition SDL_gpu.h:615
@ SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM_SRGB
Definition SDL_gpu.h:629
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM_SRGB
Definition SDL_gpu.h:622
@ SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM
Definition SDL_gpu.h:537
@ SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB
Definition SDL_gpu.h:593
@ SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM
Definition SDL_gpu.h:541
@ SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB
Definition SDL_gpu.h:594
@ SDL_GPU_TEXTUREFORMAT_R32_FLOAT
Definition SDL_gpu.h:562
@ SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT
Definition SDL_gpu.h:599
@ SDL_GPU_TEXTUREFORMAT_R32G32_UINT
Definition SDL_gpu.h:575
@ SDL_GPU_TEXTUREFORMAT_R8G8_UNORM
Definition SDL_gpu.h:530
@ SDL_GPU_TEXTUREFORMAT_ASTC_5x5_FLOAT
Definition SDL_gpu.h:634
@ SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB
Definition SDL_gpu.h:589
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM_SRGB
Definition SDL_gpu.h:627
@ SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM
Definition SDL_gpu.h:536
@ SDL_GPU_TEXTUREFORMAT_R16G16_UNORM
Definition SDL_gpu.h:533
@ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM
Definition SDL_gpu.h:531
@ SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT
Definition SDL_gpu.h:566
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x5_FLOAT
Definition SDL_gpu.h:640
@ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT
Definition SDL_gpu.h:583
@ SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM
Definition SDL_gpu.h:606
@ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT
Definition SDL_gpu.h:570
@ SDL_GPU_TEXTUREFORMAT_R16G16_UINT
Definition SDL_gpu.h:572
@ SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT
Definition SDL_gpu.h:561
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM
Definition SDL_gpu.h:609
@ SDL_GPU_TEXTUREFORMAT_R16_SNORM
Definition SDL_gpu.h:555
@ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT
Definition SDL_gpu.h:580
@ SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM
Definition SDL_gpu.h:535
@ SDL_GPU_TEXTUREFORMAT_R16_FLOAT
Definition SDL_gpu.h:559
@ SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM_SRGB
Definition SDL_gpu.h:626
@ SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM_SRGB
Definition SDL_gpu.h:630
@ SDL_GPU_TEXTUREFORMAT_ASTC_6x5_FLOAT
Definition SDL_gpu.h:635
@ SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM
Definition SDL_gpu.h:607
struct SDL_GPUComputePass SDL_GPUComputePass
Definition SDL_gpu.h:350
bool SDL_GPUSupportsProperties(SDL_PropertiesID props)
bool SDL_GPUSupportsShaderFormats(SDL_GPUShaderFormat format_flags, const char *name)
void * SDL_MapGPUTransferBuffer(SDL_GPUDevice *device, SDL_GPUTransferBuffer *transfer_buffer, bool cycle)
void SDL_BindGPUVertexStorageBuffers(SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings)
struct SDL_GPUDevice SDL_GPUDevice
Definition SDL_gpu.h:186
void SDL_DownloadFromGPUTexture(SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureRegion *source, const SDL_GPUTextureTransferInfo *destination)
Uint32 SDL_PropertiesID
uint8_t Uint8
Definition SDL_stdinc.h:337
int32_t Sint32
Definition SDL_stdinc.h:364
SDL_MALLOC size_t size
Definition SDL_stdinc.h:737
uint32_t Uint32
Definition SDL_stdinc.h:373
SDL_FlipMode
Definition SDL_surface.h:95
struct SDL_Window SDL_Window
Definition SDL_video.h:165
SDL_FlipMode flip_mode
Definition SDL_gpu.h:1819
SDL_FColor clear_color
Definition SDL_gpu.h:1818
SDL_GPUFilter filter
Definition SDL_gpu.h:1820
SDL_GPUBlitRegion source
Definition SDL_gpu.h:1815
SDL_GPUBlitRegion destination
Definition SDL_gpu.h:1816
SDL_GPULoadOp load_op
Definition SDL_gpu.h:1817
SDL_GPUTexture * texture
Definition SDL_gpu.h:1235
Uint32 layer_or_depth_plane
Definition SDL_gpu.h:1237
SDL_GPUBuffer * buffer
Definition SDL_gpu.h:1839
SDL_PropertiesID props
Definition SDL_gpu.h:1529
SDL_GPUBufferUsageFlags usage
Definition SDL_gpu.h:1526
SDL_GPUBuffer * buffer
Definition SDL_gpu.h:1255
SDL_GPUBuffer * buffer
Definition SDL_gpu.h:1271
SDL_GPUBlendOp color_blend_op
Definition SDL_gpu.h:1448
SDL_GPUColorComponentFlags color_write_mask
Definition SDL_gpu.h:1452
SDL_GPUBlendFactor src_alpha_blendfactor
Definition SDL_gpu.h:1449
SDL_GPUBlendOp alpha_blend_op
Definition SDL_gpu.h:1451
SDL_GPUBlendFactor dst_alpha_blendfactor
Definition SDL_gpu.h:1450
SDL_GPUBlendFactor src_color_blendfactor
Definition SDL_gpu.h:1446
SDL_GPUBlendFactor dst_color_blendfactor
Definition SDL_gpu.h:1447
SDL_GPUColorTargetBlendState blend_state
Definition SDL_gpu.h:1628
SDL_GPUTextureFormat format
Definition SDL_gpu.h:1627
SDL_FColor clear_color
Definition SDL_gpu.h:1737
SDL_GPUTexture * texture
Definition SDL_gpu.h:1734
SDL_GPULoadOp load_op
Definition SDL_gpu.h:1738
SDL_GPUTexture * resolve_texture
Definition SDL_gpu.h:1740
SDL_GPUStoreOp store_op
Definition SDL_gpu.h:1739
SDL_GPUShaderFormat format
Definition SDL_gpu.h:1683
SDL_GPUStencilOpState back_stencil_state
Definition SDL_gpu.h:1605
SDL_GPUCompareOp compare_op
Definition SDL_gpu.h:1604
SDL_GPUStencilOpState front_stencil_state
Definition SDL_gpu.h:1606
SDL_GPUTexture * texture
Definition SDL_gpu.h:1795
SDL_GPUStoreOp stencil_store_op
Definition SDL_gpu.h:1800
SDL_GPULoadOp stencil_load_op
Definition SDL_gpu.h:1799
SDL_GPUMultisampleState multisample_state
Definition SDL_gpu.h:1664
SDL_GPUPrimitiveType primitive_type
Definition SDL_gpu.h:1662
SDL_GPUDepthStencilState depth_stencil_state
Definition SDL_gpu.h:1665
SDL_GPUGraphicsPipelineTargetInfo target_info
Definition SDL_gpu.h:1666
SDL_GPUVertexInputState vertex_input_state
Definition SDL_gpu.h:1661
SDL_GPURasterizerState rasterizer_state
Definition SDL_gpu.h:1663
SDL_GPUTextureFormat depth_stencil_format
Definition SDL_gpu.h:1643
const SDL_GPUColorTargetDescription * color_target_descriptions
Definition SDL_gpu.h:1641
SDL_GPUSampleCount sample_count
Definition SDL_gpu.h:1586
SDL_GPUFrontFace front_face
Definition SDL_gpu.h:1566
SDL_GPUCullMode cull_mode
Definition SDL_gpu.h:1565
float depth_bias_constant_factor
Definition SDL_gpu.h:1567
SDL_GPUFillMode fill_mode
Definition SDL_gpu.h:1564
SDL_GPUFilter mag_filter
Definition SDL_gpu.h:1343
SDL_GPUSamplerAddressMode address_mode_u
Definition SDL_gpu.h:1345
SDL_GPUSamplerMipmapMode mipmap_mode
Definition SDL_gpu.h:1344
SDL_GPUSamplerAddressMode address_mode_v
Definition SDL_gpu.h:1346
SDL_GPUSamplerAddressMode address_mode_w
Definition SDL_gpu.h:1347
SDL_GPUFilter min_filter
Definition SDL_gpu.h:1342
SDL_PropertiesID props
Definition SDL_gpu.h:1358
SDL_GPUCompareOp compare_op
Definition SDL_gpu.h:1350
SDL_PropertiesID props
Definition SDL_gpu.h:1479
SDL_GPUShaderFormat format
Definition SDL_gpu.h:1472
const Uint8 * code
Definition SDL_gpu.h:1470
const char * entrypoint
Definition SDL_gpu.h:1471
SDL_GPUShaderStage stage
Definition SDL_gpu.h:1473
SDL_GPUStencilOp fail_op
Definition SDL_gpu.h:1431
SDL_GPUStencilOp depth_fail_op
Definition SDL_gpu.h:1433
SDL_GPUStencilOp pass_op
Definition SDL_gpu.h:1432
SDL_GPUCompareOp compare_op
Definition SDL_gpu.h:1434
SDL_PropertiesID props
Definition SDL_gpu.h:1504
SDL_GPUTextureUsageFlags usage
Definition SDL_gpu.h:1497
SDL_GPUTextureFormat format
Definition SDL_gpu.h:1496
SDL_GPUTextureType type
Definition SDL_gpu.h:1495
SDL_GPUSampleCount sample_count
Definition SDL_gpu.h:1502
SDL_GPUTexture * texture
Definition SDL_gpu.h:1195
SDL_GPUTexture * texture
Definition SDL_gpu.h:1215
SDL_GPUSampler * sampler
Definition SDL_gpu.h:1854
SDL_GPUTexture * texture
Definition SDL_gpu.h:1853
SDL_GPUTransferBuffer * transfer_buffer
Definition SDL_gpu.h:1162
SDL_GPUTransferBufferUsage usage
Definition SDL_gpu.h:1541
SDL_GPUTransferBuffer * transfer_buffer
Definition SDL_gpu.h:1180
SDL_GPUVertexElementFormat format
Definition SDL_gpu.h:1402
SDL_GPUVertexInputRate input_rate
Definition SDL_gpu.h:1383
const SDL_GPUVertexAttribute * vertex_attributes
Definition SDL_gpu.h:1418
const SDL_GPUVertexBufferDescription * vertex_buffer_descriptions
Definition SDL_gpu.h:1416