panfrost: Derive texture/sampler_count from shader
[mesa.git] / src / gallium / drivers / freedreno / freedreno_context.c
index 4572147c4e72e4471f596436f5044471f8fb2dd1..e783a8ac71599a29de7d4a072c395a94afd02800 100644 (file)
@@ -60,7 +60,8 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
         * not an "fd" fence, which results in eglDupNativeFenceFDANDROID()
         * errors.
         */
-       if (flags & PIPE_FLUSH_FENCE_FD)
+       if ((flags & PIPE_FLUSH_FENCE_FD) && ctx->last_fence &&
+                       !fd_fence_is_fd(ctx->last_fence))
                fd_fence_ref(&ctx->last_fence, NULL);
 
        /* if no rendering since last flush, ie. app just decided it needed
@@ -138,31 +139,11 @@ fd_memory_barrier(struct pipe_context *pctx, unsigned flags)
        /* TODO do we need to check for persistently mapped buffers and fd_bo_cpu_prep()?? */
 }
 
-/**
- * emit marker string as payload of a no-op packet, which can be
- * decoded by cffdump.
- */
 static void
-fd_emit_string_marker(struct pipe_context *pctx, const char *string, int len)
+emit_string_tail(struct fd_ringbuffer *ring, const char *string, int len)
 {
-       struct fd_context *ctx = fd_context(pctx);
-       struct fd_ringbuffer *ring;
        const uint32_t *buf = (const void *)string;
 
-       if (!ctx->batch)
-               return;
-
-       ctx->batch->needs_flush = true;
-
-       ring = ctx->batch->draw;
-
-       /* max packet size is 0x3fff dwords: */
-       len = MIN2(len, 0x3fff * 4);
-
-       if (ctx->screen->gpu_id >= 500)
-               OUT_PKT7(ring, CP_NOP, align(len, 4) / 4);
-       else
-               OUT_PKT3(ring, CP_NOP, align(len, 4) / 4);
        while (len >= 4) {
                OUT_RING(ring, *buf);
                buf++;
@@ -177,6 +158,51 @@ fd_emit_string_marker(struct pipe_context *pctx, const char *string, int len)
        }
 }
 
+/* for prior to a5xx: */
+void
+fd_emit_string(struct fd_ringbuffer *ring,
+               const char *string, int len)
+{
+       /* max packet size is 0x3fff+1 dwords: */
+       len = MIN2(len, 0x4000 * 4);
+
+       OUT_PKT3(ring, CP_NOP, align(len, 4) / 4);
+       emit_string_tail(ring, string, len);
+}
+
+/* for a5xx+ */
+void
+fd_emit_string5(struct fd_ringbuffer *ring,
+               const char *string, int len)
+{
+       /* max packet size is 0x3fff dwords: */
+       len = MIN2(len, 0x3fff * 4);
+
+       OUT_PKT7(ring, CP_NOP, align(len, 4) / 4);
+       emit_string_tail(ring, string, len);
+}
+
+/**
+ * emit marker string as payload of a no-op packet, which can be
+ * decoded by cffdump.
+ */
+static void
+fd_emit_string_marker(struct pipe_context *pctx, const char *string, int len)
+{
+       struct fd_context *ctx = fd_context(pctx);
+
+       if (!ctx->batch)
+               return;
+
+       ctx->batch->needs_flush = true;
+
+       if (ctx->screen->gpu_id >= 500) {
+               fd_emit_string5(ctx->batch->draw, string, len);
+       } else {
+               fd_emit_string(ctx->batch->draw, string, len);
+       }
+}
+
 void
 fd_context_destroy(struct pipe_context *pctx)
 {
@@ -402,6 +428,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
        pctx->get_device_reset_status = fd_get_device_reset_status;
        pctx->create_fence_fd = fd_create_fence_fd;
        pctx->fence_server_sync = fd_fence_server_sync;
+       pctx->fence_server_signal = fd_fence_server_signal;
        pctx->texture_barrier = fd_texture_barrier;
        pctx->memory_barrier = fd_memory_barrier;