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