From 37c319f62f59d7750dd172034e43dfd489f572cc Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Fri, 3 Jul 2009 20:14:24 +0200 Subject: [PATCH] r300: implement proper IsProgramNative check for vertex programs --- src/mesa/drivers/dri/r300/r300_context.h | 1 - src/mesa/drivers/dri/r300/r300_shader.c | 9 +++++++-- src/mesa/drivers/dri/r300/r300_state.c | 8 ++++++-- src/mesa/drivers/dri/r300/r300_vertprog.c | 13 ++++++------- src/mesa/drivers/dri/r300/r300_vertprog.h | 4 ++++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 30b6e750398..44211a45b31 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -673,7 +673,6 @@ extern GLboolean r300CreateContext(const __GLcontextModes * glVisual, __DRIcontextPrivate * driContextPriv, void *sharedContextPrivate); -extern void r300SelectVertexShader(r300ContextPtr r300); extern void r300InitShaderFuncs(struct dd_function_table *functions); extern void r300InitShaderFunctions(r300ContextPtr r300); diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c index 7206379ea05..854eb5d80ae 100644 --- a/src/mesa/drivers/dri/r300/r300_shader.c +++ b/src/mesa/drivers/dri/r300/r300_shader.c @@ -128,8 +128,13 @@ r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog) r300TranslateFragmentShader(ctx, fp); return !fp->error; - } else - return GL_TRUE; + } else { + struct r300_vertex_program *vp = r300SelectVertexShader(ctx); + if (!vp->translated) + r300TranslateVertexShader(vp); + + return !vp->error; + } } void r300InitShaderFuncs(struct dd_function_table *functions) diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index e0996383ebb..8c228ab5e7b 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -2045,6 +2045,7 @@ void r300UpdateShaders(r300ContextPtr rmesa) } if (rmesa->radeon.NewGLState && rmesa->options.hw_tcl_enabled) { + struct r300_vertex_program *vp; int i; for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { rmesa->temp_attrib[i] = @@ -2060,8 +2061,11 @@ void r300UpdateShaders(r300ContextPtr rmesa) rmesa->temp_attrib[i]; } - r300SelectVertexShader(rmesa); - r300SwitchFallback(ctx, R300_FALLBACK_VERTEX_PROGRAM, rmesa->selected_vp->error); + vp = r300SelectVertexShader(ctx); + if (!vp->translated) + r300TranslateVertexShader(vp); + + r300SwitchFallback(ctx, R300_FALLBACK_VERTEX_PROGRAM, vp->error); } fp = r300SelectFragmentShader(ctx); diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 25c42814ec7..326183bda42 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1027,7 +1027,7 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) } } -static void r300TranslateVertexShader(struct r300_vertex_program *vp) +void r300TranslateVertexShader(struct r300_vertex_program *vp) { struct prog_instruction *vpi = vp->Base->Base.Instructions; int i; @@ -1524,7 +1524,6 @@ static struct r300_vertex_program *build_program(GLcontext *ctx, assert(prog->NumInstructions); vp->num_temporaries = prog->NumTemporaries; - r300TranslateVertexShader(vp); return vp; } @@ -1538,9 +1537,9 @@ static void add_outputs(struct r300_vertex_program_key *key, GLint vert) key->OutputsAdded |= 1 << vert; } -void r300SelectVertexShader(r300ContextPtr r300) +struct r300_vertex_program * r300SelectVertexShader(GLcontext *ctx) { - GLcontext *ctx = ctx = r300->radeon.glCtx; + r300ContextPtr r300 = R300_CONTEXT(ctx); GLuint InputsRead; struct r300_vertex_program_key wanted_key = { 0 }; GLint i; @@ -1596,14 +1595,14 @@ void r300SelectVertexShader(r300ContextPtr r300) for (vp = vpc->progs; vp; vp = vp->next) if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) == 0) { - r300->selected_vp = vp; - return; + return r300->selected_vp = vp; } vp = build_program(ctx, &wanted_key, &vpc->mesa_program, wpos_idx); vp->next = vpc->progs; vpc->progs = vp; - r300->selected_vp = vp; + + return r300->selected_vp = vp; } #define bump_vpu_count(ptr, new_count) do { \ diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h index b552e3fb1bd..2dab11c3378 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.h +++ b/src/mesa/drivers/dri/r300/r300_vertprog.h @@ -34,4 +34,8 @@ void r300SetupVertexProgram(r300ContextPtr rmesa); +struct r300_vertex_program * r300SelectVertexShader(GLcontext *ctx); + +void r300TranslateVertexShader(struct r300_vertex_program *vp); + #endif -- 2.30.2