gallium/auxiliary: Sanitize NULL checks into canonical form
[mesa.git] / src / gallium / auxiliary / postprocess / pp_init.c
index 1130248467a6c3cb5f3a4133a9bb88b703fe985b..b9eff78bf4f5ccf839b8960b7fef029d8ae242db 100644 (file)
 #include "pipe/p_compiler.h"
 
 #include "postprocess/filters.h"
+#include "postprocess/pp_private.h"
 
 #include "pipe/p_screen.h"
 #include "util/u_inlines.h"
-#include "util/u_blit.h"
 #include "util/u_math.h"
 #include "util/u_debug.h"
 #include "util/u_memory.h"
@@ -58,7 +58,7 @@ pp_init(struct pipe_context *pipe, const unsigned int *enabled,
 
    ppq = CALLOC(1, sizeof(struct pp_queue_t));
 
-   if (ppq == NULL) {
+   if (!ppq) {
       pp_debug("Unable to allocate memory for ppq.\n");
       goto error;
    }
@@ -111,13 +111,6 @@ pp_init(struct pipe_context *pipe, const unsigned int *enabled,
       }
    }
 
-   ppq->p->blitctx = util_create_blit(ppq->p->pipe, cso);
-
-   if (ppq->p->blitctx == NULL) {
-      pp_debug("Unable to create a blit context.\n");
-      goto error;
-   }
-
    ppq->n_filters = curpos;
    ppq->n_tmp = (curpos > 2 ? 2 : 1);
    ppq->n_inner_tmp = tmp_req;
@@ -177,14 +170,12 @@ pp_free(struct pp_queue_t *ppq)
 {
    unsigned int i, j;
 
-   pp_free_fbos(ppq);
+   if (!ppq)
+      return;
 
-   if (ppq && ppq->p) {
-      /* Only destroy created contexts. */
-      if (ppq->p->blitctx) {
-         util_destroy_blit(ppq->p->blitctx);
-      }
+   pp_free_fbos(ppq);
 
+   if (ppq->p) {
       if (ppq->p->pipe && ppq->filters && ppq->shaders) {
          for (i = 0; i < ppq->n_filters; i++) {
             unsigned int filter = ppq->filters[i];
@@ -232,17 +223,15 @@ pp_free(struct pp_queue_t *ppq)
       FREE(ppq->p);
    }
 
-   if (ppq) {
-      /*
-       * Handle partial initialization for common resource destruction
-       * in the create path.
-       */
-      FREE(ppq->filters);
-      FREE(ppq->shaders);
-      FREE(ppq->pp_queue);
+   /*
+    * Handle partial initialization for common resource destruction
+    * in the create path.
+    */
+   FREE(ppq->filters);
+   FREE(ppq->shaders);
+   FREE(ppq->pp_queue);
   
-      FREE(ppq);
-   }
+   FREE(ppq);
 
    pp_debug("Queue taken down.\n");
 }
@@ -267,7 +256,7 @@ pp_init_fbos(struct pp_queue_t *ppq, unsigned int w,
              unsigned int h)
 {
 
-   struct program *p = ppq->p;  /* The lazy will inherit the earth */
+   struct pp_program *p = ppq->p;  /* The lazy will inherit the earth */
 
    unsigned int i;
    struct pipe_resource tmp_res;
@@ -335,8 +324,6 @@ pp_init_fbos(struct pp_queue_t *ppq, unsigned int w,
 
    p->viewport.scale[0] = p->viewport.translate[0] = (float) w / 2.0f;
    p->viewport.scale[1] = p->viewport.translate[1] = (float) h / 2.0f;
-   p->viewport.scale[3] = 1.0f;
-   p->viewport.translate[3] = 0.0f;
 
    ppq->fbos_init = true;