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