From 35707dbe57873adb5a8088cd47c13bd216e143e4 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Thu, 12 Apr 2007 09:43:00 +0800 Subject: Initial 965 GLSL support --- src/mesa/drivers/dri/i965/brw_context.c | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/mesa/drivers/dri/i965/brw_context.c') diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 397a9bd3f5..badf178b68 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -44,6 +44,8 @@ #include "api_noop.h" #include "vtxfmt.h" +#include "shader/shader_api.h" + /*************************************** * Mesa's Driver Functions ***************************************/ @@ -60,12 +62,57 @@ static const struct dri_extension brw_extensions[] = { NULL, NULL } }; +static void brwLinkProgram(GLcontext *ctx, GLuint program) +{ + struct brw_context *brw = brw_context(ctx); + struct brw_vertex_program *vert_prog; + struct brw_fragment_program *frag_prog; + struct gl_shader_program *sh_prog; + _mesa_link_program(ctx, program); + + sh_prog = _mesa_lookup_shader_program(ctx, program); + if (sh_prog) { + sh_prog->FragmentProgram = + _mesa_realloc(sh_prog->FragmentProgram, + sizeof(struct gl_fragment_program), + sizeof(struct brw_fragment_program)); + frag_prog = (struct brw_fragment_program *)sh_prog->FragmentProgram; + frag_prog->id = brw->program_id++; + sh_prog->VertexProgram = _mesa_realloc(sh_prog->VertexProgram, + sizeof(struct gl_vertex_program), + sizeof(struct brw_vertex_program)); + vert_prog = (struct brw_vertex_program *)sh_prog->VertexProgram; + vert_prog->id = brw->program_id++; + } +} + +static void brwUseProgram(GLcontext *ctx, GLuint program) +{ + struct brw_context *brw = brw_context(ctx); + struct gl_shader_program *sh_prog; + _mesa_use_program(ctx, program); + sh_prog = ctx->Shader.CurrentProgram; + if (sh_prog) { + ctx->VertexProgram.Enabled = GL_TRUE; + ctx->FragmentProgram.Enabled = GL_TRUE; + brw->attribs.VertexProgram->Current = sh_prog->VertexProgram; + brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram; + brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; + brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; + } +} +static void brwInitProgFuncs( struct dd_function_table *functions ) +{ + functions->UseProgram = brwUseProgram; + functions->LinkProgram = brwLinkProgram; +} static void brwInitDriverFunctions( struct dd_function_table *functions ) { intelInitDriverFunctions( functions ); brwInitTextureFuncs( functions ); brwInitFragProgFuncs( functions ); + brwInitProgFuncs( functions ); } -- cgit v1.2.3 From 719cf0b7958d0dedf8727c97eaddb6a1f31977e1 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Tue, 17 Jul 2007 11:19:52 +0800 Subject: Use ProgramStringNotify --- src/mesa/drivers/dri/i965/brw_context.c | 27 --------------------------- src/mesa/shader/program.c | 2 ++ 2 files changed, 2 insertions(+), 27 deletions(-) (limited to 'src/mesa/drivers/dri/i965/brw_context.c') diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index badf178b68..8366f14dbe 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -62,30 +62,6 @@ static const struct dri_extension brw_extensions[] = { NULL, NULL } }; -static void brwLinkProgram(GLcontext *ctx, GLuint program) -{ - struct brw_context *brw = brw_context(ctx); - struct brw_vertex_program *vert_prog; - struct brw_fragment_program *frag_prog; - struct gl_shader_program *sh_prog; - _mesa_link_program(ctx, program); - - sh_prog = _mesa_lookup_shader_program(ctx, program); - if (sh_prog) { - sh_prog->FragmentProgram = - _mesa_realloc(sh_prog->FragmentProgram, - sizeof(struct gl_fragment_program), - sizeof(struct brw_fragment_program)); - frag_prog = (struct brw_fragment_program *)sh_prog->FragmentProgram; - frag_prog->id = brw->program_id++; - sh_prog->VertexProgram = _mesa_realloc(sh_prog->VertexProgram, - sizeof(struct gl_vertex_program), - sizeof(struct brw_vertex_program)); - vert_prog = (struct brw_vertex_program *)sh_prog->VertexProgram; - vert_prog->id = brw->program_id++; - } -} - static void brwUseProgram(GLcontext *ctx, GLuint program) { struct brw_context *brw = brw_context(ctx); @@ -97,15 +73,12 @@ static void brwUseProgram(GLcontext *ctx, GLuint program) ctx->FragmentProgram.Enabled = GL_TRUE; brw->attribs.VertexProgram->Current = sh_prog->VertexProgram; brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram; - brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM; - brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; } } static void brwInitProgFuncs( struct dd_function_table *functions ) { functions->UseProgram = brwUseProgram; - functions->LinkProgram = brwLinkProgram; } static void brwInitDriverFunctions( struct dd_function_table *functions ) { diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 4205919828..03be368a92 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -242,6 +242,8 @@ _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog, struct gl_program * _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id) { + if (ctx->Driver.NewProgram) + return ctx->Driver.NewProgram(ctx, target, id); switch (target) { case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program), -- cgit v1.2.3 From 35a0634e358baac832d6e5a76630fcae57a948a7 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Thu, 27 Sep 2007 15:47:00 +0800 Subject: fix issue when only fragment shader or vertex shader is used --- src/mesa/drivers/dri/i965/brw_context.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/mesa/drivers/dri/i965/brw_context.c') diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 8366f14dbe..2031d556c1 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -69,11 +69,18 @@ static void brwUseProgram(GLcontext *ctx, GLuint program) _mesa_use_program(ctx, program); sh_prog = ctx->Shader.CurrentProgram; if (sh_prog) { - ctx->VertexProgram.Enabled = GL_TRUE; - ctx->FragmentProgram.Enabled = GL_TRUE; - brw->attribs.VertexProgram->Current = sh_prog->VertexProgram; - brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram; - } + if (sh_prog->VertexProgram) { + brw->attribs.VertexProgram->Current = sh_prog->VertexProgram; + ctx->VertexProgram.Enabled = GL_TRUE; + }else + ctx->VertexProgram.Enabled = GL_FALSE; + + if (sh_prog->FragmentProgram) { + brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram; + ctx->FragmentProgram.Enabled = GL_TRUE; + } else + ctx->VertexProgram.Enabled = GL_FALSE; + } } static void brwInitProgFuncs( struct dd_function_table *functions ) -- cgit v1.2.3 From ac985708f4820173bdc4509d032bdabeb93a0590 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Mon, 8 Oct 2007 15:34:03 +0800 Subject: Only vertex program fix, bypass tnl vertex program --- src/mesa/drivers/dri/i965/brw_context.c | 2 +- src/mesa/main/texenvprogram.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/i965/brw_context.c') diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 2031d556c1..9266e73570 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -79,7 +79,7 @@ static void brwUseProgram(GLcontext *ctx, GLuint program) brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram; ctx->FragmentProgram.Enabled = GL_TRUE; } else - ctx->VertexProgram.Enabled = GL_FALSE; + ctx->FragmentProgram.Enabled = GL_FALSE; } } diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 72b54b27d9..126a9e1179 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -1239,7 +1239,7 @@ _mesa_UpdateTexEnvProgram( GLcontext *ctx ) /* If a conventional fragment program/shader isn't in effect... */ if (!ctx->FragmentProgram._Enabled && - !ctx->Shader.CurrentProgram) { + (!ctx->Shader.CurrentProgram || !ctx->Shader.CurrentProgram->FragmentProgram)) { make_state_key(ctx, &key); hash = hash_key(&key); -- cgit v1.2.3