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:
parent
1fd3861a71
commit
284c43ed4b
|
@ -985,6 +985,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||||
struct pipe_resource *texture)
|
struct pipe_resource *texture)
|
||||||
{
|
{
|
||||||
struct panfrost_device *device = pan_device(pctx->screen);
|
struct panfrost_device *device = pan_device(pctx->screen);
|
||||||
|
bool is_bifrost = device->quirks & IS_BIFROST;
|
||||||
struct panfrost_resource *prsrc = (struct panfrost_resource *)texture;
|
struct panfrost_resource *prsrc = (struct panfrost_resource *)texture;
|
||||||
enum pipe_format format = so->base.format;
|
enum pipe_format format = so->base.format;
|
||||||
assert(prsrc->bo);
|
assert(prsrc->bo);
|
||||||
|
@ -1040,62 +1041,39 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||||
enum mali_texture_dimension type =
|
enum mali_texture_dimension type =
|
||||||
panfrost_translate_texture_dimension(so->base.target);
|
panfrost_translate_texture_dimension(so->base.target);
|
||||||
|
|
||||||
if (device->quirks & IS_BIFROST) {
|
unsigned size =
|
||||||
unsigned size = panfrost_estimate_texture_payload_size(
|
(is_bifrost ? 0 : MALI_MIDGARD_TEXTURE_LENGTH) +
|
||||||
so->base.u.tex.first_level,
|
panfrost_estimate_texture_payload_size(so->base.u.tex.first_level,
|
||||||
so->base.u.tex.last_level,
|
so->base.u.tex.last_level,
|
||||||
so->base.u.tex.first_layer,
|
so->base.u.tex.first_layer,
|
||||||
so->base.u.tex.last_layer,
|
so->base.u.tex.last_layer,
|
||||||
texture->nr_samples,
|
texture->nr_samples,
|
||||||
type, prsrc->modifier);
|
type, prsrc->modifier);
|
||||||
|
|
||||||
so->bo = panfrost_bo_create(device, size, 0);
|
so->bo = panfrost_bo_create(device, size, 0);
|
||||||
|
|
||||||
panfrost_new_texture_bifrost(
|
struct panfrost_ptr payload = so->bo->ptr;
|
||||||
device,
|
void *tex = is_bifrost ? &so->bifrost_descriptor : so->bo->ptr.cpu;
|
||||||
&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;
|
|
||||||
|
|
||||||
so->bo = panfrost_bo_create(device, size, 0);
|
if (!is_bifrost) {
|
||||||
|
payload.cpu += MALI_MIDGARD_TEXTURE_LENGTH;
|
||||||
panfrost_new_texture(
|
payload.gpu += MALI_MIDGARD_TEXTURE_LENGTH;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 *
|
static struct pipe_sampler_view *
|
||||||
|
|
|
@ -303,6 +303,11 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
|
||||||
MAX2(image->nr_samples, 1),
|
MAX2(image->nr_samples, 1),
|
||||||
128);
|
128);
|
||||||
|
|
||||||
|
struct panfrost_ptr payload = {
|
||||||
|
texture.cpu + MALI_MIDGARD_TEXTURE_LENGTH,
|
||||||
|
texture.gpu + MALI_MIDGARD_TEXTURE_LENGTH,
|
||||||
|
};
|
||||||
|
|
||||||
struct panfrost_ptr sampler =
|
struct panfrost_ptr sampler =
|
||||||
panfrost_pool_alloc(pool, MALI_MIDGARD_SAMPLER_LENGTH);
|
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,
|
panfrost_get_layer_stride(image->slices,
|
||||||
image->dim == MALI_TEXTURE_DIMENSION_3D,
|
image->dim == MALI_TEXTURE_DIMENSION_3D,
|
||||||
image->cubemap_stride, image->first_level),
|
image->cubemap_stride, image->first_level),
|
||||||
image->slices);
|
image->slices, &payload);
|
||||||
|
|
||||||
pan_pack(sampler.cpu, MIDGARD_SAMPLER, cfg)
|
pan_pack(sampler.cpu, MIDGARD_SAMPLER, cfg)
|
||||||
cfg.normalized_coordinates = false;
|
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,
|
.gpu = texture.gpu + MALI_BIFROST_TEXTURE_LENGTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
panfrost_new_texture_bifrost(pool->dev, (void *)texture.cpu,
|
panfrost_new_texture(pool->dev, (void *)texture.cpu,
|
||||||
image->width0, image->height0,
|
image->width0, image->height0,
|
||||||
MAX2(image->nr_samples, 1), 1,
|
MAX2(image->nr_samples, 1), 1,
|
||||||
image->format, MALI_TEXTURE_DIMENSION_2D,
|
image->format, MALI_TEXTURE_DIMENSION_2D,
|
||||||
image->modifier,
|
image->modifier,
|
||||||
image->first_level, image->last_level,
|
image->first_level, image->last_level,
|
||||||
0, 0,
|
0, 0,
|
||||||
image->nr_samples,
|
image->nr_samples,
|
||||||
0,
|
0,
|
||||||
(MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
|
(MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) |
|
||||||
(MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9),
|
(MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9),
|
||||||
image->bo->ptr.gpu + image->first_layer *
|
image->bo->ptr.gpu + image->first_layer *
|
||||||
panfrost_get_layer_stride(image->slices,
|
panfrost_get_layer_stride(image->slices,
|
||||||
image->dim == MALI_TEXTURE_DIMENSION_3D,
|
image->dim == MALI_TEXTURE_DIMENSION_3D,
|
||||||
image->cubemap_stride, image->first_level),
|
image->cubemap_stride, image->first_level),
|
||||||
image->slices,
|
image->slices, &payload);
|
||||||
&payload);
|
|
||||||
|
|
||||||
pan_pack(sampler.cpu, BIFROST_SAMPLER, cfg) {
|
pan_pack(sampler.cpu, BIFROST_SAMPLER, cfg) {
|
||||||
cfg.seamless_cube_map = false;
|
cfg.seamless_cube_map = false;
|
||||||
|
|
|
@ -407,82 +407,30 @@ panfrost_emit_texture_payload(const struct panfrost_device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
panfrost_new_texture(
|
panfrost_new_texture(const struct panfrost_device *dev,
|
||||||
const struct panfrost_device *dev,
|
void *out,
|
||||||
void *out,
|
uint16_t width, uint16_t height,
|
||||||
uint16_t width, uint16_t height,
|
uint16_t depth, uint16_t array_size,
|
||||||
uint16_t depth, uint16_t array_size,
|
enum pipe_format format,
|
||||||
enum pipe_format format,
|
enum mali_texture_dimension dim,
|
||||||
enum mali_texture_dimension dim,
|
uint64_t modifier,
|
||||||
uint64_t modifier,
|
unsigned first_level, unsigned last_level,
|
||||||
unsigned first_level, unsigned last_level,
|
unsigned first_layer, unsigned last_layer,
|
||||||
unsigned first_layer, unsigned last_layer,
|
unsigned nr_samples,
|
||||||
unsigned nr_samples,
|
unsigned cube_stride,
|
||||||
unsigned cube_stride,
|
unsigned swizzle,
|
||||||
unsigned swizzle,
|
mali_ptr base,
|
||||||
mali_ptr base,
|
struct panfrost_slice *slices,
|
||||||
struct panfrost_slice *slices)
|
const struct panfrost_ptr *payload)
|
||||||
{
|
{
|
||||||
const struct util_format_description *desc =
|
const struct util_format_description *desc =
|
||||||
util_format_description(format);
|
util_format_description(format);
|
||||||
|
|
||||||
|
bool is_bifrost = dev->quirks & IS_BIFROST;
|
||||||
bool manual_stride =
|
bool manual_stride =
|
||||||
panfrost_needs_explicit_stride(dev, modifier, format, slices,
|
panfrost_needs_explicit_stride(dev, modifier, format, slices,
|
||||||
width, first_level, last_level);
|
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,
|
panfrost_emit_texture_payload(dev,
|
||||||
payload->cpu,
|
payload->cpu,
|
||||||
desc,
|
desc,
|
||||||
|
@ -493,30 +441,47 @@ panfrost_new_texture_bifrost(
|
||||||
first_layer, last_layer,
|
first_layer, last_layer,
|
||||||
nr_samples,
|
nr_samples,
|
||||||
cube_stride,
|
cube_stride,
|
||||||
true, /* Stride explicit on Bifrost */
|
manual_stride,
|
||||||
base,
|
base,
|
||||||
slices);
|
slices);
|
||||||
|
|
||||||
pan_pack(out, BIFROST_TEXTURE, cfg) {
|
if (is_bifrost) {
|
||||||
cfg.dimension = dim;
|
pan_pack(out, BIFROST_TEXTURE, cfg) {
|
||||||
cfg.format = dev->formats[format].hw;
|
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);
|
/* We specify API-level LOD clamps in the sampler descriptor
|
||||||
cfg.height = u_minify(height, first_level);
|
* and use these clamps simply for bounds checking */
|
||||||
if (dim == MALI_TEXTURE_DIMENSION_3D)
|
cfg.minimum_lod = FIXED_16(0, false);
|
||||||
cfg.depth = u_minify(depth, first_level);
|
cfg.maximum_lod = FIXED_16(cfg.levels - 1, false);
|
||||||
else
|
}
|
||||||
cfg.sample_count = MAX2(nr_samples, 1);
|
} else {
|
||||||
cfg.swizzle = swizzle;
|
pan_pack(out, MIDGARD_TEXTURE, cfg) {
|
||||||
cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
|
cfg.width = u_minify(width, first_level);
|
||||||
cfg.levels = last_level - first_level + 1;
|
cfg.height = u_minify(height, first_level);
|
||||||
cfg.array_size = array_size;
|
if (dim == MALI_TEXTURE_DIMENSION_3D)
|
||||||
cfg.surfaces = payload->gpu;
|
cfg.depth = u_minify(depth, first_level);
|
||||||
|
else
|
||||||
/* We specify API-level LOD clamps in the sampler descriptor
|
cfg.sample_count = MAX2(1, nr_samples);
|
||||||
* and use these clamps simply for bounds checking */
|
cfg.array_size = array_size;
|
||||||
cfg.minimum_lod = FIXED_16(0, false);
|
cfg.format = panfrost_pipe_format_v6[format].hw;
|
||||||
cfg.maximum_lod = FIXED_16(cfg.levels - 1, false);
|
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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,40 +101,21 @@ panfrost_estimate_texture_payload_size(
|
||||||
enum mali_texture_dimension dim, uint64_t modifier);
|
enum mali_texture_dimension dim, uint64_t modifier);
|
||||||
|
|
||||||
void
|
void
|
||||||
panfrost_new_texture(
|
panfrost_new_texture(const struct panfrost_device *dev,
|
||||||
const struct panfrost_device *dev,
|
void *out,
|
||||||
void *out,
|
uint16_t width, uint16_t height,
|
||||||
uint16_t width, uint16_t height,
|
uint16_t depth, uint16_t array_size,
|
||||||
uint16_t depth, uint16_t array_size,
|
enum pipe_format format,
|
||||||
enum pipe_format format,
|
enum mali_texture_dimension dim,
|
||||||
enum mali_texture_dimension dim,
|
uint64_t modifier,
|
||||||
uint64_t modifier,
|
unsigned first_level, unsigned last_level,
|
||||||
unsigned first_level, unsigned last_level,
|
unsigned first_layer, unsigned last_layer,
|
||||||
unsigned first_layer, unsigned last_layer,
|
unsigned nr_samples,
|
||||||
unsigned nr_samples,
|
unsigned cube_stride,
|
||||||
unsigned cube_stride,
|
unsigned swizzle,
|
||||||
unsigned swizzle,
|
mali_ptr base,
|
||||||
mali_ptr base,
|
struct panfrost_slice *slices,
|
||||||
struct panfrost_slice *slices);
|
const struct panfrost_ptr *payload);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
panfrost_get_layer_stride(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level);
|
panfrost_get_layer_stride(struct panfrost_slice *slices, bool is_3d, unsigned cube_stride, unsigned level);
|
||||||
|
|
Loading…
Reference in New Issue