[Mesa-dev] [PATCH 02/16] mesa: Add support to query block depth using _mesa_get_format_block_size()

Brian Paul brianp at vmware.com
Sat Mar 5 16:02:47 UTC 2016


On 03/04/2016 06:29 PM, Anuj Phogat wrote:
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
>   src/mesa/drivers/dri/i915/intel_mipmap_tree.c    |  8 ++++----
>   src/mesa/drivers/dri/i915/intel_tex_layout.c     |  4 ++--
>   src/mesa/drivers/dri/i965/brw_tex_layout.c       | 21 +++++++++++----------
>   src/mesa/drivers/dri/i965/intel_copy_image.c     | 14 +++++++-------
>   src/mesa/drivers/dri/i965/intel_mipmap_tree.c    |  8 ++++----
>   src/mesa/drivers/dri/nouveau/nouveau_util.h      |  8 ++++++--
>   src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 11 +++++++----
>   src/mesa/drivers/dri/radeon/radeon_texture.c     |  4 ++--
>   src/mesa/main/copyimage.c                        |  6 +++---
>   src/mesa/main/formatquery.c                      |  4 ++--
>   src/mesa/main/formats.c                          |  4 +++-
>   src/mesa/main/formats.h                          |  3 ++-
>   src/mesa/main/texcompress.c                      |  8 ++++----
>   src/mesa/main/texgetimage.c                      |  4 ++--
>   src/mesa/main/teximage.c                         |  4 ++--
>   src/mesa/main/texstore.c                         |  4 ++--
>   src/mesa/swrast/s_texfetch.c                     |  4 ++--
>   src/mesa/swrast/s_texture.c                      |  4 ++--
>   18 files changed, 67 insertions(+), 56 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
> index 5cbf763..947a556 100644
> --- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
> @@ -90,8 +90,8 @@ intel_miptree_create_layout(struct intel_context *intel,
>      /* The cpp is bytes per (1, blockheight)-sized block for compressed
>       * textures.  This is why you'll see divides by blockheight all over
>       */
> -   unsigned bw, bh;
> -   _mesa_get_format_block_size(format, &bw, &bh);
> +   unsigned bw, bh, bd;
> +   _mesa_get_format_block_size(format, &bw, &bh, &bd);
>      assert(_mesa_get_format_bytes(mt->format) % bw == 0);
>      mt->cpp = _mesa_get_format_bytes(mt->format) / bw;
>
> @@ -726,7 +726,7 @@ intel_miptree_map_gtt(struct intel_context *intel,
>   		      struct intel_miptree_map *map,
>   		      unsigned int level, unsigned int slice)
>   {
> -   unsigned int bw, bh;
> +   unsigned int bw, bh, bd;
>      void *base;
>      unsigned int image_x, image_y;
>      int x = map->x;
> @@ -736,7 +736,7 @@ intel_miptree_map_gtt(struct intel_context *intel,
>       * row of blocks.  intel_miptree_get_image_offset() already does
>       * the divide.
>       */
> -   _mesa_get_format_block_size(mt->format, &bw, &bh);
> +   _mesa_get_format_block_size(mt->format, &bw, &bh, &bd);
>      assert(y % bh == 0);
>      y /= bh;
>
> diff --git a/src/mesa/drivers/dri/i915/intel_tex_layout.c b/src/mesa/drivers/dri/i915/intel_tex_layout.c
> index 01ea165..401282c 100644
> --- a/src/mesa/drivers/dri/i915/intel_tex_layout.c
> +++ b/src/mesa/drivers/dri/i915/intel_tex_layout.c
> @@ -69,8 +69,8 @@ intel_horizontal_texture_alignment_unit(struct intel_context *intel,
>          /* The hardware alignment requirements for compressed textures
>           * happen to match the block boundaries.
>           */
> -      unsigned int i, j;
> -      _mesa_get_format_block_size(format, &i, &j);
> +      unsigned int i, j, k;
> +      _mesa_get_format_block_size(format, &i, &j, &k);
>         return i;
>       }
>
> diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c
> index a294829..67923e9 100644
> --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
> +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
> @@ -296,9 +296,9 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt)
>      unsigned width = mt->physical_width0;
>      unsigned height = mt->physical_height0;
>      unsigned depth = mt->physical_depth0; /* number of array layers. */
> -   unsigned int bw, bh;
> +   unsigned int bw, bh, bd;
>
> -   _mesa_get_format_block_size(mt->format, &bw, &bh);
> +   _mesa_get_format_block_size(mt->format, &bw, &bh, &bd);
>
>      mt->total_width = mt->physical_width0;
>
> @@ -515,9 +515,9 @@ brw_miptree_layout_texture_3d(struct brw_context *brw,
>      mt->total_height = 0;
>
>      unsigned ysum = 0;
> -   unsigned bh, bw;
> +   unsigned bh, bw, bd;
>
> -   _mesa_get_format_block_size(mt->format, &bw, &bh);
> +   _mesa_get_format_block_size(mt->format, &bw, &bh, &bd);
>
>      for (unsigned level = mt->first_level; level <= mt->last_level; level++) {
>         unsigned WL = MAX2(mt->physical_width0 >> level, 1);
> @@ -745,10 +745,11 @@ intel_miptree_set_alignment(struct brw_context *brw,
>            mt->valign = 32;
>         }
>      } else if (mt->compressed) {
> -       /* The hardware alignment requirements for compressed textures
> -        * happen to match the block boundaries.
> -        */
> -      _mesa_get_format_block_size(mt->format, &mt->halign, &mt->valign);
> +      unsigned int bd;
> +      /* The hardware alignment requirements for compressed textures
> +       * happen to match the block boundaries.
> +       */
> +      _mesa_get_format_block_size(mt->format, &mt->halign, &mt->valign, &bd);
>
>         /* On Gen9+ we can pick our own alignment for compressed textures but it
>          * has to be a multiple of the block size. The minimum alignment we can
> @@ -793,8 +794,8 @@ brw_miptree_layout(struct brw_context *brw,
>       * size
>       */
>      if (brw->gen >= 9) {
> -      unsigned int i, j;
> -      _mesa_get_format_block_size(mt->format, &i, &j);
> +      unsigned int i, j, k;
> +      _mesa_get_format_block_size(mt->format, &i, &j, &k);
>         mt->halign /= i;
>         mt->valign /= j;
>      }
> diff --git a/src/mesa/drivers/dri/i965/intel_copy_image.c b/src/mesa/drivers/dri/i965/intel_copy_image.c
> index 08b7623..3690585 100644
> --- a/src/mesa/drivers/dri/i965/intel_copy_image.c
> +++ b/src/mesa/drivers/dri/i965/intel_copy_image.c
> @@ -41,7 +41,7 @@ copy_image_with_blitter(struct brw_context *brw,
>                           int dst_x, int dst_y, int dst_z,
>                           int src_width, int src_height)
>   {
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>      uint32_t src_image_x, src_image_y, dst_image_x, dst_image_y;
>
>      /* The blitter doesn't understand multisampling at all. */
> @@ -76,7 +76,7 @@ copy_image_with_blitter(struct brw_context *brw,
>                                     &src_image_x, &src_image_y);
>
>      if (_mesa_is_format_compressed(src_mt->format)) {
> -      _mesa_get_format_block_size(src_mt->format, &bw, &bh);
> +      _mesa_get_format_block_size(src_mt->format, &bw, &bh, &bd);
>
>         assert(src_x % bw == 0);
>         assert(src_y % bh == 0);
> @@ -95,7 +95,7 @@ copy_image_with_blitter(struct brw_context *brw,
>                                     &dst_image_x, &dst_image_y);
>
>      if (_mesa_is_format_compressed(dst_mt->format)) {
> -      _mesa_get_format_block_size(dst_mt->format, &bw, &bh);
> +      _mesa_get_format_block_size(dst_mt->format, &bw, &bh, &bd);
>
>         assert(dst_x % bw == 0);
>         assert(dst_y % bh == 0);
> @@ -134,10 +134,10 @@ copy_image_with_memcpy(struct brw_context *brw,
>      void *mapped, *src_mapped, *dst_mapped;
>      ptrdiff_t src_stride, dst_stride, cpp;
>      int map_x1, map_y1, map_x2, map_y2;
> -   GLuint src_bw, src_bh;
> +   GLuint src_bw, src_bh, src_bd;
>
>      cpp = _mesa_get_format_bytes(src_mt->format);
> -   _mesa_get_format_block_size(src_mt->format, &src_bw, &src_bh);
> +   _mesa_get_format_block_size(src_mt->format, &src_bw, &src_bh, &src_bd);
>
>      assert(src_width % src_bw == 0);
>      assert(src_height % src_bw == 0);
> @@ -212,7 +212,7 @@ intel_copy_image_sub_data(struct gl_context *ctx,
>      struct brw_context *brw = brw_context(ctx);
>      struct intel_mipmap_tree *src_mt, *dst_mt;
>      unsigned src_level, dst_level;
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>
>      if (_mesa_meta_CopyImageSubData_uncompressed(ctx,
>                                                   src_image, src_renderbuffer,
> @@ -276,7 +276,7 @@ intel_copy_image_sub_data(struct gl_context *ctx,
>      intel_miptree_all_slices_resolve_depth(brw, dst_mt);
>      intel_miptree_resolve_color(brw, dst_mt, 0);
>
> -   _mesa_get_format_block_size(src_mt->format, &bw, &bh);
> +   _mesa_get_format_block_size(src_mt->format, &bw, &bh, &bd);
>
>      /* It's legal to have a WxH that's smaller than a compressed block. This
>       * happens for example when you are using a higher level LOD. For this case,
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 6c233d8..0874902 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -1373,8 +1373,8 @@ intel_miptree_copy_slice(struct brw_context *brw,
>      assert(src_mt->format == dst_mt->format);
>
>      if (dst_mt->compressed) {
> -      unsigned int i, j;
> -      _mesa_get_format_block_size(dst_mt->format, &i, &j);
> +      unsigned int i, j, k;
> +      _mesa_get_format_block_size(dst_mt->format, &i, &j, &k);
>         height = ALIGN_NPOT(height, j) / j;
>         width = ALIGN_NPOT(width, i) / i;
>      }
> @@ -2231,7 +2231,7 @@ intel_miptree_map_gtt(struct brw_context *brw,
>   		      struct intel_miptree_map *map,
>   		      unsigned int level, unsigned int slice)
>   {
> -   unsigned int bw, bh;
> +   unsigned int bw, bh, bd;
>      void *base;
>      unsigned int image_x, image_y;
>      intptr_t x = map->x;
> @@ -2241,7 +2241,7 @@ intel_miptree_map_gtt(struct brw_context *brw,
>       * row of blocks.  intel_miptree_get_image_offset() already does
>       * the divide.
>       */
> -   _mesa_get_format_block_size(mt->format, &bw, &bh);
> +   _mesa_get_format_block_size(mt->format, &bw, &bh, &bd);
>      assert(y % bh == 0);
>      assert(x % bw == 0);
>      y /= bh;
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h
> index 8087445..236b883 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h
> @@ -216,7 +216,9 @@ get_format_blocksx(mesa_format format,
>   {
>   	GLuint blockwidth;
>   	GLuint blockheight;
> -	_mesa_get_format_block_size(format, &blockwidth, &blockheight);
> +	GLuint blockdepth;
> +	_mesa_get_format_block_size(format, &blockwidth, &blockheight,
> +				    &blockdepth);
>   	return (x + blockwidth - 1) / blockwidth;
>   }
>
> @@ -226,7 +228,9 @@ get_format_blocksy(mesa_format format,
>   {
>   	GLuint blockwidth;
>   	GLuint blockheight;
> -	_mesa_get_format_block_size(format, &blockwidth, &blockheight);
> +	GLuint blockdepth;
> +	_mesa_get_format_block_size(format, &blockwidth, &blockheight,
> +				    &blockdepth);
>   	return (y + blockheight - 1) / blockheight;
>   }
>
> diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
> index c71766d..d2bddb9 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
> @@ -44,10 +44,12 @@ static unsigned get_aligned_compressed_row_stride(
>   		unsigned minStride)
>   {
>   	const unsigned blockBytes = _mesa_get_format_bytes(format);
> -	unsigned blockWidth, blockHeight;
> +	unsigned blockWidth, blockHeight, blockDepth;
>   	unsigned stride;
>
> -	_mesa_get_format_block_size(format, &blockWidth, &blockHeight);
> +	_mesa_get_format_block_size(format, &blockwidth, &blockheight,
> +				    &blockDepth);
> +
>
>   	/* Count number of blocks required to store the given width.
>   	 * And then multiple it with bytes required to store a block.
> @@ -78,9 +80,10 @@ unsigned get_texture_image_size(
>   		unsigned tiling)
>   {
>   	if (_mesa_is_format_compressed(format)) {
> -		unsigned blockWidth, blockHeight;
> +		unsigned blockWidth, blockHeight, blockDepth;
>
> -		_mesa_get_format_block_size(format, &blockWidth, &blockHeight);
> +		_mesa_get_format_block_size(format, &blockWidth, &blockHeight
> +					    &blockDepth);
>
>   		return rowStride * ((height + blockHeight - 1) / blockHeight) * depth;
>   	} else if (tiling) {
> diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
> index 4794dda..f9bb62f 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_texture.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
> @@ -158,10 +158,10 @@ radeon_map_texture_image(struct gl_context *ctx,
>   	GLuint width = texImage->Width;
>   	GLuint height = texImage->Height;
>   	struct radeon_bo *bo = !image->mt ? image->bo : image->mt->bo;
> -	unsigned int bw, bh;
> +	unsigned int bw, bh, bd;
>   	GLboolean write = (mode & GL_MAP_WRITE_BIT) != 0;
>
> -	_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
> +	_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh, &bd);
>   	assert(y % bh == 0);
>   	y /= bh;
>   	texel_size /= bw;
> diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c
> index d571d22..754eaf1 100644
> --- a/src/mesa/main/copyimage.c
> +++ b/src/mesa/main/copyimage.c
> @@ -430,7 +430,7 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
>      mesa_format srcFormat, dstFormat;
>      GLenum srcIntFormat, dstIntFormat;
>      GLuint src_w, src_h, dst_w, dst_h;
> -   GLuint src_bw, src_bh, dst_bw, dst_bh;
> +   GLuint src_bw, src_bh, src_bd, dst_bw, dst_bh, dst_bd;
>      int dstWidth, dstHeight, dstDepth;
>      int i;
>
> @@ -460,7 +460,7 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
>                          &dstIntFormat, &dst_w, &dst_h, "dst"))
>         return;
>
> -   _mesa_get_format_block_size(srcFormat, &src_bw, &src_bh);
> +   _mesa_get_format_block_size(srcFormat, &src_bw, &src_bh, &src_bd);
>
>      /* Section 18.3.2 (Copying Between Images) of the OpenGL 4.5 Core Profile
>       * spec says:
> @@ -492,7 +492,7 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
>         return;
>      }
>
> -   _mesa_get_format_block_size(dstFormat, &dst_bw, &dst_bh);
> +   _mesa_get_format_block_size(dstFormat, &dst_bw, &dst_bh, &dst_bd);
>      if ((dstX % dst_bw != 0) || (dstY % dst_bh != 0)) {
>         _mesa_error(ctx, GL_INVALID_VALUE,
>                     "glCopyImageSubData(unaligned dst rectangle)");
> diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
> index 215c14f..fd41319 100644
> --- a/src/mesa/main/formatquery.c
> +++ b/src/mesa/main/formatquery.c
> @@ -1470,10 +1470,10 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
>         if (pname == GL_TEXTURE_COMPRESSED_BLOCK_SIZE) {
>            buffer[0] = block_size;
>         } else {
> -         GLuint bwidth, bheight;
> +         GLuint bwidth, bheight, bdepth;
>
>            /* Returns the width and height in pixels. We return bytes */
> -         _mesa_get_format_block_size(mesaformat, &bwidth, &bheight);
> +         _mesa_get_format_block_size(mesaformat, &bwidth, &bheight, &bdepth);
>            assert(bwidth > 0 && bheight > 0);
>
>            if (pname == GL_TEXTURE_COMPRESSED_BLOCK_WIDTH)
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index 3d2349b..6c23dda 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -312,11 +312,13 @@ _mesa_get_format_base_format(uint32_t format)
>    * \param bh  returns block height in pixels
>    */
>   void
> -_mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh)
> +_mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh,
> +                            GLuint* bd)
>   {
>      const struct gl_format_info *info = _mesa_get_format_info(format);
>      *bw = info->BlockWidth;
>      *bh = info->BlockHeight;
> +   *bd = info->BlockDepth;
>   }
>
>
> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
> index 794d599..2f8f63c 100644
> --- a/src/mesa/main/formats.h
> +++ b/src/mesa/main/formats.h
> @@ -661,7 +661,8 @@ extern GLenum
>   _mesa_get_format_base_format(uint32_t format);
>
>   extern void
> -_mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh);
> +_mesa_get_format_block_size(mesa_format format, GLuint *bw,
> +                            GLuint *bh, GLuint *bd);
>
>   extern mesa_array_format
>   _mesa_array_format_flip_channels(mesa_array_format format);
> diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
> index 3ae6452..9f2f171 100644
> --- a/src/mesa/main/texcompress.c
> +++ b/src/mesa/main/texcompress.c
> @@ -756,10 +756,10 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
>   {
>      /* XXX only 2D images implemented, not 3D */
>      const GLuint blockSize = _mesa_get_format_bytes(mesaFormat);
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>      GLint offset;
>
> -   _mesa_get_format_block_size(mesaFormat, &bw, &bh);
> +   _mesa_get_format_block_size(mesaFormat, &bw, &bh, &bd);
>
>      assert(col % bw == 0);
>      assert(row % bh == 0);
> @@ -808,11 +808,11 @@ _mesa_decompress_image(mesa_format format, GLuint width, GLuint height,
>   {
>      compressed_fetch_func fetch;
>      GLuint i, j;
> -   GLuint bytes, bw, bh;
> +   GLuint bytes, bw, bh, bd;
>      GLint stride;
>
>      bytes = _mesa_get_format_bytes(format);
> -   _mesa_get_format_block_size(format, &bw, &bh);
> +   _mesa_get_format_block_size(format, &bw, &bh, &bd);
>
>      fetch = _mesa_get_compressed_fetch_func(format);
>      if (!fetch) {
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index 06bc8f1..a414b2e 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -1037,8 +1037,8 @@ dimensions_error_check(struct gl_context *ctx,
>
>      /* Extra checks for compressed textures */
>      {
> -      GLuint bw, bh;
> -      _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
> +      GLuint bw, bh, bd;
> +      _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh, &bd);
>         if (bw > 1 || bh > 1) {
>            /* offset must be multiple of block size */
>            if (xoffset % bw != 0) {
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 616a929..ba72353 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1112,7 +1112,7 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims,
>                                     GLsizei subDepth, const char *func)
>   {
>      const GLenum target = destImage->TexObject->Target;
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>
>      /* Check size */
>      if (subWidth < 0) {
> @@ -1185,7 +1185,7 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims,
>       * compressed formats supported by Mesa allow sub-textures to be updated
>       * along compressed block boundaries.
>       */
> -   _mesa_get_format_block_size(destImage->TexFormat, &bw, &bh);
> +   _mesa_get_format_block_size(destImage->TexFormat, &bw, &bh, &bd);
>
>      if (bw != 1 || bh != 1) {
>         /* offset must be multiple of block size */
> diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
> index c33b109..02670d1 100644
> --- a/src/mesa/main/texstore.c
> +++ b/src/mesa/main/texstore.c
> @@ -1267,9 +1267,9 @@ _mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat,
>                                       const struct gl_pixelstore_attrib *packing,
>                                       struct compressed_pixelstore *store)
>   {
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>
> -   _mesa_get_format_block_size(texFormat, &bw, &bh);
> +   _mesa_get_format_block_size(texFormat, &bw, &bh, &bd);
>
>      store->SkipBytes = 0;
>      store->TotalBytesPerRow = store->CopyBytesPerRow =
> diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
> index 27de9b3..4a9ec2c 100644
> --- a/src/mesa/swrast/s_texfetch.c
> +++ b/src/mesa/swrast/s_texfetch.c
> @@ -71,9 +71,9 @@ fetch_compressed(const struct swrast_texture_image *swImage,
>      /* The FetchCompressedTexel function takes an integer pixel rowstride,
>       * while the image's rowstride is bytes per row of blocks.
>       */
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>      GLuint texelBytes = _mesa_get_format_bytes(swImage->Base.TexFormat);
> -   _mesa_get_format_block_size(swImage->Base.TexFormat, &bw, &bh);
> +   _mesa_get_format_block_size(swImage->Base.TexFormat, &bw, &bh, &bd);
>      assert(swImage->RowStride * bw % texelBytes == 0);
>
>      swImage->FetchCompressedTexel(swImage->ImageSlices[k],
> diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
> index 9ccd0e3..d7f0b35 100644
> --- a/src/mesa/swrast/s_texture.c
> +++ b/src/mesa/swrast/s_texture.c
> @@ -214,7 +214,7 @@ _swrast_map_teximage(struct gl_context *ctx,
>      struct swrast_texture_image *swImage = swrast_texture_image(texImage);
>      GLubyte *map;
>      GLint stride, texelSize;
> -   GLuint bw, bh;
> +   GLuint bw, bh, bd;
>
>      check_map_teximage(texImage, slice, x, y, w, h);
>
> @@ -229,7 +229,7 @@ _swrast_map_teximage(struct gl_context *ctx,
>
>      texelSize = _mesa_get_format_bytes(texImage->TexFormat);
>      stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
> -   _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
> +   _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh, &bd);
>
>      assert(x % bw == 0);
>      assert(y % bh == 0);
>

Isn't there more work to do here (or in a subsequent patch)?

We're querying the block depth everywhere now, but not actually doing 
anything with it.  For example, in the texgetimage.c files you're not 
using the block depth to check the zoffset/depth values.

I wonder if it would be better to leave _mesa_get_format_block_size() 
as-is and add a new _mesa_get_format_block_size_3d() function that's 
used by code that actually handles non-1 block depths?

We could also assert in _mesa_get_format_block_size() that the caller is 
querying a non-3D block size format.  If the assertion fails, that'd 
tell us that the calling code needs to be updated for 3d block depths. 
Otherwise, we may get some silent failures.

Other than that, the series looks good to me.

-Brian



More information about the mesa-dev mailing list