diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2008-09-17 16:48:13 -0600 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2008-09-17 16:48:13 -0600 |
commit | d7a7b0a10dd355fbeb7a404091a42d4ab558c820 (patch) | |
tree | 6580b3dab45c18fa892e73c5ccbe99a11bc9eade | |
parent | 3b3d34d637d413af48fa5bd037b579ccb4ea7bb5 (diff) |
mesa: new gl_fragment_program fields indicating use of fog, front-facing, point coord
-rw-r--r-- | src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_link.c | 50 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2fc169493b..a5e1cf6a27 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1953,7 +1953,10 @@ struct gl_fragment_program { struct gl_program Base; /**< base class */ GLenum FogOption; - GLboolean UsesKill; + GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean UsesPointCoord; /**< shader uses gl_PointCoord */ + GLboolean UsesFrontFacing; /**< shader used gl_FrontFacing */ + GLboolean UsesFogFragCoord; /**< shader used gl_FogFragCoord */ }; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index a44d001477..dd7d5be6d8 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -42,6 +42,24 @@ #include "slang_link.h" +/** cast wrapper */ +static struct gl_vertex_program * +vertex_program(struct gl_program *prog) +{ + assert(prog->Target == GL_VERTEX_PROGRAM_ARB); + return (struct gl_vertex_program *) prog; +} + + +/** cast wrapper */ +static struct gl_fragment_program * +fragment_program(struct gl_program *prog) +{ + assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); + return (struct gl_fragment_program *) prog; +} + + /** * Record a linking error. */ @@ -374,6 +392,20 @@ _slang_update_inputs_outputs(struct gl_program *prog) for (j = 0; j < numSrc; j++) { if (inst->SrcReg[j].File == PROGRAM_INPUT) { prog->InputsRead |= 1 << inst->SrcReg[j].Index; + if (prog->Target == GL_FRAGMENT_PROGRAM_ARB && + inst->SrcReg[j].Index == FRAG_ATTRIB_FOGC) { + /* The fragment shader FOGC input is used for fog, + * front-facing and sprite/point coord. + */ + struct gl_fragment_program *fp = fragment_program(prog); + const GLint swz = GET_SWZ(inst->SrcReg[j].Swizzle, 0); + if (swz == SWIZZLE_X) + fp->UsesFogFragCoord = GL_TRUE; + else if (swz == SWIZZLE_Y) + fp->UsesFrontFacing = GL_TRUE; + else if (swz == SWIZZLE_Z || swz == SWIZZLE_W) + fp->UsesPointCoord = GL_TRUE; + } } else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) { maxAddrReg = MAX2(maxAddrReg, inst->SrcReg[j].Index + 1); @@ -391,24 +423,6 @@ _slang_update_inputs_outputs(struct gl_program *prog) } -/** cast wrapper */ -static struct gl_vertex_program * -vertex_program(struct gl_program *prog) -{ - assert(prog->Target == GL_VERTEX_PROGRAM_ARB); - return (struct gl_vertex_program *) prog; -} - - -/** cast wrapper */ -static struct gl_fragment_program * -fragment_program(struct gl_program *prog) -{ - assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); - return (struct gl_fragment_program *) prog; -} - - /** * Shader linker. Currently: * |