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 */
1117
1118 /* 10-bit Unsigned Normalized */
1121
1122/**
1123 * Specifies the rate at which vertex attributes are pulled from buffers.
1124 *
1125 * \since This enum is available since SDL 3.2.0.
1126 *
1127 * \sa SDL_CreateGPUGraphicsPipeline
1128 */
1130{
1131 SDL_GPU_VERTEXINPUTRATE_VERTEX, /**< Attribute addressing is a function of the vertex index. */
1132 SDL_GPU_VERTEXINPUTRATE_INSTANCE /**< Attribute addressing is a function of the instance index. */
1134
1135/**
1136 * Specifies the fill mode of the graphics pipeline.
1137 *
1138 * \since This enum is available since SDL 3.2.0.
1139 *
1140 * \sa SDL_CreateGPUGraphicsPipeline
1141 */
1143{
1144 SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */
1145 SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */
1147
1148/**
1149 * Specifies the facing direction in which triangle faces will be culled.
1150 *
1151 * \since This enum is available since SDL 3.2.0.
1152 *
1153 * \sa SDL_CreateGPUGraphicsPipeline
1154 */
1156{
1157 SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */
1158 SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */
1159 SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */
1161
1162/**
1163 * Specifies the vertex winding that will cause a triangle to be determined to
1164 * be front-facing.
1165 *
1166 * \since This enum is available since SDL 3.2.0.
1167 *
1168 * \sa SDL_CreateGPUGraphicsPipeline
1169 */
1171{
1172 SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */
1173 SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */
1175
1176/**
1177 * Specifies a comparison operator for depth, stencil and sampler operations.
1178 *
1179 * \since This enum is available since SDL 3.2.0.
1180 *
1181 * \sa SDL_CreateGPUGraphicsPipeline
1182 */
1184{
1186 SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */
1187 SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */
1188 SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */
1189 SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */
1190 SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */
1191 SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */
1192 SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evaluates reference >= test. */
1193 SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */
1195
1196/**
1197 * Specifies what happens to a stored stencil value if stencil tests fail or
1198 * pass.
1199 *
1200 * \since This enum is available since SDL 3.2.0.
1201 *
1202 * \sa SDL_CreateGPUGraphicsPipeline
1203 */
1205{
1207 SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */
1208 SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */
1209 SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */
1210 SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */
1211 SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */
1212 SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */
1213 SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */
1214 SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */
1216
1217/**
1218 * Specifies the operator to be used when pixels in a render target are
1219 * blended with existing pixels in the texture.
1220 *
1221 * The source color is the value written by the fragment shader. The
1222 * destination color is the value currently existing in the texture.
1223 *
1224 * \since This enum is available since SDL 3.2.0.
1225 *
1226 * \sa SDL_CreateGPUGraphicsPipeline
1227 */
1228typedef enum SDL_GPUBlendOp
1229{
1231 SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */
1232 SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */
1233 SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */
1234 SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */
1235 SDL_GPU_BLENDOP_MAX /**< max(source, destination) */
1237
1238/**
1239 * Specifies a blending factor to be used when pixels in a render target are
1240 * blended with existing pixels in the texture.
1241 *
1242 * The source color is the value written by the fragment shader. The
1243 * destination color is the value currently existing in the texture.
1244 *
1245 * \since This enum is available since SDL 3.2.0.
1246 *
1247 * \sa SDL_CreateGPUGraphicsPipeline
1248 */
1266
1267/**
1268 * Specifies which color components are written in a graphics pipeline.
1269 *
1270 * \since This datatype is available since SDL 3.2.0.
1271 *
1272 * \sa SDL_CreateGPUGraphicsPipeline
1273 */
1275
1276#define SDL_GPU_COLORCOMPONENT_R (1u << 0) /**< the red component */
1277#define SDL_GPU_COLORCOMPONENT_G (1u << 1) /**< the green component */
1278#define SDL_GPU_COLORCOMPONENT_B (1u << 2) /**< the blue component */
1279#define SDL_GPU_COLORCOMPONENT_A (1u << 3) /**< the alpha component */
1280
1281/**
1282 * Specifies a filter operation used by a sampler.
1283 *
1284 * \since This enum is available since SDL 3.2.0.
1285 *
1286 * \sa SDL_CreateGPUSampler
1287 */
1288typedef enum SDL_GPUFilter
1289{
1290 SDL_GPU_FILTER_NEAREST, /**< Point filtering. */
1291 SDL_GPU_FILTER_LINEAR /**< Linear filtering. */
1293
1294/**
1295 * Specifies a mipmap mode used by a sampler.
1296 *
1297 * \since This enum is available since SDL 3.2.0.
1298 *
1299 * \sa SDL_CreateGPUSampler
1300 */
1306
1307/**
1308 * Specifies behavior of texture sampling when the coordinates exceed the 0-1
1309 * range.
1310 *
1311 * \since This enum is available since SDL 3.2.0.
1312 *
1313 * \sa SDL_CreateGPUSampler
1314 */
1316{
1317 SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */
1318 SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */
1319 SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */
1321
1322/**
1323 * Specifies the timing that will be used to present swapchain textures to the
1324 * OS.
1325 *
1326 * VSYNC mode will always be supported. IMMEDIATE and MAILBOX modes may not be
1327 * supported on certain systems.
1328 *
1329 * It is recommended to query SDL_WindowSupportsGPUPresentMode after claiming
1330 * the window if you wish to change the present mode to IMMEDIATE or MAILBOX.
1331 *
1332 * - VSYNC: Waits for vblank before presenting. No tearing is possible. If
1333 * there is a pending image to present, the new image is enqueued for
1334 * presentation. Disallows tearing at the cost of visual latency.
1335 * - IMMEDIATE: Immediately presents. Lowest latency option, but tearing may
1336 * occur.
1337 * - MAILBOX: Waits for vblank before presenting. No tearing is possible. If
1338 * there is a pending image to present, the pending image is replaced by the
1339 * new image. Similar to VSYNC, but with reduced visual latency.
1340 *
1341 * \since This enum is available since SDL 3.2.0.
1342 *
1343 * \sa SDL_SetGPUSwapchainParameters
1344 * \sa SDL_WindowSupportsGPUPresentMode
1345 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
1346 */
1353
1354/**
1355 * Specifies the texture format and colorspace of the swapchain textures.
1356 *
1357 * SDR will always be supported. Other compositions may not be supported on
1358 * certain systems.
1359 *
1360 * It is recommended to query SDL_WindowSupportsGPUSwapchainComposition after
1361 * claiming the window if you wish to change the swapchain composition from
1362 * SDR.
1363 *
1364 * - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in sRGB encoding.
1365 * - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are
1366 * stored in memory in sRGB encoding but accessed in shaders in "linear
1367 * sRGB" encoding which is sRGB but with a linear transfer function.
1368 * - HDR_EXTENDED_LINEAR: R16G16B16A16_FLOAT swapchain. Pixel values are in
1369 * extended linear sRGB encoding and permits values outside of the [0, 1]
1370 * range.
1371 * - HDR10_ST2084: A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in
1372 * BT.2020 ST2084 (PQ) encoding.
1373 *
1374 * \since This enum is available since SDL 3.2.0.
1375 *
1376 * \sa SDL_SetGPUSwapchainParameters
1377 * \sa SDL_WindowSupportsGPUSwapchainComposition
1378 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
1379 */
1387
1388/* Structures */
1389
1390/**
1391 * A structure specifying a viewport.
1392 *
1393 * \since This struct is available since SDL 3.2.0.
1394 *
1395 * \sa SDL_SetGPUViewport
1396 */
1397typedef struct SDL_GPUViewport
1398{
1399 float x; /**< The left offset of the viewport. */
1400 float y; /**< The top offset of the viewport. */
1401 float w; /**< The width of the viewport. */
1402 float h; /**< The height of the viewport. */
1403 float min_depth; /**< The minimum depth of the viewport. */
1404 float max_depth; /**< The maximum depth of the viewport. */
1406
1407/**
1408 * A structure specifying parameters related to transferring data to or from a
1409 * texture.
1410 *
1411 * If either of `pixels_per_row` or `rows_per_layer` is zero, then width and
1412 * height of passed SDL_GPUTextureRegion to SDL_UploadToGPUTexture or
1413 * SDL_DownloadFromGPUTexture are used as default values respectively and data
1414 * is considered to be tightly packed.
1415 *
1416 * **WARNING**: On some older/integrated hardware, Direct3D 12 requires
1417 * texture data row pitch to be 256 byte aligned, and offsets to be aligned to
1418 * 512 bytes. If they are not, SDL will make a temporary copy of the data that
1419 * is properly aligned, but this adds overhead to the transfer process. Apps
1420 * can avoid this by aligning their data appropriately, or using a different
1421 * GPU backend than Direct3D 12.
1422 *
1423 * \since This struct is available since SDL 3.2.0.
1424 *
1425 * \sa SDL_UploadToGPUTexture
1426 * \sa SDL_DownloadFromGPUTexture
1427 * \sa SDL_GPUTransferBuffer
1428 */
1430{
1431 SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */
1432 Uint32 offset; /**< The starting byte of the image data in the transfer buffer. */
1433 Uint32 pixels_per_row; /**< The number of pixels from one row to the next. */
1434 Uint32 rows_per_layer; /**< The number of rows from one layer/depth-slice to the next. */
1436
1437/**
1438 * A structure specifying a location in a transfer buffer.
1439 *
1440 * Used when transferring buffer data to or from a transfer buffer.
1441 *
1442 * \since This struct is available since SDL 3.2.0.
1443 *
1444 * \sa SDL_UploadToGPUBuffer
1445 * \sa SDL_DownloadFromGPUBuffer
1446 * \sa SDL_GPUTransferBuffer
1447 */
1449{
1450 SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */
1451 Uint32 offset; /**< The starting byte of the buffer data in the transfer buffer. */
1453
1454/**
1455 * A structure specifying a location in a texture.
1456 *
1457 * Used when copying data from one texture to another.
1458 *
1459 * \since This struct is available since SDL 3.2.0.
1460 *
1461 * \sa SDL_CopyGPUTextureToTexture
1462 * \sa SDL_GPUTexture
1463 */
1465{
1466 SDL_GPUTexture *texture; /**< The texture used in the copy operation. */
1467 Uint32 mip_level; /**< The mip level index of the location. */
1468 Uint32 layer; /**< The layer index of the location. */
1469 Uint32 x; /**< The left offset of the location. */
1470 Uint32 y; /**< The top offset of the location. */
1471 Uint32 z; /**< The front offset of the location. */
1473
1474/**
1475 * A structure specifying a region of a texture.
1476 *
1477 * Used when transferring data to or from a texture.
1478 *
1479 * \since This struct is available since SDL 3.2.0.
1480 *
1481 * \sa SDL_UploadToGPUTexture
1482 * \sa SDL_DownloadFromGPUTexture
1483 * \sa SDL_CreateGPUTexture
1484 * \sa SDL_GPUTexture
1485 */
1487{
1488 SDL_GPUTexture *texture; /**< The texture used in the copy operation. */
1489 Uint32 mip_level; /**< The mip level index to transfer. */
1490 Uint32 layer; /**< The layer index to transfer. */
1491 Uint32 x; /**< The left offset of the region. */
1492 Uint32 y; /**< The top offset of the region. */
1493 Uint32 z; /**< The front offset of the region. */
1494 Uint32 w; /**< The width of the region. */
1495 Uint32 h; /**< The height of the region. */
1496 Uint32 d; /**< The depth of the region. */
1498
1499/**
1500 * A structure specifying a region of a texture used in the blit operation.
1501 *
1502 * \since This struct is available since SDL 3.2.0.
1503 *
1504 * \sa SDL_BlitGPUTexture
1505 * \sa SDL_GPUTexture
1506 */
1507typedef struct SDL_GPUBlitRegion
1508{
1509 SDL_GPUTexture *texture; /**< The texture. */
1510 Uint32 mip_level; /**< The mip level index of the region. */
1511 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. */
1512 Uint32 x; /**< The left offset of the region. */
1513 Uint32 y; /**< The top offset of the region. */
1514 Uint32 w; /**< The width of the region. */
1515 Uint32 h; /**< The height of the region. */
1517
1518/**
1519 * A structure specifying a location in a buffer.
1520 *
1521 * Used when copying data between buffers.
1522 *
1523 * \since This struct is available since SDL 3.2.0.
1524 *
1525 * \sa SDL_CopyGPUBufferToBuffer
1526 */
1528{
1529 SDL_GPUBuffer *buffer; /**< The buffer. */
1530 Uint32 offset; /**< The starting byte within the buffer. */
1532
1533/**
1534 * A structure specifying a region of a buffer.
1535 *
1536 * Used when transferring data to or from buffers.
1537 *
1538 * \since This struct is available since SDL 3.2.0.
1539 *
1540 * \sa SDL_UploadToGPUBuffer
1541 * \sa SDL_DownloadFromGPUBuffer
1542 */
1544{
1545 SDL_GPUBuffer *buffer; /**< The buffer. */
1546 Uint32 offset; /**< The starting byte within the buffer. */
1547 Uint32 size; /**< The size in bytes of the region. */
1549
1550/**
1551 * A structure specifying the parameters of an indirect draw command.
1552 *
1553 * Note that the `first_vertex` and `first_instance` parameters are NOT
1554 * compatible with built-in vertex/instance ID variables in shaders (for
1555 * example, SV_VertexID); GPU APIs and shader languages do not define these
1556 * built-in variables consistently, so if your shader depends on them, the
1557 * only way to keep behavior consistent and portable is to always pass 0 for
1558 * the correlating parameter in the draw calls.
1559 *
1560 * \since This struct is available since SDL 3.2.0.
1561 *
1562 * \sa SDL_DrawGPUPrimitivesIndirect
1563 */
1565{
1566 Uint32 num_vertices; /**< The number of vertices to draw. */
1567 Uint32 num_instances; /**< The number of instances to draw. */
1568 Uint32 first_vertex; /**< The index of the first vertex to draw. */
1569 Uint32 first_instance; /**< The ID of the first instance to draw. */
1571
1572/**
1573 * A structure specifying the parameters of an indexed indirect draw command.
1574 *
1575 * Note that the `first_vertex` and `first_instance` parameters are NOT
1576 * compatible with built-in vertex/instance ID variables in shaders (for
1577 * example, SV_VertexID); GPU APIs and shader languages do not define these
1578 * built-in variables consistently, so if your shader depends on them, the
1579 * only way to keep behavior consistent and portable is to always pass 0 for
1580 * the correlating parameter in the draw calls.
1581 *
1582 * \since This struct is available since SDL 3.2.0.
1583 *
1584 * \sa SDL_DrawGPUIndexedPrimitivesIndirect
1585 */
1587{
1588 Uint32 num_indices; /**< The number of indices to draw per instance. */
1589 Uint32 num_instances; /**< The number of instances to draw. */
1590 Uint32 first_index; /**< The base index within the index buffer. */
1591 Sint32 vertex_offset; /**< The value added to the vertex index before indexing into the vertex buffer. */
1592 Uint32 first_instance; /**< The ID of the first instance to draw. */
1594
1595/**
1596 * A structure specifying the parameters of an indexed dispatch command.
1597 *
1598 * \since This struct is available since SDL 3.2.0.
1599 *
1600 * \sa SDL_DispatchGPUComputeIndirect
1601 */
1603{
1604 Uint32 groupcount_x; /**< The number of local workgroups to dispatch in the X dimension. */
1605 Uint32 groupcount_y; /**< The number of local workgroups to dispatch in the Y dimension. */
1606 Uint32 groupcount_z; /**< The number of local workgroups to dispatch in the Z dimension. */
1608
1609/* State structures */
1610
1611/**
1612 * A structure specifying the parameters of a sampler.
1613 *
1614 * Note that mip_lod_bias is a no-op for the Metal driver. For Metal, LOD bias
1615 * must be applied via shader instead.
1616 *
1617 * \since This function is available since SDL 3.2.0.
1618 *
1619 * \sa SDL_CreateGPUSampler
1620 * \sa SDL_GPUFilter
1621 * \sa SDL_GPUSamplerMipmapMode
1622 * \sa SDL_GPUSamplerAddressMode
1623 * \sa SDL_GPUCompareOp
1624 */
1626{
1627 SDL_GPUFilter min_filter; /**< The minification filter to apply to lookups. */
1628 SDL_GPUFilter mag_filter; /**< The magnification filter to apply to lookups. */
1629 SDL_GPUSamplerMipmapMode mipmap_mode; /**< The mipmap filter to apply to lookups. */
1630 SDL_GPUSamplerAddressMode address_mode_u; /**< The addressing mode for U coordinates outside [0, 1). */
1631 SDL_GPUSamplerAddressMode address_mode_v; /**< The addressing mode for V coordinates outside [0, 1). */
1632 SDL_GPUSamplerAddressMode address_mode_w; /**< The addressing mode for W coordinates outside [0, 1). */
1633 float mip_lod_bias; /**< The bias to be added to mipmap LOD calculation. */
1634 float max_anisotropy; /**< The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored. */
1635 SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */
1636 float min_lod; /**< Clamps the minimum of the computed LOD value. */
1637 float max_lod; /**< Clamps the maximum of the computed LOD value. */
1638 bool enable_anisotropy; /**< true to enable anisotropic filtering. */
1639 bool enable_compare; /**< true to enable comparison against a reference value during lookups. */
1642
1643 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1645
1646/**
1647 * A structure specifying the parameters of vertex buffers used in a graphics
1648 * pipeline.
1649 *
1650 * When you call SDL_BindGPUVertexBuffers, you specify the binding slots of
1651 * the vertex buffers. For example if you called SDL_BindGPUVertexBuffers with
1652 * a first_slot of 2 and num_bindings of 3, the binding slots 2, 3, 4 would be
1653 * used by the vertex buffers you pass in.
1654 *
1655 * Vertex attributes are linked to buffers via the buffer_slot field of
1656 * SDL_GPUVertexAttribute. For example, if an attribute has a buffer_slot of
1657 * 0, then that attribute belongs to the vertex buffer bound at slot 0.
1658 *
1659 * \since This struct is available since SDL 3.2.0.
1660 *
1661 * \sa SDL_GPUVertexAttribute
1662 * \sa SDL_GPUVertexInputRate
1663 */
1665{
1666 Uint32 slot; /**< The binding slot of the vertex buffer. */
1667 Uint32 pitch; /**< The size of a single element + the offset between elements. */
1668 SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */
1669 Uint32 instance_step_rate; /**< Reserved for future use. Must be set to 0. */
1671
1672/**
1673 * A structure specifying a vertex attribute.
1674 *
1675 * All vertex attribute locations provided to an SDL_GPUVertexInputState must
1676 * be unique.
1677 *
1678 * \since This struct is available since SDL 3.2.0.
1679 *
1680 * \sa SDL_GPUVertexBufferDescription
1681 * \sa SDL_GPUVertexInputState
1682 * \sa SDL_GPUVertexElementFormat
1683 */
1685{
1686 Uint32 location; /**< The shader input location index. */
1687 Uint32 buffer_slot; /**< The binding slot of the associated vertex buffer. */
1688 SDL_GPUVertexElementFormat format; /**< The size and type of the attribute data. */
1689 Uint32 offset; /**< The byte offset of this attribute relative to the start of the vertex element. */
1691
1692/**
1693 * A structure specifying the parameters of a graphics pipeline vertex input
1694 * state.
1695 *
1696 * \since This struct is available since SDL 3.2.0.
1697 *
1698 * \sa SDL_GPUGraphicsPipelineCreateInfo
1699 * \sa SDL_GPUVertexBufferDescription
1700 * \sa SDL_GPUVertexAttribute
1701 */
1703{
1704 const SDL_GPUVertexBufferDescription *vertex_buffer_descriptions; /**< A pointer to an array of vertex buffer descriptions. */
1705 Uint32 num_vertex_buffers; /**< The number of vertex buffer descriptions in the above array. */
1706 const SDL_GPUVertexAttribute *vertex_attributes; /**< A pointer to an array of vertex attribute descriptions. */
1707 Uint32 num_vertex_attributes; /**< The number of vertex attribute descriptions in the above array. */
1709
1710/**
1711 * A structure specifying the stencil operation state of a graphics pipeline.
1712 *
1713 * \since This struct is available since SDL 3.2.0.
1714 *
1715 * \sa SDL_GPUDepthStencilState
1716 * \sa SDL_GPUStencilOp
1717 * \sa SDL_GPUCompareOp
1718 */
1720{
1721 SDL_GPUStencilOp fail_op; /**< The action performed on samples that fail the stencil test. */
1722 SDL_GPUStencilOp pass_op; /**< The action performed on samples that pass the depth and stencil tests. */
1723 SDL_GPUStencilOp depth_fail_op; /**< The action performed on samples that pass the stencil test and fail the depth test. */
1724 SDL_GPUCompareOp compare_op; /**< The comparison operator used in the stencil test. */
1726
1727/**
1728 * A structure specifying the blend state of a color target.
1729 *
1730 * \since This struct is available since SDL 3.2.0.
1731 *
1732 * \sa SDL_SetGPUBlendConstants
1733 * \sa SDL_GPUColorTargetDescription
1734 * \sa SDL_GPUBlendFactor
1735 * \sa SDL_GPUBlendOp
1736 * \sa SDL_GPUColorComponentFlags
1737 */
1739{
1740 SDL_GPUBlendFactor src_color_blendfactor; /**< The value to be multiplied by the source RGB value. */
1741 SDL_GPUBlendFactor dst_color_blendfactor; /**< The value to be multiplied by the destination RGB value. */
1742 SDL_GPUBlendOp color_blend_op; /**< The blend operation for the RGB components. */
1743 SDL_GPUBlendFactor src_alpha_blendfactor; /**< The value to be multiplied by the source alpha. */
1744 SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */
1745 SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */
1746 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. */
1747 bool enable_blend; /**< Whether blending is enabled for the color target. */
1748 bool enable_color_write_mask; /**< Whether the color write mask is enabled. */
1752
1753
1754/**
1755 * A structure specifying code and metadata for creating a shader object.
1756 *
1757 * \since This struct is available since SDL 3.2.0.
1758 *
1759 * \sa SDL_CreateGPUShader
1760 * \sa SDL_GPUShaderFormat
1761 * \sa SDL_GPUShaderStage
1762 */
1764{
1765 size_t code_size; /**< The size in bytes of the code pointed to. */
1766 const Uint8 *code; /**< A pointer to shader code. */
1767 const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */
1768 SDL_GPUShaderFormat format; /**< The format of the shader code. */
1769 SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */
1770 Uint32 num_samplers; /**< The number of samplers defined in the shader. */
1771 Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */
1772 Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */
1773 Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */
1774
1775 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1777
1778/**
1779 * A structure specifying the parameters of a texture.
1780 *
1781 * Usage flags can be bitwise OR'd together for combinations of usages. Note
1782 * that certain usage combinations are invalid, for example SAMPLER and
1783 * GRAPHICS_STORAGE.
1784 *
1785 * \since This struct is available since SDL 3.2.0.
1786 *
1787 * \sa SDL_CreateGPUTexture
1788 * \sa SDL_GPUTextureType
1789 * \sa SDL_GPUTextureFormat
1790 * \sa SDL_GPUTextureUsageFlags
1791 * \sa SDL_GPUSampleCount
1792 */
1794{
1795 SDL_GPUTextureType type; /**< The base dimensionality of the texture. */
1796 SDL_GPUTextureFormat format; /**< The pixel format of the texture. */
1797 SDL_GPUTextureUsageFlags usage; /**< How the texture is intended to be used by the client. */
1798 Uint32 width; /**< The width of the texture. */
1799 Uint32 height; /**< The height of the texture. */
1800 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. */
1801 Uint32 num_levels; /**< The number of mip levels in the texture. */
1802 SDL_GPUSampleCount sample_count; /**< The number of samples per texel. Only applies if the texture is used as a render target. */
1803
1804 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1806
1807/**
1808 * A structure specifying the parameters of a buffer.
1809 *
1810 * Usage flags can be bitwise OR'd together for combinations of usages. Note
1811 * that certain combinations are invalid, for example VERTEX and INDEX.
1812 *
1813 * \since This struct is available since SDL 3.2.0.
1814 *
1815 * \sa SDL_CreateGPUBuffer
1816 * \sa SDL_GPUBufferUsageFlags
1817 */
1819{
1820 SDL_GPUBufferUsageFlags usage; /**< How the buffer is intended to be used by the client. */
1821 Uint32 size; /**< The size in bytes of the buffer. */
1822
1823 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1825
1826/**
1827 * A structure specifying the parameters of a transfer buffer.
1828 *
1829 * \since This struct is available since SDL 3.2.0.
1830 *
1831 * \sa SDL_GPUTransferBufferUsage
1832 * \sa SDL_CreateGPUTransferBuffer
1833 */
1835{
1836 SDL_GPUTransferBufferUsage usage; /**< How the transfer buffer is intended to be used by the client. */
1837 Uint32 size; /**< The size in bytes of the transfer buffer. */
1838
1839 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1841
1842/* Pipeline state structures */
1843
1844/**
1845 * A structure specifying the parameters of the graphics pipeline rasterizer
1846 * state.
1847 *
1848 * Note that SDL_GPU_FILLMODE_LINE is not supported on many Android devices.
1849 * For those devices, the fill mode will automatically fall back to FILL.
1850 *
1851 * Also note that the D3D12 driver will enable depth clamping even if
1852 * enable_depth_clip is true. If you need this clamp+clip behavior, consider
1853 * enabling depth clip and then manually clamping depth in your fragment
1854 * shaders on Metal and Vulkan.
1855 *
1856 * \since This struct is available since SDL 3.2.0.
1857 *
1858 * \sa SDL_GPUGraphicsPipelineCreateInfo
1859 * \sa SDL_GPUFillMode
1860 * \sa SDL_GPUCullMode
1861 * \sa SDL_GPUFrontFace
1862 */
1864{
1865 SDL_GPUFillMode fill_mode; /**< Whether polygons will be filled in or drawn as lines. */
1866 SDL_GPUCullMode cull_mode; /**< The facing direction in which triangles will be culled. */
1867 SDL_GPUFrontFace front_face; /**< The vertex winding that will cause a triangle to be determined as front-facing. */
1868 float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */
1869 float depth_bias_clamp; /**< The maximum depth bias of a fragment. */
1870 float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */
1871 bool enable_depth_bias; /**< true to bias fragment depth values. */
1872 bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */
1876
1877/**
1878 * A structure specifying the parameters of the graphics pipeline multisample
1879 * state.
1880 *
1881 * \since This struct is available since SDL 3.2.0.
1882 *
1883 * \sa SDL_GPUGraphicsPipelineCreateInfo
1884 * \sa SDL_GPUSampleCount
1885 */
1887{
1888 SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */
1889 Uint32 sample_mask; /**< Reserved for future use. Must be set to 0. */
1890 bool enable_mask; /**< Reserved for future use. Must be set to false. */
1891 bool enable_alpha_to_coverage; /**< true enables the alpha-to-coverage feature. */
1895
1896/**
1897 * A structure specifying the parameters of the graphics pipeline depth
1898 * stencil state.
1899 *
1900 * \since This struct is available since SDL 3.2.0.
1901 *
1902 * \sa SDL_GPUGraphicsPipelineCreateInfo
1903 * \sa SDL_GPUCompareOp
1904 * \sa SDL_GPUStencilOpState
1905 */
1907{
1908 SDL_GPUCompareOp compare_op; /**< The comparison operator used for depth testing. */
1909 SDL_GPUStencilOpState back_stencil_state; /**< The stencil op state for back-facing triangles. */
1910 SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */
1911 Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */
1912 Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */
1913 bool enable_depth_test; /**< true enables the depth test. */
1914 bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */
1915 bool enable_stencil_test; /**< true enables the stencil test. */
1920
1921/**
1922 * A structure specifying the parameters of color targets used in a graphics
1923 * pipeline.
1924 *
1925 * \since This struct is available since SDL 3.2.0.
1926 *
1927 * \sa SDL_GPUGraphicsPipelineTargetInfo
1928 * \sa SDL_GPUTextureFormat
1929 * \sa SDL_GPUColorTargetBlendState
1930 */
1932{
1933 SDL_GPUTextureFormat format; /**< The pixel format of the texture to be used as a color target. */
1934 SDL_GPUColorTargetBlendState blend_state; /**< The blend state to be used for the color target. */
1936
1937/**
1938 * A structure specifying the descriptions of render targets used in a
1939 * graphics pipeline.
1940 *
1941 * \since This struct is available since SDL 3.2.0.
1942 *
1943 * \sa SDL_GPUGraphicsPipelineCreateInfo
1944 * \sa SDL_GPUColorTargetDescription
1945 * \sa SDL_GPUTextureFormat
1946 */
1948{
1949 const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */
1950 Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */
1951 SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */
1952 bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */
1957
1958/**
1959 * A structure specifying the parameters of a graphics pipeline state.
1960 *
1961 * \since This struct is available since SDL 3.2.0.
1962 *
1963 * \sa SDL_CreateGPUGraphicsPipeline
1964 * \sa SDL_GPUShader
1965 * \sa SDL_GPUVertexInputState
1966 * \sa SDL_GPUPrimitiveType
1967 * \sa SDL_GPURasterizerState
1968 * \sa SDL_GPUMultisampleState
1969 * \sa SDL_GPUDepthStencilState
1970 * \sa SDL_GPUGraphicsPipelineTargetInfo
1971 */
1973{
1974 SDL_GPUShader *vertex_shader; /**< The vertex shader used by the graphics pipeline. */
1975 SDL_GPUShader *fragment_shader; /**< The fragment shader used by the graphics pipeline. */
1976 SDL_GPUVertexInputState vertex_input_state; /**< The vertex layout of the graphics pipeline. */
1977 SDL_GPUPrimitiveType primitive_type; /**< The primitive topology of the graphics pipeline. */
1978 SDL_GPURasterizerState rasterizer_state; /**< The rasterizer state of the graphics pipeline. */
1979 SDL_GPUMultisampleState multisample_state; /**< The multisample state of the graphics pipeline. */
1980 SDL_GPUDepthStencilState depth_stencil_state; /**< The depth-stencil state of the graphics pipeline. */
1981 SDL_GPUGraphicsPipelineTargetInfo target_info; /**< Formats and blend modes for the render targets of the graphics pipeline. */
1982
1983 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
1985
1986/**
1987 * A structure specifying the parameters of a compute pipeline state.
1988 *
1989 * \since This struct is available since SDL 3.2.0.
1990 *
1991 * \sa SDL_CreateGPUComputePipeline
1992 * \sa SDL_GPUShaderFormat
1993 */
1995{
1996 size_t code_size; /**< The size in bytes of the compute shader code pointed to. */
1997 const Uint8 *code; /**< A pointer to compute shader code. */
1998 const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */
1999 SDL_GPUShaderFormat format; /**< The format of the compute shader code. */
2000 Uint32 num_samplers; /**< The number of samplers defined in the shader. */
2001 Uint32 num_readonly_storage_textures; /**< The number of readonly storage textures defined in the shader. */
2002 Uint32 num_readonly_storage_buffers; /**< The number of readonly storage buffers defined in the shader. */
2003 Uint32 num_readwrite_storage_textures; /**< The number of read-write storage textures defined in the shader. */
2004 Uint32 num_readwrite_storage_buffers; /**< The number of read-write storage buffers defined in the shader. */
2005 Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */
2006 Uint32 threadcount_x; /**< The number of threads in the X dimension. This should match the value in the shader. */
2007 Uint32 threadcount_y; /**< The number of threads in the Y dimension. This should match the value in the shader. */
2008 Uint32 threadcount_z; /**< The number of threads in the Z dimension. This should match the value in the shader. */
2009
2010 SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
2012
2013/**
2014 * A structure specifying the parameters of a color target used by a render
2015 * pass.
2016 *
2017 * The load_op field determines what is done with the texture at the beginning
2018 * of the render pass.
2019 *
2020 * - LOAD: Loads the data currently in the texture. Not recommended for
2021 * multisample textures as it requires significant memory bandwidth.
2022 * - CLEAR: Clears the texture to a single color.
2023 * - DONT_CARE: The driver will do whatever it wants with the texture memory.
2024 * This is a good option if you know that every single pixel will be touched
2025 * in the render pass.
2026 *
2027 * The store_op field determines what is done with the color results of the
2028 * render pass.
2029 *
2030 * - STORE: Stores the results of the render pass in the texture. Not
2031 * recommended for multisample textures as it requires significant memory
2032 * bandwidth.
2033 * - DONT_CARE: The driver will do whatever it wants with the texture memory.
2034 * This is often a good option for depth/stencil textures.
2035 * - RESOLVE: Resolves a multisample texture into resolve_texture, which must
2036 * have a sample count of 1. Then the driver may discard the multisample
2037 * texture memory. This is the most performant method of resolving a
2038 * multisample target.
2039 * - RESOLVE_AND_STORE: Resolves a multisample texture into the
2040 * resolve_texture, which must have a sample count of 1. Then the driver
2041 * stores the multisample texture's contents. Not recommended as it requires
2042 * significant memory bandwidth.
2043 *
2044 * \since This struct is available since SDL 3.2.0.
2045 *
2046 * \sa SDL_BeginGPURenderPass
2047 * \sa SDL_FColor
2048 */
2050{
2051 SDL_GPUTexture *texture; /**< The texture that will be used as a color target by a render pass. */
2052 Uint32 mip_level; /**< The mip level to use as a color target. */
2053 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. */
2054 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. */
2055 SDL_GPULoadOp load_op; /**< What is done with the contents of the color target at the beginning of the render pass. */
2056 SDL_GPUStoreOp store_op; /**< What is done with the results of the render pass. */
2057 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. */
2058 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. */
2059 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. */
2060 bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */
2061 bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */
2065
2066/**
2067 * A structure specifying the parameters of a depth-stencil target used by a
2068 * render pass.
2069 *
2070 * The load_op field determines what is done with the depth contents of the
2071 * texture at the beginning of the render pass.
2072 *
2073 * - LOAD: Loads the depth values currently in the texture.
2074 * - CLEAR: Clears the texture to a single depth.
2075 * - DONT_CARE: The driver will do whatever it wants with the memory. This is
2076 * a good option if you know that every single pixel will be touched in the
2077 * render pass.
2078 *
2079 * The store_op field determines what is done with the depth results of the
2080 * render pass.
2081 *
2082 * - STORE: Stores the depth results in the texture.
2083 * - DONT_CARE: The driver will do whatever it wants with the depth results.
2084 * This is often a good option for depth/stencil textures that don't need to
2085 * be reused again.
2086 *
2087 * The stencil_load_op field determines what is done with the stencil contents
2088 * of the texture at the beginning of the render pass.
2089 *
2090 * - LOAD: Loads the stencil values currently in the texture.
2091 * - CLEAR: Clears the stencil values to a single value.
2092 * - DONT_CARE: The driver will do whatever it wants with the memory. This is
2093 * a good option if you know that every single pixel will be touched in the
2094 * render pass.
2095 *
2096 * The stencil_store_op field determines what is done with the stencil results
2097 * of the render pass.
2098 *
2099 * - STORE: Stores the stencil results in the texture.
2100 * - DONT_CARE: The driver will do whatever it wants with the stencil results.
2101 * This is often a good option for depth/stencil textures that don't need to
2102 * be reused again.
2103 *
2104 * Note that depth/stencil targets do not support multisample resolves.
2105 *
2106 * Due to ABI limitations, depth textures with more than 255 layers are not
2107 * supported.
2108 *
2109 * \since This struct is available since SDL 3.2.0.
2110 *
2111 * \sa SDL_BeginGPURenderPass
2112 */
2114{
2115 SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */
2116 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. */
2117 SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */
2118 SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */
2119 SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */
2120 SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */
2121 bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */
2122 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. */
2123 Uint8 mip_level; /**< The mip level to use as the depth stencil target. */
2124 Uint8 layer; /**< The layer index to use as the depth stencil target. */
2126
2127/**
2128 * A structure containing parameters for a blit command.
2129 *
2130 * \since This struct is available since SDL 3.2.0.
2131 *
2132 * \sa SDL_BlitGPUTexture
2133 * \sa SDL_GPUBlitRegion
2134 * \sa SDL_GPULoadOp
2135 * \sa SDL_FColor
2136 * \sa SDL_FlipMode
2137 * \sa SDL_GPUFilter
2138 */
2139typedef struct SDL_GPUBlitInfo {
2140 SDL_GPUBlitRegion source; /**< The source region for the blit. */
2141 SDL_GPUBlitRegion destination; /**< The destination region for the blit. */
2142 SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */
2143 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. */
2144 SDL_FlipMode flip_mode; /**< The flip mode for the source region. */
2145 SDL_GPUFilter filter; /**< The filter mode used when blitting. */
2146 bool cycle; /**< true cycles the destination texture if it is already bound. */
2151
2152/* Binding structs */
2153
2154/**
2155 * A structure specifying parameters in a buffer binding call.
2156 *
2157 * \since This struct is available since SDL 3.2.0.
2158 *
2159 * \sa SDL_BindGPUVertexBuffers
2160 * \sa SDL_BindGPUIndexBuffer
2161 */
2163{
2164 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. */
2165 Uint32 offset; /**< The starting byte of the data to bind in the buffer. */
2167
2168/**
2169 * A structure specifying parameters in a sampler binding call.
2170 *
2171 * \since This struct is available since SDL 3.2.0.
2172 *
2173 * \sa SDL_BindGPUVertexSamplers
2174 * \sa SDL_BindGPUFragmentSamplers
2175 * \sa SDL_GPUTexture
2176 * \sa SDL_GPUSampler
2177 */
2179{
2180 SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. */
2181 SDL_GPUSampler *sampler; /**< The sampler to bind. */
2183
2184/**
2185 * A structure specifying parameters related to binding buffers in a compute
2186 * pass.
2187 *
2188 * \since This struct is available since SDL 3.2.0.
2189 *
2190 * \sa SDL_BeginGPUComputePass
2191 */
2193{
2194 SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE. */
2195 bool cycle; /**< true cycles the buffer if it is already bound. */
2200
2201/**
2202 * A structure specifying parameters related to binding textures in a compute
2203 * pass.
2204 *
2205 * \since This struct is available since SDL 3.2.0.
2206 *
2207 * \sa SDL_BeginGPUComputePass
2208 */
2210{
2211 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. */
2212 Uint32 mip_level; /**< The mip level index to bind. */
2213 Uint32 layer; /**< The layer index to bind. */
2214 bool cycle; /**< true cycles the texture if it is already bound. */
2219
2220/* Functions */
2221
2222/* Device */
2223
2224/**
2225 * Checks for GPU runtime support.
2226 *
2227 * \param format_flags a bitflag indicating which shader formats the app is
2228 * able to provide.
2229 * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
2230 * driver.
2231 * \returns true if supported, false otherwise.
2232 *
2233 * \since This function is available since SDL 3.2.0.
2234 *
2235 * \sa SDL_CreateGPUDevice
2236 */
2237extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsShaderFormats(
2238 SDL_GPUShaderFormat format_flags,
2239 const char *name);
2240
2241/**
2242 * Checks for GPU runtime support.
2243 *
2244 * \param props the properties to use.
2245 * \returns true if supported, false otherwise.
2246 *
2247 * \since This function is available since SDL 3.2.0.
2248 *
2249 * \sa SDL_CreateGPUDeviceWithProperties
2250 */
2251extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties(
2252 SDL_PropertiesID props);
2253
2254/**
2255 * Creates a GPU context.
2256 *
2257 * The GPU driver name can be one of the following:
2258 *
2259 * - "vulkan": [Vulkan](CategoryGPU#vulkan)
2260 * - "direct3d12": [D3D12](CategoryGPU#d3d12)
2261 * - "metal": [Metal](CategoryGPU#metal)
2262 * - NULL: let SDL pick the optimal driver
2263 *
2264 * \param format_flags a bitflag indicating which shader formats the app is
2265 * able to provide.
2266 * \param debug_mode enable debug mode properties and validations.
2267 * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
2268 * driver.
2269 * \returns a GPU context on success or NULL on failure; call SDL_GetError()
2270 * for more information.
2271 *
2272 * \since This function is available since SDL 3.2.0.
2273 *
2274 * \sa SDL_CreateGPUDeviceWithProperties
2275 * \sa SDL_GetGPUShaderFormats
2276 * \sa SDL_GetGPUDeviceDriver
2277 * \sa SDL_DestroyGPUDevice
2278 * \sa SDL_GPUSupportsShaderFormats
2279 */
2280extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
2281 SDL_GPUShaderFormat format_flags,
2282 bool debug_mode,
2283 const char *name);
2284
2285/**
2286 * Creates a GPU context.
2287 *
2288 * These are the supported properties:
2289 *
2290 * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN`: enable debug mode
2291 * properties and validations, defaults to true.
2292 * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer
2293 * energy efficiency over maximum GPU performance, defaults to false.
2294 * - `SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN`: enable to automatically log
2295 * useful debug information on device creation, defaults to true.
2296 * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to
2297 * use, if a specific one is desired.
2298 * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN`: Enable Vulkan
2299 * device feature shaderClipDistance. If disabled, clip distances are not
2300 * supported in shader code: gl_ClipDistance[] built-ins of GLSL,
2301 * SV_ClipDistance0/1 semantics of HLSL and [[clip_distance]] attribute of
2302 * Metal. Disabling optional features allows the application to run on some
2303 * older Android devices. Defaults to true.
2304 * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN`: Enable
2305 * Vulkan device feature depthClamp. If disabled, there is no depth clamp
2306 * support and enable_depth_clip in SDL_GPURasterizerState must always be
2307 * set to true. Disabling optional features allows the application to run on
2308 * some older Android devices. Defaults to true.
2309 * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN`:
2310 * Enable Vulkan device feature drawIndirectFirstInstance. If disabled, the
2311 * argument first_instance of SDL_GPUIndirectDrawCommand must be set to
2312 * zero. Disabling optional features allows the application to run on some
2313 * older Android devices. Defaults to true.
2314 * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN`: Enable Vulkan
2315 * device feature samplerAnisotropy. If disabled, enable_anisotropy of
2316 * SDL_GPUSamplerCreateInfo must be set to false. Disabling optional
2317 * features allows the application to run on some older Android devices.
2318 * Defaults to true.
2319 *
2320 * These are the current shader format properties:
2321 *
2322 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN`: The app is able to
2323 * provide shaders for an NDA platform.
2324 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN`: The app is able to
2325 * provide SPIR-V shaders if applicable.
2326 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN`: The app is able to
2327 * provide DXBC shaders if applicable
2328 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN`: The app is able to
2329 * provide DXIL shaders if applicable.
2330 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN`: The app is able to
2331 * provide MSL shaders if applicable.
2332 * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to
2333 * provide Metal shader libraries if applicable.
2334 *
2335 * With the D3D12 backend:
2336 *
2337 * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to
2338 * use for all vertex semantics, default is "TEXCOORD".
2339 * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN`: By
2340 * default, Resourcing Binding Tier 2 is required for D3D12 support.
2341 * However, an application can set this property to true to enable Tier 1
2342 * support, if (and only if) the application uses 8 or fewer storage
2343 * resources across all shader stages. As of writing, this property is
2344 * useful for targeting Intel Haswell and Broadwell GPUs; other hardware
2345 * either supports Tier 2 Resource Binding or does not support D3D12 in any
2346 * capacity. Defaults to false.
2347 * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER`: Certain
2348 * feature checks are only possible on Windows 11 by default. By setting
2349 * this alongside `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRING`
2350 * and vendoring D3D12Core.dll from the D3D12 Agility SDK, you can make
2351 * those feature checks possible on older platforms. The version you provide
2352 * must match the one given in the DLL.
2353 * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRING`: Certain
2354 * feature checks are only possible on Windows 11 by default. By setting
2355 * this alongside
2356 * `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER` and
2357 * vendoring D3D12Core.dll from the D3D12 Agility SDK, you can make those
2358 * feature checks possible on older platforms. The path you provide must be
2359 * relative to the executable path of your app. Be sure not to put the DLL
2360 * in the same directory as the exe; Microsoft strongly advises against
2361 * this!
2362 *
2363 * With the Vulkan backend:
2364 *
2365 * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN`:
2366 * By default, Vulkan device enumeration includes drivers of all types,
2367 * including software renderers (for example, the Lavapipe Mesa driver).
2368 * This can be useful if your application _requires_ SDL_GPU, but if you can
2369 * provide your own fallback renderer (for example, an OpenGL renderer) this
2370 * property can be set to true. Defaults to false.
2371 * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER`: a pointer to an
2372 * SDL_GPUVulkanOptions structure to be processed during device creation.
2373 * This allows configuring a variety of Vulkan-specific options such as
2374 * increasing the API version and opting into extensions aside from the
2375 * minimal set SDL requires.
2376 *
2377 * With the Metal backend: -
2378 * `SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1_BOOLEAN`: By default,
2379 * macOS support requires what Apple calls "MTLGPUFamilyMac2" hardware or
2380 * newer. However, an application can set this property to true to enable
2381 * support for "MTLGPUFamilyMac1" hardware, if (and only if) the application
2382 * does not write to sRGB textures. (For history's sake: MacFamily1 also does
2383 * not support indirect command buffers, MSAA depth resolve, and stencil
2384 * resolve/feedback, but these are not exposed features in SDL_GPU.)
2385 *
2386 * \param props the properties to use.
2387 * \returns a GPU context on success or NULL on failure; call SDL_GetError()
2388 * for more information.
2389 *
2390 * \since This function is available since SDL 3.2.0.
2391 *
2392 * \sa SDL_GetGPUShaderFormats
2393 * \sa SDL_GetGPUDeviceDriver
2394 * \sa SDL_DestroyGPUDevice
2395 * \sa SDL_GPUSupportsProperties
2396 */
2398 SDL_PropertiesID props);
2399
2400#define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode"
2401#define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower"
2402#define SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN "SDL.gpu.device.create.verbose"
2403#define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name"
2404#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN "SDL.gpu.device.create.feature.clip_distance"
2405#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN "SDL.gpu.device.create.feature.depth_clamping"
2406#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN "SDL.gpu.device.create.feature.indirect_draw_first_instance"
2407#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN "SDL.gpu.device.create.feature.anisotropy"
2408#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private"
2409#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv"
2410#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc"
2411#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil"
2412#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl"
2413#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib"
2414#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding"
2415#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
2416#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER "SDL.gpu.device.create.d3d12.agility_sdk_version"
2417#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRING "SDL.gpu.device.create.d3d12.agility_sdk_path"
2418#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN "SDL.gpu.device.create.vulkan.requirehardwareacceleration"
2419#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER "SDL.gpu.device.create.vulkan.options"
2420#define SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1_BOOLEAN "SDL.gpu.device.create.metal.allowmacfamily1"
2421
2422#define SDL_PROP_GPU_DEVICE_CREATE_XR_ENABLE_BOOLEAN "SDL.gpu.device.create.xr.enable"
2423#define SDL_PROP_GPU_DEVICE_CREATE_XR_INSTANCE_POINTER "SDL.gpu.device.create.xr.instance_out"
2424#define SDL_PROP_GPU_DEVICE_CREATE_XR_SYSTEM_ID_POINTER "SDL.gpu.device.create.xr.system_id_out"
2425#define SDL_PROP_GPU_DEVICE_CREATE_XR_VERSION_NUMBER "SDL.gpu.device.create.xr.version"
2426#define SDL_PROP_GPU_DEVICE_CREATE_XR_FORM_FACTOR_NUMBER "SDL.gpu.device.create.xr.form_factor"
2427#define SDL_PROP_GPU_DEVICE_CREATE_XR_EXTENSION_COUNT_NUMBER "SDL.gpu.device.create.xr.extensions.count"
2428#define SDL_PROP_GPU_DEVICE_CREATE_XR_EXTENSION_NAMES_POINTER "SDL.gpu.device.create.xr.extensions.names"
2429#define SDL_PROP_GPU_DEVICE_CREATE_XR_LAYER_COUNT_NUMBER "SDL.gpu.device.create.xr.layers.count"
2430#define SDL_PROP_GPU_DEVICE_CREATE_XR_LAYER_NAMES_POINTER "SDL.gpu.device.create.xr.layers.names"
2431#define SDL_PROP_GPU_DEVICE_CREATE_XR_APPLICATION_NAME_STRING "SDL.gpu.device.create.xr.application.name"
2432#define SDL_PROP_GPU_DEVICE_CREATE_XR_APPLICATION_VERSION_NUMBER "SDL.gpu.device.create.xr.application.version"
2433#define SDL_PROP_GPU_DEVICE_CREATE_XR_ENGINE_NAME_STRING "SDL.gpu.device.create.xr.engine.name"
2434#define SDL_PROP_GPU_DEVICE_CREATE_XR_ENGINE_VERSION_NUMBER "SDL.gpu.device.create.xr.engine.version"
2435
2436
2437/**
2438 * A structure specifying additional options when using Vulkan.
2439 *
2440 * When no such structure is provided, SDL will use Vulkan API version 1.0 and
2441 * a minimal set of features. The requested API version influences how the
2442 * feature_list is processed by SDL. When requesting API version 1.0, the
2443 * feature_list is ignored. Only the vulkan_10_physical_device_features and
2444 * the extension lists are used. When requesting API version 1.1, the
2445 * feature_list is scanned for feature structures introduced in Vulkan 1.1.
2446 * When requesting Vulkan 1.2 or higher, the feature_list is additionally
2447 * scanned for compound feature structs such as
2448 * VkPhysicalDeviceVulkan11Features. The device and instance extension lists,
2449 * as well as vulkan_10_physical_device_features, are always processed.
2450 *
2451 * \since This struct is available since SDL 3.4.0.
2452 */
2454{
2455 Uint32 vulkan_api_version; /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */
2456 void *feature_list; /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/
2457 void *vulkan_10_physical_device_features; /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */
2458 Uint32 device_extension_count; /**< Number of additional device extensions to require. */
2459 const char **device_extension_names; /**< Pointer to a list of additional device extensions to require. */
2460 Uint32 instance_extension_count; /**< Number of additional instance extensions to require. */
2461 const char **instance_extension_names; /**< Pointer to a list of additional instance extensions to require. */
2463
2464/**
2465 * Destroys a GPU context previously returned by SDL_CreateGPUDevice.
2466 *
2467 * \param device a GPU Context to destroy.
2468 *
2469 * \since This function is available since SDL 3.2.0.
2470 *
2471 * \sa SDL_CreateGPUDevice
2472 */
2473extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device);
2474
2475/**
2476 * Get the number of GPU drivers compiled into SDL.
2477 *
2478 * \returns the number of built in GPU drivers.
2479 *
2480 * \since This function is available since SDL 3.2.0.
2481 *
2482 * \sa SDL_GetGPUDriver
2483 */
2484extern SDL_DECLSPEC int SDLCALL SDL_GetNumGPUDrivers(void);
2485
2486/**
2487 * Get the name of a built in GPU driver.
2488 *
2489 * The GPU drivers are presented in the order in which they are normally
2490 * checked during initialization.
2491 *
2492 * The names of drivers are all simple, low-ASCII identifiers, like "vulkan",
2493 * "metal" or "direct3d12". These never have Unicode characters, and are not
2494 * meant to be proper names.
2495 *
2496 * \param index the index of a GPU driver.
2497 * \returns the name of the GPU driver with the given **index** or NULL when
2498 * the index is out of bounds; call SDL_GetError() for more
2499 * information.
2500 *
2501 * \since This function is available since SDL 3.2.0.
2502 *
2503 * \sa SDL_GetNumGPUDrivers
2504 */
2505extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index);
2506
2507/**
2508 * Returns the name of the backend used to create this GPU context.
2509 *
2510 * \param device a GPU context to query.
2511 * \returns the name of the device's driver, or NULL on error.
2512 *
2513 * \since This function is available since SDL 3.2.0.
2514 */
2515extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device);
2516
2517/**
2518 * Returns the supported shader formats for this GPU context.
2519 *
2520 * \param device a GPU context to query.
2521 * \returns a bitflag indicating which shader formats the driver is able to
2522 * consume.
2523 *
2524 * \since This function is available since SDL 3.2.0.
2525 */
2526extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device);
2527
2528/**
2529 * Get the properties associated with a GPU device.
2530 *
2531 * All properties are optional and may differ between GPU backends and SDL
2532 * versions.
2533 *
2534 * The following properties are provided by SDL:
2535 *
2536 * `SDL_PROP_GPU_DEVICE_NAME_STRING`: Contains the name of the underlying
2537 * device as reported by the system driver. This string has no standardized
2538 * format, is highly inconsistent between hardware devices and drivers, and is
2539 * able to change at any time. Do not attempt to parse this string as it is
2540 * bound to fail at some point in the future when system drivers are updated,
2541 * new hardware devices are introduced, or when SDL adds new GPU backends or
2542 * modifies existing ones.
2543 *
2544 * Strings that have been found in the wild include:
2545 *
2546 * - GTX 970
2547 * - GeForce GTX 970
2548 * - NVIDIA GeForce GTX 970
2549 * - Microsoft Direct3D12 (NVIDIA GeForce GTX 970)
2550 * - NVIDIA Graphics Device
2551 * - GeForce GPU
2552 * - P106-100
2553 * - AMD 15D8:C9
2554 * - AMD Custom GPU 0405
2555 * - AMD Radeon (TM) Graphics
2556 * - ASUS Radeon RX 470 Series
2557 * - Intel(R) Arc(tm) A380 Graphics (DG2)
2558 * - Virtio-GPU Venus (NVIDIA TITAN V)
2559 * - SwiftShader Device (LLVM 16.0.0)
2560 * - llvmpipe (LLVM 15.0.4, 256 bits)
2561 * - Microsoft Basic Render Driver
2562 * - unknown device
2563 *
2564 * The above list shows that the same device can have different formats, the
2565 * vendor name may or may not appear in the string, the included vendor name
2566 * may not be the vendor of the chipset on the device, some manufacturers
2567 * include pseudo-legal marks while others don't, some devices may not use a
2568 * marketing name in the string, the device string may be wrapped by the name
2569 * of a translation interface, the device may be emulated in software, or the
2570 * string may contain generic text that does not identify the device at all.
2571 *
2572 * `SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING`: Contains the self-reported name
2573 * of the underlying system driver.
2574 *
2575 * Strings that have been found in the wild include:
2576 *
2577 * - Intel Corporation
2578 * - Intel open-source Mesa driver
2579 * - Qualcomm Technologies Inc. Adreno Vulkan Driver
2580 * - MoltenVK
2581 * - Mali-G715
2582 * - venus
2583 *
2584 * `SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING`: Contains the self-reported
2585 * version of the underlying system driver. This is a relatively short version
2586 * string in an unspecified format. If SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING
2587 * is available then that property should be preferred over this one as it may
2588 * contain additional information that is useful for identifying the exact
2589 * driver version used.
2590 *
2591 * Strings that have been found in the wild include:
2592 *
2593 * - 53.0.0
2594 * - 0.405.2463
2595 * - 32.0.15.6614
2596 *
2597 * `SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING`: Contains the detailed version
2598 * information of the underlying system driver as reported by the driver. This
2599 * is an arbitrary string with no standardized format and it may contain
2600 * newlines. This property should be preferred over
2601 * SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING if it is available as it usually
2602 * contains the same information but in a format that is easier to read.
2603 *
2604 * Strings that have been found in the wild include:
2605 *
2606 * - 101.6559
2607 * - 1.2.11
2608 * - Mesa 21.2.2 (LLVM 12.0.1)
2609 * - Mesa 22.2.0-devel (git-f226222 2022-04-14 impish-oibaf-ppa)
2610 * - v1.r53p0-00eac0.824c4f31403fb1fbf8ee1042422c2129
2611 *
2612 * This string has also been observed to be a multiline string (which has a
2613 * trailing newline):
2614 *
2615 * ```
2616 * Driver Build: 85da404, I46ff5fc46f, 1606794520
2617 * Date: 11/30/20
2618 * Compiler Version: EV031.31.04.01
2619 * Driver Branch: promo490_3_Google
2620 * ```
2621 *
2622 * \param device a GPU context to query.
2623 * \returns a valid property ID on success or 0 on failure; call
2624 * SDL_GetError() for more information.
2625 *
2626 * \threadsafety It is safe to call this function from any thread.
2627 *
2628 * \since This function is available since SDL 3.4.0.
2629 */
2630extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUDevice *device);
2631
2632#define SDL_PROP_GPU_DEVICE_NAME_STRING "SDL.gpu.device.name"
2633#define SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING "SDL.gpu.device.driver_name"
2634#define SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING "SDL.gpu.device.driver_version"
2635#define SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING "SDL.gpu.device.driver_info"
2636
2637
2638/* State Creation */
2639
2640/**
2641 * Creates a pipeline object to be used in a compute workflow.
2642 *
2643 * Shader resource bindings must be authored to follow a particular convention
2644 * depending on the shader format. See below for details.
2645 *
2646 * ---
2647 *
2648 * **SPIR-V (GLSL)**
2649 *
2650 * For compute shaders, use:
2651 *
2652 * - Set 0 for samplers, read-only storage textures, and read-only storage
2653 * buffers
2654 * - Set 1 for read-write storage textures and read-write storage buffers
2655 * - Set 2 for uniform data
2656 *
2657 * The first resource in a given set must have a `binding` of 0. Additional
2658 * resources must appear at consecutive bindings (1, 2, etc), leaving no gaps
2659 * in the set.
2660 *
2661 * All samplers must come first in the binding order of Set 0, in order of how
2662 * they are bound via `SDL_BindGPUComputeSamplers()`.
2663 *
2664 * All read-only storage textures must come after all samplers in the binding
2665 * order, in order of how they are bound via
2666 * `SDL_BindGPUComputeStorageTextures()`.
2667 *
2668 * All read-only storage buffers must come after all read-only storage
2669 * textures in the binding order, in order of how they are bound via
2670 * `SDL_BindGPUComputeStorageBuffers()`.
2671 *
2672 * All read-write storage textures must come first in the binding order of Set
2673 * 1, in order of how they are bound via `SDL_BeginGPUComputePass()`.
2674 *
2675 * All read-write storage buffers must come after all read-write storage
2676 * textures in the binding order, in order of how they are bound via
2677 * `SDL_BeginGPUComputePass()`.
2678 *
2679 * **Example**
2680 *
2681 * If a compute shader binds 2 of each resource type, its binding layout
2682 * should look like this:
2683 *
2684 * ```glsl
2685 * // Any samplers come first in Set 0, in SDL bind slot order
2686 * layout(set = 0, binding = 0) uniform sampler2D samplerBoundToSlot0;
2687 * layout(set = 0, binding = 1) uniform sampler2D samplerBoundToSlot1;
2688 * // Any read-only storage textures come next in Set 0, in SDL bind slot order
2689 * layout(set = 0, binding = 2) uniform image2D storageTextureBoundToSlot0;
2690 * layout(set = 0, binding = 3) uniform image2D storageTextureBoundToSlot1;
2691 * // Any read-only storage buffers come next in Set 0, in SDL bind slot order
2692 * layout(set = 0, binding = 4) buffer storageBufferBoundToSlot0 { ... };
2693 * layout(set = 0, binding = 5) buffer storageBufferBoundToSlot1 { ... };
2694 * // Any read-write storage textures come first in Set 1, in SDL bind slot order
2695 * layout(set = 1, binding = 0) uniform image2D rwStorageTextureBoundToSlot0;
2696 * layout(set = 1, binding = 1) uniform image2D rwStorageTextureBoundToSlot1;
2697 * // Any read-write storage buffers come next in Set 1, in SDL bind slot order
2698 * layout(set = 1, binding = 2) buffer rwStorageBufferBoundToSlot0 { ... };
2699 * layout(set = 1, binding = 3) buffer rwStorageBufferBoundToSlot1 { ... };
2700 * // Any uniform buffers are in Set 2, in SDL slot order
2701 * layout(set = 2, binding = 0) uniform UniformDataBoundToSlot0 { ... };
2702 * layout(set = 2, binding = 1) uniform UniformDataBoundToSlot1 { ... };
2703 * ```
2704 *
2705 * ---
2706 *
2707 * **DXBC / DXIL (HLSL)**
2708 *
2709 * For compute shaders, use:
2710 *
2711 * - `(t[n], space0)` for sampled textures, read-only storage textures, and
2712 * read-only storage buffers
2713 * - `(s[n], space0)` for samplers
2714 * - `(u[n], space1)` for read-write storage textures and read-write storage
2715 * buffers
2716 * - `(b[n], space2)` for uniform data
2717 *
2718 * The first resource in a given register set must have a register index of
2719 * `0`. Additional resources must appear at consecutive indices (1, 2, etc),
2720 * leaving no gaps in the register set.
2721 *
2722 * All sampled textures must come first in the `t` register set, in order of
2723 * how they are bound via `SDL_BindGPUComputeSamplers()`.
2724 *
2725 * All sampler objects must be in the `s` register set, in the same order as
2726 * the textures above.
2727 *
2728 * All read-only storage textures must come after all samplers in the `t`
2729 * register set, in order of how they are bound via
2730 * `SDL_BindComputeStorageTextures()`.
2731 *
2732 * All read-only storage buffers must come after all storage textures in the
2733 * `t` register set, in order of how they are bound via
2734 * `SDL_BindComputeStorageBuffers()`.
2735 *
2736 * All read-write storage textures must come first in the `u` register set in
2737 * `space1`, in order of how they are bound via `SDL_BeginGPUComputePass()`.
2738 *
2739 * All read-write storage buffers must come after all read-write storage
2740 * textures in the `u` register set in `space1`, in order of how they are
2741 * bound via `SDL_BeginGPUComputePass()`.
2742 *
2743 * **Example**
2744 *
2745 * If a compute shader binds 2 of each resource type, the layout should look
2746 * like this:
2747 *
2748 * ```c
2749 * // Any samplers and sampled textures come first in their respective register sets, in SDL bind slot order
2750 * SamplerState SamplerBoundToSlot0 : register( s0, space0 );
2751 * SamplerState SamplerBoundToSlot1 : register( s1, space0 );
2752 * Texture2D SampledTextureBoundToSlot0 : register( t0, space0 );
2753 * Texture2D SampledTextureBoundToSlot1 : register( t1, space0 );
2754 * // Any read-only storage textures come next in the `t` register set, in SDL bind slot order
2755 * Texture2D StorageTextureBoundToSlot0 : register( t2, space0 );
2756 * Texture2D StorageTextureBoundToSlot1 : register( t3, space0 );
2757 * // Any read-only storage buffers come next in the `t` register set, in SDL bind slot order
2758 * ByteAddressBuffer StorageBufferBoundToSlot0 : register( t4, space0 );
2759 * ByteAddressBuffer StorageBufferBoundToSlot1 : register( t5, space0 );
2760 * // Any read-write storage textures come first in the `u` register set in space1, in SDL bind slot order
2761 * RWTexture2D RWStorageTextureBoundToSlot0 : register( u0, space1 );
2762 * RWTexture2D RWStorageTextureBoundToSlot1 : register( u1, space1 );
2763 * // Any read-write storage buffers come next in the `u` register set in space1, in SDL bind slot order
2764 * RWByteAddressBuffer RWStorageTextureBoundToSlot0 : register( u2, space1 );
2765 * RWByteAddressBuffer RWStorageTextureBoundToSlot1 : register( u3, space1 );
2766 * // Any uniform buffers are in the `b` register set in space2, in SDL slot order
2767 * cbuffer UniformDataBoundToSlot0 : register( b0, space2 ) { ... };
2768 * cbuffer UniformDataBoundToSlot1 : register( b1, space2 ) { ... };
2769 * ```
2770 *
2771 * ---
2772 *
2773 * **MSL / Metallib (Metal Shading Language)**
2774 *
2775 * The first resource in a given argument table must have an index of `0`.
2776 * Additional resources must appear at consecutive indices (1, 2, etc),
2777 * leaving no gaps in the table.
2778 *
2779 * All sampled textures must come first in the `[[texture]]` argument table,
2780 * in order of how they are bound via `SDL_BindGPUComputeSamplers()`.
2781 *
2782 * All sampler objects must be in the `[[sampler]]` argument table, in the
2783 * same order as the textures above.
2784 *
2785 * All read-only storage textures must come after all sampled textures in the
2786 * `[[texture]]` argument table, in order of how they are bound via
2787 * `SDL_BindGPUComputeStorageTextures()`.
2788 *
2789 * All read-write storage textures must come after all read-only storage
2790 * textures in the `[[texture]]` argument table, in order of how they are
2791 * bound via `SDL_BeginGPUComputePass()`.
2792 *
2793 * All uniform buffers must come first in the `[[buffer]]` argument table, in
2794 * order of their slots in `SDL_PushGPUComputeUniformData()`.
2795 *
2796 * All read-only storage buffers must come after all uniform buffers in the
2797 * `[[buffer]]` argument table, in order of how they are bound via
2798 * `SDL_BindGPUComputeStorageBuffers()`.
2799 *
2800 * All read-write storage buffers must come after all read-only storage
2801 * buffers in the `[[buffer]]` argument table, in order of how they are bound
2802 * via `SDL_BeginGPUComputePass()`.
2803 *
2804 * **Example**
2805 *
2806 * For a compute shader binding 2 of each resource type, the main function
2807 * signature should look like this:
2808 *
2809 * ```c++
2810 * kernel void ExampleComputeShader(
2811 * // Any samplers go in the `sampler` table, in SDL bind slot order
2812 * sampler samplerBoundToSlot0 [[sampler(0)]],
2813 * sampler samplerBoundToSlot1 [[sampler(1)]],
2814 * // Any sampled textures come first in the `texture` table, in SDL bind slot order
2815 * texture2d<float> sampledTextureBoundToSlot0 [[texture(0)]],
2816 * texture2d<float> sampledTextureBoundToSlot1 [[texture(1)]],
2817 * // Any read-only storage textures come next in the `texture` table, in SDL bind slot order
2818 * texture2d<float> storageTextureBoundToSlot0 [[texture(2)]],
2819 * texture2d<float> storageTextureBoundToSlot1 [[texture(3)]],
2820 * // Any read-write storage textures come next in the `texture` table, in SDL bind slot order
2821 * texture2d<float, access::write> rwStorageTextureBoundToSlot0 [[texture(4)]];
2822 * texture2d<float, access::write> rwStorageTextureBoundToSlot1 [[texture(5)]];
2823 * // Any uniform buffers come first in the `buffer` table, in SDL slot order
2824 * constant SomeUniformStruct uniformDataBoundToSlot0 [[buffer(0)]],
2825 * constant SomeUniformStruct uniformDataBoundToSlot1 [[buffer(1)]],
2826 * // Any read-only storage buffers come next in the `buffer` table, in SDL bind slot order
2827 * device SomeBufferStruct& storageBufferBoundToSlot0 [[buffer(2)]],
2828 * device SomeBufferStruct& storageBufferBoundToSlot1 [[buffer(3)]]);
2829 * // Any read-write storage buffers come next in the `buffer` table, in SDL bind slot order
2830 * device SomeBufferStruct& rwStorageBufferBoundToSlot0 [[buffer(4)]];
2831 * device SomeBufferStruct& rwStorageBufferBoundToSlot1 [[buffer(5)]]);
2832 * ```
2833 *
2834 * ---
2835 *
2836 * There are optional properties that can be provided through `props`. These
2837 * are the supported properties:
2838 *
2839 * - `SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING`: a name that can be
2840 * displayed in debugging tools.
2841 *
2842 * \param device a GPU Context.
2843 * \param createinfo a struct describing the state of the compute pipeline to
2844 * create.
2845 * \returns a compute pipeline object on success, or NULL on failure; call
2846 * SDL_GetError() for more information.
2847 *
2848 * \since This function is available since SDL 3.2.0.
2849 *
2850 * \sa SDL_BindGPUComputePipeline
2851 * \sa SDL_ReleaseGPUComputePipeline
2852 */
2854 SDL_GPUDevice *device,
2855 const SDL_GPUComputePipelineCreateInfo *createinfo);
2856
2857#define SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING "SDL.gpu.computepipeline.create.name"
2858
2859/**
2860 * Creates a pipeline object to be used in a graphics workflow.
2861 *
2862 * There are optional properties that can be provided through `props`. These
2863 * are the supported properties:
2864 *
2865 * - `SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING`: a name that can be
2866 * displayed in debugging tools.
2867 *
2868 * \param device a GPU Context.
2869 * \param createinfo a struct describing the state of the graphics pipeline to
2870 * create.
2871 * \returns a graphics pipeline object on success, or NULL on failure; call
2872 * SDL_GetError() for more information.
2873 *
2874 * \since This function is available since SDL 3.2.0.
2875 *
2876 * \sa SDL_CreateGPUShader
2877 * \sa SDL_BindGPUGraphicsPipeline
2878 * \sa SDL_ReleaseGPUGraphicsPipeline
2879 */
2881 SDL_GPUDevice *device,
2882 const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
2883
2884#define SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING "SDL.gpu.graphicspipeline.create.name"
2885
2886/**
2887 * Creates a sampler object to be used when binding textures in a graphics
2888 * workflow.
2889 *
2890 * There are optional properties that can be provided through `props`. These
2891 * are the supported properties:
2892 *
2893 * - `SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING`: a name that can be displayed
2894 * in debugging tools.
2895 *
2896 * \param device a GPU Context.
2897 * \param createinfo a struct describing the state of the sampler to create.
2898 * \returns a sampler object on success, or NULL on failure; call
2899 * SDL_GetError() for more information.
2900 *
2901 * \since This function is available since SDL 3.2.0.
2902 *
2903 * \sa SDL_BindGPUVertexSamplers
2904 * \sa SDL_BindGPUFragmentSamplers
2905 * \sa SDL_ReleaseGPUSampler
2906 */
2907extern SDL_DECLSPEC SDL_GPUSampler * SDLCALL SDL_CreateGPUSampler(
2908 SDL_GPUDevice *device,
2909 const SDL_GPUSamplerCreateInfo *createinfo);
2910
2911#define SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING "SDL.gpu.sampler.create.name"
2912
2913/**
2914 * Creates a shader to be used when creating a graphics pipeline.
2915 *
2916 * Shader resource bindings must be authored to follow a particular convention
2917 * depending on the shader format. See below for details.
2918 *
2919 * ---
2920 *
2921 * **SPIR-V (GLSL)**
2922 *
2923 * For vertex shaders, use: - Set 0 for samplers, storage textures, and
2924 * storage buffers - Set 1 for uniform data
2925 *
2926 * For fragment shaders, use: - Set 2 for samplers, storage textures, and
2927 * storage buffers - Set 3 for uniform data
2928 *
2929 * The first resource in a given set must have a `binding` of 0. Additional
2930 * resources must appear at consecutive bindings (1, 2, etc), leaving no gaps
2931 * in the set.
2932 *
2933 * All samplers must come first in the binding order, in order of how they are
2934 * bound via `SDL_BindGPU*Samplers()`.
2935 *
2936 * All storage textures must come after all samplers in the binding order, in
2937 * order of how they are bound via `SDL_Bind*StorageTextures()`.
2938 *
2939 * All storage buffers must come after all storage textures in the binding
2940 * order, in order of how they are bound via `SDL_Bind*StorageBuffers()`.
2941 *
2942 * **Example**
2943 *
2944 * If a vertex shader binds 2 samplers, 2 storage textures, 2 storage buffers,
2945 * and 2 uniform buffers, its binding layout should look like this:
2946 *
2947 * ```glsl
2948 * // Any samplers come first in the set, in SDL bind slot order
2949 * layout(set = 0, binding = 0) uniform sampler2D samplerBoundToSlot0;
2950 * layout(set = 0, binding = 1) uniform sampler2D samplerBoundToSlot1;
2951 * // Any storage textures come next in the set, in SDL bind slot order
2952 * layout(set = 0, binding = 2) uniform image2D storageTextureBoundToSlot0;
2953 * layout(set = 0, binding = 3) uniform image2D storageTextureBoundToSlot1;
2954 * // Any storage buffers come next in the set, in SDL bind slot order
2955 * layout(set = 0, binding = 4) buffer storageBufferBoundToSlot0 { ... };
2956 * layout(set = 0, binding = 5) buffer storageBufferBoundToSlot1 { ... };
2957 * // Any uniform buffers are in their own set, in SDL slot order
2958 * layout(set = 1, binding = 0) uniform UniformDataBoundToSlot0 { ... };
2959 * layout(set = 1, binding = 1) uniform UniformDataBoundToSlot1 { ... };
2960 * ```
2961 *
2962 * ---
2963 *
2964 * **DXBC / DXIL (HLSL)**
2965 *
2966 * For vertex shaders, use: - `(t[n], space0)` for sampled textures, storage
2967 * textures, and storage buffers - `(s[n], space0)` for samplers - `(b[n],
2968 * space1)` for uniform data
2969 *
2970 * For fragment (aka "pixel") shaders, use: - `(t[n], space2)` for sampled
2971 * textures, storage textures, and storage buffers - `(s[n], space2)` for
2972 * samplers - `(b[n], space3)` for uniform data
2973 *
2974 * The first resource in a given register set must have a register index of
2975 * `0`. Additional resources must appear at consecutive indices (1, 2, etc),
2976 * leaving no gaps in the register set.
2977 *
2978 * All sampled textures must come first in the `t` register set, in order of
2979 * how they are bound via `SDL_BindGPU*Samplers()`.
2980 *
2981 * All sampler objects must be in the `s` register set, in the same order as
2982 * the textures above.
2983 *
2984 * All storage textures must come after all samplers in the `t` register set,
2985 * in order of how they are bound via `SDL_Bind*StorageTextures()`.
2986 *
2987 * All storage buffers must come after all storage textures in the `t`
2988 * register set, in order of how they are bound via
2989 * `SDL_Bind*StorageBuffers()`.
2990 *
2991 * **Example**
2992 *
2993 * If a pixel shader binds 2 samplers, 2 storage textures, 2 storage buffers,
2994 * and 2 uniform buffers, its binding layout should look like this:
2995 *
2996 * ```c
2997 * // Any samplers and sampled textures come first in their respective register sets, in SDL bind slot order
2998 * SamplerState SamplerBoundToSlot0 : register( s0, space2 );
2999 * SamplerState SamplerBoundToSlot1 : register( s1, space2 );
3000 * Texture2D SampledTextureBoundToSlot0 : register( t0, space2 );
3001 * Texture2D SampledTextureBoundToSlot1 : register( t1, space2 );
3002 * // Any storage textures come next in the `t` register set, in SDL bind slot order
3003 * Texture2D StorageTextureBoundToSlot0 : register( t2, space2 );
3004 * Texture2D StorageTextureBoundToSlot1 : register( t3, space2 );
3005 * // Any storage buffers come next in the `t` register set, in SDL bind slot order
3006 * ByteAddressBuffer StorageBufferBoundToSlot0 : register( t4, space2 );
3007 * ByteAddressBuffer StorageBufferBoundToSlot1 : register( t5, space2 );
3008 * // Any uniform buffers are in the `b` register set *and* in their own space, in SDL slot order
3009 * cbuffer UniformDataBoundToSlot0 : register( b0, space3 ) { ... };
3010 * cbuffer UniformDataBoundToSlot1 : register( b1, space3 ) { ... };
3011 * ```
3012 *
3013 * ---
3014 *
3015 * **MSL / Metallib (Metal Shading Language)**
3016 *
3017 * The first resource in a given argument table must have an index of `0`.
3018 * Additional resources must appear at consecutive indices (1, 2, etc),
3019 * leaving no gaps in the table. (_Except_ in the case of vertex buffers,
3020 * which are mentioned below.)
3021 *
3022 * All sampled textures must come first in the `[[texture]]` argument table,
3023 * in order of how they are bound via `SDL_BindGPU*Samplers()`.
3024 *
3025 * All sampler objects must be in the `[[sampler]]` argument table, in the
3026 * same order as the textures above.
3027 *
3028 * All storage textures must come after all sampled textures in the
3029 * `[[texture]]` argument table, in order of how they are bound via
3030 * `SDL_BindGPU*StorageTextures()`.
3031 *
3032 * All uniform buffers must come first in the `[[buffer]]` argument table, in
3033 * order of their slots in `SDL_PushGPU*UniformData()`.
3034 *
3035 * All storage buffers must come after all uniform buffers in the `[[buffer]]`
3036 * argument table, in order of how they are bound via
3037 * `SDL_BindGPU*StorageBuffers()`.
3038 *
3039 * In Metal, vertex buffers are also included in the `[[buffer]]` argument
3040 * table. To work around this, SDL forces the vertex buffer bound to slot 0 to
3041 * be bound at `[[buffer(14)]]`. The vertex buffer in slot 1 will be bound to
3042 * `[[buffer(15)]]`, and so on. Rather than manually authoring vertex buffer
3043 * indices, use the `[[stage_in]]` attribute which will automatically use the
3044 * vertex input information from the SDL_GPUGraphicsPipeline.
3045 *
3046 * **Example**
3047 *
3048 * For a vertex shader with 1 vertex buffer, 2 samplers, 2 storage textures, 2
3049 * storage buffers, and 2 uniform buffers, the main function signature should
3050 * look something like this:
3051 *
3052 * ```c++
3053 * vertex VertexOutput ExampleVertexShader(
3054 * // Vertex buffers are their own special thing...
3055 * SomeVertexInput input [[stage_in]], // alternatively, SomeVertexInput input [[buffer(14)]]
3056 * // Any samplers go in the `sampler` table, in SDL bind slot order
3057 * sampler samplerBoundToSlot0 [[sampler(0)]],
3058 * sampler samplerBoundToSlot1 [[sampler(1)]],
3059 * // Any sampled textures come first in the `texture` table, in SDL bind slot order
3060 * texture2d<float> sampledTextureBoundToSlot0 [[texture(0)]],
3061 * texture2d<float> sampledTextureBoundToSlot1 [[texture(1)]],
3062 * // Any storage textures come next in the `texture` table, in SDL bind slot order
3063 * texture2d<float> storageTextureBoundToSlot0 [[texture(2)]],
3064 * texture2d<float> storageTextureBoundToSlot1 [[texture(3)]],
3065 * // Any uniform buffers come first in the `buffer` table, in SDL slot order
3066 * constant SomeUniformStruct uniformDataBoundToSlot0 [[buffer(0)]],
3067 * constant SomeUniformStruct uniformDataBoundToSlot1 [[buffer(1)]],
3068 * // Any storage buffers come next in the `buffer` table, in SDL bind slot order
3069 * device SomeBufferStruct& storageBufferBoundToSlot0 [[buffer(2)]],
3070 * device SomeBufferStruct& storageBufferBoundToSlot1 [[buffer(3)]]);
3071 *
3072 * ```
3073 *
3074 * ---
3075 *
3076 * Shader semantics other than system-value semantics do not matter in D3D12.
3077 * For ease of use, the SDL implementation assumes that non system-value
3078 * semantics will all be `TEXCOORD`. If you are using HLSL as the shader
3079 * source language, your vertex semantics should start at `TEXCOORD0` and
3080 * increment like so: `TEXCOORD1`, `TEXCOORD2`, etc.
3081 *
3082 * If you wish to change the semantic prefix to something other than
3083 * `TEXCOORD` you can use
3084 * SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING with
3085 * SDL_CreateGPUDeviceWithProperties().
3086 *
3087 * There are optional properties that can be provided through `props`. These
3088 * are the supported properties:
3089 *
3090 * - `SDL_PROP_GPU_SHADER_CREATE_NAME_STRING`: a name that can be displayed in
3091 * debugging tools.
3092 *
3093 * \param device a GPU Context.
3094 * \param createinfo a struct describing the state of the shader to create.
3095 * \returns a shader object on success, or NULL on failure; call
3096 * SDL_GetError() for more information.
3097 *
3098 * \since This function is available since SDL 3.2.0.
3099 *
3100 * \sa SDL_CreateGPUGraphicsPipeline
3101 * \sa SDL_ReleaseGPUShader
3102 */
3103extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader(
3104 SDL_GPUDevice *device,
3105 const SDL_GPUShaderCreateInfo *createinfo);
3106
3107#define SDL_PROP_GPU_SHADER_CREATE_NAME_STRING "SDL.gpu.shader.create.name"
3108
3109/**
3110 * Creates a texture object to be used in graphics or compute workflows.
3111 *
3112 * The contents of this texture are undefined until data is written to the
3113 * texture, either via SDL_UploadToGPUTexture or by performing a render or
3114 * compute pass with this texture as a target.
3115 *
3116 * Note that certain combinations of usage flags are invalid. For example, a
3117 * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags.
3118 *
3119 * If you request a sample count higher than the hardware supports, the
3120 * implementation will automatically fall back to the highest available sample
3121 * count.
3122 *
3123 * There are optional properties that can be provided through
3124 * SDL_GPUTextureCreateInfo's `props`. These are the supported properties:
3125 *
3126 * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOAT`: (Direct3D 12 only) if
3127 * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture
3128 * to a color with this red intensity. Defaults to zero.
3129 * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOAT`: (Direct3D 12 only) if
3130 * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture
3131 * to a color with this green intensity. Defaults to zero.
3132 * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOAT`: (Direct3D 12 only) if
3133 * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture
3134 * to a color with this blue intensity. Defaults to zero.
3135 * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOAT`: (Direct3D 12 only) if
3136 * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture
3137 * to a color with this alpha intensity. Defaults to zero.
3138 * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOAT`: (Direct3D 12 only)
3139 * if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear
3140 * the texture to a depth of this value. Defaults to zero.
3141 * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBER`: (Direct3D 12
3142 * only) if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET,
3143 * clear the texture to a stencil of this Uint8 value. Defaults to zero.
3144 * - `SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING`: a name that can be displayed
3145 * in debugging tools.
3146 *
3147 * \param device a GPU Context.
3148 * \param createinfo a struct describing the state of the texture to create.
3149 * \returns a texture object on success, or NULL on failure; call
3150 * SDL_GetError() for more information.
3151 *
3152 * \since This function is available since SDL 3.2.0.
3153 *
3154 * \sa SDL_UploadToGPUTexture
3155 * \sa SDL_DownloadFromGPUTexture
3156 * \sa SDL_BeginGPURenderPass
3157 * \sa SDL_BeginGPUComputePass
3158 * \sa SDL_BindGPUVertexSamplers
3159 * \sa SDL_BindGPUVertexStorageTextures
3160 * \sa SDL_BindGPUFragmentSamplers
3161 * \sa SDL_BindGPUFragmentStorageTextures
3162 * \sa SDL_BindGPUComputeStorageTextures
3163 * \sa SDL_BlitGPUTexture
3164 * \sa SDL_ReleaseGPUTexture
3165 * \sa SDL_GPUTextureSupportsFormat
3166 */
3167extern SDL_DECLSPEC SDL_GPUTexture * SDLCALL SDL_CreateGPUTexture(
3168 SDL_GPUDevice *device,
3169 const SDL_GPUTextureCreateInfo *createinfo);
3170
3171#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOAT "SDL.gpu.texture.create.d3d12.clear.r"
3172#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOAT "SDL.gpu.texture.create.d3d12.clear.g"
3173#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOAT "SDL.gpu.texture.create.d3d12.clear.b"
3174#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOAT "SDL.gpu.texture.create.d3d12.clear.a"
3175#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.texture.create.d3d12.clear.depth"
3176#define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBER "SDL.gpu.texture.create.d3d12.clear.stencil"
3177#define SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING "SDL.gpu.texture.create.name"
3178
3179/**
3180 * Creates a buffer object to be used in graphics or compute workflows.
3181 *
3182 * The contents of this buffer are undefined until data is written to the
3183 * buffer.
3184 *
3185 * Note that certain combinations of usage flags are invalid. For example, a
3186 * buffer cannot have both the VERTEX and INDEX flags.
3187 *
3188 * If you use a STORAGE flag, the data in the buffer must respect std430
3189 * layout conventions. In practical terms this means you must ensure that vec3
3190 * and vec4 fields are 16-byte aligned.
3191 *
3192 * For better understanding of underlying concepts and memory management with
3193 * SDL GPU API, you may refer
3194 * [this blog post](https://moonside.games/posts/sdl-gpu-concepts-cycling/)
3195 * .
3196 *
3197 * There are optional properties that can be provided through `props`. These
3198 * are the supported properties:
3199 *
3200 * - `SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING`: a name that can be displayed in
3201 * debugging tools.
3202 *
3203 * \param device a GPU Context.
3204 * \param createinfo a struct describing the state of the buffer to create.
3205 * \returns a buffer object on success, or NULL on failure; call
3206 * SDL_GetError() for more information.
3207 *
3208 * \since This function is available since SDL 3.2.0.
3209 *
3210 * \sa SDL_UploadToGPUBuffer
3211 * \sa SDL_DownloadFromGPUBuffer
3212 * \sa SDL_CopyGPUBufferToBuffer
3213 * \sa SDL_BindGPUVertexBuffers
3214 * \sa SDL_BindGPUIndexBuffer
3215 * \sa SDL_BindGPUVertexStorageBuffers
3216 * \sa SDL_BindGPUFragmentStorageBuffers
3217 * \sa SDL_DrawGPUPrimitivesIndirect
3218 * \sa SDL_DrawGPUIndexedPrimitivesIndirect
3219 * \sa SDL_BindGPUComputeStorageBuffers
3220 * \sa SDL_DispatchGPUComputeIndirect
3221 * \sa SDL_ReleaseGPUBuffer
3222 */
3223extern SDL_DECLSPEC SDL_GPUBuffer * SDLCALL SDL_CreateGPUBuffer(
3224 SDL_GPUDevice *device,
3225 const SDL_GPUBufferCreateInfo *createinfo);
3226
3227#define SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING "SDL.gpu.buffer.create.name"
3228
3229/**
3230 * Creates a transfer buffer to be used when uploading to or downloading from
3231 * graphics resources.
3232 *
3233 * Download buffers can be particularly expensive to create, so it is good
3234 * practice to reuse them if data will be downloaded regularly.
3235 *
3236 * There are optional properties that can be provided through `props`. These
3237 * are the supported properties:
3238 *
3239 * - `SDL_PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING`: a name that can be
3240 * displayed in debugging tools.
3241 *
3242 * \param device a GPU Context.
3243 * \param createinfo a struct describing the state of the transfer buffer to
3244 * create.
3245 * \returns a transfer buffer on success, or NULL on failure; call
3246 * SDL_GetError() for more information.
3247 *
3248 * \since This function is available since SDL 3.2.0.
3249 *
3250 * \sa SDL_MapGPUTransferBuffer
3251 * \sa SDL_UnmapGPUTransferBuffer
3252 * \sa SDL_UploadToGPUBuffer
3253 * \sa SDL_DownloadFromGPUBuffer
3254 * \sa SDL_UploadToGPUTexture
3255 * \sa SDL_DownloadFromGPUTexture
3256 * \sa SDL_ReleaseGPUTransferBuffer
3257 */
3259 SDL_GPUDevice *device,
3260 const SDL_GPUTransferBufferCreateInfo *createinfo);
3261
3262#define SDL_PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING "SDL.gpu.transferbuffer.create.name"
3263
3264/* Debug Naming */
3265
3266/**
3267 * Sets an arbitrary string constant to label a buffer.
3268 *
3269 * You should use SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING with
3270 * SDL_CreateGPUBuffer instead of this function to avoid thread safety issues.
3271 *
3272 * \param device a GPU Context.
3273 * \param buffer a buffer to attach the name to.
3274 * \param text a UTF-8 string constant to mark as the name of the buffer.
3275 *
3276 * \threadsafety This function is not thread safe, you must make sure the
3277 * buffer is not simultaneously used by any other thread.
3278 *
3279 * \since This function is available since SDL 3.2.0.
3280 *
3281 * \sa SDL_CreateGPUBuffer
3282 */
3283extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName(
3284 SDL_GPUDevice *device,
3285 SDL_GPUBuffer *buffer,
3286 const char *text);
3287
3288/**
3289 * Sets an arbitrary string constant to label a texture.
3290 *
3291 * You should use SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING with
3292 * SDL_CreateGPUTexture instead of this function to avoid thread safety
3293 * issues.
3294 *
3295 * \param device a GPU Context.
3296 * \param texture a texture to attach the name to.
3297 * \param text a UTF-8 string constant to mark as the name of the texture.
3298 *
3299 * \threadsafety This function is not thread safe, you must make sure the
3300 * texture is not simultaneously used by any other thread.
3301 *
3302 * \since This function is available since SDL 3.2.0.
3303 *
3304 * \sa SDL_CreateGPUTexture
3305 */
3306extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName(
3307 SDL_GPUDevice *device,
3308 SDL_GPUTexture *texture,
3309 const char *text);
3310
3311/**
3312 * Inserts an arbitrary string label into the command buffer callstream.
3313 *
3314 * Useful for debugging.
3315 *
3316 * On Direct3D 12, using SDL_InsertGPUDebugLabel requires
3317 * WinPixEventRuntime.dll to be in your PATH or in the same directory as your
3318 * executable. See
3319 * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/)
3320 * for instructions on how to obtain it.
3321 *
3322 * \param command_buffer a command buffer.
3323 * \param text a UTF-8 string constant to insert as the label.
3324 *
3325 * \since This function is available since SDL 3.2.0.
3326 */
3327extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
3328 SDL_GPUCommandBuffer *command_buffer,
3329 const char *text);
3330
3331/**
3332 * Begins a debug group with an arbitrary name.
3333 *
3334 * Used for denoting groups of calls when viewing the command buffer
3335 * callstream in a graphics debugging tool.
3336 *
3337 * Each call to SDL_PushGPUDebugGroup must have a corresponding call to
3338 * SDL_PopGPUDebugGroup.
3339 *
3340 * On Direct3D 12, using SDL_PushGPUDebugGroup requires WinPixEventRuntime.dll
3341 * to be in your PATH or in the same directory as your executable. See
3342 * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/)
3343 * for instructions on how to obtain it.
3344 *
3345 * On some backends (e.g. Metal), pushing a debug group during a
3346 * render/blit/compute pass will create a group that is scoped to the native
3347 * pass rather than the command buffer. For best results, if you push a debug
3348 * group during a pass, always pop it in the same pass.
3349 *
3350 * \param command_buffer a command buffer.
3351 * \param name a UTF-8 string constant that names the group.
3352 *
3353 * \since This function is available since SDL 3.2.0.
3354 *
3355 * \sa SDL_PopGPUDebugGroup
3356 */
3357extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup(
3358 SDL_GPUCommandBuffer *command_buffer,
3359 const char *name);
3360
3361/**
3362 * Ends the most-recently pushed debug group.
3363 *
3364 * On Direct3D 12, using SDL_PopGPUDebugGroup requires WinPixEventRuntime.dll
3365 * to be in your PATH or in the same directory as your executable. See
3366 * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/)
3367 * for instructions on how to obtain it.
3368 *
3369 * \param command_buffer a command buffer.
3370 *
3371 * \since This function is available since SDL 3.2.0.
3372 *
3373 * \sa SDL_PushGPUDebugGroup
3374 */
3375extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup(
3376 SDL_GPUCommandBuffer *command_buffer);
3377
3378/* Disposal */
3379
3380/**
3381 * Frees the given texture as soon as it is safe to do so.
3382 *
3383 * You must not reference the texture after calling this function.
3384 *
3385 * It is safe to pass NULL for `texture`, in that case this function is a
3386 * no-op.
3387 *
3388 * \param device a GPU context.
3389 * \param texture a texture to be destroyed.
3390 *
3391 * \since This function is available since SDL 3.2.0.
3392 */
3393extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture(
3394 SDL_GPUDevice *device,
3395 SDL_GPUTexture *texture);
3396
3397/**
3398 * Frees the given sampler as soon as it is safe to do so.
3399 *
3400 * You must not reference the sampler after calling this function.
3401 *
3402 * It is safe to pass NULL for `sampler`, in that case this function is a
3403 * no-op.
3404 *
3405 * \param device a GPU context.
3406 * \param sampler a sampler to be destroyed.
3407 *
3408 * \since This function is available since SDL 3.2.0.
3409 */
3410extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler(
3411 SDL_GPUDevice *device,
3412 SDL_GPUSampler *sampler);
3413
3414/**
3415 * Frees the given buffer as soon as it is safe to do so.
3416 *
3417 * You must not reference the buffer after calling this function.
3418 *
3419 * It is safe to pass NULL for `buffer`, in that case this function is a
3420 * no-op.
3421 *
3422 * \param device a GPU context.
3423 * \param buffer a buffer to be destroyed.
3424 *
3425 * \since This function is available since SDL 3.2.0.
3426 */
3427extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer(
3428 SDL_GPUDevice *device,
3429 SDL_GPUBuffer *buffer);
3430
3431/**
3432 * Frees the given transfer buffer as soon as it is safe to do so.
3433 *
3434 * You must not reference the transfer buffer after calling this function.
3435 *
3436 * It is safe to pass NULL for `transfer_buffer`, in that case this function
3437 * is a no-op.
3438 *
3439 * \param device a GPU context.
3440 * \param transfer_buffer a transfer buffer to be destroyed.
3441 *
3442 * \since This function is available since SDL 3.2.0.
3443 */
3444extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer(
3445 SDL_GPUDevice *device,
3446 SDL_GPUTransferBuffer *transfer_buffer);
3447
3448/**
3449 * Frees the given compute pipeline as soon as it is safe to do so.
3450 *
3451 * You must not reference the compute pipeline after calling this function.
3452 *
3453 * It is safe to pass NULL for `compute_pipeline`, in that case this function
3454 * is a no-op.
3455 *
3456 * \param device a GPU context.
3457 * \param compute_pipeline a compute pipeline to be destroyed.
3458 *
3459 * \since This function is available since SDL 3.2.0.
3460 */
3461extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline(
3462 SDL_GPUDevice *device,
3463 SDL_GPUComputePipeline *compute_pipeline);
3464
3465/**
3466 * Frees the given shader as soon as it is safe to do so.
3467 *
3468 * You must not reference the shader after calling this function.
3469 *
3470 * It is safe to pass NULL for `shader`, in that case this function is a
3471 * no-op.
3472 *
3473 * \param device a GPU context.
3474 * \param shader a shader to be destroyed.
3475 *
3476 * \since This function is available since SDL 3.2.0.
3477 */
3478extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader(
3479 SDL_GPUDevice *device,
3480 SDL_GPUShader *shader);
3481
3482/**
3483 * Frees the given graphics pipeline as soon as it is safe to do so.
3484 *
3485 * You must not reference the graphics pipeline after calling this function.
3486 *
3487 * It is safe to pass NULL for `graphics_pipeline`, in that case this function
3488 * is a no-op.
3489 *
3490 * \param device a GPU context.
3491 * \param graphics_pipeline a graphics pipeline to be destroyed.
3492 *
3493 * \since This function is available since SDL 3.2.0.
3494 */
3495extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline(
3496 SDL_GPUDevice *device,
3497 SDL_GPUGraphicsPipeline *graphics_pipeline);
3498
3499/**
3500 * Acquire a command buffer.
3501 *
3502 * This command buffer is managed by the implementation and should not be
3503 * freed by the user. The command buffer may only be used on the thread it was
3504 * acquired on. The command buffer should be submitted on the thread it was
3505 * acquired on.
3506 *
3507 * It is valid to acquire multiple command buffers on the same thread at once.
3508 * In fact a common design pattern is to acquire two command buffers per frame
3509 * where one is dedicated to render and compute passes and the other is
3510 * dedicated to copy passes and other preparatory work such as generating
3511 * mipmaps. Interleaving commands between the two command buffers reduces the
3512 * total amount of passes overall which improves rendering performance.
3513 *
3514 * \param device a GPU context.
3515 * \returns a command buffer, or NULL on failure; call SDL_GetError() for more
3516 * information.
3517 *
3518 * \since This function is available since SDL 3.2.0.
3519 *
3520 * \sa SDL_SubmitGPUCommandBuffer
3521 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
3522 */
3524 SDL_GPUDevice *device);
3525
3526/* Uniform Data */
3527
3528/**
3529 * Pushes data to a vertex uniform slot on the command buffer.
3530 *
3531 * Subsequent draw calls in this command buffer will use this uniform data.
3532 *
3533 * The data being pushed must respect std140 layout conventions. In practical
3534 * terms this means you must ensure that vec3 and vec4 fields are 16-byte
3535 * aligned.
3536 *
3537 * For detailed information about accessing uniform data from a shader, please
3538 * refer to SDL_CreateGPUShader.
3539 *
3540 * \param command_buffer a command buffer.
3541 * \param slot_index the vertex uniform slot to push data to.
3542 * \param data client data to write.
3543 * \param length the length of the data to write.
3544 *
3545 * \since This function is available since SDL 3.2.0.
3546 */
3547extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData(
3548 SDL_GPUCommandBuffer *command_buffer,
3549 Uint32 slot_index,
3550 const void *data,
3551 Uint32 length);
3552
3553/**
3554 * Pushes data to a fragment uniform slot on the command buffer.
3555 *
3556 * Subsequent draw calls in this command buffer will use this uniform data.
3557 *
3558 * The data being pushed must respect std140 layout conventions. In practical
3559 * terms this means you must ensure that vec3 and vec4 fields are 16-byte
3560 * aligned.
3561 *
3562 * \param command_buffer a command buffer.
3563 * \param slot_index the fragment uniform slot to push data to.
3564 * \param data client data to write.
3565 * \param length the length of the data to write.
3566 *
3567 * \since This function is available since SDL 3.2.0.
3568 */
3569extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData(
3570 SDL_GPUCommandBuffer *command_buffer,
3571 Uint32 slot_index,
3572 const void *data,
3573 Uint32 length);
3574
3575/**
3576 * Pushes data to a uniform slot on the command buffer.
3577 *
3578 * Subsequent draw calls in this command buffer will use this uniform data.
3579 *
3580 * The data being pushed must respect std140 layout conventions. In practical
3581 * terms this means you must ensure that vec3 and vec4 fields are 16-byte
3582 * aligned.
3583 *
3584 * \param command_buffer a command buffer.
3585 * \param slot_index the uniform slot to push data to.
3586 * \param data client data to write.
3587 * \param length the length of the data to write.
3588 *
3589 * \since This function is available since SDL 3.2.0.
3590 */
3591extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData(
3592 SDL_GPUCommandBuffer *command_buffer,
3593 Uint32 slot_index,
3594 const void *data,
3595 Uint32 length);
3596
3597/* Graphics State */
3598
3599/**
3600 * Begins a render pass on a command buffer.
3601 *
3602 * A render pass consists of a set of texture subresources (or depth slices in
3603 * the 3D texture case) which will be rendered to during the render pass,
3604 * along with corresponding clear values and load/store operations. All
3605 * operations related to graphics pipelines must take place inside of a render
3606 * pass. A default viewport and scissor state are automatically set when this
3607 * is called. You cannot begin another render pass, or begin a compute pass or
3608 * copy pass until you have ended the render pass.
3609 *
3610 * Using SDL_GPU_LOADOP_LOAD before any contents have been written to the
3611 * texture subresource will result in undefined behavior. SDL_GPU_LOADOP_CLEAR
3612 * will set the contents of the texture subresource to a single value before
3613 * any rendering is performed. It's fine to do an empty render pass using
3614 * SDL_GPU_STOREOP_STORE to clear a texture, but in general it's better to
3615 * think of clearing not as an independent operation but as something that's
3616 * done as the beginning of a render pass.
3617 *
3618 * \param command_buffer a command buffer.
3619 * \param color_target_infos an array of texture subresources with
3620 * corresponding clear values and load/store ops.
3621 * \param num_color_targets the number of color targets in the
3622 * color_target_infos array.
3623 * \param depth_stencil_target_info a texture subresource with corresponding
3624 * clear value and load/store ops, may be
3625 * NULL.
3626 * \returns a render pass handle.
3627 *
3628 * \since This function is available since SDL 3.2.0.
3629 *
3630 * \sa SDL_EndGPURenderPass
3631 */
3632extern SDL_DECLSPEC SDL_GPURenderPass * SDLCALL SDL_BeginGPURenderPass(
3633 SDL_GPUCommandBuffer *command_buffer,
3634 const SDL_GPUColorTargetInfo *color_target_infos,
3635 Uint32 num_color_targets,
3636 const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
3637
3638/**
3639 * Binds a graphics pipeline on a render pass to be used in rendering.
3640 *
3641 * A graphics pipeline must be bound before making any draw calls.
3642 *
3643 * \param render_pass a render pass handle.
3644 * \param graphics_pipeline the graphics pipeline to bind.
3645 *
3646 * \since This function is available since SDL 3.2.0.
3647 */
3648extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline(
3649 SDL_GPURenderPass *render_pass,
3650 SDL_GPUGraphicsPipeline *graphics_pipeline);
3651
3652/**
3653 * Sets the current viewport state on a command buffer.
3654 *
3655 * \param render_pass a render pass handle.
3656 * \param viewport the viewport to set.
3657 *
3658 * \since This function is available since SDL 3.2.0.
3659 */
3660extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport(
3661 SDL_GPURenderPass *render_pass,
3662 const SDL_GPUViewport *viewport);
3663
3664/**
3665 * Sets the current scissor state on a command buffer.
3666 *
3667 * \param render_pass a render pass handle.
3668 * \param scissor the scissor area to set.
3669 *
3670 * \since This function is available since SDL 3.2.0.
3671 */
3672extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor(
3673 SDL_GPURenderPass *render_pass,
3674 const SDL_Rect *scissor);
3675
3676/**
3677 * Sets the current blend constants on a command buffer.
3678 *
3679 * \param render_pass a render pass handle.
3680 * \param blend_constants the blend constant color.
3681 *
3682 * \since This function is available since SDL 3.2.0.
3683 *
3684 * \sa SDL_GPU_BLENDFACTOR_CONSTANT_COLOR
3685 * \sa SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR
3686 */
3687extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBlendConstants(
3688 SDL_GPURenderPass *render_pass,
3689 SDL_FColor blend_constants);
3690
3691/**
3692 * Sets the current stencil reference value on a command buffer.
3693 *
3694 * \param render_pass a render pass handle.
3695 * \param reference the stencil reference value to set.
3696 *
3697 * \since This function is available since SDL 3.2.0.
3698 */
3699extern SDL_DECLSPEC void SDLCALL SDL_SetGPUStencilReference(
3700 SDL_GPURenderPass *render_pass,
3701 Uint8 reference);
3702
3703/**
3704 * Binds vertex buffers on a command buffer for use with subsequent draw
3705 * calls.
3706 *
3707 * \param render_pass a render pass handle.
3708 * \param first_slot the vertex buffer slot to begin binding from.
3709 * \param bindings an array of SDL_GPUBufferBinding structs containing vertex
3710 * buffers and offset values.
3711 * \param num_bindings the number of bindings in the bindings array.
3712 *
3713 * \since This function is available since SDL 3.2.0.
3714 */
3715extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(
3716 SDL_GPURenderPass *render_pass,
3717 Uint32 first_slot,
3718 const SDL_GPUBufferBinding *bindings,
3719 Uint32 num_bindings);
3720
3721/**
3722 * Binds an index buffer on a command buffer for use with subsequent draw
3723 * calls.
3724 *
3725 * \param render_pass a render pass handle.
3726 * \param binding a pointer to a struct containing an index buffer and offset.
3727 * \param index_element_size whether the index values in the buffer are 16- or
3728 * 32-bit.
3729 *
3730 * \since This function is available since SDL 3.2.0.
3731 */
3732extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer(
3733 SDL_GPURenderPass *render_pass,
3734 const SDL_GPUBufferBinding *binding,
3735 SDL_GPUIndexElementSize index_element_size);
3736
3737/**
3738 * Binds texture-sampler pairs for use on the vertex shader.
3739 *
3740 * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
3741 *
3742 * The textures being bound must have a matching type declared in the shader
3743 * (2D, 3D, etc.). Multisample textures are not allowed.
3744 *
3745 * Be sure your shader is set up according to the requirements documented in
3746 * SDL_CreateGPUShader().
3747 *
3748 * \param render_pass a render pass handle.
3749 * \param first_slot the vertex sampler slot to begin binding from.
3750 * \param texture_sampler_bindings an array of texture-sampler binding
3751 * structs.
3752 * \param num_bindings the number of texture-sampler pairs to bind from the
3753 * array.
3754 *
3755 * \since This function is available since SDL 3.2.0.
3756 *
3757 * \sa SDL_CreateGPUShader
3758 */
3759extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(
3760 SDL_GPURenderPass *render_pass,
3761 Uint32 first_slot,
3762 const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
3763 Uint32 num_bindings);
3764
3765/**
3766 * Binds storage textures for use on the vertex shader.
3767 *
3768 * These textures must have been created with
3769 * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ.
3770 *
3771 * The textures being bound must have a matching type declared in the shader
3772 * (2D, 3D, 2DMS, etc.)
3773 *
3774 * Be sure your shader is set up according to the requirements documented in
3775 * SDL_CreateGPUShader().
3776 *
3777 * \param render_pass a render pass handle.
3778 * \param first_slot the vertex storage texture slot to begin binding from.
3779 * \param storage_textures an array of storage textures.
3780 * \param num_bindings the number of storage texture to bind from the array.
3781 *
3782 * \since This function is available since SDL 3.2.0.
3783 *
3784 * \sa SDL_CreateGPUShader
3785 */
3786extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures(
3787 SDL_GPURenderPass *render_pass,
3788 Uint32 first_slot,
3789 SDL_GPUTexture *const *storage_textures,
3790 Uint32 num_bindings);
3791
3792/**
3793 * Binds storage buffers for use on the vertex shader.
3794 *
3795 * These buffers must have been created with
3796 * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ.
3797 *
3798 * Be sure your shader is set up according to the requirements documented in
3799 * SDL_CreateGPUShader().
3800 *
3801 * \param render_pass a render pass handle.
3802 * \param first_slot the vertex storage buffer slot to begin binding from.
3803 * \param storage_buffers an array of buffers.
3804 * \param num_bindings the number of buffers to bind from the array.
3805 *
3806 * \since This function is available since SDL 3.2.0.
3807 *
3808 * \sa SDL_CreateGPUShader
3809 */
3810extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers(
3811 SDL_GPURenderPass *render_pass,
3812 Uint32 first_slot,
3813 SDL_GPUBuffer *const *storage_buffers,
3814 Uint32 num_bindings);
3815
3816/**
3817 * Binds texture-sampler pairs for use on the fragment shader.
3818 *
3819 * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
3820 *
3821 * The textures being bound must have a matching type declared in the shader
3822 * (2D, 3D, etc.). Multisample textures are not allowed.
3823 *
3824 * Be sure your shader is set up according to the requirements documented in
3825 * SDL_CreateGPUShader().
3826 *
3827 * \param render_pass a render pass handle.
3828 * \param first_slot the fragment sampler slot to begin binding from.
3829 * \param texture_sampler_bindings an array of texture-sampler binding
3830 * structs.
3831 * \param num_bindings the number of texture-sampler pairs to bind from the
3832 * array.
3833 *
3834 * \since This function is available since SDL 3.2.0.
3835 *
3836 * \sa SDL_CreateGPUShader
3837 */
3838extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(
3839 SDL_GPURenderPass *render_pass,
3840 Uint32 first_slot,
3841 const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
3842 Uint32 num_bindings);
3843
3844/**
3845 * Binds storage textures for use on the fragment shader.
3846 *
3847 * These textures must have been created with
3848 * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ.
3849 *
3850 * The textures being bound must have a matching type declared in the shader
3851 * (2D, 3D, 2DMS, etc.)
3852 *
3853 * Be sure your shader is set up according to the requirements documented in
3854 * SDL_CreateGPUShader().
3855 *
3856 * \param render_pass a render pass handle.
3857 * \param first_slot the fragment storage texture slot to begin binding from.
3858 * \param storage_textures an array of storage textures.
3859 * \param num_bindings the number of storage textures to bind from the array.
3860 *
3861 * \since This function is available since SDL 3.2.0.
3862 *
3863 * \sa SDL_CreateGPUShader
3864 */
3865extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(
3866 SDL_GPURenderPass *render_pass,
3867 Uint32 first_slot,
3868 SDL_GPUTexture *const *storage_textures,
3869 Uint32 num_bindings);
3870
3871/**
3872 * Binds storage buffers for use on the fragment shader.
3873 *
3874 * These buffers must have been created with
3875 * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ.
3876 *
3877 * Be sure your shader is set up according to the requirements documented in
3878 * SDL_CreateGPUShader().
3879 *
3880 * \param render_pass a render pass handle.
3881 * \param first_slot the fragment storage buffer slot to begin binding from.
3882 * \param storage_buffers an array of storage buffers.
3883 * \param num_bindings the number of storage buffers to bind from the array.
3884 *
3885 * \since This function is available since SDL 3.2.0.
3886 *
3887 * \sa SDL_CreateGPUShader
3888 */
3889extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(
3890 SDL_GPURenderPass *render_pass,
3891 Uint32 first_slot,
3892 SDL_GPUBuffer *const *storage_buffers,
3893 Uint32 num_bindings);
3894
3895/* Drawing */
3896
3897/**
3898 * Draws data using bound graphics state with an index buffer and instancing
3899 * enabled.
3900 *
3901 * You must not call this function before binding a graphics pipeline.
3902 *
3903 * Note that the `first_vertex` and `first_instance` parameters are NOT
3904 * compatible with built-in vertex/instance ID variables in shaders (for
3905 * example, SV_VertexID); GPU APIs and shader languages do not define these
3906 * built-in variables consistently, so if your shader depends on them, the
3907 * only way to keep behavior consistent and portable is to always pass 0 for
3908 * the correlating parameter in the draw calls.
3909 *
3910 * \param render_pass a render pass handle.
3911 * \param num_indices the number of indices to draw per instance.
3912 * \param num_instances the number of instances to draw.
3913 * \param first_index the starting index within the index buffer.
3914 * \param vertex_offset value added to vertex index before indexing into the
3915 * vertex buffer.
3916 * \param first_instance the ID of the first instance to draw.
3917 *
3918 * \since This function is available since SDL 3.2.0.
3919 */
3920extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives(
3921 SDL_GPURenderPass *render_pass,
3922 Uint32 num_indices,
3923 Uint32 num_instances,
3924 Uint32 first_index,
3925 Sint32 vertex_offset,
3926 Uint32 first_instance);
3927
3928/**
3929 * Draws data using bound graphics state.
3930 *
3931 * You must not call this function before binding a graphics pipeline.
3932 *
3933 * Note that the `first_vertex` and `first_instance` parameters are NOT
3934 * compatible with built-in vertex/instance ID variables in shaders (for
3935 * example, SV_VertexID); GPU APIs and shader languages do not define these
3936 * built-in variables consistently, so if your shader depends on them, the
3937 * only way to keep behavior consistent and portable is to always pass 0 for
3938 * the correlating parameter in the draw calls.
3939 *
3940 * \param render_pass a render pass handle.
3941 * \param num_vertices the number of vertices to draw.
3942 * \param num_instances the number of instances that will be drawn.
3943 * \param first_vertex the index of the first vertex to draw.
3944 * \param first_instance the ID of the first instance to draw.
3945 *
3946 * \since This function is available since SDL 3.2.0.
3947 */
3948extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives(
3949 SDL_GPURenderPass *render_pass,
3950 Uint32 num_vertices,
3951 Uint32 num_instances,
3952 Uint32 first_vertex,
3953 Uint32 first_instance);
3954
3955/**
3956 * Draws data using bound graphics state and with draw parameters set from a
3957 * buffer.
3958 *
3959 * The buffer must consist of tightly-packed draw parameter sets that each
3960 * match the layout of SDL_GPUIndirectDrawCommand. You must not call this
3961 * function before binding a graphics pipeline.
3962 *
3963 * \param render_pass a render pass handle.
3964 * \param buffer a buffer containing draw parameters.
3965 * \param offset the offset to start reading from the draw buffer.
3966 * \param draw_count the number of draw parameter sets that should be read
3967 * from the draw buffer.
3968 *
3969 * \since This function is available since SDL 3.2.0.
3970 */
3971extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect(
3972 SDL_GPURenderPass *render_pass,
3973 SDL_GPUBuffer *buffer,
3974 Uint32 offset,
3975 Uint32 draw_count);
3976
3977/**
3978 * Draws data using bound graphics state with an index buffer enabled and with
3979 * draw parameters set from a buffer.
3980 *
3981 * The buffer must consist of tightly-packed draw parameter sets that each
3982 * match the layout of SDL_GPUIndexedIndirectDrawCommand. You must not call
3983 * this function before binding a graphics pipeline.
3984 *
3985 * \param render_pass a render pass handle.
3986 * \param buffer a buffer containing draw parameters.
3987 * \param offset the offset to start reading from the draw buffer.
3988 * \param draw_count the number of draw parameter sets that should be read
3989 * from the draw buffer.
3990 *
3991 * \since This function is available since SDL 3.2.0.
3992 */
3993extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect(
3994 SDL_GPURenderPass *render_pass,
3995 SDL_GPUBuffer *buffer,
3996 Uint32 offset,
3997 Uint32 draw_count);
3998
3999/**
4000 * Ends the given render pass.
4001 *
4002 * All bound graphics state on the render pass command buffer is unset. The
4003 * render pass handle is now invalid.
4004 *
4005 * \param render_pass a render pass handle.
4006 *
4007 * \since This function is available since SDL 3.2.0.
4008 */
4009extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass(
4010 SDL_GPURenderPass *render_pass);
4011
4012/* Compute Pass */
4013
4014/**
4015 * Begins a compute pass on a command buffer.
4016 *
4017 * A compute pass is defined by a set of texture subresources and buffers that
4018 * may be written to by compute pipelines. These textures and buffers must
4019 * have been created with the COMPUTE_STORAGE_WRITE bit or the
4020 * COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE bit. If you do not create a texture
4021 * with COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE, you must not read from the
4022 * texture in the compute pass. All operations related to compute pipelines
4023 * must take place inside of a compute pass. You must not begin another
4024 * compute pass, or a render pass or copy pass before ending the compute pass.
4025 *
4026 * A VERY IMPORTANT NOTE - Reads and writes in compute passes are NOT
4027 * implicitly synchronized. This means you may cause data races by both
4028 * reading and writing a resource region in a compute pass, or by writing
4029 * multiple times to a resource region. If your compute work depends on
4030 * reading the completed output from a previous dispatch, you MUST end the
4031 * current compute pass and begin a new one before you can safely access the
4032 * data. Otherwise you will receive unexpected results. Reading and writing a
4033 * texture in the same compute pass is only supported by specific texture
4034 * formats. Make sure you check the format support!
4035 *
4036 * \param command_buffer a command buffer.
4037 * \param storage_texture_bindings an array of writeable storage texture
4038 * binding structs.
4039 * \param num_storage_texture_bindings the number of storage textures to bind
4040 * from the array.
4041 * \param storage_buffer_bindings an array of writeable storage buffer binding
4042 * structs.
4043 * \param num_storage_buffer_bindings the number of storage buffers to bind
4044 * from the array.
4045 * \returns a compute pass handle.
4046 *
4047 * \since This function is available since SDL 3.2.0.
4048 *
4049 * \sa SDL_EndGPUComputePass
4050 */
4051extern SDL_DECLSPEC SDL_GPUComputePass * SDLCALL SDL_BeginGPUComputePass(
4052 SDL_GPUCommandBuffer *command_buffer,
4053 const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings,
4054 Uint32 num_storage_texture_bindings,
4055 const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings,
4056 Uint32 num_storage_buffer_bindings);
4057
4058/**
4059 * Binds a compute pipeline on a command buffer for use in compute dispatch.
4060 *
4061 * \param compute_pass a compute pass handle.
4062 * \param compute_pipeline a compute pipeline to bind.
4063 *
4064 * \since This function is available since SDL 3.2.0.
4065 */
4066extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline(
4067 SDL_GPUComputePass *compute_pass,
4068 SDL_GPUComputePipeline *compute_pipeline);
4069
4070/**
4071 * Binds texture-sampler pairs for use on the compute shader.
4072 *
4073 * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
4074 *
4075 * The textures being bound must have a matching type declared in the shader
4076 * (2D, 3D, etc.). Multisample textures are not allowed.
4077 *
4078 * Be sure your shader is set up according to the requirements documented in
4079 * SDL_CreateGPUComputePipeline().
4080 *
4081 * \param compute_pass a compute pass handle.
4082 * \param first_slot the compute sampler slot to begin binding from.
4083 * \param texture_sampler_bindings an array of texture-sampler binding
4084 * structs.
4085 * \param num_bindings the number of texture-sampler bindings to bind from the
4086 * array.
4087 *
4088 * \since This function is available since SDL 3.2.0.
4089 *
4090 * \sa SDL_CreateGPUComputePipeline
4091 */
4092extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers(
4093 SDL_GPUComputePass *compute_pass,
4094 Uint32 first_slot,
4095 const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
4096 Uint32 num_bindings);
4097
4098/**
4099 * Binds storage textures as readonly for use on the compute pipeline.
4100 *
4101 * These textures must have been created with
4102 * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ.
4103 *
4104 * The textures being bound must have a matching type declared in the shader
4105 * (2D, 3D, 2DMS, etc.)
4106 *
4107 * Be sure your shader is set up according to the requirements documented in
4108 * SDL_CreateGPUComputePipeline().
4109 *
4110 * \param compute_pass a compute pass handle.
4111 * \param first_slot the compute storage texture slot to begin binding from.
4112 * \param storage_textures an array of storage textures.
4113 * \param num_bindings the number of storage textures to bind from the array.
4114 *
4115 * \since This function is available since SDL 3.2.0.
4116 *
4117 * \sa SDL_CreateGPUComputePipeline
4118 */
4119extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(
4120 SDL_GPUComputePass *compute_pass,
4121 Uint32 first_slot,
4122 SDL_GPUTexture *const *storage_textures,
4123 Uint32 num_bindings);
4124
4125/**
4126 * Binds storage buffers as readonly for use on the compute pipeline.
4127 *
4128 * These buffers must have been created with
4129 * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ.
4130 *
4131 * Be sure your shader is set up according to the requirements documented in
4132 * SDL_CreateGPUComputePipeline().
4133 *
4134 * \param compute_pass a compute pass handle.
4135 * \param first_slot the compute storage buffer slot to begin binding from.
4136 * \param storage_buffers an array of storage buffer binding structs.
4137 * \param num_bindings the number of storage buffers to bind from the array.
4138 *
4139 * \since This function is available since SDL 3.2.0.
4140 *
4141 * \sa SDL_CreateGPUComputePipeline
4142 */
4143extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(
4144 SDL_GPUComputePass *compute_pass,
4145 Uint32 first_slot,
4146 SDL_GPUBuffer *const *storage_buffers,
4147 Uint32 num_bindings);
4148
4149/**
4150 * Dispatches compute work.
4151 *
4152 * You must not call this function before binding a compute pipeline.
4153 *
4154 * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
4155 * the dispatches write to the same resource region as each other, there is no
4156 * guarantee of which order the writes will occur. If the write order matters,
4157 * you MUST end the compute pass and begin another one.
4158 *
4159 * \param compute_pass a compute pass handle.
4160 * \param groupcount_x number of local workgroups to dispatch in the X
4161 * dimension.
4162 * \param groupcount_y number of local workgroups to dispatch in the Y
4163 * dimension.
4164 * \param groupcount_z number of local workgroups to dispatch in the Z
4165 * dimension.
4166 *
4167 * \since This function is available since SDL 3.2.0.
4168 */
4169extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute(
4170 SDL_GPUComputePass *compute_pass,
4171 Uint32 groupcount_x,
4172 Uint32 groupcount_y,
4173 Uint32 groupcount_z);
4174
4175/**
4176 * Dispatches compute work with parameters set from a buffer.
4177 *
4178 * The buffer layout should match the layout of
4179 * SDL_GPUIndirectDispatchCommand. You must not call this function before
4180 * binding a compute pipeline.
4181 *
4182 * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
4183 * the dispatches write to the same resource region as each other, there is no
4184 * guarantee of which order the writes will occur. If the write order matters,
4185 * you MUST end the compute pass and begin another one.
4186 *
4187 * \param compute_pass a compute pass handle.
4188 * \param buffer a buffer containing dispatch parameters.
4189 * \param offset the offset to start reading from the dispatch buffer.
4190 *
4191 * \since This function is available since SDL 3.2.0.
4192 */
4193extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect(
4194 SDL_GPUComputePass *compute_pass,
4195 SDL_GPUBuffer *buffer,
4196 Uint32 offset);
4197
4198/**
4199 * Ends the current compute pass.
4200 *
4201 * All bound compute state on the command buffer is unset. The compute pass
4202 * handle is now invalid.
4203 *
4204 * \param compute_pass a compute pass handle.
4205 *
4206 * \since This function is available since SDL 3.2.0.
4207 */
4208extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(
4209 SDL_GPUComputePass *compute_pass);
4210
4211/* TransferBuffer Data */
4212
4213/**
4214 * Maps a transfer buffer into application address space.
4215 *
4216 * You must unmap the transfer buffer before encoding upload commands using
4217 * SDL_UnmapGPUTransferBuffer. The memory is owned by the graphics driver - do
4218 * NOT call SDL_free() on the returned pointer.
4219 *
4220 * \param device a GPU context.
4221 * \param transfer_buffer a transfer buffer.
4222 * \param cycle if true, cycles the transfer buffer if it is already bound.
4223 * \returns the address of the mapped transfer buffer memory, or NULL on
4224 * failure; call SDL_GetError() for more information.
4225 *
4226 * \since This function is available since SDL 3.2.0.
4227 */
4228extern SDL_DECLSPEC void * SDLCALL SDL_MapGPUTransferBuffer(
4229 SDL_GPUDevice *device,
4230 SDL_GPUTransferBuffer *transfer_buffer,
4231 bool cycle);
4232
4233/**
4234 * Unmaps a previously mapped transfer buffer.
4235 *
4236 * \param device a GPU context.
4237 * \param transfer_buffer a previously mapped transfer buffer.
4238 *
4239 * \since This function is available since SDL 3.2.0.
4240 */
4241extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer(
4242 SDL_GPUDevice *device,
4243 SDL_GPUTransferBuffer *transfer_buffer);
4244
4245/* Copy Pass */
4246
4247/**
4248 * Begins a copy pass on a command buffer.
4249 *
4250 * All operations related to copying to or from buffers or textures take place
4251 * inside a copy pass. You must not begin another copy pass, or a render pass
4252 * or compute pass before ending the copy pass.
4253 *
4254 * \param command_buffer a command buffer.
4255 * \returns a copy pass handle.
4256 *
4257 * \since This function is available since SDL 3.2.0.
4258 *
4259 * \sa SDL_EndGPUCopyPass
4260 */
4261extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass(
4262 SDL_GPUCommandBuffer *command_buffer);
4263
4264/**
4265 * Uploads data from a transfer buffer to a texture.
4266 *
4267 * The upload occurs on the GPU timeline. You may assume that the upload has
4268 * finished in subsequent commands.
4269 *
4270 * You must align the data in the transfer buffer to a multiple of the texel
4271 * size of the texture format.
4272 *
4273 * \param copy_pass a copy pass handle.
4274 * \param source the source transfer buffer with image layout information.
4275 * \param destination the destination texture region.
4276 * \param cycle if true, cycles the texture if the texture is bound, otherwise
4277 * overwrites the data.
4278 *
4279 * \since This function is available since SDL 3.2.0.
4280 */
4281extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture(
4282 SDL_GPUCopyPass *copy_pass,
4283 const SDL_GPUTextureTransferInfo *source,
4284 const SDL_GPUTextureRegion *destination,
4285 bool cycle);
4286
4287/**
4288 * Uploads data from a transfer buffer to a buffer.
4289 *
4290 * The upload occurs on the GPU timeline. You may assume that the upload has
4291 * finished in subsequent commands.
4292 *
4293 * \param copy_pass a copy pass handle.
4294 * \param source the source transfer buffer with offset.
4295 * \param destination the destination buffer with offset and size.
4296 * \param cycle if true, cycles the buffer if it is already bound, otherwise
4297 * overwrites the data.
4298 *
4299 * \since This function is available since SDL 3.2.0.
4300 */
4301extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer(
4302 SDL_GPUCopyPass *copy_pass,
4303 const SDL_GPUTransferBufferLocation *source,
4304 const SDL_GPUBufferRegion *destination,
4305 bool cycle);
4306
4307/**
4308 * Performs a texture-to-texture copy.
4309 *
4310 * This copy occurs on the GPU timeline. You may assume the copy has finished
4311 * in subsequent commands.
4312 *
4313 * This function does not support copying between depth and color textures.
4314 * For those, copy the texture to a buffer and then to the destination
4315 * texture.
4316 *
4317 * \param copy_pass a copy pass handle.
4318 * \param source a source texture region.
4319 * \param destination a destination texture region.
4320 * \param w the width of the region to copy.
4321 * \param h the height of the region to copy.
4322 * \param d the depth of the region to copy.
4323 * \param cycle if true, cycles the destination texture if the destination
4324 * texture is bound, otherwise overwrites the data.
4325 *
4326 * \since This function is available since SDL 3.2.0.
4327 */
4328extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture(
4329 SDL_GPUCopyPass *copy_pass,
4330 const SDL_GPUTextureLocation *source,
4331 const SDL_GPUTextureLocation *destination,
4332 Uint32 w,
4333 Uint32 h,
4334 Uint32 d,
4335 bool cycle);
4336
4337/**
4338 * Performs a buffer-to-buffer copy.
4339 *
4340 * This copy occurs on the GPU timeline. You may assume the copy has finished
4341 * in subsequent commands.
4342 *
4343 * \param copy_pass a copy pass handle.
4344 * \param source the buffer and offset to copy from.
4345 * \param destination the buffer and offset to copy to.
4346 * \param size the length of the buffer to copy.
4347 * \param cycle if true, cycles the destination buffer if it is already bound,
4348 * otherwise overwrites the data.
4349 *
4350 * \since This function is available since SDL 3.2.0.
4351 */
4352extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer(
4353 SDL_GPUCopyPass *copy_pass,
4354 const SDL_GPUBufferLocation *source,
4355 const SDL_GPUBufferLocation *destination,
4356 Uint32 size,
4357 bool cycle);
4358
4359/**
4360 * Copies data from a texture to a transfer buffer on the GPU timeline.
4361 *
4362 * This data is not guaranteed to be copied until the command buffer fence is
4363 * signaled.
4364 *
4365 * \param copy_pass a copy pass handle.
4366 * \param source the source texture region.
4367 * \param destination the destination transfer buffer with image layout
4368 * information.
4369 *
4370 * \since This function is available since SDL 3.2.0.
4371 */
4372extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture(
4373 SDL_GPUCopyPass *copy_pass,
4374 const SDL_GPUTextureRegion *source,
4375 const SDL_GPUTextureTransferInfo *destination);
4376
4377/**
4378 * Copies data from a buffer to a transfer buffer on the GPU timeline.
4379 *
4380 * This data is not guaranteed to be copied until the command buffer fence is
4381 * signaled.
4382 *
4383 * \param copy_pass a copy pass handle.
4384 * \param source the source buffer with offset and size.
4385 * \param destination the destination transfer buffer with offset.
4386 *
4387 * \since This function is available since SDL 3.2.0.
4388 */
4389extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer(
4390 SDL_GPUCopyPass *copy_pass,
4391 const SDL_GPUBufferRegion *source,
4392 const SDL_GPUTransferBufferLocation *destination);
4393
4394/**
4395 * Ends the current copy pass.
4396 *
4397 * \param copy_pass a copy pass handle.
4398 *
4399 * \since This function is available since SDL 3.2.0.
4400 */
4401extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass(
4402 SDL_GPUCopyPass *copy_pass);
4403
4404/**
4405 * Generates mipmaps for the given texture.
4406 *
4407 * This function must not be called inside of any pass.
4408 *
4409 * \param command_buffer a command_buffer.
4410 * \param texture a texture with more than 1 mip level.
4411 *
4412 * \since This function is available since SDL 3.2.0.
4413 */
4414extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(
4415 SDL_GPUCommandBuffer *command_buffer,
4416 SDL_GPUTexture *texture);
4417
4418/**
4419 * Blits from a source texture region to a destination texture region.
4420 *
4421 * This function must not be called inside of any pass.
4422 *
4423 * \param command_buffer a command buffer.
4424 * \param info the blit info struct containing the blit parameters.
4425 *
4426 * \since This function is available since SDL 3.2.0.
4427 */
4428extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
4429 SDL_GPUCommandBuffer *command_buffer,
4430 const SDL_GPUBlitInfo *info);
4431
4432/* Submission/Presentation */
4433
4434/**
4435 * Determines whether a swapchain composition is supported by the window.
4436 *
4437 * The window must be claimed before calling this function.
4438 *
4439 * \param device a GPU context.
4440 * \param window an SDL_Window.
4441 * \param swapchain_composition the swapchain composition to check.
4442 * \returns true if supported, false if unsupported.
4443 *
4444 * \since This function is available since SDL 3.2.0.
4445 *
4446 * \sa SDL_ClaimWindowForGPUDevice
4447 */
4448extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition(
4449 SDL_GPUDevice *device,
4451 SDL_GPUSwapchainComposition swapchain_composition);
4452
4453/**
4454 * Determines whether a presentation mode is supported by the window.
4455 *
4456 * The window must be claimed before calling this function.
4457 *
4458 * \param device a GPU context.
4459 * \param window an SDL_Window.
4460 * \param present_mode the presentation mode to check.
4461 * \returns true if supported, false if unsupported.
4462 *
4463 * \since This function is available since SDL 3.2.0.
4464 *
4465 * \sa SDL_ClaimWindowForGPUDevice
4466 */
4467extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUPresentMode(
4468 SDL_GPUDevice *device,
4470 SDL_GPUPresentMode present_mode);
4471
4472/**
4473 * Claims a window, creating a swapchain structure for it.
4474 *
4475 * This must be called before SDL_AcquireGPUSwapchainTexture is called using
4476 * the window. You should only call this function from the thread that created
4477 * the window.
4478 *
4479 * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and
4480 * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain
4481 * parameters, you must call SDL_SetGPUSwapchainParameters after claiming the
4482 * window.
4483 *
4484 * \param device a GPU context.
4485 * \param window an SDL_Window.
4486 * \returns true on success, or false on failure; call SDL_GetError() for more
4487 * information.
4488 *
4489 * \threadsafety This function should only be called from the thread that
4490 * created the window.
4491 *
4492 * \since This function is available since SDL 3.2.0.
4493 *
4494 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
4495 * \sa SDL_ReleaseWindowFromGPUDevice
4496 * \sa SDL_WindowSupportsGPUPresentMode
4497 * \sa SDL_WindowSupportsGPUSwapchainComposition
4498 */
4499extern SDL_DECLSPEC bool SDLCALL SDL_ClaimWindowForGPUDevice(
4500 SDL_GPUDevice *device,
4502
4503/**
4504 * Unclaims a window, destroying its swapchain structure.
4505 *
4506 * \param device a GPU context.
4507 * \param window an SDL_Window that has been claimed.
4508 *
4509 * \since This function is available since SDL 3.2.0.
4510 *
4511 * \sa SDL_ClaimWindowForGPUDevice
4512 */
4513extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice(
4514 SDL_GPUDevice *device,
4516
4517/**
4518 * Changes the swapchain parameters for the given claimed window.
4519 *
4520 * This function will fail if the requested present mode or swapchain
4521 * composition are unsupported by the device. Check if the parameters are
4522 * supported via SDL_WindowSupportsGPUPresentMode /
4523 * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function.
4524 *
4525 * SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR is always
4526 * supported.
4527 *
4528 * \param device a GPU context.
4529 * \param window an SDL_Window that has been claimed.
4530 * \param swapchain_composition the desired composition of the swapchain.
4531 * \param present_mode the desired present mode for the swapchain.
4532 * \returns true if successful, false on error; call SDL_GetError() for more
4533 * information.
4534 *
4535 * \since This function is available since SDL 3.2.0.
4536 *
4537 * \sa SDL_WindowSupportsGPUPresentMode
4538 * \sa SDL_WindowSupportsGPUSwapchainComposition
4539 */
4540extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUSwapchainParameters(
4541 SDL_GPUDevice *device,
4543 SDL_GPUSwapchainComposition swapchain_composition,
4544 SDL_GPUPresentMode present_mode);
4545
4546/**
4547 * Configures the maximum allowed number of frames in flight.
4548 *
4549 * The default value when the device is created is 2. This means that after
4550 * you have submitted 2 frames for presentation, if the GPU has not finished
4551 * working on the first frame, SDL_AcquireGPUSwapchainTexture() will fill the
4552 * swapchain texture pointer with NULL, and
4553 * SDL_WaitAndAcquireGPUSwapchainTexture() will block.
4554 *
4555 * Higher values increase throughput at the expense of visual latency. Lower
4556 * values decrease visual latency at the expense of throughput.
4557 *
4558 * Note that calling this function will stall and flush the command queue to
4559 * prevent synchronization issues.
4560 *
4561 * The minimum value of allowed frames in flight is 1, and the maximum is 3.
4562 *
4563 * \param device a GPU context.
4564 * \param allowed_frames_in_flight the maximum number of frames that can be
4565 * pending on the GPU.
4566 * \returns true if successful, false on error; call SDL_GetError() for more
4567 * information.
4568 *
4569 * \since This function is available since SDL 3.2.0.
4570 */
4571extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUAllowedFramesInFlight(
4572 SDL_GPUDevice *device,
4573 Uint32 allowed_frames_in_flight);
4574
4575/**
4576 * Obtains the texture format of the swapchain for the given window.
4577 *
4578 * Note that this format can change if the swapchain parameters change.
4579 *
4580 * \param device a GPU context.
4581 * \param window an SDL_Window that has been claimed.
4582 * \returns the texture format of the swapchain.
4583 *
4584 * \since This function is available since SDL 3.2.0.
4585 */
4587 SDL_GPUDevice *device,
4589
4590/**
4591 * Acquire a texture to use in presentation.
4592 *
4593 * When a swapchain texture is acquired on a command buffer, it will
4594 * automatically be submitted for presentation when the command buffer is
4595 * submitted. The swapchain texture should only be referenced by the command
4596 * buffer used to acquire it.
4597 *
4598 * If too many frames are in flight, this function will fill the swapchain
4599 * texture handle with NULL and return true. This is not an error. This NULL
4600 * pointer should not be passed back into SDL. Instead, it should be
4601 * considered as an indication to wait.
4602 *
4603 * In VSYNC present mode (which is the default) this function may block on
4604 * vblank.
4605 *
4606 * If you use this function, it is possible to create a situation where many
4607 * command buffers are allocated while the rendering context waits for the GPU
4608 * to catch up, which will cause memory usage to grow. You should use
4609 * SDL_WaitAndAcquireGPUSwapchainTexture() unless you know what you are doing
4610 * with timing.
4611 *
4612 * The swapchain texture is managed by the implementation and must not be
4613 * freed by the user. You MUST NOT call this function from any thread other
4614 * than the one that created the window.
4615 *
4616 * \param command_buffer a command buffer.
4617 * \param window a window that has been claimed.
4618 * \param swapchain_texture a pointer filled in with a swapchain texture
4619 * handle.
4620 * \param swapchain_texture_width a pointer filled in with the swapchain
4621 * texture width, may be NULL.
4622 * \param swapchain_texture_height a pointer filled in with the swapchain
4623 * texture height, may be NULL.
4624 * \returns true on success, false on error; call SDL_GetError() for more
4625 * information.
4626 *
4627 * \threadsafety This function should only be called from the thread that
4628 * created the window.
4629 *
4630 * \since This function is available since SDL 3.2.0.
4631 *
4632 * \sa SDL_ClaimWindowForGPUDevice
4633 * \sa SDL_SubmitGPUCommandBuffer
4634 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
4635 * \sa SDL_CancelGPUCommandBuffer
4636 * \sa SDL_GetWindowSizeInPixels
4637 * \sa SDL_WaitForGPUSwapchain
4638 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
4639 * \sa SDL_SetGPUAllowedFramesInFlight
4640 */
4641extern SDL_DECLSPEC bool SDLCALL SDL_AcquireGPUSwapchainTexture(
4642 SDL_GPUCommandBuffer *command_buffer,
4644 SDL_GPUTexture **swapchain_texture,
4645 Uint32 *swapchain_texture_width,
4646 Uint32 *swapchain_texture_height);
4647
4648/**
4649 * Blocks the thread until all presenting command buffers are finished
4650 * executing.
4651 *
4652 * \param device a GPU context.
4653 * \param window a window that has been claimed.
4654 * \returns true on success, false on failure; call SDL_GetError() for more
4655 * information.
4656 *
4657 * \threadsafety This function should only be called from the thread that
4658 * created the window.
4659 *
4660 * \since This function is available since SDL 3.2.0.
4661 *
4662 * \sa SDL_AcquireGPUSwapchainTexture
4663 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
4664 * \sa SDL_SetGPUAllowedFramesInFlight
4665 */
4666extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUSwapchain(
4667 SDL_GPUDevice *device,
4669
4670/**
4671 * Blocks the thread until a swapchain texture is available to be acquired,
4672 * and then acquires it.
4673 *
4674 * When a swapchain texture is acquired on a command buffer, it will
4675 * automatically be submitted for presentation when the command buffer is
4676 * submitted. The swapchain texture should only be referenced by the command
4677 * buffer used to acquire it. It is an error to call
4678 * SDL_CancelGPUCommandBuffer() after a swapchain texture is acquired.
4679 *
4680 * This function can fill the swapchain texture handle with NULL in certain
4681 * cases, for example if the window is minimized. This is not an error. You
4682 * should always make sure to check whether the pointer is NULL before
4683 * actually using it.
4684 *
4685 * The swapchain texture is managed by the implementation and must not be
4686 * freed by the user. You MUST NOT call this function from any thread other
4687 * than the one that created the window.
4688 *
4689 * The swapchain texture is write-only and cannot be used as a sampler or for
4690 * another reading operation.
4691 *
4692 * \param command_buffer a command buffer.
4693 * \param window a window that has been claimed.
4694 * \param swapchain_texture a pointer filled in with a swapchain texture
4695 * handle.
4696 * \param swapchain_texture_width a pointer filled in with the swapchain
4697 * texture width, may be NULL.
4698 * \param swapchain_texture_height a pointer filled in with the swapchain
4699 * texture height, may be NULL.
4700 * \returns true on success, false on error; call SDL_GetError() for more
4701 * information.
4702 *
4703 * \threadsafety This function should only be called from the thread that
4704 * created the window.
4705 *
4706 * \since This function is available since SDL 3.2.0.
4707 *
4708 * \sa SDL_SubmitGPUCommandBuffer
4709 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
4710 * \sa SDL_AcquireGPUSwapchainTexture
4711 */
4712extern SDL_DECLSPEC bool SDLCALL SDL_WaitAndAcquireGPUSwapchainTexture(
4713 SDL_GPUCommandBuffer *command_buffer,
4715 SDL_GPUTexture **swapchain_texture,
4716 Uint32 *swapchain_texture_width,
4717 Uint32 *swapchain_texture_height);
4718
4719/**
4720 * Submits a command buffer so its commands can be processed on the GPU.
4721 *
4722 * It is invalid to use the command buffer after this is called.
4723 *
4724 * This must be called from the thread the command buffer was acquired on.
4725 *
4726 * All commands in the submission are guaranteed to begin executing before any
4727 * command in a subsequent submission begins executing.
4728 *
4729 * \param command_buffer a command buffer.
4730 * \returns true on success, false on failure; call SDL_GetError() for more
4731 * information.
4732 *
4733 * \since This function is available since SDL 3.2.0.
4734 *
4735 * \sa SDL_AcquireGPUCommandBuffer
4736 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
4737 * \sa SDL_AcquireGPUSwapchainTexture
4738 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
4739 */
4740extern SDL_DECLSPEC bool SDLCALL SDL_SubmitGPUCommandBuffer(
4741 SDL_GPUCommandBuffer *command_buffer);
4742
4743/**
4744 * Submits a command buffer so its commands can be processed on the GPU, and
4745 * acquires a fence associated with the command buffer.
4746 *
4747 * You must release this fence when it is no longer needed or it will cause a
4748 * leak. It is invalid to use the command buffer after this is called.
4749 *
4750 * This must be called from the thread the command buffer was acquired on.
4751 *
4752 * All commands in the submission are guaranteed to begin executing before any
4753 * command in a subsequent submission begins executing.
4754 *
4755 * \param command_buffer a command buffer.
4756 * \returns a fence associated with the command buffer, or NULL on failure;
4757 * call SDL_GetError() for more information.
4758 *
4759 * \since This function is available since SDL 3.2.0.
4760 *
4761 * \sa SDL_AcquireGPUCommandBuffer
4762 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
4763 * \sa SDL_AcquireGPUSwapchainTexture
4764 * \sa SDL_SubmitGPUCommandBuffer
4765 * \sa SDL_ReleaseGPUFence
4766 */
4768 SDL_GPUCommandBuffer *command_buffer);
4769
4770/**
4771 * Cancels a command buffer.
4772 *
4773 * None of the enqueued commands are executed.
4774 *
4775 * It is an error to call this function after a swapchain texture has been
4776 * acquired.
4777 *
4778 * This must be called from the thread the command buffer was acquired on.
4779 *
4780 * You must not reference the command buffer after calling this function.
4781 *
4782 * \param command_buffer a command buffer.
4783 * \returns true on success, false on error; call SDL_GetError() for more
4784 * information.
4785 *
4786 * \since This function is available since SDL 3.2.0.
4787 *
4788 * \sa SDL_WaitAndAcquireGPUSwapchainTexture
4789 * \sa SDL_AcquireGPUCommandBuffer
4790 * \sa SDL_AcquireGPUSwapchainTexture
4791 */
4792extern SDL_DECLSPEC bool SDLCALL SDL_CancelGPUCommandBuffer(
4793 SDL_GPUCommandBuffer *command_buffer);
4794
4795/**
4796 * Blocks the thread until the GPU is completely idle.
4797 *
4798 * \param device a GPU context.
4799 * \returns true on success, false on failure; call SDL_GetError() for more
4800 * information.
4801 *
4802 * \since This function is available since SDL 3.2.0.
4803 *
4804 * \sa SDL_WaitForGPUFences
4805 */
4806extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUIdle(
4807 SDL_GPUDevice *device);
4808
4809/**
4810 * Blocks the thread until the given fences are signaled.
4811 *
4812 * \param device a GPU context.
4813 * \param wait_all if 0, wait for any fence to be signaled, if 1, wait for all
4814 * fences to be signaled.
4815 * \param fences an array of fences to wait on.
4816 * \param num_fences the number of fences in the fences array.
4817 * \returns true on success, false on failure; call SDL_GetError() for more
4818 * information.
4819 *
4820 * \since This function is available since SDL 3.2.0.
4821 *
4822 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
4823 * \sa SDL_WaitForGPUIdle
4824 */
4825extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUFences(
4826 SDL_GPUDevice *device,
4827 bool wait_all,
4828 SDL_GPUFence *const *fences,
4829 Uint32 num_fences);
4830
4831/**
4832 * Checks the status of a fence.
4833 *
4834 * \param device a GPU context.
4835 * \param fence a fence.
4836 * \returns true if the fence is signaled, false if it is not.
4837 *
4838 * \since This function is available since SDL 3.2.0.
4839 *
4840 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
4841 */
4842extern SDL_DECLSPEC bool SDLCALL SDL_QueryGPUFence(
4843 SDL_GPUDevice *device,
4844 SDL_GPUFence *fence);
4845
4846/**
4847 * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence.
4848 *
4849 * You must not reference the fence after calling this function.
4850 *
4851 * It is safe to pass NULL for `fence`, in that case this function is a no-op.
4852 *
4853 * \param device a GPU context.
4854 * \param fence a fence.
4855 *
4856 * \since This function is available since SDL 3.2.0.
4857 *
4858 * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
4859 */
4860extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence(
4861 SDL_GPUDevice *device,
4862 SDL_GPUFence *fence);
4863
4864/* Format Info */
4865
4866/**
4867 * Obtains the texel block size for a texture format.
4868 *
4869 * \param format the texture format you want to know the texel size of.
4870 * \returns the texel block size of the texture format.
4871 *
4872 * \since This function is available since SDL 3.2.0.
4873 *
4874 * \sa SDL_UploadToGPUTexture
4875 */
4876extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize(
4877 SDL_GPUTextureFormat format);
4878
4879/**
4880 * Determines whether a texture format is supported for a given type and
4881 * usage.
4882 *
4883 * \param device a GPU context.
4884 * \param format the texture format to check.
4885 * \param type the type of texture (2D, 3D, Cube).
4886 * \param usage a bitmask of all usage scenarios to check.
4887 * \returns whether the texture format is supported for this type and usage.
4888 *
4889 * \since This function is available since SDL 3.2.0.
4890 */
4891extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsFormat(
4892 SDL_GPUDevice *device,
4893 SDL_GPUTextureFormat format,
4894 SDL_GPUTextureType type,
4896
4897/**
4898 * Determines if a sample count for a texture format is supported.
4899 *
4900 * \param device a GPU context.
4901 * \param format the texture format to check.
4902 * \param sample_count the sample count to check.
4903 * \returns whether the sample count is supported for this texture format.
4904 *
4905 * \since This function is available since SDL 3.2.0.
4906 */
4907extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsSampleCount(
4908 SDL_GPUDevice *device,
4909 SDL_GPUTextureFormat format,
4910 SDL_GPUSampleCount sample_count);
4911
4912/**
4913 * Calculate the size in bytes of a texture format with dimensions.
4914 *
4915 * \param format a texture format.
4916 * \param width width in pixels.
4917 * \param height height in pixels.
4918 * \param depth_or_layer_count depth for 3D textures or layer count otherwise.
4919 * \returns the size of a texture with this format and dimensions.
4920 *
4921 * \since This function is available since SDL 3.2.0.
4922 */
4923extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize(
4924 SDL_GPUTextureFormat format,
4925 Uint32 width,
4926 Uint32 height,
4927 Uint32 depth_or_layer_count);
4928
4929/**
4930 * Get the SDL pixel format corresponding to a GPU texture format.
4931 *
4932 * \param format a texture format.
4933 * \returns the corresponding pixel format, or SDL_PIXELFORMAT_UNKNOWN if
4934 * there is no corresponding pixel format.
4935 *
4936 * \since This function is available since SDL 3.4.0.
4937 */
4939
4940/**
4941 * Get the GPU texture format corresponding to an SDL pixel format.
4942 *
4943 * \param format a pixel format.
4944 * \returns the corresponding GPU texture format, or
4945 * SDL_GPU_TEXTUREFORMAT_INVALID if there is no corresponding GPU
4946 * texture format.
4947 *
4948 * \since This function is available since SDL 3.4.0.
4949 */
4951
4952#ifdef SDL_PLATFORM_GDK
4953
4954/**
4955 * Call this to suspend GPU operation on Xbox after receiving the
4956 * SDL_EVENT_DID_ENTER_BACKGROUND event.
4957 *
4958 * Do NOT call any SDL_GPU functions after calling this function! This must
4959 * also be called before calling SDL_GDKSuspendComplete.
4960 *
4961 * This function MUST be called from the application's render thread.
4962 *
4963 * \param device a GPU context.
4964 *
4965 * \since This function is available since SDL 3.2.0.
4966 *
4967 * \sa SDL_AddEventWatch
4968 */
4969extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device);
4970
4971/**
4972 * Call this to resume GPU operation on Xbox after receiving the
4973 * SDL_EVENT_WILL_ENTER_FOREGROUND event.
4974 *
4975 * When resuming, this function MUST be called before calling any other
4976 * SDL_GPU functions.
4977 *
4978 * This function MUST be called from the application's render thread.
4979 *
4980 * \param device a GPU context.
4981 *
4982 * \since This function is available since SDL 3.2.0.
4983 *
4984 * \sa SDL_AddEventWatch
4985 */
4986extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device);
4987
4988#endif /* SDL_PLATFORM_GDK */
4989
4990#ifdef __cplusplus
4991}
4992#endif /* __cplusplus */
4993#include <SDL3/SDL_close_code.h>
4994
4995#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:1171
@ SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE
Definition SDL_gpu.h:1172
@ SDL_GPU_FRONTFACE_CLOCKWISE
Definition SDL_gpu.h:1173
SDL_GPUDevice * SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
SDL_GPUVertexInputRate
Definition SDL_gpu.h:1130
@ SDL_GPU_VERTEXINPUTRATE_INSTANCE
Definition SDL_gpu.h:1132
@ SDL_GPU_VERTEXINPUTRATE_VERTEX
Definition SDL_gpu.h:1131
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:1143
@ SDL_GPU_FILLMODE_FILL
Definition SDL_gpu.h:1144
@ SDL_GPU_FILLMODE_LINE
Definition SDL_gpu.h:1145
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:1250
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
Definition SDL_gpu.h:1259
@ SDL_GPU_BLENDFACTOR_CONSTANT_COLOR
Definition SDL_gpu.h:1262
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR
Definition SDL_gpu.h:1257
@ SDL_GPU_BLENDFACTOR_INVALID
Definition SDL_gpu.h:1251
@ SDL_GPU_BLENDFACTOR_DST_ALPHA
Definition SDL_gpu.h:1260
@ SDL_GPU_BLENDFACTOR_ZERO
Definition SDL_gpu.h:1252
@ SDL_GPU_BLENDFACTOR_DST_COLOR
Definition SDL_gpu.h:1256
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA
Definition SDL_gpu.h:1261
@ SDL_GPU_BLENDFACTOR_SRC_ALPHA
Definition SDL_gpu.h:1258
@ SDL_GPU_BLENDFACTOR_SRC_COLOR
Definition SDL_gpu.h:1254
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR
Definition SDL_gpu.h:1255
@ SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE
Definition SDL_gpu.h:1264
@ SDL_GPU_BLENDFACTOR_ONE
Definition SDL_gpu.h:1253
@ SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR
Definition SDL_gpu.h:1263
const char * SDL_GetGPUDriver(int index)
SDL_GPUCullMode
Definition SDL_gpu.h:1156
@ SDL_GPU_CULLMODE_FRONT
Definition SDL_gpu.h:1158
@ SDL_GPU_CULLMODE_NONE
Definition SDL_gpu.h:1157
@ SDL_GPU_CULLMODE_BACK
Definition SDL_gpu.h:1159
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:1302
@ SDL_GPU_SAMPLERMIPMAPMODE_NEAREST
Definition SDL_gpu.h:1303
@ SDL_GPU_SAMPLERMIPMAPMODE_LINEAR
Definition SDL_gpu.h:1304
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:1205
@ SDL_GPU_STENCILOP_DECREMENT_AND_WRAP
Definition SDL_gpu.h:1214
@ SDL_GPU_STENCILOP_ZERO
Definition SDL_gpu.h:1208
@ SDL_GPU_STENCILOP_KEEP
Definition SDL_gpu.h:1207
@ SDL_GPU_STENCILOP_INVERT
Definition SDL_gpu.h:1212
@ SDL_GPU_STENCILOP_REPLACE
Definition SDL_gpu.h:1209
@ SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP
Definition SDL_gpu.h:1211
@ SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP
Definition SDL_gpu.h:1210
@ SDL_GPU_STENCILOP_INCREMENT_AND_WRAP
Definition SDL_gpu.h:1213
@ SDL_GPU_STENCILOP_INVALID
Definition SDL_gpu.h:1206
struct SDL_GPUFence SDL_GPUFence
Definition SDL_gpu.h:601
Uint32 SDL_GPUTextureFormatTexelBlockSize(SDL_GPUTextureFormat format)
SDL_GPUBlendOp
Definition SDL_gpu.h:1229
@ SDL_GPU_BLENDOP_MIN
Definition SDL_gpu.h:1234
@ SDL_GPU_BLENDOP_INVALID
Definition SDL_gpu.h:1230
@ SDL_GPU_BLENDOP_MAX
Definition SDL_gpu.h:1235
@ SDL_GPU_BLENDOP_REVERSE_SUBTRACT
Definition SDL_gpu.h:1233
@ SDL_GPU_BLENDOP_SUBTRACT
Definition SDL_gpu.h:1232
@ SDL_GPU_BLENDOP_ADD
Definition SDL_gpu.h:1231
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:1274
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_R10G10B10A2_UNORM
Definition SDL_gpu.h:1119
@ 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:1348
@ SDL_GPU_PRESENTMODE_VSYNC
Definition SDL_gpu.h:1349
@ SDL_GPU_PRESENTMODE_IMMEDIATE
Definition SDL_gpu.h:1350
@ SDL_GPU_PRESENTMODE_MAILBOX
Definition SDL_gpu.h:1351
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:1184
@ SDL_GPU_COMPAREOP_NEVER
Definition SDL_gpu.h:1186
@ SDL_GPU_COMPAREOP_INVALID
Definition SDL_gpu.h:1185
@ SDL_GPU_COMPAREOP_GREATER
Definition SDL_gpu.h:1190
@ SDL_GPU_COMPAREOP_LESS
Definition SDL_gpu.h:1187
@ SDL_GPU_COMPAREOP_GREATER_OR_EQUAL
Definition SDL_gpu.h:1192
@ SDL_GPU_COMPAREOP_ALWAYS
Definition SDL_gpu.h:1193
@ SDL_GPU_COMPAREOP_LESS_OR_EQUAL
Definition SDL_gpu.h:1189
@ SDL_GPU_COMPAREOP_NOT_EQUAL
Definition SDL_gpu.h:1191
@ SDL_GPU_COMPAREOP_EQUAL
Definition SDL_gpu.h:1188
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:1289
@ SDL_GPU_FILTER_NEAREST
Definition SDL_gpu.h:1290
@ SDL_GPU_FILTER_LINEAR
Definition SDL_gpu.h:1291
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:1381
@ SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2084
Definition SDL_gpu.h:1385
@ SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR
Definition SDL_gpu.h:1383
@ SDL_GPU_SWAPCHAINCOMPOSITION_SDR
Definition SDL_gpu.h:1382
@ SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR
Definition SDL_gpu.h:1384
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:1316
@ SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT
Definition SDL_gpu.h:1318
@ SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE
Definition SDL_gpu.h:1319
@ SDL_GPU_SAMPLERADDRESSMODE_REPEAT
Definition SDL_gpu.h:1317
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:551
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:2144
SDL_FColor clear_color
Definition SDL_gpu.h:2143
SDL_GPUFilter filter
Definition SDL_gpu.h:2145
SDL_GPUBlitRegion source
Definition SDL_gpu.h:2140
SDL_GPUBlitRegion destination
Definition SDL_gpu.h:2141
SDL_GPULoadOp load_op
Definition SDL_gpu.h:2142
SDL_GPUTexture * texture
Definition SDL_gpu.h:1509
Uint32 layer_or_depth_plane
Definition SDL_gpu.h:1511
SDL_GPUBuffer * buffer
Definition SDL_gpu.h:2164
SDL_PropertiesID props
Definition SDL_gpu.h:1823
SDL_GPUBufferUsageFlags usage
Definition SDL_gpu.h:1820
SDL_GPUBuffer * buffer
Definition SDL_gpu.h:1529
SDL_GPUBuffer * buffer
Definition SDL_gpu.h:1545
SDL_GPUBlendOp color_blend_op
Definition SDL_gpu.h:1742
SDL_GPUColorComponentFlags color_write_mask
Definition SDL_gpu.h:1746
SDL_GPUBlendFactor src_alpha_blendfactor
Definition SDL_gpu.h:1743
SDL_GPUBlendOp alpha_blend_op
Definition SDL_gpu.h:1745
SDL_GPUBlendFactor dst_alpha_blendfactor
Definition SDL_gpu.h:1744
SDL_GPUBlendFactor src_color_blendfactor
Definition SDL_gpu.h:1740
SDL_GPUBlendFactor dst_color_blendfactor
Definition SDL_gpu.h:1741
SDL_GPUColorTargetBlendState blend_state
Definition SDL_gpu.h:1934
SDL_GPUTextureFormat format
Definition SDL_gpu.h:1933
SDL_FColor clear_color
Definition SDL_gpu.h:2054
SDL_GPUTexture * texture
Definition SDL_gpu.h:2051
SDL_GPULoadOp load_op
Definition SDL_gpu.h:2055
SDL_GPUTexture * resolve_texture
Definition SDL_gpu.h:2057
SDL_GPUStoreOp store_op
Definition SDL_gpu.h:2056
SDL_GPUShaderFormat format
Definition SDL_gpu.h:1999
SDL_GPUStencilOpState back_stencil_state
Definition SDL_gpu.h:1909
SDL_GPUCompareOp compare_op
Definition SDL_gpu.h:1908
SDL_GPUStencilOpState front_stencil_state
Definition SDL_gpu.h:1910
SDL_GPUTexture * texture
Definition SDL_gpu.h:2115
SDL_GPUStoreOp stencil_store_op
Definition SDL_gpu.h:2120
SDL_GPULoadOp stencil_load_op
Definition SDL_gpu.h:2119
SDL_GPUMultisampleState multisample_state
Definition SDL_gpu.h:1979
SDL_GPUPrimitiveType primitive_type
Definition SDL_gpu.h:1977
SDL_GPUDepthStencilState depth_stencil_state
Definition SDL_gpu.h:1980
SDL_GPUGraphicsPipelineTargetInfo target_info
Definition SDL_gpu.h:1981
SDL_GPUVertexInputState vertex_input_state
Definition SDL_gpu.h:1976
SDL_GPURasterizerState rasterizer_state
Definition SDL_gpu.h:1978
SDL_GPUTextureFormat depth_stencil_format
Definition SDL_gpu.h:1951
const SDL_GPUColorTargetDescription * color_target_descriptions
Definition SDL_gpu.h:1949
SDL_GPUSampleCount sample_count
Definition SDL_gpu.h:1888
SDL_GPUFrontFace front_face
Definition SDL_gpu.h:1867
SDL_GPUCullMode cull_mode
Definition SDL_gpu.h:1866
float depth_bias_constant_factor
Definition SDL_gpu.h:1868
SDL_GPUFillMode fill_mode
Definition SDL_gpu.h:1865
SDL_GPUFilter mag_filter
Definition SDL_gpu.h:1628
SDL_GPUSamplerAddressMode address_mode_u
Definition SDL_gpu.h:1630
SDL_GPUSamplerMipmapMode mipmap_mode
Definition SDL_gpu.h:1629
SDL_GPUSamplerAddressMode address_mode_v
Definition SDL_gpu.h:1631
SDL_GPUSamplerAddressMode address_mode_w
Definition SDL_gpu.h:1632
SDL_GPUFilter min_filter
Definition SDL_gpu.h:1627
SDL_PropertiesID props
Definition SDL_gpu.h:1643
SDL_GPUCompareOp compare_op
Definition SDL_gpu.h:1635
SDL_PropertiesID props
Definition SDL_gpu.h:1775
SDL_GPUShaderFormat format
Definition SDL_gpu.h:1768
const Uint8 * code
Definition SDL_gpu.h:1766
const char * entrypoint
Definition SDL_gpu.h:1767
SDL_GPUShaderStage stage
Definition SDL_gpu.h:1769
SDL_GPUStencilOp fail_op
Definition SDL_gpu.h:1721
SDL_GPUStencilOp depth_fail_op
Definition SDL_gpu.h:1723
SDL_GPUStencilOp pass_op
Definition SDL_gpu.h:1722
SDL_GPUCompareOp compare_op
Definition SDL_gpu.h:1724
SDL_PropertiesID props
Definition SDL_gpu.h:1804
SDL_GPUTextureUsageFlags usage
Definition SDL_gpu.h:1797
SDL_GPUTextureFormat format
Definition SDL_gpu.h:1796
SDL_GPUTextureType type
Definition SDL_gpu.h:1795
SDL_GPUSampleCount sample_count
Definition SDL_gpu.h:1802
SDL_GPUTexture * texture
Definition SDL_gpu.h:1466
SDL_GPUTexture * texture
Definition SDL_gpu.h:1488
SDL_GPUSampler * sampler
Definition SDL_gpu.h:2181
SDL_GPUTexture * texture
Definition SDL_gpu.h:2180
SDL_GPUTransferBuffer * transfer_buffer
Definition SDL_gpu.h:1431
SDL_GPUTransferBufferUsage usage
Definition SDL_gpu.h:1836
SDL_GPUTransferBuffer * transfer_buffer
Definition SDL_gpu.h:1450
SDL_GPUVertexElementFormat format
Definition SDL_gpu.h:1688
SDL_GPUVertexInputRate input_rate
Definition SDL_gpu.h:1668
const SDL_GPUVertexAttribute * vertex_attributes
Definition SDL_gpu.h:1706
const SDL_GPUVertexBufferDescription * vertex_buffer_descriptions
Definition SDL_gpu.h:1704
void * vulkan_10_physical_device_features
Definition SDL_gpu.h:2457
Uint32 instance_extension_count
Definition SDL_gpu.h:2460
Uint32 vulkan_api_version
Definition SDL_gpu.h:2455
const char ** device_extension_names
Definition SDL_gpu.h:2459
Uint32 device_extension_count
Definition SDL_gpu.h:2458
const char ** instance_extension_names
Definition SDL_gpu.h:2461