From 214132adfee555a26b64b2dd359afa6b09e845f5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 19 Mar 2009 09:26:20 -0600 Subject: glsl: when debug pragma is on, emit comments about function calls/inlines BTW, the debug pragma syntax is "#pragma debug(on)" --- src/mesa/shader/slang/slang_codegen.c | 6 ++++++ src/mesa/shader/slang/slang_emit.c | 6 ++++++ src/mesa/shader/slang/slang_ir.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 6c8c8c18563..13a801c18a2 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -1439,6 +1439,12 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun, /*_slang_label_delete(A->curFuncEndLabel);*/ A->curFuncEndLabel = prevFuncEndLabel; + if (A->pragmas->Debug) { + char s[1000]; + snprintf(s, sizeof(s), "Call/inline %s()", (char *) fun->header.a_name); + n->Comment = _slang_strdup(s); + } + return n; } diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 94d0c084aaf..1b1edb44609 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -2194,6 +2194,12 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n) return NULL; } + if (n->Comment) { + inst = new_instruction(emitInfo, OPCODE_NOP); + inst->Comment = _mesa_strdup(n->Comment); + inst = NULL; + } + switch (n->Opcode) { case IR_SEQ: /* sequence of two sub-trees */ diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index 0ec38b10a5a..e796693ed58 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -212,6 +212,7 @@ typedef struct slang_ir_node_ struct slang_ir_node_ *List; /**< For various linked lists */ struct slang_ir_node_ *Parent; /**< Pointer to logical parent (ie. loop) */ slang_label *Label; /**< Used for branches */ + const char *Comment; /**< If Opcode == IR_COMMENT */ } slang_ir_node; -- cgit v1.2.3