Merge pull request #107452 from Ivorforce/bit-math-header
Move binary math functions to `Math` namespace in `math_funcs_binary.h`
This commit is contained in:
commit
fa56f71ddd
50 changed files with 330 additions and 286 deletions
|
|
@ -226,7 +226,7 @@ void LightmapperRD::_sort_triangle_clusters(uint32_t p_cluster_size, uint32_t p_
|
|||
break;
|
||||
}
|
||||
|
||||
uint32_t left_cluster_count = next_power_of_2(p_count / 2);
|
||||
uint32_t left_cluster_count = Math::next_power_of_2(p_count / 2);
|
||||
left_cluster_count = MAX(left_cluster_count, p_cluster_size);
|
||||
left_cluster_count = MIN(left_cluster_count, p_count);
|
||||
_sort_triangle_clusters(p_cluster_size, p_cluster_index, p_index_start, left_cluster_count, p_triangle_sort, p_cluster_aabb);
|
||||
|
|
@ -257,8 +257,8 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
|
|||
atlas_size = atlas_size.max(s + Size2i(2, 2).maxi(p_denoiser_range) * p_supersampling_factor);
|
||||
}
|
||||
|
||||
int max = nearest_power_of_2_templated(atlas_size.width);
|
||||
max = MAX(max, nearest_power_of_2_templated(atlas_size.height));
|
||||
int max = Math::nearest_power_of_2_templated(atlas_size.width);
|
||||
max = MAX(max, Math::nearest_power_of_2_templated(atlas_size.height));
|
||||
|
||||
if (max > p_max_texture_size) {
|
||||
return BAKE_ERROR_TEXTURE_EXCEEDS_MAX_SIZE;
|
||||
|
|
@ -1016,7 +1016,7 @@ LightmapperRD::BakeError LightmapperRD::_denoise(RenderingDevice *p_rd, Ref<RDSh
|
|||
// We denoise in fixed size regions and synchronize execution to avoid GPU timeouts.
|
||||
// We use a region with 1/4 the amount of pixels if we're denoising SH lightmaps, as
|
||||
// all four of them are denoised in the shader in one dispatch.
|
||||
const int user_region_size = nearest_power_of_2_templated(int(GLOBAL_GET("rendering/lightmapping/bake_performance/region_size")));
|
||||
const int user_region_size = Math::nearest_power_of_2_templated(int(GLOBAL_GET("rendering/lightmapping/bake_performance/region_size")));
|
||||
const int max_region_size = p_bake_sh ? user_region_size / 2 : user_region_size;
|
||||
int x_regions = Math::division_round_up(p_atlas_size.width, max_region_size);
|
||||
int y_regions = Math::division_round_up(p_atlas_size.height, max_region_size);
|
||||
|
|
@ -1683,7 +1683,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
|
|||
}
|
||||
}
|
||||
|
||||
const int max_region_size = nearest_power_of_2_templated(int(GLOBAL_GET("rendering/lightmapping/bake_performance/region_size")));
|
||||
const int max_region_size = Math::nearest_power_of_2_templated(int(GLOBAL_GET("rendering/lightmapping/bake_performance/region_size")));
|
||||
const int x_regions = Math::division_round_up(atlas_size.width, max_region_size);
|
||||
const int y_regions = Math::division_round_up(atlas_size.height, max_region_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -870,17 +870,17 @@ _FORCE_INLINE_ TextServerAdvanced::FontTexturePosition TextServerAdvanced::find_
|
|||
// Could not find texture to fit, create one.
|
||||
int texsize = MAX(p_data->size.x * 0.125, 256);
|
||||
|
||||
texsize = next_power_of_2((uint32_t)texsize);
|
||||
texsize = Math::next_power_of_2((uint32_t)texsize);
|
||||
if (p_msdf) {
|
||||
texsize = MIN(texsize, 2048);
|
||||
} else {
|
||||
texsize = MIN(texsize, 1024);
|
||||
}
|
||||
if (mw > texsize) { // Special case, adapt to it?
|
||||
texsize = next_power_of_2((uint32_t)mw);
|
||||
texsize = Math::next_power_of_2((uint32_t)mw);
|
||||
}
|
||||
if (mh > texsize) { // Special case, adapt to it?
|
||||
texsize = next_power_of_2((uint32_t)mh);
|
||||
texsize = Math::next_power_of_2((uint32_t)mh);
|
||||
}
|
||||
|
||||
ShelfPackTexture tex = ShelfPackTexture(texsize, texsize);
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ _FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_
|
|||
// Could not find texture to fit, create one.
|
||||
int texsize = MAX(p_data->size.x * 0.125, 256);
|
||||
|
||||
texsize = next_power_of_2((uint32_t)texsize);
|
||||
texsize = Math::next_power_of_2((uint32_t)texsize);
|
||||
|
||||
if (p_msdf) {
|
||||
texsize = MIN(texsize, 2048);
|
||||
|
|
@ -295,10 +295,10 @@ _FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_
|
|||
texsize = MIN(texsize, 1024);
|
||||
}
|
||||
if (mw > texsize) { // Special case, adapt to it?
|
||||
texsize = next_power_of_2((uint32_t)mw);
|
||||
texsize = Math::next_power_of_2((uint32_t)mw);
|
||||
}
|
||||
if (mh > texsize) { // Special case, adapt to it?
|
||||
texsize = next_power_of_2((uint32_t)mh);
|
||||
texsize = Math::next_power_of_2((uint32_t)mh);
|
||||
}
|
||||
|
||||
ShelfPackTexture tex = ShelfPackTexture(texsize, texsize);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ void WebRTCDataChannel::_bind_methods() {
|
|||
}
|
||||
|
||||
WebRTCDataChannel::WebRTCDataChannel() {
|
||||
_in_buffer_shift = nearest_shift(uint32_t((int)GLOBAL_GET("network/limits/webrtc/max_channel_in_buffer_kb") - 1)) + (uint32_t)10;
|
||||
_in_buffer_shift = Math::nearest_shift(uint32_t((int)GLOBAL_GET("network/limits/webrtc/max_channel_in_buffer_kb") - 1)) + (uint32_t)10;
|
||||
}
|
||||
|
||||
WebRTCDataChannel::~WebRTCDataChannel() {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ Error EMWSPeer::connect_to_url(const String &p_url, const Ref<TLSOptions> &p_tls
|
|||
if (peer_sock == -1) {
|
||||
return FAILED;
|
||||
}
|
||||
in_buffer.resize(nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
in_buffer.resize(Math::nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
packet_buffer.resize(inbound_buffer_size);
|
||||
ready_state = STATE_CONNECTING;
|
||||
return OK;
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ Error WSLPeer::_do_server_handshake() {
|
|||
wslay_event_context_server_init(&wsl_ctx, &_wsl_callbacks, this);
|
||||
wslay_event_config_set_no_buffering(wsl_ctx, 1);
|
||||
wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size);
|
||||
in_buffer.resize(nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
in_buffer.resize(Math::nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
packet_buffer.resize(inbound_buffer_size);
|
||||
ready_state = STATE_OPEN;
|
||||
}
|
||||
|
|
@ -406,7 +406,7 @@ void WSLPeer::_do_client_handshake() {
|
|||
wslay_event_context_client_init(&wsl_ctx, &_wsl_callbacks, this);
|
||||
wslay_event_config_set_no_buffering(wsl_ctx, 1);
|
||||
wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size);
|
||||
in_buffer.resize(nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
in_buffer.resize(Math::nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
packet_buffer.resize(inbound_buffer_size);
|
||||
ready_state = STATE_OPEN;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue