Add 64-bit versions of core power of 2 functions
This commit is contained in:
@ -178,7 +178,7 @@ int AudioRBResampler::get_num_of_ready_frames() {
|
||||
Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_mix_rate, int p_buffer_msec, int p_minbuff_needed) {
|
||||
ERR_FAIL_COND_V(p_channels != 1 && p_channels != 2 && p_channels != 4 && p_channels != 6 && p_channels != 8, ERR_INVALID_PARAMETER);
|
||||
|
||||
int desired_rb_bits = nearest_shift(MAX((p_buffer_msec / 1000.0) * p_src_mix_rate, p_minbuff_needed));
|
||||
int desired_rb_bits = nearest_shift((uint32_t)MAX((p_buffer_msec / 1000.0) * p_src_mix_rate, p_minbuff_needed));
|
||||
|
||||
bool recreate = !rb;
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ Ref<AudioEffectInstance> AudioEffectCapture::instantiate() {
|
||||
if (!buffer_initialized) {
|
||||
float target_buffer_size = AudioServer::get_singleton()->get_mix_rate() * buffer_length_seconds;
|
||||
ERR_FAIL_COND_V(target_buffer_size <= 0 || target_buffer_size >= (1 << 27), Ref<AudioEffectInstance>());
|
||||
buffer.resize(nearest_shift((int)target_buffer_size));
|
||||
buffer.resize(nearest_shift((uint32_t)target_buffer_size));
|
||||
buffer_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ Ref<AudioStreamPlayback> AudioStreamGenerator::instantiate_playback() {
|
||||
Ref<AudioStreamGeneratorPlayback> playback;
|
||||
playback.instantiate();
|
||||
playback->generator = this;
|
||||
int target_buffer_size = _get_target_rate() * buffer_len;
|
||||
uint32_t target_buffer_size = _get_target_rate() * buffer_len;
|
||||
playback->buffer.resize(nearest_shift(target_buffer_size));
|
||||
playback->buffer.clear();
|
||||
return playback;
|
||||
|
||||
@ -2133,7 +2133,7 @@ void LightStorage::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
|
||||
ERR_FAIL_NULL(shadow_atlas);
|
||||
ERR_FAIL_COND(p_size < 0);
|
||||
p_size = next_power_of_2(p_size);
|
||||
p_size = next_power_of_2((uint32_t)p_size);
|
||||
|
||||
if (p_size == shadow_atlas->size && p_16_bits == shadow_atlas->use_16_bits) {
|
||||
return;
|
||||
@ -2170,7 +2170,7 @@ void LightStorage::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quad
|
||||
ERR_FAIL_INDEX(p_quadrant, 4);
|
||||
ERR_FAIL_INDEX(p_subdivision, 16384);
|
||||
|
||||
uint32_t subdiv = next_power_of_2(p_subdivision);
|
||||
uint32_t subdiv = next_power_of_2((uint32_t)p_subdivision);
|
||||
if (subdiv & 0xaaaaaaaa) { //sqrt(subdiv) must be integer
|
||||
subdiv <<= 1;
|
||||
}
|
||||
@ -2365,7 +2365,7 @@ bool LightStorage::shadow_atlas_update_light(RID p_atlas, RID p_light_instance,
|
||||
}
|
||||
|
||||
uint32_t quad_size = shadow_atlas->size >> 1;
|
||||
int desired_fit = MIN(quad_size / shadow_atlas->smallest_subdiv, next_power_of_2(quad_size * p_coverage));
|
||||
int desired_fit = MIN(quad_size / shadow_atlas->smallest_subdiv, next_power_of_2(uint32_t(quad_size * p_coverage)));
|
||||
|
||||
int valid_quadrants[4];
|
||||
int valid_quadrant_count = 0;
|
||||
|
||||
Reference in New Issue
Block a user