pvr: Add pvr_csb_emit_link function to support secondary buffer links.
authorRajnesh Kanwal <rajnesh.kanwal@imgtec.com>
Wed, 21 Sep 2022 15:18:19 +0000 (16:18 +0100)
committerRajnesh Kanwal <rajnesh.kanwal@imgtec.com>
Mon, 3 Oct 2022 11:30:51 +0000 (16:30 +0500)
Signed-off-by: Rajnesh Kanwal <rajnesh.kanwal@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18871>

src/imagination/vulkan/pvr_csb.c
src/imagination/vulkan/pvr_csb.h

index 64c734d..9c05f22 100644 (file)
@@ -154,33 +154,7 @@ static bool pvr_csb_buffer_extend(struct pvr_csb *csb)
       csb->end += stream_link_space;
       assert(csb->next + stream_link_space <= csb->end);
 
-      switch (csb->stream_type) {
-      case PVR_CMD_STREAM_TYPE_GRAPHICS:
-         pvr_csb_emit (csb, VDMCTRL_STREAM_LINK0, link) {
-            link.link_addrmsb = pvr_bo->vma->dev_addr;
-         }
-
-         pvr_csb_emit (csb, VDMCTRL_STREAM_LINK1, link) {
-            link.link_addrlsb = pvr_bo->vma->dev_addr;
-         }
-
-         break;
-
-      case PVR_CMD_STREAM_TYPE_COMPUTE:
-         pvr_csb_emit (csb, CDMCTRL_STREAM_LINK0, link) {
-            link.link_addrmsb = pvr_bo->vma->dev_addr;
-         }
-
-         pvr_csb_emit (csb, CDMCTRL_STREAM_LINK1, link) {
-            link.link_addrlsb = pvr_bo->vma->dev_addr;
-         }
-
-         break;
-
-      default:
-         unreachable("Unknown stream type");
-         break;
-      }
+      pvr_csb_emit_link(csb, pvr_bo->vma->dev_addr, false);
    }
 
    csb->pvr_bo = pvr_bo;
@@ -230,6 +204,50 @@ void *pvr_csb_alloc_dwords(struct pvr_csb *csb, uint32_t num_dwords)
 }
 
 /**
+ * \brief Adds VDMCTRL_STREAM_LINK/CDMCTRL_STREAM_LINK dwords into the control
+ * stream pointed by csb object.
+ *
+ * \param[in] csb  Control Stream Builder object to add LINK dwords to.
+ * \param[in] addr Device virtual address of the sub control stream to link to.
+ * \param[in] ret  Selects whether the sub control stream will return or
+ *                 terminate.
+ */
+void pvr_csb_emit_link(struct pvr_csb *csb, pvr_dev_addr_t addr, bool ret)
+{
+   /* Stream return is only supported for graphics control stream. */
+   assert(!ret || csb->stream_type == PVR_CMD_STREAM_TYPE_GRAPHICS);
+
+   switch (csb->stream_type) {
+   case PVR_CMD_STREAM_TYPE_GRAPHICS:
+      pvr_csb_emit (csb, VDMCTRL_STREAM_LINK0, link) {
+         link.link_addrmsb = addr;
+         link.with_return = ret;
+      }
+
+      pvr_csb_emit (csb, VDMCTRL_STREAM_LINK1, link) {
+         link.link_addrlsb = addr;
+      }
+
+      break;
+
+   case PVR_CMD_STREAM_TYPE_COMPUTE:
+      pvr_csb_emit (csb, CDMCTRL_STREAM_LINK0, link) {
+         link.link_addrmsb = addr;
+      }
+
+      pvr_csb_emit (csb, CDMCTRL_STREAM_LINK1, link) {
+         link.link_addrlsb = addr;
+      }
+
+      break;
+
+   default:
+      unreachable("Unknown stream type");
+      break;
+   }
+}
+
+/**
  * \brief Adds VDMCTRL_STREAM_RETURN dword into the control stream pointed by
  * csb object. Given a VDMCTRL_STREAM_RETURN marks the end of the sub control
  * stream, we return the status of the control stream as well.
index 3bb1061..3695f23 100644 (file)
@@ -123,6 +123,7 @@ void pvr_csb_init(struct pvr_device *device,
                   struct pvr_csb *csb);
 void pvr_csb_finish(struct pvr_csb *csb);
 void *pvr_csb_alloc_dwords(struct pvr_csb *csb, uint32_t num_dwords);
+void pvr_csb_emit_link(struct pvr_csb *csb, pvr_dev_addr_t addr, bool ret);
 VkResult pvr_csb_emit_return(struct pvr_csb *csb);
 VkResult pvr_csb_emit_terminate(struct pvr_csb *csb);