diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/audio/audio_stream.cpp | 8 | ||||
-rw-r--r-- | servers/audio_server.cpp | 4 | ||||
-rw-r--r-- | servers/visual/shader_language.cpp | 46 | ||||
-rw-r--r-- | servers/visual_server.cpp | 10 |
4 files changed, 55 insertions, 13 deletions
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index bd98619e92..12ee98595d 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -138,7 +138,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer(); unsigned int input_size = AudioDriver::get_singleton()->get_input_size(); int mix_rate = AudioDriver::get_singleton()->get_mix_rate(); - int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1); + unsigned int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1); #ifdef DEBUG_ENABLED unsigned int input_position = AudioDriver::get_singleton()->get_input_position(); #endif @@ -152,11 +152,11 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr for (int i = 0; i < p_frames; i++) { if (input_size > input_ofs) { float l = (buf[input_ofs++] >> 16) / 32768.f; - if (input_ofs >= buf.size()) { + if ((int)input_ofs >= buf.size()) { input_ofs = 0; } float r = (buf[input_ofs++] >> 16) / 32768.f; - if (input_ofs >= buf.size()) { + if ((int)input_ofs >= buf.size()) { input_ofs = 0; } @@ -168,7 +168,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr } #ifdef DEBUG_ENABLED - if (input_ofs > input_position && (input_ofs - input_position) < (p_frames * 2)) { + if (input_ofs > input_position && (int)(input_ofs - input_position) < (p_frames * 2)) { print_verbose(String(get_class_name()) + " buffer underrun: input_position=" + itos(input_position) + " input_ofs=" + itos(input_ofs) + " input_size=" + itos(input_size)); } #endif diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index a2e5813a4f..df6218ac79 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -91,10 +91,10 @@ void AudioDriver::input_buffer_init(int driver_buffer_frames) { void AudioDriver::input_buffer_write(int32_t sample) { input_buffer.write[input_position++] = sample; - if (input_position >= input_buffer.size()) { + if ((int)input_position >= input_buffer.size()) { input_position = 0; } - if (input_size < input_buffer.size()) { + if ((int)input_size < input_buffer.size()) { input_size++; } } diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 9a0218d5d0..1f9d263354 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -2074,7 +2074,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p bool fail = false; for (int i = 0; i < argcount; i++) { - if (args[i] != builtin_func_defs[idx].args[i]) { + if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) { + //all good, but needs implicit conversion later + } else if (args[i] != builtin_func_defs[idx].args[i]) { fail = true; break; } @@ -2119,6 +2121,24 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p outarg_idx++; } + //implicitly convert values if possible + for (int i = 0; i < argcount; i++) { + + if (get_scalar_type(args[i]) != args[i] || args[i] == builtin_func_defs[idx].args[i] || p_func->arguments[i + 1]->type != Node::TYPE_CONSTANT) { + //can't do implicit conversion here + continue; + } + + //this is an implicit conversion + ConstantNode *constant = static_cast<ConstantNode *>(p_func->arguments[i + 1]); + ConstantNode *conversion = alloc_node<ConstantNode>(); + + conversion->datatype = builtin_func_defs[idx].args[i]; + conversion->values.resize(1); + + convert_constant(constant, builtin_func_defs[idx].args[i], conversion->values.ptrw()); + p_func->arguments.write[i + 1] = conversion; + } if (r_ret_type) *r_ret_type = builtin_func_defs[idx].rettype; @@ -2184,13 +2204,35 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p for (int j = 0; j < args.size(); j++) { - if (args[j] != pfunc->arguments[j].type) { + if (get_scalar_type(args[j]) == args[j] && p_func->arguments[j + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[j + 1]), pfunc->arguments[j].type)) { + //all good, but it needs implicit conversion later + } else if (args[j] != pfunc->arguments[j].type) { fail = true; break; } } if (!fail) { + + //implicitly convert values if possible + for (int k = 0; k < args.size(); k++) { + + if (get_scalar_type(args[k]) != args[k] || args[k] == pfunc->arguments[k].type || p_func->arguments[k + 1]->type != Node::TYPE_CONSTANT) { + //can't do implicit conversion here + continue; + } + + //this is an implicit conversion + ConstantNode *constant = static_cast<ConstantNode *>(p_func->arguments[k + 1]); + ConstantNode *conversion = alloc_node<ConstantNode>(); + + conversion->datatype = pfunc->arguments[k].type; + conversion->values.resize(1); + + convert_constant(constant, pfunc->arguments[k].type, conversion->values.ptrw()); + p_func->arguments.write[k + 1] = conversion; + } + if (r_ret_type) *r_ret_type = pfunc->return_type; return true; diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index c61e2b99e2..3dbe516f74 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2368,11 +2368,11 @@ VisualServer::VisualServer() { //ERR_FAIL_COND(singleton); singleton = this; - GLOBAL_DEF("rendering/vram_compression/import_bptc", false); - GLOBAL_DEF("rendering/vram_compression/import_s3tc", true); - GLOBAL_DEF("rendering/vram_compression/import_etc", false); - GLOBAL_DEF("rendering/vram_compression/import_etc2", true); - GLOBAL_DEF("rendering/vram_compression/import_pvrtc", false); + GLOBAL_DEF_RST("rendering/vram_compression/import_bptc", false); + GLOBAL_DEF_RST("rendering/vram_compression/import_s3tc", true); + GLOBAL_DEF_RST("rendering/vram_compression/import_etc", false); + GLOBAL_DEF_RST("rendering/vram_compression/import_etc2", true); + GLOBAL_DEF_RST("rendering/vram_compression/import_pvrtc", false); GLOBAL_DEF("rendering/quality/directional_shadow/size", 4096); GLOBAL_DEF("rendering/quality/directional_shadow/size.mobile", 2048); |