diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-10-20 19:19:19 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-10-20 19:19:19 -0300 |
commit | b5011d9bf1dea0e16b5b15da82f6110c4055ad09 (patch) | |
tree | 02dba35ef82e31a807fbe08887e64ea6fff6c1f3 /tools | |
parent | 2b12a8109dda1f47f9b75a5de91d7d00c1f25869 (diff) |
-Fixes on atlas import to save memory if mipmaps are not used
-Make the video memory visible to improve debugging
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/io_plugins/editor_texture_import_plugin.cpp | 20 | ||||
-rw-r--r-- | tools/editor/script_editor_debugger.cpp | 32 | ||||
-rw-r--r-- | tools/editor/script_editor_debugger.h | 3 |
3 files changed, 51 insertions, 4 deletions
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index c0887ab40a..8d5a4f1dcf 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -1180,8 +1180,15 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc ep.step("Blitting Images",sources.size()+2); + bool blit_to_po2=tex_flags&Texture::FLAG_MIPMAPS; + int atlas_w=dst_size.width; + int atlas_h=dst_size.height; + if (blit_to_po2) { + atlas_w=nearest_power_of_2(dst_size.width); + atlas_h=nearest_power_of_2(dst_size.height); + } Image atlas; - atlas.create(nearest_power_of_2(dst_size.width),nearest_power_of_2(dst_size.height),0,alpha?Image::FORMAT_RGBA:Image::FORMAT_RGB); + atlas.create(atlas_w,atlas_h,0,alpha?Image::FORMAT_RGBA:Image::FORMAT_RGB); atlases.resize(from->get_source_count()); @@ -1210,16 +1217,21 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc ERR_CONTINUE( !source_map.has(i) ); for (List<int>::Element *E=source_map[i].front();E;E=E->next()) { - Ref<AtlasTexture> at = memnew( AtlasTexture ); + String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); + + Ref<AtlasTexture> at; + if (ResourceCache::has(apath)) { + at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() ); + } else { + at = Ref<AtlasTexture>( memnew( AtlasTexture ) ); + } at->set_region(region); at->set_margin(margin); - String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); at->set_path(apath); atlases[E->get()]=at; print_line("Atlas Tex: "+apath); - } } if (ResourceCache::has(p_path)) { diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 2e1fa2814e..084e7a6a1f 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -1322,6 +1322,38 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ } + VBoxContainer *vmem_vb = memnew( VBoxContainer ); + HBoxContainer *vmem_hb = memnew( HBoxContainer ); + Label *vmlb = memnew(Label("List of Video Memory Usage by Resource: ") ); + vmlb->set_h_size_flags(SIZE_EXPAND_FILL); + vmem_hb->add_child( vmlb ); + vmem_refresh = memnew( Button ); + vmem_hb->add_child(vmem_refresh); + vmem_vb->add_child(vmem_hb); + + MarginContainer *vmmc = memnew( MarginContainer ); + vmmc = memnew( MarginContainer ); + vmem_tree = memnew( Tree ); + vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL); + vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL); + vmmc->add_child(vmem_tree); + vmmc->set_v_size_flags(SIZE_EXPAND_FILL); + vmem_vb->add_child(vmmc); + + vmem_vb->set_name("Video Mem"); + vmem_tree->set_columns(3); + vmem_tree->set_column_titles_visible(true); + vmem_tree->set_column_title(0,"Resource Path"); + vmem_tree->set_column_expand(0,true); + vmem_tree->set_column_expand(1,false); + vmem_tree->set_column_title(1,"Type"); + vmem_tree->set_column_min_width(1,150); + vmem_tree->set_column_expand(2,false); + vmem_tree->set_column_title(2,"Usage"); + vmem_tree->set_column_min_width(2,150); + + tabs->add_child(vmem_vb); + info = memnew( HSplitContainer ); info->set_name("Info"); tabs->add_child(info); diff --git a/tools/editor/script_editor_debugger.h b/tools/editor/script_editor_debugger.h index 3c66dde340..04459e39f8 100644 --- a/tools/editor/script_editor_debugger.h +++ b/tools/editor/script_editor_debugger.h @@ -96,6 +96,9 @@ class ScriptEditorDebugger : public Control { Tree *perf_monitors; Control *perf_draw; + Tree *vmem_tree; + Button *vmem_refresh; + Tree *stack_dump; PropertyEditor *inspector; |