123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613 |
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
- */
- /* WIKI CATEGORY: GPU */
- /**
- * # CategoryGPU
- *
- * Include file for SDL GPU API functions
- */
- #ifndef SDL_GPU_H
- #define SDL_GPU_H
- #include <SDL3/SDL_stdinc.h>
- #ifdef __cplusplus
- extern "C" {
- #endif /* __cplusplus */
- /* Type Declarations */
- typedef struct SDL_GPUDevice SDL_GPUDevice;
- typedef struct SDL_GPUBuffer SDL_GPUBuffer;
- typedef struct SDL_GPUTransferBuffer SDL_GPUTransferBuffer;
- typedef struct SDL_GPUTexture SDL_GPUTexture;
- typedef struct SDL_GPUSampler SDL_GPUSampler;
- typedef struct SDL_GPUShader SDL_GPUShader;
- typedef struct SDL_GPUComputePipeline SDL_GPUComputePipeline;
- typedef struct SDL_GPUGraphicsPipeline SDL_GPUGraphicsPipeline;
- typedef struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer;
- typedef struct SDL_GPURenderPass SDL_GPURenderPass;
- typedef struct SDL_GPUComputePass SDL_GPUComputePass;
- typedef struct SDL_GPUCopyPass SDL_GPUCopyPass;
- typedef struct SDL_GPUFence SDL_GPUFence;
- typedef enum SDL_GPUPrimitiveType
- {
- SDL_GPU_PRIMITIVETYPE_POINTLIST,
- SDL_GPU_PRIMITIVETYPE_LINELIST,
- SDL_GPU_PRIMITIVETYPE_LINESTRIP,
- SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
- SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP
- } SDL_GPUPrimitiveType;
- typedef enum SDL_GPULoadOp
- {
- SDL_GPU_LOADOP_LOAD,
- SDL_GPU_LOADOP_CLEAR,
- SDL_GPU_LOADOP_DONT_CARE
- } SDL_GPULoadOp;
- typedef enum SDL_GPUStoreOp
- {
- SDL_GPU_STOREOP_STORE,
- SDL_GPU_STOREOP_DONT_CARE
- } SDL_GPUStoreOp;
- typedef enum SDL_GPUIndexElementSize
- {
- SDL_GPU_INDEXELEMENTSIZE_16BIT,
- SDL_GPU_INDEXELEMENTSIZE_32BIT
- } SDL_GPUIndexElementSize;
- /* Texture format support varies depending on driver, hardware, and usage flags.
- * In general, you should use SDL_GPUTextureSupportsFormat to query if a format
- * is supported before using it. However, there are a few guaranteed formats.
- *
- * For SAMPLER usage, the following formats are universally supported:
- * - R8G8B8A8_UNORM
- * - B8G8R8A8_UNORM
- * - R8_UNORM
- * - R8G8_SNORM
- * - R8G8B8A8_SNORM
- * - R16_FLOAT
- * - R16G16_FLOAT
- * - R16G16B16A16_FLOAT
- * - R32_FLOAT
- * - R32G32_FLOAT
- * - R32G32B32A32_FLOAT
- * - R8G8B8A8_UNORM_SRGB
- * - B8G8R8A8_UNORM_SRGB
- * - D16_UNORM
- *
- * For COLOR_TARGET usage, the following formats are universally supported:
- * - R8G8B8A8_UNORM
- * - B8G8R8A8_UNORM
- * - R8_UNORM
- * - R16_FLOAT
- * - R16G16_FLOAT
- * - R16G16B16A16_FLOAT
- * - R32_FLOAT
- * - R32G32_FLOAT
- * - R32G32B32A32_FLOAT
- * - R8_UINT
- * - R8G8_UINT
- * - R8G8B8A8_UINT
- * - R16_UINT
- * - R16G16_UINT
- * - R16G16B16A16_UINT
- * - R8G8B8A8_UNORM_SRGB
- * - B8G8R8A8_UNORM_SRGB
- *
- * For STORAGE usages, the following formats are universally supported:
- * - R8G8B8A8_UNORM
- * - R8G8B8A8_SNORM
- * - R16G16B16A16_FLOAT
- * - R32_FLOAT
- * - R32G32_FLOAT
- * - R32G32B32A32_FLOAT
- * - R8_UINT
- * - R8G8_UINT
- * - R8G8B8A8_UINT
- * - R16_UINT
- * - R16G16_UINT
- * - R16G16B16A16_UINT
- *
- * For DEPTH_STENCIL_TARGET usage, the following formats are universally supported:
- * - D16_UNORM
- * - Either (but not necessarily both!) D24_UNORM or D32_SFLOAT
- * - Either (but not necessarily both!) D24_UNORM_S8_UINT or D32_SFLOAT_S8_UINT
- *
- * Unless D16_UNORM is sufficient for your purposes, always check which
- * of D24/D32 is supported before creating a depth-stencil texture!
- */
- typedef enum SDL_GPUTextureFormat
- {
- SDL_GPU_TEXTUREFORMAT_INVALID = -1,
- /* Unsigned Normalized Float Color Formats */
- SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
- SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM,
- SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM,
- SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM,
- SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM,
- SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM,
- SDL_GPU_TEXTUREFORMAT_R16G16_UNORM,
- SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM,
- SDL_GPU_TEXTUREFORMAT_R8_UNORM,
- SDL_GPU_TEXTUREFORMAT_A8_UNORM,
- /* Compressed Unsigned Normalized Float Color Formats */
- SDL_GPU_TEXTUREFORMAT_BC1_UNORM,
- SDL_GPU_TEXTUREFORMAT_BC2_UNORM,
- SDL_GPU_TEXTUREFORMAT_BC3_UNORM,
- SDL_GPU_TEXTUREFORMAT_BC7_UNORM,
- /* Signed Normalized Float Color Formats */
- SDL_GPU_TEXTUREFORMAT_R8G8_SNORM,
- SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM,
- /* Signed Float Color Formats */
- SDL_GPU_TEXTUREFORMAT_R16_FLOAT,
- SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT,
- SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT,
- SDL_GPU_TEXTUREFORMAT_R32_FLOAT,
- SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT,
- SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT,
- /* Unsigned Integer Color Formats */
- SDL_GPU_TEXTUREFORMAT_R8_UINT,
- SDL_GPU_TEXTUREFORMAT_R8G8_UINT,
- SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT,
- SDL_GPU_TEXTUREFORMAT_R16_UINT,
- SDL_GPU_TEXTUREFORMAT_R16G16_UINT,
- SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT,
- /* SRGB Unsigned Normalized Color Formats */
- SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB,
- SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB,
- /* Compressed SRGB Unsigned Normalized Color Formats */
- SDL_GPU_TEXTUREFORMAT_BC3_UNORM_SRGB,
- SDL_GPU_TEXTUREFORMAT_BC7_UNORM_SRGB,
- /* Depth Formats */
- SDL_GPU_TEXTUREFORMAT_D16_UNORM,
- SDL_GPU_TEXTUREFORMAT_D24_UNORM,
- SDL_GPU_TEXTUREFORMAT_D32_FLOAT,
- SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT,
- SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT
- } SDL_GPUTextureFormat;
- typedef enum SDL_GPUTextureUsageFlagBits
- {
- SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT = 0x00000001,
- SDL_GPU_TEXTUREUSAGE_COLOR_TARGET_BIT = 0x00000002,
- SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET_BIT = 0x00000004,
- SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ_BIT = 0x00000008,
- SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ_BIT = 0x00000020,
- SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE_BIT = 0x00000040
- } SDL_GPUTextureUsageFlagBits;
- typedef Uint32 SDL_GPUTextureUsageFlags;
- typedef enum SDL_GPUTextureType
- {
- SDL_GPU_TEXTURETYPE_2D,
- SDL_GPU_TEXTURETYPE_2D_ARRAY,
- SDL_GPU_TEXTURETYPE_3D,
- SDL_GPU_TEXTURETYPE_CUBE
- } SDL_GPUTextureType;
- typedef enum SDL_GPUSampleCount
- {
- SDL_GPU_SAMPLECOUNT_1,
- SDL_GPU_SAMPLECOUNT_2,
- SDL_GPU_SAMPLECOUNT_4,
- SDL_GPU_SAMPLECOUNT_8
- } SDL_GPUSampleCount;
- typedef enum SDL_GPUCubeMapFace
- {
- SDL_GPU_CUBEMAPFACE_POSITIVEX,
- SDL_GPU_CUBEMAPFACE_NEGATIVEX,
- SDL_GPU_CUBEMAPFACE_POSITIVEY,
- SDL_GPU_CUBEMAPFACE_NEGATIVEY,
- SDL_GPU_CUBEMAPFACE_POSITIVEZ,
- SDL_GPU_CUBEMAPFACE_NEGATIVEZ
- } SDL_GPUCubeMapFace;
- typedef enum SDL_GPUBufferUsageFlagBits
- {
- SDL_GPU_BUFFERUSAGE_VERTEX_BIT = 0x00000001,
- SDL_GPU_BUFFERUSAGE_INDEX_BIT = 0x00000002,
- SDL_GPU_BUFFERUSAGE_INDIRECT_BIT = 0x00000004,
- SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ_BIT = 0x00000008,
- SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ_BIT = 0x00000020,
- SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE_BIT = 0x00000040
- } SDL_GPUBufferUsageFlagBits;
- typedef Uint32 SDL_GPUBufferUsageFlags;
- typedef enum SDL_GPUTransferBufferUsage
- {
- SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
- SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
- } SDL_GPUTransferBufferUsage;
- typedef enum SDL_GPUShaderStage
- {
- SDL_GPU_SHADERSTAGE_VERTEX,
- SDL_GPU_SHADERSTAGE_FRAGMENT
- } SDL_GPUShaderStage;
- typedef enum SDL_GPUShaderFormatFlagBits
- {
- SDL_GPU_SHADERFORMAT_INVALID = 0x00000000,
- SDL_GPU_SHADERFORMAT_SECRET = 0x00000001, /* NDA'd platforms */
- SDL_GPU_SHADERFORMAT_SPIRV = 0x00000002, /* Vulkan */
- SDL_GPU_SHADERFORMAT_DXBC = 0x00000004, /* D3D11 (Shader Model 5_0) */
- SDL_GPU_SHADERFORMAT_DXIL = 0x00000008, /* D3D12 */
- SDL_GPU_SHADERFORMAT_MSL = 0x00000010, /* Metal */
- SDL_GPU_SHADERFORMAT_METALLIB = 0x00000020, /* Metal */
- } SDL_GPUShaderFormatFlagBits;
- typedef Uint32 SDL_GPUShaderFormat;
- typedef enum SDL_GPUVertexElementFormat
- {
- /* 32-bit Signed Integers */
- SDL_GPU_VERTEXELEMENTFORMAT_INT,
- SDL_GPU_VERTEXELEMENTFORMAT_INT2,
- SDL_GPU_VERTEXELEMENTFORMAT_INT3,
- SDL_GPU_VERTEXELEMENTFORMAT_INT4,
- /* 32-bit Unsigned Integers */
- SDL_GPU_VERTEXELEMENTFORMAT_UINT,
- SDL_GPU_VERTEXELEMENTFORMAT_UINT2,
- SDL_GPU_VERTEXELEMENTFORMAT_UINT3,
- SDL_GPU_VERTEXELEMENTFORMAT_UINT4,
- /* 32-bit Floats */
- SDL_GPU_VERTEXELEMENTFORMAT_FLOAT,
- SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
- SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
- SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4,
- /* 8-bit Signed Integers */
- SDL_GPU_VERTEXELEMENTFORMAT_BYTE2,
- SDL_GPU_VERTEXELEMENTFORMAT_BYTE4,
- /* 8-bit Unsigned Integers */
- SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2,
- SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4,
- /* 8-bit Signed Normalized */
- SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM,
- SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM,
- /* 8-bit Unsigned Normalized */
- SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM,
- SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM,
- /* 16-bit Signed Integers */
- SDL_GPU_VERTEXELEMENTFORMAT_SHORT2,
- SDL_GPU_VERTEXELEMENTFORMAT_SHORT4,
- /* 16-bit Unsigned Integers */
- SDL_GPU_VERTEXELEMENTFORMAT_USHORT2,
- SDL_GPU_VERTEXELEMENTFORMAT_USHORT4,
- /* 16-bit Signed Normalized */
- SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM,
- SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM,
- /* 16-bit Unsigned Normalized */
- SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM,
- SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM,
- /* 16-bit Floats */
- SDL_GPU_VERTEXELEMENTFORMAT_HALF2,
- SDL_GPU_VERTEXELEMENTFORMAT_HALF4
- } SDL_GPUVertexElementFormat;
- typedef enum SDL_GPUVertexInputRate
- {
- SDL_GPU_VERTEXINPUTRATE_VERTEX = 0,
- SDL_GPU_VERTEXINPUTRATE_INSTANCE = 1
- } SDL_GPUVertexInputRate;
- typedef enum SDL_GPUFillMode
- {
- SDL_GPU_FILLMODE_FILL,
- SDL_GPU_FILLMODE_LINE
- } SDL_GPUFillMode;
- typedef enum SDL_GPUCullMode
- {
- SDL_GPU_CULLMODE_NONE,
- SDL_GPU_CULLMODE_FRONT,
- SDL_GPU_CULLMODE_BACK
- } SDL_GPUCullMode;
- typedef enum SDL_GPUFrontFace
- {
- SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE,
- SDL_GPU_FRONTFACE_CLOCKWISE
- } SDL_GPUFrontFace;
- typedef enum SDL_GPUCompareOp
- {
- SDL_GPU_COMPAREOP_NEVER,
- SDL_GPU_COMPAREOP_LESS,
- SDL_GPU_COMPAREOP_EQUAL,
- SDL_GPU_COMPAREOP_LESS_OR_EQUAL,
- SDL_GPU_COMPAREOP_GREATER,
- SDL_GPU_COMPAREOP_NOT_EQUAL,
- SDL_GPU_COMPAREOP_GREATER_OR_EQUAL,
- SDL_GPU_COMPAREOP_ALWAYS
- } SDL_GPUCompareOp;
- typedef enum SDL_GPUStencilOp
- {
- SDL_GPU_STENCILOP_KEEP,
- SDL_GPU_STENCILOP_ZERO,
- SDL_GPU_STENCILOP_REPLACE,
- SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP,
- SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP,
- SDL_GPU_STENCILOP_INVERT,
- SDL_GPU_STENCILOP_INCREMENT_AND_WRAP,
- SDL_GPU_STENCILOP_DECREMENT_AND_WRAP
- } SDL_GPUStencilOp;
- typedef enum SDL_GPUBlendOp
- {
- SDL_GPU_BLENDOP_ADD,
- SDL_GPU_BLENDOP_SUBTRACT,
- SDL_GPU_BLENDOP_REVERSE_SUBTRACT,
- SDL_GPU_BLENDOP_MIN,
- SDL_GPU_BLENDOP_MAX
- } SDL_GPUBlendOp;
- typedef enum SDL_GPUBlendFactor
- {
- SDL_GPU_BLENDFACTOR_ZERO,
- SDL_GPU_BLENDFACTOR_ONE,
- SDL_GPU_BLENDFACTOR_SRC_COLOR,
- SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR,
- SDL_GPU_BLENDFACTOR_DST_COLOR,
- SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR,
- SDL_GPU_BLENDFACTOR_SRC_ALPHA,
- SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- SDL_GPU_BLENDFACTOR_DST_ALPHA,
- SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA,
- SDL_GPU_BLENDFACTOR_CONSTANT_COLOR,
- SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR,
- SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE
- } SDL_GPUBlendFactor;
- typedef enum SDL_GPUColorComponentFlagBits
- {
- SDL_GPU_COLORCOMPONENT_R_BIT = 0x00000001,
- SDL_GPU_COLORCOMPONENT_G_BIT = 0x00000002,
- SDL_GPU_COLORCOMPONENT_B_BIT = 0x00000004,
- SDL_GPU_COLORCOMPONENT_A_BIT = 0x00000008
- } SDL_GPUColorComponentFlagBits;
- typedef Uint8 SDL_GPUColorComponentFlags;
- typedef enum SDL_GPUFilter
- {
- SDL_GPU_FILTER_NEAREST,
- SDL_GPU_FILTER_LINEAR
- } SDL_GPUFilter;
- typedef enum SDL_GPUSamplerMipmapMode
- {
- SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
- SDL_GPU_SAMPLERMIPMAPMODE_LINEAR
- } SDL_GPUSamplerMipmapMode;
- typedef enum SDL_GPUSamplerAddressMode
- {
- SDL_GPU_SAMPLERADDRESSMODE_REPEAT,
- SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT,
- SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE
- } SDL_GPUSamplerAddressMode;
- /*
- * VSYNC:
- * Waits for vblank before presenting.
- * If there is a pending image to present, the new image is enqueued for presentation.
- * Disallows tearing at the cost of visual latency.
- * When using this present mode, AcquireSwapchainTexture will block if too many frames are in flight.
- * IMMEDIATE:
- * Immediately presents.
- * Lowest latency option, but tearing may occur.
- * When using this mode, AcquireSwapchainTexture will return NULL if too many frames are in flight.
- * MAILBOX:
- * Waits for vblank before presenting. No tearing is possible.
- * If there is a pending image to present, the pending image is replaced by the new image.
- * Similar to VSYNC, but with reduced visual latency.
- * When using this mode, AcquireSwapchainTexture will return NULL if too many frames are in flight.
- */
- typedef enum SDL_GPUPresentMode
- {
- SDL_GPU_PRESENTMODE_VSYNC,
- SDL_GPU_PRESENTMODE_IMMEDIATE,
- SDL_GPU_PRESENTMODE_MAILBOX
- } SDL_GPUPresentMode;
- /*
- * SDR:
- * B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in nonlinear sRGB encoding. Blends raw pixel values.
- * SDR_LINEAR:
- * B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are in nonlinear sRGB encoding. Blends in linear space.
- * HDR_EXTENDED_LINEAR:
- * R16G16B16A16_SFLOAT swapchain. Pixel values are in extended linear encoding. Blends in linear space.
- * HDR10_ST2048:
- * A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in PQ ST2048 encoding. Blends raw pixel values. (TODO: verify this)
- */
- typedef enum SDL_GPUSwapchainComposition
- {
- SDL_GPU_SWAPCHAINCOMPOSITION_SDR,
- SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR,
- SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR,
- SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048
- } SDL_GPUSwapchainComposition;
- typedef enum SDL_GPUDriver
- {
- SDL_GPU_DRIVER_INVALID = -1,
- SDL_GPU_DRIVER_SECRET, /* NDA'd platforms */
- SDL_GPU_DRIVER_VULKAN,
- SDL_GPU_DRIVER_D3D11,
- SDL_GPU_DRIVER_D3D12,
- SDL_GPU_DRIVER_METAL
- } SDL_GPUDriver;
- /* Structures */
- typedef struct SDL_GPUDepthStencilValue
- {
- float depth;
- Uint8 stencil;
- } SDL_GPUDepthStencilValue;
- typedef struct SDL_GPUViewport
- {
- float x;
- float y;
- float w;
- float h;
- float minDepth;
- float maxDepth;
- } SDL_GPUViewport;
- typedef struct SDL_GPUTextureTransferInfo
- {
- SDL_GPUTransferBuffer *transferBuffer;
- Uint32 offset; /* starting location of the image data */
- Uint32 imagePitch; /* number of pixels from one row to the next */
- Uint32 imageHeight; /* number of rows from one layer/depth-slice to the next */
- } SDL_GPUTextureTransferInfo;
- typedef struct SDL_GPUTransferBufferLocation
- {
- SDL_GPUTransferBuffer *transferBuffer;
- Uint32 offset;
- } SDL_GPUTransferBufferLocation;
- typedef struct SDL_GPUTextureLocation
- {
- SDL_GPUTexture *texture;
- Uint32 mipLevel;
- Uint32 layer;
- Uint32 x;
- Uint32 y;
- Uint32 z;
- } SDL_GPUTextureLocation;
- typedef struct SDL_GPUTextureRegion
- {
- SDL_GPUTexture *texture;
- Uint32 mipLevel;
- Uint32 layer;
- Uint32 x;
- Uint32 y;
- Uint32 z;
- Uint32 w;
- Uint32 h;
- Uint32 d;
- } SDL_GPUTextureRegion;
- typedef struct SDL_GPUBlitRegion
- {
- SDL_GPUTexture *texture;
- Uint32 mipLevel;
- Uint32 layerOrDepthPlane;
- Uint32 x;
- Uint32 y;
- Uint32 w;
- Uint32 h;
- } SDL_GPUBlitRegion;
- typedef struct SDL_GPUBufferLocation
- {
- SDL_GPUBuffer *buffer;
- Uint32 offset;
- } SDL_GPUBufferLocation;
- typedef struct SDL_GPUBufferRegion
- {
- SDL_GPUBuffer *buffer;
- Uint32 offset;
- Uint32 size;
- } SDL_GPUBufferRegion;
- /* Note that the `firstVertex` and `firstInstance` parameters are NOT compatible with
- * built-in vertex/instance ID variables in shaders (for example, SV_VertexID). If
- * your shader depends on these variables, the correlating draw call parameter MUST
- * be 0.
- */
- typedef struct SDL_GPUIndirectDrawCommand
- {
- Uint32 vertexCount; /* number of vertices to draw */
- Uint32 instanceCount; /* number of instances to draw */
- Uint32 firstVertex; /* index of the first vertex to draw */
- Uint32 firstInstance; /* ID of the first instance to draw */
- } SDL_GPUIndirectDrawCommand;
- typedef struct SDL_GPUIndexedIndirectDrawCommand
- {
- Uint32 indexCount; /* number of vertices to draw per instance */
- Uint32 instanceCount; /* number of instances to draw */
- Uint32 firstIndex; /* base index within the index buffer */
- Sint32 vertexOffset; /* value added to vertex index before indexing into the vertex buffer */
- Uint32 firstInstance; /* ID of the first instance to draw */
- } SDL_GPUIndexedIndirectDrawCommand;
- typedef struct SDL_GPUIndirectDispatchCommand
- {
- Uint32 groupCountX;
- Uint32 groupCountY;
- Uint32 groupCountZ;
- } SDL_GPUIndirectDispatchCommand;
- /* State structures */
- typedef struct SDL_GPUSamplerCreateInfo
- {
- SDL_GPUFilter minFilter;
- SDL_GPUFilter magFilter;
- SDL_GPUSamplerMipmapMode mipmapMode;
- SDL_GPUSamplerAddressMode addressModeU;
- SDL_GPUSamplerAddressMode addressModeV;
- SDL_GPUSamplerAddressMode addressModeW;
- float mipLodBias;
- SDL_bool anisotropyEnable;
- float maxAnisotropy;
- SDL_bool compareEnable;
- SDL_GPUCompareOp compareOp;
- float minLod;
- float maxLod;
- SDL_PropertiesID props;
- } SDL_GPUSamplerCreateInfo;
- typedef struct SDL_GPUVertexBinding
- {
- Uint32 binding;
- Uint32 stride;
- SDL_GPUVertexInputRate inputRate;
- Uint32 instanceStepRate; /* ignored unless inputRate is INSTANCE */
- } SDL_GPUVertexBinding;
- typedef struct SDL_GPUVertexAttribute
- {
- Uint32 location;
- Uint32 binding;
- SDL_GPUVertexElementFormat format;
- Uint32 offset;
- } SDL_GPUVertexAttribute;
- typedef struct SDL_GPUVertexInputState
- {
- const SDL_GPUVertexBinding *vertexBindings;
- Uint32 vertexBindingCount;
- const SDL_GPUVertexAttribute *vertexAttributes;
- Uint32 vertexAttributeCount;
- } SDL_GPUVertexInputState;
- typedef struct SDL_GPUStencilOpState
- {
- SDL_GPUStencilOp failOp;
- SDL_GPUStencilOp passOp;
- SDL_GPUStencilOp depthFailOp;
- SDL_GPUCompareOp compareOp;
- } SDL_GPUStencilOpState;
- typedef struct SDL_GPUColorAttachmentBlendState
- {
- SDL_bool blendEnable;
- SDL_GPUBlendFactor srcColorBlendFactor;
- SDL_GPUBlendFactor dstColorBlendFactor;
- SDL_GPUBlendOp colorBlendOp;
- SDL_GPUBlendFactor srcAlphaBlendFactor;
- SDL_GPUBlendFactor dstAlphaBlendFactor;
- SDL_GPUBlendOp alphaBlendOp;
- SDL_GPUColorComponentFlags colorWriteMask;
- } SDL_GPUColorAttachmentBlendState;
- typedef struct SDL_GPUShaderCreateInfo
- {
- size_t codeSize;
- const Uint8 *code;
- const char *entryPointName;
- SDL_GPUShaderFormat format;
- SDL_GPUShaderStage stage;
- Uint32 samplerCount;
- Uint32 storageTextureCount;
- Uint32 storageBufferCount;
- Uint32 uniformBufferCount;
- SDL_PropertiesID props;
- } SDL_GPUShaderCreateInfo;
- typedef struct SDL_GPUTextureCreateInfo
- {
- SDL_GPUTextureType type;
- SDL_GPUTextureFormat format;
- SDL_GPUTextureUsageFlags usageFlags;
- Uint32 width;
- Uint32 height;
- Uint32 layerCountOrDepth;
- Uint32 levelCount;
- SDL_GPUSampleCount sampleCount;
- SDL_PropertiesID props;
- } SDL_GPUTextureCreateInfo;
- #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r"
- #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT "SDL.gpu.createtexture.d3d12.clear.g"
- #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT "SDL.gpu.createtexture.d3d12.clear.b"
- #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT "SDL.gpu.createtexture.d3d12.clear.a"
- #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.createtexture.d3d12.clear.depth"
- #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8 "SDL.gpu.createtexture.d3d12.clear.stencil"
- typedef struct SDL_GPUBufferCreateInfo
- {
- SDL_GPUBufferUsageFlags usageFlags;
- Uint32 sizeInBytes;
- SDL_PropertiesID props;
- } SDL_GPUBufferCreateInfo;
- typedef struct SDL_GPUTransferBufferCreateInfo
- {
- SDL_GPUTransferBufferUsage usage;
- Uint32 sizeInBytes;
- SDL_PropertiesID props;
- } SDL_GPUTransferBufferCreateInfo;
- /* Pipeline state structures */
- typedef struct SDL_GPURasterizerState
- {
- SDL_GPUFillMode fillMode;
- SDL_GPUCullMode cullMode;
- SDL_GPUFrontFace frontFace;
- SDL_bool depthBiasEnable;
- float depthBiasConstantFactor;
- float depthBiasClamp;
- float depthBiasSlopeFactor;
- } SDL_GPURasterizerState;
- typedef struct SDL_GPUMultisampleState
- {
- SDL_GPUSampleCount sampleCount;
- Uint32 sampleMask;
- } SDL_GPUMultisampleState;
- typedef struct SDL_GPUDepthStencilState
- {
- SDL_bool depthTestEnable;
- SDL_bool depthWriteEnable;
- SDL_GPUCompareOp compareOp;
- SDL_bool stencilTestEnable;
- SDL_GPUStencilOpState backStencilState;
- SDL_GPUStencilOpState frontStencilState;
- Uint8 compareMask;
- Uint8 writeMask;
- Uint8 reference;
- } SDL_GPUDepthStencilState;
- typedef struct SDL_GPUColorAttachmentDescription
- {
- SDL_GPUTextureFormat format;
- SDL_GPUColorAttachmentBlendState blendState;
- } SDL_GPUColorAttachmentDescription;
- typedef struct SDL_GPUGraphicsPipelineAttachmentInfo
- {
- SDL_GPUColorAttachmentDescription *colorAttachmentDescriptions;
- Uint32 colorAttachmentCount;
- SDL_bool hasDepthStencilAttachment;
- SDL_GPUTextureFormat depthStencilFormat;
- } SDL_GPUGraphicsPipelineAttachmentInfo;
- typedef struct SDL_GPUGraphicsPipelineCreateInfo
- {
- SDL_GPUShader *vertexShader;
- SDL_GPUShader *fragmentShader;
- SDL_GPUVertexInputState vertexInputState;
- SDL_GPUPrimitiveType primitiveType;
- SDL_GPURasterizerState rasterizerState;
- SDL_GPUMultisampleState multisampleState;
- SDL_GPUDepthStencilState depthStencilState;
- SDL_GPUGraphicsPipelineAttachmentInfo attachmentInfo;
- float blendConstants[4];
- SDL_PropertiesID props;
- } SDL_GPUGraphicsPipelineCreateInfo;
- typedef struct SDL_GPUComputePipelineCreateInfo
- {
- size_t codeSize;
- const Uint8 *code;
- const char *entryPointName;
- SDL_GPUShaderFormat format;
- Uint32 readOnlyStorageTextureCount;
- Uint32 readOnlyStorageBufferCount;
- Uint32 writeOnlyStorageTextureCount;
- Uint32 writeOnlyStorageBufferCount;
- Uint32 uniformBufferCount;
- Uint32 threadCountX;
- Uint32 threadCountY;
- Uint32 threadCountZ;
- SDL_PropertiesID props;
- } SDL_GPUComputePipelineCreateInfo;
- typedef struct SDL_GPUColorAttachmentInfo
- {
- /* The texture that will be used as a color attachment by a render pass. */
- SDL_GPUTexture *texture;
- Uint32 mipLevel;
- Uint32 layerOrDepthPlane; /* For 3D textures, you can bind an individual depth plane as an attachment. */
- /* Can be ignored by RenderPass if CLEAR is not used */
- SDL_FColor clearColor;
- /* Determines what is done with the texture at the beginning of the render pass.
- *
- * LOAD:
- * Loads the data currently in the texture.
- *
- * CLEAR:
- * Clears the texture to a single color.
- *
- * DONT_CARE:
- * The driver will do whatever it wants with the texture memory.
- * This is a good option if you know that every single pixel will be touched in the render pass.
- */
- SDL_GPULoadOp loadOp;
- /* Determines what is done with the texture at the end of the render pass.
- *
- * STORE:
- * Stores the results of the render pass in the texture.
- *
- * DONT_CARE:
- * The driver will do whatever it wants with the texture memory.
- * This is often a good option for depth/stencil textures.
- */
- SDL_GPUStoreOp storeOp;
- /* if SDL_TRUE, cycles the texture if the texture is bound and loadOp is not LOAD */
- SDL_bool cycle;
- } SDL_GPUColorAttachmentInfo;
- typedef struct SDL_GPUDepthStencilAttachmentInfo
- {
- /* The texture that will be used as the depth stencil attachment by a render pass. */
- SDL_GPUTexture *texture;
- /* Can be ignored by the render pass if CLEAR is not used */
- SDL_GPUDepthStencilValue depthStencilClearValue;
- /* Determines what is done with the depth values at the beginning of the render pass.
- *
- * LOAD:
- * Loads the depth values currently in the texture.
- *
- * CLEAR:
- * Clears the texture to a single depth.
- *
- * DONT_CARE:
- * The driver will do whatever it wants with the memory.
- * This is a good option if you know that every single pixel will be touched in the render pass.
- */
- SDL_GPULoadOp loadOp;
- /* Determines what is done with the depth values at the end of the render pass.
- *
- * STORE:
- * Stores the depth results in the texture.
- *
- * DONT_CARE:
- * The driver will do whatever it wants with the texture memory.
- * This is often a good option for depth/stencil textures.
- */
- SDL_GPUStoreOp storeOp;
- /* Determines what is done with the stencil values at the beginning of the render pass.
- *
- * LOAD:
- * Loads the stencil values currently in the texture.
- *
- * CLEAR:
- * Clears the texture to a single stencil value.
- *
- * DONT_CARE:
- * The driver will do whatever it wants with the memory.
- * This is a good option if you know that every single pixel will be touched in the render pass.
- */
- SDL_GPULoadOp stencilLoadOp;
- /* Determines what is done with the stencil values at the end of the render pass.
- *
- * STORE:
- * Stores the stencil results in the texture.
- *
- * DONT_CARE:
- * The driver will do whatever it wants with the texture memory.
- * This is often a good option for depth/stencil textures.
- */
- SDL_GPUStoreOp stencilStoreOp;
- /* if SDL_TRUE, cycles the texture if the texture is bound and any load ops are not LOAD */
- SDL_bool cycle;
- } SDL_GPUDepthStencilAttachmentInfo;
- /* Binding structs */
- typedef struct SDL_GPUBufferBinding
- {
- SDL_GPUBuffer *buffer;
- Uint32 offset;
- } SDL_GPUBufferBinding;
- typedef struct SDL_GPUTextureSamplerBinding
- {
- SDL_GPUTexture *texture;
- SDL_GPUSampler *sampler;
- } SDL_GPUTextureSamplerBinding;
- typedef struct SDL_GPUStorageBufferWriteOnlyBinding
- {
- SDL_GPUBuffer *buffer;
- /* if SDL_TRUE, cycles the buffer if it is bound. */
- SDL_bool cycle;
- } SDL_GPUStorageBufferWriteOnlyBinding;
- typedef struct SDL_GPUStorageTextureWriteOnlyBinding
- {
- SDL_GPUTexture *texture;
- Uint32 mipLevel;
- Uint32 layer;
- /* if SDL_TRUE, cycles the texture if the texture is bound. */
- SDL_bool cycle;
- } SDL_GPUStorageTextureWriteOnlyBinding;
- /* Functions */
- /* Device */
- /**
- * Creates a GPU context.
- *
- * \param formatFlags a bitflag indicating which shader formats the app is
- * able to provide.
- * \param debugMode enable debug mode properties and validations.
- * \param name the preferred GPU driver, or NULL to let SDL pick the optimal
- * driver.
- * \returns a GPU context on success or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetGPUDriver
- * \sa SDL_DestroyGPUDevice
- */
- extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDevice(
- SDL_GPUShaderFormat formatFlags,
- SDL_bool debugMode,
- const char *name);
- /**
- * Creates a GPU context.
- *
- * These are the supported properties:
- *
- * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL`: enable debug mode properties
- * and validations, defaults to SDL_TRUE.
- * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL`: enable to prefer energy
- * efficiency over maximum GPU performance, defaults to SDL_FALSE.
- * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to
- * use, if a specific one is desired.
- *
- * These are the current shader format properties:
- *
- * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SECRET_BOOL`: The app is able to
- * provide shaders for an NDA platform.
- * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL`: The app is able to
- * provide SPIR-V shaders if applicable.
- * - SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL`: The app is able to provide
- * DXBC shaders if applicable
- * `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL`: The app is able to
- * provide DXIL shaders if applicable.
- * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL`: The app is able to provide
- * MSL shaders if applicable.
- * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL`: The app is able to
- * provide Metal shader libraries if applicable.
- *
- * With the D3D12 renderer:
- *
- * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to
- * use for all vertex semantics, default is "TEXCOORD".
- *
- * \param props the properties to use.
- * \returns a GPU context on success or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetGPUDriver
- * \sa SDL_DestroyGPUDevice
- */
- extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDeviceWithProperties(
- SDL_PropertiesID props);
- #define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL "SDL.gpu.device.create.debugmode"
- #define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL "SDL.gpu.device.create.preferlowpower"
- #define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name"
- #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SECRET_BOOL "SDL.gpu.device.create.shaders.secret"
- #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL "SDL.gpu.device.create.shaders.spirv"
- #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL "SDL.gpu.device.create.shaders.dxbc"
- #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL "SDL.gpu.device.create.shaders.dxil"
- #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL "SDL.gpu.device.create.shaders.msl"
- #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL "SDL.gpu.device.create.shaders.metallib"
- #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
- /**
- * Destroys a GPU context previously returned by SDL_CreateGPUDevice.
- *
- * \param device a GPU Context to destroy.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_CreateGPUDevice
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device);
- /**
- * Returns the backend used to create this GPU context.
- *
- * \param device a GPU context to query.
- * \returns an SDL_GPUDriver value, or SDL_GPU_DRIVER_INVALID on error.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC SDL_GPUDriver SDLCALL SDL_GetGPUDriver(SDL_GPUDevice *device);
- /* State Creation */
- /**
- * Creates a pipeline object to be used in a compute workflow.
- *
- * Shader resource bindings must be authored to follow a particular order. For
- * SPIR-V shaders, use the following resource sets: 0: Read-only storage
- * textures, followed by read-only storage buffers 1: Write-only storage
- * textures, followed by write-only storage buffers 2: Uniform buffers
- *
- * For DXBC Shader Model 5_0 shaders, use the following register order: For t
- * registers: Read-only storage textures, followed by read-only storage
- * buffers For u registers: Write-only storage textures, followed by
- * write-only storage buffers For b registers: Uniform buffers
- *
- * For DXIL shaders, use the following register order: (t[n], space0):
- * Read-only storage textures, followed by read-only storage buffers (u[n],
- * space1): Write-only storage textures, followed by write-only storage
- * buffers (b[n], space2): Uniform buffers
- *
- * For MSL/metallib, use the following order: For [[buffer]]: Uniform buffers,
- * followed by write-only storage buffers, followed by write-only storage
- * buffers For [[texture]]: Read-only storage textures, followed by write-only
- * storage textures
- *
- * \param device a GPU Context.
- * \param computePipelineCreateInfo a struct describing the state of the
- * requested compute pipeline.
- * \returns a compute pipeline object on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_BindGPUComputePipeline
- * \sa SDL_ReleaseGPUComputePipeline
- */
- extern SDL_DECLSPEC SDL_GPUComputePipeline *SDLCALL SDL_CreateGPUComputePipeline(
- SDL_GPUDevice *device,
- SDL_GPUComputePipelineCreateInfo *computePipelineCreateInfo);
- /**
- * Creates a pipeline object to be used in a graphics workflow.
- *
- * \param device a GPU Context.
- * \param pipelineCreateInfo a struct describing the state of the desired
- * graphics pipeline.
- * \returns a graphics pipeline object on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_CreateGPUShader
- * \sa SDL_BindGPUGraphicsPipeline
- * \sa SDL_ReleaseGPUGraphicsPipeline
- */
- extern SDL_DECLSPEC SDL_GPUGraphicsPipeline *SDLCALL SDL_CreateGPUGraphicsPipeline(
- SDL_GPUDevice *device,
- SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo);
- /**
- * Creates a sampler object to be used when binding textures in a graphics
- * workflow.
- *
- * \param device a GPU Context.
- * \param samplerCreateInfo a struct describing the state of the desired
- * sampler.
- * \returns a sampler object on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_BindGPUVertexSamplers
- * \sa SDL_BindGPUFragmentSamplers
- * \sa SDL_ReleaseSampler
- */
- extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(
- SDL_GPUDevice *device,
- SDL_GPUSamplerCreateInfo *samplerCreateInfo);
- /**
- * Creates a shader to be used when creating a graphics pipeline.
- *
- * Shader resource bindings must be authored to follow a particular order
- * depending on the shader format.
- *
- * For SPIR-V shaders, use the following resource sets: For vertex shaders: 0:
- * Sampled textures, followed by storage textures, followed by storage buffers
- * 1: Uniform buffers For fragment shaders: 2: Sampled textures, followed by
- * storage textures, followed by storage buffers 3: Uniform buffers
- *
- * For DXBC Shader Model 5_0 shaders, use the following register order: For t
- * registers: Sampled textures, followed by storage textures, followed by
- * storage buffers For s registers: Samplers with indices corresponding to the
- * sampled textures For b registers: Uniform buffers
- *
- * For DXIL shaders, use the following register order: For vertex shaders:
- * (t[n], space0): Sampled textures, followed by storage textures, followed by
- * storage buffers (s[n], space0): Samplers with indices corresponding to the
- * sampled textures (b[n], space1): Uniform buffers For pixel shaders: (t[n],
- * space2): Sampled textures, followed by storage textures, followed by
- * storage buffers (s[n], space2): Samplers with indices corresponding to the
- * sampled textures (b[n], space3): Uniform buffers
- *
- * For MSL/metallib, use the following order: For [[texture]]: Sampled
- * textures, followed by storage textures For [[sampler]]: Samplers with
- * indices corresponding to the sampled textures For [[buffer]]: Uniform
- * buffers, followed by storage buffers. Vertex buffer 0 is bound at
- * [[buffer(30)]], vertex buffer 1 at [[buffer(29)]], and so on. Rather than
- * manually authoring vertex buffer indices, use the [[stage_in]] attribute
- * which will automatically use the vertex input information from the
- * SDL_GPUPipeline.
- *
- * \param device a GPU Context.
- * \param shaderCreateInfo a struct describing the state of the desired
- * shader.
- * \returns a shader object on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_CreateGPUGraphicsPipeline
- * \sa SDL_ReleaseGPUShader
- */
- extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader(
- SDL_GPUDevice *device,
- SDL_GPUShaderCreateInfo *shaderCreateInfo);
- /**
- * Creates a texture object to be used in graphics or compute workflows.
- *
- * The contents of this texture are undefined until data is written to the
- * texture.
- *
- * Note that certain combinations of usage flags are invalid. For example, a
- * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags.
- *
- * If you request a sample count higher than the hardware supports, the
- * implementation will automatically fall back to the highest available sample
- * count.
- *
- * \param device a GPU Context.
- * \param textureCreateInfo a struct describing the state of the texture to
- * create.
- * \returns a texture object on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_UploadToGPUTexture
- * \sa SDL_DownloadFromGPUTexture
- * \sa SDL_BindGPUVertexSamplers
- * \sa SDL_BindGPUVertexStorageTextures
- * \sa SDL_BindGPUFragmentSamplers
- * \sa SDL_BindGPUFragmentStorageTextures
- * \sa SDL_BindGPUComputeStorageTextures
- * \sa SDL_BlitGPUTexture
- * \sa SDL_ReleaseGPUTexture
- * \sa SDL_GPUTextureSupportsFormat
- */
- extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture(
- SDL_GPUDevice *device,
- SDL_GPUTextureCreateInfo *textureCreateInfo);
- /**
- * Creates a buffer object to be used in graphics or compute workflows.
- *
- * The contents of this buffer are undefined until data is written to the
- * buffer.
- *
- * Note that certain combinations of usage flags are invalid. For example, a
- * buffer cannot have both the VERTEX and INDEX flags.
- *
- * \param device a GPU Context.
- * \param bufferCreateInfo a struct describing the state of the buffer to
- * create.
- * \returns a buffer object on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_UploadToGPUBuffer
- * \sa SDL_BindGPUVertexBuffers
- * \sa SDL_BindGPUIndexBuffer
- * \sa SDL_BindGPUVertexStorageBuffers
- * \sa SDL_BindGPUFragmentStorageBuffers
- * \sa SDL_BindGPUComputeStorageBuffers
- * \sa SDL_ReleaseGPUBuffer
- */
- extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer(
- SDL_GPUDevice *device,
- SDL_GPUBufferCreateInfo *bufferCreateInfo);
- /**
- * Creates a transfer buffer to be used when uploading to or downloading from
- * graphics resources.
- *
- * \param device a GPU Context.
- * \param transferBufferCreateInfo a struct describing the state of the
- * transfer buffer to create.
- * \returns a transfer buffer on success, or NULL on failure.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_UploadToGPUBuffer
- * \sa SDL_DownloadFromGPUBuffer
- * \sa SDL_UploadToGPUTexture
- * \sa SDL_DownloadFromGPUTexture
- * \sa SDL_ReleaseGPUTransferBuffer
- */
- extern SDL_DECLSPEC SDL_GPUTransferBuffer *SDLCALL SDL_CreateGPUTransferBuffer(
- SDL_GPUDevice *device,
- SDL_GPUTransferBufferCreateInfo *transferBufferCreateInfo);
- /* Debug Naming */
- /**
- * Sets an arbitrary string constant to label a buffer.
- *
- * Useful for debugging.
- *
- * \param device a GPU Context.
- * \param buffer a buffer to attach the name to.
- * \param text a UTF-8 string constant to mark as the name of the buffer.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName(
- SDL_GPUDevice *device,
- SDL_GPUBuffer *buffer,
- const char *text);
- /**
- * Sets an arbitrary string constant to label a texture.
- *
- * Useful for debugging.
- *
- * \param device a GPU Context.
- * \param texture a texture to attach the name to.
- * \param text a UTF-8 string constant to mark as the name of the texture.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName(
- SDL_GPUDevice *device,
- SDL_GPUTexture *texture,
- const char *text);
- /**
- * Inserts an arbitrary string label into the command buffer callstream.
- *
- * Useful for debugging.
- *
- * \param commandBuffer a command buffer.
- * \param text a UTF-8 string constant to insert as the label.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel(
- SDL_GPUCommandBuffer *commandBuffer,
- const char *text);
- /**
- * Begins a debug group with an arbitary name.
- *
- * Used for denoting groups of calls when viewing the command buffer
- * callstream in a graphics debugging tool.
- *
- * Each call to SDL_PushGPUDebugGroup must have a corresponding call to
- * SDL_PopGPUDebugGroup.
- *
- * On some backends (e.g. Metal), pushing a debug group during a
- * render/blit/compute pass will create a group that is scoped to the native
- * pass rather than the command buffer. For best results, if you push a debug
- * group during a pass, always pop it in the same pass.
- *
- * \param commandBuffer a command buffer.
- * \param name a UTF-8 string constant that names the group.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_PopGPUDebugGroup
- */
- extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup(
- SDL_GPUCommandBuffer *commandBuffer,
- const char *name);
- /**
- * Ends the most-recently pushed debug group.
- *
- * \param commandBuffer a command buffer.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_PushGPUDebugGroup
- */
- extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup(
- SDL_GPUCommandBuffer *commandBuffer);
- /* Disposal */
- /**
- * Frees the given texture as soon as it is safe to do so.
- *
- * You must not reference the texture after calling this function.
- *
- * \param device a GPU context.
- * \param texture a texture to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture(
- SDL_GPUDevice *device,
- SDL_GPUTexture *texture);
- /**
- * Frees the given sampler as soon as it is safe to do so.
- *
- * You must not reference the texture after calling this function.
- *
- * \param device a GPU context.
- * \param sampler a sampler to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler(
- SDL_GPUDevice *device,
- SDL_GPUSampler *sampler);
- /**
- * Frees the given buffer as soon as it is safe to do so.
- *
- * You must not reference the buffer after calling this function.
- *
- * \param device a GPU context.
- * \param buffer a buffer to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer(
- SDL_GPUDevice *device,
- SDL_GPUBuffer *buffer);
- /**
- * Frees the given transfer buffer as soon as it is safe to do so.
- *
- * You must not reference the transfer buffer after calling this function.
- *
- * \param device a GPU context.
- * \param transferBuffer a transfer buffer to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer(
- SDL_GPUDevice *device,
- SDL_GPUTransferBuffer *transferBuffer);
- /**
- * Frees the given compute pipeline as soon as it is safe to do so.
- *
- * You must not reference the compute pipeline after calling this function.
- *
- * \param device a GPU context.
- * \param computePipeline a compute pipeline to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline(
- SDL_GPUDevice *device,
- SDL_GPUComputePipeline *computePipeline);
- /**
- * Frees the given shader as soon as it is safe to do so.
- *
- * You must not reference the shader after calling this function.
- *
- * \param device a GPU context.
- * \param shader a shader to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader(
- SDL_GPUDevice *device,
- SDL_GPUShader *shader);
- /**
- * Frees the given graphics pipeline as soon as it is safe to do so.
- *
- * You must not reference the graphics pipeline after calling this function.
- *
- * \param device a GPU context.
- * \param graphicsPipeline a graphics pipeline to be destroyed.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline(
- SDL_GPUDevice *device,
- SDL_GPUGraphicsPipeline *graphicsPipeline);
- /*
- * COMMAND BUFFERS
- *
- * Render state is managed via command buffers.
- * When setting render state, that state is always local to the command buffer.
- *
- * Commands only begin execution on the GPU once Submit is called.
- * Once the command buffer is submitted, it is no longer valid to use it.
- *
- * Command buffers are executed in submission order. If you submit command buffer A and then command buffer B
- * all commands in A will begin executing before any command in B begins executing.
- *
- * In multi-threading scenarios, you should acquire and submit a command buffer on the same thread.
- * As long as you satisfy this requirement, all functionality related to command buffers is thread-safe.
- */
- /**
- * Acquire a command buffer.
- *
- * This command buffer is managed by the implementation and should not be
- * freed by the user. The command buffer may only be used on the thread it was
- * acquired on. The command buffer should be submitted on the thread it was
- * acquired on.
- *
- * \param device a GPU context.
- * \returns a command buffer.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SubmitGPUCommandBuffer
- * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
- */
- extern SDL_DECLSPEC SDL_GPUCommandBuffer *SDLCALL SDL_AcquireGPUCommandBuffer(
- SDL_GPUDevice *device);
- /*
- * UNIFORM DATA
- *
- * Uniforms are for passing data to shaders.
- * The uniform data will be constant across all executions of the shader.
- *
- * There are 4 available uniform slots per shader stage (vertex, fragment, compute).
- * Uniform data pushed to a slot on a stage keeps its value throughout the command buffer
- * until you call the relevant Push function on that slot again.
- *
- * For example, you could write your vertex shaders to read a camera matrix from uniform binding slot 0,
- * push the camera matrix at the start of the command buffer, and that data will be used for every
- * subsequent draw call.
- *
- * It is valid to push uniform data during a render or compute pass.
- *
- * Uniforms are best for pushing small amounts of data.
- * If you are pushing more than a matrix or two per call you should consider using a storage buffer instead.
- */
- /**
- * Pushes data to a vertex uniform slot on the command buffer.
- *
- * Subsequent draw calls will use this uniform data.
- *
- * \param commandBuffer a command buffer.
- * \param slotIndex the vertex uniform slot to push data to.
- * \param data client data to write.
- * \param dataLengthInBytes the length of the data to write.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData(
- SDL_GPUCommandBuffer *commandBuffer,
- Uint32 slotIndex,
- const void *data,
- Uint32 dataLengthInBytes);
- /**
- * Pushes data to a fragment uniform slot on the command buffer.
- *
- * Subsequent draw calls will use this uniform data.
- *
- * \param commandBuffer a command buffer.
- * \param slotIndex the fragment uniform slot to push data to.
- * \param data client data to write.
- * \param dataLengthInBytes the length of the data to write.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData(
- SDL_GPUCommandBuffer *commandBuffer,
- Uint32 slotIndex,
- const void *data,
- Uint32 dataLengthInBytes);
- /**
- * Pushes data to a uniform slot on the command buffer.
- *
- * Subsequent draw calls will use this uniform data.
- *
- * \param commandBuffer a command buffer.
- * \param slotIndex the uniform slot to push data to.
- * \param data client data to write.
- * \param dataLengthInBytes the length of the data to write.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData(
- SDL_GPUCommandBuffer *commandBuffer,
- Uint32 slotIndex,
- const void *data,
- Uint32 dataLengthInBytes);
- /*
- * A NOTE ON CYCLING
- *
- * When using a command buffer, operations do not occur immediately -
- * they occur some time after the command buffer is submitted.
- *
- * When a resource is used in a pending or active command buffer, it is considered to be "bound".
- * When a resource is no longer used in any pending or active command buffers, it is considered to be "unbound".
- *
- * If data resources are bound, it is unspecified when that data will be unbound
- * unless you acquire a fence when submitting the command buffer and wait on it.
- * However, this doesn't mean you need to track resource usage manually.
- *
- * All of the functions and structs that involve writing to a resource have a "cycle" bool.
- * GPUTransferBuffer, GPUBuffer, and GPUTexture all effectively function as ring buffers on internal resources.
- * When cycle is SDL_TRUE, if the resource is bound, the cycle rotates to the next unbound internal resource,
- * or if none are available, a new one is created.
- * This means you don't have to worry about complex state tracking and synchronization as long as cycling is correctly employed.
- *
- * For example: you can call MapTransferBuffer, write texture data, UnmapTransferBuffer, and then UploadToTexture.
- * The next time you write texture data to the transfer buffer, if you set the cycle param to SDL_TRUE, you don't have
- * to worry about overwriting any data that is not yet uploaded.
- *
- * Another example: If you are using a texture in a render pass every frame, this can cause a data dependency between frames.
- * If you set cycle to SDL_TRUE in the ColorAttachmentInfo struct, you can prevent this data dependency.
- *
- * Cycling will never undefine already bound data.
- * When cycling, all data in the resource is considered to be undefined for subsequent commands until that data is written again.
- * You must take care not to read undefined data.
- *
- * Note that when cycling a texture, the entire texture will be cycled,
- * even if only part of the texture is used in the call,
- * so you must consider the entire texture to contain undefined data after cycling.
- *
- * You must also take care not to overwrite a section of data that has been referenced in a command without cycling first.
- * It is OK to overwrite unreferenced data in a bound resource without cycling,
- * but overwriting a section of data that has already been referenced will produce unexpected results.
- */
- /* Graphics State */
- /**
- * Begins a render pass on a command buffer.
- *
- * A render pass consists of a set of texture subresources (or depth slices in
- * the 3D texture case) which will be rendered to during the render pass,
- * along with corresponding clear values and load/store operations. All
- * operations related to graphics pipelines must take place inside of a render
- * pass. A default viewport and scissor state are automatically set when this
- * is called. You cannot begin another render pass, or begin a compute pass or
- * copy pass until you have ended the render pass.
- *
- * \param commandBuffer a command buffer.
- * \param colorAttachmentInfos an array of texture subresources with
- * corresponding clear values and load/store ops.
- * \param colorAttachmentCount the number of color attachments in the
- * colorAttachmentInfos array.
- * \param depthStencilAttachmentInfo a texture subresource with corresponding
- * clear value and load/store ops, may be
- * NULL.
- * \returns a render pass handle.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_EndGPURenderPass
- */
- extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass(
- SDL_GPUCommandBuffer *commandBuffer,
- SDL_GPUColorAttachmentInfo *colorAttachmentInfos,
- Uint32 colorAttachmentCount,
- SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo);
- /**
- * Binds a graphics pipeline on a render pass to be used in rendering.
- *
- * A graphics pipeline must be bound before making any draw calls.
- *
- * \param renderPass a render pass handle.
- * \param graphicsPipeline the graphics pipeline to bind.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline(
- SDL_GPURenderPass *renderPass,
- SDL_GPUGraphicsPipeline *graphicsPipeline);
- /**
- * Sets the current viewport state on a command buffer.
- *
- * \param renderPass a render pass handle.
- * \param viewport the viewport to set.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport(
- SDL_GPURenderPass *renderPass,
- SDL_GPUViewport *viewport);
- /**
- * Sets the current scissor state on a command buffer.
- *
- * \param renderPass a render pass handle.
- * \param scissor the scissor area to set.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor(
- SDL_GPURenderPass *renderPass,
- SDL_Rect *scissor);
- /**
- * Binds vertex buffers on a command buffer for use with subsequent draw
- * calls.
- *
- * \param renderPass a render pass handle.
- * \param firstBinding the starting bind point for the vertex buffers.
- * \param pBindings an array of SDL_GPUBufferBinding structs containing vertex
- * buffers and offset values.
- * \param bindingCount the number of bindings in the pBindings array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers(
- SDL_GPURenderPass *renderPass,
- Uint32 firstBinding,
- SDL_GPUBufferBinding *pBindings,
- Uint32 bindingCount);
- /**
- * Binds an index buffer on a command buffer for use with subsequent draw
- * calls.
- *
- * \param renderPass a render pass handle.
- * \param pBinding a pointer to a struct containing an index buffer and
- * offset.
- * \param indexElementSize whether the index values in the buffer are 16- or
- * 32-bit.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer(
- SDL_GPURenderPass *renderPass,
- SDL_GPUBufferBinding *pBinding,
- SDL_GPUIndexElementSize indexElementSize);
- /**
- * Binds texture-sampler pairs for use on the vertex shader.
- *
- * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT.
- *
- * \param renderPass a render pass handle.
- * \param firstSlot the vertex sampler slot to begin binding from.
- * \param textureSamplerBindings an array of texture-sampler binding structs.
- * \param bindingCount the number of texture-sampler pairs to bind from the
- * array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers(
- SDL_GPURenderPass *renderPass,
- Uint32 firstSlot,
- SDL_GPUTextureSamplerBinding *textureSamplerBindings,
- Uint32 bindingCount);
- /**
- * Binds storage textures for use on the vertex shader.
- *
- * These textures must have been created with
- * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ_BIT.
- *
- * \param renderPass a render pass handle.
- * \param firstSlot the vertex storage texture slot to begin binding from.
- * \param storageTextures an array of storage textures.
- * \param bindingCount the number of storage texture to bind from the array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures(
- SDL_GPURenderPass *renderPass,
- Uint32 firstSlot,
- SDL_GPUTexture **storageTextures,
- Uint32 bindingCount);
- /**
- * Binds storage buffers for use on the vertex shader.
- *
- * These buffers must have been created with
- * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ_BIT.
- *
- * \param renderPass a render pass handle.
- * \param firstSlot the vertex storage buffer slot to begin binding from.
- * \param storageBuffers an array of buffers.
- * \param bindingCount the number of buffers to bind from the array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers(
- SDL_GPURenderPass *renderPass,
- Uint32 firstSlot,
- SDL_GPUBuffer **storageBuffers,
- Uint32 bindingCount);
- /**
- * Binds texture-sampler pairs for use on the fragment shader.
- *
- * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER_BIT.
- *
- * \param renderPass a render pass handle.
- * \param firstSlot the fragment sampler slot to begin binding from.
- * \param textureSamplerBindings an array of texture-sampler binding structs.
- * \param bindingCount the number of texture-sampler pairs to bind from the
- * array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers(
- SDL_GPURenderPass *renderPass,
- Uint32 firstSlot,
- SDL_GPUTextureSamplerBinding *textureSamplerBindings,
- Uint32 bindingCount);
- /**
- * Binds storage textures for use on the fragment shader.
- *
- * These textures must have been created with
- * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ_BIT.
- *
- * \param renderPass a render pass handle.
- * \param firstSlot the fragment storage texture slot to begin binding from.
- * \param storageTextures an array of storage textures.
- * \param bindingCount the number of storage textures to bind from the array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures(
- SDL_GPURenderPass *renderPass,
- Uint32 firstSlot,
- SDL_GPUTexture **storageTextures,
- Uint32 bindingCount);
- /**
- * Binds storage buffers for use on the fragment shader.
- *
- * These buffers must have been created with
- * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ_BIT.
- *
- * \param renderPass a render pass handle.
- * \param firstSlot the fragment storage buffer slot to begin binding from.
- * \param storageBuffers an array of storage buffers.
- * \param bindingCount the number of storage buffers to bind from the array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers(
- SDL_GPURenderPass *renderPass,
- Uint32 firstSlot,
- SDL_GPUBuffer **storageBuffers,
- Uint32 bindingCount);
- /* Drawing */
- /**
- * Draws data using bound graphics state with an index buffer and instancing
- * enabled.
- *
- * You must not call this function before binding a graphics pipeline.
- *
- * Note that the `firstVertex` and `firstInstance` parameters are NOT
- * compatible with built-in vertex/instance ID variables in shaders (for
- * example, SV_VertexID). If your shader depends on these variables, the
- * correlating draw call parameter MUST be 0.
- *
- * \param renderPass a render pass handle.
- * \param indexCount the number of vertices to draw per instance.
- * \param instanceCount the number of instances to draw.
- * \param firstIndex the starting index within the index buffer.
- * \param vertexOffset value added to vertex index before indexing into the
- * vertex buffer.
- * \param firstInstance the ID of the first instance to draw.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives(
- SDL_GPURenderPass *renderPass,
- Uint32 indexCount,
- Uint32 instanceCount,
- Uint32 firstIndex,
- Sint32 vertexOffset,
- Uint32 firstInstance);
- /**
- * Draws data using bound graphics state.
- *
- * You must not call this function before binding a graphics pipeline.
- *
- * Note that the `firstVertex` and `firstInstance` parameters are NOT
- * compatible with built-in vertex/instance ID variables in shaders (for
- * example, SV_VertexID). If your shader depends on these variables, the
- * correlating draw call parameter MUST be 0.
- *
- * \param renderPass a render pass handle.
- * \param vertexCount the number of vertices to draw.
- * \param instanceCount the number of instances that will be drawn.
- * \param firstVertex the index of the first vertex to draw.
- * \param firstInstance the ID of the first instance to draw.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives(
- SDL_GPURenderPass *renderPass,
- Uint32 vertexCount,
- Uint32 instanceCount,
- Uint32 firstVertex,
- Uint32 firstInstance);
- /**
- * Draws data using bound graphics state and with draw parameters set from a
- * buffer.
- *
- * The buffer layout should match the layout of SDL_GPUIndirectDrawCommand.
- * You must not call this function before binding a graphics pipeline.
- *
- * \param renderPass a render pass handle.
- * \param buffer a buffer containing draw parameters.
- * \param offsetInBytes the offset to start reading from the draw buffer.
- * \param drawCount the number of draw parameter sets that should be read from
- * the draw buffer.
- * \param stride the byte stride between sets of draw parameters.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect(
- SDL_GPURenderPass *renderPass,
- SDL_GPUBuffer *buffer,
- Uint32 offsetInBytes,
- Uint32 drawCount,
- Uint32 stride);
- /**
- * Draws data using bound graphics state with an index buffer enabled and with
- * draw parameters set from a buffer.
- *
- * The buffer layout should match the layout of
- * SDL_GPUIndexedIndirectDrawCommand. You must not call this function before
- * binding a graphics pipeline.
- *
- * \param renderPass a render pass handle.
- * \param buffer a buffer containing draw parameters.
- * \param offsetInBytes the offset to start reading from the draw buffer.
- * \param drawCount the number of draw parameter sets that should be read from
- * the draw buffer.
- * \param stride the byte stride between sets of draw parameters.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect(
- SDL_GPURenderPass *renderPass,
- SDL_GPUBuffer *buffer,
- Uint32 offsetInBytes,
- Uint32 drawCount,
- Uint32 stride);
- /**
- * Ends the given render pass.
- *
- * All bound graphics state on the render pass command buffer is unset. The
- * render pass handle is now invalid.
- *
- * \param renderPass a render pass handle.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass(
- SDL_GPURenderPass *renderPass);
- /* Compute Pass */
- /**
- * Begins a compute pass on a command buffer.
- *
- * A compute pass is defined by a set of texture subresources and buffers that
- * will be written to by compute pipelines. These textures and buffers must
- * have been created with the COMPUTE_STORAGE_WRITE bit. All operations
- * related to compute pipelines must take place inside of a compute pass. You
- * must not begin another compute pass, or a render pass or copy pass before
- * ending the compute pass.
- *
- * A VERY IMPORTANT NOTE Textures and buffers bound as write-only MUST NOT be
- * read from during the compute pass. Doing so will result in undefined
- * behavior. If your compute work requires reading the output from a previous
- * dispatch, you MUST end the current compute pass and begin a new one before
- * you can safely access the data.
- *
- * \param commandBuffer a command buffer.
- * \param storageTextureBindings an array of writeable storage texture binding
- * structs.
- * \param storageTextureBindingCount the number of storage textures to bind
- * from the array.
- * \param storageBufferBindings an array of writeable storage buffer binding
- * structs.
- * \param storageBufferBindingCount the number of storage buffers to bind from
- * the array.
- * \returns a compute pass handle.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_EndGPUComputePass
- */
- extern SDL_DECLSPEC SDL_GPUComputePass *SDLCALL SDL_BeginGPUComputePass(
- SDL_GPUCommandBuffer *commandBuffer,
- SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings,
- Uint32 storageTextureBindingCount,
- SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings,
- Uint32 storageBufferBindingCount);
- /**
- * Binds a compute pipeline on a command buffer for use in compute dispatch.
- *
- * \param computePass a compute pass handle.
- * \param computePipeline a compute pipeline to bind.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline(
- SDL_GPUComputePass *computePass,
- SDL_GPUComputePipeline *computePipeline);
- /**
- * Binds storage textures as readonly for use on the compute pipeline.
- *
- * These textures must have been created with
- * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ_BIT.
- *
- * \param computePass a compute pass handle.
- * \param firstSlot the compute storage texture slot to begin binding from.
- * \param storageTextures an array of storage textures.
- * \param bindingCount the number of storage textures to bind from the array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures(
- SDL_GPUComputePass *computePass,
- Uint32 firstSlot,
- SDL_GPUTexture **storageTextures,
- Uint32 bindingCount);
- /**
- * Binds storage buffers as readonly for use on the compute pipeline.
- *
- * These buffers must have been created with
- * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ_BIT.
- *
- * \param computePass a compute pass handle.
- * \param firstSlot the compute storage buffer slot to begin binding from.
- * \param storageBuffers an array of storage buffer binding structs.
- * \param bindingCount the number of storage buffers to bind from the array.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers(
- SDL_GPUComputePass *computePass,
- Uint32 firstSlot,
- SDL_GPUBuffer **storageBuffers,
- Uint32 bindingCount);
- /**
- * Dispatches compute work.
- *
- * You must not call this function before binding a compute pipeline.
- *
- * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
- * the dispatches write to the same resource region as each other, there is no
- * guarantee of which order the writes will occur. If the write order matters,
- * you MUST end the compute pass and begin another one.
- *
- * \param computePass a compute pass handle.
- * \param groupCountX number of local workgroups to dispatch in the X
- * dimension.
- * \param groupCountY number of local workgroups to dispatch in the Y
- * dimension.
- * \param groupCountZ number of local workgroups to dispatch in the Z
- * dimension.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute(
- SDL_GPUComputePass *computePass,
- Uint32 groupCountX,
- Uint32 groupCountY,
- Uint32 groupCountZ);
- /**
- * Dispatches compute work with parameters set from a buffer.
- *
- * The buffer layout should match the layout of
- * SDL_GPUIndirectDispatchCommand. You must not call this function before
- * binding a compute pipeline.
- *
- * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and
- * the dispatches write to the same resource region as each other, there is no
- * guarantee of which order the writes will occur. If the write order matters,
- * you MUST end the compute pass and begin another one.
- *
- * \param computePass a compute pass handle.
- * \param buffer a buffer containing dispatch parameters.
- * \param offsetInBytes the offset to start reading from the dispatch buffer.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect(
- SDL_GPUComputePass *computePass,
- SDL_GPUBuffer *buffer,
- Uint32 offsetInBytes);
- /**
- * Ends the current compute pass.
- *
- * All bound compute state on the command buffer is unset. The compute pass
- * handle is now invalid.
- *
- * \param computePass a compute pass handle.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(
- SDL_GPUComputePass *computePass);
- /* TransferBuffer Data */
- /**
- * Maps a transfer buffer into application address space.
- *
- * You must unmap the transfer buffer before encoding upload commands.
- *
- * \param device a GPU context.
- * \param transferBuffer a transfer buffer.
- * \param cycle if SDL_TRUE, cycles the transfer buffer if it is bound.
- * \returns the address of the mapped transfer buffer memory.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void *SDLCALL SDL_MapGPUTransferBuffer(
- SDL_GPUDevice *device,
- SDL_GPUTransferBuffer *transferBuffer,
- SDL_bool cycle);
- /**
- * Unmaps a previously mapped transfer buffer.
- *
- * \param device a GPU context.
- * \param transferBuffer a previously mapped transfer buffer.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer(
- SDL_GPUDevice *device,
- SDL_GPUTransferBuffer *transferBuffer);
- /* Copy Pass */
- /**
- * Begins a copy pass on a command buffer.
- *
- * All operations related to copying to or from buffers or textures take place
- * inside a copy pass. You must not begin another copy pass, or a render pass
- * or compute pass before ending the copy pass.
- *
- * \param commandBuffer a command buffer.
- * \returns a copy pass handle.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass(
- SDL_GPUCommandBuffer *commandBuffer);
- /**
- * Uploads data from a transfer buffer to a texture.
- *
- * The upload occurs on the GPU timeline. You may assume that the upload has
- * finished in subsequent commands.
- *
- * You must align the data in the transfer buffer to a multiple of the texel
- * size of the texture format.
- *
- * \param copyPass a copy pass handle.
- * \param source the source transfer buffer with image layout information.
- * \param destination the destination texture region.
- * \param cycle if SDL_TRUE, cycles the texture if the texture is bound,
- * otherwise overwrites the data.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture(
- SDL_GPUCopyPass *copyPass,
- SDL_GPUTextureTransferInfo *source,
- SDL_GPUTextureRegion *destination,
- SDL_bool cycle);
- /* Uploads data from a TransferBuffer to a Buffer. */
- /**
- * Uploads data from a transfer buffer to a buffer.
- *
- * The upload occurs on the GPU timeline. You may assume that the upload has
- * finished in subsequent commands.
- *
- * \param copyPass a copy pass handle.
- * \param source the source transfer buffer with offset.
- * \param destination the destination buffer with offset and size.
- * \param cycle if SDL_TRUE, cycles the buffer if it is bound, otherwise
- * overwrites the data.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer(
- SDL_GPUCopyPass *copyPass,
- SDL_GPUTransferBufferLocation *source,
- SDL_GPUBufferRegion *destination,
- SDL_bool cycle);
- /**
- * Performs a texture-to-texture copy.
- *
- * This copy occurs on the GPU timeline. You may assume the copy has finished
- * in subsequent commands.
- *
- * \param copyPass a copy pass handle.
- * \param source a source texture region.
- * \param destination a destination texture region.
- * \param w the width of the region to copy.
- * \param h the height of the region to copy.
- * \param d the depth of the region to copy.
- * \param cycle if SDL_TRUE, cycles the destination texture if the destination
- * texture is bound, otherwise overwrites the data.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture(
- SDL_GPUCopyPass *copyPass,
- SDL_GPUTextureLocation *source,
- SDL_GPUTextureLocation *destination,
- Uint32 w,
- Uint32 h,
- Uint32 d,
- SDL_bool cycle);
- /* Copies data from a buffer to a buffer. */
- /**
- * Performs a buffer-to-buffer copy.
- *
- * This copy occurs on the GPU timeline. You may assume the copy has finished
- * in subsequent commands.
- *
- * \param copyPass a copy pass handle.
- * \param source the buffer and offset to copy from.
- * \param destination the buffer and offset to copy to.
- * \param size the length of the buffer to copy.
- * \param cycle if SDL_TRUE, cycles the destination buffer if it is bound,
- * otherwise overwrites the data.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer(
- SDL_GPUCopyPass *copyPass,
- SDL_GPUBufferLocation *source,
- SDL_GPUBufferLocation *destination,
- Uint32 size,
- SDL_bool cycle);
- /**
- * Copies data from a texture to a transfer buffer on the GPU timeline.
- *
- * This data is not guaranteed to be copied until the command buffer fence is
- * signaled.
- *
- * \param copyPass a copy pass handle.
- * \param source the source texture region.
- * \param destination the destination transfer buffer with image layout
- * information.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture(
- SDL_GPUCopyPass *copyPass,
- SDL_GPUTextureRegion *source,
- SDL_GPUTextureTransferInfo *destination);
- /**
- * Copies data from a buffer to a transfer buffer on the GPU timeline.
- *
- * This data is not guaranteed to be copied until the command buffer fence is
- * signaled.
- *
- * \param copyPass a copy pass handle.
- * \param source the source buffer with offset and size.
- * \param destination the destination transfer buffer with offset.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer(
- SDL_GPUCopyPass *copyPass,
- SDL_GPUBufferRegion *source,
- SDL_GPUTransferBufferLocation *destination);
- /**
- * Ends the current copy pass.
- *
- * \param copyPass a copy pass handle.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass(
- SDL_GPUCopyPass *copyPass);
- /**
- * Generates mipmaps for the given texture.
- *
- * This function must not be called inside of any pass.
- *
- * \param commandBuffer a commandBuffer.
- * \param texture a texture with more than 1 mip level.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(
- SDL_GPUCommandBuffer *commandBuffer,
- SDL_GPUTexture *texture);
- /**
- * Blits from a source texture region to a destination texture region.
- *
- * This function must not be called inside of any pass.
- *
- * \param commandBuffer a command buffer.
- * \param source the texture region to copy from.
- * \param destination the texture region to copy to.
- * \param flipMode the flip mode for the source texture region.
- * \param filterMode the filter mode that will be used when blitting.
- * \param cycle if SDL_TRUE, cycles the destination texture if the destination
- * texture is bound, otherwise overwrites the data.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
- SDL_GPUCommandBuffer *commandBuffer,
- SDL_GPUBlitRegion *source,
- SDL_GPUBlitRegion *destination,
- SDL_FlipMode flipMode,
- SDL_GPUFilter filterMode,
- SDL_bool cycle);
- /* Submission/Presentation */
- /**
- * Determines whether a swapchain composition is supported by the window.
- *
- * The window must be claimed before calling this function.
- *
- * \param device a GPU context.
- * \param window an SDL_Window.
- * \param swapchainComposition the swapchain composition to check.
- * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error).
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_ClaimWindowForGPUDevice
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition(
- SDL_GPUDevice *device,
- SDL_Window *window,
- SDL_GPUSwapchainComposition swapchainComposition);
- /**
- * Determines whether a presentation mode is supported by the window.
- *
- * The window must be claimed before calling this function.
- *
- * \param device a GPU context.
- * \param window an SDL_Window.
- * \param presentMode the presentation mode to check.
- * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error).
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_ClaimWindowForGPUDevice
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUPresentMode(
- SDL_GPUDevice *device,
- SDL_Window *window,
- SDL_GPUPresentMode presentMode);
- /**
- * Claims a window, creating a swapchain structure for it.
- *
- * This must be called before SDL_AcquireGPUSwapchainTexture is called using
- * the window.
- *
- * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and
- * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain
- * parameters, you must call SetSwapchainParameters after claiming the window.
- *
- * \param device a GPU context.
- * \param window an SDL_Window.
- * \returns SDL_TRUE on success, otherwise SDL_FALSE.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_AcquireGPUSwapchainTexture
- * \sa SDL_ReleaseWindowFromGPUDevice
- * \sa SDL_WindowSupportsGPUPresentMode
- * \sa SDL_WindowSupportsGPUSwapchainComposition
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClaimWindowForGPUDevice(
- SDL_GPUDevice *device,
- SDL_Window *window);
- /**
- * Unclaims a window, destroying its swapchain structure.
- *
- * \param device a GPU context.
- * \param window an SDL_Window that has been claimed.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_ClaimWindowForGPUDevice
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice(
- SDL_GPUDevice *device,
- SDL_Window *window);
- /**
- * Changes the swapchain parameters for the given claimed window.
- *
- * This function will fail if the requested present mode or swapchain
- * composition are unsupported by the device. Check if the parameters are
- * supported via SDL_WindowSupportsGPUPresentMode /
- * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function.
- *
- * SDL_GPU_PRESENTMODE_VSYNC and SDL_GPU_SWAPCHAINCOMPOSITION_SDR are always
- * supported.
- *
- * \param device a GPU context.
- * \param window an SDL_Window that has been claimed.
- * \param swapchainComposition the desired composition of the swapchain.
- * \param presentMode the desired present mode for the swapchain.
- * \returns SDL_TRUE if successful, SDL_FALSE on error.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_WindowSupportsGPUPresentMode
- * \sa SDL_WindowSupportsGPUSwapchainComposition
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGPUSwapchainParameters(
- SDL_GPUDevice *device,
- SDL_Window *window,
- SDL_GPUSwapchainComposition swapchainComposition,
- SDL_GPUPresentMode presentMode);
- /**
- * Obtains the texture format of the swapchain for the given window.
- *
- * \param device a GPU context.
- * \param window an SDL_Window that has been claimed.
- * \returns the texture format of the swapchain.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureFormat(
- SDL_GPUDevice *device,
- SDL_Window *window);
- /**
- * Acquire a texture to use in presentation.
- *
- * When a swapchain texture is acquired on a command buffer, it will
- * automatically be submitted for presentation when the command buffer is
- * submitted. The swapchain texture should only be referenced by the command
- * buffer used to acquire it. May return NULL under certain conditions. This
- * is not necessarily an error. This texture is managed by the implementation
- * and must not be freed by the user. You MUST NOT call this function from any
- * thread other than the one that created the window.
- *
- * \param commandBuffer a command buffer.
- * \param window a window that has been claimed.
- * \param pWidth a pointer filled in with the swapchain width.
- * \param pHeight a pointer filled in with the swapchain height.
- * \returns a swapchain texture.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_ClaimWindowForGPUDevice
- * \sa SDL_SubmitGPUCommandBuffer
- * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
- */
- extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_AcquireGPUSwapchainTexture(
- SDL_GPUCommandBuffer *commandBuffer,
- SDL_Window *window,
- Uint32 *pWidth,
- Uint32 *pHeight);
- /**
- * Submits a command buffer so its commands can be processed on the GPU.
- *
- * It is invalid to use the command buffer after this is called.
- *
- * This must be called from the thread the command buffer was acquired on.
- *
- * All commands in the submission are guaranteed to begin executing before any
- * command in a subsequent submission begins executing.
- *
- * \param commandBuffer a command buffer.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_AcquireGPUCommandBuffer
- * \sa SDL_AcquireGPUSwapchainTexture
- * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
- */
- extern SDL_DECLSPEC void SDLCALL SDL_SubmitGPUCommandBuffer(
- SDL_GPUCommandBuffer *commandBuffer);
- /**
- * Submits a command buffer so its commands can be processed on the GPU, and
- * acquires a fence associated with the command buffer.
- *
- * You must release this fence when it is no longer needed or it will cause a
- * leak. It is invalid to use the command buffer after this is called.
- *
- * This must be called from the thread the command buffer was acquired on.
- *
- * All commands in the submission are guaranteed to begin executing before any
- * command in a subsequent submission begins executing.
- *
- * \param commandBuffer a command buffer.
- * \returns a fence associated with the command buffer.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_AcquireGPUCommandBuffer
- * \sa SDL_AcquireGPUSwapchainTexture
- * \sa SDL_SubmitGPUCommandBuffer
- * \sa SDL_ReleaseGPUFence
- */
- extern SDL_DECLSPEC SDL_GPUFence *SDLCALL SDL_SubmitGPUCommandBufferAndAcquireFence(
- SDL_GPUCommandBuffer *commandBuffer);
- /**
- * Blocks the thread until the GPU is completely idle.
- *
- * \param device a GPU context.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_WaitForGPUFences
- */
- extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUIdle(
- SDL_GPUDevice *device);
- /**
- * Blocks the thread until the given fences are signaled.
- *
- * \param device a GPU context.
- * \param waitAll if 0, wait for any fence to be signaled, if 1, wait for all
- * fences to be signaled.
- * \param pFences an array of fences to wait on.
- * \param fenceCount the number of fences in the pFences array.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
- * \sa SDL_WaitForGPUIdle
- */
- extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUFences(
- SDL_GPUDevice *device,
- SDL_bool waitAll,
- SDL_GPUFence **pFences,
- Uint32 fenceCount);
- /**
- * Checks the status of a fence.
- *
- * \param device a GPU context.
- * \param fence a fence.
- * \returns SDL_TRUE if the fence is signaled, SDL_FALSE if it is not.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_QueryGPUFence(
- SDL_GPUDevice *device,
- SDL_GPUFence *fence);
- /**
- * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence.
- *
- * \param device a GPU context.
- * \param fence a fence.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SubmitGPUCommandBufferAndAcquireFence
- */
- extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence(
- SDL_GPUDevice *device,
- SDL_GPUFence *fence);
- /* Format Info */
- /**
- * Obtains the texel block size for a texture format.
- *
- * \param textureFormat the texture format you want to know the texel size of.
- * \returns the texel block size of the texture format.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_UploadToGPUTexture
- */
- extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize(
- SDL_GPUTextureFormat textureFormat);
- /**
- * Determines whether a texture format is supported for a given type and
- * usage.
- *
- * \param device a GPU context.
- * \param format the texture format to check.
- * \param type the type of texture (2D, 3D, Cube).
- * \param usage a bitmask of all usage scenarios to check.
- * \returns whether the texture format is supported for this type and usage.
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsFormat(
- SDL_GPUDevice *device,
- SDL_GPUTextureFormat format,
- SDL_GPUTextureType type,
- SDL_GPUTextureUsageFlags usage);
- /**
- * Determines if a sample count for a texture format is supported.
- *
- * \param device a GPU context.
- * \param format the texture format to check.
- * \param sampleCount the sample count to check.
- * \returns a hardware-specific version of min(preferred, possible).
- *
- * \since This function is available since SDL 3.0.0.
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsSampleCount(
- SDL_GPUDevice *device,
- SDL_GPUTextureFormat format,
- SDL_GPUSampleCount sampleCount);
- #ifdef SDL_PLATFORM_GDK
- /**
- * Call this to suspend GPU operation on Xbox when you receive the
- * SDL_EVENT_DID_ENTER_BACKGROUND event.
- *
- * Do NOT call any SDL_GPU functions after calling this function! This must
- * also be called before calling SDL_GDKSuspendComplete.
- *
- * \param device a GPU context.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_AddEventWatch
- */
- extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device);
- /**
- * Call this to resume GPU operation on Xbox when you receive the
- * SDL_EVENT_WILL_ENTER_FOREGROUND event.
- *
- * When resuming, this function MUST be called before calling any other
- * SDL_GPU functions.
- *
- * \param device a GPU context.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_AddEventWatch
- */
- extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device);
- #endif /* SDL_PLATFORM_GDK */
- #ifdef __cplusplus
- }
- #endif /* __cplusplus */
- #endif /* SDL_GPU_H */
|