diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/register_server_types.cpp | 20 | ||||
-rw-r--r-- | servers/visual/rasterizer.h | 5 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.h | 4 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 15 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 5 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 9 | ||||
-rw-r--r-- | servers/visual_server.h | 12 |
7 files changed, 69 insertions, 1 deletions
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 3634a03dbc..2af2a79d07 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -35,6 +35,25 @@ #include "physics_2d_server.h" #include "spatial_sound_server.h" #include "spatial_sound_2d_server.h" +#include "script_debugger_remote.h" + +static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsage>* r_usage) { + + List<VS::TextureInfo> tinfo; + VS::get_singleton()->texture_debug_usage(&tinfo); + + for (List<VS::TextureInfo>::Element *E=tinfo.front();E;E=E->next()) { + + ScriptDebuggerRemote::ResourceUsage usage; + usage.path=E->get().path; + usage.vram=E->get().bytes; + usage.id=E->get().texture; + usage.type="Texture"; + usage.format=itos(E->get().size.width)+"x"+itos(E->get().size.height)+" "+Image::get_format_name(E->get().format); + r_usage->push_back(usage); + } + +} void register_server_types() { @@ -63,6 +82,7 @@ void register_server_types() { ObjectTypeDB::register_virtual_type<PhysicsDirectSpaceState>(); ObjectTypeDB::register_virtual_type<PhysicsShapeQueryResult>(); + ScriptDebuggerRemote::resource_usage_func=_debugger_get_resource_usage; } void unregister_server_types(){ diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 15c757665b..e22b3c3a6c 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -190,9 +190,12 @@ public: virtual bool texture_has_alpha(RID p_texture) const=0; virtual void texture_set_size_override(RID p_texture,int p_width, int p_height)=0; - virtual void texture_set_reload_hook(RID p_texture,ObjectID p_owner,const StringName& p_function) const=0; + virtual void texture_set_path(RID p_texture,const String& p_path)=0; + virtual String texture_get_path(RID p_texture) const=0; + virtual void texture_debug_usage(List<VS::TextureInfo> *r_info)=0; + /* SHADER API */ virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL)=0; diff --git a/servers/visual/rasterizer_dummy.h b/servers/visual/rasterizer_dummy.h index 9249ad6256..f582fbd8ee 100644 --- a/servers/visual/rasterizer_dummy.h +++ b/servers/visual/rasterizer_dummy.h @@ -415,6 +415,10 @@ public: virtual void texture_set_size_override(RID p_texture,int p_width, int p_height); virtual void texture_set_reload_hook(RID p_texture,ObjectID p_owner,const StringName& p_function) const; + virtual void texture_set_path(RID p_texture,const String& p_path) {} + virtual String texture_get_path(RID p_texture) const { return String(); } + virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) {} + /* SHADER API */ virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 01af2d86ad..a94d4f64c7 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -112,6 +112,21 @@ void VisualServerRaster::texture_set_reload_hook(RID p_texture,ObjectID p_owner, rasterizer->texture_set_reload_hook(p_texture,p_owner,p_function); } +void VisualServerRaster::texture_set_path(RID p_texture,const String& p_path) { + + rasterizer->texture_set_path(p_texture,p_path); +} + +String VisualServerRaster::texture_get_path(RID p_texture) const{ + + return rasterizer->texture_get_path(p_texture); +} + +void VisualServerRaster::texture_debug_usage(List<TextureInfo> *r_info){ + + rasterizer->texture_debug_usage(r_info); +} + /* SHADER API */ RID VisualServerRaster::shader_create(ShaderMode p_mode) { diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 3d8331984a..b6a5ca6308 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -668,6 +668,11 @@ public: virtual bool texture_can_stream(RID p_texture) const; virtual void texture_set_reload_hook(RID p_texture,ObjectID p_owner,const StringName& p_function) const; + virtual void texture_set_path(RID p_texture,const String& p_path); + virtual String texture_get_path(RID p_texture) const; + + virtual void texture_debug_usage(List<TextureInfo> *r_info); + /* SHADER API */ diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index af88c9bdc9..57d691ae68 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -98,6 +98,15 @@ public: FUNC1RC(bool,texture_can_stream,RID); FUNC3C(texture_set_reload_hook,RID,ObjectID,const StringName&); + FUNC2(texture_set_path,RID,const String&); + FUNC1RC(String,texture_get_path,RID); + + virtual void texture_debug_usage(List<TextureInfo> *r_info) { + //pass directly, should lock the server anyway + visual_server->texture_debug_usage(r_info); + } + + /* SHADER API */ FUNC1R(RID,shader_create,ShaderMode); diff --git a/servers/visual_server.h b/servers/visual_server.h index ece61ec701..96c3e15cde 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -135,6 +135,18 @@ public: virtual bool texture_can_stream(RID p_texture) const=0; virtual void texture_set_reload_hook(RID p_texture,ObjectID p_owner,const StringName& p_function) const=0; + virtual void texture_set_path(RID p_texture,const String& p_path)=0; + virtual String texture_get_path(RID p_texture) const=0; + + struct TextureInfo { + RID texture; + Size2 size; + Image::Format format; + int bytes; + String path; + }; + + virtual void texture_debug_usage(List<TextureInfo> *r_info)=0; /* SHADER API */ |