From de947e8a5b2f10eb3fd2bdeacc54209e55447e86 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sat, 16 Dec 2006 12:32:11 +0000 Subject: Get nv10_swtcl.c working enough for glxgears on NV40. --- src/mesa/drivers/dri/nouveau/nouveau_shader.c | 65 ++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'src/mesa/drivers/dri/nouveau/nouveau_shader.c') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.c b/src/mesa/drivers/dri/nouveau/nouveau_shader.c index e3082ebc69..9a09f43d58 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_shader.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.c @@ -37,6 +37,7 @@ #include "program.h" #include "tnl/tnl.h" +#include "shader/arbprogparse.h" #include "nouveau_context.h" #include "nouveau_shader.h" @@ -161,6 +162,63 @@ nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs) return GL_TRUE; } +nouveauShader * +nvsBuildTextShader(GLcontext *ctx, GLenum target, const char *text) +{ + nouveauShader *nvs; + + nvs = CALLOC_STRUCT(_nouveauShader); + if (!nvs) + return NULL; + + if (target == GL_VERTEX_PROGRAM_ARB) { + _mesa_init_vertex_program(ctx, &nvs->mesa.vp, GL_VERTEX_PROGRAM_ARB, 0); + _mesa_parse_arb_vertex_program(ctx, + GL_VERTEX_PROGRAM_ARB, + text, + strlen(text), + &nvs->mesa.vp); + } else if (target == GL_FRAGMENT_PROGRAM_ARB) { + _mesa_init_fragment_program(ctx, &nvs->mesa.fp, GL_VERTEX_PROGRAM_ARB, 0); + _mesa_parse_arb_fragment_program(ctx, + GL_FRAGMENT_PROGRAM_ARB, + text, + strlen(text), + &nvs->mesa.fp); + } + + nouveau_shader_pass0_arb(ctx, nvs); + nouveau_shader_pass1(nvs); + nouveau_shader_pass2(nvs); + + return nvs; +} + +static void +nvsBuildPassthroughVP(GLcontext *ctx) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + + const char *vp_text = + "!!ARBvp1.0\n" + "OPTION ARB_position_invariant;" + "" + "MOV result.color, vertex.color;\n" + "MOV result.texcoord[0], vertex.texcoord[0];\n" + "MOV result.texcoord[1], vertex.texcoord[1];\n" + "MOV result.texcoord[2], vertex.texcoord[2];\n" + "MOV result.texcoord[3], vertex.texcoord[3];\n" + "MOV result.texcoord[4], vertex.texcoord[4];\n" + "MOV result.texcoord[5], vertex.texcoord[5];\n" + "MOV result.texcoord[6], vertex.texcoord[6];\n" + "MOV result.texcoord[7], vertex.texcoord[7];\n" + "END"; + + nmesa->passthrough_vp = nvsBuildTextShader(ctx, + GL_VERTEX_PROGRAM_ARB, + vp_text); +} + void nouveauShaderInitFuncs(GLcontext * ctx) { @@ -184,6 +242,11 @@ nouveauShaderInitFuncs(GLcontext * ctx) return; } + /* Build a vertex program that simply passes through all attribs. + * Needed to do swtcl on nv40 + */ + nvsBuildPassthroughVP(ctx); + ctx->Const.VertexProgram.MaxNativeInstructions = nmesa->VPfunc.MaxInst; ctx->Const.VertexProgram.MaxNativeAluInstructions = nmesa->VPfunc.MaxInst; ctx->Const.VertexProgram.MaxNativeTexInstructions = nmesa->VPfunc.MaxInst; @@ -446,7 +509,7 @@ nvsDumpReg(nvsInstruction * inst, nvsRegister * reg) printf(")"); } -void +static void nvsDumpInstruction(nvsInstruction * inst, int slot, int lvl) { struct _opcode_info *opr = &ops[inst->op]; -- cgit v1.2.3