summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2007-03-20 15:52:57 +1100
committerBen Skeggs <[email protected]>2007-03-20 16:08:07 +1100
commit4185037af2d89c5b245646f5e4a7c6dc946cae43 (patch)
tree4fb27ae3b9977a68a88ec921326448850d6eb438 /src
parent9622a634f61f02ed1a23087762a2ec8a305ae77e (diff)
nouveau: fail translate if we use too many params somehow
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader.c4
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader.h7
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader_0.c25
3 files changed, 31 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.c b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
index 9cb837ff3b7..3d5b6843a15 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
@@ -96,7 +96,9 @@ nouveauProgramStringNotify(GLcontext *ctx, GLenum target,
if (nvs->translated)
FREE(nvs->program);
- nvs->translated = 0;
+
+ nvs->error = GL_FALSE;
+ nvs->translated = GL_FALSE;
_tnl_program_string(ctx, target, prog);
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.h b/src/mesa/drivers/dri/nouveau/nouveau_shader.h
index 56ae270764b..7125a2ae821 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.h
@@ -51,6 +51,7 @@ typedef struct _nouveauShader {
nvsFunc *func;
/* State of the final program */
+ GLboolean error;
GLboolean translated;
GLboolean on_hardware;
unsigned int *program;
@@ -424,6 +425,12 @@ nvsSwizzle(nvsRegister reg, nvsSwzComp x, nvsSwzComp y,
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);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
index 0308a6c3976..7c2e2b9443b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
@@ -924,7 +924,7 @@ pass0_rebase_mesa_consts(nouveauShader *nvs)
}
}
-static void
+static GLboolean
pass0_resolve_mesa_consts(nouveauShader *nvs)
{
struct pass0_rec *rec = nvs->pass_rec;
@@ -945,6 +945,11 @@ pass0_resolve_mesa_consts(nouveauShader *nvs)
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:
@@ -958,10 +963,13 @@ pass0_resolve_mesa_consts(nouveauShader *nvs)
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
@@ -976,6 +984,14 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
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;
@@ -1020,7 +1036,8 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
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);