Use new parameter validation macro

This commit is contained in:
Sam Lantinga
2025-09-16 21:51:03 -07:00
parent ee1c90a358
commit 25b2d2c821
60 changed files with 1113 additions and 1133 deletions

View File

@@ -23,7 +23,7 @@
// FIXME: This could probably use SDL_ObjectValid
#define CHECK_DEVICE_MAGIC(device, retval) \
if (device == NULL) { \
CHECK_PARAM(device == NULL) { \
SDL_SetError("Invalid GPU device"); \
return retval; \
}
@@ -731,7 +731,6 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
void SDL_DestroyGPUDevice(SDL_GPUDevice *device)
{
CHECK_DEVICE_MAGIC(device, );
device->DestroyDevice(device);
}
@@ -746,7 +745,7 @@ int SDL_GetNumGPUDrivers(void)
const char * SDL_GetGPUDriver(int index)
{
if (index < 0 || index >= SDL_GetNumGPUDrivers()) {
CHECK_PARAM(index < 0 || index >= SDL_GetNumGPUDrivers()) {
SDL_InvalidParamError("index");
return NULL;
}
@@ -760,21 +759,18 @@ const char * SDL_GetGPUDriver(int index)
const char * SDL_GetGPUDeviceDriver(SDL_GPUDevice *device)
{
CHECK_DEVICE_MAGIC(device, NULL);
return device->backend;
}
SDL_GPUShaderFormat SDL_GetGPUShaderFormats(SDL_GPUDevice *device)
{
CHECK_DEVICE_MAGIC(device, SDL_GPU_SHADERFORMAT_INVALID);
return device->shader_formats;
}
SDL_PropertiesID SDL_GetGPUDeviceProperties(SDL_GPUDevice *device)
{
CHECK_DEVICE_MAGIC(device, 0);
return device->GetDeviceProperties(device);
}
@@ -951,6 +947,7 @@ SDL_GPUComputePipeline *SDL_CreateGPUComputePipeline(
const SDL_GPUComputePipelineCreateInfo *createinfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (createinfo == NULL) {
SDL_InvalidParamError("createinfo");
return NULL;
@@ -991,7 +988,8 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline(
const SDL_GPUGraphicsPipelineCreateInfo *graphicsPipelineCreateInfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (graphicsPipelineCreateInfo == NULL) {
CHECK_PARAM(graphicsPipelineCreateInfo == NULL) {
SDL_InvalidParamError("graphicsPipelineCreateInfo");
return NULL;
}
@@ -1118,7 +1116,8 @@ SDL_GPUSampler *SDL_CreateGPUSampler(
const SDL_GPUSamplerCreateInfo *createinfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (createinfo == NULL) {
CHECK_PARAM(createinfo == NULL) {
SDL_InvalidParamError("createinfo");
return NULL;
}
@@ -1133,7 +1132,8 @@ SDL_GPUShader *SDL_CreateGPUShader(
const SDL_GPUShaderCreateInfo *createinfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (createinfo == NULL) {
CHECK_PARAM(createinfo == NULL) {
SDL_InvalidParamError("createinfo");
return NULL;
}
@@ -1159,7 +1159,8 @@ SDL_GPUTexture *SDL_CreateGPUTexture(
const SDL_GPUTextureCreateInfo *createinfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (createinfo == NULL) {
CHECK_PARAM(createinfo == NULL) {
SDL_InvalidParamError("createinfo");
return NULL;
}
@@ -1301,7 +1302,8 @@ SDL_GPUBuffer *SDL_CreateGPUBuffer(
const SDL_GPUBufferCreateInfo *createinfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (createinfo == NULL) {
CHECK_PARAM(createinfo == NULL) {
SDL_InvalidParamError("createinfo");
return NULL;
}
@@ -1320,7 +1322,8 @@ SDL_GPUTransferBuffer *SDL_CreateGPUTransferBuffer(
const SDL_GPUTransferBufferCreateInfo *createinfo)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (createinfo == NULL) {
CHECK_PARAM(createinfo == NULL) {
SDL_InvalidParamError("createinfo");
return NULL;
}
@@ -1342,11 +1345,12 @@ void SDL_SetGPUBufferName(
const char *text)
{
CHECK_DEVICE_MAGIC(device, );
if (buffer == NULL) {
CHECK_PARAM(buffer == NULL) {
SDL_InvalidParamError("buffer");
return;
}
if (text == NULL) {
CHECK_PARAM(text == NULL) {
SDL_InvalidParamError("text");
}
@@ -1362,11 +1366,12 @@ void SDL_SetGPUTextureName(
const char *text)
{
CHECK_DEVICE_MAGIC(device, );
if (texture == NULL) {
CHECK_PARAM(texture == NULL) {
SDL_InvalidParamError("texture");
return;
}
if (text == NULL) {
CHECK_PARAM(text == NULL) {
SDL_InvalidParamError("text");
}
@@ -1380,11 +1385,11 @@ void SDL_InsertGPUDebugLabel(
SDL_GPUCommandBuffer *command_buffer,
const char *text)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (text == NULL) {
CHECK_PARAM(text == NULL) {
SDL_InvalidParamError("text");
return;
}
@@ -1402,11 +1407,11 @@ void SDL_PushGPUDebugGroup(
SDL_GPUCommandBuffer *command_buffer,
const char *name)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (name == NULL) {
CHECK_PARAM(name == NULL) {
SDL_InvalidParamError("name");
return;
}
@@ -1423,7 +1428,7 @@ void SDL_PushGPUDebugGroup(
void SDL_PopGPUDebugGroup(
SDL_GPUCommandBuffer *command_buffer)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
@@ -1443,7 +1448,8 @@ void SDL_ReleaseGPUTexture(
SDL_GPUTexture *texture)
{
CHECK_DEVICE_MAGIC(device, );
if (texture == NULL) {
CHECK_PARAM(texture == NULL) {
return;
}
@@ -1457,7 +1463,8 @@ void SDL_ReleaseGPUSampler(
SDL_GPUSampler *sampler)
{
CHECK_DEVICE_MAGIC(device, );
if (sampler == NULL) {
CHECK_PARAM(sampler == NULL) {
return;
}
@@ -1471,7 +1478,8 @@ void SDL_ReleaseGPUBuffer(
SDL_GPUBuffer *buffer)
{
CHECK_DEVICE_MAGIC(device, );
if (buffer == NULL) {
CHECK_PARAM(buffer == NULL) {
return;
}
@@ -1485,7 +1493,8 @@ void SDL_ReleaseGPUTransferBuffer(
SDL_GPUTransferBuffer *transfer_buffer)
{
CHECK_DEVICE_MAGIC(device, );
if (transfer_buffer == NULL) {
CHECK_PARAM(transfer_buffer == NULL) {
return;
}
@@ -1499,7 +1508,8 @@ void SDL_ReleaseGPUShader(
SDL_GPUShader *shader)
{
CHECK_DEVICE_MAGIC(device, );
if (shader == NULL) {
CHECK_PARAM(shader == NULL) {
return;
}
@@ -1513,7 +1523,8 @@ void SDL_ReleaseGPUComputePipeline(
SDL_GPUComputePipeline *compute_pipeline)
{
CHECK_DEVICE_MAGIC(device, );
if (compute_pipeline == NULL) {
CHECK_PARAM(compute_pipeline == NULL) {
return;
}
@@ -1527,7 +1538,8 @@ void SDL_ReleaseGPUGraphicsPipeline(
SDL_GPUGraphicsPipeline *graphics_pipeline)
{
CHECK_DEVICE_MAGIC(device, );
if (graphics_pipeline == NULL) {
CHECK_PARAM(graphics_pipeline == NULL) {
return;
}
@@ -1592,11 +1604,11 @@ void SDL_PushGPUVertexUniformData(
const void *data,
Uint32 length)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (data == NULL) {
CHECK_PARAM(data == NULL) {
SDL_InvalidParamError("data");
return;
}
@@ -1618,11 +1630,11 @@ void SDL_PushGPUFragmentUniformData(
const void *data,
Uint32 length)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (data == NULL) {
CHECK_PARAM(data == NULL) {
SDL_InvalidParamError("data");
return;
}
@@ -1644,11 +1656,11 @@ void SDL_PushGPUComputeUniformData(
const void *data,
Uint32 length)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (data == NULL) {
CHECK_PARAM(data == NULL) {
SDL_InvalidParamError("data");
return;
}
@@ -1674,28 +1686,20 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
{
CommandBufferCommonHeader *commandBufferHeader;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return NULL;
}
if (color_target_infos == NULL && num_color_targets > 0) {
CHECK_PARAM(color_target_infos == NULL && num_color_targets > 0) {
SDL_InvalidParamError("color_target_infos");
return NULL;
}
if (num_color_targets > MAX_COLOR_TARGET_BINDINGS) {
CHECK_PARAM(num_color_targets > MAX_COLOR_TARGET_BINDINGS) {
SDL_SetError("num_color_targets exceeds MAX_COLOR_TARGET_BINDINGS");
return NULL;
}
if (depth_stencil_target_info != NULL) {
TextureCommonHeader *depthTextureCommonHeader = (TextureCommonHeader *) depth_stencil_target_info->texture;
if (depthTextureCommonHeader->info.layer_count_or_depth > 255) {
SDL_SetError("Cannot bind a depth texture with more than 255 layers!");
return NULL;
}
}
if (COMMAND_BUFFER_DEVICE->debug_mode) {
CHECK_COMMAND_BUFFER_RETURN_NULL
CHECK_ANY_PASS_IN_PROGRESS("Cannot begin render pass during another pass!", NULL)
@@ -1749,13 +1753,17 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
}
if (depth_stencil_target_info != NULL) {
TextureCommonHeader *textureHeader = (TextureCommonHeader *)depth_stencil_target_info->texture;
if (!(textureHeader->info.usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) {
SDL_assert_release(!"Depth target must have been created with the DEPTH_STENCIL_TARGET usage flag!");
return NULL;
}
if (textureHeader->info.layer_count_or_depth > 255) {
SDL_assert_release("Cannot bind a depth texture with more than 255 layers!");
return NULL;
}
if (depth_stencil_target_info->cycle && (depth_stencil_target_info->load_op == SDL_GPU_LOADOP_LOAD || depth_stencil_target_info->stencil_load_op == SDL_GPU_LOADOP_LOAD)) {
SDL_assert_release(!"Cannot cycle depth target when load op or stencil load op is LOAD!");
return NULL;
@@ -1799,11 +1807,11 @@ void SDL_BindGPUGraphicsPipeline(
SDL_GPURenderPass *render_pass,
SDL_GPUGraphicsPipeline *graphics_pipeline)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (graphics_pipeline == NULL) {
CHECK_PARAM(graphics_pipeline == NULL) {
SDL_InvalidParamError("graphics_pipeline");
return;
}
@@ -1822,11 +1830,11 @@ void SDL_SetGPUViewport(
SDL_GPURenderPass *render_pass,
const SDL_GPUViewport *viewport)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (viewport == NULL) {
CHECK_PARAM(viewport == NULL) {
SDL_InvalidParamError("viewport");
return;
}
@@ -1844,11 +1852,11 @@ void SDL_SetGPUScissor(
SDL_GPURenderPass *render_pass,
const SDL_Rect *scissor)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (scissor == NULL) {
CHECK_PARAM(scissor == NULL) {
SDL_InvalidParamError("scissor");
return;
}
@@ -1866,7 +1874,7 @@ void SDL_SetGPUBlendConstants(
SDL_GPURenderPass *render_pass,
SDL_FColor blend_constants)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -1884,7 +1892,7 @@ void SDL_SetGPUStencilReference(
SDL_GPURenderPass *render_pass,
Uint8 reference)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -1904,7 +1912,7 @@ void SDL_BindGPUVertexBuffers(
const SDL_GPUBufferBinding *bindings,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -1929,7 +1937,7 @@ void SDL_BindGPUIndexBuffer(
const SDL_GPUBufferBinding *binding,
SDL_GPUIndexElementSize index_element_size)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -1954,11 +1962,11 @@ void SDL_BindGPUVertexSamplers(
const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (texture_sampler_bindings == NULL && num_bindings > 0) {
CHECK_PARAM(texture_sampler_bindings == NULL && num_bindings > 0) {
SDL_InvalidParamError("texture_sampler_bindings");
return;
}
@@ -1989,11 +1997,11 @@ void SDL_BindGPUVertexStorageTextures(
SDL_GPUTexture *const *storage_textures,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (storage_textures == NULL && num_bindings > 0) {
CHECK_PARAM(storage_textures == NULL && num_bindings > 0) {
SDL_InvalidParamError("storage_textures");
return;
}
@@ -2020,11 +2028,11 @@ void SDL_BindGPUVertexStorageBuffers(
SDL_GPUBuffer *const *storage_buffers,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (storage_buffers == NULL && num_bindings > 0) {
CHECK_PARAM(storage_buffers == NULL && num_bindings > 0) {
SDL_InvalidParamError("storage_buffers");
return;
}
@@ -2050,11 +2058,11 @@ void SDL_BindGPUFragmentSamplers(
const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (texture_sampler_bindings == NULL && num_bindings > 0) {
CHECK_PARAM(texture_sampler_bindings == NULL && num_bindings > 0) {
SDL_InvalidParamError("texture_sampler_bindings");
return;
}
@@ -2084,11 +2092,11 @@ void SDL_BindGPUFragmentStorageTextures(
SDL_GPUTexture *const *storage_textures,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (storage_textures == NULL && num_bindings > 0) {
CHECK_PARAM(storage_textures == NULL && num_bindings > 0) {
SDL_InvalidParamError("storage_textures");
return;
}
@@ -2115,11 +2123,11 @@ void SDL_BindGPUFragmentStorageBuffers(
SDL_GPUBuffer *const *storage_buffers,
Uint32 num_bindings)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (storage_buffers == NULL && num_bindings > 0) {
CHECK_PARAM(storage_buffers == NULL && num_bindings > 0) {
SDL_InvalidParamError("storage_buffers");
return;
}
@@ -2147,7 +2155,7 @@ void SDL_DrawGPUIndexedPrimitives(
Sint32 vertex_offset,
Uint32 first_instance)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -2174,7 +2182,7 @@ void SDL_DrawGPUPrimitives(
Uint32 first_vertex,
Uint32 first_instance)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -2199,11 +2207,11 @@ void SDL_DrawGPUPrimitivesIndirect(
Uint32 offset,
Uint32 draw_count)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (buffer == NULL) {
CHECK_PARAM(buffer == NULL) {
SDL_InvalidParamError("buffer");
return;
}
@@ -2227,11 +2235,11 @@ void SDL_DrawGPUIndexedPrimitivesIndirect(
Uint32 offset,
Uint32 draw_count)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
if (buffer == NULL) {
CHECK_PARAM(buffer == NULL) {
SDL_InvalidParamError("buffer");
return;
}
@@ -2252,7 +2260,7 @@ void SDL_DrawGPUIndexedPrimitivesIndirect(
void SDL_EndGPURenderPass(
SDL_GPURenderPass *render_pass)
{
if (render_pass == NULL) {
CHECK_PARAM(render_pass == NULL) {
SDL_InvalidParamError("render_pass");
return;
}
@@ -2296,26 +2304,27 @@ SDL_GPUComputePass *SDL_BeginGPUComputePass(
{
CommandBufferCommonHeader *commandBufferHeader;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return NULL;
}
if (storage_texture_bindings == NULL && num_storage_texture_bindings > 0) {
CHECK_PARAM(storage_texture_bindings == NULL && num_storage_texture_bindings > 0) {
SDL_InvalidParamError("storage_texture_bindings");
return NULL;
}
if (storage_buffer_bindings == NULL && num_storage_buffer_bindings > 0) {
CHECK_PARAM(storage_buffer_bindings == NULL && num_storage_buffer_bindings > 0) {
SDL_InvalidParamError("storage_buffer_bindings");
return NULL;
}
if (num_storage_texture_bindings > MAX_COMPUTE_WRITE_TEXTURES) {
CHECK_PARAM(num_storage_texture_bindings > MAX_COMPUTE_WRITE_TEXTURES) {
SDL_InvalidParamError("num_storage_texture_bindings");
return NULL;
}
if (num_storage_buffer_bindings > MAX_COMPUTE_WRITE_BUFFERS) {
CHECK_PARAM(num_storage_buffer_bindings > MAX_COMPUTE_WRITE_BUFFERS) {
SDL_InvalidParamError("num_storage_buffer_bindings");
return NULL;
}
if (COMMAND_BUFFER_DEVICE->debug_mode) {
CHECK_COMMAND_BUFFER_RETURN_NULL
CHECK_ANY_PASS_IN_PROGRESS("Cannot begin compute pass during another pass!", NULL)
@@ -2369,11 +2378,11 @@ void SDL_BindGPUComputePipeline(
SDL_GPUComputePass *compute_pass,
SDL_GPUComputePipeline *compute_pipeline)
{
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
if (compute_pipeline == NULL) {
CHECK_PARAM(compute_pipeline == NULL) {
SDL_InvalidParamError("compute_pipeline");
return;
}
@@ -2398,11 +2407,11 @@ void SDL_BindGPUComputeSamplers(
const SDL_GPUTextureSamplerBinding *texture_sampler_bindings,
Uint32 num_bindings)
{
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
if (texture_sampler_bindings == NULL && num_bindings > 0) {
CHECK_PARAM(texture_sampler_bindings == NULL && num_bindings > 0) {
SDL_InvalidParamError("texture_sampler_bindings");
return;
}
@@ -2428,11 +2437,11 @@ void SDL_BindGPUComputeStorageTextures(
SDL_GPUTexture *const *storage_textures,
Uint32 num_bindings)
{
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
if (storage_textures == NULL && num_bindings > 0) {
CHECK_PARAM(storage_textures == NULL && num_bindings > 0) {
SDL_InvalidParamError("storage_textures");
return;
}
@@ -2458,11 +2467,11 @@ void SDL_BindGPUComputeStorageBuffers(
SDL_GPUBuffer *const *storage_buffers,
Uint32 num_bindings)
{
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
if (storage_buffers == NULL && num_bindings > 0) {
CHECK_PARAM(storage_buffers == NULL && num_bindings > 0) {
SDL_InvalidParamError("storage_buffers");
return;
}
@@ -2488,7 +2497,7 @@ void SDL_DispatchGPUCompute(
Uint32 groupcount_y,
Uint32 groupcount_z)
{
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
@@ -2511,7 +2520,7 @@ void SDL_DispatchGPUComputeIndirect(
SDL_GPUBuffer *buffer,
Uint32 offset)
{
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
@@ -2533,7 +2542,7 @@ void SDL_EndGPUComputePass(
{
CommandBufferCommonHeader *commandBufferCommonHeader;
if (compute_pass == NULL) {
CHECK_PARAM(compute_pass == NULL) {
SDL_InvalidParamError("compute_pass");
return;
}
@@ -2565,7 +2574,8 @@ void *SDL_MapGPUTransferBuffer(
bool cycle)
{
CHECK_DEVICE_MAGIC(device, NULL);
if (transfer_buffer == NULL) {
CHECK_PARAM(transfer_buffer == NULL) {
SDL_InvalidParamError("transfer_buffer");
return NULL;
}
@@ -2581,7 +2591,8 @@ void SDL_UnmapGPUTransferBuffer(
SDL_GPUTransferBuffer *transfer_buffer)
{
CHECK_DEVICE_MAGIC(device, );
if (transfer_buffer == NULL) {
CHECK_PARAM(transfer_buffer == NULL) {
SDL_InvalidParamError("transfer_buffer");
return;
}
@@ -2598,7 +2609,7 @@ SDL_GPUCopyPass *SDL_BeginGPUCopyPass(
{
CommandBufferCommonHeader *commandBufferHeader;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return NULL;
}
@@ -2626,11 +2637,11 @@ void SDL_UploadToGPUTexture(
const SDL_GPUTextureRegion *destination,
bool cycle)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
if (source == NULL) {
CHECK_PARAM(source == NULL) {
SDL_InvalidParamError("source");
return;
}
@@ -2664,15 +2675,15 @@ void SDL_UploadToGPUBuffer(
const SDL_GPUBufferRegion *destination,
bool cycle)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
if (source == NULL) {
CHECK_PARAM(source == NULL) {
SDL_InvalidParamError("source");
return;
}
if (destination == NULL) {
CHECK_PARAM(destination == NULL) {
SDL_InvalidParamError("destination");
return;
}
@@ -2705,15 +2716,15 @@ void SDL_CopyGPUTextureToTexture(
Uint32 d,
bool cycle)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
if (source == NULL) {
CHECK_PARAM(source == NULL) {
SDL_InvalidParamError("source");
return;
}
if (destination == NULL) {
CHECK_PARAM(destination == NULL) {
SDL_InvalidParamError("destination");
return;
}
@@ -2754,15 +2765,15 @@ void SDL_CopyGPUBufferToBuffer(
Uint32 size,
bool cycle)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
if (source == NULL) {
CHECK_PARAM(source == NULL) {
SDL_InvalidParamError("source");
return;
}
if (destination == NULL) {
CHECK_PARAM(destination == NULL) {
SDL_InvalidParamError("destination");
return;
}
@@ -2792,15 +2803,15 @@ void SDL_DownloadFromGPUTexture(
const SDL_GPUTextureRegion *source,
const SDL_GPUTextureTransferInfo *destination)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
if (source == NULL) {
CHECK_PARAM(source == NULL) {
SDL_InvalidParamError("source");
return;
}
if (destination == NULL) {
CHECK_PARAM(destination == NULL) {
SDL_InvalidParamError("destination");
return;
}
@@ -2828,15 +2839,15 @@ void SDL_DownloadFromGPUBuffer(
const SDL_GPUBufferRegion *source,
const SDL_GPUTransferBufferLocation *destination)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
if (source == NULL) {
CHECK_PARAM(source == NULL) {
SDL_InvalidParamError("source");
return;
}
if (destination == NULL) {
CHECK_PARAM(destination == NULL) {
SDL_InvalidParamError("destination");
return;
}
@@ -2862,7 +2873,7 @@ void SDL_DownloadFromGPUBuffer(
void SDL_EndGPUCopyPass(
SDL_GPUCopyPass *copy_pass)
{
if (copy_pass == NULL) {
CHECK_PARAM(copy_pass == NULL) {
SDL_InvalidParamError("copy_pass");
return;
}
@@ -2883,11 +2894,11 @@ void SDL_GenerateMipmapsForGPUTexture(
SDL_GPUCommandBuffer *command_buffer,
SDL_GPUTexture *texture)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (texture == NULL) {
CHECK_PARAM(texture == NULL) {
SDL_InvalidParamError("texture");
return;
}
@@ -2925,11 +2936,11 @@ void SDL_BlitGPUTexture(
SDL_GPUCommandBuffer *command_buffer,
const SDL_GPUBlitInfo *info)
{
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return;
}
if (info == NULL) {
CHECK_PARAM(info == NULL) {
SDL_InvalidParamError("info");
return;
}
@@ -2990,7 +3001,8 @@ bool SDL_WindowSupportsGPUSwapchainComposition(
SDL_GPUSwapchainComposition swapchain_composition)
{
CHECK_DEVICE_MAGIC(device, false);
if (window == NULL) {
CHECK_PARAM(window == NULL) {
SDL_InvalidParamError("window");
return false;
}
@@ -3011,7 +3023,8 @@ bool SDL_WindowSupportsGPUPresentMode(
SDL_GPUPresentMode present_mode)
{
CHECK_DEVICE_MAGIC(device, false);
if (window == NULL) {
CHECK_PARAM(window == NULL) {
SDL_InvalidParamError("window");
return false;
}
@@ -3031,7 +3044,8 @@ bool SDL_ClaimWindowForGPUDevice(
SDL_Window *window)
{
CHECK_DEVICE_MAGIC(device, false);
if (window == NULL) {
CHECK_PARAM(window == NULL) {
return SDL_InvalidParamError("window");
}
@@ -3049,7 +3063,8 @@ void SDL_ReleaseWindowFromGPUDevice(
SDL_Window *window)
{
CHECK_DEVICE_MAGIC(device, );
if (window == NULL) {
CHECK_PARAM(window == NULL) {
SDL_InvalidParamError("window");
return;
}
@@ -3066,7 +3081,8 @@ bool SDL_SetGPUSwapchainParameters(
SDL_GPUPresentMode present_mode)
{
CHECK_DEVICE_MAGIC(device, false);
if (window == NULL) {
CHECK_PARAM(window == NULL) {
SDL_InvalidParamError("window");
return false;
}
@@ -3107,7 +3123,8 @@ SDL_GPUTextureFormat SDL_GetGPUSwapchainTextureFormat(
SDL_Window *window)
{
CHECK_DEVICE_MAGIC(device, SDL_GPU_TEXTUREFORMAT_INVALID);
if (window == NULL) {
CHECK_PARAM(window == NULL) {
SDL_InvalidParamError("window");
return SDL_GPU_TEXTUREFORMAT_INVALID;
}
@@ -3126,13 +3143,13 @@ bool SDL_AcquireGPUSwapchainTexture(
{
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
return SDL_InvalidParamError("command_buffer");
}
if (window == NULL) {
CHECK_PARAM(window == NULL) {
return SDL_InvalidParamError("window");
}
if (swapchain_texture == NULL) {
CHECK_PARAM(swapchain_texture == NULL) {
return SDL_InvalidParamError("swapchain_texture");
}
@@ -3161,7 +3178,7 @@ bool SDL_WaitForGPUSwapchain(
{
CHECK_DEVICE_MAGIC(device, false);
if (window == NULL) {
CHECK_PARAM(window == NULL) {
return SDL_InvalidParamError("window");
}
@@ -3179,13 +3196,13 @@ bool SDL_WaitAndAcquireGPUSwapchainTexture(
{
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
return SDL_InvalidParamError("command_buffer");
}
if (window == NULL) {
CHECK_PARAM(window == NULL) {
return SDL_InvalidParamError("window");
}
if (swapchain_texture == NULL) {
CHECK_PARAM(swapchain_texture == NULL) {
return SDL_InvalidParamError("swapchain_texture");
}
@@ -3213,7 +3230,7 @@ bool SDL_SubmitGPUCommandBuffer(
{
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return false;
}
@@ -3240,7 +3257,7 @@ SDL_GPUFence *SDL_SubmitGPUCommandBufferAndAcquireFence(
{
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return NULL;
}
@@ -3267,7 +3284,7 @@ bool SDL_CancelGPUCommandBuffer(
{
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;
if (command_buffer == NULL) {
CHECK_PARAM(command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return false;
}
@@ -3299,7 +3316,8 @@ bool SDL_WaitForGPUFences(
Uint32 num_fences)
{
CHECK_DEVICE_MAGIC(device, false);
if (fences == NULL && num_fences > 0) {
CHECK_PARAM(fences == NULL && num_fences > 0) {
SDL_InvalidParamError("fences");
return false;
}
@@ -3316,7 +3334,8 @@ bool SDL_QueryGPUFence(
SDL_GPUFence *fence)
{
CHECK_DEVICE_MAGIC(device, false);
if (fence == NULL) {
CHECK_PARAM(fence == NULL) {
SDL_InvalidParamError("fence");
return false;
}
@@ -3331,7 +3350,8 @@ void SDL_ReleaseGPUFence(
SDL_GPUFence *fence)
{
CHECK_DEVICE_MAGIC(device, );
if (fence == NULL) {
CHECK_PARAM(fence == NULL) {
return;
}