freedreno/ir3: debug cleanup
[mesa.git] / src / gallium / drivers / freedreno / freedreno_state.c
index 76b54a56044022dedaaf58c66e2a7a4b1cffe416..4f315488d1b39eafcbe8cc95ee34b00a17a984ae 100644 (file)
@@ -78,6 +78,14 @@ fd_set_sample_mask(struct pipe_context *pctx, unsigned sample_mask)
        ctx->dirty |= FD_DIRTY_SAMPLE_MASK;
 }
 
+static void
+fd_set_min_samples(struct pipe_context *pctx, unsigned min_samples)
+{
+       struct fd_context *ctx = fd_context(pctx);
+       ctx->min_samples = min_samples;
+       ctx->dirty |= FD_DIRTY_MIN_SAMPLES;
+}
+
 /* notes from calim on #dri-devel:
  * index==0 will be non-UBO (ie. glUniformXYZ()) all packed together padded
  * out to vec4's
@@ -113,7 +121,8 @@ static void
 fd_set_shader_buffers(struct pipe_context *pctx,
                enum pipe_shader_type shader,
                unsigned start, unsigned count,
-               const struct pipe_shader_buffer *buffers)
+               const struct pipe_shader_buffer *buffers,
+               unsigned writable_bitmask)
 {
        struct fd_context *ctx = fd_context(pctx);
        struct fd_shaderbuf_stateobj *so = &ctx->shaderbuf[shader];
@@ -156,7 +165,7 @@ fd_set_shader_buffers(struct pipe_context *pctx,
        ctx->dirty_shader[shader] |= FD_DIRTY_SHADER_SSBO;
 }
 
-static void
+void
 fd_set_shader_images(struct pipe_context *pctx,
                enum pipe_shader_type shader,
                unsigned start, unsigned count,
@@ -239,14 +248,14 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
                         * multiple times to the same surface), so we might as
                         * well go ahead and flush this one:
                         */
-                       fd_batch_flush(old_batch, false, false);
+                       fd_batch_flush(old_batch, false);
                }
 
                fd_batch_reference(&old_batch, NULL);
        } else {
                DBG("%d: cbufs[0]=%p, zsbuf=%p", ctx->batch->needs_flush,
                                framebuffer->cbufs[0], framebuffer->zsbuf);
-               fd_batch_flush(ctx->batch, false, false);
+               fd_batch_flush(ctx->batch, false);
                util_copy_framebuffer_state(&ctx->batch->framebuffer, cso);
        }
 
@@ -288,7 +297,36 @@ fd_set_viewport_states(struct pipe_context *pctx,
                const struct pipe_viewport_state *viewport)
 {
        struct fd_context *ctx = fd_context(pctx);
+       struct pipe_scissor_state *scissor = &ctx->viewport_scissor;
+       float minx, miny, maxx, maxy;
+
        ctx->viewport = *viewport;
+
+       /* see si_get_scissor_from_viewport(): */
+
+       /* Convert (-1, -1) and (1, 1) from clip space into window space. */
+       minx = -viewport->scale[0] + viewport->translate[0];
+       miny = -viewport->scale[1] + viewport->translate[1];
+       maxx = viewport->scale[0] + viewport->translate[0];
+       maxy = viewport->scale[1] + viewport->translate[1];
+
+       /* Handle inverted viewports. */
+       if (minx > maxx) {
+               swap(minx, maxx);
+       }
+       if (miny > maxy) {
+               swap(miny, maxy);
+       }
+
+       debug_assert(miny >= 0);
+       debug_assert(maxy >= 0);
+
+       /* Convert to integer and round up the max bounds. */
+       scissor->minx = minx;
+       scissor->miny = miny;
+       scissor->maxx = ceilf(maxx);
+       scissor->maxy = ceilf(maxy);
+
        ctx->dirty |= FD_DIRTY_VIEWPORT;
 }
 
@@ -434,7 +472,7 @@ fd_create_stream_output_target(struct pipe_context *pctx,
        target->buffer_size = buffer_size;
 
        assert(rsc->base.target == PIPE_BUFFER);
-       util_range_add(&rsc->valid_buffer_range,
+       util_range_add(&rsc->base, &rsc->valid_buffer_range,
                buffer_offset, buffer_offset + buffer_size);
 
        return target;
@@ -461,12 +499,14 @@ fd_set_stream_output_targets(struct pipe_context *pctx,
 
        for (i = 0; i < num_targets; i++) {
                boolean changed = targets[i] != so->targets[i];
-               boolean append = (offsets[i] == (unsigned)-1);
+               boolean reset = (offsets[i] != (unsigned)-1);
+
+               so->reset |= (reset << i);
 
-               if (!changed && append)
+               if (!changed && !reset)
                        continue;
 
-               if (!append)
+               if (reset)
                        so->offsets[i] = offsets[i];
 
                pipe_so_target_reference(&so->targets[i], targets[i]);
@@ -552,6 +592,7 @@ fd_state_init(struct pipe_context *pctx)
        pctx->set_stencil_ref = fd_set_stencil_ref;
        pctx->set_clip_state = fd_set_clip_state;
        pctx->set_sample_mask = fd_set_sample_mask;
+       pctx->set_min_samples = fd_set_min_samples;
        pctx->set_constant_buffer = fd_set_constant_buffer;
        pctx->set_shader_buffers = fd_set_shader_buffers;
        pctx->set_shader_images = fd_set_shader_images;