mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
freedreno/fdl, tu: Make mutable part of the image layout
Right now the image layout depends on the format for the R8G8 special case, but this is clearly wrong if we set the mutable bit because it could be reinterpreted. Refactor how it's set to make it part of the layout struct, rather than specified in the view. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32615>
This commit is contained in:
parent
ef4c752b6e
commit
ca91844fc7
10 changed files with 18 additions and 19 deletions
|
|
@ -116,7 +116,7 @@ bool
|
|||
fdl6_layout(struct fdl_layout *layout, const struct fd_dev_info *info,
|
||||
enum pipe_format format, uint32_t nr_samples, uint32_t width0,
|
||||
uint32_t height0, uint32_t depth0, uint32_t mip_levels,
|
||||
uint32_t array_size, bool is_3d,
|
||||
uint32_t array_size, bool is_3d, bool is_mutable,
|
||||
struct fdl_explicit_layout *explicit_layout)
|
||||
{
|
||||
uint32_t offset = 0, heightalign;
|
||||
|
|
@ -135,6 +135,7 @@ fdl6_layout(struct fdl_layout *layout, const struct fd_dev_info *info,
|
|||
layout->format = format;
|
||||
layout->nr_samples = nr_samples;
|
||||
layout->layer_first = !is_3d;
|
||||
layout->is_mutable = is_mutable;
|
||||
|
||||
fdl6_get_ubwc_blockwidth(layout, &ubwc_blockwidth, &ubwc_blockheight);
|
||||
|
||||
|
|
|
|||
|
|
@ -226,6 +226,8 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
|
|||
view->format = args->format;
|
||||
|
||||
memset(view->descriptor, 0, sizeof(view->descriptor));
|
||||
|
||||
bool is_mutable = layout->is_mutable && tile_mode == TILE6_3;
|
||||
|
||||
view->descriptor[0] =
|
||||
A6XX_TEX_CONST_0_TILE_MODE(tile_mode) |
|
||||
|
|
@ -237,7 +239,7 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
|
|||
A6XX_TEX_CONST_0_MIPLVLS(args->level_count - 1);
|
||||
view->descriptor[1] =
|
||||
A6XX_TEX_CONST_1_WIDTH(width) | A6XX_TEX_CONST_1_HEIGHT(height) |
|
||||
COND(args->ubwc_fc_mutable, A6XX_TEX_CONST_1_MUTABLEEN);
|
||||
COND(is_mutable, A6XX_TEX_CONST_1_MUTABLEEN);
|
||||
view->descriptor[2] =
|
||||
A6XX_TEX_CONST_2_PITCHALIGN(layout->pitchalign - 6) |
|
||||
A6XX_TEX_CONST_2_PITCH(pitch) |
|
||||
|
|
@ -325,7 +327,7 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
|
|||
COND(samples_average, A6XX_SP_PS_2D_SRC_INFO_SAMPLES_AVERAGE) |
|
||||
A6XX_SP_PS_2D_SRC_INFO_UNK20 |
|
||||
A6XX_SP_PS_2D_SRC_INFO_UNK22 |
|
||||
COND(args->ubwc_fc_mutable, A6XX_SP_PS_2D_SRC_INFO_MUTABLEEN);
|
||||
COND(is_mutable, A6XX_SP_PS_2D_SRC_INFO_MUTABLEEN);
|
||||
|
||||
view->SP_PS_2D_SRC_SIZE =
|
||||
A6XX_SP_PS_2D_SRC_SIZE_WIDTH(width) |
|
||||
|
|
@ -406,7 +408,7 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
|
|||
A6XX_RB_MRT_BUF_INFO_COLOR_FORMAT(color_format) |
|
||||
COND(args->chip >= A7XX && ubwc_enabled, A7XX_RB_MRT_BUF_INFO_LOSSLESSCOMPEN) |
|
||||
A6XX_RB_MRT_BUF_INFO_COLOR_SWAP(color_swap) |
|
||||
COND(args->ubwc_fc_mutable, A7XX_RB_MRT_BUF_INFO_MUTABLEEN);
|
||||
COND(is_mutable, A7XX_RB_MRT_BUF_INFO_MUTABLEEN);
|
||||
|
||||
view->SP_FS_MRT_REG =
|
||||
A6XX_SP_FS_MRT_REG_COLOR_FORMAT(color_format) |
|
||||
|
|
@ -419,7 +421,7 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
|
|||
A6XX_RB_2D_DST_INFO_COLOR_SWAP(color_swap) |
|
||||
COND(ubwc_enabled, A6XX_RB_2D_DST_INFO_FLAGS) |
|
||||
COND(util_format_is_srgb(args->format), A6XX_RB_2D_DST_INFO_SRGB) |
|
||||
COND(args->ubwc_fc_mutable, A6XX_RB_2D_DST_INFO_MUTABLEEN);;
|
||||
COND(is_mutable, A6XX_RB_2D_DST_INFO_MUTABLEEN);;
|
||||
|
||||
view->RB_BLIT_DST_INFO =
|
||||
A6XX_RB_BLIT_DST_INFO_TILE_MODE(tile_mode) |
|
||||
|
|
@ -427,7 +429,7 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
|
|||
A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(blit_format) |
|
||||
A6XX_RB_BLIT_DST_INFO_COLOR_SWAP(color_swap) |
|
||||
COND(ubwc_enabled, A6XX_RB_BLIT_DST_INFO_FLAGS) |
|
||||
COND(args->ubwc_fc_mutable, A6XX_RB_BLIT_DST_INFO_MUTABLEEN);
|
||||
COND(is_mutable, A6XX_RB_BLIT_DST_INFO_MUTABLEEN);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ fdl_test_layout(const struct testcase *testcase, const struct fd_dev_id *dev_id)
|
|||
MAX2(testcase->layout.nr_samples, 1), testcase->layout.width0,
|
||||
MAX2(testcase->layout.height0, 1),
|
||||
MAX2(testcase->layout.depth0, 1), mip_levels,
|
||||
MAX2(testcase->array_size, 1), testcase->is_3d, NULL);
|
||||
MAX2(testcase->array_size, 1), testcase->is_3d, false, NULL);
|
||||
} else {
|
||||
assert(fd_dev_gen(dev_id) >= 5);
|
||||
fdl5_layout(&layout, testcase->format,
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ struct fdl_layout {
|
|||
bool ubwc : 1;
|
||||
bool layer_first : 1; /* see above description */
|
||||
bool tile_all : 1;
|
||||
bool is_mutable : 1;
|
||||
|
||||
/* Note that for tiled textures, beyond a certain mipmap level (ie.
|
||||
* when width is less than block size) things switch to linear. In
|
||||
|
|
@ -239,7 +240,7 @@ void fdl5_layout(struct fdl_layout *layout, enum pipe_format format,
|
|||
bool fdl6_layout(struct fdl_layout *layout, const struct fd_dev_info *info,
|
||||
enum pipe_format format, uint32_t nr_samples, uint32_t width0,
|
||||
uint32_t height0, uint32_t depth0, uint32_t mip_levels,
|
||||
uint32_t array_size, bool is_3d,
|
||||
uint32_t array_size, bool is_3d, bool is_mutable,
|
||||
struct fdl_explicit_layout *plane_layout);
|
||||
|
||||
static inline void
|
||||
|
|
@ -280,7 +281,6 @@ struct fdl_view_args {
|
|||
enum pipe_format format;
|
||||
enum fdl_view_type type;
|
||||
enum fdl_chroma_location chroma_offsets[2];
|
||||
bool ubwc_fc_mutable;
|
||||
};
|
||||
|
||||
#define FDL6_TEX_CONST_DWORDS 16
|
||||
|
|
|
|||
|
|
@ -2176,7 +2176,6 @@ tu_image_view_copy_blit(struct fdl6_view *iview,
|
|||
},
|
||||
.format = tu_format_for_aspect(format, aspect_mask),
|
||||
.type = z_scale ? FDL_VIEW_TYPE_3D : FDL_VIEW_TYPE_2D,
|
||||
.ubwc_fc_mutable = image->ubwc_fc_mutable,
|
||||
};
|
||||
fdl6_view_init(iview, &layout, &args, false);
|
||||
}
|
||||
|
|
@ -2912,6 +2911,7 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd,
|
|||
1,
|
||||
layer_count,
|
||||
extent.depth > 1,
|
||||
false,
|
||||
NULL);
|
||||
|
||||
struct tu_bo *staging_bo;
|
||||
|
|
@ -2935,7 +2935,6 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd,
|
|||
.swiz = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W },
|
||||
.format = tu_format_for_aspect(src_format, VK_IMAGE_ASPECT_COLOR_BIT),
|
||||
.type = FDL_VIEW_TYPE_2D,
|
||||
.ubwc_fc_mutable = false,
|
||||
};
|
||||
fdl6_view_init(&staging, &staging_layout_ptr, ©_to_args, false);
|
||||
|
||||
|
|
@ -2966,7 +2965,6 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd,
|
|||
.swiz = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W },
|
||||
.format = tu_format_for_aspect(dst_format, VK_IMAGE_ASPECT_COLOR_BIT),
|
||||
.type = FDL_VIEW_TYPE_2D,
|
||||
.ubwc_fc_mutable = false,
|
||||
};
|
||||
fdl6_view_init(&staging, &staging_layout_ptr, ©_from_args, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,6 @@ tu_image_view_init(struct tu_device *device,
|
|||
args.level_count = vk_image_subresource_level_count(&image->vk, range);
|
||||
args.min_lod_clamp = iview->vk.min_lod;
|
||||
args.format = tu_format_for_aspect(format, aspect_mask);
|
||||
args.ubwc_fc_mutable = image->ubwc_fc_mutable;
|
||||
vk_component_mapping_to_pipe_swizzle(pCreateInfo->components, args.swiz);
|
||||
if (conversion) {
|
||||
unsigned char conversion_swiz[4], create_swiz[4];
|
||||
|
|
@ -548,6 +547,7 @@ tu_image_update_layout(struct tu_device *device, struct tu_image *image,
|
|||
image->vk.mip_levels,
|
||||
image->vk.array_layers,
|
||||
image->vk.image_type == VK_IMAGE_TYPE_3D,
|
||||
image->is_mutable,
|
||||
plane_layouts ? &plane_layout : NULL)) {
|
||||
assert(plane_layouts); /* can only fail with explicit layout */
|
||||
return vk_error(device, VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
|
||||
|
|
@ -730,7 +730,7 @@ tu_image_init(struct tu_device *device, struct tu_image *image,
|
|||
image->force_linear_tile = true;
|
||||
}
|
||||
|
||||
image->ubwc_fc_mutable = image->ubwc_enabled && mutable_ubwc_fc;
|
||||
image->is_mutable = image->ubwc_enabled && mutable_ubwc_fc;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct tu_image
|
|||
|
||||
bool ubwc_enabled;
|
||||
bool force_linear_tile;
|
||||
bool ubwc_fc_mutable;
|
||||
bool is_mutable;
|
||||
};
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE)
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ fd6_image_descriptor(struct fd_context *ctx, const struct pipe_image_view *buf,
|
|||
.type = fdl_type_from_pipe_target(buf->resource->target),
|
||||
.chroma_offsets = {FDL_CHROMA_LOCATION_COSITED_EVEN,
|
||||
FDL_CHROMA_LOCATION_COSITED_EVEN},
|
||||
.ubwc_fc_mutable = false,
|
||||
};
|
||||
|
||||
/* fdl6_view makes the storage descriptor treat cubes like a 2D array (so
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ fd6_setup_slices(struct fd_resource *rsc)
|
|||
|
||||
fdl6_layout(&rsc->layout, screen->info, prsc->format, fd_resource_nr_samples(prsc),
|
||||
prsc->width0, prsc->height0, prsc->depth0, prsc->last_level + 1,
|
||||
prsc->array_size, prsc->target == PIPE_TEXTURE_3D, NULL);
|
||||
prsc->array_size, prsc->target == PIPE_TEXTURE_3D, false, NULL);
|
||||
|
||||
return rsc->layout.size;
|
||||
}
|
||||
|
|
@ -318,7 +318,7 @@ fill_ubwc_buffer_sizes(struct fd_resource *rsc)
|
|||
|
||||
if (!fdl6_layout(&rsc->layout, screen->info, prsc->format, fd_resource_nr_samples(prsc),
|
||||
prsc->width0, prsc->height0, prsc->depth0,
|
||||
prsc->last_level + 1, prsc->array_size, false, &l))
|
||||
prsc->last_level + 1, prsc->array_size, false, false, &l))
|
||||
return -1;
|
||||
|
||||
if (rsc->layout.size > fd_bo_size(rsc->bo))
|
||||
|
|
|
|||
|
|
@ -437,7 +437,6 @@ fd6_sampler_view_update(struct fd_context *ctx,
|
|||
.type = fdl_type_from_pipe_target(cso->target),
|
||||
.chroma_offsets = {FDL_CHROMA_LOCATION_COSITED_EVEN,
|
||||
FDL_CHROMA_LOCATION_COSITED_EVEN},
|
||||
.ubwc_fc_mutable = false,
|
||||
};
|
||||
|
||||
if (rsc->b.b.format == PIPE_FORMAT_R8_G8B8_420_UNORM) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue