panfrost/midgard: Add ult/ule ops
[mesa.git] / src / gallium / drivers / panfrost / pan_context.c
index 8c4502b1cd8c7a7fb3f5cb51e1dae104738b1740..fd1fa7f328bd5ad52666708d26cd5503b5e20e3e 100644 (file)
@@ -1062,9 +1062,11 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
         /* For flipped-Y buffers (signaled by negative scale), the translate is
          * flipped as well */
 
-        float translate_y =
-                vp->scale[1] >= 0.0 ? vp->translate[1] :
-                (ctx->pipe_framebuffer.height - vp->translate[1]);
+        bool invert_y = vp->scale[1] < 0.0;
+        float translate_y = vp->translate[1];
+
+        if (invert_y)
+                translate_y = ctx->pipe_framebuffer.height - translate_y;
 
         float viewport_vec4[] = {
                 vp->scale[0],
@@ -1161,11 +1163,19 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
         view.viewport0[1] = (int) (translate_y - fabs(vp->scale[1]));
         view.viewport1[1] = MALI_POSITIVE((int) (translate_y + fabs(vp->scale[1])));
 
-        if (ss && ctx->rasterizer && ctx->rasterizer->base.scissor && 0) {
+        if (ss && ctx->rasterizer && ctx->rasterizer->base.scissor) {
+                /* Invert scissor if needed */
+                unsigned miny = invert_y ?
+                        ctx->pipe_framebuffer.height - ss->maxy : ss->miny;
+
+                unsigned maxy = invert_y ?
+                        ctx->pipe_framebuffer.height - ss->miny : ss->maxy;
+
+                /* Set the actual scissor */
                 view.viewport0[0] = ss->minx;
-                view.viewport0[1] = ss->miny;
+                view.viewport0[1] = miny;
                 view.viewport1[0] = MALI_POSITIVE(ss->maxx);
-                view.viewport1[1] = MALI_POSITIVE(ss->maxy);
+                view.viewport1[1] = MALI_POSITIVE(maxy);
         } 
 
         ctx->payload_tiler.postfix.viewport =
@@ -2393,6 +2403,46 @@ panfrost_get_query_result(struct pipe_context *pipe,
         return true;
 }
 
+static struct pipe_stream_output_target *
+panfrost_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
+panfrost_stream_output_target_destroy(struct pipe_context *pctx,
+                                 struct pipe_stream_output_target *target)
+{
+        pipe_resource_reference(&target->buffer, NULL);
+        free(target);
+}
+
+static void
+panfrost_set_stream_output_targets(struct pipe_context *pctx,
+                              unsigned num_targets,
+                              struct pipe_stream_output_target **targets,
+                              const unsigned *offsets)
+{
+        /* STUB */
+}
+
 static void
 panfrost_setup_hardware(struct panfrost_context *ctx)
 {
@@ -2497,6 +2547,10 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
         gallium->end_query = panfrost_end_query;
         gallium->get_query_result = panfrost_get_query_result;
 
+        gallium->create_stream_output_target = panfrost_create_stream_output_target;
+        gallium->stream_output_target_destroy = panfrost_stream_output_target_destroy;
+        gallium->set_stream_output_targets = panfrost_set_stream_output_targets;
+
         panfrost_resource_context_init(gallium);
 
         pscreen->driver->init_context(ctx);