13464ebd5Sriastradh/*
23464ebd5Sriastradh * Mesa 3-D graphics library
33464ebd5Sriastradh *
43464ebd5Sriastradh * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
53464ebd5Sriastradh *
63464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
73464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"),
83464ebd5Sriastradh * to deal in the Software without restriction, including without limitation
93464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
103464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
113464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions:
123464ebd5Sriastradh *
133464ebd5Sriastradh * The above copyright notice and this permission notice shall be included
143464ebd5Sriastradh * in all copies or substantial portions of the Software.
153464ebd5Sriastradh *
163464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
173464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
233464ebd5Sriastradh */
243464ebd5Sriastradh
253464ebd5Sriastradh#ifndef PROG_EXECUTE_H
263464ebd5Sriastradh#define PROG_EXECUTE_H
273464ebd5Sriastradh
283464ebd5Sriastradh#include "main/config.h"
2901e04c3fSmrg#include "main/glheader.h"
3001e04c3fSmrg#include "compiler/shader_enums.h"
313464ebd5Sriastradh
3201e04c3fSmrgstruct gl_context;
333464ebd5Sriastradh
343464ebd5Sriastradhtypedef void (*FetchTexelLodFunc)(struct gl_context *ctx, const GLfloat texcoord[4],
353464ebd5Sriastradh                                  GLfloat lambda, GLuint unit, GLfloat color[4]);
363464ebd5Sriastradh
373464ebd5Sriastradhtypedef void (*FetchTexelDerivFunc)(struct gl_context *ctx, const GLfloat texcoord[4],
383464ebd5Sriastradh                                    const GLfloat texdx[4],
393464ebd5Sriastradh                                    const GLfloat texdy[4],
403464ebd5Sriastradh                                    GLfloat lodBias,
413464ebd5Sriastradh                                    GLuint unit, GLfloat color[4]);
423464ebd5Sriastradh
433464ebd5Sriastradh
44af69d88dSmrg/** NOTE: This must match SWRAST_MAX_WIDTH */
45af69d88dSmrg#define PROG_MAX_WIDTH 16384
46af69d88dSmrg
47af69d88dSmrg
483464ebd5Sriastradh/**
493464ebd5Sriastradh * Virtual machine state used during execution of vertex/fragment programs.
503464ebd5Sriastradh */
513464ebd5Sriastradhstruct gl_program_machine
523464ebd5Sriastradh{
533464ebd5Sriastradh   const struct gl_program *CurProgram;
543464ebd5Sriastradh
553464ebd5Sriastradh   /** Fragment Input attributes */
56af69d88dSmrg   GLfloat (*Attribs)[PROG_MAX_WIDTH][4];
573464ebd5Sriastradh   GLfloat (*DerivX)[4];
583464ebd5Sriastradh   GLfloat (*DerivY)[4];
593464ebd5Sriastradh   GLuint NumDeriv; /**< Max index into DerivX/Y arrays */
603464ebd5Sriastradh   GLuint CurElement; /**< Index into Attribs arrays */
613464ebd5Sriastradh
623464ebd5Sriastradh   /** Vertex Input attribs */
633464ebd5Sriastradh   GLfloat VertAttribs[VERT_ATTRIB_MAX][4];
643464ebd5Sriastradh
653464ebd5Sriastradh   GLfloat Temporaries[MAX_PROGRAM_TEMPS][4];
663464ebd5Sriastradh   GLfloat Outputs[MAX_PROGRAM_OUTPUTS][4];
673464ebd5Sriastradh   GLfloat (*EnvParams)[4]; /**< Vertex or Fragment env parameters */
683464ebd5Sriastradh   GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4];
693464ebd5Sriastradh   GLfloat SystemValues[SYSTEM_VALUE_MAX][4];
703464ebd5Sriastradh
713464ebd5Sriastradh   const GLubyte *Samplers;  /** Array mapping sampler var to tex unit */
723464ebd5Sriastradh
733464ebd5Sriastradh   GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */
743464ebd5Sriastradh   GLuint StackDepth; /**< Index/ptr to top of CallStack[] */
753464ebd5Sriastradh
763464ebd5Sriastradh   /** Texture fetch functions */
773464ebd5Sriastradh   FetchTexelLodFunc FetchTexelLod;
783464ebd5Sriastradh   FetchTexelDerivFunc FetchTexelDeriv;
793464ebd5Sriastradh};
803464ebd5Sriastradh
813464ebd5Sriastradh
823464ebd5Sriastradhextern GLboolean
833464ebd5Sriastradh_mesa_execute_program(struct gl_context *ctx,
843464ebd5Sriastradh                      const struct gl_program *program,
853464ebd5Sriastradh                      struct gl_program_machine *machine);
863464ebd5Sriastradh
873464ebd5Sriastradh
883464ebd5Sriastradh#endif /* PROG_EXECUTE_H */
89