X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=flavors%2Fgl%2Fsource%2Finspector.cpp;h=5db0d3d4b1b6971532c8e1528ab06cd31bdb2a3d;hb=HEAD;hp=f7d90f846802c72f97e63b1b6198d53127b70fd9;hpb=90368e53a94c6fa68cb678a1a03a9da7bf0c7dd8;p=gldbg.git diff --git a/flavors/gl/source/inspector.cpp b/flavors/gl/source/inspector.cpp index f7d90f8..5db0d3d 100644 --- a/flavors/gl/source/inspector.cpp +++ b/flavors/gl/source/inspector.cpp @@ -1,21 +1,28 @@ #include #include #include +#include "breakpoint.h" #include "enums.h" +#include "functions.h" #include "gldbg.h" #include "inspector.h" #include "strformat.h" using namespace std; -Inspector::Inspector(GlDbg &dbg) +Inspector::Inspector(GlDbg &d): + gldbg(d), + decoder(gldecoder_new(this, NULL)), + query_state(0) { - CommandInterpreter &cmd_interp = dbg.get_command_interpreter(); + CommandInterpreter &cmd_interp = gldbg.get_command_interpreter(); cmd_interp.register_command("state", this, &Inspector::cmd_state) .set_help("Inspects general GL state", "state vertex\n" " Print current vertex attributes\n\n" + "state array\n" + " Show current vertex arrays\n\n" "state bind\n" " Show current bindings\n"); @@ -46,13 +53,46 @@ Inspector::Inspector(GlDbg &dbg) " List program objects\n\n" "program ID\n" " Print information about a program object\n"); + + decoder->gldBreak = gldBreak; +} + +Inspector::~Inspector() +{ + gldecoder_delete(decoder); } void Inspector::decode(const char *data, unsigned len) { + if(query_state) + gldecoder_decode(decoder, data, len); state.decode(data, len); } +void Inspector::process_started() +{ + gldbg.set_breakpoint(FUNC_GLXMAKECURRENT, BREAK_RETURN, this); + query_state = 1; +} + +void Inspector::process_stopped(int reason) +{ + if((reason>>8)==3 && query_state==2) + { + GlPacket *pkt = packet_begin(FUNC_GLDQUERYLIMITS); + gldbg.send(pkt); + query_state = 0; + gldbg.clear_breakpoint(FUNC_GLXMAKECURRENT, BREAK_RETURN, this); + gldbg.resume_from_break(this); + } +} + +void Inspector::gldBreak(void *user_data, unsigned short func, unsigned char flag) +{ + if(func==FUNC_GLXMAKECURRENT && flag==BREAK_RETURN) + ++reinterpret_cast(user_data)->query_state; +} + void Inspector::print_indented(const string &str, unsigned indent) { string spaces(indent, ' '); @@ -77,7 +117,8 @@ void Inspector::cmd_state(const string &args) printf("Current vertex attributes:\n"); const Vector4 &color = glstate.get_color(); printf(" Color: [%05.3f, %05.3f, %05.3f, %05.3f]\n", color.r, color.g, color.b, color.a); - for(unsigned i=0; i<8; ++i) + unsigned count = glstate.get_max_texture_units(); + for(unsigned i=0; i=10 ? " " : " "), descr.c_str()); + } + } else if(args=="bind") { printf("Current bindings:\n"); - for(unsigned i=0; i<8; ++i) + unsigned count = glstate.get_max_texture_units(); + for(unsigned i=0; iid : 0)); buf = glstate.get_current_buffer(GL_UNIFORM_BUFFER); printf(" GL_UNIFORM_BUFFER: %d\n", (buf ? buf->id : 0)); - for(unsigned i=0; i<64; ++i) + count = glstate.get_max_uniform_buffer_bindings(); + for(unsigned i=0; i &textures = state.get_textures(); - printf("%d texture objects:\n", textures.size()); + printf("%lu texture objects:\n", textures.size()); for(map::const_iterator i = textures.begin(); i!=textures.end(); ++i) { const TextureState &tex = i->second; string descr = tex.describe(); - printf(" %d: %s, %d images\n", i->first, descr.c_str(), tex.images.size()); + printf(" %d: %s, %lu images\n", i->first, descr.c_str(), tex.images.size()); } } else @@ -139,15 +208,33 @@ void Inspector::cmd_texture(const string &args) printf("Texture object %d\n", id); printf(" Target: %s\n", describe_enum(tex.target, "TextureTarget")); printf(" Images:\n"); - for(unsigned i=0; isecond.describe(); @@ -302,7 +389,7 @@ void Inspector::cmd_shader(const string &args) if(args.empty()) { const GlState::ShaderMap &shaders = state.get_shaders(); - printf("%d shader objects:\n", shaders.size()); + printf("%lu shader objects:\n", shaders.size()); for(GlState::ShaderMap::const_iterator i=shaders.begin(); i!=shaders.end(); ++i) { string descr = i->second.describe(); @@ -345,7 +432,7 @@ void Inspector::cmd_program(const std::string &args) if(args.empty()) { const GlState::ProgramMap &programs = state.get_programs(); - printf("%d program objects:\n", programs.size()); + printf("%lu program objects:\n", programs.size()); for(GlState::ProgramMap::const_iterator i=programs.begin(); i!=programs.end(); ++i) { string descr = i->second.describe();