diff options
author | Brian <[email protected]> | 2007-08-16 17:32:24 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-16 17:32:24 -0600 |
commit | 78d6d5e8fe7281f67b7ce8d9911e4f280435b1f5 (patch) | |
tree | 1e7945f1db0c03e58ccf9491aeeb515b012b81a4 | |
parent | 9ba4311e71f510797e1b446ab7dc6b6d4dc55dd5 (diff) |
make pass-through vertex shader
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 3777c53d480..492073e8403 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -152,8 +152,62 @@ make_color_shader(struct st_context *st) /** + * Create a simple vertex shader that just passes through the + * vertex position and color. + */ +static struct st_vertex_program * +make_vertex_shader(struct st_context *st) +{ + GLcontext *ctx = st->ctx; + struct st_vertex_program *stvp; + struct gl_program *p; + GLboolean b; + + p = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); + if (!p) + return NULL; + + p->NumInstructions = 3; + p->Instructions = _mesa_alloc_instructions(3); + if (!p->Instructions) { + ctx->Driver.DeleteProgram(ctx, p); + return NULL; + } + _mesa_init_instructions(p->Instructions, 3); + /* MOV result.pos, vertex.pos; */ + p->Instructions[0].Opcode = OPCODE_MOV; + p->Instructions[0].DstReg.File = PROGRAM_OUTPUT; + p->Instructions[0].DstReg.Index = VERT_RESULT_HPOS; + p->Instructions[0].SrcReg[0].File = PROGRAM_INPUT; + p->Instructions[0].SrcReg[0].Index = VERT_ATTRIB_POS; + /* MOV result.color, vertex.color; */ + p->Instructions[1].Opcode = OPCODE_MOV; + p->Instructions[1].DstReg.File = PROGRAM_OUTPUT; + p->Instructions[1].DstReg.Index = VERT_RESULT_COL0; + p->Instructions[1].SrcReg[0].File = PROGRAM_INPUT; + p->Instructions[1].SrcReg[0].Index = VERT_ATTRIB_COLOR0; + /* END; */ + p->Instructions[2].Opcode = OPCODE_END; + + p->InputsRead = VERT_BIT_POS | VERT_BIT_COLOR0; + p->OutputsWritten = ((1 << VERT_RESULT_COL0) | + (1 << VERT_RESULT_HPOS)); + + stvp = (struct st_vertex_program *) p; + /* compile into tgsi format */ + b = tgsi_mesa_compile_vp_program(&stvp->Base, + stvp->tokens, ST_FP_MAX_TOKENS); + assert(b); + + return stvp; +} + + + +/** * Draw a screen-aligned quadrilateral. * Coords are window coords. + * XXX need to emit clip coords when using a vertex program! */ static void draw_quad(GLcontext *ctx, |