diff options
author | Brian Paul <[email protected]> | 2006-08-24 22:03:38 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2006-08-24 22:03:38 +0000 |
commit | 94ff996cae9951129fee1010b201b72e8453f406 (patch) | |
tree | 3433d9149e0c91e12c19a876b9ad30447b990a06 | |
parent | a75439093c044301fd54dc42b30d0ee5a475d477 (diff) |
Check for NULL program string in r200_translate_vertex_program().
Fixes bug reported by Chris Rankin.
Added some new comments.
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vertprog.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c index 203bce143b4..32d0d8eadaa 100644 --- a/src/mesa/drivers/dri/r200/r200_vertprog.c +++ b/src/mesa/drivers/dri/r200/r200_vertprog.c @@ -389,6 +389,12 @@ static unsigned long op_operands(enum prog_opcode opcode) /* DP4 version seems to trigger some hw peculiarity - fglrx does this on r200 however */ #define PREFER_DP4 + +/** + * Generate an R200 vertex program from Mesa's internal representation. + * + * \return GL_TRUE for success, GL_FALSE for failure. + */ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) { struct gl_vertex_program *mesa_vp = &vp->mesa_program; @@ -401,6 +407,9 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) vp->native = GL_FALSE; + if (!mesa_vp->Base.String) + return GL_FALSE; + if ((mesa_vp->Base.InputsRead & ~(VERT_BIT_POS | VERT_BIT_NORMAL | VERT_BIT_COLOR0 | VERT_BIT_COLOR1 | VERT_BIT_FOG | VERT_BIT_TEX0 | VERT_BIT_TEX1 | VERT_BIT_TEX2 | @@ -423,7 +432,8 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) int u_temp_i = R200_VSF_MAX_TEMPS - 1; struct prog_src_register src[3]; -/* if (getenv("R300_VP_SAFETY")) { +#if 0 + if (getenv("R300_VP_SAFETY")) { WARN_ONCE("R300_VP_SAFETY enabled.\n"); vpi = malloc((mesa_vp->Base.NumInstructions + VSF_MAX_FRAGMENT_TEMPS) * sizeof(struct prog_instruction)); @@ -454,7 +464,9 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) vpi = &mesa_vp->Base.Instructions[mesa_vp->Base.NumInstructions-1]; assert(vpi->Opcode == OPCODE_END); - }*/ + } +#endif + /* FIXME: is changing the prog safe to do here? */ if (mesa_vp->IsPositionInvariant) { struct gl_program_parameter_list *paramList; @@ -470,6 +482,7 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) vpi = malloc((mesa_vp->Base.NumInstructions + 4) * sizeof(struct prog_instruction)); memset(vpi, 0, 4 * sizeof(struct prog_instruction)); + /* emit four dot product instructions to do MVP transformation */ for (i=0; i < 4; i++) { GLint idx; tokens[3] = tokens[4] = i; @@ -524,10 +537,13 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) #endif } + /* now append original program after our new instructions */ memcpy(&vpi[i], mesa_vp->Base.Instructions, mesa_vp->Base.NumInstructions * sizeof(struct prog_instruction)); + /* deallocate original program */ free(mesa_vp->Base.Instructions); + /* install new program */ mesa_vp->Base.Instructions = vpi; mesa_vp->Base.NumInstructions += 4; |