diff options
author | Jason Ekstrand <[email protected]> | 2016-06-24 15:00:31 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-08-17 14:46:22 -0700 |
commit | ba88a9622dbbad5bf2bca7858f91dcf192d7439b (patch) | |
tree | 4ca43488d2b1314bc05d20b430a2e1b022f3f8a7 /src/intel/isl/isl.h | |
parent | f6c75df083a65f2525fa366396c1ac8b7e6298eb (diff) |
isl: Add functions for computing surface offsets in samples
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/intel/isl/isl.h')
-rw-r--r-- | src/intel/isl/isl.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index 10f79ee81f1..c28c6c4855a 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -1325,6 +1325,22 @@ isl_surf_get_array_pitch(const struct isl_surf *surf) } /** + * Calculate the offset, in units of surface samples, to a subimage in the + * surface. + * + * @invariant level < surface levels + * @invariant logical_array_layer < logical array length of surface + * @invariant logical_z_offset_px < logical depth of surface at level + */ +void +isl_surf_get_image_offset_sa(const struct isl_surf *surf, + uint32_t level, + uint32_t logical_array_layer, + uint32_t logical_z_offset_px, + uint32_t *x_offset_sa, + uint32_t *y_offset_sa); + +/** * Calculate the offset, in units of surface elements, to a subimage in the * surface. * @@ -1361,6 +1377,38 @@ isl_tiling_get_intratile_offset_el(const struct isl_device *dev, uint32_t *x_offset_el, uint32_t *y_offset_el); +static inline void +isl_tiling_get_intratile_offset_sa(const struct isl_device *dev, + enum isl_tiling tiling, + enum isl_format format, + uint32_t row_pitch, + uint32_t total_x_offset_sa, + uint32_t total_y_offset_sa, + uint32_t *base_address_offset, + uint32_t *x_offset_sa, + uint32_t *y_offset_sa) +{ + const struct isl_format_layout *fmtl = isl_format_get_layout(format); + + assert(fmtl->bpb % 8 == 0); + + /* For computing the intratile offsets, we actually want a strange unit + * which is samples for multisampled surfaces but elements for compressed + * surfaces. + */ + assert(total_x_offset_sa % fmtl->bw == 0); + assert(total_y_offset_sa % fmtl->bw == 0); + const uint32_t total_x_offset = total_x_offset_sa / fmtl->bw; + const uint32_t total_y_offset = total_y_offset_sa / fmtl->bh; + + isl_tiling_get_intratile_offset_el(dev, tiling, fmtl->bpb / 8, row_pitch, + total_x_offset, total_y_offset, + base_address_offset, + x_offset_sa, y_offset_sa); + *x_offset_sa *= fmtl->bw; + *y_offset_sa *= fmtl->bh; +} + /** * @brief Get value of 3DSTATE_DEPTH_BUFFER.SurfaceFormat * |