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