X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=flavors%2Fgl%2Fsource%2Finspector.cpp;h=b641b05d0381a19a10afe4c4b853cab86a5a39a0;hb=7cc7ebcdb800bd4d88e4fccff8459003599e71d7;hp=f7d90f846802c72f97e63b1b6198d53127b70fd9;hpb=90368e53a94c6fa68cb678a1a03a9da7bf0c7dd8;p=gldbg.git diff --git a/flavors/gl/source/inspector.cpp b/flavors/gl/source/inspector.cpp index f7d90f8..b641b05 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