panfrost: Merge panfrost_new_texture() and panfrost_new_texture_bifrost()

There's no reason to keep both now that the internal logic has been
deduplicated.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8125>
This commit is contained in:
Boris Brezillon 2020-12-16 09:44:43 +01:00
parent 1fd3861a71
commit 284c43ed4b
4 changed files with 120 additions and 192 deletions

View File

@ -985,6 +985,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
struct pipe_resource *texture)
{
struct panfrost_device *device = pan_device(pctx->screen);
bool is_bifrost = device->quirks & IS_BIFROST;
struct panfrost_resource *prsrc = (struct panfrost_resource *)texture;
enum pipe_format format = so->base.format;
assert(prsrc->bo);
@ -1040,62 +1041,39 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
enum mali_texture_dimension type =
panfrost_translate_texture_dimension(so->base.target);
if (device->quirks & IS_BIFROST) {
unsigned size = panfrost_estimate_texture_payload_size(
so->base.u.tex.first_level,
so->base.u.tex.last_level,
so->base.u.tex.first_layer,
so->base.u.tex.last_layer,
texture->nr_samples,
type, prsrc->modifier);
unsigned size =
(is_bifrost ? 0 : MALI_MIDGARD_TEXTURE_LENGTH) +
panfrost_estimate_texture_payload_size(so->base.u.tex.first_level,
so->base.u.tex.last_level,
so->base.u.tex.first_layer,
so->base.u.tex.last_layer,
texture->nr_samples,
type, prsrc->modifier);
so->bo = panfrost_bo_create(device, size, 0);
so->bo = panfrost_bo_create(device, size, 0);
panfrost_new_texture_bifrost(
device,
&so->bifrost_descriptor,
texture->width0, texture->height0,
depth, array_size,
format,
type, prsrc->modifier,
so->base.u.tex.first_level,
so->base.u.tex.last_level,
so->base.u.tex.first_layer,
so->base.u.tex.last_layer,
texture->nr_samples,
prsrc->cubemap_stride,
panfrost_translate_swizzle_4(user_swizzle),
prsrc->bo->ptr.gpu,
prsrc->slices, &so->bo->ptr);
} else {
unsigned size = panfrost_estimate_texture_payload_size(
so->base.u.tex.first_level,
so->base.u.tex.last_level,
so->base.u.tex.first_layer,
so->base.u.tex.last_layer,
texture->nr_samples,
type, prsrc->modifier);
size += MALI_MIDGARD_TEXTURE_LENGTH;
struct panfrost_ptr payload = so->bo->ptr;
void *tex = is_bifrost ? &so->bifrost_descriptor : so->bo->ptr.cpu;
so->bo = panfrost_bo_create(device, size, 0);
panfrost_new_texture(
device,
so->bo->ptr.cpu,
texture->width0, texture->height0,
depth, array_size,
format,
type, prsrc->modifier,
so->base.u.tex.first_level,
so->base.u.tex.last_level,
so->base.u.tex.first_layer,
so->base.u.tex.last_layer,
texture->nr_samples,
prsrc->cubemap_stride,
panfrost_translate_swizzle_4(user_swizzle),
prsrc->bo->ptr.gpu,
prsrc->slices);
if (!is_bifrost) {
payload.cpu += MALI_MIDGARD_TEXTURE_LENGTH;
payload.gpu += MALI_MIDGARD_TEXTURE_LENGTH;
}
panfrost_new_texture(device, tex,
texture->width0, texture->height0,
depth, array_size,
format,
type, prsrc->modifier,
so->base.u.tex.first_level,
so->base.u.tex.last_level,
so->base.u.tex.first_layer,
so->base.u.tex.last_layer,
texture->nr_samples,
prsrc->cubemap_stride,
panfrost_translate_swizzle_4(user_swizzle),
prsrc->bo->ptr.gpu,
prsrc->slices, &payload);
}
static struct pipe_sampler_view *

View File

@ -303,6 +303,11 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
MAX2(image->nr_samples, 1),
128);
struct panfrost_ptr payload = {
texture.cpu + MALI_MIDGARD_TEXTURE_LENGTH,
texture.gpu + MALI_MIDGARD_TEXTURE_LENGTH,
};
struct panfrost_ptr sampler =
panfrost_pool_alloc(pool, MALI_MIDGARD_SAMPLER_LENGTH);
@ -326,7 +331,7 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
panfrost_get_layer_stride(image->slices,
image->dim == MALI_TEXTURE_DIMENSION_3D,
image->cubemap_stride, image->first_level),
image->slices);
image->slices, &payload);
pan_pack(sampler.cpu, MIDGARD_SAMPLER, cfg)
cfg.normalized_coordinates = false;
@ -488,23 +493,22 @@ bifrost_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
.gpu = texture.gpu + MALI_BIFROST_TEXTURE_LENGTH,
};
panfrost_new_texture_bifrost(pool->dev, (void *)texture.cpu,
image->width0, image->height0,
MAX2(image->nr_samples, 1), 1,
image->format, MALI_TEXTURE_DIMENSION_2D,
image->modifier,
image->first_level, image->last_level,
0, 0,
image->nr_samples,
0,
(MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
(MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9),
image->bo->ptr.gpu + image->first_layer *
panfrost_get_layer_stride(image->slices,
image->dim == MALI_TEXTURE_DIMENSION_3D,
image->cubemap_stride, image->first_level),
image->slices,
&payload);
panfrost_new_texture(pool->dev, (void *)texture.cpu,
image->width0, image->height0,
MAX2(image->nr_samples, 1), 1,
image->format, MALI_TEXTURE_DIMENSION_2D,
image->modifier,
image->first_level, image->last_level,
0, 0,
image->nr_samples,
0,
(MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
(MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9),
image->bo->ptr.gpu + image->first_layer *
panfrost_get_layer_stride(image->slices,
image->dim == MALI_TEXTURE_DIMENSION_3D,
image->cubemap_stride, image->first_level),
image->slices, &payload);
pan_pack(sampler.cpu, BIFROST_SAMPLER, cfg) {
cfg.seamless_cube_map = false;

View File

@ -407,82 +407,30 @@ panfrost_emit_texture_payload(const struct panfrost_device *dev,
}
void
panfrost_new_texture(
const struct panfrost_device *dev,
void *out,
uint16_t width, uint16_t height,
uint16_t depth, uint16_t array_size,
enum pipe_format format,
enum mali_texture_dimension dim,
uint64_t modifier,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer,
unsigned nr_samples,
unsigned cube_stride,
unsigned swizzle,
mali_ptr base,
struct panfrost_slice *slices)
panfrost_new_texture(const struct panfrost_device *dev,
void *out,
uint16_t width, uint16_t height,
uint16_t depth, uint16_t array_size,
enum pipe_format format,
enum mali_texture_dimension dim,
uint64_t modifier,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer,
unsigned nr_samples,
unsigned cube_stride,
unsigned swizzle,
mali_ptr base,
struct panfrost_slice *slices,
const struct panfrost_ptr *payload)
{
const struct util_format_description *desc =
util_format_description(format);
bool is_bifrost = dev->quirks & IS_BIFROST;
bool manual_stride =
panfrost_needs_explicit_stride(dev, modifier, format, slices,
width, first_level, last_level);
pan_pack(out, MIDGARD_TEXTURE, cfg) {
cfg.width = u_minify(width, first_level);
cfg.height = u_minify(height, first_level);
if (dim == MALI_TEXTURE_DIMENSION_3D)
cfg.depth = u_minify(depth, first_level);
else
cfg.sample_count = MAX2(1, nr_samples);
cfg.array_size = array_size;
cfg.format = panfrost_pipe_format_v6[format].hw;
cfg.dimension = dim;
cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
cfg.manual_stride = manual_stride;
cfg.levels = last_level - first_level + 1;
cfg.swizzle = swizzle;
};
panfrost_emit_texture_payload(
dev,
(mali_ptr *) (out + MALI_MIDGARD_TEXTURE_LENGTH),
desc,
dim,
modifier,
width, height,
first_level, last_level,
first_layer, last_layer,
nr_samples,
cube_stride,
manual_stride,
base,
slices);
}
void
panfrost_new_texture_bifrost(
const struct panfrost_device *dev,
struct mali_bifrost_texture_packed *out,
uint16_t width, uint16_t height,
uint16_t depth, uint16_t array_size,
enum pipe_format format,
enum mali_texture_dimension dim,
uint64_t modifier,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer,
unsigned nr_samples,
unsigned cube_stride,
unsigned swizzle,
mali_ptr base,
struct panfrost_slice *slices,
const struct panfrost_ptr *payload)
{
const struct util_format_description *desc =
util_format_description(format);
panfrost_emit_texture_payload(dev,
payload->cpu,
desc,
@ -493,30 +441,47 @@ panfrost_new_texture_bifrost(
first_layer, last_layer,
nr_samples,
cube_stride,
true, /* Stride explicit on Bifrost */
manual_stride,
base,
slices);
pan_pack(out, BIFROST_TEXTURE, cfg) {
cfg.dimension = dim;
cfg.format = dev->formats[format].hw;
if (is_bifrost) {
pan_pack(out, BIFROST_TEXTURE, cfg) {
cfg.dimension = dim;
cfg.format = dev->formats[format].hw;
cfg.width = u_minify(width, first_level);
cfg.height = u_minify(height, first_level);
if (dim == MALI_TEXTURE_DIMENSION_3D)
cfg.depth = u_minify(depth, first_level);
else
cfg.sample_count = MAX2(nr_samples, 1);
cfg.swizzle = swizzle;
cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
cfg.levels = last_level - first_level + 1;
cfg.array_size = array_size;
cfg.surfaces = payload->gpu;
cfg.width = u_minify(width, first_level);
cfg.height = u_minify(height, first_level);
if (dim == MALI_TEXTURE_DIMENSION_3D)
cfg.depth = u_minify(depth, first_level);
else
cfg.sample_count = MAX2(nr_samples, 1);
cfg.swizzle = swizzle;
cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
cfg.levels = last_level - first_level + 1;
cfg.array_size = array_size;
cfg.surfaces = payload->gpu;
/* We specify API-level LOD clamps in the sampler descriptor
* and use these clamps simply for bounds checking */
cfg.minimum_lod = FIXED_16(0, false);
cfg.maximum_lod = FIXED_16(cfg.levels - 1, false);
/* We specify API-level LOD clamps in the sampler descriptor
* and use these clamps simply for bounds checking */
cfg.minimum_lod = FIXED_16(0, false);
cfg.maximum_lod = FIXED_16(cfg.levels - 1, false);
}
} else {
pan_pack(out, MIDGARD_TEXTURE, cfg) {
cfg.width = u_minify(width, first_level);
cfg.height = u_minify(height, first_level);
if (dim == MALI_TEXTURE_DIMENSION_3D)
cfg.depth = u_minify(depth, first_level);
else
cfg.sample_count = MAX2(1, nr_samples);
cfg.array_size = array_size;
cfg.format = panfrost_pipe_format_v6[format].hw;
cfg.dimension = dim;
cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
cfg.manual_stride = manual_stride;
cfg.levels = last_level - first_level + 1;
cfg.swizzle = swizzle;
};
}
}

View File

@ -101,40 +101,21 @@ panfrost_estimate_texture_payload_size(
enum mali_texture_dimension dim, uint64_t modifier);
void
panfrost_new_texture(
const struct panfrost_device *dev,
void *out,
uint16_t width, uint16_t height,
uint16_t depth, uint16_t array_size,
enum pipe_format format,
enum mali_texture_dimension dim,
uint64_t modifier,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer,
unsigned nr_samples,
unsigned cube_stride,
unsigned swizzle,
mali_ptr base,
struct panfrost_slice *slices);
void
panfrost_new_texture_bifrost(
const struct panfrost_device *dev,
struct mali_bifrost_texture_packed *out,
uint16_t width, uint16_t height,
uint16_t depth, uint16_t array_size,
enum pipe_format format,
enum mali_texture_dimension dim,
uint64_t modifier,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer,
unsigned nr_samples,
unsigned cube_stride,
unsigned swizzle,
mali_ptr base,
struct panfrost_slice *slices,
const struct panfrost_ptr *payload);
panfrost_new_texture(const struct panfrost_device *dev,
void *out,
uint16_t width, uint16_t height,
uint16_t depth, uint16_t array_size,
enum pipe_format format,
enum mali_texture_dimension dim,
uint64_t modifier,
unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer,
unsigned nr_samples,
unsigned cube_stride,
unsigned swizzle,
mali_ptr base,
struct panfrost_slice *slices,
const struct panfrost_ptr *payload);
unsigned
panfrost_get_layer_stride(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level);