Functions to bind GPURenderState storage textures, buffers and sampler bindings (#15150)

This commit is contained in:
Void Star Caster
2026-03-02 21:50:58 +01:00
committed by GitHub
parent e2a2e2c31e
commit 2e3300e872
5 changed files with 132 additions and 0 deletions

View File

@@ -6210,6 +6210,72 @@ SDL_GPURenderState *SDL_CreateGPURenderState(SDL_Renderer *renderer, const SDL_G
return state;
}
bool SDL_SetGPURenderStateSamplerBindings(SDL_GPURenderState *state, int num_sampler_bindings, const SDL_GPUTextureSamplerBinding *sampler_bindings)
{
if (!state) {
return SDL_InvalidParamError("state");
}
if (!FlushRenderCommandsIfGPURenderStateNeeded(state)) {
return false;
}
Sint32 length = sizeof(SDL_GPUTextureSamplerBinding) * num_sampler_bindings;
SDL_GPUTextureSamplerBinding *new_sampler_bindings = (SDL_GPUTextureSamplerBinding *)SDL_realloc(state->sampler_bindings, length);
if (!new_sampler_bindings) {
return false;
}
SDL_memcpy(new_sampler_bindings, sampler_bindings, length);
state->num_sampler_bindings = num_sampler_bindings;
state->sampler_bindings = new_sampler_bindings;
return true;
}
bool SDL_SetGPURenderStateStorageTextures(SDL_GPURenderState *state, int num_storage_textures, SDL_GPUTexture *const *storage_textures)
{
if (!state) {
return SDL_InvalidParamError("state");
}
if (!FlushRenderCommandsIfGPURenderStateNeeded(state)) {
return false;
}
Sint32 length = sizeof(SDL_GPUTexture *) * num_storage_textures;
SDL_GPUTexture **new_storage_textures = (SDL_GPUTexture **)SDL_realloc(state->storage_textures, length);
if (!new_storage_textures) {
return false;
}
SDL_memcpy(new_storage_textures, storage_textures, length);
state->num_storage_textures = num_storage_textures;
state->storage_textures = new_storage_textures;
return true;
}
bool SDL_SetGPURenderStateStorageBuffers(SDL_GPURenderState *state, int num_storage_buffers, SDL_GPUBuffer *const *storage_buffers)
{
if (!state) {
return SDL_InvalidParamError("state");
}
if (!FlushRenderCommandsIfGPURenderStateNeeded(state)) {
return false;
}
Sint32 length = sizeof(SDL_GPUBuffer *) * num_storage_buffers;
SDL_GPUBuffer **new_storage_buffers = (SDL_GPUBuffer **)SDL_realloc(state->storage_buffers, length);
if (!new_storage_buffers) {
return false;
}
SDL_memcpy(new_storage_buffers, storage_buffers, length);
state->num_storage_buffers = num_storage_buffers;
state->storage_buffers = new_storage_buffers;
return true;
}
bool SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length)
{
if (!state) {