1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512 |
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
- */
- /**
- * \file SDL_gpu.h
- *
- * 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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- *
- * \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.x.x
- */
- 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.x.x
- */
- 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 */
|