Module: Mesa
Branch: main
Commit: 4e75e1bfec35f95543574529ff4f9723712cffc7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e75e1bfec35f95543574529ff4f9723712cffc7

Author: Karmjit Mahil <[email protected]>
Date:   Thu Jan  5 15:02:00 2023 +0000

pvr: Set SPMSCRATCHBUFFER flag.

Signed-off-by: Karmjit Mahil <[email protected]>
Reviewed-by: Frank Binns <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21102>

---

 src/imagination/vulkan/pvr_cmd_buffer.c             | 10 ++++++++++
 src/imagination/vulkan/pvr_job_render.c             |  3 +++
 src/imagination/vulkan/pvr_job_render.h             | 21 ++++++++++++---------
 src/imagination/vulkan/winsys/pvr_winsys.h          |  1 +
 .../vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c     |  3 +++
 5 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c 
b/src/imagination/vulkan/pvr_cmd_buffer.c
index c020b4b2892..4ccfc678133 100644
--- a/src/imagination/vulkan/pvr_cmd_buffer.c
+++ b/src/imagination/vulkan/pvr_cmd_buffer.c
@@ -1203,6 +1203,16 @@ static VkResult pvr_sub_cmd_gfx_job_init(const struct 
pvr_device_info *dev_info,
    job->run_frag = true;
    job->geometry_terminate = true;
 
+   /* TODO: In some cases a PR can be removed by storing to the color 
attachment
+    * and have the background object load directly from it instead of using the
+    * scratch buffer. In those cases we can also set this to "false" and avoid
+    * extra fw overhead.
+    */
+   /* The scratch buffer is always needed and allocated to avoid data loss in
+    * case SPM is hit so set the flag unconditionally.
+    */
+   job->requires_spm_scratch_buffer = true;
+
    return VK_SUCCESS;
 }
 
diff --git a/src/imagination/vulkan/pvr_job_render.c 
b/src/imagination/vulkan/pvr_job_render.c
index b772ef0dddd..32f49cbc718 100644
--- a/src/imagination/vulkan/pvr_job_render.c
+++ b/src/imagination/vulkan/pvr_job_render.c
@@ -1679,6 +1679,9 @@ static void pvr_frag_state_flags_init(const struct 
pvr_render_job *const job,
 
    if (job->get_vis_results)
       *flags |= PVR_WINSYS_FRAG_FLAG_GET_VIS_RESULTS;
+
+   if (job->requires_spm_scratch_buffer)
+      *flags |= PVR_WINSYS_FRAG_FLAG_SPMSCRATCHBUFFER;
 }
 
 static void
diff --git a/src/imagination/vulkan/pvr_job_render.h 
b/src/imagination/vulkan/pvr_job_render.h
index c7afd446bc6..e42422205af 100644
--- a/src/imagination/vulkan/pvr_job_render.h
+++ b/src/imagination/vulkan/pvr_job_render.h
@@ -45,15 +45,18 @@ struct vk_sync;
 struct pvr_render_job {
    struct pvr_rt_dataset *rt_dataset;
 
-   bool run_frag;
-   bool geometry_terminate;
-   bool frag_uses_atomic_ops;
-   bool disable_compute_overlap;
-   bool enable_bg_tag;
-   bool process_empty_tiles;
-   bool get_vis_results;
-   bool has_depth_attachment;
-   bool has_stencil_attachment;
+   struct {
+      bool run_frag : 1;
+      bool geometry_terminate : 1;
+      bool frag_uses_atomic_ops : 1;
+      bool disable_compute_overlap : 1;
+      bool enable_bg_tag : 1;
+      bool process_empty_tiles : 1;
+      bool get_vis_results : 1;
+      bool has_depth_attachment : 1;
+      bool has_stencil_attachment : 1;
+      bool requires_spm_scratch_buffer : 1;
+   };
 
    uint32_t pds_pixel_event_data_offset;
 
diff --git a/src/imagination/vulkan/winsys/pvr_winsys.h 
b/src/imagination/vulkan/winsys/pvr_winsys.h
index cb03f3727a9..880398baaf8 100644
--- a/src/imagination/vulkan/winsys/pvr_winsys.h
+++ b/src/imagination/vulkan/winsys/pvr_winsys.h
@@ -339,6 +339,7 @@ struct pvr_winsys_compute_submit_info {
 #define PVR_WINSYS_FRAG_FLAG_PREVENT_CDM_OVERLAP BITFIELD_BIT(2U)
 #define PVR_WINSYS_FRAG_FLAG_SINGLE_CORE BITFIELD_BIT(3U)
 #define PVR_WINSYS_FRAG_FLAG_GET_VIS_RESULTS BITFIELD_BIT(4U)
+#define PVR_WINSYS_FRAG_FLAG_SPMSCRATCHBUFFER (5U)
 
 struct pvr_winsys_render_submit_info {
    struct pvr_winsys_rt_dataset *rt_dataset;
diff --git a/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c 
b/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c
index 4b56c4a7512..9191da1f61c 100644
--- a/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c
+++ b/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c
@@ -662,6 +662,9 @@ static void pvr_srv_fragment_cmd_init(
 
    if (state->flags & PVR_WINSYS_FRAG_FLAG_GET_VIS_RESULTS)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_GETVISRESULTS;
+
+   if (state->flags & PVR_WINSYS_FRAG_FLAG_SPMSCRATCHBUFFER)
+      cmd->flags |= ROGUE_FWIF_RENDERFLAGS_SPMSCRATCHBUFFER;
 }
 
 VkResult pvr_srv_winsys_render_submit(

Reply via email to