SDL_gpu.h 127 KB

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