SDL GPU Binding Use After Free

I noticed when using the SDL GPU API function:

SDL_BindGPUComputeStorageBuffers(SDL_GPUComputePass *compute_pass,
Uint32 first_slot,
SDL_GPUBuffer *const *storage_buffers,
Uint32 num_bindings);

SDL wasn’t copying the binding array I passed in (a bad assumption on my part). This left me with two questions:

  1. Should I expect this behaviour for all SDL GPU API calls that take in pointers to buffer/binding array
  2. When is it safe to free the structs pointed to by API function parameters (ex. SDL_GPUBuffer *const *storage_buffers is a pointer to a struct, that struct cannot be freed until SDL GPU API is done with it)?

Looking at the code, it seems like it’s iterating over all the storage buffers and creating a reference to the internal representation, so the actual array you pass is never referenced after the function call.

It sounds like you’re not seeing that in practice? Do you have a simple example you can share to demonstrate the issue?