SDL_gpu.h 85 KB

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