gallium: add pipe cap for scissored clears and pass scissor state to clear() hook
[mesa.git] / src / gallium / auxiliary / postprocess / pp_mlaa.c
index 0edd01f3f5d5a6bf3afd98a7bc73a3ec7470aeae..51e3e0260fa1177803839c2b7521275f6f65131d 100644 (file)
 static float constants[] = { 1, 1, 0, 0 };
 static unsigned int dimensions[2] = { 0, 0 };
 
-/** Upload the constants. */
-static void
-up_consts(struct pp_queue_t *ppq)
-{
-   struct pipe_context *pipe = ppq->p->pipe;
-
-   pipe->buffer_subdata(pipe, ppq->constbuf, PIPE_TRANSFER_WRITE,
-                        0, sizeof(constants), constants);
-}
-
 /** Run function of the MLAA filter. */
 static void
 pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
@@ -86,7 +76,6 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    /* Insufficient initialization checks. */
    assert(p);
    assert(ppq);
-   assert(ppq->constbuf);
    assert(ppq->areamaptex);
    assert(ppq->inner_tmp);
    assert(ppq->shaders[n]);
@@ -104,15 +93,14 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
       constants[0] = 1.0f / p->framebuffer.width;
       constants[1] = 1.0f / p->framebuffer.height;
 
-      up_consts(ppq);
       dimensions[0] = p->framebuffer.width;
       dimensions[1] = p->framebuffer.height;
    }
 
-   cso_set_constant_buffer_resource(p->cso, PIPE_SHADER_VERTEX,
-                                    0, ppq->constbuf);
-   cso_set_constant_buffer_resource(p->cso, PIPE_SHADER_FRAGMENT,
-                                    0, ppq->constbuf);
+   cso_set_constant_user_buffer(p->cso, PIPE_SHADER_VERTEX,
+                                0, constants, sizeof(constants));
+   cso_set_constant_user_buffer(p->cso, PIPE_SHADER_FRAGMENT,
+                                0, constants, sizeof(constants));
 
    mstencil.stencil[0].enabled = 1;
    mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
@@ -134,7 +122,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    pp_filter_set_fb(p);
    pp_filter_misc_state(p);
    cso_set_depth_stencil_alpha(p->cso, &mstencil);
-   p->pipe->clear(p->pipe, PIPE_CLEAR_STENCIL | PIPE_CLEAR_COLOR0,
+   p->pipe->clear(p->pipe, PIPE_CLEAR_STENCIL | PIPE_CLEAR_COLOR0, NULL,
                   &p->clear_color, 0, 0);
 
    {
@@ -239,18 +227,9 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
       return FALSE;
    }
 
-   ppq->constbuf = pipe_buffer_create(ppq->p->screen,
-                                      PIPE_BIND_CONSTANT_BUFFER,
-                                      PIPE_USAGE_DEFAULT,
-                                      sizeof(constants));
-   if (ppq->constbuf == NULL) {
-      pp_debug("Failed to allocate constant buffer\n");
-      goto fail;
-   }
-
    pp_debug("mlaa: using %u max search steps\n", val);
 
-   util_sprintf(tmp_text, "%s"
+   sprintf(tmp_text, "%s"
                 "IMM FLT32 {    %.8f,     0.0000,     0.0000,     0.0000}\n"
                 "%s\n", blend2fs_1, (float) val, blend2fs_2);
 
@@ -261,10 +240,10 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
    res.width0 = res.height0 = 165;
    res.bind = PIPE_BIND_SAMPLER_VIEW;
    res.usage = PIPE_USAGE_DEFAULT;
-   res.depth0 = res.array_size = res.nr_samples = 1;
+   res.depth0 = res.array_size = res.nr_samples = res.nr_storage_samples = 1;
 
    if (!ppq->p->screen->is_format_supported(ppq->p->screen, res.format,
-                                            res.target, 1, res.bind))
+                                            res.target, 1, 1, res.bind))
       pp_debug("Areamap format not supported\n");
 
    ppq->areamaptex = ppq->p->screen->resource_create(ppq->p->screen, &res);
@@ -352,12 +331,6 @@ pp_jimenezmlaa_color(struct pp_queue_t *ppq, struct pipe_resource *in,
 void
 pp_jimenezmlaa_free(struct pp_queue_t *ppq, unsigned int n)
 {
-   if (ppq->areamaptex) {
-      pipe_resource_reference(&ppq->areamaptex, NULL);
-   }
-
-   if (ppq->constbuf) {
-      pipe_resource_reference(&ppq->constbuf, NULL);
-   }
+   pipe_resource_reference(&ppq->areamaptex, NULL);
 }