SDL_gpu.h 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  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. #include <SDL3/SDL_begin_code.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif /* __cplusplus */
  36. /* Type Declarations */
  37. /**
  38. * An opaque handle representing the SDL_GPU context.
  39. *
  40. * \since This struct is available since SDL 3.0.0
  41. */
  42. typedef struct SDL_GPUDevice SDL_GPUDevice;
  43. /**
  44. * An opaque handle representing a buffer.
  45. *
  46. * Used for vertices, indices, indirect draw commands, and general compute
  47. * data.
  48. *
  49. * \since This struct is available since SDL 3.0.0
  50. *
  51. * \sa SDL_CreateGPUBuffer
  52. * \sa SDL_SetGPUBufferName
  53. * \sa SDL_UploadToGPUBuffer
  54. * \sa SDL_DownloadFromGPUBuffer
  55. * \sa SDL_CopyGPUBufferToBuffer
  56. * \sa SDL_BindGPUVertexBuffers
  57. * \sa SDL_BindGPUIndexBuffer
  58. * \sa SDL_BindGPUVertexStorageBuffers
  59. * \sa SDL_BindGPUFragmentStorageBuffers
  60. * \sa SDL_DrawGPUPrimitivesIndirect
  61. * \sa SDL_DrawGPUIndexedPrimitivesIndirect
  62. * \sa SDL_BindGPUComputeStorageBuffers
  63. * \sa SDL_DispatchGPUComputeIndirect
  64. * \sa SDL_ReleaseGPUBuffer
  65. */
  66. typedef struct SDL_GPUBuffer SDL_GPUBuffer;
  67. /**
  68. * An opaque handle representing a transfer buffer.
  69. *
  70. * Used for transferring data to and from the device.
  71. *
  72. * \since This struct is available since SDL 3.0.0
  73. *
  74. * \sa SDL_CreateGPUTransferBuffer
  75. * \sa SDL_MapGPUTransferBuffer
  76. * \sa SDL_UnmapGPUTransferBuffer
  77. * \sa SDL_UploadToGPUBuffer
  78. * \sa SDL_UploadToGPUTexture
  79. * \sa SDL_DownloadFromGPUBuffer
  80. * \sa SDL_DownloadFromGPUTexture
  81. * \sa SDL_ReleaseGPUTransferBuffer
  82. */
  83. typedef struct SDL_GPUTransferBuffer SDL_GPUTransferBuffer;
  84. /**
  85. * An opaque handle representing a texture.
  86. *
  87. * \since This struct is available since SDL 3.0.0
  88. *
  89. * \sa SDL_CreateGPUTexture
  90. * \sa SDL_SetGPUTextureName
  91. * \sa SDL_UploadToGPUTexture
  92. * \sa SDL_DownloadFromGPUTexture
  93. * \sa SDL_CopyGPUTextureToTexture
  94. * \sa SDL_BindGPUVertexSamplers
  95. * \sa SDL_BindGPUVertexStorageTextures
  96. * \sa SDL_BindGPUFragmentSamplers
  97. * \sa SDL_BindGPUFragmentStorageTextures
  98. * \sa SDL_BindGPUComputeStorageTextures
  99. * \sa SDL_GenerateMipmapsForGPUTexture
  100. * \sa SDL_BlitGPUTexture
  101. * \sa SDL_ReleaseGPUTexture
  102. */
  103. typedef struct SDL_GPUTexture SDL_GPUTexture;
  104. /**
  105. * An opaque handle representing a sampler.
  106. *
  107. * \since This struct is available since SDL 3.0.0
  108. *
  109. * \sa SDL_CreateGPUSampler
  110. * \sa SDL_BindGPUVertexSamplers
  111. * \sa SDL_BindGPUFragmentSamplers
  112. * \sa SDL_ReleaseGPUSampler
  113. */
  114. typedef struct SDL_GPUSampler SDL_GPUSampler;
  115. /**
  116. * An opaque handle representing a compiled shader object.
  117. *
  118. * \since This struct is available since SDL 3.0.0
  119. *
  120. * \sa SDL_CreateGPUShader
  121. * \sa SDL_CreateGPUGraphicsPipeline
  122. * \sa SDL_ReleaseGPUShader
  123. */
  124. typedef struct SDL_GPUShader SDL_GPUShader;
  125. /**
  126. * An opaque handle representing a compute pipeline.
  127. *
  128. * Used during compute passes.
  129. *
  130. * \since This struct is available since SDL 3.0.0
  131. *
  132. * \sa SDL_CreateGPUComputePipeline
  133. * \sa SDL_BindGPUComputePipeline
  134. * \sa SDL_ReleaseGPUComputePipeline
  135. */
  136. typedef struct SDL_GPUComputePipeline SDL_GPUComputePipeline;
  137. /**
  138. * An opaque handle representing a graphics pipeline.
  139. *
  140. * Used during render passes.
  141. *
  142. * \since This struct is available since SDL 3.0.0
  143. *
  144. * \sa SDL_CreateGPUGraphicsPipeline
  145. * \sa SDL_BindGPUGraphicsPipeline
  146. * \sa SDL_ReleaseGPUGraphicsPipeline
  147. */
  148. typedef struct SDL_GPUGraphicsPipeline SDL_GPUGraphicsPipeline;
  149. /**
  150. * An opaque handle representing a command buffer.
  151. *
  152. * Most state is managed via command buffers. When setting state using a
  153. * command buffer, that state is local to the command buffer.
  154. *
  155. * Commands only begin execution on the GPU once SDL_SubmitGPUCommandBuffer is
  156. * called. Once the command buffer is submitted, it is no longer valid to use
  157. * it.
  158. *
  159. * Command buffers are executed in submission order. If you submit command
  160. * buffer A and then command buffer B all commands in A will begin executing
  161. * before any command in B begins executing.
  162. *
  163. * In multi-threading scenarios, you should acquire and submit a command
  164. * buffer on the same thread. As long as you satisfy this requirement, all
  165. * functionality related to command buffers is thread-safe.
  166. *
  167. * \since This struct is available since SDL 3.0.0
  168. *
  169. * \sa SDL_AcquireGPUCommandBuffer
  170. * \sa SDL_SubmitGPUCommandBuffer
  171. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  172. */
  173. typedef struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer;
  174. /**
  175. * An opaque handle representing a render pass.
  176. *
  177. * This handle is transient and should not be held or referenced after
  178. * SDL_EndGPURenderPass is called.
  179. *
  180. * \since This struct is available since SDL 3.0.0
  181. *
  182. * \sa SDL_BeginGPURenderPass
  183. * \sa SDL_EndGPURenderPass
  184. */
  185. typedef struct SDL_GPURenderPass SDL_GPURenderPass;
  186. /**
  187. * An opaque handle representing a compute pass.
  188. *
  189. * This handle is transient and should not be held or referenced after
  190. * SDL_EndGPUComputePass is called.
  191. *
  192. * \since This struct is available since SDL 3.0.0
  193. *
  194. * \sa SDL_BeginGPUComputePass
  195. * \sa SDL_EndGPUComputePass
  196. */
  197. typedef struct SDL_GPUComputePass SDL_GPUComputePass;
  198. /**
  199. * An opaque handle representing a copy pass.
  200. *
  201. * This handle is transient and should not be held or referenced after
  202. * SDL_EndGPUCopyPass is called.
  203. *
  204. * \since This struct is available since SDL 3.0.0
  205. *
  206. * \sa SDL_BeginGPUCopyPass
  207. * \sa SDL_EndGPUCopyPass
  208. */
  209. typedef struct SDL_GPUCopyPass SDL_GPUCopyPass;
  210. /**
  211. * An opaque handle representing a fence.
  212. *
  213. * \since This struct is available since SDL 3.0.0
  214. *
  215. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  216. * \sa SDL_QueryGPUFence
  217. * \sa SDL_WaitForGPUFences
  218. * \sa SDL_ReleaseGPUFence
  219. */
  220. typedef struct SDL_GPUFence SDL_GPUFence;
  221. /**
  222. * Specifies the primitive topology of a graphics pipeline.
  223. *
  224. * \since This enum is available since SDL 3.0.0
  225. *
  226. * \sa SDL_CreateGPUGraphicsPipeline
  227. */
  228. typedef enum SDL_GPUPrimitiveType
  229. {
  230. SDL_GPU_PRIMITIVETYPE_POINTLIST, /**< A series of separate points. */
  231. SDL_GPU_PRIMITIVETYPE_LINELIST, /**< A series of separate lines. */
  232. SDL_GPU_PRIMITIVETYPE_LINESTRIP, /**< A series of connected lines. */
  233. SDL_GPU_PRIMITIVETYPE_TRIANGLELIST, /**< A series of separate triangles. */
  234. SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP /**< A series of connected triangles. */
  235. } SDL_GPUPrimitiveType;
  236. /**
  237. * Specifies how the contents of a texture attached to a render pass are
  238. * treated at the beginning of the render pass.
  239. *
  240. * \since This enum is available since SDL 3.0.0
  241. *
  242. * \sa SDL_BeginGPURenderPass
  243. */
  244. typedef enum SDL_GPULoadOp
  245. {
  246. SDL_GPU_LOADOP_LOAD, /**< The previous contents of the texture will be preserved. */
  247. SDL_GPU_LOADOP_CLEAR, /**< The contents of the texture will be cleared to a color. */
  248. SDL_GPU_LOADOP_DONT_CARE /**< The previous contents of the texture need not be preserved. The contents will be undefined. */
  249. } SDL_GPULoadOp;
  250. /**
  251. * Specifies how the contents of a texture attached to a render pass are
  252. * treated at the end of the render pass.
  253. *
  254. * \since This enum is available since SDL 3.0.0
  255. *
  256. * \sa SDL_BeginGPURenderPass
  257. */
  258. typedef enum SDL_GPUStoreOp
  259. {
  260. SDL_GPU_STOREOP_STORE, /**< The contents generated during the render pass will be written to memory. */
  261. SDL_GPU_STOREOP_DONT_CARE /**< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */
  262. } SDL_GPUStoreOp;
  263. /**
  264. * Specifies the size of elements in an index buffer.
  265. *
  266. * \since This enum is available since SDL 3.0.0
  267. *
  268. * \sa SDL_CreateGPUGraphicsPipeline
  269. */
  270. typedef enum SDL_GPUIndexElementSize
  271. {
  272. SDL_GPU_INDEXELEMENTSIZE_16BIT, /**< The index elements are 16-bit. */
  273. SDL_GPU_INDEXELEMENTSIZE_32BIT /**< The index elements are 32-bit. */
  274. } SDL_GPUIndexElementSize;
  275. /**
  276. * Specifies the pixel format of a texture.
  277. *
  278. * Texture format support varies depending on driver, hardware, and usage
  279. * flags. In general, you should use SDL_GPUTextureSupportsFormat to query if
  280. * a format is supported before using it. However, there are a few guaranteed
  281. * formats.
  282. *
  283. * For SAMPLER usage, the following formats are universally supported:
  284. *
  285. * - R8G8B8A8_UNORM
  286. * - B8G8R8A8_UNORM
  287. * - R8_UNORM
  288. * - R8_SNORM
  289. * - R8G8_UNORM
  290. * - R8G8_SNORM
  291. * - R8G8B8A8_SNORM
  292. * - R16_FLOAT
  293. * - R16G16_FLOAT
  294. * - R16G16B16A16_FLOAT
  295. * - R32_FLOAT
  296. * - R32G32_FLOAT
  297. * - R32G32B32A32_FLOAT
  298. * - R11G11B10_UFLOAT
  299. * - R8G8B8A8_UNORM_SRGB
  300. * - B8G8R8A8_UNORM_SRGB
  301. * - D16_UNORM
  302. *
  303. * For COLOR_TARGET usage, the following formats are universally supported:
  304. *
  305. * - R8G8B8A8_UNORM
  306. * - B8G8R8A8_UNORM
  307. * - R8_UNORM
  308. * - R16_FLOAT
  309. * - R16G16_FLOAT
  310. * - R16G16B16A16_FLOAT
  311. * - R32_FLOAT
  312. * - R32G32_FLOAT
  313. * - R32G32B32A32_FLOAT
  314. * - R8_UINT
  315. * - R8G8_UINT
  316. * - R8G8B8A8_UINT
  317. * - R16_UINT
  318. * - R16G16_UINT
  319. * - R16G16B16A16_UINT
  320. * - R8_INT
  321. * - R8G8_INT
  322. * - R8G8B8A8_INT
  323. * - R16_INT
  324. * - R16G16_INT
  325. * - R16G16B16A16_INT
  326. * - R8G8B8A8_UNORM_SRGB
  327. * - B8G8R8A8_UNORM_SRGB
  328. *
  329. * For STORAGE usages, the following formats are universally supported:
  330. *
  331. * - R8G8B8A8_UNORM
  332. * - R8G8B8A8_SNORM
  333. * - R16G16B16A16_FLOAT
  334. * - R32_FLOAT
  335. * - R32G32_FLOAT
  336. * - R32G32B32A32_FLOAT
  337. * - R8G8B8A8_UINT
  338. * - R16G16B16A16_UINT
  339. * - R8G8B8A8_INT
  340. * - R16G16B16A16_INT
  341. *
  342. * For DEPTH_STENCIL_TARGET usage, the following formats are universally
  343. * supported:
  344. *
  345. * - D16_UNORM
  346. * - Either (but not necessarily both!) D24_UNORM or D32_SFLOAT
  347. * - Either (but not necessarily both!) D24_UNORM_S8_UINT or
  348. * D32_SFLOAT_S8_UINT
  349. *
  350. * Unless D16_UNORM is sufficient for your purposes, always check which of
  351. * D24/D32 is supported before creating a depth-stencil texture!
  352. *
  353. * \since This enum is available since SDL 3.0.0
  354. *
  355. * \sa SDL_CreateGPUTexture
  356. * \sa SDL_GPUTextureSupportsFormat
  357. */
  358. typedef enum SDL_GPUTextureFormat
  359. {
  360. SDL_GPU_TEXTUREFORMAT_INVALID = -1,
  361. /* Unsigned Normalized Float Color Formats */
  362. SDL_GPU_TEXTUREFORMAT_A8_UNORM,
  363. SDL_GPU_TEXTUREFORMAT_R8_UNORM,
  364. SDL_GPU_TEXTUREFORMAT_R8G8_UNORM,
  365. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
  366. SDL_GPU_TEXTUREFORMAT_R16_UNORM,
  367. SDL_GPU_TEXTUREFORMAT_R16G16_UNORM,
  368. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM,
  369. SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM,
  370. SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM,
  371. SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM,
  372. SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM,
  373. SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM,
  374. /* Compressed Unsigned Normalized Float Color Formats */
  375. SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM,
  376. SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM,
  377. SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM,
  378. SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM,
  379. SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM,
  380. SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM,
  381. /* Compressed Signed Float Color Formats */
  382. SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT,
  383. /* Compressed Unsigned Float Color Formats */
  384. SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT,
  385. /* Signed Normalized Float Color Formats */
  386. SDL_GPU_TEXTUREFORMAT_R8_SNORM,
  387. SDL_GPU_TEXTUREFORMAT_R8G8_SNORM,
  388. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM,
  389. SDL_GPU_TEXTUREFORMAT_R16_SNORM,
  390. SDL_GPU_TEXTUREFORMAT_R16G16_SNORM,
  391. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM,
  392. /* Signed Float Color Formats */
  393. SDL_GPU_TEXTUREFORMAT_R16_FLOAT,
  394. SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT,
  395. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT,
  396. SDL_GPU_TEXTUREFORMAT_R32_FLOAT,
  397. SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT,
  398. SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT,
  399. /* Unsigned Float Color Formats */
  400. SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT,
  401. /* Unsigned Integer Color Formats */
  402. SDL_GPU_TEXTUREFORMAT_R8_UINT,
  403. SDL_GPU_TEXTUREFORMAT_R8G8_UINT,
  404. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT,
  405. SDL_GPU_TEXTUREFORMAT_R16_UINT,
  406. SDL_GPU_TEXTUREFORMAT_R16G16_UINT,
  407. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT,
  408. /* Signed Integer Color Formats */
  409. SDL_GPU_TEXTUREFORMAT_R8_INT,
  410. SDL_GPU_TEXTUREFORMAT_R8G8_INT,
  411. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT,
  412. SDL_GPU_TEXTUREFORMAT_R16_INT,
  413. SDL_GPU_TEXTUREFORMAT_R16G16_INT,
  414. SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT,
  415. /* SRGB Unsigned Normalized Color Formats */
  416. SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB,
  417. SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB,
  418. /* Compressed SRGB Unsigned Normalized Color Formats */
  419. SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB,
  420. SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB,
  421. SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB,
  422. SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB,
  423. /* Depth Formats */
  424. SDL_GPU_TEXTUREFORMAT_D16_UNORM,
  425. SDL_GPU_TEXTUREFORMAT_D24_UNORM,
  426. SDL_GPU_TEXTUREFORMAT_D32_FLOAT,
  427. SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT,
  428. SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT
  429. } SDL_GPUTextureFormat;
  430. /**
  431. * Specifies how a texture is intended to be used by the client.
  432. *
  433. * A texture must have at least one usage flag. Note that some usage flag
  434. * combinations are invalid.
  435. *
  436. * \since This enum is available since SDL 3.0.0
  437. *
  438. * \sa SDL_CreateGPUTexture
  439. */
  440. typedef Uint32 SDL_GPUTextureUsageFlags;
  441. #define SDL_GPU_TEXTUREUSAGE_SAMPLER (1u << 0) /**< Texture supports sampling. */
  442. #define SDL_GPU_TEXTUREUSAGE_COLOR_TARGET (1u << 1) /**< Texture is a color render target. */
  443. #define SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET (1u << 2) /**< Texture is a depth stencil target. */
  444. #define SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Texture supports storage reads in graphics stages. */
  445. #define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Texture supports storage reads in the compute stage. */
  446. #define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Texture supports storage writes in the compute stage. */
  447. /**
  448. * Specifies the type of a texture.
  449. *
  450. * \since This enum is available since SDL 3.0.0
  451. *
  452. * \sa SDL_CreateGPUTexture
  453. */
  454. typedef enum SDL_GPUTextureType
  455. {
  456. SDL_GPU_TEXTURETYPE_2D, /**< The texture is a 2-dimensional image. */
  457. SDL_GPU_TEXTURETYPE_2D_ARRAY, /**< The texture is a 2-dimensional array image. */
  458. SDL_GPU_TEXTURETYPE_3D, /**< The texture is a 3-dimensional image. */
  459. SDL_GPU_TEXTURETYPE_CUBE /**< The texture is a cube image. */
  460. } SDL_GPUTextureType;
  461. /**
  462. * Specifies the sample count of a texture.
  463. *
  464. * Used in multisampling. Note that this value only applies when the texture
  465. * is used as a render target.
  466. *
  467. * \since This enum is available since SDL 3.0.0
  468. *
  469. * \sa SDL_CreateGPUTexture
  470. * \sa SDL_GPUTextureSupportsSampleCount
  471. */
  472. typedef enum SDL_GPUSampleCount
  473. {
  474. SDL_GPU_SAMPLECOUNT_1, /**< No multisampling. */
  475. SDL_GPU_SAMPLECOUNT_2, /**< MSAA 2x */
  476. SDL_GPU_SAMPLECOUNT_4, /**< MSAA 4x */
  477. SDL_GPU_SAMPLECOUNT_8 /**< MSAA 8x */
  478. } SDL_GPUSampleCount;
  479. /**
  480. * Specifies the face of a cube map.
  481. *
  482. * Can be passed in as the layer field in texture-related structs.
  483. *
  484. * \since This enum is available since SDL 3.0.0
  485. */
  486. typedef enum SDL_GPUCubeMapFace
  487. {
  488. SDL_GPU_CUBEMAPFACE_POSITIVEX,
  489. SDL_GPU_CUBEMAPFACE_NEGATIVEX,
  490. SDL_GPU_CUBEMAPFACE_POSITIVEY,
  491. SDL_GPU_CUBEMAPFACE_NEGATIVEY,
  492. SDL_GPU_CUBEMAPFACE_POSITIVEZ,
  493. SDL_GPU_CUBEMAPFACE_NEGATIVEZ
  494. } SDL_GPUCubeMapFace;
  495. /**
  496. * Specifies how a buffer is intended to be used by the client.
  497. *
  498. * A buffer must have at least one usage flag. Note that some usage flag
  499. * combinations are invalid.
  500. *
  501. * \since This enum is available since SDL 3.0.0
  502. *
  503. * \sa SDL_CreateGPUBuffer
  504. */
  505. typedef Uint32 SDL_GPUBufferUsageFlags;
  506. #define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */
  507. #define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */
  508. #define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */
  509. #define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */
  510. #define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */
  511. #define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */
  512. /**
  513. * Specifies how a transfer buffer is intended to be used by the client.
  514. *
  515. * Note that mapping and copying FROM an upload transfer buffer or TO a
  516. * download transfer buffer is undefined behavior.
  517. *
  518. * \since This enum is available since SDL 3.0.0
  519. *
  520. * \sa SDL_CreateGPUTransferBuffer
  521. */
  522. typedef enum SDL_GPUTransferBufferUsage
  523. {
  524. SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
  525. SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
  526. } SDL_GPUTransferBufferUsage;
  527. /**
  528. * Specifies which stage a shader program corresponds to.
  529. *
  530. * \since This enum is available since SDL 3.0.0
  531. *
  532. * \sa SDL_CreateGPUShader
  533. */
  534. typedef enum SDL_GPUShaderStage
  535. {
  536. SDL_GPU_SHADERSTAGE_VERTEX,
  537. SDL_GPU_SHADERSTAGE_FRAGMENT
  538. } SDL_GPUShaderStage;
  539. /**
  540. * Specifies the format of shader code.
  541. *
  542. * Each format corresponds to a specific backend that accepts it.
  543. *
  544. * \since This enum is available since SDL 3.0.0
  545. *
  546. * \sa SDL_CreateGPUShader
  547. */
  548. typedef Uint32 SDL_GPUShaderFormat;
  549. #define SDL_GPU_SHADERFORMAT_PRIVATE (1u << 0) /**< Shaders for NDA'd platforms. */
  550. #define SDL_GPU_SHADERFORMAT_SPIRV (1u << 1) /**< SPIR-V shaders for Vulkan. */
  551. #define SDL_GPU_SHADERFORMAT_DXBC (1u << 2) /**< DXBC SM5_0 shaders for D3D11. */
  552. #define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL shaders for D3D12. */
  553. #define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */
  554. #define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */
  555. /**
  556. * Specifies the format of a vertex attribute.
  557. *
  558. * \since This enum is available since SDL 3.0.0
  559. *
  560. * \sa SDL_CreateGPUGraphicsPipeline
  561. */
  562. typedef enum SDL_GPUVertexElementFormat
  563. {
  564. /* 32-bit Signed Integers */
  565. SDL_GPU_VERTEXELEMENTFORMAT_INT,
  566. SDL_GPU_VERTEXELEMENTFORMAT_INT2,
  567. SDL_GPU_VERTEXELEMENTFORMAT_INT3,
  568. SDL_GPU_VERTEXELEMENTFORMAT_INT4,
  569. /* 32-bit Unsigned Integers */
  570. SDL_GPU_VERTEXELEMENTFORMAT_UINT,
  571. SDL_GPU_VERTEXELEMENTFORMAT_UINT2,
  572. SDL_GPU_VERTEXELEMENTFORMAT_UINT3,
  573. SDL_GPU_VERTEXELEMENTFORMAT_UINT4,
  574. /* 32-bit Floats */
  575. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT,
  576. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
  577. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
  578. SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4,
  579. /* 8-bit Signed Integers */
  580. SDL_GPU_VERTEXELEMENTFORMAT_BYTE2,
  581. SDL_GPU_VERTEXELEMENTFORMAT_BYTE4,
  582. /* 8-bit Unsigned Integers */
  583. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2,
  584. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4,
  585. /* 8-bit Signed Normalized */
  586. SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM,
  587. SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM,
  588. /* 8-bit Unsigned Normalized */
  589. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM,
  590. SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM,
  591. /* 16-bit Signed Integers */
  592. SDL_GPU_VERTEXELEMENTFORMAT_SHORT2,
  593. SDL_GPU_VERTEXELEMENTFORMAT_SHORT4,
  594. /* 16-bit Unsigned Integers */
  595. SDL_GPU_VERTEXELEMENTFORMAT_USHORT2,
  596. SDL_GPU_VERTEXELEMENTFORMAT_USHORT4,
  597. /* 16-bit Signed Normalized */
  598. SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM,
  599. SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM,
  600. /* 16-bit Unsigned Normalized */
  601. SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM,
  602. SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM,
  603. /* 16-bit Floats */
  604. SDL_GPU_VERTEXELEMENTFORMAT_HALF2,
  605. SDL_GPU_VERTEXELEMENTFORMAT_HALF4
  606. } SDL_GPUVertexElementFormat;
  607. /**
  608. * Specifies the rate at which vertex attributes are pulled from buffers.
  609. *
  610. * \since This enum is available since SDL 3.0.0
  611. *
  612. * \sa SDL_CreateGPUGraphicsPipeline
  613. */
  614. typedef enum SDL_GPUVertexInputRate
  615. {
  616. SDL_GPU_VERTEXINPUTRATE_VERTEX = 0, /**< Attribute addressing is a function of the vertex index. */
  617. SDL_GPU_VERTEXINPUTRATE_INSTANCE = 1 /**< Attribute addressing is a function of the instance index. */
  618. } SDL_GPUVertexInputRate;
  619. /**
  620. * Specifies the fill mode of the graphics pipeline.
  621. *
  622. * \since This enum is available since SDL 3.0.0
  623. *
  624. * \sa SDL_CreateGPUGraphicsPipeline
  625. */
  626. typedef enum SDL_GPUFillMode
  627. {
  628. SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */
  629. SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */
  630. } SDL_GPUFillMode;
  631. /**
  632. * Specifies the facing direction in which triangle faces will be culled.
  633. *
  634. * \since This enum is available since SDL 3.0.0
  635. *
  636. * \sa SDL_CreateGPUGraphicsPipeline
  637. */
  638. typedef enum SDL_GPUCullMode
  639. {
  640. SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */
  641. SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */
  642. SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */
  643. } SDL_GPUCullMode;
  644. /**
  645. * Specifies the vertex winding that will cause a triangle to be determined to
  646. * be front-facing.
  647. *
  648. * \since This enum is available since SDL 3.0.0
  649. *
  650. * \sa SDL_CreateGPUGraphicsPipeline
  651. */
  652. typedef enum SDL_GPUFrontFace
  653. {
  654. SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */
  655. SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */
  656. } SDL_GPUFrontFace;
  657. /**
  658. * Specifies a comparison operator for depth, stencil and sampler operations.
  659. *
  660. * \since This enum is available since SDL 3.0.0
  661. *
  662. * \sa SDL_CreateGPUGraphicsPipeline
  663. */
  664. typedef enum SDL_GPUCompareOp
  665. {
  666. SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */
  667. SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */
  668. SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */
  669. SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */
  670. SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */
  671. SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */
  672. SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evalutes reference >= test. */
  673. SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */
  674. } SDL_GPUCompareOp;
  675. /**
  676. * Specifies what happens to a stored stencil value if stencil tests fail or
  677. * pass.
  678. *
  679. * \since This enum is available since SDL 3.0.0
  680. *
  681. * \sa SDL_CreateGPUGraphicsPipeline
  682. */
  683. typedef enum SDL_GPUStencilOp
  684. {
  685. SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */
  686. SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */
  687. SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */
  688. SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */
  689. SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */
  690. SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */
  691. SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */
  692. SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */
  693. } SDL_GPUStencilOp;
  694. /**
  695. * Specifies the operator to be used when pixels in a render target are
  696. * blended with existing pixels in the texture.
  697. *
  698. * The source color is the value written by the fragment shader. The
  699. * destination color is the value currently existing in the texture.
  700. *
  701. * \since This enum is available since SDL 3.0.0
  702. *
  703. * \sa SDL_CreateGPUGraphicsPipeline
  704. */
  705. typedef enum SDL_GPUBlendOp
  706. {
  707. SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */
  708. SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */
  709. SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */
  710. SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */
  711. SDL_GPU_BLENDOP_MAX /**< max(source, destination) */
  712. } SDL_GPUBlendOp;
  713. /**
  714. * Specifies a blending factor to be used when pixels in a render target are
  715. * blended with existing pixels in the texture.
  716. *
  717. * The source color is the value written by the fragment shader. The
  718. * destination color is the value currently existing in the texture.
  719. *
  720. * \since This enum is available since SDL 3.0.0
  721. *
  722. * \sa SDL_CreateGPUGraphicsPipeline
  723. */
  724. typedef enum SDL_GPUBlendFactor
  725. {
  726. SDL_GPU_BLENDFACTOR_ZERO, /**< 0 */
  727. SDL_GPU_BLENDFACTOR_ONE, /**< 1 */
  728. SDL_GPU_BLENDFACTOR_SRC_COLOR, /**< source color */
  729. SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR, /**< 1 - source color */
  730. SDL_GPU_BLENDFACTOR_DST_COLOR, /**< destination color */
  731. SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR, /**< 1 - destination color */
  732. SDL_GPU_BLENDFACTOR_SRC_ALPHA, /**< source alpha */
  733. SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, /**< 1 - source alpha */
  734. SDL_GPU_BLENDFACTOR_DST_ALPHA, /**< destination alpha */
  735. SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA, /**< 1 - destination alpha */
  736. SDL_GPU_BLENDFACTOR_CONSTANT_COLOR, /**< blend constant */
  737. SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, /**< 1 - blend constant */
  738. SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE /**< min(source alpha, 1 - destination alpha) */
  739. } SDL_GPUBlendFactor;
  740. /**
  741. * Specifies which color components are written in a graphics pipeline.
  742. *
  743. * \since This enum is available since SDL 3.0.0
  744. *
  745. * \sa SDL_CreateGPUGraphicsPipeline
  746. */
  747. typedef Uint8 SDL_GPUColorComponentFlags;
  748. #define SDL_GPU_COLORCOMPONENT_R (1u << 0) /**< the red component */
  749. #define SDL_GPU_COLORCOMPONENT_G (1u << 1) /**< the green component */
  750. #define SDL_GPU_COLORCOMPONENT_B (1u << 2) /**< the blue component */
  751. #define SDL_GPU_COLORCOMPONENT_A (1u << 3) /**< the alpha component */
  752. /**
  753. * Specifies a filter operation used by a sampler.
  754. *
  755. * \since This enum is available since SDL 3.0.0
  756. *
  757. * \sa SDL_CreateGPUSampler
  758. */
  759. typedef enum SDL_GPUFilter
  760. {
  761. SDL_GPU_FILTER_NEAREST, /**< Point filtering. */
  762. SDL_GPU_FILTER_LINEAR /**< Linear filtering. */
  763. } SDL_GPUFilter;
  764. /**
  765. * Specifies a mipmap mode used by a sampler.
  766. *
  767. * \since This enum is available since SDL 3.0.0
  768. *
  769. * \sa SDL_CreateGPUSampler
  770. */
  771. typedef enum SDL_GPUSamplerMipmapMode
  772. {
  773. SDL_GPU_SAMPLERMIPMAPMODE_NEAREST, /**< Point filtering. */
  774. SDL_GPU_SAMPLERMIPMAPMODE_LINEAR /**< Linear filtering. */
  775. } SDL_GPUSamplerMipmapMode;
  776. /**
  777. * Specifies behavior of texture sampling when the coordinates exceed the 0-1
  778. * range.
  779. *
  780. * \since This enum is available since SDL 3.0.0
  781. *
  782. * \sa SDL_CreateGPUSampler
  783. */
  784. typedef enum SDL_GPUSamplerAddressMode
  785. {
  786. SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */
  787. SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */
  788. SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */
  789. } SDL_GPUSamplerAddressMode;
  790. /**
  791. * Specifies the timing that will be used to present swapchain textures to the
  792. * OS.
  793. *
  794. * Note that this value affects the behavior of
  795. * SDL_AcquireGPUSwapchainTexture. VSYNC mode will always be supported.
  796. * IMMEDIATE and MAILBOX modes may not be supported on certain systems.
  797. *
  798. * It is recommended to query SDL_WindowSupportsGPUPresentMode after claiming
  799. * the window if you wish to change the present mode to IMMEDIATE or MAILBOX.
  800. *
  801. * - VSYNC: Waits for vblank before presenting. No tearing is possible. If
  802. * there is a pending image to present, the new image is enqueued for
  803. * presentation. Disallows tearing at the cost of visual latency. When using
  804. * this present mode, AcquireSwapchainTexture will block if too many frames
  805. * are in flight.
  806. * - IMMEDIATE: Immediately presents. Lowest latency option, but tearing may
  807. * occur. When using this mode, AcquireSwapchainTexture will return NULL if
  808. * too many frames are in flight.
  809. * - MAILBOX: Waits for vblank before presenting. No tearing is possible. If
  810. * there is a pending image to present, the pending image is replaced by the
  811. * new image. Similar to VSYNC, but with reduced visual latency. When using
  812. * this mode, AcquireSwapchainTexture will return NULL if too many frames
  813. * are in flight.
  814. *
  815. * \since This enum is available since SDL 3.0.0
  816. *
  817. * \sa SDL_SetGPUSwapchainParameters
  818. * \sa SDL_WindowSupportsGPUPresentMode
  819. * \sa SDL_AcquireGPUSwapchainTexture
  820. */
  821. typedef enum SDL_GPUPresentMode
  822. {
  823. SDL_GPU_PRESENTMODE_VSYNC,
  824. SDL_GPU_PRESENTMODE_IMMEDIATE,
  825. SDL_GPU_PRESENTMODE_MAILBOX
  826. } SDL_GPUPresentMode;
  827. /**
  828. * Specifies the texture format and colorspace of the swapchain textures.
  829. *
  830. * SDR will always be supported. Other compositions may not be supported on
  831. * certain systems.
  832. *
  833. * It is recommended to query SDL_WindowSupportsGPUSwapchainComposition after
  834. * claiming the window if you wish to change the swapchain composition from
  835. * SDR.
  836. *
  837. * - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in nonlinear sRGB
  838. * encoding.
  839. * - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are in
  840. * nonlinear sRGB encoding.
  841. * - HDR_EXTENDED_LINEAR: R16G16B16A16_SFLOAT swapchain. Pixel values are in
  842. * extended linear encoding.
  843. * - HDR10_ST2048: A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in
  844. * PQ ST2048 encoding.
  845. *
  846. * \since This enum is available since SDL 3.0.0
  847. *
  848. * \sa SDL_SetGPUSwapchainParameters
  849. * \sa SDL_WindowSupportsGPUSwapchainComposition
  850. * \sa SDL_AcquireGPUSwapchainTexture
  851. */
  852. typedef enum SDL_GPUSwapchainComposition
  853. {
  854. SDL_GPU_SWAPCHAINCOMPOSITION_SDR,
  855. SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR,
  856. SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR,
  857. SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048
  858. } SDL_GPUSwapchainComposition;
  859. /**
  860. * Specifies a backend API supported by SDL_GPU.
  861. *
  862. * Only one of these will be in use at a time.
  863. *
  864. * \since This enum is available since SDL 3.0.0
  865. */
  866. typedef enum SDL_GPUDriver
  867. {
  868. SDL_GPU_DRIVER_INVALID = -1,
  869. SDL_GPU_DRIVER_PRIVATE, /* NDA'd platforms */
  870. SDL_GPU_DRIVER_VULKAN,
  871. SDL_GPU_DRIVER_D3D11,
  872. SDL_GPU_DRIVER_D3D12,
  873. SDL_GPU_DRIVER_METAL
  874. } SDL_GPUDriver;
  875. /* Structures */
  876. typedef struct SDL_GPUDepthStencilValue
  877. {
  878. float depth;
  879. Uint8 stencil;
  880. Uint8 padding1;
  881. Uint8 padding2;
  882. Uint8 padding3;
  883. } SDL_GPUDepthStencilValue;
  884. typedef struct SDL_GPUViewport
  885. {
  886. float x;
  887. float y;
  888. float w;
  889. float h;
  890. float min_depth;
  891. float max_depth;
  892. } SDL_GPUViewport;
  893. typedef struct SDL_GPUTextureTransferInfo
  894. {
  895. SDL_GPUTransferBuffer *transfer_buffer;
  896. Uint32 offset; /* starting location of the image data */
  897. Uint32 pixels_per_row; /* number of pixels from one row to the next */
  898. Uint32 rows_per_layer; /* number of rows from one layer/depth-slice to the next */
  899. } SDL_GPUTextureTransferInfo;
  900. typedef struct SDL_GPUTransferBufferLocation
  901. {
  902. SDL_GPUTransferBuffer *transfer_buffer;
  903. Uint32 offset;
  904. } SDL_GPUTransferBufferLocation;
  905. typedef struct SDL_GPUTextureLocation
  906. {
  907. SDL_GPUTexture *texture;
  908. Uint32 mip_level;
  909. Uint32 layer;
  910. Uint32 x;
  911. Uint32 y;
  912. Uint32 z;
  913. } SDL_GPUTextureLocation;
  914. typedef struct SDL_GPUTextureRegion
  915. {
  916. SDL_GPUTexture *texture;
  917. Uint32 mip_level;
  918. Uint32 layer;
  919. Uint32 x;
  920. Uint32 y;
  921. Uint32 z;
  922. Uint32 w;
  923. Uint32 h;
  924. Uint32 d;
  925. } SDL_GPUTextureRegion;
  926. typedef struct SDL_GPUBlitRegion
  927. {
  928. SDL_GPUTexture *texture;
  929. Uint32 mip_level;
  930. Uint32 layer_or_depth_plane;
  931. Uint32 x;
  932. Uint32 y;
  933. Uint32 w;
  934. Uint32 h;
  935. } SDL_GPUBlitRegion;
  936. typedef struct SDL_GPUBufferLocation
  937. {
  938. SDL_GPUBuffer *buffer;
  939. Uint32 offset;
  940. } SDL_GPUBufferLocation;
  941. typedef struct SDL_GPUBufferRegion
  942. {
  943. SDL_GPUBuffer *buffer;
  944. Uint32 offset;
  945. Uint32 size;
  946. } SDL_GPUBufferRegion;
  947. /* Note that the `first_vertex` and `first_instance` parameters are NOT compatible with
  948. * built-in vertex/instance ID variables in shaders (for example, SV_VertexID). If
  949. * your shader depends on these variables, the correlating draw call parameter MUST
  950. * be 0.
  951. */
  952. typedef struct SDL_GPUIndirectDrawCommand
  953. {
  954. Uint32 num_vertices; /* number of vertices to draw */
  955. Uint32 num_instances; /* number of instances to draw */
  956. Uint32 first_vertex; /* index of the first vertex to draw */
  957. Uint32 first_instance; /* ID of the first instance to draw */
  958. } SDL_GPUIndirectDrawCommand;
  959. typedef struct SDL_GPUIndexedIndirectDrawCommand
  960. {
  961. Uint32 num_indices; /* number of vertices to draw per instance */
  962. Uint32 num_instances; /* number of instances to draw */
  963. Uint32 first_index; /* base index within the index buffer */
  964. Sint32 vertex_offset; /* value added to vertex index before indexing into the vertex buffer */
  965. Uint32 first_instance; /* ID of the first instance to draw */
  966. } SDL_GPUIndexedIndirectDrawCommand;
  967. typedef struct SDL_GPUIndirectDispatchCommand
  968. {
  969. Uint32 groupcount_x;
  970. Uint32 groupcount_y;
  971. Uint32 groupcount_z;
  972. } SDL_GPUIndirectDispatchCommand;
  973. /* State structures */
  974. typedef struct SDL_GPUSamplerCreateInfo
  975. {
  976. SDL_GPUFilter min_filter;
  977. SDL_GPUFilter mag_filter;
  978. SDL_GPUSamplerMipmapMode mipmap_mode;
  979. SDL_GPUSamplerAddressMode address_mode_u;
  980. SDL_GPUSamplerAddressMode address_mode_v;
  981. SDL_GPUSamplerAddressMode address_mode_w;
  982. float mip_lod_bias;
  983. float max_anisotropy;
  984. SDL_bool enable_anisotropy;
  985. SDL_bool enable_compare;
  986. Uint8 padding1;
  987. Uint8 padding2;
  988. SDL_GPUCompareOp compare_op;
  989. float min_lod;
  990. float max_lod;
  991. SDL_PropertiesID props;
  992. } SDL_GPUSamplerCreateInfo;
  993. typedef struct SDL_GPUVertexBinding
  994. {
  995. Uint32 binding;
  996. Uint32 pitch;
  997. SDL_GPUVertexInputRate input_rate;
  998. Uint32 instance_step_rate; /* ignored unless input_rate is INSTANCE */
  999. } SDL_GPUVertexBinding;
  1000. typedef struct SDL_GPUVertexAttribute
  1001. {
  1002. Uint32 location;
  1003. Uint32 binding;
  1004. SDL_GPUVertexElementFormat format;
  1005. Uint32 offset;
  1006. } SDL_GPUVertexAttribute;
  1007. typedef struct SDL_GPUVertexInputState
  1008. {
  1009. const SDL_GPUVertexBinding *vertex_bindings;
  1010. Uint32 num_vertex_bindings;
  1011. const SDL_GPUVertexAttribute *vertex_attributes;
  1012. Uint32 num_vertex_attributes;
  1013. } SDL_GPUVertexInputState;
  1014. typedef struct SDL_GPUStencilOpState
  1015. {
  1016. SDL_GPUStencilOp fail_op;
  1017. SDL_GPUStencilOp pass_op;
  1018. SDL_GPUStencilOp depth_fail_op;
  1019. SDL_GPUCompareOp compare_op;
  1020. } SDL_GPUStencilOpState;
  1021. typedef struct SDL_GPUColorTargetBlendState
  1022. {
  1023. SDL_bool enable_blend;
  1024. Uint8 padding1;
  1025. Uint8 padding2;
  1026. Uint8 padding3;
  1027. SDL_GPUBlendFactor src_color_blendfactor;
  1028. SDL_GPUBlendFactor dst_color_blendfactor;
  1029. SDL_GPUBlendOp color_blend_op;
  1030. SDL_GPUBlendFactor src_alpha_blendfactor;
  1031. SDL_GPUBlendFactor dst_alpha_blendfactor;
  1032. SDL_GPUBlendOp alpha_blend_op;
  1033. SDL_GPUColorComponentFlags color_write_mask;
  1034. } SDL_GPUColorTargetBlendState;
  1035. typedef struct SDL_GPUShaderCreateInfo
  1036. {
  1037. size_t code_size;
  1038. const Uint8 *code;
  1039. const char *entrypoint;
  1040. SDL_GPUShaderFormat format;
  1041. SDL_GPUShaderStage stage;
  1042. Uint32 num_samplers;
  1043. Uint32 num_storage_textures;
  1044. Uint32 num_storage_buffers;
  1045. Uint32 num_uniform_buffers;
  1046. SDL_PropertiesID props;
  1047. } SDL_GPUShaderCreateInfo;
  1048. typedef struct SDL_GPUTextureCreateInfo
  1049. {
  1050. SDL_GPUTextureType type;
  1051. SDL_GPUTextureFormat format;
  1052. SDL_GPUTextureUsageFlags usage;
  1053. Uint32 width;
  1054. Uint32 height;
  1055. Uint32 layer_count_or_depth;
  1056. Uint32 num_levels;
  1057. SDL_GPUSampleCount sample_count;
  1058. SDL_PropertiesID props;
  1059. } SDL_GPUTextureCreateInfo;
  1060. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r"
  1061. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT "SDL.gpu.createtexture.d3d12.clear.g"
  1062. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT "SDL.gpu.createtexture.d3d12.clear.b"
  1063. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT "SDL.gpu.createtexture.d3d12.clear.a"
  1064. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.createtexture.d3d12.clear.depth"
  1065. #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8 "SDL.gpu.createtexture.d3d12.clear.stencil"
  1066. typedef struct SDL_GPUBufferCreateInfo
  1067. {
  1068. SDL_GPUBufferUsageFlags usage;
  1069. Uint32 size;
  1070. SDL_PropertiesID props;
  1071. } SDL_GPUBufferCreateInfo;
  1072. typedef struct SDL_GPUTransferBufferCreateInfo
  1073. {
  1074. SDL_GPUTransferBufferUsage usage;
  1075. Uint32 size;
  1076. SDL_PropertiesID props;
  1077. } SDL_GPUTransferBufferCreateInfo;
  1078. /* Pipeline state structures */
  1079. typedef struct SDL_GPURasterizerState
  1080. {
  1081. SDL_GPUFillMode fill_mode;
  1082. SDL_GPUCullMode cull_mode;
  1083. SDL_GPUFrontFace front_face;
  1084. SDL_bool enable_depth_bias;
  1085. Uint8 padding1;
  1086. Uint8 padding2;
  1087. Uint8 padding3;
  1088. float depth_bias_constant_factor;
  1089. float depth_bias_clamp;
  1090. float depth_bias_slope_factor;
  1091. } SDL_GPURasterizerState;
  1092. typedef struct SDL_GPUMultisampleState
  1093. {
  1094. SDL_GPUSampleCount sample_count;
  1095. Uint32 sample_mask;
  1096. } SDL_GPUMultisampleState;
  1097. typedef struct SDL_GPUDepthStencilState
  1098. {
  1099. SDL_bool enable_depth_test;
  1100. SDL_bool enable_depth_write;
  1101. SDL_bool enable_stencil_test;
  1102. Uint8 padding1;
  1103. SDL_GPUCompareOp compare_op;
  1104. SDL_GPUStencilOpState back_stencil_state;
  1105. SDL_GPUStencilOpState front_stencil_state;
  1106. Uint8 compare_mask;
  1107. Uint8 write_mask;
  1108. Uint8 padding2;
  1109. Uint8 padding3;
  1110. } SDL_GPUDepthStencilState;
  1111. typedef struct SDL_GPUColorTargetDescription
  1112. {
  1113. SDL_GPUTextureFormat format;
  1114. SDL_GPUColorTargetBlendState blend_state;
  1115. } SDL_GPUColorTargetDescription;
  1116. typedef struct SDL_GpuGraphicsPipelineTargetInfo
  1117. {
  1118. const SDL_GPUColorTargetDescription *color_target_descriptions;
  1119. Uint32 num_color_targets;
  1120. SDL_bool has_depth_stencil_target;
  1121. Uint8 padding1;
  1122. Uint8 padding2;
  1123. Uint8 padding3;
  1124. SDL_GPUTextureFormat depth_stencil_format;
  1125. } SDL_GpuGraphicsPipelineTargetInfo;
  1126. typedef struct SDL_GPUGraphicsPipelineCreateInfo
  1127. {
  1128. SDL_GPUShader *vertex_shader;
  1129. SDL_GPUShader *fragment_shader;
  1130. SDL_GPUVertexInputState vertex_input_state;
  1131. SDL_GPUPrimitiveType primitive_type;
  1132. SDL_GPURasterizerState rasterizer_state;
  1133. SDL_GPUMultisampleState multisample_state;
  1134. SDL_GPUDepthStencilState depth_stencil_state;
  1135. SDL_GpuGraphicsPipelineTargetInfo target_info;
  1136. SDL_PropertiesID props;
  1137. } SDL_GPUGraphicsPipelineCreateInfo;
  1138. typedef struct SDL_GPUComputePipelineCreateInfo
  1139. {
  1140. size_t code_size;
  1141. const Uint8 *code;
  1142. const char *entrypoint;
  1143. SDL_GPUShaderFormat format;
  1144. Uint32 num_readonly_storage_textures;
  1145. Uint32 num_readonly_storage_buffers;
  1146. Uint32 num_writeonly_storage_textures;
  1147. Uint32 num_writeonly_storage_buffers;
  1148. Uint32 num_uniform_buffers;
  1149. Uint32 threadcount_x;
  1150. Uint32 threadcount_y;
  1151. Uint32 threadcount_z;
  1152. SDL_PropertiesID props;
  1153. } SDL_GPUComputePipelineCreateInfo;
  1154. typedef struct SDL_GPUColorTargetInfo
  1155. {
  1156. /* The texture that will be used as a color target by a render pass. */
  1157. SDL_GPUTexture *texture;
  1158. Uint32 mip_level;
  1159. Uint32 layer_or_depth_plane; /* For 3D textures, you can bind an individual depth plane as a target. */
  1160. /* Can be ignored by RenderPass if CLEAR is not used */
  1161. SDL_FColor clear_color;
  1162. /* Determines what is done with the texture at the beginning of the render pass.
  1163. *
  1164. * LOAD:
  1165. * Loads the data currently in the texture.
  1166. *
  1167. * CLEAR:
  1168. * Clears the texture to a single color.
  1169. *
  1170. * DONT_CARE:
  1171. * The driver will do whatever it wants with the texture memory.
  1172. * This is a good option if you know that every single pixel will be touched in the render pass.
  1173. */
  1174. SDL_GPULoadOp load_op;
  1175. /* Determines what is done with the texture at the end of the render pass.
  1176. *
  1177. * STORE:
  1178. * Stores the results of the render pass in the texture.
  1179. *
  1180. * DONT_CARE:
  1181. * The driver will do whatever it wants with the texture memory.
  1182. * This is often a good option for depth/stencil textures.
  1183. */
  1184. SDL_GPUStoreOp store_op;
  1185. /* if SDL_TRUE, cycles the texture if the texture is bound and load_op is not LOAD */
  1186. SDL_bool cycle;
  1187. Uint8 padding1;
  1188. Uint8 padding2;
  1189. Uint8 padding3;
  1190. } SDL_GPUColorTargetInfo;
  1191. typedef struct SDL_GPUDepthStencilTargetInfo
  1192. {
  1193. /* The texture that will be used as the depth stencil target by a render pass. */
  1194. SDL_GPUTexture *texture;
  1195. /* Can be ignored by the render pass if CLEAR is not used */
  1196. SDL_GPUDepthStencilValue clear_value;
  1197. /* Determines what is done with the depth values at the beginning of the render pass.
  1198. *
  1199. * LOAD:
  1200. * Loads the depth values currently in the texture.
  1201. *
  1202. * CLEAR:
  1203. * Clears the texture to a single depth.
  1204. *
  1205. * DONT_CARE:
  1206. * The driver will do whatever it wants with the memory.
  1207. * This is a good option if you know that every single pixel will be touched in the render pass.
  1208. */
  1209. SDL_GPULoadOp load_op;
  1210. /* Determines what is done with the depth values at the end of the render pass.
  1211. *
  1212. * STORE:
  1213. * Stores the depth results in the texture.
  1214. *
  1215. * DONT_CARE:
  1216. * The driver will do whatever it wants with the texture memory.
  1217. * This is often a good option for depth/stencil textures.
  1218. */
  1219. SDL_GPUStoreOp store_op;
  1220. /* Determines what is done with the stencil values at the beginning of the render pass.
  1221. *
  1222. * LOAD:
  1223. * Loads the stencil values currently in the texture.
  1224. *
  1225. * CLEAR:
  1226. * Clears the texture to a single stencil value.
  1227. *
  1228. * DONT_CARE:
  1229. * The driver will do whatever it wants with the memory.
  1230. * This is a good option if you know that every single pixel will be touched in the render pass.
  1231. */
  1232. SDL_GPULoadOp stencil_load_op;
  1233. /* Determines what is done with the stencil values at the end of the render pass.
  1234. *
  1235. * STORE:
  1236. * Stores the stencil results in the texture.
  1237. *
  1238. * DONT_CARE:
  1239. * The driver will do whatever it wants with the texture memory.
  1240. * This is often a good option for depth/stencil textures.
  1241. */
  1242. SDL_GPUStoreOp stencil_store_op;
  1243. /* if SDL_TRUE, cycles the texture if the texture is bound and any load ops are not LOAD */
  1244. SDL_bool cycle;
  1245. Uint8 padding1;
  1246. Uint8 padding2;
  1247. Uint8 padding3;
  1248. } SDL_GPUDepthStencilTargetInfo;
  1249. /* Binding structs */
  1250. typedef struct SDL_GPUBufferBinding
  1251. {
  1252. SDL_GPUBuffer *buffer;
  1253. Uint32 offset;
  1254. } SDL_GPUBufferBinding;
  1255. typedef struct SDL_GPUTextureSamplerBinding
  1256. {
  1257. SDL_GPUTexture *texture;
  1258. SDL_GPUSampler *sampler;
  1259. } SDL_GPUTextureSamplerBinding;
  1260. typedef struct SDL_GPUStorageBufferWriteOnlyBinding
  1261. {
  1262. SDL_GPUBuffer *buffer;
  1263. /* if SDL_TRUE, cycles the buffer if it is bound. */
  1264. SDL_bool cycle;
  1265. Uint8 padding1;
  1266. Uint8 padding2;
  1267. Uint8 padding3;
  1268. } SDL_GPUStorageBufferWriteOnlyBinding;
  1269. typedef struct SDL_GPUStorageTextureWriteOnlyBinding
  1270. {
  1271. SDL_GPUTexture *texture;
  1272. Uint32 mip_level;
  1273. Uint32 layer;
  1274. /* if SDL_TRUE, cycles the texture if the texture is bound. */
  1275. SDL_bool cycle;
  1276. Uint8 padding1;
  1277. Uint8 padding2;
  1278. Uint8 padding3;
  1279. } SDL_GPUStorageTextureWriteOnlyBinding;
  1280. /* Functions */
  1281. /* Device */
  1282. /**
  1283. * Creates a GPU context.
  1284. *
  1285. * \param format_flags a bitflag indicating which shader formats the app is
  1286. * able to provide.
  1287. * \param debug_mode enable debug mode properties and validations.
  1288. * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
  1289. * driver.
  1290. * \returns a GPU context on success or NULL on failure.
  1291. *
  1292. * \since This function is available since SDL 3.0.0.
  1293. *
  1294. * \sa SDL_GetGPUDriver
  1295. * \sa SDL_DestroyGPUDevice
  1296. */
  1297. extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDevice(
  1298. SDL_GPUShaderFormat format_flags,
  1299. SDL_bool debug_mode,
  1300. const char *name);
  1301. /**
  1302. * Creates a GPU context.
  1303. *
  1304. * These are the supported properties:
  1305. *
  1306. * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL`: enable debug mode properties
  1307. * and validations, defaults to SDL_TRUE.
  1308. * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL`: enable to prefer energy
  1309. * efficiency over maximum GPU performance, defaults to SDL_FALSE.
  1310. * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to
  1311. * use, if a specific one is desired.
  1312. *
  1313. * These are the current shader format properties:
  1314. *
  1315. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOL`: The app is able to
  1316. * provide shaders for an NDA platform.
  1317. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL`: The app is able to
  1318. * provide SPIR-V shaders if applicable.
  1319. * - SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL`: The app is able to provide
  1320. * DXBC shaders if applicable
  1321. * `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL`: The app is able to
  1322. * provide DXIL shaders if applicable.
  1323. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL`: The app is able to provide
  1324. * MSL shaders if applicable.
  1325. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL`: The app is able to
  1326. * provide Metal shader libraries if applicable.
  1327. *
  1328. * With the D3D12 renderer:
  1329. *
  1330. * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to
  1331. * use for all vertex semantics, default is "TEXCOORD".
  1332. *
  1333. * \param props the properties to use.
  1334. * \returns a GPU context on success or NULL on failure.
  1335. *
  1336. * \since This function is available since SDL 3.0.0.
  1337. *
  1338. * \sa SDL_GetGPUDriver
  1339. * \sa SDL_DestroyGPUDevice
  1340. */
  1341. extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDeviceWithProperties(
  1342. SDL_PropertiesID props);
  1343. #define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL "SDL.gpu.device.create.debugmode"
  1344. #define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL "SDL.gpu.device.create.preferlowpower"
  1345. #define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name"
  1346. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOL "SDL.gpu.device.create.shaders.private"
  1347. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL "SDL.gpu.device.create.shaders.spirv"
  1348. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL "SDL.gpu.device.create.shaders.dxbc"
  1349. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL "SDL.gpu.device.create.shaders.dxil"
  1350. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL "SDL.gpu.device.create.shaders.msl"
  1351. #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL "SDL.gpu.device.create.shaders.metallib"
  1352. #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
  1353. /**
  1354. * Destroys a GPU context previously returned by SDL_CreateGPUDevice.
  1355. *
  1356. * \param device a GPU Context to destroy.
  1357. *
  1358. * \since This function is available since SDL 3.0.0.
  1359. *
  1360. * \sa SDL_CreateGPUDevice
  1361. */
  1362. extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device);
  1363. /**
  1364. * Returns the backend used to create this GPU context.
  1365. *
  1366. * \param device a GPU context to query.
  1367. * \returns an SDL_GPUDriver value, or SDL_GPU_DRIVER_INVALID on error.
  1368. *
  1369. * \since This function is available since SDL 3.0.0.
  1370. */
  1371. extern SDL_DECLSPEC SDL_GPUDriver SDLCALL SDL_GetGPUDriver(SDL_GPUDevice *device);
  1372. /* State Creation */
  1373. /**
  1374. * Creates a pipeline object to be used in a compute workflow.
  1375. *
  1376. * Shader resource bindings must be authored to follow a particular order
  1377. * depending on the shader format.
  1378. *
  1379. * For SPIR-V shaders, use the following resource sets:
  1380. *
  1381. * - 0: Read-only storage textures, followed by read-only storage buffers
  1382. * - 1: Write-only storage textures, followed by write-only storage buffers
  1383. * - 2: Uniform buffers
  1384. *
  1385. * For DXBC Shader Model 5_0 shaders, use the following register order:
  1386. *
  1387. * - t registers: Read-only storage textures, followed by read-only storage
  1388. * buffers
  1389. * - u registers: Write-only storage textures, followed by write-only storage
  1390. * buffers
  1391. * - b registers: Uniform buffers
  1392. *
  1393. * For DXIL shaders, use the following register order:
  1394. *
  1395. * - (t[n], space0): Read-only storage textures, followed by read-only storage
  1396. * buffers
  1397. * - (u[n], space1): Write-only storage textures, followed by write-only
  1398. * storage buffers
  1399. * - (b[n], space2): Uniform buffers
  1400. *
  1401. * For MSL/metallib, use the following order:
  1402. *
  1403. * - [[buffer]]: Uniform buffers, followed by write-only storage buffers,
  1404. * followed by write-only storage buffers
  1405. * - [[texture]]: Read-only storage textures, followed by write-only storage
  1406. * textures
  1407. *
  1408. * \param device a GPU Context.
  1409. * \param createinfo a struct describing the state of the compute pipeline to
  1410. * create.
  1411. * \returns a compute pipeline object on success, or NULL on failure.
  1412. *
  1413. * \since This function is available since SDL 3.0.0.
  1414. *
  1415. * \sa SDL_BindGPUComputePipeline
  1416. * \sa SDL_ReleaseGPUComputePipeline
  1417. */
  1418. extern SDL_DECLSPEC SDL_GPUComputePipeline *SDLCALL SDL_CreateGPUComputePipeline(
  1419. SDL_GPUDevice *device,
  1420. const SDL_GPUComputePipelineCreateInfo *createinfo);
  1421. /**
  1422. * Creates a pipeline object to be used in a graphics workflow.
  1423. *
  1424. * \param device a GPU Context.
  1425. * \param createinfo a struct describing the state of the graphics pipeline to
  1426. * create.
  1427. * \returns a graphics pipeline object on success, or NULL on failure.
  1428. *
  1429. * \since This function is available since SDL 3.0.0.
  1430. *
  1431. * \sa SDL_CreateGPUShader
  1432. * \sa SDL_BindGPUGraphicsPipeline
  1433. * \sa SDL_ReleaseGPUGraphicsPipeline
  1434. */
  1435. extern SDL_DECLSPEC SDL_GPUGraphicsPipeline *SDLCALL SDL_CreateGPUGraphicsPipeline(
  1436. SDL_GPUDevice *device,
  1437. const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
  1438. /**
  1439. * Creates a sampler object to be used when binding textures in a graphics
  1440. * workflow.
  1441. *
  1442. * \param device a GPU Context.
  1443. * \param createinfo a struct describing the state of the sampler to create.
  1444. * \returns a sampler object on success, or NULL on failure.
  1445. *
  1446. * \since This function is available since SDL 3.0.0.
  1447. *
  1448. * \sa SDL_BindGPUVertexSamplers
  1449. * \sa SDL_BindGPUFragmentSamplers
  1450. * \sa SDL_ReleaseSampler
  1451. */
  1452. extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(
  1453. SDL_GPUDevice *device,
  1454. const SDL_GPUSamplerCreateInfo *createinfo);
  1455. /**
  1456. * Creates a shader to be used when creating a graphics pipeline.
  1457. *
  1458. * Shader resource bindings must be authored to follow a particular order
  1459. * depending on the shader format.
  1460. *
  1461. * For SPIR-V shaders, use the following resource sets:
  1462. *
  1463. * For vertex shaders:
  1464. *
  1465. * - 0: Sampled textures, followed by storage textures, followed by storage
  1466. * buffers
  1467. * - 1: Uniform buffers
  1468. *
  1469. * For fragment shaders:
  1470. *
  1471. * - 2: Sampled textures, followed by storage textures, followed by storage
  1472. * buffers
  1473. * - 3: Uniform buffers
  1474. *
  1475. * For DXBC Shader Model 5_0 shaders, use the following register order:
  1476. *
  1477. * - t registers: Sampled textures, followed by storage textures, followed by
  1478. * storage buffers
  1479. * - s registers: Samplers with indices corresponding to the sampled textures
  1480. * - b registers: Uniform buffers
  1481. *
  1482. * For DXIL shaders, use the following register order:
  1483. *
  1484. * For vertex shaders:
  1485. *
  1486. * - (t[n], space0): Sampled textures, followed by storage textures, followed
  1487. * by storage buffers
  1488. * - (s[n], space0): Samplers with indices corresponding to the sampled
  1489. * textures
  1490. * - (b[n], space1): Uniform buffers
  1491. *
  1492. * For pixel shaders:
  1493. *
  1494. * - (t[n], space2): Sampled textures, followed by storage textures, followed
  1495. * by storage buffers
  1496. * - (s[n], space2): Samplers with indices corresponding to the sampled
  1497. * textures
  1498. * - (b[n], space3): Uniform buffers
  1499. *
  1500. * For MSL/metallib, use the following order:
  1501. *
  1502. * - [[texture]]: Sampled textures, followed by storage textures
  1503. * - [[sampler]]: Samplers with indices corresponding to the sampled textures
  1504. * - [[buffer]]: Uniform buffers, followed by storage buffers. Vertex buffer 0
  1505. * is bound at [[buffer(30)]], vertex buffer 1 at [[buffer(29)]], and so on.
  1506. * Rather than manually authoring vertex buffer indices, use the
  1507. * [[stage_in]] attribute which will automatically use the vertex input
  1508. * information from the SDL_GPUPipeline.
  1509. *
  1510. * \param device a GPU Context.
  1511. * \param createinfo a struct describing the state of the shader to create.
  1512. * \returns a shader object on success, or NULL on failure.
  1513. *
  1514. * \since This function is available since SDL 3.0.0.
  1515. *
  1516. * \sa SDL_CreateGPUGraphicsPipeline
  1517. * \sa SDL_ReleaseGPUShader
  1518. */
  1519. extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader(
  1520. SDL_GPUDevice *device,
  1521. const SDL_GPUShaderCreateInfo *createinfo);
  1522. /**
  1523. * Creates a texture object to be used in graphics or compute workflows.
  1524. *
  1525. * The contents of this texture are undefined until data is written to the
  1526. * texture.
  1527. *
  1528. * Note that certain combinations of usage flags are invalid. For example, a
  1529. * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags.
  1530. *
  1531. * If you request a sample count higher than the hardware supports, the
  1532. * implementation will automatically fall back to the highest available sample
  1533. * count.
  1534. *
  1535. * \param device a GPU Context.
  1536. * \param createinfo a struct describing the state of the texture to create.
  1537. * \returns a texture object on success, or NULL on failure.
  1538. *
  1539. * \since This function is available since SDL 3.0.0.
  1540. *
  1541. * \sa SDL_UploadToGPUTexture
  1542. * \sa SDL_DownloadFromGPUTexture
  1543. * \sa SDL_BindGPUVertexSamplers
  1544. * \sa SDL_BindGPUVertexStorageTextures
  1545. * \sa SDL_BindGPUFragmentSamplers
  1546. * \sa SDL_BindGPUFragmentStorageTextures
  1547. * \sa SDL_BindGPUComputeStorageTextures
  1548. * \sa SDL_BlitGPUTexture
  1549. * \sa SDL_ReleaseGPUTexture
  1550. * \sa SDL_GPUTextureSupportsFormat
  1551. */
  1552. extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture(
  1553. SDL_GPUDevice *device,
  1554. const SDL_GPUTextureCreateInfo *createinfo);
  1555. /**
  1556. * Creates a buffer object to be used in graphics or compute workflows.
  1557. *
  1558. * The contents of this buffer are undefined until data is written to the
  1559. * buffer.
  1560. *
  1561. * Note that certain combinations of usage flags are invalid. For example, a
  1562. * buffer cannot have both the VERTEX and INDEX flags.
  1563. *
  1564. * \param device a GPU Context.
  1565. * \param createinfo a struct describing the state of the buffer to create.
  1566. * \returns a buffer object on success, or NULL on failure.
  1567. *
  1568. * \since This function is available since SDL 3.0.0.
  1569. *
  1570. * \sa SDL_SetGPUBufferName
  1571. * \sa SDL_UploadToGPUBuffer
  1572. * \sa SDL_DownloadFromGPUBuffer
  1573. * \sa SDL_CopyGPUBufferToBuffer
  1574. * \sa SDL_BindGPUVertexBuffers
  1575. * \sa SDL_BindGPUIndexBuffer
  1576. * \sa SDL_BindGPUVertexStorageBuffers
  1577. * \sa SDL_BindGPUFragmentStorageBuffers
  1578. * \sa SDL_DrawGPUPrimitivesIndirect
  1579. * \sa SDL_DrawGPUIndexedPrimitivesIndirect
  1580. * \sa SDL_BindGPUComputeStorageBuffers
  1581. * \sa SDL_DispatchGPUComputeIndirect
  1582. * \sa SDL_ReleaseGPUBuffer
  1583. */
  1584. extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer(
  1585. SDL_GPUDevice *device,
  1586. const SDL_GPUBufferCreateInfo *createinfo);
  1587. /**
  1588. * Creates a transfer buffer to be used when uploading to or downloading from
  1589. * graphics resources.
  1590. *
  1591. * \param device a GPU Context.
  1592. * \param createinfo a struct describing the state of the transfer buffer to
  1593. * create.
  1594. * \returns a transfer buffer on success, or NULL on failure.
  1595. *
  1596. * \since This function is available since SDL 3.0.0.
  1597. *
  1598. * \sa SDL_UploadToGPUBuffer
  1599. * \sa SDL_DownloadFromGPUBuffer
  1600. * \sa SDL_UploadToGPUTexture
  1601. * \sa SDL_DownloadFromGPUTexture
  1602. * \sa SDL_ReleaseGPUTransferBuffer
  1603. */
  1604. extern SDL_DECLSPEC SDL_GPUTransferBuffer *SDLCALL SDL_CreateGPUTransferBuffer(
  1605. SDL_GPUDevice *device,
  1606. const SDL_GPUTransferBufferCreateInfo *createinfo);
  1607. /* Debug Naming */
  1608. /**
  1609. * Sets an arbitrary string constant to label a buffer.
  1610. *
  1611. * Useful for debugging.
  1612. *
  1613. * \param device a GPU Context.
  1614. * \param buffer a buffer to attach the name to.
  1615. * \param text a UTF-8 string constant to mark as the name of the buffer.
  1616. *
  1617. * \since This function is available since SDL 3.0.0.
  1618. */
  1619. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName(
  1620. SDL_GPUDevice *device,
  1621. SDL_GPUBuffer *buffer,
  1622. const char *text);
  1623. /**
  1624. * Sets an arbitrary string constant to label a texture.
  1625. *
  1626. * Useful for debugging.
  1627. *
  1628. * \param device a GPU Context.
  1629. * \param texture a texture to attach the name to.
  1630. * \param text a UTF-8 string constant to mark as the name of the texture.
  1631. *
  1632. * \since This function is available since SDL 3.0.0.
  1633. */
  1634. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName(
  1635. SDL_GPUDevice *device,
  1636. SDL_GPUTexture *texture,
  1637. const char *text);
  1638. /**
  1639. * Inserts an arbitrary string label into the command buffer callstream.
  1640. *
  1641. * Useful for debugging.
  1642. *
  1643. * \param command_buffer a command buffer.
  1644. * \param text a UTF-8 string constant to insert as the label.
  1645. *
  1646. * \since This function is available since SDL 3.0.0.
  1647. */
  1648. extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
  1649. SDL_GPUCommandBuffer *command_buffer,
  1650. const char *text);
  1651. /**
  1652. * Begins a debug group with an arbitary name.
  1653. *
  1654. * Used for denoting groups of calls when viewing the command buffer
  1655. * callstream in a graphics debugging tool.
  1656. *
  1657. * Each call to SDL_PushGPUDebugGroup must have a corresponding call to
  1658. * SDL_PopGPUDebugGroup.
  1659. *
  1660. * On some backends (e.g. Metal), pushing a debug group during a
  1661. * render/blit/compute pass will create a group that is scoped to the native
  1662. * pass rather than the command buffer. For best results, if you push a debug
  1663. * group during a pass, always pop it in the same pass.
  1664. *
  1665. * \param command_buffer a command buffer.
  1666. * \param name a UTF-8 string constant that names the group.
  1667. *
  1668. * \since This function is available since SDL 3.0.0.
  1669. *
  1670. * \sa SDL_PopGPUDebugGroup
  1671. */
  1672. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup(
  1673. SDL_GPUCommandBuffer *command_buffer,
  1674. const char *name);
  1675. /**
  1676. * Ends the most-recently pushed debug group.
  1677. *
  1678. * \param command_buffer a command buffer.
  1679. *
  1680. * \since This function is available since SDL 3.0.0.
  1681. *
  1682. * \sa SDL_PushGPUDebugGroup
  1683. */
  1684. extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup(
  1685. SDL_GPUCommandBuffer *command_buffer);
  1686. /* Disposal */
  1687. /**
  1688. * Frees the given texture as soon as it is safe to do so.
  1689. *
  1690. * You must not reference the texture after calling this function.
  1691. *
  1692. * \param device a GPU context.
  1693. * \param texture a texture to be destroyed.
  1694. *
  1695. * \since This function is available since SDL 3.0.0.
  1696. */
  1697. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture(
  1698. SDL_GPUDevice *device,
  1699. SDL_GPUTexture *texture);
  1700. /**
  1701. * Frees the given sampler as soon as it is safe to do so.
  1702. *
  1703. * You must not reference the texture after calling this function.
  1704. *
  1705. * \param device a GPU context.
  1706. * \param sampler a sampler to be destroyed.
  1707. *
  1708. * \since This function is available since SDL 3.0.0.
  1709. */
  1710. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler(
  1711. SDL_GPUDevice *device,
  1712. SDL_GPUSampler *sampler);
  1713. /**
  1714. * Frees the given buffer as soon as it is safe to do so.
  1715. *
  1716. * You must not reference the buffer after calling this function.
  1717. *
  1718. * \param device a GPU context.
  1719. * \param buffer a buffer to be destroyed.
  1720. *
  1721. * \since This function is available since SDL 3.0.0.
  1722. */
  1723. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer(
  1724. SDL_GPUDevice *device,
  1725. SDL_GPUBuffer *buffer);
  1726. /**
  1727. * Frees the given transfer buffer as soon as it is safe to do so.
  1728. *
  1729. * You must not reference the transfer buffer after calling this function.
  1730. *
  1731. * \param device a GPU context.
  1732. * \param transfer_buffer a transfer buffer to be destroyed.
  1733. *
  1734. * \since This function is available since SDL 3.0.0.
  1735. */
  1736. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer(
  1737. SDL_GPUDevice *device,
  1738. SDL_GPUTransferBuffer *transfer_buffer);
  1739. /**
  1740. * Frees the given compute pipeline as soon as it is safe to do so.
  1741. *
  1742. * You must not reference the compute pipeline after calling this function.
  1743. *
  1744. * \param device a GPU context.
  1745. * \param compute_pipeline a compute pipeline to be destroyed.
  1746. *
  1747. * \since This function is available since SDL 3.0.0.
  1748. */
  1749. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline(
  1750. SDL_GPUDevice *device,
  1751. SDL_GPUComputePipeline *compute_pipeline);
  1752. /**
  1753. * Frees the given shader as soon as it is safe to do so.
  1754. *
  1755. * You must not reference the shader after calling this function.
  1756. *
  1757. * \param device a GPU context.
  1758. * \param shader a shader to be destroyed.
  1759. *
  1760. * \since This function is available since SDL 3.0.0.
  1761. */
  1762. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader(
  1763. SDL_GPUDevice *device,
  1764. SDL_GPUShader *shader);
  1765. /**
  1766. * Frees the given graphics pipeline as soon as it is safe to do so.
  1767. *
  1768. * You must not reference the graphics pipeline after calling this function.
  1769. *
  1770. * \param device a GPU context.
  1771. * \param graphics_pipeline a graphics pipeline to be destroyed.
  1772. *
  1773. * \since This function is available since SDL 3.0.0.
  1774. */
  1775. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline(
  1776. SDL_GPUDevice *device,
  1777. SDL_GPUGraphicsPipeline *graphics_pipeline);
  1778. /**
  1779. * Acquire a command buffer.
  1780. *
  1781. * This command buffer is managed by the implementation and should not be
  1782. * freed by the user. The command buffer may only be used on the thread it was
  1783. * acquired on. The command buffer should be submitted on the thread it was
  1784. * acquired on.
  1785. *
  1786. * \param device a GPU context.
  1787. * \returns a command buffer.
  1788. *
  1789. * \since This function is available since SDL 3.0.0.
  1790. *
  1791. * \sa SDL_SubmitGPUCommandBuffer
  1792. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  1793. */
  1794. extern SDL_DECLSPEC SDL_GPUCommandBuffer *SDLCALL SDL_AcquireGPUCommandBuffer(
  1795. SDL_GPUDevice *device);
  1796. /*
  1797. * UNIFORM DATA
  1798. *
  1799. * Uniforms are for passing data to shaders.
  1800. * The uniform data will be constant across all executions of the shader.
  1801. *
  1802. * There are 4 available uniform slots per shader stage (vertex, fragment, compute).
  1803. * Uniform data pushed to a slot on a stage keeps its value throughout the command buffer
  1804. * until you call the relevant Push function on that slot again.
  1805. *
  1806. * For example, you could write your vertex shaders to read a camera matrix from uniform binding slot 0,
  1807. * push the camera matrix at the start of the command buffer, and that data will be used for every
  1808. * subsequent draw call.
  1809. *
  1810. * It is valid to push uniform data during a render or compute pass.
  1811. *
  1812. * Uniforms are best for pushing small amounts of data.
  1813. * If you are pushing more than a matrix or two per call you should consider using a storage buffer instead.
  1814. */
  1815. /**
  1816. * Pushes data to a vertex uniform slot on the command buffer.
  1817. *
  1818. * Subsequent draw calls will use this uniform data.
  1819. *
  1820. * \param command_buffer a command buffer.
  1821. * \param slot_index the vertex uniform slot to push data to.
  1822. * \param data client data to write.
  1823. * \param length the length of the data to write.
  1824. *
  1825. * \since This function is available since SDL 3.0.0.
  1826. */
  1827. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData(
  1828. SDL_GPUCommandBuffer *command_buffer,
  1829. Uint32 slot_index,
  1830. const void *data,
  1831. Uint32 length);
  1832. /**
  1833. * Pushes data to a fragment uniform slot on the command buffer.
  1834. *
  1835. * Subsequent draw calls will use this uniform data.
  1836. *
  1837. * \param command_buffer a command buffer.
  1838. * \param slot_index the fragment uniform slot to push data to.
  1839. * \param data client data to write.
  1840. * \param length the length of the data to write.
  1841. *
  1842. * \since This function is available since SDL 3.0.0.
  1843. */
  1844. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData(
  1845. SDL_GPUCommandBuffer *command_buffer,
  1846. Uint32 slot_index,
  1847. const void *data,
  1848. Uint32 length);
  1849. /**
  1850. * Pushes data to a uniform slot on the command buffer.
  1851. *
  1852. * Subsequent draw calls will use this uniform data.
  1853. *
  1854. * \param command_buffer a command buffer.
  1855. * \param slot_index the uniform slot to push data to.
  1856. * \param data client data to write.
  1857. * \param length the length of the data to write.
  1858. *
  1859. * \since This function is available since SDL 3.0.0.
  1860. */
  1861. extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData(
  1862. SDL_GPUCommandBuffer *command_buffer,
  1863. Uint32 slot_index,
  1864. const void *data,
  1865. Uint32 length);
  1866. /*
  1867. * A NOTE ON CYCLING
  1868. *
  1869. * When using a command buffer, operations do not occur immediately -
  1870. * they occur some time after the command buffer is submitted.
  1871. *
  1872. * When a resource is used in a pending or active command buffer, it is considered to be "bound".
  1873. * When a resource is no longer used in any pending or active command buffers, it is considered to be "unbound".
  1874. *
  1875. * If data resources are bound, it is unspecified when that data will be unbound
  1876. * unless you acquire a fence when submitting the command buffer and wait on it.
  1877. * However, this doesn't mean you need to track resource usage manually.
  1878. *
  1879. * All of the functions and structs that involve writing to a resource have a "cycle" bool.
  1880. * GPUTransferBuffer, GPUBuffer, and GPUTexture all effectively function as ring buffers on internal resources.
  1881. * When cycle is SDL_TRUE, if the resource is bound, the cycle rotates to the next unbound internal resource,
  1882. * or if none are available, a new one is created.
  1883. * This means you don't have to worry about complex state tracking and synchronization as long as cycling is correctly employed.
  1884. *
  1885. * For example: you can call MapTransferBuffer, write texture data, UnmapTransferBuffer, and then UploadToTexture.
  1886. * The next time you write texture data to the transfer buffer, if you set the cycle param to SDL_TRUE, you don't have
  1887. * to worry about overwriting any data that is not yet uploaded.
  1888. *
  1889. * Another example: If you are using a texture in a render pass every frame, this can cause a data dependency between frames.
  1890. * If you set cycle to SDL_TRUE in the SDL_GPUColorTargetInfo struct, you can prevent this data dependency.
  1891. *
  1892. * Cycling will never undefine already bound data.
  1893. * When cycling, all data in the resource is considered to be undefined for subsequent commands until that data is written again.
  1894. * You must take care not to read undefined data.
  1895. *
  1896. * Note that when cycling a texture, the entire texture will be cycled,
  1897. * even if only part of the texture is used in the call,
  1898. * so you must consider the entire texture to contain undefined data after cycling.
  1899. *
  1900. * You must also take care not to overwrite a section of data that has been referenced in a command without cycling first.
  1901. * It is OK to overwrite unreferenced data in a bound resource without cycling,
  1902. * but overwriting a section of data that has already been referenced will produce unexpected results.
  1903. */
  1904. /* Graphics State */
  1905. /**
  1906. * Begins a render pass on a command buffer.
  1907. *
  1908. * A render pass consists of a set of texture subresources (or depth slices in
  1909. * the 3D texture case) which will be rendered to during the render pass,
  1910. * along with corresponding clear values and load/store operations. All
  1911. * operations related to graphics pipelines must take place inside of a render
  1912. * pass. A default viewport and scissor state are automatically set when this
  1913. * is called. You cannot begin another render pass, or begin a compute pass or
  1914. * copy pass until you have ended the render pass.
  1915. *
  1916. * \param command_buffer a command buffer.
  1917. * \param color_target_infos an array of texture subresources with
  1918. * corresponding clear values and load/store ops.
  1919. * \param num_color_targets the number of color targets in the
  1920. * color_target_infos array.
  1921. * \param depth_stencil_target_info a texture subresource with corresponding
  1922. * clear value and load/store ops, may be
  1923. * NULL.
  1924. * \returns a render pass handle.
  1925. *
  1926. * \since This function is available since SDL 3.0.0.
  1927. *
  1928. * \sa SDL_EndGPURenderPass
  1929. */
  1930. extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(
  1931. SDL_GPUCommandBuffer *command_buffer,
  1932. const SDL_GPUColorTargetInfo *color_target_infos,
  1933. Uint32 num_color_targets,
  1934. const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info);
  1935. /**
  1936. * Binds a graphics pipeline on a render pass to be used in rendering.
  1937. *
  1938. * A graphics pipeline must be bound before making any draw calls.
  1939. *
  1940. * \param render_pass a render pass handle.
  1941. * \param graphics_pipeline the graphics pipeline to bind.
  1942. *
  1943. * \since This function is available since SDL 3.0.0.
  1944. */
  1945. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline(
  1946. SDL_GPURenderPass *render_pass,
  1947. SDL_GPUGraphicsPipeline *graphics_pipeline);
  1948. /**
  1949. * Sets the current viewport state on a command buffer.
  1950. *
  1951. * \param render_pass a render pass handle.
  1952. * \param viewport the viewport to set.
  1953. *
  1954. * \since This function is available since SDL 3.0.0.
  1955. */
  1956. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport(
  1957. SDL_GPURenderPass *render_pass,
  1958. const SDL_GPUViewport *viewport);
  1959. /**
  1960. * Sets the current scissor state on a command buffer.
  1961. *
  1962. * \param render_pass a render pass handle.
  1963. * \param scissor the scissor area to set.
  1964. *
  1965. * \since This function is available since SDL 3.0.0.
  1966. */
  1967. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor(
  1968. SDL_GPURenderPass *render_pass,
  1969. const SDL_Rect *scissor);
  1970. /**
  1971. * Sets the current blend constants on a command buffer.
  1972. *
  1973. * \param render_pass a render pass handle.
  1974. * \param blend_constants the blend constant color.
  1975. *
  1976. * \since This function is available since SDL 3.0.0.
  1977. *
  1978. * \sa SDL_GPU_BLENDFACTOR_CONSTANT_COLOR
  1979. * \sa SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR
  1980. */
  1981. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBlendConstants(
  1982. SDL_GPURenderPass *render_pass,
  1983. SDL_FColor blend_constants);
  1984. /**
  1985. * Sets the current stencil reference value on a command buffer.
  1986. *
  1987. * \param render_pass a render pass handle.
  1988. * \param reference the stencil reference value to set.
  1989. *
  1990. * \since This function is available since SDL 3.0.0.
  1991. */
  1992. extern SDL_DECLSPEC void SDLCALL SDL_SetGPUStencilReference(
  1993. SDL_GPURenderPass *render_pass,
  1994. Uint8 reference);
  1995. /**
  1996. * Binds vertex buffers on a command buffer for use with subsequent draw
  1997. * calls.
  1998. *
  1999. * \param render_pass a render pass handle.
  2000. * \param first_binding the starting bind point for the vertex buffers.
  2001. * \param bindings an array of SDL_GPUBufferBinding structs containing vertex
  2002. * buffers and offset values.
  2003. * \param num_bindings the number of bindings in the bindings array.
  2004. *
  2005. * \since This function is available since SDL 3.0.0.
  2006. */
  2007. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(
  2008. SDL_GPURenderPass *render_pass,
  2009. Uint32 first_binding,
  2010. const SDL_GPUBufferBinding *bindings,
  2011. Uint32 num_bindings);
  2012. /**
  2013. * Binds an index buffer on a command buffer for use with subsequent draw
  2014. * calls.
  2015. *
  2016. * \param render_pass a render pass handle.
  2017. * \param binding a pointer to a struct containing an index buffer and offset.
  2018. * \param index_element_size whether the index values in the buffer are 16- or
  2019. * 32-bit.
  2020. *
  2021. * \since This function is available since SDL 3.0.0.
  2022. */
  2023. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer(
  2024. SDL_GPURenderPass *render_pass,
  2025. const SDL_GPUBufferBinding *binding,
  2026. SDL_GPUIndexElementSize index_element_size);
  2027. /**
  2028. * Binds texture-sampler pairs for use on the vertex shader.
  2029. *
  2030. * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
  2031. *
  2032. * \param render_pass a render pass handle.
  2033. * \param first_slot the vertex sampler slot to begin binding from.
  2034. * \param texture_sampler_bindings an array of texture-sampler binding
  2035. * structs.
  2036. * \param num_bindings the number of texture-sampler pairs to bind from the
  2037. * array.
  2038. *
  2039. * \since This function is available since SDL 3.0.0.
  2040. */
  2041. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(
  2042. SDL_GPURenderPass *render_pass,
  2043. Uint32 first_slot,
  2044. const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
  2045. Uint32 num_bindings);
  2046. /**
  2047. * Binds storage textures for use on the vertex shader.
  2048. *
  2049. * These textures must have been created with
  2050. * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ.
  2051. *
  2052. * \param render_pass a render pass handle.
  2053. * \param first_slot the vertex storage texture slot to begin binding from.
  2054. * \param storage_textures an array of storage textures.
  2055. * \param num_bindings the number of storage texture to bind from the array.
  2056. *
  2057. * \since This function is available since SDL 3.0.0.
  2058. */
  2059. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures(
  2060. SDL_GPURenderPass *render_pass,
  2061. Uint32 first_slot,
  2062. SDL_GPUTexture *const *storage_textures,
  2063. Uint32 num_bindings);
  2064. /**
  2065. * Binds storage buffers for use on the vertex shader.
  2066. *
  2067. * These buffers must have been created with
  2068. * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ.
  2069. *
  2070. * \param render_pass a render pass handle.
  2071. * \param first_slot the vertex storage buffer slot to begin binding from.
  2072. * \param storage_buffers an array of buffers.
  2073. * \param num_bindings the number of buffers to bind from the array.
  2074. *
  2075. * \since This function is available since SDL 3.0.0.
  2076. */
  2077. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers(
  2078. SDL_GPURenderPass *render_pass,
  2079. Uint32 first_slot,
  2080. SDL_GPUBuffer *const *storage_buffers,
  2081. Uint32 num_bindings);
  2082. /**
  2083. * Binds texture-sampler pairs for use on the fragment shader.
  2084. *
  2085. * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER.
  2086. *
  2087. * \param render_pass a render pass handle.
  2088. * \param first_slot the fragment sampler slot to begin binding from.
  2089. * \param texture_sampler_bindings an array of texture-sampler binding
  2090. * structs.
  2091. * \param num_bindings the number of texture-sampler pairs to bind from the
  2092. * array.
  2093. *
  2094. * \since This function is available since SDL 3.0.0.
  2095. */
  2096. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(
  2097. SDL_GPURenderPass *render_pass,
  2098. Uint32 first_slot,
  2099. const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
  2100. Uint32 num_bindings);
  2101. /**
  2102. * Binds storage textures for use on the fragment shader.
  2103. *
  2104. * These textures must have been created with
  2105. * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ.
  2106. *
  2107. * \param render_pass a render pass handle.
  2108. * \param first_slot the fragment storage texture slot to begin binding from.
  2109. * \param storage_textures an array of storage textures.
  2110. * \param num_bindings the number of storage textures to bind from the array.
  2111. *
  2112. * \since This function is available since SDL 3.0.0.
  2113. */
  2114. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(
  2115. SDL_GPURenderPass *render_pass,
  2116. Uint32 first_slot,
  2117. SDL_GPUTexture *const *storage_textures,
  2118. Uint32 num_bindings);
  2119. /**
  2120. * Binds storage buffers for use on the fragment shader.
  2121. *
  2122. * These buffers must have been created with
  2123. * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ.
  2124. *
  2125. * \param render_pass a render pass handle.
  2126. * \param first_slot the fragment storage buffer slot to begin binding from.
  2127. * \param storage_buffers an array of storage buffers.
  2128. * \param num_bindings the number of storage buffers to bind from the array.
  2129. *
  2130. * \since This function is available since SDL 3.0.0.
  2131. */
  2132. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(
  2133. SDL_GPURenderPass *render_pass,
  2134. Uint32 first_slot,
  2135. SDL_GPUBuffer *const *storage_buffers,
  2136. Uint32 num_bindings);
  2137. /* Drawing */
  2138. /**
  2139. * Draws data using bound graphics state with an index buffer and instancing
  2140. * enabled.
  2141. *
  2142. * You must not call this function before binding a graphics pipeline.
  2143. *
  2144. * Note that the `first_vertex` and `first_instance` parameters are NOT
  2145. * compatible with built-in vertex/instance ID variables in shaders (for
  2146. * example, SV_VertexID). If your shader depends on these variables, the
  2147. * correlating draw call parameter MUST be 0.
  2148. *
  2149. * \param render_pass a render pass handle.
  2150. * \param num_indices the number of vertices to draw per instance.
  2151. * \param num_instances the number of instances to draw.
  2152. * \param first_index the starting index within the index buffer.
  2153. * \param vertex_offset value added to vertex index before indexing into the
  2154. * vertex buffer.
  2155. * \param first_instance the ID of the first instance to draw.
  2156. *
  2157. * \since This function is available since SDL 3.0.0.
  2158. */
  2159. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives(
  2160. SDL_GPURenderPass *render_pass,
  2161. Uint32 num_indices,
  2162. Uint32 num_instances,
  2163. Uint32 first_index,
  2164. Sint32 vertex_offset,
  2165. Uint32 first_instance);
  2166. /**
  2167. * Draws data using bound graphics state.
  2168. *
  2169. * You must not call this function before binding a graphics pipeline.
  2170. *
  2171. * Note that the `first_vertex` and `first_instance` parameters are NOT
  2172. * compatible with built-in vertex/instance ID variables in shaders (for
  2173. * example, SV_VertexID). If your shader depends on these variables, the
  2174. * correlating draw call parameter MUST be 0.
  2175. *
  2176. * \param render_pass a render pass handle.
  2177. * \param num_vertices the number of vertices to draw.
  2178. * \param num_instances the number of instances that will be drawn.
  2179. * \param first_vertex the index of the first vertex to draw.
  2180. * \param first_instance the ID of the first instance to draw.
  2181. *
  2182. * \since This function is available since SDL 3.0.0.
  2183. */
  2184. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives(
  2185. SDL_GPURenderPass *render_pass,
  2186. Uint32 num_vertices,
  2187. Uint32 num_instances,
  2188. Uint32 first_vertex,
  2189. Uint32 first_instance);
  2190. /**
  2191. * Draws data using bound graphics state and with draw parameters set from a
  2192. * buffer.
  2193. *
  2194. * The buffer layout should match the layout of SDL_GPUIndirectDrawCommand.
  2195. * You must not call this function before binding a graphics pipeline.
  2196. *
  2197. * \param render_pass a render pass handle.
  2198. * \param buffer a buffer containing draw parameters.
  2199. * \param offset the offset to start reading from the draw buffer.
  2200. * \param draw_count the number of draw parameter sets that should be read
  2201. * from the draw buffer.
  2202. * \param pitch the byte pitch between sets of draw parameters.
  2203. *
  2204. * \since This function is available since SDL 3.0.0.
  2205. */
  2206. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect(
  2207. SDL_GPURenderPass *render_pass,
  2208. SDL_GPUBuffer *buffer,
  2209. Uint32 offset,
  2210. Uint32 draw_count,
  2211. Uint32 pitch);
  2212. /**
  2213. * Draws data using bound graphics state with an index buffer enabled and with
  2214. * draw parameters set from a buffer.
  2215. *
  2216. * The buffer layout should match the layout of
  2217. * SDL_GPUIndexedIndirectDrawCommand. You must not call this function before
  2218. * binding a graphics pipeline.
  2219. *
  2220. * \param render_pass a render pass handle.
  2221. * \param buffer a buffer containing draw parameters.
  2222. * \param offset the offset to start reading from the draw buffer.
  2223. * \param draw_count the number of draw parameter sets that should be read
  2224. * from the draw buffer.
  2225. * \param pitch the byte pitch between sets of draw parameters.
  2226. *
  2227. * \since This function is available since SDL 3.0.0.
  2228. */
  2229. extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect(
  2230. SDL_GPURenderPass *render_pass,
  2231. SDL_GPUBuffer *buffer,
  2232. Uint32 offset,
  2233. Uint32 draw_count,
  2234. Uint32 pitch);
  2235. /**
  2236. * Ends the given render pass.
  2237. *
  2238. * All bound graphics state on the render pass command buffer is unset. The
  2239. * render pass handle is now invalid.
  2240. *
  2241. * \param render_pass a render pass handle.
  2242. *
  2243. * \since This function is available since SDL 3.0.0.
  2244. */
  2245. extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass(
  2246. SDL_GPURenderPass *render_pass);
  2247. /* Compute Pass */
  2248. /**
  2249. * Begins a compute pass on a command buffer.
  2250. *
  2251. * A compute pass is defined by a set of texture subresources and buffers that
  2252. * will be written to by compute pipelines. These textures and buffers must
  2253. * have been created with the COMPUTE_STORAGE_WRITE bit. All operations
  2254. * related to compute pipelines must take place inside of a compute pass. You
  2255. * must not begin another compute pass, or a render pass or copy pass before
  2256. * ending the compute pass.
  2257. *
  2258. * A VERY IMPORTANT NOTE Textures and buffers bound as write-only MUST NOT be
  2259. * read from during the compute pass. Doing so will result in undefined
  2260. * behavior. If your compute work requires reading the output from a previous
  2261. * dispatch, you MUST end the current compute pass and begin a new one before
  2262. * you can safely access the data.
  2263. *
  2264. * \param command_buffer a command buffer.
  2265. * \param storage_texture_bindings an array of writeable storage texture
  2266. * binding structs.
  2267. * \param num_storage_texture_bindings the number of storage textures to bind
  2268. * from the array.
  2269. * \param storage_buffer_bindings an array of writeable storage buffer binding
  2270. * structs.
  2271. * \param num_storage_buffer_bindings the number of storage buffers to bind
  2272. * from the array.
  2273. * \returns a compute pass handle.
  2274. *
  2275. * \since This function is available since SDL 3.0.0.
  2276. *
  2277. * \sa SDL_EndGPUComputePass
  2278. */
  2279. extern SDL_DECLSPEC SDL_GPUComputePass *SDLCALL SDL_BeginGPUComputePass(
  2280. SDL_GPUCommandBuffer *command_buffer,
  2281. const SDL_GPUStorageTextureWriteOnlyBinding *storage_texture_bindings,
  2282. Uint32 num_storage_texture_bindings,
  2283. const SDL_GPUStorageBufferWriteOnlyBinding *storage_buffer_bindings,
  2284. Uint32 num_storage_buffer_bindings);
  2285. /**
  2286. * Binds a compute pipeline on a command buffer for use in compute dispatch.
  2287. *
  2288. * \param compute_pass a compute pass handle.
  2289. * \param compute_pipeline a compute pipeline to bind.
  2290. *
  2291. * \since This function is available since SDL 3.0.0.
  2292. */
  2293. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline(
  2294. SDL_GPUComputePass *compute_pass,
  2295. SDL_GPUComputePipeline *compute_pipeline);
  2296. /**
  2297. * Binds storage textures as readonly for use on the compute pipeline.
  2298. *
  2299. * These textures must have been created with
  2300. * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ.
  2301. *
  2302. * \param compute_pass a compute pass handle.
  2303. * \param first_slot the compute storage texture slot to begin binding from.
  2304. * \param storage_textures an array of storage textures.
  2305. * \param num_bindings the number of storage textures to bind from the array.
  2306. *
  2307. * \since This function is available since SDL 3.0.0.
  2308. */
  2309. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(
  2310. SDL_GPUComputePass *compute_pass,
  2311. Uint32 first_slot,
  2312. SDL_GPUTexture *const *storage_textures,
  2313. Uint32 num_bindings);
  2314. /**
  2315. * Binds storage buffers as readonly for use on the compute pipeline.
  2316. *
  2317. * These buffers must have been created with
  2318. * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ.
  2319. *
  2320. * \param compute_pass a compute pass handle.
  2321. * \param first_slot the compute storage buffer slot to begin binding from.
  2322. * \param storage_buffers an array of storage buffer binding structs.
  2323. * \param num_bindings the number of storage buffers to bind from the array.
  2324. *
  2325. * \since This function is available since SDL 3.0.0.
  2326. */
  2327. extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(
  2328. SDL_GPUComputePass *compute_pass,
  2329. Uint32 first_slot,
  2330. SDL_GPUBuffer *const *storage_buffers,
  2331. Uint32 num_bindings);
  2332. /**
  2333. * Dispatches compute work.
  2334. *
  2335. * You must not call this function before binding a compute pipeline.
  2336. *
  2337. * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
  2338. * the dispatches write to the same resource region as each other, there is no
  2339. * guarantee of which order the writes will occur. If the write order matters,
  2340. * you MUST end the compute pass and begin another one.
  2341. *
  2342. * \param compute_pass a compute pass handle.
  2343. * \param groupcount_x number of local workgroups to dispatch in the X
  2344. * dimension.
  2345. * \param groupcount_y number of local workgroups to dispatch in the Y
  2346. * dimension.
  2347. * \param groupcount_z number of local workgroups to dispatch in the Z
  2348. * dimension.
  2349. *
  2350. * \since This function is available since SDL 3.0.0.
  2351. */
  2352. extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute(
  2353. SDL_GPUComputePass *compute_pass,
  2354. Uint32 groupcount_x,
  2355. Uint32 groupcount_y,
  2356. Uint32 groupcount_z);
  2357. /**
  2358. * Dispatches compute work with parameters set from a buffer.
  2359. *
  2360. * The buffer layout should match the layout of
  2361. * SDL_GPUIndirectDispatchCommand. You must not call this function before
  2362. * binding a compute pipeline.
  2363. *
  2364. * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
  2365. * the dispatches write to the same resource region as each other, there is no
  2366. * guarantee of which order the writes will occur. If the write order matters,
  2367. * you MUST end the compute pass and begin another one.
  2368. *
  2369. * \param compute_pass a compute pass handle.
  2370. * \param buffer a buffer containing dispatch parameters.
  2371. * \param offset the offset to start reading from the dispatch buffer.
  2372. *
  2373. * \since This function is available since SDL 3.0.0.
  2374. */
  2375. extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect(
  2376. SDL_GPUComputePass *compute_pass,
  2377. SDL_GPUBuffer *buffer,
  2378. Uint32 offset);
  2379. /**
  2380. * Ends the current compute pass.
  2381. *
  2382. * All bound compute state on the command buffer is unset. The compute pass
  2383. * handle is now invalid.
  2384. *
  2385. * \param compute_pass a compute pass handle.
  2386. *
  2387. * \since This function is available since SDL 3.0.0.
  2388. */
  2389. extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(
  2390. SDL_GPUComputePass *compute_pass);
  2391. /* TransferBuffer Data */
  2392. /**
  2393. * Maps a transfer buffer into application address space.
  2394. *
  2395. * You must unmap the transfer buffer before encoding upload commands.
  2396. *
  2397. * \param device a GPU context.
  2398. * \param transfer_buffer a transfer buffer.
  2399. * \param cycle if SDL_TRUE, cycles the transfer buffer if it is bound.
  2400. * \returns the address of the mapped transfer buffer memory.
  2401. *
  2402. * \since This function is available since SDL 3.0.0.
  2403. */
  2404. extern SDL_DECLSPEC void *SDLCALL SDL_MapGPUTransferBuffer(
  2405. SDL_GPUDevice *device,
  2406. SDL_GPUTransferBuffer *transfer_buffer,
  2407. SDL_bool cycle);
  2408. /**
  2409. * Unmaps a previously mapped transfer buffer.
  2410. *
  2411. * \param device a GPU context.
  2412. * \param transfer_buffer a previously mapped transfer buffer.
  2413. *
  2414. * \since This function is available since SDL 3.0.0.
  2415. */
  2416. extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer(
  2417. SDL_GPUDevice *device,
  2418. SDL_GPUTransferBuffer *transfer_buffer);
  2419. /* Copy Pass */
  2420. /**
  2421. * Begins a copy pass on a command buffer.
  2422. *
  2423. * All operations related to copying to or from buffers or textures take place
  2424. * inside a copy pass. You must not begin another copy pass, or a render pass
  2425. * or compute pass before ending the copy pass.
  2426. *
  2427. * \param command_buffer a command buffer.
  2428. * \returns a copy pass handle.
  2429. *
  2430. * \since This function is available since SDL 3.0.0.
  2431. */
  2432. extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass(
  2433. SDL_GPUCommandBuffer *command_buffer);
  2434. /**
  2435. * Uploads data from a transfer buffer to a texture.
  2436. *
  2437. * The upload occurs on the GPU timeline. You may assume that the upload has
  2438. * finished in subsequent commands.
  2439. *
  2440. * You must align the data in the transfer buffer to a multiple of the texel
  2441. * size of the texture format.
  2442. *
  2443. * \param copy_pass a copy pass handle.
  2444. * \param source the source transfer buffer with image layout information.
  2445. * \param destination the destination texture region.
  2446. * \param cycle if SDL_TRUE, cycles the texture if the texture is bound,
  2447. * otherwise overwrites the data.
  2448. *
  2449. * \since This function is available since SDL 3.0.0.
  2450. */
  2451. extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture(
  2452. SDL_GPUCopyPass *copy_pass,
  2453. const SDL_GPUTextureTransferInfo *source,
  2454. const SDL_GPUTextureRegion *destination,
  2455. SDL_bool cycle);
  2456. /* Uploads data from a TransferBuffer to a Buffer. */
  2457. /**
  2458. * Uploads data from a transfer buffer to a buffer.
  2459. *
  2460. * The upload occurs on the GPU timeline. You may assume that the upload has
  2461. * finished in subsequent commands.
  2462. *
  2463. * \param copy_pass a copy pass handle.
  2464. * \param source the source transfer buffer with offset.
  2465. * \param destination the destination buffer with offset and size.
  2466. * \param cycle if SDL_TRUE, cycles the buffer if it is bound, otherwise
  2467. * overwrites the data.
  2468. *
  2469. * \since This function is available since SDL 3.0.0.
  2470. */
  2471. extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer(
  2472. SDL_GPUCopyPass *copy_pass,
  2473. const SDL_GPUTransferBufferLocation *source,
  2474. const SDL_GPUBufferRegion *destination,
  2475. SDL_bool cycle);
  2476. /**
  2477. * Performs a texture-to-texture copy.
  2478. *
  2479. * This copy occurs on the GPU timeline. You may assume the copy has finished
  2480. * in subsequent commands.
  2481. *
  2482. * \param copy_pass a copy pass handle.
  2483. * \param source a source texture region.
  2484. * \param destination a destination texture region.
  2485. * \param w the width of the region to copy.
  2486. * \param h the height of the region to copy.
  2487. * \param d the depth of the region to copy.
  2488. * \param cycle if SDL_TRUE, cycles the destination texture if the destination
  2489. * texture is bound, otherwise overwrites the data.
  2490. *
  2491. * \since This function is available since SDL 3.0.0.
  2492. */
  2493. extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture(
  2494. SDL_GPUCopyPass *copy_pass,
  2495. const SDL_GPUTextureLocation *source,
  2496. const SDL_GPUTextureLocation *destination,
  2497. Uint32 w,
  2498. Uint32 h,
  2499. Uint32 d,
  2500. SDL_bool cycle);
  2501. /* Copies data from a buffer to a buffer. */
  2502. /**
  2503. * Performs a buffer-to-buffer copy.
  2504. *
  2505. * This copy occurs on the GPU timeline. You may assume the copy has finished
  2506. * in subsequent commands.
  2507. *
  2508. * \param copy_pass a copy pass handle.
  2509. * \param source the buffer and offset to copy from.
  2510. * \param destination the buffer and offset to copy to.
  2511. * \param size the length of the buffer to copy.
  2512. * \param cycle if SDL_TRUE, cycles the destination buffer if it is bound,
  2513. * otherwise overwrites the data.
  2514. *
  2515. * \since This function is available since SDL 3.0.0.
  2516. */
  2517. extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer(
  2518. SDL_GPUCopyPass *copy_pass,
  2519. const SDL_GPUBufferLocation *source,
  2520. const SDL_GPUBufferLocation *destination,
  2521. Uint32 size,
  2522. SDL_bool cycle);
  2523. /**
  2524. * Copies data from a texture to a transfer buffer on the GPU timeline.
  2525. *
  2526. * This data is not guaranteed to be copied until the command buffer fence is
  2527. * signaled.
  2528. *
  2529. * \param copy_pass a copy pass handle.
  2530. * \param source the source texture region.
  2531. * \param destination the destination transfer buffer with image layout
  2532. * information.
  2533. *
  2534. * \since This function is available since SDL 3.0.0.
  2535. */
  2536. extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture(
  2537. SDL_GPUCopyPass *copy_pass,
  2538. const SDL_GPUTextureRegion *source,
  2539. const SDL_GPUTextureTransferInfo *destination);
  2540. /**
  2541. * Copies data from a buffer to a transfer buffer on the GPU timeline.
  2542. *
  2543. * This data is not guaranteed to be copied until the command buffer fence is
  2544. * signaled.
  2545. *
  2546. * \param copy_pass a copy pass handle.
  2547. * \param source the source buffer with offset and size.
  2548. * \param destination the destination transfer buffer with offset.
  2549. *
  2550. * \since This function is available since SDL 3.0.0.
  2551. */
  2552. extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer(
  2553. SDL_GPUCopyPass *copy_pass,
  2554. const SDL_GPUBufferRegion *source,
  2555. const SDL_GPUTransferBufferLocation *destination);
  2556. /**
  2557. * Ends the current copy pass.
  2558. *
  2559. * \param copy_pass a copy pass handle.
  2560. *
  2561. * \since This function is available since SDL 3.0.0.
  2562. */
  2563. extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass(
  2564. SDL_GPUCopyPass *copy_pass);
  2565. /**
  2566. * Generates mipmaps for the given texture.
  2567. *
  2568. * This function must not be called inside of any pass.
  2569. *
  2570. * \param command_buffer a command_buffer.
  2571. * \param texture a texture with more than 1 mip level.
  2572. *
  2573. * \since This function is available since SDL 3.0.0.
  2574. */
  2575. extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(
  2576. SDL_GPUCommandBuffer *command_buffer,
  2577. SDL_GPUTexture *texture);
  2578. /**
  2579. * Blits from a source texture region to a destination texture region.
  2580. *
  2581. * This function must not be called inside of any pass.
  2582. *
  2583. * \param command_buffer a command buffer.
  2584. * \param source the texture region to copy from.
  2585. * \param destination the texture region to copy to.
  2586. * \param flip_mode the flip mode for the source texture region.
  2587. * \param filter the filter mode that will be used when blitting.
  2588. * \param cycle if SDL_TRUE, cycles the destination texture if the destination
  2589. * texture is bound, otherwise overwrites the data.
  2590. *
  2591. * \since This function is available since SDL 3.0.0.
  2592. */
  2593. extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
  2594. SDL_GPUCommandBuffer *command_buffer,
  2595. const SDL_GPUBlitRegion *source,
  2596. const SDL_GPUBlitRegion *destination,
  2597. SDL_FlipMode flip_mode,
  2598. SDL_GPUFilter filter,
  2599. SDL_bool cycle);
  2600. /* Submission/Presentation */
  2601. /**
  2602. * Determines whether a swapchain composition is supported by the window.
  2603. *
  2604. * The window must be claimed before calling this function.
  2605. *
  2606. * \param device a GPU context.
  2607. * \param window an SDL_Window.
  2608. * \param swapchain_composition the swapchain composition to check.
  2609. * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error).
  2610. *
  2611. * \since This function is available since SDL 3.0.0.
  2612. *
  2613. * \sa SDL_ClaimWindowForGPUDevice
  2614. */
  2615. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition(
  2616. SDL_GPUDevice *device,
  2617. SDL_Window *window,
  2618. SDL_GPUSwapchainComposition swapchain_composition);
  2619. /**
  2620. * Determines whether a presentation mode is supported by the window.
  2621. *
  2622. * The window must be claimed before calling this function.
  2623. *
  2624. * \param device a GPU context.
  2625. * \param window an SDL_Window.
  2626. * \param present_mode the presentation mode to check.
  2627. * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error).
  2628. *
  2629. * \since This function is available since SDL 3.0.0.
  2630. *
  2631. * \sa SDL_ClaimWindowForGPUDevice
  2632. */
  2633. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUPresentMode(
  2634. SDL_GPUDevice *device,
  2635. SDL_Window *window,
  2636. SDL_GPUPresentMode present_mode);
  2637. /**
  2638. * Claims a window, creating a swapchain structure for it.
  2639. *
  2640. * This must be called before SDL_AcquireGPUSwapchainTexture is called using
  2641. * the window.
  2642. *
  2643. * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and
  2644. * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain
  2645. * parameters, you must call SDL_SetGPUSwapchainParameters after claiming the
  2646. * window.
  2647. *
  2648. * \param device a GPU context.
  2649. * \param window an SDL_Window.
  2650. * \returns SDL_TRUE on success, otherwise SDL_FALSE.
  2651. *
  2652. * \since This function is available since SDL 3.0.0.
  2653. *
  2654. * \sa SDL_AcquireGPUSwapchainTexture
  2655. * \sa SDL_ReleaseWindowFromGPUDevice
  2656. * \sa SDL_WindowSupportsGPUPresentMode
  2657. * \sa SDL_WindowSupportsGPUSwapchainComposition
  2658. */
  2659. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClaimWindowForGPUDevice(
  2660. SDL_GPUDevice *device,
  2661. SDL_Window *window);
  2662. /**
  2663. * Unclaims a window, destroying its swapchain structure.
  2664. *
  2665. * \param device a GPU context.
  2666. * \param window an SDL_Window that has been claimed.
  2667. *
  2668. * \since This function is available since SDL 3.0.0.
  2669. *
  2670. * \sa SDL_ClaimWindowForGPUDevice
  2671. */
  2672. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice(
  2673. SDL_GPUDevice *device,
  2674. SDL_Window *window);
  2675. /**
  2676. * Changes the swapchain parameters for the given claimed window.
  2677. *
  2678. * This function will fail if the requested present mode or swapchain
  2679. * composition are unsupported by the device. Check if the parameters are
  2680. * supported via SDL_WindowSupportsGPUPresentMode /
  2681. * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function.
  2682. *
  2683. * SDL_GPU_PRESENTMODE_VSYNC and SDL_GPU_SWAPCHAINCOMPOSITION_SDR are always
  2684. * supported.
  2685. *
  2686. * \param device a GPU context.
  2687. * \param window an SDL_Window that has been claimed.
  2688. * \param swapchain_composition the desired composition of the swapchain.
  2689. * \param present_mode the desired present mode for the swapchain.
  2690. * \returns SDL_TRUE if successful, SDL_FALSE on error.
  2691. *
  2692. * \since This function is available since SDL 3.0.0.
  2693. *
  2694. * \sa SDL_WindowSupportsGPUPresentMode
  2695. * \sa SDL_WindowSupportsGPUSwapchainComposition
  2696. */
  2697. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGPUSwapchainParameters(
  2698. SDL_GPUDevice *device,
  2699. SDL_Window *window,
  2700. SDL_GPUSwapchainComposition swapchain_composition,
  2701. SDL_GPUPresentMode present_mode);
  2702. /**
  2703. * Obtains the texture format of the swapchain for the given window.
  2704. *
  2705. * \param device a GPU context.
  2706. * \param window an SDL_Window that has been claimed.
  2707. * \returns the texture format of the swapchain.
  2708. *
  2709. * \since This function is available since SDL 3.0.0.
  2710. */
  2711. extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureFormat(
  2712. SDL_GPUDevice *device,
  2713. SDL_Window *window);
  2714. /**
  2715. * Acquire a texture to use in presentation.
  2716. *
  2717. * When a swapchain texture is acquired on a command buffer, it will
  2718. * automatically be submitted for presentation when the command buffer is
  2719. * submitted. The swapchain texture should only be referenced by the command
  2720. * buffer used to acquire it. May return NULL under certain conditions. This
  2721. * is not necessarily an error. This texture is managed by the implementation
  2722. * and must not be freed by the user. You MUST NOT call this function from any
  2723. * thread other than the one that created the window.
  2724. *
  2725. * \param command_buffer a command buffer.
  2726. * \param window a window that has been claimed.
  2727. * \param w a pointer filled in with the swapchain width.
  2728. * \param h a pointer filled in with the swapchain height.
  2729. * \returns a swapchain texture.
  2730. *
  2731. * \since This function is available since SDL 3.0.0.
  2732. *
  2733. * \sa SDL_ClaimWindowForGPUDevice
  2734. * \sa SDL_SubmitGPUCommandBuffer
  2735. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2736. */
  2737. extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_AcquireGPUSwapchainTexture(
  2738. SDL_GPUCommandBuffer *command_buffer,
  2739. SDL_Window *window,
  2740. Uint32 *w,
  2741. Uint32 *h);
  2742. /**
  2743. * Submits a command buffer so its commands can be processed on the GPU.
  2744. *
  2745. * It is invalid to use the command buffer after this is called.
  2746. *
  2747. * This must be called from the thread the command buffer was acquired on.
  2748. *
  2749. * All commands in the submission are guaranteed to begin executing before any
  2750. * command in a subsequent submission begins executing.
  2751. *
  2752. * \param command_buffer a command buffer.
  2753. *
  2754. * \since This function is available since SDL 3.0.0.
  2755. *
  2756. * \sa SDL_AcquireGPUCommandBuffer
  2757. * \sa SDL_AcquireGPUSwapchainTexture
  2758. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2759. */
  2760. extern SDL_DECLSPEC void SDLCALL SDL_SubmitGPUCommandBuffer(
  2761. SDL_GPUCommandBuffer *command_buffer);
  2762. /**
  2763. * Submits a command buffer so its commands can be processed on the GPU, and
  2764. * acquires a fence associated with the command buffer.
  2765. *
  2766. * You must release this fence when it is no longer needed or it will cause a
  2767. * leak. It is invalid to use the command buffer after this is called.
  2768. *
  2769. * This must be called from the thread the command buffer was acquired on.
  2770. *
  2771. * All commands in the submission are guaranteed to begin executing before any
  2772. * command in a subsequent submission begins executing.
  2773. *
  2774. * \param command_buffer a command buffer.
  2775. * \returns a fence associated with the command buffer.
  2776. *
  2777. * \since This function is available since SDL 3.0.0.
  2778. *
  2779. * \sa SDL_AcquireGPUCommandBuffer
  2780. * \sa SDL_AcquireGPUSwapchainTexture
  2781. * \sa SDL_SubmitGPUCommandBuffer
  2782. * \sa SDL_ReleaseGPUFence
  2783. */
  2784. extern SDL_DECLSPEC SDL_GPUFence *SDLCALL SDL_SubmitGPUCommandBufferAndAcquireFence(
  2785. SDL_GPUCommandBuffer *command_buffer);
  2786. /**
  2787. * Blocks the thread until the GPU is completely idle.
  2788. *
  2789. * \param device a GPU context.
  2790. *
  2791. * \since This function is available since SDL 3.0.0.
  2792. *
  2793. * \sa SDL_WaitForGPUFences
  2794. */
  2795. extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUIdle(
  2796. SDL_GPUDevice *device);
  2797. /**
  2798. * Blocks the thread until the given fences are signaled.
  2799. *
  2800. * \param device a GPU context.
  2801. * \param wait_all if 0, wait for any fence to be signaled, if 1, wait for all
  2802. * fences to be signaled.
  2803. * \param fences an array of fences to wait on.
  2804. * \param num_fences the number of fences in the fences array.
  2805. *
  2806. * \since This function is available since SDL 3.0.0.
  2807. *
  2808. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2809. * \sa SDL_WaitForGPUIdle
  2810. */
  2811. extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUFences(
  2812. SDL_GPUDevice *device,
  2813. SDL_bool wait_all,
  2814. SDL_GPUFence *const *fences,
  2815. Uint32 num_fences);
  2816. /**
  2817. * Checks the status of a fence.
  2818. *
  2819. * \param device a GPU context.
  2820. * \param fence a fence.
  2821. * \returns SDL_TRUE if the fence is signaled, SDL_FALSE if it is not.
  2822. *
  2823. * \since This function is available since SDL 3.0.0.
  2824. *
  2825. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2826. */
  2827. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_QueryGPUFence(
  2828. SDL_GPUDevice *device,
  2829. SDL_GPUFence *fence);
  2830. /**
  2831. * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence.
  2832. *
  2833. * \param device a GPU context.
  2834. * \param fence a fence.
  2835. *
  2836. * \since This function is available since SDL 3.0.0.
  2837. *
  2838. * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
  2839. */
  2840. extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence(
  2841. SDL_GPUDevice *device,
  2842. SDL_GPUFence *fence);
  2843. /* Format Info */
  2844. /**
  2845. * Obtains the texel block size for a texture format.
  2846. *
  2847. * \param format the texture format you want to know the texel size of.
  2848. * \returns the texel block size of the texture format.
  2849. *
  2850. * \since This function is available since SDL 3.0.0.
  2851. *
  2852. * \sa SDL_UploadToGPUTexture
  2853. */
  2854. extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize(
  2855. SDL_GPUTextureFormat format);
  2856. /**
  2857. * Determines whether a texture format is supported for a given type and
  2858. * usage.
  2859. *
  2860. * \param device a GPU context.
  2861. * \param format the texture format to check.
  2862. * \param type the type of texture (2D, 3D, Cube).
  2863. * \param usage a bitmask of all usage scenarios to check.
  2864. * \returns whether the texture format is supported for this type and usage.
  2865. *
  2866. * \since This function is available since SDL 3.0.0.
  2867. */
  2868. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsFormat(
  2869. SDL_GPUDevice *device,
  2870. SDL_GPUTextureFormat format,
  2871. SDL_GPUTextureType type,
  2872. SDL_GPUTextureUsageFlags usage);
  2873. /**
  2874. * Determines if a sample count for a texture format is supported.
  2875. *
  2876. * \param device a GPU context.
  2877. * \param format the texture format to check.
  2878. * \param sample_count the sample count to check.
  2879. * \returns a hardware-specific version of min(preferred, possible).
  2880. *
  2881. * \since This function is available since SDL 3.0.0.
  2882. */
  2883. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsSampleCount(
  2884. SDL_GPUDevice *device,
  2885. SDL_GPUTextureFormat format,
  2886. SDL_GPUSampleCount sample_count);
  2887. #ifdef SDL_PLATFORM_GDK
  2888. /**
  2889. * Call this to suspend GPU operation on Xbox when you receive the
  2890. * SDL_EVENT_DID_ENTER_BACKGROUND event.
  2891. *
  2892. * Do NOT call any SDL_GPU functions after calling this function! This must
  2893. * also be called before calling SDL_GDKSuspendComplete.
  2894. *
  2895. * \param device a GPU context.
  2896. *
  2897. * \since This function is available since SDL 3.0.0.
  2898. *
  2899. * \sa SDL_AddEventWatch
  2900. */
  2901. extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device);
  2902. /**
  2903. * Call this to resume GPU operation on Xbox when you receive the
  2904. * SDL_EVENT_WILL_ENTER_FOREGROUND event.
  2905. *
  2906. * When resuming, this function MUST be called before calling any other
  2907. * SDL_GPU functions.
  2908. *
  2909. * \param device a GPU context.
  2910. *
  2911. * \since This function is available since SDL 3.0.0.
  2912. *
  2913. * \sa SDL_AddEventWatch
  2914. */
  2915. extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device);
  2916. #endif /* SDL_PLATFORM_GDK */
  2917. #ifdef __cplusplus
  2918. }
  2919. #endif /* __cplusplus */
  2920. #include <SDL3/SDL_close_code.h>
  2921. #endif /* SDL_gpu_h_ */