This is similar to what r300 does inside the driver, but I've added it as a generic option since it seems most hardware will want it. Fixes piglit nv-init-zero-reg.vpfp and nv-init-zero-addr.vpfp.tags/mesa_7_6_rc1
| @@ -125,6 +125,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, | |||
| /* We want the GLSL compiler to emit code that uses condition codes */ | |||
| ctx->Shader.EmitCondCodes = GL_TRUE; | |||
| ctx->Shader.EmitNVTempInitialization = GL_TRUE; | |||
| ctx->Const.VertexProgram.MaxNativeInstructions = (16 * 1024); | |||
| ctx->Const.VertexProgram.MaxAluInstructions = 0; | |||
| @@ -2079,6 +2079,7 @@ struct gl_shader_state | |||
| GLboolean EmitContReturn; /**< Emit CONT/RET opcodes? */ | |||
| GLboolean EmitCondCodes; /**< Use condition codes? */ | |||
| GLboolean EmitComments; /**< Annotated instructions */ | |||
| GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ | |||
| void *MemPool; | |||
| GLbitfield Flags; /**< Mask of GLSL_x flags */ | |||
| struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ | |||
| @@ -509,7 +509,51 @@ _mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer) | |||
| *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr; | |||
| } | |||
| void | |||
| _mesa_emit_nv_temp_initialization(GLcontext *ctx, | |||
| struct gl_program *program) | |||
| { | |||
| struct prog_instruction *inst; | |||
| int i; | |||
| if (!ctx->Shader.EmitNVTempInitialization) | |||
| return; | |||
| /* We'll swizzle up a zero temporary so we can use it for the | |||
| * ARL. | |||
| */ | |||
| if (program->NumTemporaries == 0) | |||
| program->NumTemporaries = 1; | |||
| _mesa_insert_instructions(program, 0, program->NumTemporaries + 1); | |||
| for (i = 0; i < program->NumTemporaries; i++) { | |||
| struct prog_instruction *inst = &program->Instructions[i]; | |||
| inst->Opcode = OPCODE_SWZ; | |||
| inst->DstReg.File = PROGRAM_TEMPORARY; | |||
| inst->DstReg.Index = i; | |||
| inst->DstReg.WriteMask = WRITEMASK_XYZW; | |||
| inst->SrcReg[0].File = PROGRAM_TEMPORARY; | |||
| inst->SrcReg[0].Index = 0; | |||
| inst->SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_ZERO, | |||
| SWIZZLE_ZERO, | |||
| SWIZZLE_ZERO, | |||
| SWIZZLE_ZERO); | |||
| } | |||
| inst = &program->Instructions[i]; | |||
| inst->Opcode = OPCODE_ARL; | |||
| inst->DstReg.File = PROGRAM_ADDRESS; | |||
| inst->DstReg.Index = 0; | |||
| inst->DstReg.WriteMask = WRITEMASK_XYZW; | |||
| inst->SrcReg[0].File = PROGRAM_TEMPORARY; | |||
| inst->SrcReg[0].Index = 0; | |||
| inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; | |||
| if (program->NumAddressRegs == 0) | |||
| program->NumAddressRegs = 1; | |||
| } | |||
| void | |||
| _mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program) | |||
| @@ -106,4 +106,8 @@ _mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, | |||
| extern void | |||
| _mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program); | |||
| extern void | |||
| _mesa_emit_nv_temp_initialization(GLcontext *ctx, | |||
| struct gl_program *program); | |||
| #endif | |||
| @@ -1423,6 +1423,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, | |||
| program->Base.NumParameters = program->Base.Parameters->NumParameters; | |||
| _mesa_setup_nv_temporary_count(ctx, &program->Base); | |||
| _mesa_emit_nv_temp_initialization(ctx, &program->Base); | |||
| } | |||
| else { | |||
| /* Error! */ | |||