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