SDL_UploadToGPUTexture(3)

๐Ÿ’– SDL_UploadToGPUTexture ๐Ÿ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today we're talking about SDL_UploadToGPUTexture โ€” she's the one who takes data from a transfer buffer and yeets it onto a texture. no cap. ๐ŸŽ€


โœจ NAME โœจ

SDL_UploadToGPUTexture โ€” uploads data from a transfer buffer to a texture. that's it, that's the whole job, and she does it flawlessly ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <SDL3/SDL_gpu.h>

void SDL_UploadToGPUTexture(
    SDL_GPUCopyPass *copy_pass,
    const SDL_GPUTextureTransferInfo *source,
    const SDL_GPUTextureRegion *destination,
    bool cycle);

like. look at that signature. four parameters. immaculate. โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so the tea โ˜•: the upload happens on the GPU timeline. which means โ€” and this is the iconic part โ€” you may assume that the upload has finished in subsequent commands. so don't be out here stressin' about sync, she already handled it. main character energy fr fr ๐Ÿ‘‘

and now for the part where you have to actually be careful: you must align the data in the transfer buffer to a multiple of the texel size</> of the texture format. like, texel size, multiple of it, non-negotiable. do the math, bestie ๐Ÿงฎ


๐ŸŽ€ FUNCTION PARAMETERS ๐ŸŽ€

  • copy_pass โ€” a copy pass handle. your ticket to the copy pass, basically ๐ŸŽŸ๏ธ
  • source โ€” the source transfer buffer, with image layout information attached. so she knows what she's working with ๐Ÿ’–
  • destination โ€” the destination texture region. where the data is going, obviously ๐ŸŒˆ
  • cycle โ€” if true, cycles the texture if the texture is bound; otherwise it overwrites the data. so like, pick your vibe: recycle or replace ๐Ÿฆ‹

โญ AVAILABILITY โญ

this function is available since SDL 3.2.0. so if you're on anything older, bestie... it's giving "not for you" ๐Ÿ˜ญ upgrade time.


lowkey reminder: don't forget that alignment rule. she will not forgive you. the texel size is the law ๐Ÿ”ฅ

and that's the whole page, periodt ๐Ÿ’… shoutout to Simple Directmedia Layer, version SDL 3.4.18, and the SDL_UploadToGPUTexture(3) page itself โ€” go off, queens ๐Ÿ‘‘โœจ ๐Ÿซถ

๐Ÿ“ฆ where this page comes from