diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/renderer_scene_render_rd.cpp | 6 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_storage_rd.cpp | 21 | ||||
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 22 | ||||
-rw-r--r-- | servers/rendering/shader_language.cpp | 41 | ||||
-rw-r--r-- | servers/text/text_server_extension.cpp | 15 | ||||
-rw-r--r-- | servers/text/text_server_extension.h | 5 | ||||
-rw-r--r-- | servers/text_server.cpp | 32 | ||||
-rw-r--r-- | servers/text_server.h | 3 | ||||
-rw-r--r-- | servers/xr/xr_pose.cpp | 2 |
9 files changed, 100 insertions, 47 deletions
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 7af4f0e849..77843ceee5 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -545,11 +545,7 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba Ref<Image> panorama; panorama.instantiate(); panorama->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF); - for (int x = 0; x < p_size.width; x++) { - for (int y = 0; y < p_size.height; y++) { - panorama->set_pixel(x, y, panorama_color); - } - } + panorama->fill(panorama_color); return panorama; } diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 5507f206b5..932cdcaea8 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -971,12 +971,7 @@ void RendererStorageRD::texture_2d_placeholder_initialize(RID p_texture) { Ref<Image> image; image.instantiate(); image->create(4, 4, false, Image::FORMAT_RGBA8); - - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - image->set_pixel(i, j, Color(1, 0, 1, 1)); - } - } + image->fill(Color(1, 0, 1, 1)); texture_2d_initialize(p_texture, image); } @@ -987,12 +982,7 @@ void RendererStorageRD::texture_2d_layered_placeholder_initialize(RID p_texture, Ref<Image> image; image.instantiate(); image->create(4, 4, false, Image::FORMAT_RGBA8); - - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - image->set_pixel(i, j, Color(1, 0, 1, 1)); - } - } + image->fill(Color(1, 0, 1, 1)); Vector<Ref<Image>> images; if (p_layered_type == RS::TEXTURE_LAYERED_2D_ARRAY) { @@ -1013,12 +1003,7 @@ void RendererStorageRD::texture_3d_placeholder_initialize(RID p_texture) { Ref<Image> image; image.instantiate(); image->create(4, 4, false, Image::FORMAT_RGBA8); - - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - image->set_pixel(i, j, Color(1, 0, 1, 1)); - } - } + image->fill(Color(1, 0, 1, 1)); Vector<Ref<Image>> images; //cube diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 47934e7299..17a665922f 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -582,6 +582,21 @@ void RendererViewport::draw_viewports() { bool visible = vp->viewport_to_screen_rect != Rect2(); + if (vp->use_xr && xr_interface.is_valid()) { + visible = true; // XR viewport is always visible regardless of update mode, output is sent to HMD. + + // Override our size, make sure it matches our required size and is created as a stereo target + Size2 xr_size = xr_interface->get_render_target_size(); + + // Would have been nice if we could call viewport_set_size here, + // but alas that takes our RID and we now have our pointer, + // also we only check if view_count changes in render_target_set_size so we need to call that for this to reliably change + vp->occlusion_buffer_dirty = vp->occlusion_buffer_dirty || (vp->size != xr_size); + vp->size = xr_size; + uint32_t view_count = xr_interface->get_view_count(); + RSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y, view_count); + } + if (vp->update_mode == RS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) { visible = true; } @@ -619,11 +634,6 @@ void RendererViewport::draw_viewports() { RSG::storage->render_target_set_as_unused(vp->render_target); if (vp->use_xr && xr_interface.is_valid()) { - // override our size, make sure it matches our required size and is created as a stereo target - vp->size = xr_interface->get_render_target_size(); - uint32_t view_count = xr_interface->get_view_count(); - RSG::storage->render_target_set_size(vp->render_target, vp->internal_size.x, vp->internal_size.y, view_count); - // check for an external texture destination (disabled for now, not yet supported) // RSG::storage->render_target_set_external_texture(vp->render_target, xr_interface->get_external_texture_for_eye(leftOrMono)); RSG::storage->render_target_set_external_texture(vp->render_target, 0); @@ -843,7 +853,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_ // if render_direct_to_screen was used, reset size and position if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { RSG::storage->render_target_set_position(viewport->render_target, 0, 0); - RSG::storage->render_target_set_size(viewport->render_target, viewport->internal_size.x, viewport->internal_size.y, viewport->get_view_count()); + RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y, viewport->get_view_count()); } viewport->viewport_to_screen_rect = Rect2(); diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 5d420ba48d..adbcdedacc 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -7596,8 +7596,16 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct #ifdef DEBUG_ENABLED int uniform_buffer_size = 0; int max_uniform_buffer_size = 0; - if (RenderingDevice::get_singleton()) { - max_uniform_buffer_size = RenderingDevice::get_singleton()->limit_get(RenderingDevice::LIMIT_MAX_UNIFORM_BUFFER_SIZE); + int uniform_buffer_exceeded_line = -1; + + bool check_device_limit_warnings = false; + { + RenderingDevice *device = RenderingDevice::get_singleton(); + if (device != nullptr) { + check_device_limit_warnings = check_warnings && HAS_WARNING(ShaderWarning::DEVICE_LIMIT_EXCEEDED_FLAG); + + max_uniform_buffer_size = device->limit_get(RenderingDevice::LIMIT_MAX_UNIFORM_BUFFER_SIZE); + } } #endif // DEBUG_ENABLED ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL; @@ -8001,15 +8009,21 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) { uniform2.order = uniforms++; #ifdef DEBUG_ENABLED - if (uniform2.array_size > 0) { - int size = get_datatype_size(uniform2.type) * uniform2.array_size; - int m = (16 * uniform2.array_size); - if ((size % m) != 0U) { - size += m - (size % m); + if (check_device_limit_warnings) { + if (uniform2.array_size > 0) { + int size = get_datatype_size(uniform2.type) * uniform2.array_size; + int m = (16 * uniform2.array_size); + if ((size % m) != 0U) { + size += m - (size % m); + } + uniform_buffer_size += size; + } else { + uniform_buffer_size += get_datatype_size(uniform2.type); + } + + if (uniform_buffer_exceeded_line == -1 && uniform_buffer_size > max_uniform_buffer_size) { + uniform_buffer_exceeded_line = tk_line; } - uniform_buffer_size += size; - } else { - uniform_buffer_size += get_datatype_size(uniform2.type); } #endif // DEBUG_ENABLED } @@ -9022,11 +9036,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } #ifdef DEBUG_ENABLED - if (HAS_WARNING(ShaderWarning::DEVICE_LIMIT_EXCEEDED) && (uniform_buffer_size > max_uniform_buffer_size)) { - Vector<Variant> args; - args.push_back(uniform_buffer_size); - args.push_back(max_uniform_buffer_size); - _add_global_warning(ShaderWarning::DEVICE_LIMIT_EXCEEDED, "uniform buffer", args); + if (check_device_limit_warnings && uniform_buffer_exceeded_line != -1) { + _add_warning(ShaderWarning::DEVICE_LIMIT_EXCEEDED, uniform_buffer_exceeded_line, "uniform buffer", { uniform_buffer_size, max_uniform_buffer_size }); } #endif // DEBUG_ENABLED return OK; diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index 2b0510680e..a51b62e730 100644 --- a/servers/text/text_server_extension.cpp +++ b/servers/text/text_server_extension.cpp @@ -174,6 +174,9 @@ void TextServerExtension::_bind_methods() { GDVIRTUAL_BIND(_font_remove_script_support_override, "font_rid", "script"); GDVIRTUAL_BIND(_font_get_script_support_overrides, "font_rid"); + GDVIRTUAL_BIND(_font_set_opentype_feature_overrides, "font_rid", "overrides"); + GDVIRTUAL_BIND(_font_get_opentype_feature_overrides, "font_rid"); + GDVIRTUAL_BIND(_font_supported_feature_list, "font_rid"); GDVIRTUAL_BIND(_font_supported_variation_list, "font_rid"); @@ -869,6 +872,18 @@ Vector<String> TextServerExtension::font_get_script_support_overrides(RID p_font return Vector<String>(); } +void TextServerExtension::font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) { + GDVIRTUAL_CALL(_font_set_opentype_feature_overrides, p_font_rid, p_overrides); +} + +Dictionary TextServerExtension::font_get_opentype_feature_overrides(RID p_font_rid) const { + Dictionary ret; + if (GDVIRTUAL_CALL(_font_get_opentype_feature_overrides, p_font_rid, ret)) { + return ret; + } + return Dictionary(); +} + Dictionary TextServerExtension::font_supported_feature_list(RID p_font_rid) const { Dictionary ret; if (GDVIRTUAL_CALL(_font_supported_feature_list, p_font_rid, ret)) { diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index 5c97401118..9b456c2dd7 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -285,6 +285,11 @@ public: GDVIRTUAL2(_font_remove_script_support_override, RID, const String &); GDVIRTUAL1R(Vector<String>, _font_get_script_support_overrides, RID); + virtual void font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(RID p_font_rid) const override; + GDVIRTUAL2(_font_set_opentype_feature_overrides, RID, const Dictionary &); + GDVIRTUAL1RC(Dictionary, _font_get_opentype_feature_overrides, RID); + virtual Dictionary font_supported_feature_list(RID p_font_rid) const override; virtual Dictionary font_supported_variation_list(RID p_font_rid) const override; GDVIRTUAL1RC(Dictionary, _font_supported_feature_list, RID); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index d547bcc75e..143cda985d 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -327,6 +327,9 @@ void TextServer::_bind_methods() { ClassDB::bind_method(D_METHOD("font_remove_script_support_override", "font_rid", "script"), &TextServer::font_remove_script_support_override); ClassDB::bind_method(D_METHOD("font_get_script_support_overrides", "font_rid"), &TextServer::font_get_script_support_overrides); + ClassDB::bind_method(D_METHOD("font_set_opentype_feature_overrides", "font_rid", "overrides"), &TextServer::font_set_opentype_feature_overrides); + ClassDB::bind_method(D_METHOD("font_get_opentype_feature_overrides", "font_rid"), &TextServer::font_get_opentype_feature_overrides); + ClassDB::bind_method(D_METHOD("font_supported_feature_list", "font_rid"), &TextServer::font_supported_feature_list); ClassDB::bind_method(D_METHOD("font_supported_variation_list", "font_rid"), &TextServer::font_supported_variation_list); @@ -989,9 +992,9 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start, } real_t char_adv = advance / (real_t)(glyphs[i].end - glyphs[i].start); if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { - ranges.push_back(Vector2(off, off + char_adv * (start - glyphs[i].start))); + ranges.push_back(Vector2(off, off + char_adv * (glyphs[i].end - start))); } else { - ranges.push_back(Vector2(off + char_adv * (glyphs[i].end - start), off + advance)); + ranges.push_back(Vector2(off + char_adv * (start - glyphs[i].start), off + advance)); } } // Selection range is within grapheme. @@ -1099,6 +1102,31 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) cons return glyphs[i].start; } } + // Ligature, handle mid-grapheme hit. + if (p_coords >= off && p_coords < off + advance && glyphs[i].end > glyphs[i].start + 1) { + int cnt = glyphs[i].end - glyphs[i].start; + real_t char_adv = advance / (real_t)(cnt); + real_t sub_off = off; + for (int j = 0; j < cnt; j++) { + // Place caret to the left of clicked sub-grapheme. + if (p_coords >= sub_off && p_coords < sub_off + char_adv / 2) { + if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { + return glyphs[i].end - j; + } else { + return glyphs[i].start + j; + } + } + // Place caret to the right of clicked sub-grapheme. + if (p_coords >= sub_off + char_adv / 2 && p_coords < sub_off + char_adv) { + if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { + return glyphs[i].start + (cnt - 1) - j; + } else { + return glyphs[i].end - (cnt - 1) + j; + } + } + sub_off += char_adv; + } + } // Place caret to the left of clicked grapheme. if (p_coords >= off && p_coords < off + advance / 2) { if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { diff --git a/servers/text_server.h b/servers/text_server.h index e9c5248866..d5dccc0edb 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -350,6 +350,9 @@ public: virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) = 0; virtual Vector<String> font_get_script_support_overrides(RID p_font_rid) = 0; + virtual void font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) = 0; + virtual Dictionary font_get_opentype_feature_overrides(RID p_font_rid) const = 0; + virtual Dictionary font_supported_feature_list(RID p_font_rid) const = 0; virtual Dictionary font_supported_variation_list(RID p_font_rid) const = 0; diff --git a/servers/xr/xr_pose.cpp b/servers/xr/xr_pose.cpp index ab6eb042c9..0862fefef5 100644 --- a/servers/xr/xr_pose.cpp +++ b/servers/xr/xr_pose.cpp @@ -35,7 +35,7 @@ void XRPose::_bind_methods() { ClassDB::bind_method(D_METHOD("set_has_tracking_data", "has_tracking_data"), &XRPose::set_has_tracking_data); ClassDB::bind_method(D_METHOD("get_has_tracking_data"), &XRPose::get_has_tracking_data); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "has_tracking_data"), "set_has_tracking_data", "get_has_tracking_data"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "has_tracking_data"), "set_has_tracking_data", "get_has_tracking_data"); ClassDB::bind_method(D_METHOD("set_name", "name"), &XRPose::set_name); ClassDB::bind_method(D_METHOD("get_name"), &XRPose::get_name); |