aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNian Wu <[email protected]>2007-03-16 17:00:24 +0800
committerNian Wu <[email protected]>2007-03-16 17:00:24 +0800
commita02870f4f61a66560b3eb75f98a7fe57ebcb6ed6 (patch)
tree8f1ecfc19e60d583969fa1e34c24e86e877ef2f6
parentd63eef4b86af02aea5b26f90de9cf3d46aee398c (diff)
parent95764262a7f2dfda761a0dbd87c3d9b12df0d534 (diff)
Merge git://proxy01.pd.intel.com:9419/git/mesa/mesa into crestline
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state.c2
-rw-r--r--src/mesa/drivers/dri/r300/Makefile2
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c89
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_shader.c26
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c14
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.h1
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c (renamed from src/mesa/drivers/dri/r300/r300_vertexprog.c)91
-rw-r--r--src/mesa/main/buffers.c3
-rw-r--r--src/mesa/main/image.c37
-rw-r--r--src/mesa/shader/nvvertparse.c8
-rw-r--r--src/mesa/shader/program.c14
-rw-r--r--src/mesa/shader/program.h10
-rw-r--r--src/mesa/swrast/s_accum.c4
-rw-r--r--src/mesa/swrast/s_depth.c2
-rw-r--r--src/mesa/swrast/s_stencil.c2
17 files changed, 172 insertions, 141 deletions
diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c
index 78ae4bdb5fc..1fafadced02 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state.c
+++ b/src/mesa/drivers/dri/i915tex/i915_state.c
@@ -859,7 +859,7 @@ i915_init_packets(struct i915_context *i915)
i915->state.Ctx[I915_CTXREG_LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
I1_LOAD_S(2) |
I1_LOAD_S(4) |
- I1_LOAD_S(5) | I1_LOAD_S(6) | (4));
+ I1_LOAD_S(5) | I1_LOAD_S(6) | (3));
i915->state.Ctx[I915_CTXREG_LIS2] = 0;
i915->state.Ctx[I915_CTXREG_LIS4] = 0;
i915->state.Ctx[I915_CTXREG_LIS5] = 0;
diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile
index 2ee23289341..d4bf0ae892f 100644
--- a/src/mesa/drivers/dri/r300/Makefile
+++ b/src/mesa/drivers/dri/r300/Makefile
@@ -39,7 +39,7 @@ DRIVER_SOURCES = \
r300_texmem.c \
r300_tex.c \
r300_texstate.c \
- r300_vertexprog.c \
+ r300_vertprog.c \
r300_fragprog.c \
r300_shader.c \
r300_maos.c \
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index e4511e0c21c..a106bbc6abf 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -545,9 +545,9 @@ void r300InitCmdBuf(r300ContextPtr r300)
size = 64*256;
if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA)) {
- fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%u\n",
+ fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%zd\n",
sizeof(drm_r300_cmd_header_t));
- fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%u\n",
+ fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%zd\n",
sizeof(drm_radeon_cmd_buffer_t));
fprintf(stderr,
"Allocating %d bytes command buffer (max state is %d bytes)\n",
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index a1c634a54d0..251fd260821 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -49,6 +49,7 @@
#include "r300_context.h"
#include "r300_fragprog.h"
#include "r300_reg.h"
+#include "r300_state.h"
/*
* Usefull macros and values
@@ -1787,6 +1788,92 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
return GL_TRUE;
}
+static void insert_wpos(struct gl_program *prog)
+{
+ GLint tokens[6] = { STATE_INTERNAL, STATE_R300_WINDOW_DIMENSION, 0, 0, 0, 0 };
+ struct prog_instruction *fpi;
+ GLuint window_index;
+ int i = 0;
+ GLuint tempregi = prog->NumTemporaries;
+ /* should do something else if no temps left... */
+ prog->NumTemporaries++;
+
+ fpi = _mesa_alloc_instructions (prog->NumInstructions + 3);
+ _mesa_init_instructions (fpi, prog->NumInstructions + 3);
+
+ /* perspective divide */
+ fpi[i].Opcode = OPCODE_RCP;
+
+ fpi[i].DstReg.File = PROGRAM_TEMPORARY;
+ fpi[i].DstReg.Index = tempregi;
+ fpi[i].DstReg.WriteMask = WRITEMASK_W;
+ fpi[i].DstReg.CondMask = COND_TR;
+
+ fpi[i].SrcReg[0].File = PROGRAM_INPUT;
+ fpi[i].SrcReg[0].Index = FRAG_ATTRIB_WPOS;
+ fpi[i].SrcReg[0].Swizzle = SWIZZLE_WWWW;
+ i++;
+
+ fpi[i].Opcode = OPCODE_MUL;
+
+ fpi[i].DstReg.File = PROGRAM_TEMPORARY;
+ fpi[i].DstReg.Index = tempregi;
+ fpi[i].DstReg.WriteMask = WRITEMASK_XYZ;
+ fpi[i].DstReg.CondMask = COND_TR;
+
+ fpi[i].SrcReg[0].File = PROGRAM_INPUT;
+ fpi[i].SrcReg[0].Index = FRAG_ATTRIB_WPOS;
+ fpi[i].SrcReg[0].Swizzle = SWIZZLE_XYZW;
+
+ fpi[i].SrcReg[1].File = PROGRAM_TEMPORARY;
+ fpi[i].SrcReg[1].Index = tempregi;
+ fpi[i].SrcReg[1].Swizzle = SWIZZLE_WWWW;
+ i++;
+
+ /* viewport transformation */
+ window_index = _mesa_add_state_reference(prog->Parameters, tokens);
+
+ fpi[i].Opcode = OPCODE_MAD;
+
+ fpi[i].DstReg.File = PROGRAM_TEMPORARY;
+ fpi[i].DstReg.Index = tempregi;
+ fpi[i].DstReg.WriteMask = WRITEMASK_XYZ;
+ fpi[i].DstReg.CondMask = COND_TR;
+
+ fpi[i].SrcReg[0].File = PROGRAM_TEMPORARY;
+ fpi[i].SrcReg[0].Index = tempregi;
+ fpi[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
+
+ fpi[i].SrcReg[1].File = PROGRAM_STATE_VAR;
+ fpi[i].SrcReg[1].Index = window_index;
+ fpi[i].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
+
+ fpi[i].SrcReg[2].File = PROGRAM_STATE_VAR;
+ fpi[i].SrcReg[2].Index = window_index;
+ fpi[i].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
+ i++;
+
+ _mesa_copy_instructions (&fpi[i], prog->Instructions, prog->NumInstructions);
+
+ free(prog->Instructions);
+
+ prog->Instructions = fpi;
+
+ prog->NumInstructions += i;
+ fpi = &prog->Instructions[prog->NumInstructions-1];
+
+ assert(fpi->Opcode == OPCODE_END);
+
+ for(fpi = &prog->Instructions[3]; fpi->Opcode != OPCODE_END; fpi++){
+ for(i=0; i<3; i++)
+ if( fpi->SrcReg[i].File == PROGRAM_INPUT &&
+ fpi->SrcReg[i].Index == FRAG_ATTRIB_WPOS ){
+ fpi->SrcReg[i].File = PROGRAM_TEMPORARY;
+ fpi->SrcReg[i].Index = tempregi;
+ }
+ }
+}
+
/* - Init structures
* - Determine what hwregs each input corresponds to
*/
@@ -1844,6 +1931,7 @@ static void init_program(r300ContextPtr r300, struct r300_fragment_program *rp)
if (InputsRead & FRAG_BIT_WPOS) {
cs->inputs[FRAG_ATTRIB_WPOS].refcount = 0;
cs->inputs[FRAG_ATTRIB_WPOS].reg = get_hw_temp(rp);
+ insert_wpos(&mp->Base);
}
InputsRead &= ~FRAG_BIT_WPOS;
@@ -1956,6 +2044,7 @@ void r300_translate_fragment_shader(r300ContextPtr r300, struct r300_fragment_pr
rp->translated = GL_TRUE;
if (0) dump_program(rp);
+ r300UpdateStateParameters(rp->ctx, _NEW_PROGRAM);
}
update_params(rp);
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
index f674fea7c9e..11e2d42e494 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.c
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -389,7 +389,7 @@ void r300Flush(GLcontext * ctx)
#ifdef USER_BUFFERS
#include "radeon_mm.h"
-void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
+static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
{
struct r300_dma_buffer *dmabuf;
size = MAX2(size, RADEON_BUFFER_SIZE*16);
@@ -503,7 +503,7 @@ void r300AllocDmaRegion(r300ContextPtr rmesa,
}
#else
-void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
+static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
{
struct r300_dma_buffer *dmabuf;
int fd = rmesa->radeon.dri.fd;
diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c
index 26721e8dfda..41c07a31888 100644
--- a/src/mesa/drivers/dri/r300/r300_shader.c
+++ b/src/mesa/drivers/dri/r300/r300_shader.c
@@ -10,22 +10,8 @@
static void
r300BindProgram(GLcontext *ctx, GLenum target, struct gl_program *prog)
{
-
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- struct r300_vertex_program_cont *vp=(void *)prog;
-
-
switch(target){
case GL_VERTEX_PROGRAM_ARB:
- //rmesa->curr_vp = (struct gl_vertex_program *)vp;
- //vp->ref_count++;
-#if 0
- if((vp->ref_count % 1500) == 0) {
- fprintf(stderr, "id %p, ref_count %d\n", vp, vp->ref_count);
- _mesa_print_program(&vp->mesa_program.Base);
- }
-#endif
-
case GL_FRAGMENT_PROGRAM_ARB:
break;
default:
@@ -59,18 +45,9 @@ r300NewProgram(GLcontext *ctx, GLenum target, GLuint id)
return NULL;
}
-
static void
r300DeleteProgram(GLcontext *ctx, struct gl_program *prog)
{
-#if 0
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- struct r300_vertex_program *vp=(void *)prog;
-
- if(rmesa->curr_vp == vp)
- rmesa->curr_vp = NULL;
-#endif
-
_mesa_delete_program(ctx, prog);
}
@@ -98,9 +75,6 @@ r300ProgramStringNotify(GLcontext *ctx, GLenum target, struct gl_program *prog)
static GLboolean
r300IsProgramNative(GLcontext *ctx, GLenum target, struct gl_program *prog)
{
- //struct r300_vertex_program *vp=(void *)prog;
- //r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
return 1;
}
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 895c2ff43cc..fcb61a28316 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1066,8 +1066,8 @@ static void r300FetchStateParameter(GLcontext *ctx, const enum state_index state
switch(state[1])
{
case STATE_R300_WINDOW_DIMENSION:
- value[0] = r300->radeon.dri.drawable->w; /* width */
- value[1] = r300->radeon.dri.drawable->h; /* height */
+ value[0] = r300->radeon.dri.drawable->w*0.5f;/* width*0.5 */
+ value[1] = r300->radeon.dri.drawable->h*0.5f;/* height*0.5 */
value[2] = 0.5F; /* for moving range [-1 1] -> [0 1] */
value[3] = 1.0F; /* not used */
break;
@@ -1081,20 +1081,20 @@ static void r300FetchStateParameter(GLcontext *ctx, const enum state_index state
* Update R300's own internal state parameters.
* For now just STATE_R300_WINDOW_DIMENSION
*/
-static void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
+void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
{
- struct r300_vertex_program_cont *vpc;
+ struct r300_fragment_program *fp;
struct gl_program_parameter_list *paramList;
GLuint i;
if(!(new_state & (_NEW_BUFFERS|_NEW_PROGRAM)))
return;
- vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
- if (!vpc)
+ fp = (struct r300_fragment_program *)ctx->FragmentProgram._Current;
+ if (!fp)
return;
- paramList = vpc->mesa_program.Base.Parameters;
+ paramList = fp->mesa_program.Base.Parameters;
if (!paramList)
return;
diff --git a/src/mesa/drivers/dri/r300/r300_state.h b/src/mesa/drivers/dri/r300/r300_state.h
index f6a50655d1b..52e606f2416 100644
--- a/src/mesa/drivers/dri/r300/r300_state.h
+++ b/src/mesa/drivers/dri/r300/r300_state.h
@@ -61,6 +61,7 @@ do { \
extern void r300ResetHwState(r300ContextPtr r300);
+extern void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state);
extern void r300InitState(r300ContextPtr r300);
extern void r300InitStateFuncs(struct dd_function_table* functions);
extern void r300UpdateViewportOffset( GLcontext *ctx );
diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index 2ff92e13289..092ebb1140e 100644
--- a/src/mesa/drivers/dri/r300/r300_vertexprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -889,8 +889,8 @@ static void position_invariant(struct gl_program *prog)
#endif
paramList = prog->Parameters;
- vpi = malloc((prog->NumInstructions + 4) * sizeof(struct prog_instruction));
- memset(vpi, 0, 4 * sizeof(struct prog_instruction));
+ vpi = _mesa_alloc_instructions (prog->NumInstructions + 4);
+ _mesa_init_instructions (vpi, prog->NumInstructions + 4);
for (i=0; i < 4; i++) {
GLint idx;
@@ -908,11 +908,11 @@ static void position_invariant(struct gl_program *prog)
vpi[i].SrcReg[0].File = PROGRAM_STATE_VAR;
vpi[i].SrcReg[0].Index = idx;
- vpi[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
+ vpi[i].SrcReg[0].Swizzle = SWIZZLE_XYZW;
vpi[i].SrcReg[1].File = PROGRAM_INPUT;
vpi[i].SrcReg[1].Index = VERT_ATTRIB_POS;
- vpi[i].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
+ vpi[i].SrcReg[1].Swizzle = SWIZZLE_XYZW;
#else
if (i == 0)
vpi[i].Opcode = OPCODE_MUL;
@@ -932,7 +932,7 @@ static void position_invariant(struct gl_program *prog)
vpi[i].SrcReg[0].File = PROGRAM_STATE_VAR;
vpi[i].SrcReg[0].Index = idx;
- vpi[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
+ vpi[i].SrcReg[0].Swizzle = SWIZZLE_XYZW;
vpi[i].SrcReg[1].File = PROGRAM_INPUT;
vpi[i].SrcReg[1].Index = VERT_ATTRIB_POS;
@@ -941,12 +941,12 @@ static void position_invariant(struct gl_program *prog)
if (i > 0) {
vpi[i].SrcReg[2].File = PROGRAM_TEMPORARY;
vpi[i].SrcReg[2].Index = 0;
- vpi[i].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
+ vpi[i].SrcReg[2].Swizzle = SWIZZLE_XYZW;
}
#endif
}
- memcpy(&vpi[i], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
+ _mesa_copy_instructions (&vpi[i], prog->Instructions, prog->NumInstructions);
free(prog->Instructions);
@@ -962,22 +962,19 @@ static void insert_wpos(struct r300_vertex_program *vp,
struct gl_program *prog,
GLuint temp_index)
{
-
- GLint tokens[6] = { STATE_INTERNAL, STATE_R300_WINDOW_DIMENSION, 0, 0, 0, 0 };
struct prog_instruction *vpi;
struct prog_instruction *vpi_insert;
- GLuint window_index;
int i = 0;
- vpi = malloc((prog->NumInstructions + 5) * sizeof(struct prog_instruction));
+ vpi = _mesa_alloc_instructions (prog->NumInstructions + 2);
+ _mesa_init_instructions (vpi, prog->NumInstructions + 2);
/* all but END */
- memcpy(vpi, prog->Instructions, (prog->NumInstructions - 1) * sizeof(struct prog_instruction));
+ _mesa_copy_instructions (vpi, prog->Instructions, prog->NumInstructions - 1);
/* END */
- memcpy(&vpi[prog->NumInstructions + 4], &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];
- memset(vpi_insert, 0, 5 * sizeof(struct prog_instruction));
vpi_insert[i].Opcode = OPCODE_MOV;
@@ -988,62 +985,10 @@ static void insert_wpos(struct r300_vertex_program *vp,
vpi_insert[i].SrcReg[0].File = PROGRAM_TEMPORARY;
vpi_insert[i].SrcReg[0].Index = temp_index;
- vpi_insert[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
+ vpi_insert[i].SrcReg[0].Swizzle = SWIZZLE_XYZW;
i++;
- /* perspective divide */
- vpi_insert[i].Opcode = OPCODE_RCP;
-
- vpi_insert[i].DstReg.File = PROGRAM_TEMPORARY;
- vpi_insert[i].DstReg.Index = temp_index;
- vpi_insert[i].DstReg.WriteMask = WRITEMASK_W;
- vpi_insert[i].DstReg.CondMask = COND_TR;
-
- vpi_insert[i].SrcReg[0].File = PROGRAM_TEMPORARY;
- vpi_insert[i].SrcReg[0].Index = temp_index;
- vpi_insert[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO);
- i++;
-
- vpi_insert[i].Opcode = OPCODE_MUL;
-
- vpi_insert[i].DstReg.File = PROGRAM_TEMPORARY;
- vpi_insert[i].DstReg.Index = temp_index;
- vpi_insert[i].DstReg.WriteMask = WRITEMASK_XYZ;
- vpi_insert[i].DstReg.CondMask = COND_TR;
-
- vpi_insert[i].SrcReg[0].File = PROGRAM_TEMPORARY;
- vpi_insert[i].SrcReg[0].Index = temp_index;
- vpi_insert[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
-
- vpi_insert[i].SrcReg[1].File = PROGRAM_TEMPORARY;
- vpi_insert[i].SrcReg[1].Index = temp_index;
- vpi_insert[i].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_ZERO);
- i++;
-
- /* viewport transformation */
- window_index = _mesa_add_state_reference(prog->Parameters, tokens);
-
- vpi_insert[i].Opcode = OPCODE_MAD;
-
- vpi_insert[i].DstReg.File = PROGRAM_TEMPORARY;
- vpi_insert[i].DstReg.Index = temp_index;
- vpi_insert[i].DstReg.WriteMask = WRITEMASK_XYZ;
- vpi_insert[i].DstReg.CondMask = COND_TR;
-
- vpi_insert[i].SrcReg[0].File = PROGRAM_TEMPORARY;
- vpi_insert[i].SrcReg[0].Index = temp_index;
- vpi_insert[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
-
- vpi_insert[i].SrcReg[1].File = PROGRAM_STATE_VAR;
- vpi_insert[i].SrcReg[1].Index = window_index;
- vpi_insert[i].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_ZERO);
-
- vpi_insert[i].SrcReg[2].File = PROGRAM_STATE_VAR;
- vpi_insert[i].SrcReg[2].Index = window_index;
- vpi_insert[i].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_ZERO);
- i++;
-
- vpi_insert[i].Opcode = OPCODE_MUL;
+ vpi_insert[i].Opcode = OPCODE_MOV;
vpi_insert[i].DstReg.File = PROGRAM_OUTPUT;
vpi_insert[i].DstReg.Index = VERT_RESULT_TEX0+vp->wpos_idx;
@@ -1052,11 +997,7 @@ static void insert_wpos(struct r300_vertex_program *vp,
vpi_insert[i].SrcReg[0].File = PROGRAM_TEMPORARY;
vpi_insert[i].SrcReg[0].Index = temp_index;
- vpi_insert[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W);
-
- vpi_insert[i].SrcReg[1].File = PROGRAM_STATE_VAR;
- vpi_insert[i].SrcReg[1].Index = window_index;
- vpi_insert[i].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_ONE, SWIZZLE_ONE);
+ vpi_insert[i].SrcReg[0].Swizzle = SWIZZLE_XYZW;
i++;
free(prog->Instructions);
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 0e3ed155841..11bd173e35c 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -140,6 +140,9 @@ _mesa_Clear( GLbitfield mask )
return;
}
+ if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0)
+ return;
+
if (ctx->RenderMode == GL_RENDER) {
GLbitfield bufferMask;
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index cdcf49886ad..f53730cbcf5 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.2
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1454,9 +1454,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (dstPacking->SwapBytes) {
- _mesa_swap2( (GLushort *) dst, n * comps);
- }
}
break;
case GL_SHORT:
@@ -1530,9 +1527,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (dstPacking->SwapBytes) {
- _mesa_swap2( (GLushort *) dst, n * comps );
- }
}
break;
case GL_UNSIGNED_INT:
@@ -1606,9 +1600,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (dstPacking->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n * comps );
- }
}
break;
case GL_INT:
@@ -1682,9 +1673,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (dstPacking->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n * comps );
- }
}
break;
case GL_FLOAT:
@@ -1758,9 +1746,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (dstPacking->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n * comps );
- }
}
break;
case GL_HALF_FLOAT_ARB:
@@ -1834,9 +1819,6 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
default:
_mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (dstPacking->SwapBytes) {
- _mesa_swap2( (GLushort *) dst, n * comps );
- }
}
break;
case GL_UNSIGNED_BYTE_3_3_2:
@@ -2113,6 +2095,21 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
break;
default:
_mesa_problem(ctx, "bad type in _mesa_pack_rgba_span_float");
+ return;
+ }
+
+ if (dstPacking->SwapBytes) {
+ GLint swapSize = _mesa_sizeof_packed_type(dstType);
+ if (swapSize == 2) {
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2((GLushort *) dstAddr, n * comps);
+ }
+ }
+ else if (swapSize == 4) {
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4((GLuint *) dstAddr, n * comps);
+ }
+ }
}
}
diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c
index ecfe8ec334f..6d395c6011e 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.c b/src/mesa/shader/program.c
index 490f9194457..98daf7062f2 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 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,
+ 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 a0bde077629..7746289621b 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)
@@ -121,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
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index 69e9404c55c..f53e7f52c5e 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -136,7 +136,9 @@ _swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
return;
}
- assert(rb);
+ if (!rb || !rb->Data)
+ return;
+
assert(rb->_BaseFormat == GL_RGBA);
/* add other types in future? */
assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 408174c990f..dde2b1db83a 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1350,7 +1350,7 @@ _swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
GLuint clearValue;
GLint x, y, width, height;
- if (!rb || !ctx->Depth.Mask) {
+ if (!rb || !ctx->Depth.Mask || !rb->Data) {
/* no depth buffer, or writing to it is disabled */
return;
}
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index a8aa1d4b6dc..43475c0e816 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1154,7 +1154,7 @@ _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
const GLuint stencilMax = (1 << stencilBits) - 1;
GLint x, y, width, height;
- if (!rb || mask == 0)
+ if (!rb || mask == 0 || !rb->Data)
return;
ASSERT(rb->DataType == GL_UNSIGNED_BYTE ||