From fc6b8f2d3012f97d5a1f0d4fbefd191268d6a263 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 15 Mar 2007 11:51:54 -0600 Subject: added SWIZZLE_XXXX, YYYY, etc. macros --- src/mesa/shader/nvvertparse.c | 8 ++++---- src/mesa/shader/program.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index ecfe8ec334..6d395c6011 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -686,13 +686,13 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *sr if (token[1] == 0) { /* single letter swizzle */ if (token[0] == 'x') - srcReg->Swizzle = MAKE_SWIZZLE4(0, 0, 0, 0); + srcReg->Swizzle = SWIZZLE_XXXX; else if (token[0] == 'y') - srcReg->Swizzle = MAKE_SWIZZLE4(1, 1, 1, 1); + srcReg->Swizzle = SWIZZLE_YYYY; else if (token[0] == 'z') - srcReg->Swizzle = MAKE_SWIZZLE4(2, 2, 2, 2); + srcReg->Swizzle = SWIZZLE_ZZZZ; else if (token[0] == 'w') - srcReg->Swizzle = MAKE_SWIZZLE4(3, 3, 3, 3); + srcReg->Swizzle = SWIZZLE_WWWW; else RETURN_ERROR1("Expected x, y, z, or w"); } diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index a0bde07762..5b5d134f6d 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -53,6 +53,13 @@ #define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) #define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) + +#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) +#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) +#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) +#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) +#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) + #define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) #define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) -- cgit v1.2.3 From 0c25d9ab198f79afee23ec1bf8ac61c4cd801d3a Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Thu, 15 Mar 2007 20:55:30 +0000 Subject: r300: Added _mesa_copy_instructions. --- src/mesa/shader/program.c | 14 ++++++++++++++ src/mesa/shader/program.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 490f919445..3d5f648191 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -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 diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 5b5d134f6d..6f5013df35 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -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 -- cgit v1.2.3 From 95764262a7f2dfda761a0dbd87c3d9b12df0d534 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Thu, 15 Mar 2007 21:57:31 +0000 Subject: Fixed a minor typo in the comment near _mesa_copy_instructions. --- src/mesa/shader/program.c | 4 ++-- src/mesa/shader/program.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 3d5f648191..98daf7062f 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -1481,14 +1481,14 @@ _mesa_realloc_instructions(struct prog_instruction *oldInst, } /** - * Copy an narray of program instructions. + * Copy an array 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, +_mesa_copy_instructions (struct prog_instruction *dest, const struct prog_instruction *src, GLuint n) { return _mesa_memcpy (dest, src, n * sizeof (struct prog_instruction)); diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 6f5013df35..7746289621 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -129,7 +129,7 @@ _mesa_realloc_instructions(struct prog_instruction *oldInst, GLuint numOldInst, GLuint numNewInst); extern struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, +_mesa_copy_instructions (struct prog_instruction *dest, const struct prog_instruction *src, GLuint n); /** -- cgit v1.2.3 From cfe984dbd0c478906785dbf8a9430504173ae952 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Sun, 18 Mar 2007 07:21:21 +0000 Subject: Use _mesa_copy_instructions rather than memcpy in _mesa_insert_mvp_code. --- src/mesa/shader/programopt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index dca44c853d..fed8e5b758 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -100,8 +100,7 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) } /* Append original instructions after new instructions */ - _mesa_memcpy(newInst + 4, vprog->Base.Instructions, - origLen * sizeof(struct prog_instruction)); + _mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen); /* free old instructions */ _mesa_free(vprog->Base.Instructions); -- cgit v1.2.3