diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index e81e983bcbd..73cf3f2f1b6 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -820,17 +820,12 @@ panfrost_load_surface(struct panfrost_batch *batch, struct pipe_surface *surf, u panfrost_translate_texture_dimension(rsrc->base.target); struct pan_image img = { - .width0 = rsrc->base.width0, - .height0 = rsrc->base.height0, - .depth0 = rsrc->base.depth0, .format = format, .dim = dim, - .array_size = rsrc->base.array_size, .first_level = level, .last_level = level, .first_layer = surf->u.tex.first_layer, .last_layer = surf->u.tex.last_layer, - .nr_samples = rsrc->base.nr_samples, .bo = rsrc->bo, .layout = &rsrc->layout, }; diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index e5e3c10e25c..e4c7541ab80 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -86,6 +86,12 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, rsc->modifier_constant = true; rsc->layout.slices[0].line_stride = whandle->stride; rsc->layout.slices[0].row_stride = whandle->stride; + rsc->layout.width = prsc->width0; + rsc->layout.height = prsc->height0; + rsc->layout.depth = prsc->depth0; + rsc->layout.nr_samples = prsc->nr_samples; + rsc->layout.array_size = prsc->array_size; + rsc->layout.data_size = rsc->bo->size; if (rsc->layout.modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED || drm_is_afbc(rsc->layout.modifier)) { @@ -341,6 +347,11 @@ panfrost_setup_layout(struct panfrost_device *dev, unsigned depth = res->depth0; unsigned bytes_per_pixel = util_format_get_blocksize(pres->layout.format); + pres->layout.width = width; + pres->layout.height = height; + pres->layout.depth = height; + pres->layout.array_size = res->array_size; + /* Z32_S8X24 variants are actually stored in 2 planes (one per * component), we have to adjust the bytes_per_pixel value accordingly. */ @@ -352,6 +363,7 @@ panfrost_setup_layout(struct panfrost_device *dev, * sample #, horrifyingly enough */ unsigned nr_samples = MAX2(res->nr_samples, 1); + pres->layout.nr_samples = nr_samples; assert(depth == 1 || nr_samples == 1); @@ -472,8 +484,10 @@ panfrost_setup_layout(struct panfrost_device *dev, /* Arrays and cubemaps have the entire miptree duplicated */ pres->layout.array_stride = ALIGN_POT(offset, 64); + pres->layout.data_size = + ALIGN_POT(pres->layout.array_stride * res->array_size, 4096); if (bo_size) - *bo_size = ALIGN_POT(pres->layout.array_stride * res->array_size, 4096); + *bo_size = pres->layout.data_size; } static inline bool diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c index 95cc9057053..9d8d7970dc9 100644 --- a/src/panfrost/lib/pan_blit.c +++ b/src/panfrost/lib/pan_blit.c @@ -214,8 +214,8 @@ panfrost_load_emit_viewport(struct pan_pool *pool, struct MALI_DRAW *draw, struct pan_image *image) { struct panfrost_ptr t = panfrost_pool_alloc_desc(pool, VIEWPORT); - unsigned width = u_minify(image->width0, image->first_level); - unsigned height = u_minify(image->height0, image->first_level); + unsigned width = u_minify(image->layout->width, image->first_level); + unsigned height = u_minify(image->layout->height, image->first_level); pan_pack(t.cpu, VIEWPORT, cfg) { cfg.scissor_maximum_x = width - 1; /* Inclusive */ @@ -236,7 +236,7 @@ panfrost_load_prepare_rsd(struct pan_pool *pool, struct MALI_RENDERER_STATE *sta (util_format_is_pure_uint(image->format)) ? PAN_BLIT_UINT : (util_format_is_pure_sint(image->format)) ? PAN_BLIT_INT : PAN_BLIT_FLOAT; - bool ms = image->nr_samples > 1; + bool ms = image->layout->nr_samples > 1; const struct pan_blit_shader *shader = &pool->dev->blit_shaders.loads[loc][T][ms]; @@ -311,7 +311,7 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw, struct panfrost_ptr texture = panfrost_pool_alloc_desc_aggregate(pool, PAN_DESC(MIDGARD_TEXTURE), - PAN_DESC_ARRAY(MAX2(image->nr_samples, 1), + PAN_DESC_ARRAY(image->layout->nr_samples, SURFACE_WITH_STRIDE)); struct panfrost_ptr payload = { @@ -337,11 +337,11 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw, }; panfrost_new_texture(pool->dev, image->layout, texture.cpu, - image->width0, image->height0, 1, 1, + image->layout->width, image->layout->height, 1, 1, image->format, MALI_TEXTURE_DIMENSION_2D, image->first_level, image->last_level, 0, 0, - image->nr_samples, + image->layout->nr_samples, swizzle, image->bo->ptr.gpu + offset, &payload); @@ -494,7 +494,7 @@ bifrost_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw, struct panfrost_ptr texture = panfrost_pool_alloc_desc_aggregate(pool, PAN_DESC(BIFROST_TEXTURE), - PAN_DESC_ARRAY(MAX2(image->nr_samples, 1), + PAN_DESC_ARRAY(image->layout->nr_samples, SURFACE_WITH_STRIDE)); struct panfrost_ptr sampler = panfrost_pool_alloc_desc(pool, BIFROST_SAMPLER); @@ -512,11 +512,11 @@ bifrost_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw, }; panfrost_new_texture(pool->dev, image->layout, texture.cpu, - image->width0, image->height0, 1, 1, + image->layout->width, image->layout->height, 1, 1, image->format, MALI_TEXTURE_DIMENSION_2D, image->first_level, image->last_level, 0, 0, - image->nr_samples, + image->layout->nr_samples, swizzle, image->bo->ptr.gpu + offset, &payload); @@ -620,7 +620,7 @@ bifrost_load_emit_rsd(struct pan_pool *pool, struct MALI_DRAW *draw, } cfg.properties.bifrost.allow_forward_pixel_to_kill = true; cfg.preload.fragment.coverage = true; - cfg.preload.fragment.sample_mask_id = image->nr_samples > 1; + cfg.preload.fragment.sample_mask_id = image->layout->nr_samples > 1; } for (unsigned i = 0; i < 8; ++i) { diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h index a3e5c454183..6ac54d18888 100644 --- a/src/panfrost/lib/pan_texture.h +++ b/src/panfrost/lib/pan_texture.h @@ -75,9 +75,13 @@ struct pan_image_slice_layout { struct pan_image_layout { uint64_t modifier; enum pipe_format format; + unsigned width, height, depth; + unsigned nr_samples; enum mali_texture_dimension dim; struct pan_image_slice_layout slices[MAX_MIP_LEVELS]; + unsigned array_size; unsigned array_stride; + unsigned data_size; }; struct pan_image_slice_state { @@ -94,12 +98,10 @@ struct pan_image_state { struct pan_image { /* Format and size */ - uint16_t width0, height0, depth0, array_size; enum pipe_format format; enum mali_texture_dimension dim; unsigned first_level, last_level; unsigned first_layer, last_layer; - unsigned nr_samples; struct panfrost_bo *bo; const struct pan_image_layout *layout; };