| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613 |
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
- 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_SupportsGpuTextureFormat 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 preferLowPower set this to SDL_TRUE if your app prefers energy
- * efficiency over maximum GPU performance.
- * \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,
- SDL_bool preferLowPower,
- const char *name);
- /**
- * Creates a GPU context.
- *
- * These are the supported properties:
- *
- * - `SDL_PROP_GPU_CREATEDEVICE_DEBUGMODE_BOOL`: enable debug mode properties
- * and validations, default is true
- * - `SDL_PROP_GPU_CREATEDEVICE_PREFERLOWPOWER_BOOL`: enable to prefer energy
- * efficiency over maximum GPU performance
- * - `SDL_PROP_GPU_CREATEDEVICE_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_CREATEDEVICE_SHADERS_SECRET_BOOL`: The app is able to provide
- * shaders for an NDA platform `SDL_PROP_GPU_CREATEDEVICE_SHADERS_SPIRV_BOOL`:
- * The app is able to provide SPIR-V shaders if applicable
- * `SDL_PROP_GPU_CREATEDEVICE_SHADERS_DXBC_BOOL`: The app is able to provide
- * DXBC shaders if applicable `SDL_PROP_GPU_CREATEDEVICE_SHADERS_DXIL_BOOL`:
- * The app is able to provide DXIL shaders if applicable
- * `SDL_PROP_GPU_CREATEDEVICE_SHADERS_MSL_BOOL`: The app is able to provide
- * MSL shaders if applicable
- * `SDL_PROP_GPU_CREATEDEVICE_SHADERS_METALLIB_BOOL`: The app is able to
- * provide Metal shader libraries if applicable
- *
- * With the D3D12 renderer: -
- * `SDL_PROP_GPU_CREATEDEVICE_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_CREATEDEVICE_DEBUGMODE_BOOL "SDL.gpu.createdevice.debugmode"
- #define SDL_PROP_GPU_CREATEDEVICE_PREFERLOWPOWER_BOOL "SDL.gpu.createdevice.preferlowpower"
- #define SDL_PROP_GPU_CREATEDEVICE_NAME_STRING "SDL.gpu.createdevice.name"
- #define SDL_PROP_GPU_CREATEDEVICE_SHADERS_SECRET_BOOL "SDL.gpu.createdevice.shaders.secret"
- #define SDL_PROP_GPU_CREATEDEVICE_SHADERS_SPIRV_BOOL "SDL.gpu.createdevice.shaders.spirv"
- #define SDL_PROP_GPU_CREATEDEVICE_SHADERS_DXBC_BOOL "SDL.gpu.createdevice.shaders.dxbc"
- #define SDL_PROP_GPU_CREATEDEVICE_SHADERS_DXIL_BOOL "SDL.gpu.createdevice.shaders.dxil"
- #define SDL_PROP_GPU_CREATEDEVICE_SHADERS_MSL_BOOL "SDL.gpu.createdevice.shaders.msl"
- #define SDL_PROP_GPU_CREATEDEVICE_SHADERS_METALLIB_BOOL "SDL.gpu.createdevice.shaders.metallib"
- #define SDL_PROP_GPU_CREATEDEVICE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.createdevice.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_BlitGpu
- * \sa SDL_ReleaseGpuTexture
- * \sa SDL_SupportsGpuTextureFormat
- */
- 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_SubmitGpu
- * \sa SDL_SubmitGpuAndAcquireFence
- */
- 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_GenerateGpuMipmaps(
- 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_BlitGpu(
- 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_ClaimGpuWindow
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SupportsGpuSwapchainComposition(
- 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_ClaimGpuWindow
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SupportsGpuPresentMode(
- 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_UnclaimGpuWindow
- * \sa SDL_SupportsGpuPresentMode
- * \sa SDL_SupportsGpuSwapchainComposition
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ClaimGpuWindow(
- 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_ClaimGpuWindow
- */
- extern SDL_DECLSPEC void SDLCALL SDL_UnclaimGpuWindow(
- 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_SupportsGpuPresentMode /
- * SDL_SupportsGpuSwapchainComposition 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_SupportsGpuPresentMode
- * \sa SDL_SupportsGpuSwapchainComposition
- */
- 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_ClaimGpuWindow
- * \sa SDL_SubmitGpu
- * \sa SDL_SubmitGpuAndAcquireFence
- */
- 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_SubmitGpuAndAcquireFence
- */
- extern SDL_DECLSPEC void SDLCALL SDL_SubmitGpu(
- 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_SubmitGpu
- * \sa SDL_ReleaseGpuFence
- */
- extern SDL_DECLSPEC SDL_GpuFence *SDLCALL SDL_SubmitGpuAndAcquireFence(
- 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_WaitGpuForFences
- */
- extern SDL_DECLSPEC void SDLCALL SDL_WaitGpu(
- 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_SubmitGpuAndAcquireFence
- * \sa SDL_WaitGpu
- */
- extern SDL_DECLSPEC void SDLCALL SDL_WaitGpuForFences(
- 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_SubmitGpuAndAcquireFence
- */
- extern SDL_DECLSPEC SDL_bool SDLCALL SDL_QueryGpuFence(
- SDL_GpuDevice *device,
- SDL_GpuFence *fence);
- /**
- * Releases a fence obtained from SDL_SubmitGpuAndAcquireFence.
- *
- * \param device a GPU context.
- * \param fence a fence.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SubmitGpuAndAcquireFence
- */
- 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_SupportsGpuTextureFormat(
- 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_SupportsGpuSampleCount(
- 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 */
|