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