ruby2d 0.12.0 → 1.0.0

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