/* XXX temporarily here */
-static GLboolean EmitHighLevelInstructions = GL_TRUE;
-static GLboolean EmitComments = GL_FALSE;
typedef struct
slang_info_log *log;
slang_var_table *vt;
struct gl_program *prog;
+ /* code-gen options */
+ GLboolean EmitHighLevelInstructions;
+ GLboolean EmitComments;
} slang_emit_info;
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;
if (n->Children[2]) {
/* have else body */
elseInstLoc = prog->NumInstructions;
- if (EmitHighLevelInstructions) {
+ if (emitInfo->EmitHighLevelInstructions) {
(void) new_instruction(emitInfo, OPCODE_ELSE);
}
else {
ifInst->BranchTarget = prog->NumInstructions + 1;
}
- if (EmitHighLevelInstructions) {
+ if (emitInfo->EmitHighLevelInstructions) {
(void) new_instruction(emitInfo, OPCODE_ENDIF);
}
/* emit OPCODE_BGNLOOP */
beginInstLoc = prog->NumInstructions;
- if (EmitHighLevelInstructions) {
+ if (emitInfo->EmitHighLevelInstructions) {
(void) new_instruction(emitInfo, OPCODE_BGNLOOP);
}
emit(emitInfo, n->Children[0]);
endInstLoc = prog->NumInstructions;
- if (EmitHighLevelInstructions) {
+ if (emitInfo->EmitHighLevelInstructions) {
/* emit OPCODE_ENDLOOP */
endInst = new_instruction(emitInfo, OPCODE_ENDLOOP);
}
/* 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;
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 {
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;
*/
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)",
struct gl_program *prog, GLboolean withEnd,
slang_info_log *log)
{
+ GET_CURRENT_CONTEXT(ctx);
GLboolean success;
slang_emit_info emitInfo;
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 */