summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/nvprogram.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2009-09-24 11:58:33 -0700
committerEric Anholt <[email protected]>2009-09-24 13:34:06 -0700
commit726a04a2cd1bf159a6c40584b4b2b9bc5948a82e (patch)
treec008dc09ea2e22feac5246d2301332219855828a /src/mesa/shader/nvprogram.c
parenta9a47afe7e87075432ce2d393b55409fcb7149ac (diff)
i965: Emit zero initialization for NV VP temporaries as required.
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.
Diffstat (limited to 'src/mesa/shader/nvprogram.c')
-rw-r--r--src/mesa/shader/nvprogram.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index fdb2f4210ad..471a7358a2f 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -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)