X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=flavors%2Fgl%2Fsource%2Finspector.cpp;h=122c2e45298f340ddfe935a2f5e29375dcde480c;hb=d72ef6d75a11f6cc05ab8ec039520719e1044741;hp=f7d90f846802c72f97e63b1b6198d53127b70fd9;hpb=cbf00fed7d2ab4d3a6593a1f230d17f21bc61818;p=gldbg.git diff --git a/flavors/gl/source/inspector.cpp b/flavors/gl/source/inspector.cpp index f7d90f8..122c2e4 100644 --- a/flavors/gl/source/inspector.cpp +++ b/flavors/gl/source/inspector.cpp @@ -1,16 +1,21 @@ #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", @@ -46,13 +51,40 @@ Inspector::Inspector(GlDbg &dbg) " List program objects\n\n" "program ID\n" " Print information about a program object\n"); + + decoder->gldBreak = gldBreak; } 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.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 +109,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; 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