nvc0: sort performance counter queries by name
[mesa.git] / src / gallium / drivers / freedreno / freedreno_state.c
index e7d783a6a561220a9014a8b4c6cdf56b357b1f2f..7bf8bdb45070691ed4cc22c2bbeaf8ded156f0dd 100644 (file)
@@ -123,12 +123,12 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
 
        fd_context_render(pctx);
 
-       util_copy_framebuffer_state(cso, framebuffer);
-
        if ((cso->width != framebuffer->width) ||
                        (cso->height != framebuffer->height))
                ctx->needs_rb_fbd = true;
 
+       util_copy_framebuffer_state(cso, framebuffer);
+
        ctx->dirty |= FD_DIRTY_FRAMEBUFFER;
 
        ctx->disabled_scissor.minx = 0;
@@ -177,7 +177,7 @@ fd_set_vertex_buffers(struct pipe_context *pctx,
                const struct pipe_vertex_buffer *vb)
 {
        struct fd_context *ctx = fd_context(pctx);
-       struct fd_vertexbuf_stateobj *so = &ctx->vertexbuf;
+       struct fd_vertexbuf_stateobj *so = &ctx->vtx.vertexbuf;
        int i;
 
        /* on a2xx, pitch is encoded in the vtx fetch instruction, so
@@ -237,8 +237,18 @@ static void
 fd_rasterizer_state_bind(struct pipe_context *pctx, void *hwcso)
 {
        struct fd_context *ctx = fd_context(pctx);
+       struct pipe_scissor_state *old_scissor = fd_context_get_scissor(ctx);
+
        ctx->rasterizer = hwcso;
        ctx->dirty |= FD_DIRTY_RASTERIZER;
+
+       /* if scissor enable bit changed we need to mark scissor
+        * state as dirty as well:
+        * NOTE: we can do a shallow compare, since we only care
+        * if it changed to/from &ctx->disable_scissor
+        */
+       if (old_scissor != fd_context_get_scissor(ctx))
+               ctx->dirty |= FD_DIRTY_SCISSOR;
 }
 
 static void
@@ -286,10 +296,71 @@ static void
 fd_vertex_state_bind(struct pipe_context *pctx, void *hwcso)
 {
        struct fd_context *ctx = fd_context(pctx);
-       ctx->vtx = hwcso;
+       ctx->vtx.vtx = hwcso;
        ctx->dirty |= FD_DIRTY_VTXSTATE;
 }
 
+static struct pipe_stream_output_target *
+fd_create_stream_output_target(struct pipe_context *pctx,
+               struct pipe_resource *prsc, unsigned buffer_offset,
+               unsigned buffer_size)
+{
+       struct pipe_stream_output_target *target;
+
+       target = CALLOC_STRUCT(pipe_stream_output_target);
+       if (!target)
+               return NULL;
+
+       pipe_reference_init(&target->reference, 1);
+       pipe_resource_reference(&target->buffer, prsc);
+
+       target->context = pctx;
+       target->buffer_offset = buffer_offset;
+       target->buffer_size = buffer_size;
+
+       return target;
+}
+
+static void
+fd_stream_output_target_destroy(struct pipe_context *pctx,
+               struct pipe_stream_output_target *target)
+{
+       pipe_resource_reference(&target->buffer, NULL);
+       FREE(target);
+}
+
+static void
+fd_set_stream_output_targets(struct pipe_context *pctx,
+               unsigned num_targets, struct pipe_stream_output_target **targets,
+               const unsigned *offsets)
+{
+       struct fd_context *ctx = fd_context(pctx);
+       struct fd_streamout_stateobj *so = &ctx->streamout;
+       unsigned i;
+
+       debug_assert(num_targets <= ARRAY_SIZE(so->targets));
+
+       for (i = 0; i < num_targets; i++) {
+               boolean changed = targets[i] != so->targets[i];
+               boolean append = (offsets[i] == (unsigned)-1);
+
+               if (!changed && append)
+                       continue;
+
+               so->offsets[i] = 0;
+
+               pipe_so_target_reference(&so->targets[i], targets[i]);
+       }
+
+       for (; i < so->num_targets; i++) {
+               pipe_so_target_reference(&so->targets[i], NULL);
+       }
+
+       so->num_targets = num_targets;
+
+       ctx->dirty |= FD_DIRTY_STREAMOUT;
+}
+
 void
 fd_state_init(struct pipe_context *pctx)
 {
@@ -318,4 +389,8 @@ fd_state_init(struct pipe_context *pctx)
        pctx->create_vertex_elements_state = fd_vertex_state_create;
        pctx->delete_vertex_elements_state = fd_vertex_state_delete;
        pctx->bind_vertex_elements_state = fd_vertex_state_bind;
+
+       pctx->create_stream_output_target = fd_create_stream_output_target;
+       pctx->stream_output_target_destroy = fd_stream_output_target_destroy;
+       pctx->set_stream_output_targets = fd_set_stream_output_targets;
 }