-Ability to debug video memory usage
-Small fix to xml saver (swapping > and <)
This commit is contained in:
parent
f6a790d58c
commit
b59c86f6f9
18 changed files with 271 additions and 7 deletions
|
@ -34,6 +34,33 @@
|
||||||
#include "print_string.h"
|
#include "print_string.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
const char* Image::format_names[Image::FORMAT_MAX]={
|
||||||
|
"Grayscale",
|
||||||
|
"Intensity",
|
||||||
|
"GrayscaleAlpha",
|
||||||
|
"RGB",
|
||||||
|
"RGBA",
|
||||||
|
"Indexed",
|
||||||
|
"IndexedAlpha",
|
||||||
|
"YUV422",
|
||||||
|
"YUV444",
|
||||||
|
"BC1",
|
||||||
|
"BC2",
|
||||||
|
"BC3",
|
||||||
|
"BC4",
|
||||||
|
"BC5",
|
||||||
|
"PVRTC2",
|
||||||
|
"PVRTC2Alpha",
|
||||||
|
"PVRTC4",
|
||||||
|
"PVRTC4Alpha",
|
||||||
|
"ETC",
|
||||||
|
"ATC",
|
||||||
|
"ATCAlphaExp",
|
||||||
|
"ATCAlphaInterp",
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
SavePNGFunc Image::save_png_func = NULL;
|
SavePNGFunc Image::save_png_func = NULL;
|
||||||
|
|
||||||
void Image::_put_pixel(int p_x,int p_y, const BColor& p_color, unsigned char *p_data) {
|
void Image::_put_pixel(int p_x,int p_y, const BColor& p_color, unsigned char *p_data) {
|
||||||
|
@ -2355,6 +2382,12 @@ void Image::fix_alpha_edges() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Image::get_format_name(Format p_format) {
|
||||||
|
|
||||||
|
ERR_FAIL_INDEX_V(p_format,FORMAT_MAX,String());
|
||||||
|
return format_names[p_format];
|
||||||
|
}
|
||||||
|
|
||||||
Image::Image(const uint8_t* p_png,int p_len) {
|
Image::Image(const uint8_t* p_png,int p_len) {
|
||||||
|
|
||||||
width=0;
|
width=0;
|
||||||
|
|
|
@ -87,6 +87,7 @@ public:
|
||||||
FORMAT_MAX
|
FORMAT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* format_names[FORMAT_MAX];
|
||||||
enum Interpolation {
|
enum Interpolation {
|
||||||
|
|
||||||
INTERPOLATE_NEAREST,
|
INTERPOLATE_NEAREST,
|
||||||
|
@ -352,6 +353,8 @@ public:
|
||||||
Image get_rect(const Rect2& p_area) const;
|
Image get_rect(const Rect2& p_area) const;
|
||||||
|
|
||||||
static void set_compress_bc_func(void (*p_compress_func)(Image *));
|
static void set_compress_bc_func(void (*p_compress_func)(Image *));
|
||||||
|
static String get_format_name(Format p_format);
|
||||||
|
|
||||||
Image(const uint8_t* p_mem_png, int p_len=-1);
|
Image(const uint8_t* p_mem_png, int p_len=-1);
|
||||||
Image(const char **p_xpm);
|
Image(const char **p_xpm);
|
||||||
~Image();
|
~Image();
|
||||||
|
|
|
@ -2056,8 +2056,8 @@ Error ResourceFormatLoaderXML::rename_dependencies(const String &p_path,const Ma
|
||||||
void ResourceFormatSaverXMLInstance::escape(String& p_str) {
|
void ResourceFormatSaverXMLInstance::escape(String& p_str) {
|
||||||
|
|
||||||
p_str=p_str.replace("&","&");
|
p_str=p_str.replace("&","&");
|
||||||
p_str=p_str.replace("<",">");
|
p_str=p_str.replace("<","<");
|
||||||
p_str=p_str.replace(">","<");
|
p_str=p_str.replace(">",">");
|
||||||
p_str=p_str.replace("'","'");
|
p_str=p_str.replace("'","'");
|
||||||
p_str=p_str.replace("\"",""");
|
p_str=p_str.replace("\"",""");
|
||||||
for (char i=1;i<32;i++) {
|
for (char i=1;i<32;i++) {
|
||||||
|
|
|
@ -31,6 +31,28 @@
|
||||||
#include "io/ip.h"
|
#include "io/ip.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
void ScriptDebuggerRemote::_send_video_memory() {
|
||||||
|
|
||||||
|
List<ResourceUsage> usage;
|
||||||
|
if (resource_usage_func)
|
||||||
|
resource_usage_func(&usage);
|
||||||
|
|
||||||
|
usage.sort();
|
||||||
|
|
||||||
|
packet_peer_stream->put_var("message:video_mem");
|
||||||
|
packet_peer_stream->put_var(usage.size()*4);
|
||||||
|
|
||||||
|
|
||||||
|
for(List<ResourceUsage>::Element *E=usage.front();E;E=E->next()) {
|
||||||
|
|
||||||
|
packet_peer_stream->put_var(E->get().path);
|
||||||
|
packet_peer_stream->put_var(E->get().type);
|
||||||
|
packet_peer_stream->put_var(E->get().format);
|
||||||
|
packet_peer_stream->put_var(E->get().vram);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Error ScriptDebuggerRemote::connect_to_host(const String& p_host,uint16_t p_port) {
|
Error ScriptDebuggerRemote::connect_to_host(const String& p_host,uint16_t p_port) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,6 +270,9 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
|
||||||
if (request_scene_tree)
|
if (request_scene_tree)
|
||||||
request_scene_tree(request_scene_tree_ud);
|
request_scene_tree(request_scene_tree_ud);
|
||||||
|
|
||||||
|
} else if (command=="request_video_mem") {
|
||||||
|
|
||||||
|
_send_video_memory();
|
||||||
} else if (command=="breakpoint") {
|
} else if (command=="breakpoint") {
|
||||||
|
|
||||||
bool set = cmd[3];
|
bool set = cmd[3];
|
||||||
|
@ -531,6 +556,9 @@ void ScriptDebuggerRemote::_poll_events() {
|
||||||
|
|
||||||
if (request_scene_tree)
|
if (request_scene_tree)
|
||||||
request_scene_tree(request_scene_tree_ud);
|
request_scene_tree(request_scene_tree_ud);
|
||||||
|
} else if (command=="request_video_mem") {
|
||||||
|
|
||||||
|
_send_video_memory();
|
||||||
} else if (command=="breakpoint") {
|
} else if (command=="breakpoint") {
|
||||||
|
|
||||||
bool set = cmd[3];
|
bool set = cmd[3];
|
||||||
|
@ -652,6 +680,8 @@ void ScriptDebuggerRemote::set_live_edit_funcs(LiveEditFuncs *p_funcs) {
|
||||||
live_edit_funcs=p_funcs;
|
live_edit_funcs=p_funcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func=NULL;
|
||||||
|
|
||||||
ScriptDebuggerRemote::ScriptDebuggerRemote() {
|
ScriptDebuggerRemote::ScriptDebuggerRemote() {
|
||||||
|
|
||||||
tcp_client = StreamPeerTCP::create_ref();
|
tcp_client = StreamPeerTCP::create_ref();
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "io/stream_peer_tcp.h"
|
#include "io/stream_peer_tcp.h"
|
||||||
#include "io/packet_peer.h"
|
#include "io/packet_peer.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
class ScriptDebuggerRemote : public ScriptDebugger {
|
class ScriptDebuggerRemote : public ScriptDebugger {
|
||||||
|
|
||||||
struct Message {
|
struct Message {
|
||||||
|
@ -42,6 +43,8 @@ class ScriptDebuggerRemote : public ScriptDebugger {
|
||||||
Array data;
|
Array data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ref<StreamPeerTCP> tcp_client;
|
Ref<StreamPeerTCP> tcp_client;
|
||||||
Ref<PacketPeerStream> packet_peer_stream;
|
Ref<PacketPeerStream> packet_peer_stream;
|
||||||
|
|
||||||
|
@ -90,6 +93,7 @@ class ScriptDebuggerRemote : public ScriptDebugger {
|
||||||
RequestSceneTreeMessageFunc request_scene_tree;
|
RequestSceneTreeMessageFunc request_scene_tree;
|
||||||
void *request_scene_tree_ud;
|
void *request_scene_tree_ud;
|
||||||
|
|
||||||
|
void _send_video_memory();
|
||||||
LiveEditFuncs *live_edit_funcs;
|
LiveEditFuncs *live_edit_funcs;
|
||||||
|
|
||||||
ErrorHandlerList eh;
|
ErrorHandlerList eh;
|
||||||
|
@ -98,6 +102,20 @@ class ScriptDebuggerRemote : public ScriptDebugger {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
struct ResourceUsage {
|
||||||
|
|
||||||
|
String path;
|
||||||
|
String format;
|
||||||
|
String type;
|
||||||
|
RID id;
|
||||||
|
int vram;
|
||||||
|
bool operator<(const ResourceUsage& p_img) const { return vram==p_img.vram ? id<p_img.id : vram > p_img.vram; }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void (*ResourceUsageFunc)(List<ResourceUsage>*);
|
||||||
|
|
||||||
|
static ResourceUsageFunc resource_usage_func;
|
||||||
|
|
||||||
Error connect_to_host(const String& p_host,uint16_t p_port);
|
Error connect_to_host(const String& p_host,uint16_t p_port);
|
||||||
virtual void debug(ScriptLanguage *p_script,bool p_can_continue=true);
|
virtual void debug(ScriptLanguage *p_script,bool p_can_continue=true);
|
||||||
virtual void idle_poll();
|
virtual void idle_poll();
|
||||||
|
|
|
@ -1408,6 +1408,40 @@ GLuint RasterizerGLES2::_texture_get_name(RID p_tex) {
|
||||||
return texture->tex_id;
|
return texture->tex_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void RasterizerGLES2::texture_set_path(RID p_texture,const String& p_path) {
|
||||||
|
Texture * texture = texture_owner.get(p_texture);
|
||||||
|
ERR_FAIL_COND(!texture);
|
||||||
|
|
||||||
|
texture->path=p_path;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String RasterizerGLES2::texture_get_path(RID p_texture) const{
|
||||||
|
|
||||||
|
Texture * texture = texture_owner.get(p_texture);
|
||||||
|
ERR_FAIL_COND_V(!texture,String());
|
||||||
|
return texture->path;
|
||||||
|
}
|
||||||
|
void RasterizerGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info){
|
||||||
|
|
||||||
|
List<RID> textures;
|
||||||
|
texture_owner.get_owned_list(&textures);
|
||||||
|
|
||||||
|
for (List<RID>::Element *E=textures.front();E;E=E->next()) {
|
||||||
|
|
||||||
|
Texture *t = texture_owner.get(E->get());
|
||||||
|
if (!t)
|
||||||
|
continue;
|
||||||
|
VS::TextureInfo tinfo;
|
||||||
|
tinfo.path=t->path;
|
||||||
|
tinfo.format=t->format;
|
||||||
|
tinfo.size.x=t->alloc_width;
|
||||||
|
tinfo.size.y=t->alloc_height;
|
||||||
|
tinfo.bytes=t->total_data_size;
|
||||||
|
r_info->push_back(tinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* SHADER API */
|
/* SHADER API */
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ class RasterizerGLES2 : public Rasterizer {
|
||||||
|
|
||||||
struct Texture {
|
struct Texture {
|
||||||
|
|
||||||
|
String path;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
int width,height;
|
int width,height;
|
||||||
int alloc_width, alloc_height;
|
int alloc_width, alloc_height;
|
||||||
|
@ -1325,6 +1326,10 @@ public:
|
||||||
virtual void texture_set_size_override(RID p_texture,int p_width, int p_height);
|
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_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<VS::TextureInfo> *r_info);
|
||||||
|
|
||||||
GLuint _texture_get_name(RID p_tex);
|
GLuint _texture_get_name(RID p_tex);
|
||||||
|
|
||||||
/* SHADER API */
|
/* SHADER API */
|
||||||
|
|
|
@ -366,6 +366,16 @@ void ImageTexture::set_size_override(const Size2& p_size) {
|
||||||
VisualServer::get_singleton()->texture_set_size_override(texture,w,h);
|
VisualServer::get_singleton()->texture_set_size_override(texture,w,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageTexture::set_path(const String& p_path,bool p_take_over) {
|
||||||
|
|
||||||
|
if (texture.is_valid()) {
|
||||||
|
VisualServer::get_singleton()->texture_set_path(texture,p_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Resource::set_path(p_path,p_take_over);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImageTexture::set_storage(Storage p_storage) {
|
void ImageTexture::set_storage(Storage p_storage) {
|
||||||
|
|
||||||
storage=p_storage;
|
storage=p_storage;
|
||||||
|
@ -944,6 +954,16 @@ float CubeMap::get_lossy_storage_quality() const {
|
||||||
return lossy_storage_quality;
|
return lossy_storage_quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CubeMap::set_path(const String& p_path,bool p_take_over) {
|
||||||
|
|
||||||
|
if (cubemap.is_valid()) {
|
||||||
|
VisualServer::get_singleton()->texture_set_path(cubemap,p_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Resource::set_path(p_path,p_take_over);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CubeMap::_set(const StringName& p_name, const Variant& p_value) {
|
bool CubeMap::_set(const StringName& p_name, const Variant& p_value) {
|
||||||
|
|
||||||
if (p_name=="side/left") {
|
if (p_name=="side/left") {
|
||||||
|
|
|
@ -152,7 +152,8 @@ public:
|
||||||
|
|
||||||
void set_size_override(const Size2& p_size);
|
void set_size_override(const Size2& p_size);
|
||||||
|
|
||||||
|
virtual void set_path(const String& p_path,bool p_take_over=false);
|
||||||
|
|
||||||
ImageTexture();
|
ImageTexture();
|
||||||
~ImageTexture();
|
~ImageTexture();
|
||||||
|
|
||||||
|
@ -320,6 +321,8 @@ public:
|
||||||
void set_lossy_storage_quality(float p_lossy_storage_quality);
|
void set_lossy_storage_quality(float p_lossy_storage_quality);
|
||||||
float get_lossy_storage_quality() const;
|
float get_lossy_storage_quality() const;
|
||||||
|
|
||||||
|
virtual void set_path(const String& p_path,bool p_take_over=false);
|
||||||
|
|
||||||
CubeMap();
|
CubeMap();
|
||||||
~CubeMap();
|
~CubeMap();
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,25 @@
|
||||||
#include "physics_2d_server.h"
|
#include "physics_2d_server.h"
|
||||||
#include "spatial_sound_server.h"
|
#include "spatial_sound_server.h"
|
||||||
#include "spatial_sound_2d_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() {
|
void register_server_types() {
|
||||||
|
|
||||||
|
@ -63,6 +82,7 @@ void register_server_types() {
|
||||||
ObjectTypeDB::register_virtual_type<PhysicsDirectSpaceState>();
|
ObjectTypeDB::register_virtual_type<PhysicsDirectSpaceState>();
|
||||||
ObjectTypeDB::register_virtual_type<PhysicsShapeQueryResult>();
|
ObjectTypeDB::register_virtual_type<PhysicsShapeQueryResult>();
|
||||||
|
|
||||||
|
ScriptDebuggerRemote::resource_usage_func=_debugger_get_resource_usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregister_server_types(){
|
void unregister_server_types(){
|
||||||
|
|
|
@ -190,9 +190,12 @@ public:
|
||||||
virtual bool texture_has_alpha(RID p_texture) const=0;
|
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_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_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 */
|
/* SHADER API */
|
||||||
|
|
||||||
virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL)=0;
|
virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL)=0;
|
||||||
|
|
|
@ -415,6 +415,10 @@ public:
|
||||||
virtual void texture_set_size_override(RID p_texture,int p_width, int p_height);
|
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_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 */
|
/* SHADER API */
|
||||||
|
|
||||||
virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL);
|
virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL);
|
||||||
|
|
|
@ -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);
|
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 */
|
/* SHADER API */
|
||||||
|
|
||||||
RID VisualServerRaster::shader_create(ShaderMode p_mode) {
|
RID VisualServerRaster::shader_create(ShaderMode p_mode) {
|
||||||
|
|
|
@ -668,6 +668,11 @@ public:
|
||||||
virtual bool texture_can_stream(RID p_texture) const;
|
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_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 */
|
/* SHADER API */
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,15 @@ public:
|
||||||
FUNC1RC(bool,texture_can_stream,RID);
|
FUNC1RC(bool,texture_can_stream,RID);
|
||||||
FUNC3C(texture_set_reload_hook,RID,ObjectID,const StringName&);
|
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 */
|
/* SHADER API */
|
||||||
|
|
||||||
FUNC1R(RID,shader_create,ShaderMode);
|
FUNC1R(RID,shader_create,ShaderMode);
|
||||||
|
|
|
@ -135,6 +135,18 @@ public:
|
||||||
virtual bool texture_can_stream(RID p_texture) const=0;
|
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_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 */
|
/* SHADER API */
|
||||||
|
|
|
@ -169,6 +169,17 @@ void ScriptEditorDebugger::_scene_tree_request() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEditorDebugger::_video_mem_request() {
|
||||||
|
|
||||||
|
ERR_FAIL_COND(connection.is_null());
|
||||||
|
ERR_FAIL_COND(!connection->is_connected());
|
||||||
|
|
||||||
|
Array msg;
|
||||||
|
msg.push_back("request_video_mem");
|
||||||
|
ppeer->put_var(msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Size2 ScriptEditorDebugger::get_minimum_size() const {
|
Size2 ScriptEditorDebugger::get_minimum_size() const {
|
||||||
|
|
||||||
Size2 ms = Control::get_minimum_size();
|
Size2 ms = Control::get_minimum_size();
|
||||||
|
@ -244,6 +255,31 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
|
||||||
le_clear->set_disabled(false);
|
le_clear->set_disabled(false);
|
||||||
le_set->set_disabled(false);
|
le_set->set_disabled(false);
|
||||||
|
|
||||||
|
} else if (p_msg=="message:video_mem") {
|
||||||
|
|
||||||
|
vmem_tree->clear();
|
||||||
|
TreeItem* root=vmem_tree->create_item();
|
||||||
|
|
||||||
|
int total=0;
|
||||||
|
|
||||||
|
for(int i=0;i<p_data.size();i+=4) {
|
||||||
|
|
||||||
|
TreeItem *it = vmem_tree->create_item(root);
|
||||||
|
String type=p_data[i+1];
|
||||||
|
int bytes=p_data[i+3].operator int();
|
||||||
|
it->set_text(0,p_data[i+0]); //path
|
||||||
|
it->set_text(1,type); //type
|
||||||
|
it->set_text(2,p_data[i+2]); //type
|
||||||
|
it->set_text(3,String::humanize_size(bytes)); //type
|
||||||
|
total+=bytes;
|
||||||
|
|
||||||
|
if (has_icon(type,"EditorIcons"))
|
||||||
|
it->set_icon(0,get_icon(type,"EditorIcons"));
|
||||||
|
}
|
||||||
|
|
||||||
|
vmem_total->set_tooltip("Bytes: "+itos(total));
|
||||||
|
vmem_total->set_text(String::humanize_size(total));
|
||||||
|
|
||||||
} else if (p_msg=="stack_dump") {
|
} else if (p_msg=="stack_dump") {
|
||||||
|
|
||||||
stack_dump->clear();
|
stack_dump->clear();
|
||||||
|
@ -506,6 +542,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
||||||
le_clear->connect("pressed",this,"_live_edit_clear");
|
le_clear->connect("pressed",this,"_live_edit_clear");
|
||||||
error_list->connect("item_selected",this,"_error_selected");
|
error_list->connect("item_selected",this,"_error_selected");
|
||||||
error_stack->connect("item_selected",this,"_error_stack_selected");
|
error_stack->connect("item_selected",this,"_error_stack_selected");
|
||||||
|
vmem_refresh->set_icon( get_icon("Reload","EditorIcons"));
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
|
@ -1136,6 +1173,7 @@ void ScriptEditorDebugger::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("_performance_draw"),&ScriptEditorDebugger::_performance_draw);
|
ObjectTypeDB::bind_method(_MD("_performance_draw"),&ScriptEditorDebugger::_performance_draw);
|
||||||
ObjectTypeDB::bind_method(_MD("_performance_select"),&ScriptEditorDebugger::_performance_select);
|
ObjectTypeDB::bind_method(_MD("_performance_select"),&ScriptEditorDebugger::_performance_select);
|
||||||
ObjectTypeDB::bind_method(_MD("_scene_tree_request"),&ScriptEditorDebugger::_scene_tree_request);
|
ObjectTypeDB::bind_method(_MD("_scene_tree_request"),&ScriptEditorDebugger::_scene_tree_request);
|
||||||
|
ObjectTypeDB::bind_method(_MD("_video_mem_request"),&ScriptEditorDebugger::_video_mem_request);
|
||||||
ObjectTypeDB::bind_method(_MD("_live_edit_set"),&ScriptEditorDebugger::_live_edit_set);
|
ObjectTypeDB::bind_method(_MD("_live_edit_set"),&ScriptEditorDebugger::_live_edit_set);
|
||||||
ObjectTypeDB::bind_method(_MD("_live_edit_clear"),&ScriptEditorDebugger::_live_edit_clear);
|
ObjectTypeDB::bind_method(_MD("_live_edit_clear"),&ScriptEditorDebugger::_live_edit_clear);
|
||||||
|
|
||||||
|
@ -1327,9 +1365,15 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
|
||||||
Label *vmlb = memnew(Label("List of Video Memory Usage by Resource: ") );
|
Label *vmlb = memnew(Label("List of Video Memory Usage by Resource: ") );
|
||||||
vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
|
vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
vmem_hb->add_child( vmlb );
|
vmem_hb->add_child( vmlb );
|
||||||
|
vmem_hb->add_child( memnew(Label("Total: ")) );
|
||||||
|
vmem_total = memnew( LineEdit );
|
||||||
|
vmem_total->set_editable(false);
|
||||||
|
vmem_total->set_custom_minimum_size(Size2(100,1));
|
||||||
|
vmem_hb->add_child(vmem_total);
|
||||||
vmem_refresh = memnew( Button );
|
vmem_refresh = memnew( Button );
|
||||||
vmem_hb->add_child(vmem_refresh);
|
vmem_hb->add_child(vmem_refresh);
|
||||||
vmem_vb->add_child(vmem_hb);
|
vmem_vb->add_child(vmem_hb);
|
||||||
|
vmem_refresh->connect("pressed",this,"_video_mem_request");
|
||||||
|
|
||||||
MarginContainer *vmmc = memnew( MarginContainer );
|
MarginContainer *vmmc = memnew( MarginContainer );
|
||||||
vmmc = memnew( MarginContainer );
|
vmmc = memnew( MarginContainer );
|
||||||
|
@ -1341,16 +1385,20 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
|
||||||
vmem_vb->add_child(vmmc);
|
vmem_vb->add_child(vmmc);
|
||||||
|
|
||||||
vmem_vb->set_name("Video Mem");
|
vmem_vb->set_name("Video Mem");
|
||||||
vmem_tree->set_columns(3);
|
vmem_tree->set_columns(4);
|
||||||
vmem_tree->set_column_titles_visible(true);
|
vmem_tree->set_column_titles_visible(true);
|
||||||
vmem_tree->set_column_title(0,"Resource Path");
|
vmem_tree->set_column_title(0,"Resource Path");
|
||||||
vmem_tree->set_column_expand(0,true);
|
vmem_tree->set_column_expand(0,true);
|
||||||
vmem_tree->set_column_expand(1,false);
|
vmem_tree->set_column_expand(1,false);
|
||||||
vmem_tree->set_column_title(1,"Type");
|
vmem_tree->set_column_title(1,"Type");
|
||||||
vmem_tree->set_column_min_width(1,150);
|
vmem_tree->set_column_min_width(1,100);
|
||||||
vmem_tree->set_column_expand(2,false);
|
vmem_tree->set_column_expand(2,false);
|
||||||
vmem_tree->set_column_title(2,"Usage");
|
vmem_tree->set_column_title(2,"Format");
|
||||||
vmem_tree->set_column_min_width(2,150);
|
vmem_tree->set_column_min_width(2,150);
|
||||||
|
vmem_tree->set_column_expand(3,false);
|
||||||
|
vmem_tree->set_column_title(3,"Usage");
|
||||||
|
vmem_tree->set_column_min_width(3,80);
|
||||||
|
vmem_tree->set_hide_root(true);
|
||||||
|
|
||||||
tabs->add_child(vmem_vb);
|
tabs->add_child(vmem_vb);
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ class ScriptEditorDebugger : public Control {
|
||||||
|
|
||||||
Tree *vmem_tree;
|
Tree *vmem_tree;
|
||||||
Button *vmem_refresh;
|
Button *vmem_refresh;
|
||||||
|
LineEdit *vmem_total;
|
||||||
|
|
||||||
Tree *stack_dump;
|
Tree *stack_dump;
|
||||||
PropertyEditor *inspector;
|
PropertyEditor *inspector;
|
||||||
|
@ -130,6 +131,7 @@ class ScriptEditorDebugger : public Control {
|
||||||
void _scene_tree_request();
|
void _scene_tree_request();
|
||||||
void _parse_message(const String& p_msg,const Array& p_data);
|
void _parse_message(const String& p_msg,const Array& p_data);
|
||||||
|
|
||||||
|
void _video_mem_request();
|
||||||
|
|
||||||
int _get_node_path_cache(const NodePath& p_path);
|
int _get_node_path_cache(const NodePath& p_path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue