From 39d429e49705fe153a20dfb27421f1246237a683 Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 8 Mar 2022 15:10:48 +0100 Subject: Change some math macros to constexpr Changes `MAX`, `MIN`, `ABS`, `CLAMP` and `SIGN`. --- servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp | 4 ++-- servers/rendering/renderer_rd/renderer_scene_render_rd.cpp | 4 ++-- servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp | 12 ++++++------ servers/rendering/renderer_rd/renderer_storage_rd.cpp | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'servers') diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 38234cf0e7..e6fc50afbf 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -694,9 +694,9 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend _bind_canvas_texture(p_draw_list, RID(), current_filter, current_repeat, last_texture, push_constant, texpixel_size); - RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[MIN(3, primitive->point_count) - 1]); + RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[MIN(3u, primitive->point_count) - 1]); - for (uint32_t j = 0; j < MIN(3, primitive->point_count); j++) { + for (uint32_t j = 0; j < MIN(3u, primitive->point_count); j++) { push_constant.points[j * 2 + 0] = primitive->points[j].x; push_constant.points[j * 2 + 1] = primitive->points[j].y; push_constant.uvs[j * 2 + 0] = primitive->uvs[j].x; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 6296e10962..14207c6620 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1666,8 +1666,8 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { if (i == 1) { // next 2 are half size - tf.width = MAX(1, tf.width >> 1); - tf.height = MAX(1, tf.height >> 1); + tf.width = MAX(1u, tf.width >> 1); + tf.height = MAX(1u, tf.height >> 1); } } diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index d39fe306f4..51874df0f2 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -362,8 +362,8 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(RendererStorageR layer.views.write[j] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + i * 6, j, 1, RD::TEXTURE_SLICE_CUBEMAP); - mmw = MAX(1, mmw >> 1); - mmh = MAX(1, mmh >> 1); + mmw = MAX(1u, mmw >> 1); + mmh = MAX(1u, mmh >> 1); } layers.push_back(layer); @@ -390,8 +390,8 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(RendererStorageR layer.views.write[j] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer, j, 1, RD::TEXTURE_SLICE_CUBEMAP); - mmw = MAX(1, mmw >> 1); - mmh = MAX(1, mmh >> 1); + mmw = MAX(1u, mmw >> 1); + mmh = MAX(1u, mmh >> 1); } layers.push_back(layer); @@ -432,8 +432,8 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(RendererStorageR } } - mmw = MAX(1, mmw >> 1); - mmh = MAX(1, mmh >> 1); + mmw = MAX(1u, mmw >> 1); + mmh = MAX(1u, mmh >> 1); } } } diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index e4ddc1b41f..f00931cf47 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -9510,8 +9510,7 @@ RendererStorageRD::RendererStorageRD() { static_assert(sizeof(GlobalVariables::Value) == 16); - global_variables.buffer_size = GLOBAL_GET("rendering/limits/global_shader_variables/buffer_size"); - global_variables.buffer_size = MAX(4096, global_variables.buffer_size); + global_variables.buffer_size = MAX(4096, (int)GLOBAL_GET("rendering/limits/global_shader_variables/buffer_size")); global_variables.buffer_values = memnew_arr(GlobalVariables::Value, global_variables.buffer_size); memset(global_variables.buffer_values, 0, sizeof(GlobalVariables::Value) * global_variables.buffer_size); global_variables.buffer_usage = memnew_arr(GlobalVariables::ValueUsage, global_variables.buffer_size); -- cgit v1.2.3