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