summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/audio/audio_stream.cpp8
-rw-r--r--servers/audio/reverb_sw.cpp3
-rw-r--r--servers/audio_server.cpp4
-rw-r--r--servers/physics/collision_object_sw.h2
-rw-r--r--servers/register_server_types.cpp13
-rw-r--r--servers/visual/shader_language.cpp42
-rw-r--r--servers/visual/visual_server_scene.cpp10
-rw-r--r--servers/visual/visual_server_viewport.cpp2
-rw-r--r--servers/visual_server.cpp10
9 files changed, 71 insertions, 23 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/reverb_sw.cpp b/servers/audio/reverb_sw.cpp
index 8adc21b406..63bf1a7eaa 100644
--- a/servers/audio/reverb_sw.cpp
+++ b/servers/audio/reverb_sw.cpp
@@ -39,9 +39,6 @@
#define rangeloop(c, min, max) \
for ((c) = (min); (c) < (max); (c)++)
-#define ABSDIFF(x, y) \
- (((x) < (y)) ? ((y) - (x)) : ((x) - (y)))
-
#define MULSHIFT_S32(Factor1, Factor2, Bits) \
((int)(((int64_t)(Factor1) * (Factor2)) >> (Bits)))
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/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index 6e6b66dac2..5c14d5aaf9 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -130,7 +130,7 @@ public:
_FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; }
_FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
_FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
- _FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; }
+ _FORCE_INLINE_ real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; }
_FORCE_INLINE_ Transform get_transform() const { return transform; }
_FORCE_INLINE_ Transform get_inv_transform() const { return inv_transform; }
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 4e167be300..922f017d0b 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -88,8 +88,21 @@ Physics2DServer *_createGodotPhysics2DCallback() {
return Physics2DServerWrapMT::init_server<Physics2DServerSW>();
}
+static bool has_server_feature_callback(const String &p_feature) {
+
+ if (VisualServer::get_singleton()) {
+ if (VisualServer::get_singleton()->has_os_feature(p_feature)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void register_server_types() {
+ OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
+
ClassDB::register_virtual_class<VisualServer>();
ClassDB::register_class<AudioServer>();
ClassDB::register_virtual_class<PhysicsServer>();
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 639946916d..1f9d263354 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -2075,7 +2075,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p
for (int i = 0; i < argcount; 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
+ //all good, but needs implicit conversion later
} else if (args[i] != builtin_func_defs[idx].args[i]) {
fail = true;
break;
@@ -2121,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;
@@ -2187,7 +2205,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p
for (int j = 0; j < args.size(); j++) {
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
+ //all good, but it needs implicit conversion later
} else if (args[j] != pfunc->arguments[j].type) {
fail = true;
break;
@@ -2195,6 +2213,26 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p
}
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/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index b561351374..42be56cfdd 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -2480,7 +2480,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
uint32_t a = uint32_t(alpha_block[x][y]) - min_alpha;
//convert range to 3 bits
a = int((a * 7.0 / (max_alpha - min_alpha)) + 0.5);
- a = CLAMP(a, 0, 7); //just to be sure
+ a = MIN(a, 7); //just to be sure
a = 7 - a; //because range is inverted in this mode
if (a == 0) {
//do none, remain
@@ -2924,10 +2924,10 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
uint32_t mm_ofs = sizes[0] * sizes[1] * (local_data[idx].pos[2]) + sizes[0] * (local_data[idx].pos[1]) + (local_data[idx].pos[0]);
mm_ofs *= 4; //for RGBA (4 bytes)
- mipmapw[mm_ofs + 0] = uint8_t(CLAMP(r2, 0, 255));
- mipmapw[mm_ofs + 1] = uint8_t(CLAMP(g, 0, 255));
- mipmapw[mm_ofs + 2] = uint8_t(CLAMP(b, 0, 255));
- mipmapw[mm_ofs + 3] = uint8_t(CLAMP(a, 0, 255));
+ mipmapw[mm_ofs + 0] = uint8_t(MIN(r2, 255));
+ mipmapw[mm_ofs + 1] = uint8_t(MIN(g, 255));
+ mipmapw[mm_ofs + 2] = uint8_t(MIN(b, 255));
+ mipmapw[mm_ofs + 3] = uint8_t(MIN(a, 255));
}
}
} else if (probe_data->dynamic.compression == RasterizerStorage::GI_PROBE_S3TC) {
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index d6e43b0f00..2c6709662f 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -167,7 +167,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
RasterizerCanvas::Light *light = lights_with_shadow;
while (light) {
- VSG::canvas_render->canvas_light_shadow_buffer_update(light->shadow_buffer, light->xform_cache.affine_inverse(), light->item_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders, &light->shadow_matrix_cache);
+ VSG::canvas_render->canvas_light_shadow_buffer_update(light->shadow_buffer, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders, &light->shadow_matrix_cache);
light = light->shadows_next_ptr;
}
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);