~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/imagination/vulkan/pvr_job_compute.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "pvr_job_context.h"
33
33
#include "pvr_job_compute.h"
34
34
#include "pvr_private.h"
 
35
#include "pvr_types.h"
35
36
#include "pvr_winsys.h"
36
37
#include "util/macros.h"
37
38
 
40
41
                            struct pvr_sub_cmd_compute *sub_cmd,
41
42
                            struct pvr_winsys_compute_submit_info *submit_info)
42
43
{
43
 
   const struct pvr_physical_device *const pdevice = ctx->device->pdevice;
 
44
   const struct pvr_device *const device = ctx->device;
 
45
   const struct pvr_physical_device *const pdevice = device->pdevice;
44
46
   const struct pvr_device_runtime_info *const dev_runtime_info =
45
47
      &pdevice->dev_runtime_info;
46
48
   const struct pvr_device_info *const dev_info = &pdevice->dev_info;
47
49
   const struct pvr_compute_ctx_switch *const ctx_switch = &ctx->ctx_switch;
48
50
 
49
51
   uint32_t *stream_ptr = (uint32_t *)submit_info->fw_stream;
50
 
 
51
 
   /* FIXME: Need to set up the border color table at device creation time. Set
52
 
    * to invalid for the time being.
53
 
    */
 
52
   uint32_t *stream_len_ptr = stream_ptr;
 
53
 
 
54
   /* Leave space for stream header. */
 
55
   stream_ptr += pvr_cmd_length(KMD_STREAM_HDR);
 
56
 
54
57
   pvr_csb_pack ((uint64_t *)stream_ptr,
55
58
                 CR_TPU_BORDER_COLOUR_TABLE_CDM,
56
59
                 value) {
57
 
      value.border_colour_table_address = PVR_DEV_ADDR_INVALID;
 
60
      value.border_colour_table_address =
 
61
         device->border_color_table.table->vma->dev_addr;
58
62
   }
59
63
   stream_ptr += pvr_cmd_length(CR_TPU_BORDER_COLOUR_TABLE_CDM);
60
64
 
69
73
   stream_ptr += pvr_cmd_length(CR_CDM_CONTEXT_STATE_BASE);
70
74
 
71
75
   pvr_csb_pack (stream_ptr, CR_CDM_CONTEXT_PDS1, state) {
72
 
      /* Convert the data size from dwords to bytes. */
73
76
      const uint32_t load_program_data_size =
74
 
         ctx_switch->sr[0].pds.load_program.data_size * 4U;
 
77
         PVR_DW_TO_BYTES(ctx_switch->sr[0].pds.load_program.data_size);
75
78
 
76
79
      state.pds_seq_dep = false;
77
80
      state.usc_seq_dep = false;
123
126
      stream_ptr++;
124
127
   }
125
128
 
126
 
   submit_info->fw_stream_len = (uint8_t *)stream_ptr - submit_info->fw_stream;
 
129
   submit_info->fw_stream_len =
 
130
      (uint8_t *)stream_ptr - (uint8_t *)submit_info->fw_stream;
127
131
   assert(submit_info->fw_stream_len <= ARRAY_SIZE(submit_info->fw_stream));
 
132
 
 
133
   pvr_csb_pack ((uint64_t *)stream_len_ptr, KMD_STREAM_HDR, value) {
 
134
      value.length = submit_info->fw_stream_len;
 
135
   }
128
136
}
129
137
 
130
138
static void pvr_submit_info_ext_stream_init(
134
142
   const struct pvr_device_info *const dev_info =
135
143
      &ctx->device->pdevice->dev_info;
136
144
 
137
 
   uint32_t *ext_stream_ptr = (uint32_t *)submit_info->fw_ext_stream;
 
145
   uint32_t *stream_ptr = (uint32_t *)submit_info->fw_stream;
 
146
   uint32_t main_stream_len =
 
147
      pvr_csb_unpack((uint64_t *)stream_ptr, KMD_STREAM_HDR).length;
 
148
   uint32_t *ext_stream_ptr =
 
149
      (uint32_t *)((uint8_t *)stream_ptr + main_stream_len);
138
150
   uint32_t *header0_ptr;
139
151
 
140
152
   header0_ptr = ext_stream_ptr;
141
 
   ext_stream_ptr += pvr_cmd_length(FW_STREAM_EXTHDR_COMPUTE0);
 
153
   ext_stream_ptr += pvr_cmd_length(KMD_STREAM_EXTHDR_COMPUTE0);
142
154
 
143
 
   pvr_csb_pack (header0_ptr, FW_STREAM_EXTHDR_COMPUTE0, header0) {
 
155
   pvr_csb_pack (header0_ptr, KMD_STREAM_EXTHDR_COMPUTE0, header0) {
144
156
      if (PVR_HAS_QUIRK(dev_info, 49927)) {
145
157
         header0.has_brn49927 = true;
146
158
 
151
163
      }
152
164
   }
153
165
 
154
 
   submit_info->fw_ext_stream_len =
155
 
      (uint8_t *)ext_stream_ptr - submit_info->fw_ext_stream;
156
 
   assert(submit_info->fw_ext_stream_len <=
157
 
          ARRAY_SIZE(submit_info->fw_ext_stream));
158
 
 
159
 
   if ((*header0_ptr & PVRX(FW_STREAM_EXTHDR_DATA_MASK)) == 0)
160
 
      submit_info->fw_ext_stream_len = 0;
 
166
   if ((*header0_ptr & PVRX(KMD_STREAM_EXTHDR_DATA_MASK)) != 0) {
 
167
      submit_info->fw_stream_len =
 
168
         (uint8_t *)ext_stream_ptr - (uint8_t *)submit_info->fw_stream;
 
169
      assert(submit_info->fw_stream_len <= ARRAY_SIZE(submit_info->fw_stream));
 
170
   }
161
171
}
162
172
 
163
173
static void
164
174
pvr_submit_info_flags_init(const struct pvr_device_info *const dev_info,
165
175
                           const struct pvr_sub_cmd_compute *const sub_cmd,
166
 
                           uint32_t *const flags)
 
176
                           struct pvr_winsys_compute_submit_flags *flags)
167
177
{
168
 
   *flags = 0;
169
 
 
170
 
   if (sub_cmd->uses_barrier)
171
 
      *flags |= PVR_WINSYS_COMPUTE_FLAG_PREVENT_ALL_OVERLAP;
172
 
 
173
 
   if (PVR_HAS_FEATURE(dev_info, gpu_multicore_support) &&
174
 
       sub_cmd->uses_atomic_ops) {
175
 
      *flags |= PVR_WINSYS_COMPUTE_FLAG_SINGLE_CORE;
176
 
   }
 
178
   *flags = (struct pvr_winsys_compute_submit_flags){
 
179
      .prevent_all_overlap = sub_cmd->uses_barrier,
 
180
      .use_single_core = PVR_HAS_FEATURE(dev_info, gpu_multicore_support) &&
 
181
                         sub_cmd->uses_atomic_ops,
 
182
   };
177
183
}
178
184
 
179
185
static void pvr_compute_job_ws_submit_info_init(