summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-12-11 19:27:39 +0100
committerMarek Olšák <[email protected]>2017-12-25 14:23:02 +0100
commit986e467e4c5c9610a01b0176c02c2310ed019ae8 (patch)
treec608a5876e4cb8b17319bfba760ebfb7cd622c16 /src
parent70b5e85fc3a79214b4f25db0e6d8fcc32d62a2f1 (diff)
gallium/util: add util_num_layers helper
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c4
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c4
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h8
-rw-r--r--src/gallium/drivers/r600/r600_texture.c8
-rw-r--r--src/gallium/drivers/radeon/r600_texture.c8
-rw-r--r--src/gallium/drivers/radeonsi/si_clear.c2
-rw-r--r--src/gallium/drivers/rbug/rbug_core.c2
7 files changed, 21 insertions, 15 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 824213b4e30..057411fb3fa 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -2077,8 +2077,8 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
srcbox.height = u_minify(tex->height0, src_level);
if (target == PIPE_TEXTURE_3D) {
- dstbox.depth = util_max_layer(tex, dst_level) + 1;
- srcbox.depth = util_max_layer(tex, src_level) + 1;
+ dstbox.depth = util_num_layers(tex, dst_level);
+ srcbox.depth = util_num_layers(tex, src_level);
} else {
dstbox.z = srcbox.z = first_layer;
dstbox.depth = srcbox.depth = last_layer - first_layer + 1;
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index aa8eaebb679..3c55d9f385c 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -113,8 +113,8 @@ util_gen_mipmap(struct pipe_context *pipe, struct pipe_resource *pt,
if (pt->target == PIPE_TEXTURE_3D) {
/* generate all layers/slices at once */
blit.src.box.z = blit.dst.box.z = 0;
- blit.src.box.depth = util_max_layer(pt, blit.src.level)+1;
- blit.dst.box.depth = util_max_layer(pt, blit.dst.level)+1;
+ blit.src.box.depth = util_num_layers(pt, blit.src.level);
+ blit.dst.box.depth = util_num_layers(pt, blit.dst.level);
}
else {
blit.src.box.z = blit.dst.box.z = first_layer;
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 790352d7800..4ba6ad72b62 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -666,6 +666,12 @@ util_max_layer(const struct pipe_resource *r, unsigned level)
}
}
+static inline unsigned
+util_num_layers(const struct pipe_resource *r, unsigned level)
+{
+ return util_max_layer(r, level) + 1;
+}
+
static inline bool
util_texrange_covers_whole_level(const struct pipe_resource *tex,
unsigned level, unsigned x, unsigned y,
@@ -675,7 +681,7 @@ util_texrange_covers_whole_level(const struct pipe_resource *tex,
return x == 0 && y == 0 && z == 0 &&
width == u_minify(tex->width0, level) &&
height == u_minify(tex->height0, level) &&
- depth == util_max_layer(tex, level) + 1;
+ depth == util_num_layers(tex, level);
}
#ifdef __cplusplus
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 3895d53912c..03cdcd22eee 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -393,7 +393,7 @@ static void r600_reallocate_texture_inplace(struct r600_common_context *rctx,
u_box_3d(0, 0, 0,
u_minify(templ.width0, i), u_minify(templ.height0, i),
- util_max_layer(&templ, i) + 1, &box);
+ util_num_layers(&templ, i), &box);
rctx->dma_copy(&rctx->b, &new_tex->resource.b.b, i, 0, 0, 0,
&rtex->resource.b.b, i, &box);
@@ -676,7 +676,7 @@ void r600_texture_get_cmask_info(struct r600_common_screen *rscreen,
out->slice_tile_max = ((pitch_elements * height) / (128*128)) - 1;
out->alignment = MAX2(256, base_align);
- out->size = (util_max_layer(&rtex->resource.b.b, 0) + 1) *
+ out->size = util_num_layers(&rtex->resource.b.b, 0) *
align(slice_bytes, base_align);
}
@@ -785,7 +785,7 @@ static void r600_texture_get_htile_size(struct r600_common_screen *rscreen,
rtex->surface.htile_alignment = base_align;
rtex->surface.htile_size =
- (util_max_layer(&rtex->resource.b.b, 0) + 1) *
+ util_num_layers(&rtex->resource.b.b, 0) *
align(slice_bytes, base_align);
}
@@ -996,7 +996,7 @@ r600_texture_create_object(struct pipe_screen *screen,
fprintf(stderr, "VM start=0x%"PRIX64" end=0x%"PRIX64" | Texture %ix%ix%i, %i levels, %i samples, %s\n",
rtex->resource.gpu_address,
rtex->resource.gpu_address + rtex->resource.buf->size,
- base->width0, base->height0, util_max_layer(base, 0)+1, base->last_level+1,
+ base->width0, base->height0, util_num_layers(base, 0), base->last_level+1,
base->nr_samples ? base->nr_samples : 1, util_format_short_name(base->format));
}
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 66d4f02622f..34b3ab0cdeb 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -513,7 +513,7 @@ static void r600_reallocate_texture_inplace(struct r600_common_context *rctx,
u_box_3d(0, 0, 0,
u_minify(templ.width0, i), u_minify(templ.height0, i),
- util_max_layer(&templ, i) + 1, &box);
+ util_num_layers(&templ, i), &box);
rctx->dma_copy(&rctx->b, &new_tex->resource.b.b, i, 0, 0, 0,
&rtex->resource.b.b, i, &box);
@@ -935,7 +935,7 @@ void si_texture_get_cmask_info(struct si_screen *sscreen,
out->slice_tile_max -= 1;
out->alignment = MAX2(256, base_align);
- out->size = (util_max_layer(&rtex->resource.b.b, 0) + 1) *
+ out->size = util_num_layers(&rtex->resource.b.b, 0) *
align(slice_bytes, base_align);
}
@@ -1014,7 +1014,7 @@ static void r600_texture_get_htile_size(struct si_screen *sscreen,
rtex->surface.htile_alignment = base_align;
rtex->surface.htile_size =
- (util_max_layer(&rtex->resource.b.b, 0) + 1) *
+ util_num_layers(&rtex->resource.b.b, 0) *
align(slice_bytes, base_align);
}
@@ -1333,7 +1333,7 @@ r600_texture_create_object(struct pipe_screen *screen,
fprintf(stderr, "VM start=0x%"PRIX64" end=0x%"PRIX64" | Texture %ix%ix%i, %i levels, %i samples, %s\n",
rtex->resource.gpu_address,
rtex->resource.gpu_address + rtex->resource.buf->size,
- base->width0, base->height0, util_max_layer(base, 0)+1, base->last_level+1,
+ base->width0, base->height0, util_num_layers(base, 0), base->last_level+1,
base->nr_samples ? base->nr_samples : 1, util_format_short_name(base->format));
}
diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c
index ba95ed51f14..0ac83f446bf 100644
--- a/src/gallium/drivers/radeonsi/si_clear.c
+++ b/src/gallium/drivers/radeonsi/si_clear.c
@@ -214,7 +214,7 @@ void vi_dcc_clear_level(struct si_context *sctx,
assert(rtex->resource.b.b.nr_samples <= 1);
clear_size = rtex->surface.dcc_size;
} else {
- unsigned num_layers = util_max_layer(&rtex->resource.b.b, level) + 1;
+ unsigned num_layers = util_num_layers(&rtex->resource.b.b, level);
/* If this is 0, fast clear isn't possible. (can occur with MSAA) */
assert(rtex->surface.u.legacy.level[level].dcc_fast_clear_size);
diff --git a/src/gallium/drivers/rbug/rbug_core.c b/src/gallium/drivers/rbug/rbug_core.c
index 8eb39c17b14..76394039b9b 100644
--- a/src/gallium/drivers/rbug/rbug_core.c
+++ b/src/gallium/drivers/rbug/rbug_core.c
@@ -221,7 +221,7 @@ rbug_texture_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
}
t = tr_tex->resource;
- num_layers = util_max_layer(t, 0) + 1;
+ num_layers = util_num_layers(t, 0);
rbug_send_texture_info_reply(tr_rbug->con, serial,
t->target, t->format,