Put gl_program_machine into swrast structure rather than using a local variable.

Basically an easy way to make sure the memory gets initialized once (to zero)
to avoid lots of valgrind warnings.
This commit is contained in:
Brian
2007-04-19 14:24:10 -06:00
parent 020cdb47cf
commit 8b5fce6bcc
2 changed files with 13 additions and 10 deletions

View File

@@ -1,8 +1,8 @@
/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -46,6 +46,7 @@
#include "mtypes.h" #include "mtypes.h"
#include "swrast.h" #include "swrast.h"
#include "s_span.h" #include "s_span.h"
#include "prog_execute.h"
typedef void (*texture_sample_func)(GLcontext *ctx, typedef void (*texture_sample_func)(GLcontext *ctx,
@@ -222,6 +223,9 @@ typedef struct
validate_texture_image_func ValidateTextureImage; validate_texture_image_func ValidateTextureImage;
/** State used during execution of fragment programs */
struct gl_program_machine FragProgMachine;
} SWcontext; } SWcontext;

View File

@@ -25,7 +25,6 @@
#include "glheader.h" #include "glheader.h"
#include "colormac.h" #include "colormac.h"
#include "context.h" #include "context.h"
#include "prog_execute.h"
#include "prog_instruction.h" #include "prog_instruction.h"
#include "s_fragprog.h" #include "s_fragprog.h"
@@ -105,7 +104,7 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine,
if (ctx->FragmentProgram.CallbackEnabled) if (ctx->FragmentProgram.CallbackEnabled)
inputsRead = ~0; inputsRead = ~0;
if (program->Base.Target == GL_FRAGMENT_PROGRAM_NV) { if (1/*program->Base.Target == GL_FRAGMENT_PROGRAM_NV*/) {
/* Clear temporary registers (undefined for ARB_f_p) */ /* Clear temporary registers (undefined for ARB_f_p) */
_mesa_bzero(machine->Temporaries, _mesa_bzero(machine->Temporaries,
MAX_PROGRAM_TEMPS * 4 * sizeof(GLfloat)); MAX_PROGRAM_TEMPS * 4 * sizeof(GLfloat));
@@ -142,19 +141,19 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
const struct gl_fragment_program *program = ctx->FragmentProgram._Current; const struct gl_fragment_program *program = ctx->FragmentProgram._Current;
const GLbitfield outputsWritten = program->Base.OutputsWritten; const GLbitfield outputsWritten = program->Base.OutputsWritten;
struct gl_program_machine machine; struct gl_program_machine *machine = &swrast->FragProgMachine;
GLuint i; GLuint i;
for (i = start; i < end; i++) { for (i = start; i < end; i++) {
if (span->array->mask[i]) { if (span->array->mask[i]) {
init_machine(ctx, &machine, program, span, i); init_machine(ctx, machine, program, span, i);
if (_mesa_execute_program(ctx, &program->Base, &machine)) { if (_mesa_execute_program(ctx, &program->Base, machine)) {
/* Store result color */ /* Store result color */
if (outputsWritten & (1 << FRAG_RESULT_COLR)) { if (outputsWritten & (1 << FRAG_RESULT_COLR)) {
COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i],
machine.Outputs[FRAG_RESULT_COLR]); machine->Outputs[FRAG_RESULT_COLR]);
} }
else { else {
/* Multiple drawbuffers / render targets /* Multiple drawbuffers / render targets
@@ -165,14 +164,14 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
for (output = 0; output < swrast->_NumColorOutputs; output++) { for (output = 0; output < swrast->_NumColorOutputs; output++) {
if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + output))) { if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + output))) {
COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0+output][i], COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0+output][i],
machine.Outputs[FRAG_RESULT_DATA0 + output]); machine->Outputs[FRAG_RESULT_DATA0 + output]);
} }
} }
} }
/* Store result depth/z */ /* Store result depth/z */
if (outputsWritten & (1 << FRAG_RESULT_DEPR)) { if (outputsWritten & (1 << FRAG_RESULT_DEPR)) {
const GLfloat depth = machine.Outputs[FRAG_RESULT_DEPR][2]; const GLfloat depth = machine->Outputs[FRAG_RESULT_DEPR][2];
if (depth <= 0.0) if (depth <= 0.0)
span->array->z[i] = 0; span->array->z[i] = 0;
else if (depth >= 1.0) else if (depth >= 1.0)