r300: Added _mesa_copy_instructions.
authorOliver McFadden <z3ro.geek@gmail.com>
Thu, 15 Mar 2007 20:55:30 +0000 (20:55 +0000)
committerOliver McFadden <z3ro.geek@gmail.com>
Thu, 15 Mar 2007 20:55:30 +0000 (20:55 +0000)
src/mesa/drivers/dri/r300/r300_fragprog.c
src/mesa/drivers/dri/r300/r300_vertprog.c
src/mesa/shader/program.c
src/mesa/shader/program.h

index e05abdb7c6108836d7201de3ebe62ab34f9a87e7..251fd2608213161191ef6292c13219dd73c5c95f 100644 (file)
@@ -1853,7 +1853,7 @@ static void insert_wpos(struct gl_program *prog)
        fpi[i].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
        i++;
 
-       _mesa_memcpy(&fpi[i], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
+       _mesa_copy_instructions (&fpi[i], prog->Instructions, prog->NumInstructions);
 
        free(prog->Instructions);
 
index 0c43270d757eff3acff36e0ad985d71d578192c1..092ebb1140e31532885e6a79a9bd35765741c6f2 100644 (file)
@@ -946,7 +946,7 @@ static void position_invariant(struct gl_program *prog)
 #endif                                 
        }
 
-       _mesa_memcpy(&vpi[i], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
+       _mesa_copy_instructions (&vpi[i], prog->Instructions, prog->NumInstructions);
 
        free(prog->Instructions);
 
@@ -969,10 +969,11 @@ static void insert_wpos(struct r300_vertex_program *vp,
        vpi = _mesa_alloc_instructions (prog->NumInstructions + 2);
        _mesa_init_instructions (vpi, prog->NumInstructions + 2);
        /* all but END */
-       _mesa_memcpy(vpi, prog->Instructions, (prog->NumInstructions - 1) * sizeof(struct prog_instruction));
+       _mesa_copy_instructions (vpi, prog->Instructions, prog->NumInstructions - 1);
        /* END */
-       _mesa_memcpy(&vpi[prog->NumInstructions + 1], &prog->Instructions[prog->NumInstructions - 1],
-               sizeof(struct prog_instruction));
+       _mesa_copy_instructions (&vpi[prog->NumInstructions + 1],
+                                &prog->Instructions[prog->NumInstructions - 1],
+                                1);
        vpi_insert = &vpi[prog->NumInstructions - 1];
 
        vpi_insert[i].Opcode = OPCODE_MOV;
index 490f9194457f35198a48e761aea6c2000bac6abb..3d5f648191a6133e99cc63af0b888342898aac58 100644 (file)
@@ -1480,6 +1480,20 @@ _mesa_realloc_instructions(struct prog_instruction *oldInst,
    return newInst;
 }
 
+/**
+ * Copy an narray of program instructions.
+ * \param dest  pointer to destination.
+ * \param src  pointer to source.
+ * \param n  number of instructions to copy.
+ * \return pointer to destination.
+ */
+struct prog_instruction *
+_mesa_copy_instructions(struct prog_instruction *dest,
+                        const struct prog_instruction *src, GLuint n)
+{
+  return _mesa_memcpy (dest, src, n * sizeof (struct prog_instruction));
+}
+
 
 /**
  * Basic info about each instruction
index 5b5d134f6dae6fb3178afb2cedeb81f2a40c6474..6f5013df358d740495ab037c344a0226c21cec3f 100644 (file)
@@ -128,6 +128,9 @@ extern struct prog_instruction *
 _mesa_realloc_instructions(struct prog_instruction *oldInst,
                            GLuint numOldInst, GLuint numNewInst);
 
+extern struct prog_instruction *
+_mesa_copy_instructions(struct prog_instruction *dest,
+                        const struct prog_instruction *src, GLuint n);
 
 /**
  * Used for describing GL state referenced from inside ARB vertex and