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