nvsFunc *func;
/* State of the final program */
+ GLboolean error;
GLboolean translated;
GLboolean on_hardware;
unsigned int *program;
return reg;
}
+#define nvsProgramError(nvs,fmt,args...) do { \
+ fprintf(stderr, "nvsProgramError (%s): "fmt, __func__, ##args); \
+ (nvs)->error = GL_TRUE; \
+ (nvs)->translated = GL_FALSE; \
+} while(0)
+
extern GLboolean nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs);
extern void nvsDisasmHWShader(nvsPtr);
extern void nvsDumpFragmentList(nvsFragmentHeader *f, int lvl);
}
}
-static void
+static GLboolean
pass0_resolve_mesa_consts(nouveauShader *nvs)
{
struct pass0_rec *rec = nvs->pass_rec;
for (i=0; i<plist->NumParameters; i++) {
int hw = rec->mesa_const_base + i;
+ if (hw > NVS_MAX_CONSTS) {
+ nvsProgramError(nvs, "hw = %d > NVS_MAX_CONSTS!\n", hw);
+ return GL_FALSE;
+ }
+
switch (plist->Parameters[i].Type) {
case PROGRAM_NAMED_PARAM:
case PROGRAM_STATE_VAR:
COPY_4V(nvs->params[hw].val, plist->ParameterValues[i]);
break;
default:
- assert(0);
- break;
+ nvsProgramError(nvs, "hit bad type=%d on param %d\n",
+ plist->Parameters[i].Type, i);
+ return GL_FALSE;
}
}
+
+ return GL_TRUE;
}
GLboolean
NVSDBG("start: nvs=%p\n", nvs);
+ /* Previously detected an error, and haven't recieved new program
+ * string, so fail immediately.
+ */
+ if (nvs->error) {
+ NVSDBG("failed previous compile attempt, not retrying\n");
+ return GL_FALSE;
+ }
+
rec = CALLOC_STRUCT(pass0_rec);
if (!rec)
return GL_FALSE;
ret = pass0_translate_instructions(nvs, 0, 0, nvs->program_tree);
if (ret)
- pass0_resolve_mesa_consts(nvs);
+ ret = pass0_resolve_mesa_consts(nvs);
+
/*XXX: if (!ret) DESTROY TREE!!! */
FREE(rec);