i965: avoid unnecessary calls to brw_wm_is_glsl()

This function scans the shader to see if it has any GLSL features like
conditionals and loops.  Calling this during state validation is expensive.
Just call it when the shader is given to the driver and save the result.

There's some new/temporary assertions to be sure we don't get out of sync
on this.
This commit is contained in:
Brian Paul
2009-03-06 16:04:53 -07:00
parent 99e4809f5d
commit 5cbd1170da
4 changed files with 12 additions and 2 deletions
+1
View File
@@ -164,6 +164,7 @@ struct brw_vertex_program {
struct brw_fragment_program {
struct gl_fragment_program program;
GLuint id; /**< serial no. to identify frag progs, never re-used */
GLboolean isGLSL; /**< really, any IF/LOOP/CONT/BREAK instructions */
};
+2
View File
@@ -38,6 +38,7 @@
#include "brw_context.h"
#include "brw_util.h"
#include "brw_wm.h"
static void brwBindProgram( GLcontext *ctx,
GLenum target,
@@ -122,6 +123,7 @@ static void brwProgramStringNotify( GLcontext *ctx,
if (newFP == curFP)
brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM;
newFP->id = brw->program_id++;
newFP->isGLSL = brw_wm_is_glsl(fprog);
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
struct brw_vertex_program *newVP = (struct brw_vertex_program *) prog;
+4 -1
View File
@@ -149,11 +149,14 @@ static void do_wm_prog( struct brw_context *brw,
brw_init_compile(brw, &c->func);
/* temporary sanity check assertion */
ASSERT(fp->isGLSL == brw_wm_is_glsl(&c->fp->program));
/*
* Shader which use GLSL features such as flow control are handled
* differently from "simple" shaders.
*/
if (brw_wm_is_glsl(&c->fp->program)) {
if (fp->isGLSL) {
brw_wm_glsl_emit(brw, c);
}
else {
+5 -1
View File
@@ -62,6 +62,7 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
{
GLcontext *ctx = &brw->intel.ctx;
const struct gl_fragment_program *fp = brw->fragment_program;
const struct brw_fragment_program *bfp = (struct brw_fragment_program *) fp;
struct intel_context *intel = &brw->intel;
memset(key, 0, sizeof(*key));
@@ -107,7 +108,10 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
/* _NEW_COLOR */
key->uses_kill = fp->UsesKill || ctx->Color.AlphaEnabled;
key->is_glsl = brw_wm_is_glsl(fp);
key->is_glsl = bfp->isGLSL;
/* temporary sanity check assertion */
ASSERT(bfp->isGLSL == brw_wm_is_glsl(fp));
/* XXX: This needs a flag to indicate when it changes. */
key->stats_wm = intel->stats_wm;