mesa: Branch 'glsl-compiler-1' - 2 commits

Brian Paul brianp at kemper.freedesktop.org
Tue Feb 27 01:35:51 UTC 2007


 src/mesa/main/mtypes.h             |    3 ++-
 src/mesa/shader/shader_api.c       |   14 ++++++++------
 src/mesa/shader/slang/slang_emit.c |   27 ++++++++++++++++-----------
 3 files changed, 26 insertions(+), 18 deletions(-)

New commits:
diff-tree 2cf8d24131edec78778d7b6ce49ead9157c2b266 (from fa4d0364246d24b3f86bc9a8486a9ad7db60f1b3)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Feb 26 18:35:34 2007 -0700

    remove unused DriverMgrCtx

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 26b5c91..0a25666 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2887,7 +2887,6 @@ struct __GLcontextRec
    struct dd_function_table Driver;
 
    void *DriverCtx;	/**< Points to device driver context/state */
-   void *DriverMgrCtx;	/**< Points to device driver manager (optional)*/
 
    /** Core/Driver constants */
    struct gl_constants Const;
diff-tree fa4d0364246d24b3f86bc9a8486a9ad7db60f1b3 (from 4f26a52908d14b753199a529fd4c24da608ead29)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Feb 26 18:33:50 2007 -0700

    Add EmitHighLevelInstructions, EmitComments booleans to gl_shader_state.
    
    These control code generation options.  May be overridden by drivers, debuggers, etc.

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bd9198e..26b5c91 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2104,6 +2104,8 @@ struct gl_shader_program
 struct gl_shader_state
 {
    struct gl_shader_program *CurrentProgram; /**< The user-bound program */
+   GLboolean EmitHighLevelInstructions; /**< Driver-selectable */
+   GLboolean EmitComments;              /**< Driver-selectable */
 };
 
 
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 70ceb70..48ba8b6 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -196,16 +196,20 @@ _mesa_lookup_shader(GLcontext *ctx, GLui
 }
 
 
+/**
+ * Initialize context's shader state.
+ */
 void
 _mesa_init_shader_state(GLcontext * ctx)
 {
-   /* no-op */
+   /* Device drivers may override these to control what kind of instructions
+    * are generated by the GLSL compiler.
+    */
+   ctx->Shader.EmitHighLevelInstructions = GL_TRUE;
+   ctx->Shader.EmitComments = GL_FALSE;
 }
 
 
-
-
-
 /**
  * Copy string from <src> to <dst>, up to maxLength characters, returning
  * length of <dst> in <length>.
@@ -227,8 +231,6 @@ copy_string(GLchar *dst, GLsizei maxLeng
 }
 
 
-
-
 /**
  * Called via ctx->Driver.AttachShader()
  */
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index b0776e9..9ead896 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -52,8 +52,6 @@
 
 
 /* XXX temporarily here */
-static GLboolean EmitHighLevelInstructions = GL_TRUE;
-static GLboolean EmitComments = GL_FALSE;
 
 
 typedef struct
@@ -61,6 +59,9 @@ typedef struct
    slang_info_log *log;
    slang_var_table *vt;
    struct gl_program *prog;
+   /* code-gen options */
+   GLboolean EmitHighLevelInstructions;
+   GLboolean EmitComments;
 } slang_emit_info;
 
 
@@ -1111,7 +1112,7 @@ emit_if(slang_emit_info *emitInfo, slang
 
    emit(emitInfo, n->Children[0]);  /* the condition */
    ifInstLoc = prog->NumInstructions;
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       ifInst = new_instruction(emitInfo, OPCODE_IF);
       ifInst->DstReg.CondMask = COND_NE;  /* if cond is non-zero */
       ifInst->DstReg.CondSwizzle = SWIZZLE_X;
@@ -1130,7 +1131,7 @@ emit_if(slang_emit_info *emitInfo, slang
    if (n->Children[2]) {
       /* have else body */
       elseInstLoc = prog->NumInstructions;
-      if (EmitHighLevelInstructions) {
+      if (emitInfo->EmitHighLevelInstructions) {
          (void) new_instruction(emitInfo, OPCODE_ELSE);
       }
       else {
@@ -1151,7 +1152,7 @@ emit_if(slang_emit_info *emitInfo, slang
       ifInst->BranchTarget = prog->NumInstructions + 1;
    }
 
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       (void) new_instruction(emitInfo, OPCODE_ENDIF);
    }
 
@@ -1174,7 +1175,7 @@ emit_loop(slang_emit_info *emitInfo, sla
 
    /* emit OPCODE_BGNLOOP */
    beginInstLoc = prog->NumInstructions;
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       (void) new_instruction(emitInfo, OPCODE_BGNLOOP);
    }
 
@@ -1182,7 +1183,7 @@ emit_loop(slang_emit_info *emitInfo, sla
    emit(emitInfo, n->Children[0]);
 
    endInstLoc = prog->NumInstructions;
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       /* emit OPCODE_ENDLOOP */
       endInst = new_instruction(emitInfo, OPCODE_ENDLOOP);
    }
@@ -1194,7 +1195,7 @@ emit_loop(slang_emit_info *emitInfo, sla
    /* end instruction's BranchTarget points to top of loop */
    endInst->BranchTarget = beginInstLoc;
 
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       /* BGNLOOP's BranchTarget points to the ENDLOOP inst */
       beginInst = prog->Instructions + beginInstLoc;
       beginInst->BranchTarget = prog->NumInstructions - 1;
@@ -1239,7 +1240,7 @@ emit_cont_break(slang_emit_info *emitInf
    gl_inst_opcode opcode;
    struct prog_instruction *inst;
    n->InstLocation = emitInfo->prog->NumInstructions;
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       opcode = (n->Opcode == IR_CONT) ? OPCODE_CONT : OPCODE_BRK;
    }
    else {
@@ -1268,7 +1269,7 @@ emit_cont_break_if(slang_emit_info *emit
    inst->CondUpdate = GL_TRUE;
 
    n->InstLocation = emitInfo->prog->NumInstructions;
-   if (EmitHighLevelInstructions) {
+   if (emitInfo->EmitHighLevelInstructions) {
       if (n->Opcode == IR_CONT_IF_TRUE ||
           n->Opcode == IR_CONT_IF_FALSE)
          opcode = OPCODE_CONT;
@@ -1440,7 +1441,7 @@ emit(slang_emit_info *emitInfo, slang_ir
          */
          assert(n->Var->aux == n->Store);
       }
-      if (EmitComments) {
+      if (emitInfo->EmitComments) {
          /* emit NOP with comment describing the variable's storage location */
          char s[1000];
          sprintf(s, "TEMP[%d]%s = %s (size %d)",
@@ -1599,6 +1600,7 @@ _slang_emit_code(slang_ir_node *n, slang
                  struct gl_program *prog, GLboolean withEnd,
                  slang_info_log *log)
 {
+   GET_CURRENT_CONTEXT(ctx);
    GLboolean success;
    slang_emit_info emitInfo;
 
@@ -1606,6 +1608,9 @@ _slang_emit_code(slang_ir_node *n, slang
    emitInfo.vt = vt;
    emitInfo.prog = prog;
 
+   emitInfo.EmitHighLevelInstructions = ctx->Shader.EmitHighLevelInstructions;
+   emitInfo.EmitComments = ctx->Shader.EmitComments;
+
    (void) emit(&emitInfo, n);
 
    /* finish up by adding the END opcode to program */



More information about the mesa-commit mailing list