SDL_CreateGPUTexture(3)
π SDL_CreateGPUTexture π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual β today's main character is SDL_CreateGPUTexture, and she is literally the girl who makes textures for your graphics and compute workflows. β¨
πΈ NAME πΈ
SDL_CreateGPUTexture β Creates a texture object to be used in graphics or compute workflows.
π SYNOPSIS π
#include <SDL3/SDL_gpu.h>
SDL_GPUTexture * SDL_CreateGPUTexture(
SDL_GPUDevice *device,
const SDL_GPUTextureCreateInfo *createinfo);
β¨ DESCRIPTION β¨
so, real talk: the contents of this texture are undefined until you actually write data to it. that's not me being dramatic, that's just the vibe. you write to it either by calling SDL_UploadToGPUTexture, or by running a render or compute pass with this texture as a target. no data written = mystery texture. π
alsooo, heads up: certain combos of usage flags are invalid, and the implementation will not be nice about it. for example, a texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags. like, pick a lane bestie. π
and if you ask for a sample count higher than the hardware actually supports? no crash, no drama β the implementation will automatically fall back to the highest available sample count. she's adaptable. π¦
there are also optional properties you can hand over through SDL_GPUTextureCreateInfo's props. these are the supported ones:
SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOATβ (Direct3D 12 only) if the texture usage isSDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture to a color with this red intensity. Defaults to zero.SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOATβ (Direct3D 12 only) if the texture usage isSDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture to a color with this green intensity. Defaults to zero.SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOATβ (Direct3D 12 only) if the texture usage isSDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture to a color with this blue intensity. Defaults to zero.SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOATβ (Direct3D 12 only) if the texture usage isSDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture to a color with this alpha intensity. Defaults to zero.SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOATβ (Direct3D 12 only) if the texture usage isSDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear the texture to a depth of this value. Defaults to zero.SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBERβ (Direct3D 12 only) if the texture usage isSDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear the texture to a stencil of thisUint8value. Defaults to zero.SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRINGβ a name that can be displayed in debugging tools.
not me listing every single one of those D3D12 clear props π they all default to zero, they're all Direct3D 12 only, and the color ones only kick in forSDL_GPU_TEXTUREUSAGE_COLOR_TARGETwhile the depth/stencil ones only kick in forSDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET. iykyk. π«Ά
π§ FUNCTION PARAMETERS π§
deviceβ a GPU Context. (yes queen, the whole context. π)createinfoβ a struct describing the state of the texture to create.
β RETURN VALUE β
Returns a texture object on success, or NULL on failure. if you get NULL, go call SDL_GetError() for more information β she will tell you what went wrong, fr fr. π
π AVAILABILITY π
This function is available since SDL 3.2.0.
π SEE ALSO π
SDL_UploadToGPUTexture(3)SDL_DownloadFromGPUTexture(3)SDL_BeginGPURenderPass(3)SDL_BeginGPUComputePass(3)SDL_BindGPUVertexSamplers(3)SDL_BindGPUVertexStorageTextures(3)SDL_BindGPUFragmentSamplers(3)SDL_BindGPUFragmentStorageTextures(3)SDL_BindGPUComputeStorageTextures(3)SDL_BlitGPUTexture(3)SDL_ReleaseGPUTexture(3)SDL_GPUTextureSupportsFormat(3)
and that's the whole page, bestie!! π go forth and create textures, you absolute icon. this lil writeup came to you straight from Simple Directmedia Layer, version SDL 3.4.18, and yeah the SDL_CreateGPUTexture(3) header was right there in the corner the whole time. slay, mwah πβ¨π₯
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms