dispatch: stop generating separate GLES1 API code.
[mesa.git] / src / mesa / main / atifragshader.c
index ae2feb3229ad03e3314e71e0d820e7df91f4f05e..32ddfb8bbe1184f079d5482288ba57e9daaec16f 100644 (file)
 #include "main/hash.h"
 #include "main/imports.h"
 #include "main/macros.h"
+#include "main/mfeatures.h"
 #include "main/enums.h"
 #include "main/mtypes.h"
 #include "main/dispatch.h"
 #include "main/atifragshader.h"
 
-#if FEATURE_ATI_fragment_shader
-
 #define MESA_DEBUG_ATI_FS 0
 
 static struct ati_fragment_shader DummyShader;
@@ -82,10 +81,8 @@ _mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_sha
 {
    GLuint i;
    for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
-      if (s->Instructions[i])
-         free(s->Instructions[i]);
-      if (s->SetupInst[i])
-         free(s->SetupInst[i]);
+      free(s->Instructions[i]);
+      free(s->SetupInst[i]);
    }
    free(s);
 }
@@ -316,6 +313,7 @@ _mesa_DeleteFragmentShaderATI(GLuint id)
       if (prog) {
         prog->RefCount--;
         if (prog->RefCount <= 0) {
+           assert(prog != &DummyShader);
            free(prog);
         }
       }
@@ -340,21 +338,17 @@ _mesa_BeginFragmentShaderATI(void)
       (or, could use the same mem but would need to reinitialize) */
    /* no idea if it's allowed to redefine a shader */
    for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
-         if (ctx->ATIFragmentShader.Current->Instructions[i])
-            free(ctx->ATIFragmentShader.Current->Instructions[i]);
-         if (ctx->ATIFragmentShader.Current->SetupInst[i])
-            free(ctx->ATIFragmentShader.Current->SetupInst[i]);
+         free(ctx->ATIFragmentShader.Current->Instructions[i]);
+         free(ctx->ATIFragmentShader.Current->SetupInst[i]);
    }
 
    /* malloc the instructions here - not sure if the best place but its
       a start */
    for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
       ctx->ATIFragmentShader.Current->Instructions[i] =
-        (struct atifs_instruction *)
         calloc(1, sizeof(struct atifs_instruction) *
                   (MAX_NUM_INSTRUCTIONS_PER_PASS_ATI));
       ctx->ATIFragmentShader.Current->SetupInst[i] =
-        (struct atifs_setupinst *)
         calloc(1, sizeof(struct atifs_setupinst) *
                   (MAX_NUM_FRAGMENT_REGISTERS_ATI));
    }
@@ -492,7 +486,7 @@ _mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle)
       }
    }
 
-   curProg->regsAssigned[curProg->cur_pass >> 1] |=  1 << (dst - GL_REG_0_ATI);
+   curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI);
    new_tex_inst(curProg);
 
    /* add the instructions */
@@ -565,7 +559,7 @@ _mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle)
       }
    }
 
-   curProg->regsAssigned[curProg->cur_pass >> 1] |=  1 << (dst - GL_REG_0_ATI);
+   curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI);
    new_tex_inst(curProg);
 
    /* add the instructions */
@@ -790,5 +784,3 @@ _mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value)
       COPY_4V(ctx->ATIFragmentShader.GlobalConstants[dstindex], value);
    }
 }
-
-#endif /* FEATURE_ATI_fragment_shader */