SDL_GPUTextureUsageFlags(3type)

πŸ’– SDL_GPUTextureUsageFlags πŸ’–

okay bestie, welcome to the SDL_GPUTextureUsageFlags page β€” it's a datatype from the SDL3 manual (the 3type girlies know), and she's here to tell you exactly how a texture is intended to be used by the client. no cap. πŸŽ€


✨ NAME ✨

SDL_GPUTextureUsageFlags β€” specifies how a texture is intended to be used by the client. that's the whole vibe. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gpu.h>

typedef Uint32 SDL_GPUTextureUsageFlags;

#define SDL_GPU_TEXTUREUSAGE_SAMPLER                                 (1u << 0) /**< Texture supports sampling. */
#define SDL_GPU_TEXTUREUSAGE_COLOR_TARGET                            (1u << 1) /**< Texture is a color render target. */
#define SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET                    (1u << 2) /**< Texture is a depth stencil target. */
#define SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ                   (1u << 3) /**< Texture supports storage reads in graphics stages. */
#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ                    (1u << 4) /**< Texture supports storage reads in the compute stage. */
#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE                   (1u << 5) /**< Texture supports storage writes in the compute stage. */
#define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE (1u << 6) /**< Texture supports reads and writes in the same compute shader. This is NOT equivalent to READ | WRITE. */

so it's literally just a typedef Uint32 and then a lil family of #defines. bit flags. iconic behavior honestly. πŸ’…

  • SDL_GPU_TEXTUREUSAGE_SAMPLER β€” (1u << 0) β€” texture supports sampling. πŸ¦‹
  • SDL_GPU_TEXTUREUSAGE_COLOR_TARGET β€” (1u << 1) β€” texture is a color render target. 🎨
  • SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET β€” (1u << 2) β€” texture is a depth stencil target. 🌈
  • SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ β€” (1u << 3) β€” texture supports storage reads in graphics stages. πŸ‘€
  • SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ β€” (1u << 4) β€” texture supports storage reads in the compute stage. πŸ“–
  • SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE β€” (1u << 5) β€” texture supports storage writes in the compute stage. ✍️
  • SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE β€” (1u << 6) β€” texture supports reads and writes in the same compute shader. and listen β€” this is NOT equivalent to READ | WRITE. do not come for me about it, they are different, periodt. πŸ’€

🧚 DESCRIPTION 🧚

first thing's first: a texture must have at least one usage flag. zero flags is not a lewk, it's not allowed, she needs at least one. 🫢

also β€” combining SAMPLER with the STORAGE_READ flags is invalid. like, don't. it's giving error. 🚫

now the compute storage tea, because this is the part everyone gets confused about, and honestly valid:

  • READ | WRITE means you can have shader A that only writes into the texture and shader B that only reads from the texture, and you bind the same texture to either shader respectively. two different shaders, two different jobs, same texture, no overlap. 🀝
  • SIMULTANEOUS means you can do reads and writes within the same shader or compute pass. it also implies that atomic ops can be used, since those are read-modify-write operations. 🧠✨
⚠️ if you use SIMULTANEOUS, you are responsible for avoiding data races, because there is no data synchronization within a compute pass. that's on you, bestie. no one's coming to save you. 😭

and one more lil caveat β€” SIMULTANEOUS usage is only supported by a limited number of texture formats. so vibe check your format first. 🌸


πŸ’œ AVAILABILITY πŸ’œ

this datatype has been available since SDL 3.2.0. she's a newer girl but she's thriving. ⭐


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! πŸŽ€ go forth and flag your textures responsibly. mwah. πŸ’–

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_GPUTextureUsageFlags(3type) β€” sending u all my love, xoxo, see u in the next manpage πŸ«ΆπŸ’…βœ¨

πŸ“¦ where this page comes from