pvr: Change winsys flag defines to bitfields
authorKarmjit Mahil <Karmjit.Mahil@imgtec.com>
Wed, 14 Jun 2023 14:44:10 +0000 (15:44 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 27 Jun 2023 11:11:03 +0000 (11:11 +0000)
Makes it easier to see which flags are set while debugging, and
prevent errors where the `BITFIELD_BIT()` is missing or using the
wrong flag for something.

Some fields have also been renamed to better fit with the naming
scheme around the code base.

Signed-off-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23765>

src/imagination/vulkan/pvr_job_compute.c
src/imagination/vulkan/pvr_job_render.c
src/imagination/vulkan/pvr_job_transfer.c
src/imagination/vulkan/winsys/pvr_winsys.h
src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_compute.c
src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_render.c
src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_transfer.c

index ef00dd6..0436dcd 100644 (file)
@@ -162,17 +162,13 @@ static void pvr_submit_info_ext_stream_init(
 static void
 pvr_submit_info_flags_init(const struct pvr_device_info *const dev_info,
                            const struct pvr_sub_cmd_compute *const sub_cmd,
-                           uint32_t *const flags)
+                           struct pvr_winsys_compute_submit_flags *flags)
 {
-   *flags = 0;
-
-   if (sub_cmd->uses_barrier)
-      *flags |= PVR_WINSYS_COMPUTE_FLAG_PREVENT_ALL_OVERLAP;
-
-   if (PVR_HAS_FEATURE(dev_info, gpu_multicore_support) &&
-       sub_cmd->uses_atomic_ops) {
-      *flags |= PVR_WINSYS_COMPUTE_FLAG_SINGLE_CORE;
-   }
+   *flags = (struct pvr_winsys_compute_submit_flags){
+      .prevent_all_overlap = sub_cmd->uses_barrier,
+      .use_single_core = PVR_HAS_FEATURE(dev_info, gpu_multicore_support) &&
+                         sub_cmd->uses_atomic_ops,
+   };
 }
 
 static void pvr_compute_job_ws_submit_info_init(
index d325e1f..7f8d169 100644 (file)
@@ -1028,19 +1028,15 @@ pvr_geom_state_stream_ext_init(struct pvr_render_ctx *ctx,
       state->fw_ext_stream_len = 0;
 }
 
-static void pvr_geom_state_flags_init(const struct pvr_render_job *const job,
-                                      uint32_t *const flags)
+static void
+pvr_geom_state_flags_init(const struct pvr_render_job *const job,
+                          struct pvr_winsys_geometry_state_flags *flags)
 {
-   *flags = 0;
-
-   if (!job->rt_dataset->need_frag)
-      *flags |= PVR_WINSYS_GEOM_FLAG_FIRST_GEOMETRY;
-
-   if (job->geometry_terminate)
-      *flags |= PVR_WINSYS_GEOM_FLAG_LAST_GEOMETRY;
-
-   if (job->frag_uses_atomic_ops)
-      *flags |= PVR_WINSYS_GEOM_FLAG_SINGLE_CORE;
+   *flags = (struct pvr_winsys_geometry_state_flags){
+      .is_first_geometry = !job->rt_dataset->need_frag,
+      .is_last_geometry = job->geometry_terminate,
+      .use_single_core = job->frag_uses_atomic_ops,
+   };
 }
 
 static void
@@ -1405,28 +1401,18 @@ pvr_frag_state_stream_ext_init(struct pvr_render_ctx *ctx,
       state->fw_ext_stream_len = 0;
 }
 
-static void pvr_frag_state_flags_init(const struct pvr_render_job *const job,
-                                      uint32_t *const flags)
+static void
+pvr_frag_state_flags_init(const struct pvr_render_job *const job,
+                          struct pvr_winsys_fragment_state_flags *flags)
 {
-   *flags = 0;
-
-   if (job->has_depth_attachment)
-      *flags |= PVR_WINSYS_FRAG_FLAG_DEPTH_BUFFER_PRESENT;
-
-   if (job->has_stencil_attachment)
-      *flags |= PVR_WINSYS_FRAG_FLAG_STENCIL_BUFFER_PRESENT;
-
-   if (job->disable_compute_overlap)
-      *flags |= PVR_WINSYS_FRAG_FLAG_PREVENT_CDM_OVERLAP;
-
-   if (job->frag_uses_atomic_ops)
-      *flags |= PVR_WINSYS_FRAG_FLAG_SINGLE_CORE;
-
-   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;
+   *flags = (struct pvr_winsys_fragment_state_flags){
+      .has_depth_buffer = job->has_depth_attachment,
+      .has_stencil_buffer = job->has_stencil_attachment,
+      .prevent_cdm_overlap = job->disable_compute_overlap,
+      .use_single_core = job->frag_uses_atomic_ops,
+      .get_vis_results = job->get_vis_results,
+      .has_spm_scratch_buffer = job->requires_spm_scratch_buffer,
+   };
 }
 
 static void
index f40eac7..e316c00 100644 (file)
@@ -163,7 +163,7 @@ struct pvr_transfer_3d_state {
 };
 
 struct pvr_transfer_prep_data {
-   uint32_t flags;
+   struct pvr_winsys_transfer_cmd_flags flags;
    struct pvr_transfer_3d_state state;
 };
 
@@ -5740,12 +5740,10 @@ pvr_submit_info_stream_init(struct pvr_transfer_ctx *ctx,
 static void
 pvr_submit_info_flags_init(const struct pvr_device_info *const dev_info,
                            const struct pvr_transfer_prep_data *const prep_data,
-                           uint32_t *const flags)
+                           struct pvr_winsys_transfer_cmd_flags *flags)
 {
    *flags = prep_data->flags;
-
-   if (PVR_HAS_FEATURE(dev_info, gpu_multicore_support))
-      *flags |= PVR_WINSYS_TRANSFER_FLAG_SINGLE_CORE;
+   flags->use_single_core = PVR_HAS_FEATURE(dev_info, gpu_multicore_support);
 }
 
 static void pvr_transfer_job_ws_submit_info_init(
index f20a277..64ffa7b 100644 (file)
@@ -240,8 +240,6 @@ struct pvr_winsys_transfer_ctx {
    struct pvr_winsys *ws;
 };
 
-#define PVR_WINSYS_TRANSFER_FLAG_SINGLE_CORE BITFIELD_BIT(0U)
-
 #define PVR_TRANSFER_MAX_PREPARES_PER_SUBMIT 16U
 #define PVR_TRANSFER_MAX_RENDER_TARGETS 3U
 
@@ -277,8 +275,9 @@ struct pvr_winsys_transfer_cmd {
    uint8_t fw_stream[172];
    uint32_t fw_stream_len;
 
-   /* Must be 0 or a combination of PVR_WINSYS_TRANSFER_FLAG_* flags. */
-   uint32_t flags;
+   struct pvr_winsys_transfer_cmd_flags {
+      bool use_single_core : 1;
+   } flags;
 };
 
 struct pvr_winsys_transfer_submit_info {
@@ -291,9 +290,6 @@ struct pvr_winsys_transfer_submit_info {
    struct pvr_winsys_transfer_cmd cmds[PVR_TRANSFER_MAX_PREPARES_PER_SUBMIT];
 };
 
-#define PVR_WINSYS_COMPUTE_FLAG_PREVENT_ALL_OVERLAP BITFIELD_BIT(0U)
-#define PVR_WINSYS_COMPUTE_FLAG_SINGLE_CORE BITFIELD_BIT(1U)
-
 struct pvr_winsys_compute_submit_info {
    uint32_t frame_num;
    uint32_t job_num;
@@ -312,21 +308,12 @@ struct pvr_winsys_compute_submit_info {
    uint8_t fw_ext_stream[8];
    uint32_t fw_ext_stream_len;
 
-   /* Must be 0 or a combination of PVR_WINSYS_COMPUTE_FLAG_* flags. */
-   uint32_t flags;
+   struct pvr_winsys_compute_submit_flags {
+      bool prevent_all_overlap : 1;
+      bool use_single_core : 1;
+   } flags;
 };
 
-#define PVR_WINSYS_GEOM_FLAG_FIRST_GEOMETRY BITFIELD_BIT(0U)
-#define PVR_WINSYS_GEOM_FLAG_LAST_GEOMETRY BITFIELD_BIT(1U)
-#define PVR_WINSYS_GEOM_FLAG_SINGLE_CORE BITFIELD_BIT(2U)
-
-#define PVR_WINSYS_FRAG_FLAG_DEPTH_BUFFER_PRESENT BITFIELD_BIT(0U)
-#define PVR_WINSYS_FRAG_FLAG_STENCIL_BUFFER_PRESENT BITFIELD_BIT(1U)
-#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 BITFIELD_BIT(5U)
-
 struct pvr_winsys_render_submit_info {
    struct pvr_winsys_rt_dataset *rt_dataset;
    uint8_t rt_data_idx;
@@ -350,8 +337,11 @@ struct pvr_winsys_render_submit_info {
       uint8_t fw_ext_stream[12];
       uint32_t fw_ext_stream_len;
 
-      /* Must be 0 or a combination of PVR_WINSYS_GEOM_FLAG_* flags. */
-      uint32_t flags;
+      struct pvr_winsys_geometry_state_flags {
+         bool is_first_geometry : 1;
+         bool is_last_geometry : 1;
+         bool use_single_core : 1;
+      } flags;
 
       struct vk_sync *wait;
    } geometry;
@@ -369,8 +359,14 @@ struct pvr_winsys_render_submit_info {
       uint8_t fw_ext_stream[8];
       uint32_t fw_ext_stream_len;
 
-      /* Must be 0 or a combination of PVR_WINSYS_FRAG_FLAG_* flags. */
-      uint32_t flags;
+      struct pvr_winsys_fragment_state_flags {
+         bool has_depth_buffer : 1;
+         bool has_stencil_buffer : 1;
+         bool prevent_cdm_overlap : 1;
+         bool use_single_core : 1;
+         bool get_vis_results : 1;
+         bool has_spm_scratch_buffer : 1;
+      } flags;
 
       struct vk_sync *wait;
    } fragment;
index b468c58..89cc9cb 100644 (file)
@@ -219,10 +219,10 @@ static void pvr_srv_compute_cmd_init(
                                           dev_info);
    }
 
-   if (submit_info->flags & PVR_WINSYS_COMPUTE_FLAG_PREVENT_ALL_OVERLAP)
+   if (submit_info->flags.prevent_all_overlap)
       cmd->flags |= ROGUE_FWIF_COMPUTE_FLAG_PREVENT_ALL_OVERLAP;
 
-   if (submit_info->flags & PVR_WINSYS_COMPUTE_FLAG_SINGLE_CORE)
+   if (submit_info->flags.use_single_core)
       cmd->flags |= ROGUE_FWIF_COMPUTE_FLAG_SINGLE_CORE;
 }
 
index 8c62cf8..4fa6dc7 100644 (file)
@@ -711,13 +711,13 @@ static void pvr_srv_geometry_cmd_init(
                                            dev_info);
    }
 
-   if (state->flags & PVR_WINSYS_GEOM_FLAG_FIRST_GEOMETRY)
+   if (state->flags.is_first_geometry)
       cmd->flags |= ROGUE_FWIF_TAFLAGS_FIRSTKICK;
 
-   if (state->flags & PVR_WINSYS_GEOM_FLAG_LAST_GEOMETRY)
+   if (state->flags.is_last_geometry)
       cmd->flags |= ROGUE_FWIF_TAFLAGS_LASTKICK;
 
-   if (state->flags & PVR_WINSYS_GEOM_FLAG_SINGLE_CORE)
+   if (state->flags.use_single_core)
       cmd->flags |= ROGUE_FWIF_TAFLAGS_SINGLE_CORE;
 
    cmd->partial_render_ta_3d_fence.ufo_addr.addr =
@@ -880,22 +880,22 @@ static void pvr_srv_fragment_cmd_init(
                                            dev_info);
    }
 
-   if (state->flags & PVR_WINSYS_FRAG_FLAG_DEPTH_BUFFER_PRESENT)
+   if (state->flags.has_depth_buffer)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_DEPTHBUFFER;
 
-   if (state->flags & PVR_WINSYS_FRAG_FLAG_STENCIL_BUFFER_PRESENT)
+   if (state->flags.has_stencil_buffer)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_STENCILBUFFER;
 
-   if (state->flags & PVR_WINSYS_FRAG_FLAG_PREVENT_CDM_OVERLAP)
+   if (state->flags.prevent_cdm_overlap)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_PREVENT_CDM_OVERLAP;
 
-   if (state->flags & PVR_WINSYS_FRAG_FLAG_SINGLE_CORE)
+   if (state->flags.use_single_core)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_SINGLE_CORE;
 
-   if (state->flags & PVR_WINSYS_FRAG_FLAG_GET_VIS_RESULTS)
+   if (state->flags.get_vis_results)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_GETVISRESULTS;
 
-   if (state->flags & PVR_WINSYS_FRAG_FLAG_SPMSCRATCHBUFFER)
+   if (state->flags.has_spm_scratch_buffer)
       cmd->flags |= ROGUE_FWIF_RENDERFLAGS_SPMSCRATCHBUFFER;
 }
 
@@ -973,7 +973,7 @@ VkResult pvr_srv_winsys_render_submit(
       }
    }
 
-   if (submit_info->geometry.flags & PVR_WINSYS_GEOM_FLAG_FIRST_GEOMETRY) {
+   if (submit_info->geometry.flags.is_first_geometry) {
       frag_to_geom_fence_count = 1;
       frag_to_geom_fence_value = current_sync_value;
    }
index 437bd68..d33abc9 100644 (file)
@@ -230,7 +230,7 @@ static void pvr_srv_transfer_cmds_init(
                                        submit_cmd->fw_stream_len,
                                        dev_info);
 
-      if (submit_info->cmds[i].flags & PVR_WINSYS_TRANSFER_FLAG_SINGLE_CORE)
+      if (submit_info->cmds[i].flags.use_single_core)
          cmd->flags |= ROGUE_FWIF_CMDTRANSFER_SINGLE_CORE;
    }
 }