~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/util/format/u_format.h

  • 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:
914
914
   return (z + blockdepth - 1) / blockdepth;
915
915
}
916
916
 
917
 
static inline unsigned
 
917
static inline uint64_t
918
918
util_format_get_nblocks(enum pipe_format format,
919
919
                        unsigned width,
920
920
                        unsigned height)
921
921
{
922
922
   assert(util_format_get_blockdepth(format) == 1);
923
 
   return util_format_get_nblocksx(format, width) * util_format_get_nblocksy(format, height);
 
923
   return (uint64_t)util_format_get_nblocksx(format, width) *
 
924
          util_format_get_nblocksy(format, height);
924
925
}
925
926
 
926
 
static inline size_t
 
927
static inline unsigned
927
928
util_format_get_stride(enum pipe_format format,
928
929
                       unsigned width)
929
930
{
930
 
   return (size_t)util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
 
931
   return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
931
932
}
932
933
 
933
 
static inline size_t
934
 
util_format_get_2d_size(enum pipe_format format,
935
 
                        size_t stride,
 
934
static inline uint64_t
 
935
util_format_get_2d_size(enum pipe_format format, unsigned stride,
936
936
                        unsigned height)
937
937
{
938
 
   return util_format_get_nblocksy(format, height) * stride;
 
938
   return (uint64_t)util_format_get_nblocksy(format, height) * stride;
939
939
}
940
940
 
941
941
static inline unsigned
1233
1233
   }
1234
1234
}
1235
1235
 
 
1236
static inline enum pipe_format
 
1237
util_format_as_renderable(enum pipe_format format)
 
1238
{
 
1239
   switch (util_format_get_blocksizebits(format)) {
 
1240
   case 128:
 
1241
      return PIPE_FORMAT_R32G32B32A32_UINT;
 
1242
   case 96:
 
1243
      return PIPE_FORMAT_R32G32B32_UINT;
 
1244
   case 64:
 
1245
      return PIPE_FORMAT_R32G32_UINT;
 
1246
   case 48:
 
1247
      return PIPE_FORMAT_R16G16B16_UINT;
 
1248
   case 32:
 
1249
      return PIPE_FORMAT_R32_UINT;
 
1250
   case 24:
 
1251
      return PIPE_FORMAT_R8G8B8_UINT;
 
1252
   case 16:
 
1253
      return PIPE_FORMAT_R16_UINT;
 
1254
   case 8:
 
1255
      return PIPE_FORMAT_R8_UINT;
 
1256
   default:
 
1257
      return PIPE_FORMAT_NONE;
 
1258
   }
 
1259
}
 
1260
 
1236
1261
/**
1237
1262
 * Converts PIPE_FORMAT_*I* to PIPE_FORMAT_*R*.
1238
1263
 * This is identity for non-intensity formats.
1378
1403
   case PIPE_FORMAT_Y8_U8_V8_422_UNORM:
1379
1404
   case PIPE_FORMAT_Y8_U8_V8_444_UNORM:
1380
1405
   case PIPE_FORMAT_Y8_400_UNORM:
 
1406
   case PIPE_FORMAT_R8_G8_B8_UNORM:
1381
1407
      return PIPE_FORMAT_R8_UNORM;
1382
1408
   case PIPE_FORMAT_NV12:
1383
1409
   case PIPE_FORMAT_Y8_U8V8_422_UNORM:
1645
1671
bool
1646
1672
util_format_translate_3d(enum pipe_format dst_format,
1647
1673
                         void *dst, unsigned dst_stride,
1648
 
                         unsigned dst_slice_stride,
 
1674
                         uint64_t dst_slice_stride,
1649
1675
                         unsigned dst_x, unsigned dst_y,
1650
1676
                         unsigned dst_z,
1651
1677
                         enum pipe_format src_format,
1652
1678
                         const void *src, unsigned src_stride,
1653
 
                         unsigned src_slice_stride,
 
1679
                         uint64_t src_slice_stride,
1654
1680
                         unsigned src_x, unsigned src_y,
1655
1681
                         unsigned src_z, unsigned width,
1656
1682
                         unsigned height, unsigned depth);