-Fixes on atlas import to save memory if mipmaps are not used
-Make the video memory visible to improve debugging
This commit is contained in:
parent
2b12a8109d
commit
b5011d9bf1
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user