SDL_gpu.h 125 KB

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