Fixed warnings building with Visual Studio

This commit is contained in:
Sam Lantinga 2024-09-05 20:09:48 -07:00
parent 8edb901724
commit 379aea5c2d
8 changed files with 34 additions and 20 deletions

View File

@ -613,7 +613,7 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size)
data->vertices.buffer = SDL_CreateGPUBuffer(data->device, &bci);
if (!data->vertices.buffer) {
return -1;
return false;
}
SDL_GPUTransferBufferCreateInfo tbci;
@ -622,7 +622,12 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size)
tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
data->vertices.transfer_buf = SDL_CreateGPUTransferBuffer(data->device, &tbci);
return (bool)data->vertices.transfer_buf;
if (!data->vertices.transfer_buf) {
return false;
}
return true;
}
static bool UploadVertices(GPU_RenderData *data, void *vertices, size_t vertsize)
@ -852,8 +857,13 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
}
Uint32 bpp = SDL_BYTESPERPIXEL(pixfmt);
Uint32 row_size = rect->w * bpp;
Uint32 image_size = row_size * rect->h;
size_t row_size, image_size;
if (!SDL_size_mul_check_overflow(rect->w, bpp, &row_size) ||
!SDL_size_mul_check_overflow(rect->h, row_size, &image_size)) {
SDL_SetError("read size overflow");
return NULL;
}
SDL_Surface *surface = SDL_CreateSurface(rect->w, rect->h, pixfmt);
@ -863,7 +873,7 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
SDL_GPUTransferBufferCreateInfo tbci;
SDL_zero(tbci);
tbci.sizeInBytes = image_size;
tbci.sizeInBytes = (Uint32)image_size;
tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD;
SDL_GPUTransferBuffer *tbuf = SDL_CreateGPUTransferBuffer(data->device, &tbci);
@ -899,7 +909,7 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
void *mapped_tbuf = SDL_MapGPUTransferBuffer(data->device, tbuf, false);
if (surface->pitch == row_size) {
if ((size_t)surface->pitch == row_size) {
memcpy(surface->pixels, mapped_tbuf, image_size);
} else {
Uint8 *input = mapped_tbuf;
@ -935,7 +945,11 @@ static bool CreateBackbuffer(GPU_RenderData *data, Uint32 w, Uint32 h, SDL_GPUTe
data->backbuffer.height = h;
data->backbuffer.format = fmt;
return (bool)data->backbuffer.texture;
if (!data->backbuffer.texture) {
return false;
}
return true;
}
static bool GPU_RenderPresent(SDL_Renderer *renderer)

View File

@ -83,7 +83,7 @@ typedef struct GPU_ShaderSources
IF_VULKAN(.spirv = { code, sizeof(code), SDL_GPU_SHADERFORMAT_SPIRV }, )
#define SHADER_DXBC50(code) \
IF_D3D11(.dxbc50 = { code, sizeof(code), SDL_GPU_SHADERFORMAT_DXBC }, )
IF_D3D11(.dxbc50 = { (const unsigned char *)code, sizeof(code), SDL_GPU_SHADERFORMAT_DXBC }, )
#define SHADER_DXIL60(code) \
IF_D3D12(.dxil60 = { code, sizeof(code), SDL_GPU_SHADERFORMAT_DXIL }, )

View File

@ -1,4 +1,4 @@
const unsigned char color_frag_sm50_dxbc[] =
const signed char color_frag_sm50_dxbc[] =
{
68, 88, 66, 67, 114,-117,
-124, 82, -97, 76, -66, -74,
@ -82,4 +82,4 @@ const unsigned char color_frag_sm50_dxbc[] =
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
};
};

View File

@ -1,4 +1,4 @@
const unsigned char linepoint_vert_sm50_dxbc[] =
const signed char linepoint_vert_sm50_dxbc[] =
{
68, 88, 66, 67, 0, 119,
101, -18, 103, 113, 34, 52,
@ -169,4 +169,4 @@ const unsigned char linepoint_vert_sm50_dxbc[] =
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0
};
};

View File

@ -1,4 +1,4 @@
const unsigned char texture_rgb_frag_sm50_dxbc[] =
const signed char texture_rgb_frag_sm50_dxbc[] =
{
68, 88, 66, 67, -22, -54,
-48, 73, -47, -40, -92, -21,
@ -120,4 +120,4 @@ const unsigned char texture_rgb_frag_sm50_dxbc[] =
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
};
};

View File

@ -1,4 +1,4 @@
const unsigned char texture_rgba_frag_sm50_dxbc[] =
const signed char texture_rgba_frag_sm50_dxbc[] =
{
68, 88, 66, 67, -83, 124,
-3, -84,-102, 126, 29, -62,
@ -117,4 +117,4 @@ const unsigned char texture_rgba_frag_sm50_dxbc[] =
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
};

View File

@ -1,4 +1,4 @@
const unsigned char tri_color_vert_sm50_dxbc[] =
const signed char tri_color_vert_sm50_dxbc[] =
{
68, 88, 66, 67, -99, -1,
-83, -50, 75, -96, -1, 28,
@ -175,4 +175,4 @@ const unsigned char tri_color_vert_sm50_dxbc[] =
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
};

View File

@ -1,4 +1,4 @@
const unsigned char tri_texture_vert_sm50_dxbc[] =
const signed char tri_texture_vert_sm50_dxbc[] =
{
68, 88, 66, 67, 108, 113,
-108, 81, -2, 27, 41, 94,
@ -192,4 +192,4 @@ const unsigned char tri_texture_vert_sm50_dxbc[] =
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
};
};