2
0

SDL_gpu.h 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* WIKI CATEGORY: GPU */
  19. /**
  20. * # CategoryGPU
  21. *
  22. * Include file for SDL GPU API functions
  23. */
  24. #ifndef SDL_GPU_H
  25. #define SDL_GPU_H
  26. #include <SDL3/SDL_stdinc.h>
  27. #include <SDL3/SDL_pixels.h>
  28. #include <SDL3/SDL_properties.h>
  29. #include <SDL3/SDL_rect.h>
  30. #include <SDL3/SDL_surface.h>
  31. #include <SDL3/SDL_video.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif /* __cplusplus */
  35. /* Type Declarations */
  36. typedef struct SDL_GPUDevice SDL_GPUDevice;
  37. typedef struct SDL_GPUBuffer SDL_GPUBuffer;
  38. typedef struct SDL_GPUTransferBuffer SDL_GPUTransferBuffer;
  39. typedef struct SDL_GPUTexture SDL_GPUTexture;
  40. typedef struct SDL_GPUSampler SDL_GPUSampler;
  41. typedef struct SDL_GPUShader SDL_GPUShader;
  42. typedef struct SDL_GPUComputePipeline SDL_GPUComputePipeline;
  43. typedef struct SDL_GPUGraphicsPipeline SDL_GPUGraphicsPipeline;
  44. typedef struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer;
  45. typedef struct SDL_GPURenderPass SDL_GPURenderPass;
  46. typedef struct SDL_GPUComputePass SDL_GPUComputePass;
  47. typedef struct SDL_GPUCopyPass SDL_GPUCopyPass;
  48. typedef struct SDL_GPUFence SDL_GPUFence;
  49. typedef enum SDL_GPUPrimitiveType
  50. {
  51. SDL_GPU_PRIMITIVETYPE_POINTLIST,
  52. SDL_GPU_PRIMITIVETYPE_LINELIST,
  53. SDL_GPU_PRIMITIVETYPE_LINESTRIP,
  54. SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
  55. SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP
  56. } SDL_GPUPrimitiveType;
  57. typedef enum SDL_GPULoadOp
  58. {
  59. SDL_GPU_LOADOP_LOAD,
  60. SDL_GPU_LOADOP_CLEAR,
  61. SDL_GPU_LOADOP_DONT_CARE
  62. } SDL_GPULoadOp;
  63. typedef enum SDL_GPUStoreOp
  64. {
  65. SDL_GPU_STOREOP_STORE,
  66. SDL_GPU_STOREOP_DONT_CARE
  67. } SDL_GPUStoreOp;
  68. typedef enum SDL_GPUIndexElementSize
  69. {
  70. SDL_GPU_INDEXELEMENTSIZE_16BIT,
  71. SDL_GPU_INDEXELEMENTSIZE_32BIT
  72. } SDL_GPUIndexElementSize;
  73. /* Texture format support varies depending on driver, hardware, and usage flags.
  74. * In general, you should use SDL_GPUTextureSupportsFormat to query if a format
  75. * is supported before using it. However, there are a few guaranteed formats.
  76. *
  77. * For SAMPLER usage, the following formats are universally supported:
  78. * - R8G8B8A8_UNORM
  79. * - B8G8R8A8_UNORM
  80. * - R8_UNORM
  81. * - R8G8_SNORM
  82. * - R8G8B8A8_SNORM
  83. * - R16_FLOAT
  84. * - R16G16_FLOAT
  85. * - R16G16B16A16_FLOAT
  86. * - R32_FLOAT
  87. * - R32G32_FLOAT
  88. * - R32G32B32A32_FLOAT
  89. * - R8G8B8A8_UNORM_SRGB
  90. * - B8G8R8A8_UNORM_SRGB
  91. * - D16_UNORM
  92. *
  93. * For COLOR_TARGET usage, the following formats are universally supported:
  94. * - R8G8B8A8_UNORM
  95. * - B8G8R8A8_UNORM
  96. * - R8_UNORM
  97. * - R16_FLOAT
  98. * - R16G16_FLOAT
  99. * - R16G16B16A16_FLOAT
  100. * - R32_FLOAT
  101. * - R32G32_FLOAT
  102. * - R32G32B32A32_FLOAT
  103. * - R8_UINT
  104. * - R8G8_UINT
  105. * - R8G8B8A8_UINT
  106. * - R16_UINT
  107. * - R16G16_UINT
  108. * - R16G16B16A16_UINT
  109. * - R8G8B8A8_UNORM_SRGB
  110. * - B8G8R8A8_UNORM_SRGB
  111. *
  112. * For STORAGE usages, the following formats are universally supported:
  113. * - R8G8B8A8_UNORM
  114. * - R8G8B8A8_SNORM
  115. * - R16G16B16A16_FLOAT
  116. * - R32_FLOAT
  117. * - R32G32_FLOAT
  118. * - R32G32B32A32_FLOAT
  119. * - R8_UINT
  120. * - R8G8_UINT
  121. * - R8G8B8A8_UINT
  122. * - R16_UINT
  123. * - R16G16_UINT
  124. * - R16G16B16A16_UINT
  125. *
  126. * For DEPTH_STENCIL_TARGET usage, the following formats are universally supported:
  127. * - D16_UNORM
  128. * - Either (but not necessarily both!) D24_UNORM or D32_SFLOAT
  129. * - Either (but not necessarily both!) D24_UNORM_S8_UINT or D32_SFLOAT_S8_UINT
  130. *
  131. * Unless D16_UNORM is sufficient for your purposes, always check which
  132. * of D24/D32 is supported before creating a depth-stencil texture!
  133. */
  134. typedef enum SDL_GPUTextureFormat
  135. {
  136. SDL_GPU_TEXTUREFORMAT_INVALID = -1,
  137. /* Unsigned Normalized Float Color Formats */
  138. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
  139. SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM,
  140. SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM,
  141. SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM,
  142. SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM,
  143. SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM,
  144. SDL_GPU_TEXTUREFORMAT_R16G16_UNORM,
  145. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM,
  146. SDL_GPU_TEXTUREFORMAT_R8_UNORM,
  147. SDL_GPU_TEXTUREFORMAT_A8_UNORM,
  148. /* Compressed Unsigned Normalized Float Color Formats */
  149. SDL_GPU_TEXTUREFORMAT_BC1_UNORM,
  150. SDL_GPU_TEXTUREFORMAT_BC2_UNORM,
  151. SDL_GPU_TEXTUREFORMAT_BC3_UNORM,
  152. SDL_GPU_TEXTUREFORMAT_BC7_UNORM,
  153. /* Signed Normalized Float Color Formats */
  154. SDL_GPU_TEXTUREFORMAT_R8G8_SNORM,
  155. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM,
  156. /* Signed Float Color Formats */
  157. SDL_GPU_TEXTUREFORMAT_R16_FLOAT,
  158. SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT,
  159. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT,
  160. SDL_GPU_TEXTUREFORMAT_R32_FLOAT,
  161. SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT,
  162. SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT,
  163. /* Unsigned Integer Color Formats */
  164. SDL_GPU_TEXTUREFORMAT_R8_UINT,
  165. SDL_GPU_TEXTUREFORMAT_R8G8_UINT,
  166. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT,
  167. SDL_GPU_TEXTUREFORMAT_R16_UINT,
  168. SDL_GPU_TEXTUREFORMAT_R16G16_UINT,
  169. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT,
  170. /* SRGB Unsigned Normalized Color Formats */
  171. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB,
  172. SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB,
  173. /* Compressed SRGB Unsigned Normalized Color Formats */
  174. SDL_GPU_TEXTUREFORMAT_BC3_UNORM_SRGB,
  175. SDL_GPU_TEXTUREFORMAT_BC7_UNORM_SRGB,
  176. /* Depth Formats */
  177. SDL_GPU_TEXTUREFORMAT_D16_UNORM,
  178. SDL_GPU_TEXTUREFORMAT_D24_UNORM,
  179. SDL_GPU_TEXTUREFORMAT_D32_FLOAT,
  180. SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT,
  181. SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT
  182. } SDL_GPUTextureFormat;
  183. typedef enum SDL_GPUTextureUsageFlagBits
  184. {
  185. SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT = 0x00000001,
  186. SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT = 0x00000002,
  187. SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET_BIT = 0x00000004,
  188. SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ_BIT = 0x00000008,
  189. SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ_BIT = 0x00000020,
  190. SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE_BIT = 0x00000040
  191. } SDL_GPUTextureUsageFlagBits;
  192. typedef Uint32 SDL_GPUTextureUsageFlags;
  193. typedef enum SDL_GPUTextureType
  194. {
  195. SDL_GPU_TEXTURETYPE_2D,
  196. SDL_GPU_TEXTURETYPE_2D_ARRAY,
  197. SDL_GPU_TEXTURETYPE_3D,
  198. SDL_GPU_TEXTURETYPE_CUBE
  199. } SDL_GPUTextureType;
  200. typedef enum SDL_GPUSampleCount
  201. {
  202. SDL_GPU_SAMPLECOUNT_1,
  203. SDL_GPU_SAMPLECOUNT_2,
  204. SDL_GPU_SAMPLECOUNT_4,
  205. SDL_GPU_SAMPLECOUNT_8
  206. } SDL_GPUSampleCount;
  207. typedef enum SDL_GPUCubeMapFace
  208. {
  209. SDL_GPU_CUBEMAPFACE_POSITIVEX,
  210. SDL_GPU_CUBEMAPFACE_NEGATIVEX,
  211. SDL_GPU_CUBEMAPFACE_POSITIVEY,
  212. SDL_GPU_CUBEMAPFACE_NEGATIVEY,
  213. SDL_GPU_CUBEMAPFACE_POSITIVEZ,
  214. SDL_GPU_CUBEMAPFACE_NEGATIVEZ
  215. } SDL_GPUCubeMapFace;
  216. typedef enum SDL_GPUBufferUsageFlagBits
  217. {
  218. SDL_GPU_BUFFERUSAGE_VERTEX_BIT = 0x00000001,
  219. SDL_GPU_BUFFERUSAGE_INDEX_BIT = 0x00000002,
  220. SDL_GPU_BUFFERUSAGE_INDIRECT_BIT = 0x00000004,
  221. SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ_BIT = 0x00000008,
  222. SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ_BIT = 0x00000020,
  223. SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE_BIT = 0x00000040
  224. } SDL_GPUBufferUsageFlagBits;
  225. typedef Uint32 SDL_GPUBufferUsageFlags;
  226. typedef enum SDL_GPUTransferBufferUsage
  227. {
  228. SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
  229. SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
  230. } SDL_GPUTransferBufferUsage;
  231. typedef enum SDL_GPUShaderStage
  232. {
  233. SDL_GPU_SHADERSTAGE_VERTEX,
  234. SDL_GPU_SHADERSTAGE_FRAGMENT
  235. } SDL_GPUShaderStage;
  236. typedef enum SDL_GPUShaderFormatFlagBits
  237. {
  238. SDL_GPU_SHADERFORMAT_INVALID = 0x00000000,
  239. SDL_GPU_SHADERFORMAT_SECRET = 0x00000001, /* NDA'd platforms */
  240. SDL_GPU_SHADERFORMAT_SPIRV = 0x00000002, /* Vulkan */
  241. SDL_GPU_SHADERFORMAT_DXBC = 0x00000004, /* D3D11 (Shader Model 5_0) */
  242. SDL_GPU_SHADERFORMAT_DXIL = 0x00000008, /* D3D12 */
  243. SDL_GPU_SHADERFORMAT_MSL = 0x00000010, /* Metal */
  244. SDL_GPU_SHADERFORMAT_METALLIB = 0x00000020, /* Metal */
  245. } SDL_GPUShaderFormatFlagBits;
  246. typedef Uint32 SDL_GPUShaderFormat;
  247. typedef enum SDL_GPUVertexElementFormat
  248. {
  249. /* 32-bit Signed Integers */
  250. SDL_GPU_VERTEXELEMENTFORMAT_INT,
  251. SDL_GPU_VERTEXELEMENTFORMAT_INT2,
  252. SDL_GPU_VERTEXELEMENTFORMAT_INT3,
  253. SDL_GPU_VERTEXELEMENTFORMAT_INT4,
  254. /* 32-bit Unsigned Integers */
  255. SDL_GPU_VERTEXELEMENTFORMAT_UINT,
  256. SDL_GPU_VERTEXELEMENTFORMAT_UINT2,
  257. SDL_GPU_VERTEXELEMENTFORMAT_UINT3,
  258. SDL_GPU_VERTEXELEMENTFORMAT_UINT4,
  259. /* 32-bit Floats */
  260. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT,
  261. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
  262. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
  263. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4,
  264. /* 8-bit Signed Integers */
  265. SDL_GPU_VERTEXELEMENTFORMAT_BYTE2,
  266. SDL_GPU_VERTEXELEMENTFORMAT_BYTE4,
  267. /* 8-bit Unsigned Integers */
  268. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2,
  269. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4,
  270. /* 8-bit Signed Normalized */
  271. SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM,
  272. SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM,
  273. /* 8-bit Unsigned Normalized */
  274. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM,
  275. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM,
  276. /* 16-bit Signed Integers */
  277. SDL_GPU_VERTEXELEMENTFORMAT_SHORT2,
  278. SDL_GPU_VERTEXELEMENTFORMAT_SHORT4,
  279. /* 16-bit Unsigned Integers */
  280. SDL_GPU_VERTEXELEMENTFORMAT_USHORT2,
  281. SDL_GPU_VERTEXELEMENTFORMAT_USHORT4,
  282. /* 16-bit Signed Normalized */
  283. SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM,
  284. SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM,
  285. /* 16-bit Unsigned Normalized */
  286. SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM,
  287. SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM,
  288. /* 16-bit Floats */
  289. SDL_GPU_VERTEXELEMENTFORMAT_HALF2,
  290. SDL_GPU_VERTEXELEMENTFORMAT_HALF4
  291. } SDL_GPUVertexElementFormat;
  292. typedef enum SDL_GPUVertexInputRate
  293. {
  294. SDL_GPU_VERTEXINPUTRATE_VERTEX = 0,
  295. SDL_GPU_VERTEXINPUTRATE_INSTANCE = 1
  296. } SDL_GPUVertexInputRate;
  297. typedef enum SDL_GPUFillMode
  298. {
  299. SDL_GPU_FILLMODE_FILL,
  300. SDL_GPU_FILLMODE_LINE
  301. } SDL_GPUFillMode;
  302. typedef enum SDL_GPUCullMode
  303. {
  304. SDL_GPU_CULLMODE_NONE,
  305. SDL_GPU_CULLMODE_FRONT,
  306. SDL_GPU_CULLMODE_BACK
  307. } SDL_GPUCullMode;
  308. typedef enum SDL_GPUFrontFace
  309. {
  310. SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE,
  311. SDL_GPU_FRONTFACE_CLOCKWISE
  312. } SDL_GPUFrontFace;
  313. typedef enum SDL_GPUCompareOp
  314. {
  315. SDL_GPU_COMPAREOP_NEVER,
  316. SDL_GPU_COMPAREOP_LESS,
  317. SDL_GPU_COMPAREOP_EQUAL,
  318. SDL_GPU_COMPAREOP_LESS_OR_EQUAL,
  319. SDL_GPU_COMPAREOP_GREATER,
  320. SDL_GPU_COMPAREOP_NOT_EQUAL,
  321. SDL_GPU_COMPAREOP_GREATER_OR_EQUAL,
  322. SDL_GPU_COMPAREOP_ALWAYS
  323. } SDL_GPUCompareOp;
  324. typedef enum SDL_GPUStencilOp
  325. {
  326. SDL_GPU_STENCILOP_KEEP,
  327. SDL_GPU_STENCILOP_ZERO,
  328. SDL_GPU_STENCILOP_REPLACE,
  329. SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP,
  330. SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP,
  331. SDL_GPU_STENCILOP_INVERT,
  332. SDL_GPU_STENCILOP_INCREMENT_AND_WRAP,
  333. SDL_GPU_STENCILOP_DECREMENT_AND_WRAP
  334. } SDL_GPUStencilOp;
  335. typedef enum SDL_GPUBlendOp
  336. {
  337. SDL_GPU_BLENDOP_ADD,
  338. SDL_GPU_BLENDOP_SUBTRACT,
  339. SDL_GPU_BLENDOP_REVERSE_SUBTRACT,
  340. SDL_GPU_BLENDOP_MIN,
  341. SDL_GPU_BLENDOP_MAX
  342. } SDL_GPUBlendOp;
  343. typedef enum SDL_GPUBlendFactor
  344. {
  345. SDL_GPU_BLENDFACTOR_ZERO,
  346. SDL_GPU_BLENDFACTOR_ONE,
  347. SDL_GPU_BLENDFACTOR_SRC_COLOR,
  348. SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR,
  349. SDL_GPU_BLENDFACTOR_DST_COLOR,
  350. SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR,
  351. SDL_GPU_BLENDFACTOR_SRC_ALPHA,
  352. SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
  353. SDL_GPU_BLENDFACTOR_DST_ALPHA,
  354. SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA,
  355. SDL_GPU_BLENDFACTOR_CONSTANT_COLOR,
  356. SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR,
  357. SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE
  358. } SDL_GPUBlendFactor;
  359. typedef enum SDL_GPUColorComponentFlagBits
  360. {
  361. SDL_GPU_COLORCOMPONENT_R_BIT = 0x00000001,
  362. SDL_GPU_COLORCOMPONENT_G_BIT = 0x00000002,
  363. SDL_GPU_COLORCOMPONENT_B_BIT = 0x00000004,
  364. SDL_GPU_COLORCOMPONENT_A_BIT = 0x00000008
  365. } SDL_GPUColorComponentFlagBits;
  366. typedef Uint8 SDL_GPUColorComponentFlags;
  367. typedef enum SDL_GPUFilter
  368. {
  369. SDL_GPU_FILTER_NEAREST,
  370. SDL_GPU_FILTER_LINEAR
  371. } SDL_GPUFilter;
  372. typedef enum SDL_GPUSamplerMipmapMode
  373. {
  374. SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
  375. SDL_GPU_SAMPLERMIPMAPMODE_LINEAR
  376. } SDL_GPUSamplerMipmapMode;
  377. typedef enum SDL_GPUSamplerAddressMode
  378. {
  379. SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
  380. SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT,
  381. SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE
  382. } SDL_GPUSamplerAddressMode;
  383. /*
  384. * VSYNC:
  385. * Waits for vblank before presenting.
  386. * If there is a pending image to present, the new image is enqueued for presentation.
  387. * Disallows tearing at the cost of visual latency.
  388. * When using this present mode, AcquireSwapchainTexture will block if too many frames are in flight.
  389. * IMMEDIATE:
  390. * Immediately presents.
  391. * Lowest latency option, but tearing may occur.
  392. * When using this mode, AcquireSwapchainTexture will return NULL if too many frames are in flight.
  393. * MAILBOX:
  394. * Waits for vblank before presenting. No tearing is possible.
  395. * If there is a pending image to present, the pending image is replaced by the new image.
  396. * Similar to VSYNC, but with reduced visual latency.
  397. * When using this mode, AcquireSwapchainTexture will return NULL if too many frames are in flight.
  398. */
  399. typedef enum SDL_GPUPresentMode
  400. {
  401. SDL_GPU_PRESENTMODE_VSYNC,
  402. SDL_GPU_PRESENTMODE_IMMEDIATE,
  403. SDL_GPU_PRESENTMODE_MAILBOX
  404. } SDL_GPUPresentMode;
  405. /*
  406. * SDR:
  407. * B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in nonlinear sRGB encoding. Blends raw pixel values.
  408. * SDR_LINEAR:
  409. * B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are in nonlinear sRGB encoding. Blends in linear space.
  410. * HDR_EXTENDED_LINEAR:
  411. * R16G16B16A16_SFLOAT swapchain. Pixel values are in extended linear encoding. Blends in linear space.
  412. * HDR10_ST2048:
  413. * A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in PQ ST2048 encoding. Blends raw pixel values. (TODO: verify this)
  414. */
  415. typedef enum SDL_GPUSwapchainComposition
  416. {
  417. SDL_GPU_SWAPCHAINCOMPOSITION_SDR,
  418. SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR,
  419. SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR,
  420. SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048
  421. } SDL_GPUSwapchainComposition;
  422. typedef enum SDL_GPUDriver
  423. {
  424. SDL_GPU_DRIVER_INVALID = -1,
  425. SDL_GPU_DRIVER_SECRET, /* NDA'd platforms */
  426. SDL_GPU_DRIVER_VULKAN,
  427. SDL_GPU_DRIVER_D3D11,
  428. SDL_GPU_DRIVER_D3D12,
  429. SDL_GPU_DRIVER_METAL
  430. } SDL_GPUDriver;
  431. /* Structures */
  432. typedef struct SDL_GPUDepthStencilValue
  433. {
  434. float depth;
  435. Uint8 stencil;
  436. } SDL_GPUDepthStencilValue;
  437. typedef struct SDL_GPUViewport
  438. {
  439. float x;
  440. float y;
  441. float w;
  442. float h;
  443. float minDepth;
  444. float maxDepth;
  445. } SDL_GPUViewport;
  446. typedef struct SDL_GPUTextureTransferInfo
  447. {
  448. SDL_GPUTransferBuffer *transferBuffer;
  449. Uint32 offset; /* starting location of the image data */
  450. Uint32 imagePitch; /* number of pixels from one row to the next */
  451. Uint32 imageHeight; /* number of rows from one layer/depth-slice to the next */
  452. } SDL_GPUTextureTransferInfo;
  453. typedef struct SDL_GPUTransferBufferLocation
  454. {
  455. SDL_GPUTransferBuffer *transferBuffer;
  456. Uint32 offset;
  457. } SDL_GPUTransferBufferLocation;
  458. typedef struct SDL_GPUTextureLocation
  459. {
  460. SDL_GPUTexture *texture;
  461. Uint32 mipLevel;
  462. Uint32 layer;
  463. Uint32 x;
  464. Uint32 y;
  465. Uint32 z;
  466. } SDL_GPUTextureLocation;
  467. typedef struct SDL_GPUTextureRegion
  468. {
  469. SDL_GPUTexture *texture;
  470. Uint32 mipLevel;
  471. Uint32 layer;
  472. Uint32 x;
  473. Uint32 y;
  474. Uint32 z;
  475. Uint32 w;
  476. Uint32 h;
  477. Uint32 d;
  478. } SDL_GPUTextureRegion;
  479. typedef struct SDL_GPUBlitRegion
  480. {
  481. SDL_GPUTexture *texture;
  482. Uint32 mipLevel;
  483. Uint32 layerOrDepthPlane;
  484. Uint32 x;
  485. Uint32 y;
  486. Uint32 w;
  487. Uint32 h;
  488. } SDL_GPUBlitRegion;
  489. typedef struct SDL_GPUBufferLocation
  490. {
  491. SDL_GPUBuffer *buffer;
  492. Uint32 offset;
  493. } SDL_GPUBufferLocation;
  494. typedef struct SDL_GPUBufferRegion
  495. {
  496. SDL_GPUBuffer *buffer;
  497. Uint32 offset;
  498. Uint32 size;
  499. } SDL_GPUBufferRegion;
  500. /* Note that the `firstVertex` and `firstInstance` parameters are NOT compatible with
  501. * built-in vertex/instance ID variables in shaders (for example, SV_VertexID). If
  502. * your shader depends on these variables, the correlating draw call parameter MUST
  503. * be 0.
  504. */
  505. typedef struct SDL_GPUIndirectDrawCommand
  506. {
  507. Uint32 vertexCount; /* number of vertices to draw */
  508. Uint32 instanceCount; /* number of instances to draw */
  509. Uint32 firstVertex; /* index of the first vertex to draw */
  510. Uint32 firstInstance; /* ID of the first instance to draw */
  511. } SDL_GPUIndirectDrawCommand;
  512. typedef struct SDL_GPUIndexedIndirectDrawCommand
  513. {
  514. Uint32 indexCount; /* number of vertices to draw per instance */
  515. Uint32 instanceCount; /* number of instances to draw */
  516. Uint32 firstIndex; /* base index within the index buffer */
  517. Sint32 vertexOffset; /* value added to vertex index before indexing into the vertex buffer */
  518. Uint32 firstInstance; /* ID of the first instance to draw */
  519. } SDL_GPUIndexedIndirectDrawCommand;
  520. typedef struct SDL_GPUIndirectDispatchCommand
  521. {
  522. Uint32 groupCountX;
  523. Uint32 groupCountY;
  524. Uint32 groupCountZ;
  525. } SDL_GPUIndirectDispatchCommand;
  526. /* State structures */
  527. typedef struct SDL_GPUSamplerCreateInfo
  528. {
  529. SDL_GPUFilter minFilter;
  530. SDL_GPUFilter magFilter;
  531. SDL_GPUSamplerMipmapMode mipmapMode;
  532. SDL_GPUSamplerAddressMode addressModeU;
  533. SDL_GPUSamplerAddressMode addressModeV;
  534. SDL_GPUSamplerAddressMode addressModeW;
  535. float mipLodBias;
  536. SDL_bool anisotropyEnable;
  537. float maxAnisotropy;
  538. SDL_bool compareEnable;
  539. SDL_GPUCompareOp compareOp;
  540. float minLod;
  541. float maxLod;
  542. SDL_PropertiesID props;
  543. } SDL_GPUSamplerCreateInfo;
  544. typedef struct SDL_GPUVertexBinding
  545. {
  546. Uint32 binding;
  547. Uint32 stride;
  548. SDL_GPUVertexInputRate inputRate;
  549. Uint32 instanceStepRate; /* ignored unless inputRate is INSTANCE */
  550. } SDL_GPUVertexBinding;
  551. typedef struct SDL_GPUVertexAttribute
  552. {
  553. Uint32 location;
  554. Uint32 binding;
  555. SDL_GPUVertexElementFormat format;
  556. Uint32 offset;
  557. } SDL_GPUVertexAttribute;
  558. typedef struct SDL_GPUVertexInputState
  559. {
  560. const SDL_GPUVertexBinding *vertexBindings;
  561. Uint32 vertexBindingCount;
  562. const SDL_GPUVertexAttribute *vertexAttributes;
  563. Uint32 vertexAttributeCount;
  564. } SDL_GPUVertexInputState;
  565. typedef struct SDL_GPUStencilOpState
  566. {
  567. SDL_GPUStencilOp failOp;
  568. SDL_GPUStencilOp passOp;
  569. SDL_GPUStencilOp depthFailOp;
  570. SDL_GPUCompareOp compareOp;
  571. } SDL_GPUStencilOpState;
  572. typedef struct SDL_GPUColorAttachmentBlendState
  573. {
  574. SDL_bool blendEnable;
  575. SDL_GPUBlendFactor srcColorBlendFactor;
  576. SDL_GPUBlendFactor dstColorBlendFactor;
  577. SDL_GPUBlendOp colorBlendOp;
  578. SDL_GPUBlendFactor srcAlphaBlendFactor;
  579. SDL_GPUBlendFactor dstAlphaBlendFactor;
  580. SDL_GPUBlendOp alphaBlendOp;
  581. SDL_GPUColorComponentFlags colorWriteMask;
  582. } SDL_GPUColorAttachmentBlendState;
  583. typedef struct SDL_GPUShaderCreateInfo
  584. {
  585. size_t codeSize;
  586. const Uint8 *code;
  587. const char *entryPointName;
  588. SDL_GPUShaderFormat format;
  589. SDL_GPUShaderStage stage;
  590. Uint32 samplerCount;
  591. Uint32 storageTextureCount;
  592. Uint32 storageBufferCount;
  593. Uint32 uniformBufferCount;
  594. SDL_PropertiesID props;
  595. } SDL_GPUShaderCreateInfo;
  596. typedef struct SDL_GPUTextureCreateInfo
  597. {
  598. SDL_GPUTextureType type;
  599. SDL_GPUTextureFormat format;
  600. SDL_GPUTextureUsageFlags usageFlags;
  601. Uint32 width;
  602. Uint32 height;
  603. Uint32 layerCountOrDepth;
  604. Uint32 levelCount;
  605. SDL_GPUSampleCount sampleCount;
  606. SDL_PropertiesID props;
  607. } SDL_GPUTextureCreateInfo;
  608. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r"
  609. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT "SDL.gpu.createtexture.d3d12.clear.g"
  610. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT "SDL.gpu.createtexture.d3d12.clear.b"
  611. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT "SDL.gpu.createtexture.d3d12.clear.a"
  612. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.createtexture.d3d12.clear.depth"
  613. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8 "SDL.gpu.createtexture.d3d12.clear.stencil"
  614. typedef struct SDL_GPUBufferCreateInfo
  615. {
  616. SDL_GPUBufferUsageFlags usageFlags;
  617. Uint32 sizeInBytes;
  618. SDL_PropertiesID props;
  619. } SDL_GPUBufferCreateInfo;
  620. typedef struct SDL_GPUTransferBufferCreateInfo
  621. {
  622. SDL_GPUTransferBufferUsage usage;
  623. Uint32 sizeInBytes;
  624. SDL_PropertiesID props;
  625. } SDL_GPUTransferBufferCreateInfo;
  626. /* Pipeline state structures */
  627. typedef struct SDL_GPURasterizerState
  628. {
  629. SDL_GPUFillMode fillMode;
  630. SDL_GPUCullMode cullMode;
  631. SDL_GPUFrontFace frontFace;
  632. SDL_bool depthBiasEnable;
  633. float depthBiasConstantFactor;
  634. float depthBiasClamp;
  635. float depthBiasSlopeFactor;
  636. } SDL_GPURasterizerState;
  637. typedef struct SDL_GPUMultisampleState
  638. {
  639. SDL_GPUSampleCount sampleCount;
  640. Uint32 sampleMask;
  641. } SDL_GPUMultisampleState;
  642. typedef struct SDL_GPUDepthStencilState
  643. {
  644. SDL_bool depthTestEnable;
  645. SDL_bool depthWriteEnable;
  646. SDL_GPUCompareOp compareOp;
  647. SDL_bool stencilTestEnable;
  648. SDL_GPUStencilOpState backStencilState;
  649. SDL_GPUStencilOpState frontStencilState;
  650. Uint8 compareMask;
  651. Uint8 writeMask;
  652. Uint8 reference;
  653. } SDL_GPUDepthStencilState;
  654. typedef struct SDL_GPUColorAttachmentDescription
  655. {
  656. SDL_GPUTextureFormat format;
  657. SDL_GPUColorAttachmentBlendState blendState;
  658. } SDL_GPUColorAttachmentDescription;
  659. typedef struct SDL_GPUGraphicsPipelineAttachmentInfo
  660. {
  661. SDL_GPUColorAttachmentDescription *colorAttachmentDescriptions;
  662. Uint32 colorAttachmentCount;
  663. SDL_bool hasDepthStencilAttachment;
  664. SDL_GPUTextureFormat depthStencilFormat;
  665. } SDL_GPUGraphicsPipelineAttachmentInfo;
  666. typedef struct SDL_GPUGraphicsPipelineCreateInfo
  667. {
  668. SDL_GPUShader *vertexShader;
  669. SDL_GPUShader *fragmentShader;
  670. SDL_GPUVertexInputState vertexInputState;
  671. SDL_GPUPrimitiveType primitiveType;
  672. SDL_GPURasterizerState rasterizerState;
  673. SDL_GPUMultisampleState multisampleState;
  674. SDL_GPUDepthStencilState depthStencilState;
  675. SDL_GPUGraphicsPipelineAttachmentInfo attachmentInfo;
  676. float blendConstants[4];
  677. SDL_PropertiesID props;
  678. } SDL_GPUGraphicsPipelineCreateInfo;
  679. typedef struct SDL_GPUComputePipelineCreateInfo
  680. {
  681. size_t codeSize;
  682. const Uint8 *code;
  683. const char *entryPointName;
  684. SDL_GPUShaderFormat format;
  685. Uint32 readOnlyStorageTextureCount;
  686. Uint32 readOnlyStorageBufferCount;
  687. Uint32 writeOnlyStorageTextureCount;
  688. Uint32 writeOnlyStorageBufferCount;
  689. Uint32 uniformBufferCount;
  690. Uint32 threadCountX;
  691. Uint32 threadCountY;
  692. Uint32 threadCountZ;
  693. SDL_PropertiesID props;
  694. } SDL_GPUComputePipelineCreateInfo;
  695. typedef struct SDL_GPUColorAttachmentInfo
  696. {
  697. /* The texture that will be used as a color attachment by a render pass. */
  698. SDL_GPUTexture *texture;
  699. Uint32 mipLevel;
  700. Uint32 layerOrDepthPlane; /* For 3D textures, you can bind an individual depth plane as an attachment. */
  701. /* Can be ignored by RenderPass if CLEAR is not used */
  702. SDL_FColor clearColor;
  703. /* Determines what is done with the texture at the beginning of the render pass.
  704. *
  705. * LOAD:
  706. * Loads the data currently in the texture.
  707. *
  708. * CLEAR:
  709. * Clears the texture to a single color.
  710. *
  711. * DONT_CARE:
  712. * The driver will do whatever it wants with the texture memory.
  713. * This is a good option if you know that every single pixel will be touched in the render pass.
  714. */
  715. SDL_GPULoadOp loadOp;
  716. /* Determines what is done with the texture at the end of the render pass.
  717. *
  718. * STORE:
  719. * Stores the results of the render pass in the texture.
  720. *
  721. * DONT_CARE:
  722. * The driver will do whatever it wants with the texture memory.
  723. * This is often a good option for depth/stencil textures.
  724. */
  725. SDL_GPUStoreOp storeOp;
  726. /* if SDL_TRUE, cycles the texture if the texture is bound and loadOp is not LOAD */
  727. SDL_bool cycle;
  728. } SDL_GPUColorAttachmentInfo;
  729. typedef struct SDL_GPUDepthStencilAttachmentInfo
  730. {
  731. /* The texture that will be used as the depth stencil attachment by a render pass. */
  732. SDL_GPUTexture *texture;
  733. /* Can be ignored by the render pass if CLEAR is not used */
  734. SDL_GPUDepthStencilValue depthStencilClearValue;
  735. /* Determines what is done with the depth values at the beginning of the render pass.
  736. *
  737. * LOAD:
  738. * Loads the depth values currently in the texture.
  739. *
  740. * CLEAR:
  741. * Clears the texture to a single depth.
  742. *
  743. * DONT_CARE:
  744. * The driver will do whatever it wants with the memory.
  745. * This is a good option if you know that every single pixel will be touched in the render pass.
  746. */
  747. SDL_GPULoadOp loadOp;
  748. /* Determines what is done with the depth values at the end of the render pass.
  749. *
  750. * STORE:
  751. * Stores the depth results in the texture.
  752. *
  753. * DONT_CARE:
  754. * The driver will do whatever it wants with the texture memory.
  755. * This is often a good option for depth/stencil textures.
  756. */
  757. SDL_GPUStoreOp storeOp;
  758. /* Determines what is done with the stencil values at the beginning of the render pass.
  759. *
  760. * LOAD:
  761. * Loads the stencil values currently in the texture.
  762. *
  763. * CLEAR:
  764. * Clears the texture to a single stencil value.
  765. *
  766. * DONT_CARE:
  767. * The driver will do whatever it wants with the memory.
  768. * This is a good option if you know that every single pixel will be touched in the render pass.
  769. */
  770. SDL_GPULoadOp stencilLoadOp;
  771. /* Determines what is done with the stencil values at the end of the render pass.
  772. *
  773. * STORE:
  774. * Stores the stencil results in the texture.
  775. *
  776. * DONT_CARE:
  777. * The driver will do whatever it wants with the texture memory.
  778. * This is often a good option for depth/stencil textures.
  779. */
  780. SDL_GPUStoreOp stencilStoreOp;
  781. /* if SDL_TRUE, cycles the texture if the texture is bound and any load ops are not LOAD */
  782. SDL_bool cycle;
  783. } SDL_GPUDepthStencilAttachmentInfo;
  784. /* Binding structs */
  785. typedef struct SDL_GPUBufferBinding
  786. {
  787. SDL_GPUBuffer *buffer;
  788. Uint32 offset;
  789. } SDL_GPUBufferBinding;
  790. typedef struct SDL_GPUTextureSamplerBinding
  791. {
  792. SDL_GPUTexture *texture;
  793. SDL_GPUSampler *sampler;
  794. } SDL_GPUTextureSamplerBinding;
  795. typedef struct SDL_GPUStorageBufferWriteOnlyBinding
  796. {
  797. SDL_GPUBuffer *buffer;
  798. /* if SDL_TRUE, cycles the buffer if it is bound. */
  799. SDL_bool cycle;
  800. } SDL_GPUStorageBufferWriteOnlyBinding;
  801. typedef struct SDL_GPUStorageTextureWriteOnlyBinding
  802. {
  803. SDL_GPUTexture *texture;
  804. Uint32 mipLevel;
  805. Uint32 layer;
  806. /* if SDL_TRUE, cycles the texture if the texture is bound. */
  807. SDL_bool cycle;
  808. } SDL_GPUStorageTextureWriteOnlyBinding;
  809. /* Functions */
  810. /* Device */
  811. /**
  812. * Creates a GPU context.
  813. *
  814. * \param formatFlags a bitflag indicating which shader formats the app is
  815. * able to provide.
  816. * \param debugMode enable debug mode properties and validations.
  817. * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
  818. * driver.
  819. * \returns a GPU context on success or NULL on failure.
  820. *
  821. * \since This function is available since SDL 3.0.0.
  822. *
  823. * \sa SDL_GetGPUDriver
  824. * \sa SDL_DestroyGPUDevice
  825. */
  826. extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDevice(
  827. SDL_GPUShaderFormat formatFlags,
  828. SDL_bool debugMode,
  829. const char *name);
  830. /**
  831. * Creates a GPU context.
  832. *
  833. * These are the supported properties:
  834. *
  835. * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL`: enable debug mode properties
  836. * and validations, defaults to SDL_TRUE.
  837. * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL`: enable to prefer energy
  838. * efficiency over maximum GPU performance, defaults to SDL_FALSE.
  839. * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to
  840. * use, if a specific one is desired.
  841. *
  842. * These are the current shader format properties:
  843. *
  844. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SECRET_BOOL`: The app is able to
  845. * provide shaders for an NDA platform.
  846. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL`: The app is able to
  847. * provide SPIR-V shaders if applicable.
  848. * - SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL`: The app is able to provide
  849. * DXBC shaders if applicable
  850. * `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL`: The app is able to
  851. * provide DXIL shaders if applicable.
  852. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL`: The app is able to provide
  853. * MSL shaders if applicable.
  854. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL`: The app is able to
  855. * provide Metal shader libraries if applicable.
  856. *
  857. * With the D3D12 renderer:
  858. *
  859. * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to
  860. * use for all vertex semantics, default is "TEXCOORD".
  861. *
  862. * \param props the properties to use.
  863. * \returns a GPU context on success or NULL on failure.
  864. *
  865. * \since This function is available since SDL 3.0.0.
  866. *
  867. * \sa SDL_GetGPUDriver
  868. * \sa SDL_DestroyGPUDevice
  869. */
  870. extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDeviceWithProperties(
  871. SDL_PropertiesID props);
  872. #define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL "SDL.gpu.device.create.debugmode"
  873. #define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL "SDL.gpu.device.create.preferlowpower"
  874. #define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name"
  875. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SECRET_BOOL "SDL.gpu.device.create.shaders.secret"
  876. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL "SDL.gpu.device.create.shaders.spirv"
  877. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL "SDL.gpu.device.create.shaders.dxbc"
  878. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL "SDL.gpu.device.create.shaders.dxil"
  879. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL "SDL.gpu.device.create.shaders.msl"
  880. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL "SDL.gpu.device.create.shaders.metallib"
  881. #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
  882. /**
  883. * Destroys a GPU context previously returned by SDL_CreateGPUDevice.
  884. *
  885. * \param device a GPU Context to destroy.
  886. *
  887. * \since This function is available since SDL 3.0.0.
  888. *
  889. * \sa SDL_CreateGPUDevice
  890. */
  891. extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device);
  892. /**
  893. * Returns the backend used to create this GPU context.
  894. *
  895. * \param device a GPU context to query.
  896. * \returns an SDL_GPUDriver value, or SDL_GPU_DRIVER_INVALID on error.
  897. *
  898. * \since This function is available since SDL 3.0.0.
  899. */
  900. extern SDL_DECLSPEC SDL_GPUDriver SDLCALL SDL_GetGPUDriver(SDL_GPUDevice *device);
  901. /* State Creation */
  902. /**
  903. * Creates a pipeline object to be used in a compute workflow.
  904. *
  905. * Shader resource bindings must be authored to follow a particular order. For
  906. * SPIR-V shaders, use the following resource sets: 0: Read-only storage
  907. * textures, followed by read-only storage buffers 1: Write-only storage
  908. * textures, followed by write-only storage buffers 2: Uniform buffers
  909. *
  910. * For DXBC Shader Model 5_0 shaders, use the following register order: For t
  911. * registers: Read-only storage textures, followed by read-only storage
  912. * buffers For u registers: Write-only storage textures, followed by
  913. * write-only storage buffers For b registers: Uniform buffers
  914. *
  915. * For DXIL shaders, use the following register order: (t[n], space0):
  916. * Read-only storage textures, followed by read-only storage buffers (u[n],
  917. * space1): Write-only storage textures, followed by write-only storage
  918. * buffers (b[n], space2): Uniform buffers
  919. *
  920. * For MSL/metallib, use the following order: For [[buffer]]: Uniform buffers,
  921. * followed by write-only storage buffers, followed by write-only storage
  922. * buffers For [[texture]]: Read-only storage textures, followed by write-only
  923. * storage textures
  924. *
  925. * \param device a GPU Context.
  926. * \param computePipelineCreateInfo a struct describing the state of the
  927. * requested compute pipeline.
  928. * \returns a compute pipeline object on success, or NULL on failure.
  929. *
  930. * \since This function is available since SDL 3.0.0.
  931. *
  932. * \sa SDL_BindGPUComputePipeline
  933. * \sa SDL_ReleaseGPUComputePipeline
  934. */
  935. extern SDL_DECLSPEC SDL_GPUComputePipeline *SDLCALL SDL_CreateGPUComputePipeline(
  936. SDL_GPUDevice *device,
  937. SDL_GPUComputePipelineCreateInfo *computePipelineCreateInfo);
  938. /**
  939. * Creates a pipeline object to be used in a graphics workflow.
  940. *
  941. * \param device a GPU Context.
  942. * \param pipelineCreateInfo a struct describing the state of the desired
  943. * graphics pipeline.
  944. * \returns a graphics pipeline object on success, or NULL on failure.
  945. *
  946. * \since This function is available since SDL 3.0.0.
  947. *
  948. * \sa SDL_CreateGPUShader
  949. * \sa SDL_BindGPUGraphicsPipeline
  950. * \sa SDL_ReleaseGPUGraphicsPipeline
  951. */
  952. extern SDL_DECLSPEC SDL_GPUGraphicsPipeline *SDLCALL SDL_CreateGPUGraphicsPipeline(
  953. SDL_GPUDevice *device,
  954. SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo);
  955. /**
  956. * Creates a sampler object to be used when binding textures in a graphics
  957. * workflow.
  958. *
  959. * \param device a GPU Context.
  960. * \param samplerCreateInfo a struct describing the state of the desired
  961. * sampler.
  962. * \returns a sampler object on success, or NULL on failure.
  963. *
  964. * \since This function is available since SDL 3.0.0.
  965. *
  966. * \sa SDL_BindGPUVertexSamplers
  967. * \sa SDL_BindGPUFragmentSamplers
  968. * \sa SDL_ReleaseSampler
  969. */
  970. extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(
  971. SDL_GPUDevice *device,
  972. SDL_GPUSamplerCreateInfo *samplerCreateInfo);
  973. /**
  974. * Creates a shader to be used when creating a graphics pipeline.
  975. *
  976. * Shader resource bindings must be authored to follow a particular order
  977. * depending on the shader format.
  978. *
  979. * For SPIR-V shaders, use the following resource sets: For vertex shaders: 0:
  980. * Sampled textures, followed by storage textures, followed by storage buffers
  981. * 1: Uniform buffers For fragment shaders: 2: Sampled textures, followed by
  982. * storage textures, followed by storage buffers 3: Uniform buffers
  983. *
  984. * For DXBC Shader Model 5_0 shaders, use the following register order: For t
  985. * registers: Sampled textures, followed by storage textures, followed by
  986. * storage buffers For s registers: Samplers with indices corresponding to the
  987. * sampled textures For b registers: Uniform buffers
  988. *
  989. * For DXIL shaders, use the following register order: For vertex shaders:
  990. * (t[n], space0): Sampled textures, followed by storage textures, followed by
  991. * storage buffers (s[n], space0): Samplers with indices corresponding to the
  992. * sampled textures (b[n], space1): Uniform buffers For pixel shaders: (t[n],
  993. * space2): Sampled textures, followed by storage textures, followed by
  994. * storage buffers (s[n], space2): Samplers with indices corresponding to the
  995. * sampled textures (b[n], space3): Uniform buffers
  996. *
  997. * For MSL/metallib, use the following order: For [[texture]]: Sampled
  998. * textures, followed by storage textures For [[sampler]]: Samplers with
  999. * indices corresponding to the sampled textures For [[buffer]]: Uniform
  1000. * buffers, followed by storage buffers. Vertex buffer 0 is bound at
  1001. * [[buffer(30)]], vertex buffer 1 at [[buffer(29)]], and so on. Rather than
  1002. * manually authoring vertex buffer indices, use the [[stage_in]] attribute
  1003. * which will automatically use the vertex input information from the
  1004. * SDL_GPUPipeline.
  1005. *
  1006. * \param device a GPU Context.
  1007. * \param shaderCreateInfo a struct describing the state of the desired
  1008. * shader.
  1009. * \returns a shader object on success, or NULL on failure.
  1010. *
  1011. * \since This function is available since SDL 3.0.0.
  1012. *
  1013. * \sa SDL_CreateGPUGraphicsPipeline
  1014. * \sa SDL_ReleaseGPUShader
  1015. */
  1016. extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader(
  1017. SDL_GPUDevice *device,
  1018. SDL_GPUShaderCreateInfo *shaderCreateInfo);
  1019. /**
  1020. * Creates a texture object to be used in graphics or compute workflows.
  1021. *
  1022. * The contents of this texture are undefined until data is written to the
  1023. * texture.
  1024. *
  1025. * Note that certain combinations of usage flags are invalid. For example, a
  1026. * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags.
  1027. *
  1028. * If you request a sample count higher than the hardware supports, the
  1029. * implementation will automatically fall back to the highest available sample
  1030. * count.
  1031. *
  1032. * \param device a GPU Context.
  1033. * \param textureCreateInfo a struct describing the state of the texture to
  1034. * create.
  1035. * \returns a texture object on success, or NULL on failure.
  1036. *
  1037. * \since This function is available since SDL 3.0.0.
  1038. *
  1039. * \sa SDL_UploadToGPUTexture
  1040. * \sa SDL_DownloadFromGPUTexture
  1041. * \sa SDL_BindGPUVertexSamplers
  1042. * \sa SDL_BindGPUVertexStorageTextures
  1043. * \sa SDL_BindGPUFragmentSamplers
  1044. * \sa SDL_BindGPUFragmentStorageTextures
  1045. * \sa SDL_BindGPUComputeStorageTextures
  1046. * \sa SDL_BlitGPUTexture
  1047. * \sa SDL_ReleaseGPUTexture
  1048. * \sa SDL_GPUTextureSupportsFormat
  1049. */
  1050. extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture(
  1051. SDL_GPUDevice *device,
  1052. SDL_GPUTextureCreateInfo *textureCreateInfo);
  1053. /**
  1054. * Creates a buffer object to be used in graphics or compute workflows.
  1055. *
  1056. * The contents of this buffer are undefined until data is written to the
  1057. * buffer.
  1058. *
  1059. * Note that certain combinations of usage flags are invalid. For example, a
  1060. * buffer cannot have both the VERTEX and INDEX flags.
  1061. *
  1062. * \param device a GPU Context.
  1063. * \param bufferCreateInfo a struct describing the state of the buffer to
  1064. * create.
  1065. * \returns a buffer object on success, or NULL on failure.
  1066. *
  1067. * \since This function is available since SDL 3.0.0.
  1068. *
  1069. * \sa SDL_UploadToGPUBuffer
  1070. * \sa SDL_BindGPUVertexBuffers
  1071. * \sa SDL_BindGPUIndexBuffer
  1072. * \sa SDL_BindGPUVertexStorageBuffers
  1073. * \sa SDL_BindGPUFragmentStorageBuffers
  1074. * \sa SDL_BindGPUComputeStorageBuffers
  1075. * \sa SDL_ReleaseGPUBuffer
  1076. */
  1077. extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer(
  1078. SDL_GPUDevice *device,
  1079. SDL_GPUBufferCreateInfo *bufferCreateInfo);
  1080. /**
  1081. * Creates a transfer buffer to be used when uploading to or downloading from
  1082. * graphics resources.
  1083. *
  1084. * \param device a GPU Context.
  1085. * \param transferBufferCreateInfo a struct describing the state of the
  1086. * transfer buffer to create.
  1087. * \returns a transfer buffer on success, or NULL on failure.
  1088. *
  1089. * \since This function is available since SDL 3.0.0.
  1090. *
  1091. * \sa SDL_UploadToGPUBuffer
  1092. * \sa SDL_DownloadFromGPUBuffer
  1093. * \sa SDL_UploadToGPUTexture
  1094. * \sa SDL_DownloadFromGPUTexture
  1095. * \sa SDL_ReleaseGPUTransferBuffer
  1096. */
  1097. extern SDL_DECLSPEC SDL_GPUTransferBuffer *SDLCALL SDL_CreateGPUTransferBuffer(
  1098. SDL_GPUDevice *device,
  1099. SDL_GPUTransferBufferCreateInfo *transferBufferCreateInfo);
  1100. /* Debug Naming */
  1101. /**
  1102. * Sets an arbitrary string constant to label a buffer.
  1103. *
  1104. * Useful for debugging.
  1105. *
  1106. * \param device a GPU Context.
  1107. * \param buffer a buffer to attach the name to.
  1108. * \param text a UTF-8 string constant to mark as the name of the buffer.
  1109. *
  1110. * \since This function is available since SDL 3.0.0.
  1111. */
  1112. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName(
  1113. SDL_GPUDevice *device,
  1114. SDL_GPUBuffer *buffer,
  1115. const char *text);
  1116. /**
  1117. * Sets an arbitrary string constant to label a texture.
  1118. *
  1119. * Useful for debugging.
  1120. *
  1121. * \param device a GPU Context.
  1122. * \param texture a texture to attach the name to.
  1123. * \param text a UTF-8 string constant to mark as the name of the texture.
  1124. *
  1125. * \since This function is available since SDL 3.0.0.
  1126. */
  1127. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName(
  1128. SDL_GPUDevice *device,
  1129. SDL_GPUTexture *texture,
  1130. const char *text);
  1131. /**
  1132. * Inserts an arbitrary string label into the command buffer callstream.
  1133. *
  1134. * Useful for debugging.
  1135. *
  1136. * \param commandBuffer a command buffer.
  1137. * \param text a UTF-8 string constant to insert as the label.
  1138. *
  1139. * \since This function is available since SDL 3.0.0.
  1140. */
  1141. extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
  1142. SDL_GPUCommandBuffer *commandBuffer,
  1143. const char *text);
  1144. /**
  1145. * Begins a debug group with an arbitary name.
  1146. *
  1147. * Used for denoting groups of calls when viewing the command buffer
  1148. * callstream in a graphics debugging tool.
  1149. *
  1150. * Each call to SDL_PushGPUDebugGroup must have a corresponding call to
  1151. * SDL_PopGPUDebugGroup.
  1152. *
  1153. * On some backends (e.g. Metal), pushing a debug group during a
  1154. * render/blit/compute pass will create a group that is scoped to the native
  1155. * pass rather than the command buffer. For best results, if you push a debug
  1156. * group during a pass, always pop it in the same pass.
  1157. *
  1158. * \param commandBuffer a command buffer.
  1159. * \param name a UTF-8 string constant that names the group.
  1160. *
  1161. * \since This function is available since SDL 3.0.0.
  1162. *
  1163. * \sa SDL_PopGPUDebugGroup
  1164. */
  1165. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup(
  1166. SDL_GPUCommandBuffer *commandBuffer,
  1167. const char *name);
  1168. /**
  1169. * Ends the most-recently pushed debug group.
  1170. *
  1171. * \param commandBuffer a command buffer.
  1172. *
  1173. * \since This function is available since SDL 3.0.0.
  1174. *
  1175. * \sa SDL_PushGPUDebugGroup
  1176. */
  1177. extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup(
  1178. SDL_GPUCommandBuffer *commandBuffer);
  1179. /* Disposal */
  1180. /**
  1181. * Frees the given texture as soon as it is safe to do so.
  1182. *
  1183. * You must not reference the texture after calling this function.
  1184. *
  1185. * \param device a GPU context.
  1186. * \param texture a texture to be destroyed.
  1187. *
  1188. * \since This function is available since SDL 3.0.0.
  1189. */
  1190. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture(
  1191. SDL_GPUDevice *device,
  1192. SDL_GPUTexture *texture);
  1193. /**
  1194. * Frees the given sampler as soon as it is safe to do so.
  1195. *
  1196. * You must not reference the texture after calling this function.
  1197. *
  1198. * \param device a GPU context.
  1199. * \param sampler a sampler to be destroyed.
  1200. *
  1201. * \since This function is available since SDL 3.0.0.
  1202. */
  1203. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler(
  1204. SDL_GPUDevice *device,
  1205. SDL_GPUSampler *sampler);
  1206. /**
  1207. * Frees the given buffer as soon as it is safe to do so.
  1208. *
  1209. * You must not reference the buffer after calling this function.
  1210. *
  1211. * \param device a GPU context.
  1212. * \param buffer a buffer to be destroyed.
  1213. *
  1214. * \since This function is available since SDL 3.0.0.
  1215. */
  1216. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer(
  1217. SDL_GPUDevice *device,
  1218. SDL_GPUBuffer *buffer);
  1219. /**
  1220. * Frees the given transfer buffer as soon as it is safe to do so.
  1221. *
  1222. * You must not reference the transfer buffer after calling this function.
  1223. *
  1224. * \param device a GPU context.
  1225. * \param transferBuffer a transfer buffer to be destroyed.
  1226. *
  1227. * \since This function is available since SDL 3.0.0.
  1228. */
  1229. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer(
  1230. SDL_GPUDevice *device,
  1231. SDL_GPUTransferBuffer *transferBuffer);
  1232. /**
  1233. * Frees the given compute pipeline as soon as it is safe to do so.
  1234. *
  1235. * You must not reference the compute pipeline after calling this function.
  1236. *
  1237. * \param device a GPU context.
  1238. * \param computePipeline a compute pipeline to be destroyed.
  1239. *
  1240. * \since This function is available since SDL 3.0.0.
  1241. */
  1242. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline(
  1243. SDL_GPUDevice *device,
  1244. SDL_GPUComputePipeline *computePipeline);
  1245. /**
  1246. * Frees the given shader as soon as it is safe to do so.
  1247. *
  1248. * You must not reference the shader after calling this function.
  1249. *
  1250. * \param device a GPU context.
  1251. * \param shader a shader to be destroyed.
  1252. *
  1253. * \since This function is available since SDL 3.0.0.
  1254. */
  1255. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader(
  1256. SDL_GPUDevice *device,
  1257. SDL_GPUShader *shader);
  1258. /**
  1259. * Frees the given graphics pipeline as soon as it is safe to do so.
  1260. *
  1261. * You must not reference the graphics pipeline after calling this function.
  1262. *
  1263. * \param device a GPU context.
  1264. * \param graphicsPipeline a graphics pipeline to be destroyed.
  1265. *
  1266. * \since This function is available since SDL 3.0.0.
  1267. */
  1268. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline(
  1269. SDL_GPUDevice *device,
  1270. SDL_GPUGraphicsPipeline *graphicsPipeline);
  1271. /*
  1272. * COMMAND BUFFERS
  1273. *
  1274. * Render state is managed via command buffers.
  1275. * When setting render state, that state is always local to the command buffer.
  1276. *
  1277. * Commands only begin execution on the GPU once Submit is called.
  1278. * Once the command buffer is submitted, it is no longer valid to use it.
  1279. *
  1280. * Command buffers are executed in submission order. If you submit command buffer A and then command buffer B
  1281. * all commands in A will begin executing before any command in B begins executing.
  1282. *
  1283. * In multi-threading scenarios, you should acquire and submit a command buffer on the same thread.
  1284. * As long as you satisfy this requirement, all functionality related to command buffers is thread-safe.
  1285. */
  1286. /**
  1287. * Acquire a command buffer.
  1288. *
  1289. * This command buffer is managed by the implementation and should not be
  1290. * freed by the user. The command buffer may only be used on the thread it was
  1291. * acquired on. The command buffer should be submitted on the thread it was
  1292. * acquired on.
  1293. *
  1294. * \param device a GPU context.
  1295. * \returns a command buffer.
  1296. *
  1297. * \since This function is available since SDL 3.0.0.
  1298. *
  1299. * \sa SDL_SubmitGPUCommandBuffer
  1300. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  1301. */
  1302. extern SDL_DECLSPEC SDL_GPUCommandBuffer *SDLCALL SDL_AcquireGPUCommandBuffer(
  1303. SDL_GPUDevice *device);
  1304. /*
  1305. * UNIFORM DATA
  1306. *
  1307. * Uniforms are for passing data to shaders.
  1308. * The uniform data will be constant across all executions of the shader.
  1309. *
  1310. * There are 4 available uniform slots per shader stage (vertex, fragment, compute).
  1311. * Uniform data pushed to a slot on a stage keeps its value throughout the command buffer
  1312. * until you call the relevant Push function on that slot again.
  1313. *
  1314. * For example, you could write your vertex shaders to read a camera matrix from uniform binding slot 0,
  1315. * push the camera matrix at the start of the command buffer, and that data will be used for every
  1316. * subsequent draw call.
  1317. *
  1318. * It is valid to push uniform data during a render or compute pass.
  1319. *
  1320. * Uniforms are best for pushing small amounts of data.
  1321. * If you are pushing more than a matrix or two per call you should consider using a storage buffer instead.
  1322. */
  1323. /**
  1324. * Pushes data to a vertex uniform slot on the command buffer.
  1325. *
  1326. * Subsequent draw calls will use this uniform data.
  1327. *
  1328. * \param commandBuffer a command buffer.
  1329. * \param slotIndex the vertex uniform slot to push data to.
  1330. * \param data client data to write.
  1331. * \param dataLengthInBytes the length of the data to write.
  1332. *
  1333. * \since This function is available since SDL 3.0.0.
  1334. */
  1335. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData(
  1336. SDL_GPUCommandBuffer *commandBuffer,
  1337. Uint32 slotIndex,
  1338. const void *data,
  1339. Uint32 dataLengthInBytes);
  1340. /**
  1341. * Pushes data to a fragment uniform slot on the command buffer.
  1342. *
  1343. * Subsequent draw calls will use this uniform data.
  1344. *
  1345. * \param commandBuffer a command buffer.
  1346. * \param slotIndex the fragment uniform slot to push data to.
  1347. * \param data client data to write.
  1348. * \param dataLengthInBytes the length of the data to write.
  1349. *
  1350. * \since This function is available since SDL 3.0.0.
  1351. */
  1352. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData(
  1353. SDL_GPUCommandBuffer *commandBuffer,
  1354. Uint32 slotIndex,
  1355. const void *data,
  1356. Uint32 dataLengthInBytes);
  1357. /**
  1358. * Pushes data to a uniform slot on the command buffer.
  1359. *
  1360. * Subsequent draw calls will use this uniform data.
  1361. *
  1362. * \param commandBuffer a command buffer.
  1363. * \param slotIndex the uniform slot to push data to.
  1364. * \param data client data to write.
  1365. * \param dataLengthInBytes the length of the data to write.
  1366. *
  1367. * \since This function is available since SDL 3.0.0.
  1368. */
  1369. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData(
  1370. SDL_GPUCommandBuffer *commandBuffer,
  1371. Uint32 slotIndex,
  1372. const void *data,
  1373. Uint32 dataLengthInBytes);
  1374. /*
  1375. * A NOTE ON CYCLING
  1376. *
  1377. * When using a command buffer, operations do not occur immediately -
  1378. * they occur some time after the command buffer is submitted.
  1379. *
  1380. * When a resource is used in a pending or active command buffer, it is considered to be "bound".
  1381. * When a resource is no longer used in any pending or active command buffers, it is considered to be "unbound".
  1382. *
  1383. * If data resources are bound, it is unspecified when that data will be unbound
  1384. * unless you acquire a fence when submitting the command buffer and wait on it.
  1385. * However, this doesn't mean you need to track resource usage manually.
  1386. *
  1387. * All of the functions and structs that involve writing to a resource have a "cycle" bool.
  1388. * GPUTransferBuffer, GPUBuffer, and GPUTexture all effectively function as ring buffers on internal resources.
  1389. * When cycle is SDL_TRUE, if the resource is bound, the cycle rotates to the next unbound internal resource,
  1390. * or if none are available, a new one is created.
  1391. * This means you don't have to worry about complex state tracking and synchronization as long as cycling is correctly employed.
  1392. *
  1393. * For example: you can call MapTransferBuffer, write texture data, UnmapTransferBuffer, and then UploadToTexture.
  1394. * The next time you write texture data to the transfer buffer, if you set the cycle param to SDL_TRUE, you don't have
  1395. * to worry about overwriting any data that is not yet uploaded.
  1396. *
  1397. * Another example: If you are using a texture in a render pass every frame, this can cause a data dependency between frames.
  1398. * If you set cycle to SDL_TRUE in the ColorAttachmentInfo struct, you can prevent this data dependency.
  1399. *
  1400. * Cycling will never undefine already bound data.
  1401. * When cycling, all data in the resource is considered to be undefined for subsequent commands until that data is written again.
  1402. * You must take care not to read undefined data.
  1403. *
  1404. * Note that when cycling a texture, the entire texture will be cycled,
  1405. * even if only part of the texture is used in the call,
  1406. * so you must consider the entire texture to contain undefined data after cycling.
  1407. *
  1408. * You must also take care not to overwrite a section of data that has been referenced in a command without cycling first.
  1409. * It is OK to overwrite unreferenced data in a bound resource without cycling,
  1410. * but overwriting a section of data that has already been referenced will produce unexpected results.
  1411. */
  1412. /* Graphics State */
  1413. /**
  1414. * Begins a render pass on a command buffer.
  1415. *
  1416. * A render pass consists of a set of texture subresources (or depth slices in
  1417. * the 3D texture case) which will be rendered to during the render pass,
  1418. * along with corresponding clear values and load/store operations. All
  1419. * operations related to graphics pipelines must take place inside of a render
  1420. * pass. A default viewport and scissor state are automatically set when this
  1421. * is called. You cannot begin another render pass, or begin a compute pass or
  1422. * copy pass until you have ended the render pass.
  1423. *
  1424. * \param commandBuffer a command buffer.
  1425. * \param colorAttachmentInfos an array of texture subresources with
  1426. * corresponding clear values and load/store ops.
  1427. * \param colorAttachmentCount the number of color attachments in the
  1428. * colorAttachmentInfos array.
  1429. * \param depthStencilAttachmentInfo a texture subresource with corresponding
  1430. * clear value and load/store ops, may be
  1431. * NULL.
  1432. * \returns a render pass handle.
  1433. *
  1434. * \since This function is available since SDL 3.0.0.
  1435. *
  1436. * \sa SDL_EndGPURenderPass
  1437. */
  1438. extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(
  1439. SDL_GPUCommandBuffer *commandBuffer,
  1440. SDL_GPUColorAttachmentInfo *colorAttachmentInfos,
  1441. Uint32 colorAttachmentCount,
  1442. SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo);
  1443. /**
  1444. * Binds a graphics pipeline on a render pass to be used in rendering.
  1445. *
  1446. * A graphics pipeline must be bound before making any draw calls.
  1447. *
  1448. * \param renderPass a render pass handle.
  1449. * \param graphicsPipeline the graphics pipeline to bind.
  1450. *
  1451. * \since This function is available since SDL 3.0.0.
  1452. */
  1453. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline(
  1454. SDL_GPURenderPass *renderPass,
  1455. SDL_GPUGraphicsPipeline *graphicsPipeline);
  1456. /**
  1457. * Sets the current viewport state on a command buffer.
  1458. *
  1459. * \param renderPass a render pass handle.
  1460. * \param viewport the viewport to set.
  1461. *
  1462. * \since This function is available since SDL 3.0.0.
  1463. */
  1464. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport(
  1465. SDL_GPURenderPass *renderPass,
  1466. SDL_GPUViewport *viewport);
  1467. /**
  1468. * Sets the current scissor state on a command buffer.
  1469. *
  1470. * \param renderPass a render pass handle.
  1471. * \param scissor the scissor area to set.
  1472. *
  1473. * \since This function is available since SDL 3.0.0.
  1474. */
  1475. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor(
  1476. SDL_GPURenderPass *renderPass,
  1477. SDL_Rect *scissor);
  1478. /**
  1479. * Binds vertex buffers on a command buffer for use with subsequent draw
  1480. * calls.
  1481. *
  1482. * \param renderPass a render pass handle.
  1483. * \param firstBinding the starting bind point for the vertex buffers.
  1484. * \param pBindings an array of SDL_GPUBufferBinding structs containing vertex
  1485. * buffers and offset values.
  1486. * \param bindingCount the number of bindings in the pBindings array.
  1487. *
  1488. * \since This function is available since SDL 3.0.0.
  1489. */
  1490. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(
  1491. SDL_GPURenderPass *renderPass,
  1492. Uint32 firstBinding,
  1493. SDL_GPUBufferBinding *pBindings,
  1494. Uint32 bindingCount);
  1495. /**
  1496. * Binds an index buffer on a command buffer for use with subsequent draw
  1497. * calls.
  1498. *
  1499. * \param renderPass a render pass handle.
  1500. * \param pBinding a pointer to a struct containing an index buffer and
  1501. * offset.
  1502. * \param indexElementSize whether the index values in the buffer are 16- or
  1503. * 32-bit.
  1504. *
  1505. * \since This function is available since SDL 3.0.0.
  1506. */
  1507. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer(
  1508. SDL_GPURenderPass *renderPass,
  1509. SDL_GPUBufferBinding *pBinding,
  1510. SDL_GPUIndexElementSize indexElementSize);
  1511. /**
  1512. * Binds texture-sampler pairs for use on the vertex shader.
  1513. *
  1514. * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT.
  1515. *
  1516. * \param renderPass a render pass handle.
  1517. * \param firstSlot the vertex sampler slot to begin binding from.
  1518. * \param textureSamplerBindings an array of texture-sampler binding structs.
  1519. * \param bindingCount the number of texture-sampler pairs to bind from the
  1520. * array.
  1521. *
  1522. * \since This function is available since SDL 3.0.0.
  1523. */
  1524. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(
  1525. SDL_GPURenderPass *renderPass,
  1526. Uint32 firstSlot,
  1527. SDL_GPUTextureSamplerBinding *textureSamplerBindings,
  1528. Uint32 bindingCount);
  1529. /**
  1530. * Binds storage textures for use on the vertex shader.
  1531. *
  1532. * These textures must have been created with
  1533. * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ_BIT.
  1534. *
  1535. * \param renderPass a render pass handle.
  1536. * \param firstSlot the vertex storage texture slot to begin binding from.
  1537. * \param storageTextures an array of storage textures.
  1538. * \param bindingCount the number of storage texture to bind from the array.
  1539. *
  1540. * \since This function is available since SDL 3.0.0.
  1541. */
  1542. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures(
  1543. SDL_GPURenderPass *renderPass,
  1544. Uint32 firstSlot,
  1545. SDL_GPUTexture **storageTextures,
  1546. Uint32 bindingCount);
  1547. /**
  1548. * Binds storage buffers for use on the vertex shader.
  1549. *
  1550. * These buffers must have been created with
  1551. * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ_BIT.
  1552. *
  1553. * \param renderPass a render pass handle.
  1554. * \param firstSlot the vertex storage buffer slot to begin binding from.
  1555. * \param storageBuffers an array of buffers.
  1556. * \param bindingCount the number of buffers to bind from the array.
  1557. *
  1558. * \since This function is available since SDL 3.0.0.
  1559. */
  1560. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers(
  1561. SDL_GPURenderPass *renderPass,
  1562. Uint32 firstSlot,
  1563. SDL_GPUBuffer **storageBuffers,
  1564. Uint32 bindingCount);
  1565. /**
  1566. * Binds texture-sampler pairs for use on the fragment shader.
  1567. *
  1568. * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT.
  1569. *
  1570. * \param renderPass a render pass handle.
  1571. * \param firstSlot the fragment sampler slot to begin binding from.
  1572. * \param textureSamplerBindings an array of texture-sampler binding structs.
  1573. * \param bindingCount the number of texture-sampler pairs to bind from the
  1574. * array.
  1575. *
  1576. * \since This function is available since SDL 3.0.0.
  1577. */
  1578. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(
  1579. SDL_GPURenderPass *renderPass,
  1580. Uint32 firstSlot,
  1581. SDL_GPUTextureSamplerBinding *textureSamplerBindings,
  1582. Uint32 bindingCount);
  1583. /**
  1584. * Binds storage textures for use on the fragment shader.
  1585. *
  1586. * These textures must have been created with
  1587. * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ_BIT.
  1588. *
  1589. * \param renderPass a render pass handle.
  1590. * \param firstSlot the fragment storage texture slot to begin binding from.
  1591. * \param storageTextures an array of storage textures.
  1592. * \param bindingCount the number of storage textures to bind from the array.
  1593. *
  1594. * \since This function is available since SDL 3.0.0.
  1595. */
  1596. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(
  1597. SDL_GPURenderPass *renderPass,
  1598. Uint32 firstSlot,
  1599. SDL_GPUTexture **storageTextures,
  1600. Uint32 bindingCount);
  1601. /**
  1602. * Binds storage buffers for use on the fragment shader.
  1603. *
  1604. * These buffers must have been created with
  1605. * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ_BIT.
  1606. *
  1607. * \param renderPass a render pass handle.
  1608. * \param firstSlot the fragment storage buffer slot to begin binding from.
  1609. * \param storageBuffers an array of storage buffers.
  1610. * \param bindingCount the number of storage buffers to bind from the array.
  1611. *
  1612. * \since This function is available since SDL 3.0.0.
  1613. */
  1614. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(
  1615. SDL_GPURenderPass *renderPass,
  1616. Uint32 firstSlot,
  1617. SDL_GPUBuffer **storageBuffers,
  1618. Uint32 bindingCount);
  1619. /* Drawing */
  1620. /**
  1621. * Draws data using bound graphics state with an index buffer and instancing
  1622. * enabled.
  1623. *
  1624. * You must not call this function before binding a graphics pipeline.
  1625. *
  1626. * Note that the `firstVertex` and `firstInstance` parameters are NOT
  1627. * compatible with built-in vertex/instance ID variables in shaders (for
  1628. * example, SV_VertexID). If your shader depends on these variables, the
  1629. * correlating draw call parameter MUST be 0.
  1630. *
  1631. * \param renderPass a render pass handle.
  1632. * \param indexCount the number of vertices to draw per instance.
  1633. * \param instanceCount the number of instances to draw.
  1634. * \param firstIndex the starting index within the index buffer.
  1635. * \param vertexOffset value added to vertex index before indexing into the
  1636. * vertex buffer.
  1637. * \param firstInstance the ID of the first instance to draw.
  1638. *
  1639. * \since This function is available since SDL 3.0.0.
  1640. */
  1641. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives(
  1642. SDL_GPURenderPass *renderPass,
  1643. Uint32 indexCount,
  1644. Uint32 instanceCount,
  1645. Uint32 firstIndex,
  1646. Sint32 vertexOffset,
  1647. Uint32 firstInstance);
  1648. /**
  1649. * Draws data using bound graphics state.
  1650. *
  1651. * You must not call this function before binding a graphics pipeline.
  1652. *
  1653. * Note that the `firstVertex` and `firstInstance` parameters are NOT
  1654. * compatible with built-in vertex/instance ID variables in shaders (for
  1655. * example, SV_VertexID). If your shader depends on these variables, the
  1656. * correlating draw call parameter MUST be 0.
  1657. *
  1658. * \param renderPass a render pass handle.
  1659. * \param vertexCount the number of vertices to draw.
  1660. * \param instanceCount the number of instances that will be drawn.
  1661. * \param firstVertex the index of the first vertex to draw.
  1662. * \param firstInstance the ID of the first instance to draw.
  1663. *
  1664. * \since This function is available since SDL 3.0.0.
  1665. */
  1666. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives(
  1667. SDL_GPURenderPass *renderPass,
  1668. Uint32 vertexCount,
  1669. Uint32 instanceCount,
  1670. Uint32 firstVertex,
  1671. Uint32 firstInstance);
  1672. /**
  1673. * Draws data using bound graphics state and with draw parameters set from a
  1674. * buffer.
  1675. *
  1676. * The buffer layout should match the layout of SDL_GPUIndirectDrawCommand.
  1677. * You must not call this function before binding a graphics pipeline.
  1678. *
  1679. * \param renderPass a render pass handle.
  1680. * \param buffer a buffer containing draw parameters.
  1681. * \param offsetInBytes the offset to start reading from the draw buffer.
  1682. * \param drawCount the number of draw parameter sets that should be read from
  1683. * the draw buffer.
  1684. * \param stride the byte stride between sets of draw parameters.
  1685. *
  1686. * \since This function is available since SDL 3.0.0.
  1687. */
  1688. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect(
  1689. SDL_GPURenderPass *renderPass,
  1690. SDL_GPUBuffer *buffer,
  1691. Uint32 offsetInBytes,
  1692. Uint32 drawCount,
  1693. Uint32 stride);
  1694. /**
  1695. * Draws data using bound graphics state with an index buffer enabled and with
  1696. * draw parameters set from a buffer.
  1697. *
  1698. * The buffer layout should match the layout of
  1699. * SDL_GPUIndexedIndirectDrawCommand. You must not call this function before
  1700. * binding a graphics pipeline.
  1701. *
  1702. * \param renderPass a render pass handle.
  1703. * \param buffer a buffer containing draw parameters.
  1704. * \param offsetInBytes the offset to start reading from the draw buffer.
  1705. * \param drawCount the number of draw parameter sets that should be read from
  1706. * the draw buffer.
  1707. * \param stride the byte stride between sets of draw parameters.
  1708. *
  1709. * \since This function is available since SDL 3.0.0.
  1710. */
  1711. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect(
  1712. SDL_GPURenderPass *renderPass,
  1713. SDL_GPUBuffer *buffer,
  1714. Uint32 offsetInBytes,
  1715. Uint32 drawCount,
  1716. Uint32 stride);
  1717. /**
  1718. * Ends the given render pass.
  1719. *
  1720. * All bound graphics state on the render pass command buffer is unset. The
  1721. * render pass handle is now invalid.
  1722. *
  1723. * \param renderPass a render pass handle.
  1724. *
  1725. * \since This function is available since SDL 3.0.0.
  1726. */
  1727. extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass(
  1728. SDL_GPURenderPass *renderPass);
  1729. /* Compute Pass */
  1730. /**
  1731. * Begins a compute pass on a command buffer.
  1732. *
  1733. * A compute pass is defined by a set of texture subresources and buffers that
  1734. * will be written to by compute pipelines. These textures and buffers must
  1735. * have been created with the COMPUTE_STORAGE_WRITE bit. All operations
  1736. * related to compute pipelines must take place inside of a compute pass. You
  1737. * must not begin another compute pass, or a render pass or copy pass before
  1738. * ending the compute pass.
  1739. *
  1740. * A VERY IMPORTANT NOTE Textures and buffers bound as write-only MUST NOT be
  1741. * read from during the compute pass. Doing so will result in undefined
  1742. * behavior. If your compute work requires reading the output from a previous
  1743. * dispatch, you MUST end the current compute pass and begin a new one before
  1744. * you can safely access the data.
  1745. *
  1746. * \param commandBuffer a command buffer.
  1747. * \param storageTextureBindings an array of writeable storage texture binding
  1748. * structs.
  1749. * \param storageTextureBindingCount the number of storage textures to bind
  1750. * from the array.
  1751. * \param storageBufferBindings an array of writeable storage buffer binding
  1752. * structs.
  1753. * \param storageBufferBindingCount the number of storage buffers to bind from
  1754. * the array.
  1755. * \returns a compute pass handle.
  1756. *
  1757. * \since This function is available since SDL 3.0.0.
  1758. *
  1759. * \sa SDL_EndGPUComputePass
  1760. */
  1761. extern SDL_DECLSPEC SDL_GPUComputePass *SDLCALL SDL_BeginGPUComputePass(
  1762. SDL_GPUCommandBuffer *commandBuffer,
  1763. SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings,
  1764. Uint32 storageTextureBindingCount,
  1765. SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings,
  1766. Uint32 storageBufferBindingCount);
  1767. /**
  1768. * Binds a compute pipeline on a command buffer for use in compute dispatch.
  1769. *
  1770. * \param computePass a compute pass handle.
  1771. * \param computePipeline a compute pipeline to bind.
  1772. *
  1773. * \since This function is available since SDL 3.0.0.
  1774. */
  1775. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline(
  1776. SDL_GPUComputePass *computePass,
  1777. SDL_GPUComputePipeline *computePipeline);
  1778. /**
  1779. * Binds storage textures as readonly for use on the compute pipeline.
  1780. *
  1781. * These textures must have been created with
  1782. * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ_BIT.
  1783. *
  1784. * \param computePass a compute pass handle.
  1785. * \param firstSlot the compute storage texture slot to begin binding from.
  1786. * \param storageTextures an array of storage textures.
  1787. * \param bindingCount the number of storage textures to bind from the array.
  1788. *
  1789. * \since This function is available since SDL 3.0.0.
  1790. */
  1791. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(
  1792. SDL_GPUComputePass *computePass,
  1793. Uint32 firstSlot,
  1794. SDL_GPUTexture **storageTextures,
  1795. Uint32 bindingCount);
  1796. /**
  1797. * Binds storage buffers as readonly for use on the compute pipeline.
  1798. *
  1799. * These buffers must have been created with
  1800. * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ_BIT.
  1801. *
  1802. * \param computePass a compute pass handle.
  1803. * \param firstSlot the compute storage buffer slot to begin binding from.
  1804. * \param storageBuffers an array of storage buffer binding structs.
  1805. * \param bindingCount the number of storage buffers to bind from the array.
  1806. *
  1807. * \since This function is available since SDL 3.0.0.
  1808. */
  1809. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(
  1810. SDL_GPUComputePass *computePass,
  1811. Uint32 firstSlot,
  1812. SDL_GPUBuffer **storageBuffers,
  1813. Uint32 bindingCount);
  1814. /**
  1815. * Dispatches compute work.
  1816. *
  1817. * You must not call this function before binding a compute pipeline.
  1818. *
  1819. * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
  1820. * the dispatches write to the same resource region as each other, there is no
  1821. * guarantee of which order the writes will occur. If the write order matters,
  1822. * you MUST end the compute pass and begin another one.
  1823. *
  1824. * \param computePass a compute pass handle.
  1825. * \param groupCountX number of local workgroups to dispatch in the X
  1826. * dimension.
  1827. * \param groupCountY number of local workgroups to dispatch in the Y
  1828. * dimension.
  1829. * \param groupCountZ number of local workgroups to dispatch in the Z
  1830. * dimension.
  1831. *
  1832. * \since This function is available since SDL 3.0.0.
  1833. */
  1834. extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute(
  1835. SDL_GPUComputePass *computePass,
  1836. Uint32 groupCountX,
  1837. Uint32 groupCountY,
  1838. Uint32 groupCountZ);
  1839. /**
  1840. * Dispatches compute work with parameters set from a buffer.
  1841. *
  1842. * The buffer layout should match the layout of
  1843. * SDL_GPUIndirectDispatchCommand. You must not call this function before
  1844. * binding a compute pipeline.
  1845. *
  1846. * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
  1847. * the dispatches write to the same resource region as each other, there is no
  1848. * guarantee of which order the writes will occur. If the write order matters,
  1849. * you MUST end the compute pass and begin another one.
  1850. *
  1851. * \param computePass a compute pass handle.
  1852. * \param buffer a buffer containing dispatch parameters.
  1853. * \param offsetInBytes the offset to start reading from the dispatch buffer.
  1854. *
  1855. * \since This function is available since SDL 3.0.0.
  1856. */
  1857. extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect(
  1858. SDL_GPUComputePass *computePass,
  1859. SDL_GPUBuffer *buffer,
  1860. Uint32 offsetInBytes);
  1861. /**
  1862. * Ends the current compute pass.
  1863. *
  1864. * All bound compute state on the command buffer is unset. The compute pass
  1865. * handle is now invalid.
  1866. *
  1867. * \param computePass a compute pass handle.
  1868. *
  1869. * \since This function is available since SDL 3.0.0.
  1870. */
  1871. extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(
  1872. SDL_GPUComputePass *computePass);
  1873. /* TransferBuffer Data */
  1874. /**
  1875. * Maps a transfer buffer into application address space.
  1876. *
  1877. * You must unmap the transfer buffer before encoding upload commands.
  1878. *
  1879. * \param device a GPU context.
  1880. * \param transferBuffer a transfer buffer.
  1881. * \param cycle if SDL_TRUE, cycles the transfer buffer if it is bound.
  1882. * \returns the address of the mapped transfer buffer memory.
  1883. *
  1884. * \since This function is available since SDL 3.0.0.
  1885. */
  1886. extern SDL_DECLSPEC void *SDLCALL SDL_MapGPUTransferBuffer(
  1887. SDL_GPUDevice *device,
  1888. SDL_GPUTransferBuffer *transferBuffer,
  1889. SDL_bool cycle);
  1890. /**
  1891. * Unmaps a previously mapped transfer buffer.
  1892. *
  1893. * \param device a GPU context.
  1894. * \param transferBuffer a previously mapped transfer buffer.
  1895. *
  1896. * \since This function is available since SDL 3.0.0.
  1897. */
  1898. extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer(
  1899. SDL_GPUDevice *device,
  1900. SDL_GPUTransferBuffer *transferBuffer);
  1901. /* Copy Pass */
  1902. /**
  1903. * Begins a copy pass on a command buffer.
  1904. *
  1905. * All operations related to copying to or from buffers or textures take place
  1906. * inside a copy pass. You must not begin another copy pass, or a render pass
  1907. * or compute pass before ending the copy pass.
  1908. *
  1909. * \param commandBuffer a command buffer.
  1910. * \returns a copy pass handle.
  1911. *
  1912. * \since This function is available since SDL 3.0.0.
  1913. */
  1914. extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass(
  1915. SDL_GPUCommandBuffer *commandBuffer);
  1916. /**
  1917. * Uploads data from a transfer buffer to a texture.
  1918. *
  1919. * The upload occurs on the GPU timeline. You may assume that the upload has
  1920. * finished in subsequent commands.
  1921. *
  1922. * You must align the data in the transfer buffer to a multiple of the texel
  1923. * size of the texture format.
  1924. *
  1925. * \param copyPass a copy pass handle.
  1926. * \param source the source transfer buffer with image layout information.
  1927. * \param destination the destination texture region.
  1928. * \param cycle if SDL_TRUE, cycles the texture if the texture is bound,
  1929. * otherwise overwrites the data.
  1930. *
  1931. * \since This function is available since SDL 3.0.0.
  1932. */
  1933. extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture(
  1934. SDL_GPUCopyPass *copyPass,
  1935. SDL_GPUTextureTransferInfo *source,
  1936. SDL_GPUTextureRegion *destination,
  1937. SDL_bool cycle);
  1938. /* Uploads data from a TransferBuffer to a Buffer. */
  1939. /**
  1940. * Uploads data from a transfer buffer to a buffer.
  1941. *
  1942. * The upload occurs on the GPU timeline. You may assume that the upload has
  1943. * finished in subsequent commands.
  1944. *
  1945. * \param copyPass a copy pass handle.
  1946. * \param source the source transfer buffer with offset.
  1947. * \param destination the destination buffer with offset and size.
  1948. * \param cycle if SDL_TRUE, cycles the buffer if it is bound, otherwise
  1949. * overwrites the data.
  1950. *
  1951. * \since This function is available since SDL 3.0.0.
  1952. */
  1953. extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer(
  1954. SDL_GPUCopyPass *copyPass,
  1955. SDL_GPUTransferBufferLocation *source,
  1956. SDL_GPUBufferRegion *destination,
  1957. SDL_bool cycle);
  1958. /**
  1959. * Performs a texture-to-texture copy.
  1960. *
  1961. * This copy occurs on the GPU timeline. You may assume the copy has finished
  1962. * in subsequent commands.
  1963. *
  1964. * \param copyPass a copy pass handle.
  1965. * \param source a source texture region.
  1966. * \param destination a destination texture region.
  1967. * \param w the width of the region to copy.
  1968. * \param h the height of the region to copy.
  1969. * \param d the depth of the region to copy.
  1970. * \param cycle if SDL_TRUE, cycles the destination texture if the destination
  1971. * texture is bound, otherwise overwrites the data.
  1972. *
  1973. * \since This function is available since SDL 3.0.0.
  1974. */
  1975. extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture(
  1976. SDL_GPUCopyPass *copyPass,
  1977. SDL_GPUTextureLocation *source,
  1978. SDL_GPUTextureLocation *destination,
  1979. Uint32 w,
  1980. Uint32 h,
  1981. Uint32 d,
  1982. SDL_bool cycle);
  1983. /* Copies data from a buffer to a buffer. */
  1984. /**
  1985. * Performs a buffer-to-buffer copy.
  1986. *
  1987. * This copy occurs on the GPU timeline. You may assume the copy has finished
  1988. * in subsequent commands.
  1989. *
  1990. * \param copyPass a copy pass handle.
  1991. * \param source the buffer and offset to copy from.
  1992. * \param destination the buffer and offset to copy to.
  1993. * \param size the length of the buffer to copy.
  1994. * \param cycle if SDL_TRUE, cycles the destination buffer if it is bound,
  1995. * otherwise overwrites the data.
  1996. *
  1997. * \since This function is available since SDL 3.0.0.
  1998. */
  1999. extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer(
  2000. SDL_GPUCopyPass *copyPass,
  2001. SDL_GPUBufferLocation *source,
  2002. SDL_GPUBufferLocation *destination,
  2003. Uint32 size,
  2004. SDL_bool cycle);
  2005. /**
  2006. * Copies data from a texture to a transfer buffer on the GPU timeline.
  2007. *
  2008. * This data is not guaranteed to be copied until the command buffer fence is
  2009. * signaled.
  2010. *
  2011. * \param copyPass a copy pass handle.
  2012. * \param source the source texture region.
  2013. * \param destination the destination transfer buffer with image layout
  2014. * information.
  2015. *
  2016. * \since This function is available since SDL 3.0.0.
  2017. */
  2018. extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture(
  2019. SDL_GPUCopyPass *copyPass,
  2020. SDL_GPUTextureRegion *source,
  2021. SDL_GPUTextureTransferInfo *destination);
  2022. /**
  2023. * Copies data from a buffer to a transfer buffer on the GPU timeline.
  2024. *
  2025. * This data is not guaranteed to be copied until the command buffer fence is
  2026. * signaled.
  2027. *
  2028. * \param copyPass a copy pass handle.
  2029. * \param source the source buffer with offset and size.
  2030. * \param destination the destination transfer buffer with offset.
  2031. *
  2032. * \since This function is available since SDL 3.0.0.
  2033. */
  2034. extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer(
  2035. SDL_GPUCopyPass *copyPass,
  2036. SDL_GPUBufferRegion *source,
  2037. SDL_GPUTransferBufferLocation *destination);
  2038. /**
  2039. * Ends the current copy pass.
  2040. *
  2041. * \param copyPass a copy pass handle.
  2042. *
  2043. * \since This function is available since SDL 3.0.0.
  2044. */
  2045. extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass(
  2046. SDL_GPUCopyPass *copyPass);
  2047. /**
  2048. * Generates mipmaps for the given texture.
  2049. *
  2050. * This function must not be called inside of any pass.
  2051. *
  2052. * \param commandBuffer a commandBuffer.
  2053. * \param texture a texture with more than 1 mip level.
  2054. *
  2055. * \since This function is available since SDL 3.0.0.
  2056. */
  2057. extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(
  2058. SDL_GPUCommandBuffer *commandBuffer,
  2059. SDL_GPUTexture *texture);
  2060. /**
  2061. * Blits from a source texture region to a destination texture region.
  2062. *
  2063. * This function must not be called inside of any pass.
  2064. *
  2065. * \param commandBuffer a command buffer.
  2066. * \param source the texture region to copy from.
  2067. * \param destination the texture region to copy to.
  2068. * \param flipMode the flip mode for the source texture region.
  2069. * \param filterMode the filter mode that will be used when blitting.
  2070. * \param cycle if SDL_TRUE, cycles the destination texture if the destination
  2071. * texture is bound, otherwise overwrites the data.
  2072. *
  2073. * \since This function is available since SDL 3.0.0.
  2074. */
  2075. extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
  2076. SDL_GPUCommandBuffer *commandBuffer,
  2077. SDL_GPUBlitRegion *source,
  2078. SDL_GPUBlitRegion *destination,
  2079. SDL_FlipMode flipMode,
  2080. SDL_GPUFilter filterMode,
  2081. SDL_bool cycle);
  2082. /* Submission/Presentation */
  2083. /**
  2084. * Determines whether a swapchain composition is supported by the window.
  2085. *
  2086. * The window must be claimed before calling this function.
  2087. *
  2088. * \param device a GPU context.
  2089. * \param window an SDL_Window.
  2090. * \param swapchainComposition the swapchain composition to check.
  2091. * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error).
  2092. *
  2093. * \since This function is available since SDL 3.0.0.
  2094. *
  2095. * \sa SDL_ClaimWindowForGPUDevice
  2096. */
  2097. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition(
  2098. SDL_GPUDevice *device,
  2099. SDL_Window *window,
  2100. SDL_GPUSwapchainComposition swapchainComposition);
  2101. /**
  2102. * Determines whether a presentation mode is supported by the window.
  2103. *
  2104. * The window must be claimed before calling this function.
  2105. *
  2106. * \param device a GPU context.
  2107. * \param window an SDL_Window.
  2108. * \param presentMode the presentation mode to check.
  2109. * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error).
  2110. *
  2111. * \since This function is available since SDL 3.0.0.
  2112. *
  2113. * \sa SDL_ClaimWindowForGPUDevice
  2114. */
  2115. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUPresentMode(
  2116. SDL_GPUDevice *device,
  2117. SDL_Window *window,
  2118. SDL_GPUPresentMode presentMode);
  2119. /**
  2120. * Claims a window, creating a swapchain structure for it.
  2121. *
  2122. * This must be called before SDL_AcquireGPUSwapchainTexture is called using
  2123. * the window.
  2124. *
  2125. * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and
  2126. * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain
  2127. * parameters, you must call SetSwapchainParameters after claiming the window.
  2128. *
  2129. * \param device a GPU context.
  2130. * \param window an SDL_Window.
  2131. * \returns SDL_TRUE on success, otherwise SDL_FALSE.
  2132. *
  2133. * \since This function is available since SDL 3.0.0.
  2134. *
  2135. * \sa SDL_AcquireGPUSwapchainTexture
  2136. * \sa SDL_ReleaseWindowFromGPUDevice
  2137. * \sa SDL_WindowSupportsGPUPresentMode
  2138. * \sa SDL_WindowSupportsGPUSwapchainComposition
  2139. */
  2140. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClaimWindowForGPUDevice(
  2141. SDL_GPUDevice *device,
  2142. SDL_Window *window);
  2143. /**
  2144. * Unclaims a window, destroying its swapchain structure.
  2145. *
  2146. * \param device a GPU context.
  2147. * \param window an SDL_Window that has been claimed.
  2148. *
  2149. * \since This function is available since SDL 3.0.0.
  2150. *
  2151. * \sa SDL_ClaimWindowForGPUDevice
  2152. */
  2153. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice(
  2154. SDL_GPUDevice *device,
  2155. SDL_Window *window);
  2156. /**
  2157. * Changes the swapchain parameters for the given claimed window.
  2158. *
  2159. * This function will fail if the requested present mode or swapchain
  2160. * composition are unsupported by the device. Check if the parameters are
  2161. * supported via SDL_WindowSupportsGPUPresentMode /
  2162. * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function.
  2163. *
  2164. * SDL_GPU_PRESENTMODE_VSYNC and SDL_GPU_SWAPCHAINCOMPOSITION_SDR are always
  2165. * supported.
  2166. *
  2167. * \param device a GPU context.
  2168. * \param window an SDL_Window that has been claimed.
  2169. * \param swapchainComposition the desired composition of the swapchain.
  2170. * \param presentMode the desired present mode for the swapchain.
  2171. * \returns SDL_TRUE if successful, SDL_FALSE on error.
  2172. *
  2173. * \since This function is available since SDL 3.0.0.
  2174. *
  2175. * \sa SDL_WindowSupportsGPUPresentMode
  2176. * \sa SDL_WindowSupportsGPUSwapchainComposition
  2177. */
  2178. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGPUSwapchainParameters(
  2179. SDL_GPUDevice *device,
  2180. SDL_Window *window,
  2181. SDL_GPUSwapchainComposition swapchainComposition,
  2182. SDL_GPUPresentMode presentMode);
  2183. /**
  2184. * Obtains the texture format of the swapchain for the given window.
  2185. *
  2186. * \param device a GPU context.
  2187. * \param window an SDL_Window that has been claimed.
  2188. * \returns the texture format of the swapchain.
  2189. *
  2190. * \since This function is available since SDL 3.0.0.
  2191. */
  2192. extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureFormat(
  2193. SDL_GPUDevice *device,
  2194. SDL_Window *window);
  2195. /**
  2196. * Acquire a texture to use in presentation.
  2197. *
  2198. * When a swapchain texture is acquired on a command buffer, it will
  2199. * automatically be submitted for presentation when the command buffer is
  2200. * submitted. The swapchain texture should only be referenced by the command
  2201. * buffer used to acquire it. May return NULL under certain conditions. This
  2202. * is not necessarily an error. This texture is managed by the implementation
  2203. * and must not be freed by the user. You MUST NOT call this function from any
  2204. * thread other than the one that created the window.
  2205. *
  2206. * \param commandBuffer a command buffer.
  2207. * \param window a window that has been claimed.
  2208. * \param pWidth a pointer filled in with the swapchain width.
  2209. * \param pHeight a pointer filled in with the swapchain height.
  2210. * \returns a swapchain texture.
  2211. *
  2212. * \since This function is available since SDL 3.0.0.
  2213. *
  2214. * \sa SDL_ClaimWindowForGPUDevice
  2215. * \sa SDL_SubmitGPUCommandBuffer
  2216. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2217. */
  2218. extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_AcquireGPUSwapchainTexture(
  2219. SDL_GPUCommandBuffer *commandBuffer,
  2220. SDL_Window *window,
  2221. Uint32 *pWidth,
  2222. Uint32 *pHeight);
  2223. /**
  2224. * Submits a command buffer so its commands can be processed on the GPU.
  2225. *
  2226. * It is invalid to use the command buffer after this is called.
  2227. *
  2228. * This must be called from the thread the command buffer was acquired on.
  2229. *
  2230. * All commands in the submission are guaranteed to begin executing before any
  2231. * command in a subsequent submission begins executing.
  2232. *
  2233. * \param commandBuffer a command buffer.
  2234. *
  2235. * \since This function is available since SDL 3.0.0.
  2236. *
  2237. * \sa SDL_AcquireGPUCommandBuffer
  2238. * \sa SDL_AcquireGPUSwapchainTexture
  2239. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2240. */
  2241. extern SDL_DECLSPEC void SDLCALL SDL_SubmitGPUCommandBuffer(
  2242. SDL_GPUCommandBuffer *commandBuffer);
  2243. /**
  2244. * Submits a command buffer so its commands can be processed on the GPU, and
  2245. * acquires a fence associated with the command buffer.
  2246. *
  2247. * You must release this fence when it is no longer needed or it will cause a
  2248. * leak. It is invalid to use the command buffer after this is called.
  2249. *
  2250. * This must be called from the thread the command buffer was acquired on.
  2251. *
  2252. * All commands in the submission are guaranteed to begin executing before any
  2253. * command in a subsequent submission begins executing.
  2254. *
  2255. * \param commandBuffer a command buffer.
  2256. * \returns a fence associated with the command buffer.
  2257. *
  2258. * \since This function is available since SDL 3.0.0.
  2259. *
  2260. * \sa SDL_AcquireGPUCommandBuffer
  2261. * \sa SDL_AcquireGPUSwapchainTexture
  2262. * \sa SDL_SubmitGPUCommandBuffer
  2263. * \sa SDL_ReleaseGPUFence
  2264. */
  2265. extern SDL_DECLSPEC SDL_GPUFence *SDLCALL SDL_SubmitGPUCommandBufferAndAcquireFence(
  2266. SDL_GPUCommandBuffer *commandBuffer);
  2267. /**
  2268. * Blocks the thread until the GPU is completely idle.
  2269. *
  2270. * \param device a GPU context.
  2271. *
  2272. * \since This function is available since SDL 3.0.0.
  2273. *
  2274. * \sa SDL_WaitForGPUFences
  2275. */
  2276. extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUIdle(
  2277. SDL_GPUDevice *device);
  2278. /**
  2279. * Blocks the thread until the given fences are signaled.
  2280. *
  2281. * \param device a GPU context.
  2282. * \param waitAll if 0, wait for any fence to be signaled, if 1, wait for all
  2283. * fences to be signaled.
  2284. * \param pFences an array of fences to wait on.
  2285. * \param fenceCount the number of fences in the pFences array.
  2286. *
  2287. * \since This function is available since SDL 3.0.0.
  2288. *
  2289. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2290. * \sa SDL_WaitForGPUIdle
  2291. */
  2292. extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUFences(
  2293. SDL_GPUDevice *device,
  2294. SDL_bool waitAll,
  2295. SDL_GPUFence **pFences,
  2296. Uint32 fenceCount);
  2297. /**
  2298. * Checks the status of a fence.
  2299. *
  2300. * \param device a GPU context.
  2301. * \param fence a fence.
  2302. * \returns SDL_TRUE if the fence is signaled, SDL_FALSE if it is not.
  2303. *
  2304. * \since This function is available since SDL 3.0.0.
  2305. *
  2306. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2307. */
  2308. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_QueryGPUFence(
  2309. SDL_GPUDevice *device,
  2310. SDL_GPUFence *fence);
  2311. /**
  2312. * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence.
  2313. *
  2314. * \param device a GPU context.
  2315. * \param fence a fence.
  2316. *
  2317. * \since This function is available since SDL 3.0.0.
  2318. *
  2319. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2320. */
  2321. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence(
  2322. SDL_GPUDevice *device,
  2323. SDL_GPUFence *fence);
  2324. /* Format Info */
  2325. /**
  2326. * Obtains the texel block size for a texture format.
  2327. *
  2328. * \param textureFormat the texture format you want to know the texel size of.
  2329. * \returns the texel block size of the texture format.
  2330. *
  2331. * \since This function is available since SDL 3.0.0.
  2332. *
  2333. * \sa SDL_UploadToGPUTexture
  2334. */
  2335. extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize(
  2336. SDL_GPUTextureFormat textureFormat);
  2337. /**
  2338. * Determines whether a texture format is supported for a given type and
  2339. * usage.
  2340. *
  2341. * \param device a GPU context.
  2342. * \param format the texture format to check.
  2343. * \param type the type of texture (2D, 3D, Cube).
  2344. * \param usage a bitmask of all usage scenarios to check.
  2345. * \returns whether the texture format is supported for this type and usage.
  2346. *
  2347. * \since This function is available since SDL 3.0.0.
  2348. */
  2349. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsFormat(
  2350. SDL_GPUDevice *device,
  2351. SDL_GPUTextureFormat format,
  2352. SDL_GPUTextureType type,
  2353. SDL_GPUTextureUsageFlags usage);
  2354. /**
  2355. * Determines if a sample count for a texture format is supported.
  2356. *
  2357. * \param device a GPU context.
  2358. * \param format the texture format to check.
  2359. * \param sampleCount the sample count to check.
  2360. * \returns a hardware-specific version of min(preferred, possible).
  2361. *
  2362. * \since This function is available since SDL 3.0.0.
  2363. */
  2364. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsSampleCount(
  2365. SDL_GPUDevice *device,
  2366. SDL_GPUTextureFormat format,
  2367. SDL_GPUSampleCount sampleCount);
  2368. #ifdef SDL_PLATFORM_GDK
  2369. /**
  2370. * Call this to suspend GPU operation on Xbox when you receive the
  2371. * SDL_EVENT_DID_ENTER_BACKGROUND event.
  2372. *
  2373. * Do NOT call any SDL_GPU functions after calling this function! This must
  2374. * also be called before calling SDL_GDKSuspendComplete.
  2375. *
  2376. * \param device a GPU context.
  2377. *
  2378. * \since This function is available since SDL 3.0.0.
  2379. *
  2380. * \sa SDL_AddEventWatch
  2381. */
  2382. extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device);
  2383. /**
  2384. * Call this to resume GPU operation on Xbox when you receive the
  2385. * SDL_EVENT_WILL_ENTER_FOREGROUND event.
  2386. *
  2387. * When resuming, this function MUST be called before calling any other
  2388. * SDL_GPU functions.
  2389. *
  2390. * \param device a GPU context.
  2391. *
  2392. * \since This function is available since SDL 3.0.0.
  2393. *
  2394. * \sa SDL_AddEventWatch
  2395. */
  2396. extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device);
  2397. #endif /* SDL_PLATFORM_GDK */
  2398. #ifdef __cplusplus
  2399. }
  2400. #endif /* __cplusplus */
  2401. #endif /* SDL_GPU_H */