Fixed build warnings

This commit is contained in:
Sam Lantinga
2024-09-02 16:53:30 -07:00
parent f11e7cd06f
commit 35dadda327
5 changed files with 28 additions and 21 deletions

View File

@@ -84,8 +84,10 @@ bool GPU_InitPipelineCache(GPU_PipelineCache *cache, SDL_GPUDevice *device)
{
// FIXME how many buckets do we need?
cache->table = SDL_CreateHashTable(device, 32, HashPassthrough, MatchPipelineCacheKey, NukePipelineCacheEntry, true);
return (bool)cache->table;
if (!cache->table) {
return false;
}
return true;
}
void GPU_DestroyPipelineCache(GPU_PipelineCache *cache)

View File

@@ -248,12 +248,16 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
GPU_TextureData *data = (GPU_TextureData *)texture->internal;
const Uint32 texturebpp = SDL_BYTESPERPIXEL(texture->format);
Uint32 row_size = texturebpp * rect->w;
Uint32 data_size = row_size * rect->h;
size_t row_size, data_size;
if (!SDL_size_mul_check_overflow(rect->w, texturebpp, &row_size) ||
!SDL_size_mul_check_overflow(rect->h, row_size, &data_size)) {
return SDL_SetError("update size overflow");
}
SDL_GPUTransferBufferCreateInfo tbci;
SDL_zero(tbci);
tbci.sizeInBytes = data_size;
tbci.sizeInBytes = (Uint32)data_size;
tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
SDL_GPUTransferBuffer *tbuf = SDL_CreateGPUTransferBuffer(renderdata->device, &tbci);
@@ -264,7 +268,7 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
Uint8 *output = SDL_MapGPUTransferBuffer(renderdata->device, tbuf, false);
if (pitch == row_size) {
if ((size_t)pitch == row_size) {
memcpy(output, pixels, data_size);
} else {
// FIXME is negative pitch supposed to work?