~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/asahi/lib/agx_nir_lower_vbo.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:
4
4
 */
5
5
 
6
6
#include "agx_nir_lower_vbo.h"
 
7
#include "asahi/compiler/agx_internal_formats.h"
7
8
#include "compiler/nir/nir_builder.h"
8
9
#include "compiler/nir/nir_format_convert.h"
9
10
#include "util/u_math.h"
169
170
 
170
171
   unsigned stride_el = stride / interchange_align;
171
172
   unsigned offset_el = offset / interchange_align;
 
173
   unsigned shift = 0;
 
174
 
 
175
   /* Try to use the small shift on the load itself when possible. This can save
 
176
    * an instruction. Shifts are only available for regular interchange formats,
 
177
    * i.e. the set of formats that support masking.
 
178
    */
 
179
   if (offset_el == 0 && (stride_el == 2 || stride_el == 4) &&
 
180
       agx_internal_format_supports_mask(interchange_format)) {
 
181
 
 
182
      shift = util_logbase2(stride_el);
 
183
      stride_el = 1;
 
184
   }
172
185
 
173
186
   nir_ssa_def *stride_offset_el =
174
187
      nir_iadd_imm(b, nir_imul_imm(b, el, stride_el), offset_el);
176
189
   /* Load the raw vector */
177
190
   nir_ssa_def *memory = nir_load_constant_agx(
178
191
      b, interchange_comps, interchange_register_size, base, stride_offset_el,
179
 
      .format = interchange_format);
 
192
      .format = interchange_format, .base = shift);
180
193
 
181
194
   unsigned dest_size = nir_dest_bit_size(intr->dest);
182
195