anv: Make anv_image_aspect_to_plane take an anv_image*
It's called anv_image_* so it really should take an anv_image. For the couple of cases where we really want to pass in a set of aspects, we leave an anv_aspect_to_plane() helper. anv_image_aspect_to_plane() is then just a wrapper around it which grabs the aspects from the image. While we're in the area, sprinkle some const around. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12141>
This commit is contained in:
committed by
Marge Bot
parent
e37c2d923a
commit
56fe30cbfc
@@ -205,7 +205,7 @@ get_blorp_surf_for_anv_image(const struct anv_device *device,
|
||||
enum isl_aux_usage aux_usage,
|
||||
struct blorp_surf *blorp_surf)
|
||||
{
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
if (layout != ANV_IMAGE_LAYOUT_EXPLICIT_AUX) {
|
||||
assert(usage != 0);
|
||||
@@ -274,7 +274,7 @@ get_blorp_surf_for_anv_shadow_image(const struct anv_device *device,
|
||||
struct blorp_surf *blorp_surf)
|
||||
{
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
if (!anv_surface_is_valid(&image->planes[plane].shadow_surface))
|
||||
return false;
|
||||
|
||||
@@ -1620,8 +1620,8 @@ anv_image_clear_depth_stencil(struct anv_cmd_buffer *cmd_buffer,
|
||||
|
||||
struct blorp_surf stencil = {};
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
get_blorp_surf_for_anv_image(cmd_buffer->device,
|
||||
image, VK_IMAGE_ASPECT_STENCIL_BIT,
|
||||
0, ANV_IMAGE_LAYOUT_EXPLICIT_AUX,
|
||||
@@ -1686,7 +1686,7 @@ anv_image_hiz_op(struct anv_cmd_buffer *cmd_buffer,
|
||||
{
|
||||
assert(aspect == VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
assert(base_layer + layer_count <= anv_image_aux_layers(image, aspect, level));
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
assert(plane == 0);
|
||||
|
||||
struct blorp_batch batch;
|
||||
@@ -1719,8 +1719,8 @@ anv_image_hiz_clear(struct anv_cmd_buffer *cmd_buffer,
|
||||
|
||||
struct blorp_surf depth = {};
|
||||
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
assert(base_layer + layer_count <=
|
||||
anv_image_aux_layers(image, VK_IMAGE_ASPECT_DEPTH_BIT, level));
|
||||
get_blorp_surf_for_anv_image(cmd_buffer->device,
|
||||
@@ -1731,8 +1731,8 @@ anv_image_hiz_clear(struct anv_cmd_buffer *cmd_buffer,
|
||||
|
||||
struct blorp_surf stencil = {};
|
||||
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
get_blorp_surf_for_anv_image(cmd_buffer->device,
|
||||
image, VK_IMAGE_ASPECT_STENCIL_BIT,
|
||||
0, ANV_IMAGE_LAYOUT_EXPLICIT_AUX,
|
||||
@@ -1888,7 +1888,7 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,
|
||||
assert(base_layer + layer_count <=
|
||||
anv_image_aux_layers(image, aspect, level));
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
struct blorp_batch batch;
|
||||
blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer,
|
||||
|
||||
@@ -537,7 +537,7 @@ anv_get_format_aspect(const struct intel_device_info *devinfo,
|
||||
VkImageAspectFlagBits aspect, VkImageTiling tiling)
|
||||
{
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(vk_format_aspects(vk_format), aspect);
|
||||
anv_aspect_to_plane(vk_format_aspects(vk_format), aspect);
|
||||
return anv_get_format_plane(devinfo, vk_format, plane, tiling);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ image_aspect_to_binding(struct anv_image *image, VkImageAspectFlags aspect)
|
||||
|
||||
plane = aspect - VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT;
|
||||
} else {
|
||||
plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
plane = anv_image_aspect_to_plane(image, aspect);
|
||||
}
|
||||
|
||||
return &image->bindings[ANV_IMAGE_MEMORY_BINDING_PLANE_0 + plane];
|
||||
@@ -1033,7 +1033,7 @@ add_all_surfaces_implicit_layout(
|
||||
|
||||
u_foreach_bit(b, image->aspects) {
|
||||
VkImageAspectFlagBits aspect = 1 << b;
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
const struct anv_format_plane plane_format =
|
||||
anv_get_format_plane(devinfo, image->vk_format, plane, image->tiling);
|
||||
|
||||
@@ -1154,7 +1154,7 @@ add_all_surfaces_explicit_layout(
|
||||
|
||||
u_foreach_bit(b, image->aspects) {
|
||||
const VkImageAspectFlagBits aspect = 1 << b;
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
const struct anv_format_plane format_plane =
|
||||
anv_get_format_plane(devinfo, image->vk_format, plane, image->tiling);
|
||||
const VkSubresourceLayout *primary_layout = &drm_info->pPlaneLayouts[plane];
|
||||
@@ -1885,8 +1885,8 @@ void anv_GetImageSubresourceLayout(
|
||||
surface = &image->planes[mem_plane].primary_surface;
|
||||
}
|
||||
} else {
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
subresource->aspectMask);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, subresource->aspectMask);
|
||||
surface = &image->planes[plane].primary_surface;
|
||||
}
|
||||
|
||||
@@ -2114,7 +2114,7 @@ anv_layout_to_aux_state(const struct intel_device_info * const devinfo,
|
||||
|
||||
/* Determine the optimal buffer. */
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
/* If we don't have an aux buffer then aux state makes no sense */
|
||||
const enum isl_aux_usage aux_usage = image->planes[plane].aux_usage;
|
||||
@@ -2312,7 +2312,7 @@ anv_layout_to_aux_usage(const struct intel_device_info * const devinfo,
|
||||
const VkImageUsageFlagBits usage,
|
||||
const VkImageLayout layout)
|
||||
{
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
/* If there is no auxiliary surface allocated, we must use the one and only
|
||||
* main buffer.
|
||||
@@ -2381,7 +2381,7 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo,
|
||||
if (INTEL_DEBUG & DEBUG_NO_FAST_CLEAR)
|
||||
return ANV_FAST_CLEAR_NONE;
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
/* If there is no auxiliary surface allocated, there are no fast-clears */
|
||||
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
|
||||
@@ -2478,7 +2478,7 @@ anv_image_fill_surface_state(struct anv_device *device,
|
||||
struct anv_surface_state *state_inout,
|
||||
struct brw_image_param *image_param_out)
|
||||
{
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
const struct anv_surface *surface = &image->planes[plane].primary_surface,
|
||||
*aux_surface = &image->planes[plane].aux_surface;
|
||||
@@ -2775,9 +2775,9 @@ anv_CreateImageView(VkDevice _device,
|
||||
*/
|
||||
anv_foreach_image_aspect_bit(iaspect_bit, image, iview->aspects) {
|
||||
const uint32_t iplane =
|
||||
anv_image_aspect_to_plane(image->aspects, 1UL << iaspect_bit);
|
||||
anv_aspect_to_plane(image->aspects, 1UL << iaspect_bit);
|
||||
const uint32_t vplane =
|
||||
anv_image_aspect_to_plane(iview->aspects, 1UL << iaspect_bit);
|
||||
anv_aspect_to_plane(iview->aspects, 1UL << iaspect_bit);
|
||||
struct anv_format_plane format;
|
||||
if (image->aspects & (VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||
|
||||
@@ -3808,15 +3808,10 @@ anv_assert_valid_aspect_set(VkImageAspectFlags aspects)
|
||||
* instance, all_aspects would be the set of aspects in the image. For
|
||||
* an image view, all_aspects would be the subset of aspects represented
|
||||
* by that particular view.
|
||||
*
|
||||
* Return the aspect's _format_ plane, not its _memory_ plane (using the
|
||||
* vocabulary of VK_EXT_image_drm_format_modifier). As a consequence, \a
|
||||
* aspect_mask may contain VK_IMAGE_ASPECT_PLANE_*, but must not contain
|
||||
* VK_IMAGE_ASPECT_MEMORY_PLANE_* .
|
||||
*/
|
||||
static inline uint32_t
|
||||
anv_image_aspect_to_plane(VkImageAspectFlags all_aspects,
|
||||
VkImageAspectFlagBits aspect)
|
||||
anv_aspect_to_plane(VkImageAspectFlags all_aspects,
|
||||
VkImageAspectFlagBits aspect)
|
||||
{
|
||||
anv_assert_valid_aspect_set(all_aspects);
|
||||
assert(util_bitcount(aspect) == 1);
|
||||
@@ -4075,12 +4070,25 @@ enum anv_fast_clear_type {
|
||||
ANV_FAST_CLEAR_ANY = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the aspect's _format_ plane, not its _memory_ plane (using the
|
||||
* vocabulary of VK_EXT_image_drm_format_modifier). As a consequence, \a
|
||||
* aspect_mask may contain VK_IMAGE_ASPECT_PLANE_*, but must not contain
|
||||
* VK_IMAGE_ASPECT_MEMORY_PLANE_* .
|
||||
*/
|
||||
static inline uint32_t
|
||||
anv_image_aspect_to_plane(const struct anv_image *image,
|
||||
VkImageAspectFlagBits aspect)
|
||||
{
|
||||
return anv_aspect_to_plane(image->aspects, aspect);
|
||||
}
|
||||
|
||||
/* Returns the number of auxiliary buffer levels attached to an image. */
|
||||
static inline uint8_t
|
||||
anv_image_aux_levels(const struct anv_image * const image,
|
||||
VkImageAspectFlagBits aspect)
|
||||
{
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
|
||||
return 0;
|
||||
|
||||
@@ -4129,7 +4137,7 @@ anv_image_get_clear_color_addr(UNUSED const struct anv_device *device,
|
||||
assert(image->aspects & (VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV |
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT));
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
const struct anv_image_memory_range *mem_range =
|
||||
&image->planes[plane].fast_clear_memory_range;
|
||||
|
||||
@@ -4158,7 +4166,7 @@ anv_image_get_compression_state_addr(const struct anv_device *device,
|
||||
{
|
||||
assert(level < anv_image_aux_levels(image, aspect));
|
||||
assert(array_layer < anv_image_aux_layers(image, aspect, level));
|
||||
UNUSED uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
UNUSED uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E);
|
||||
|
||||
/* Relative to start of the plane's fast clear memory range */
|
||||
@@ -4219,7 +4227,7 @@ anv_can_sample_mcs_with_clear(const struct intel_device_info * const devinfo,
|
||||
{
|
||||
assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
|
||||
assert(isl_aux_usage_has_mcs(image->planes[plane].aux_usage));
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ anv_image_init_aux_tt(struct anv_cmd_buffer *cmd_buffer,
|
||||
uint32_t base_level, uint32_t level_count,
|
||||
uint32_t base_layer, uint32_t layer_count)
|
||||
{
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
const struct anv_surface *surface = &image->planes[plane].primary_surface;
|
||||
uint64_t base_address =
|
||||
@@ -599,8 +599,8 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
VkImageLayout final_layout,
|
||||
bool will_full_fast_clear)
|
||||
{
|
||||
uint32_t depth_plane =
|
||||
anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
const uint32_t depth_plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
if (image->planes[depth_plane].aux_usage == ISL_AUX_USAGE_NONE)
|
||||
return;
|
||||
|
||||
@@ -686,8 +686,8 @@ transition_stencil_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
bool will_full_fast_clear)
|
||||
{
|
||||
#if GFX_VER == 7
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
||||
/* On gfx7, we have to store a texturable version of the stencil buffer in
|
||||
* a shadow whenever VK_IMAGE_USAGE_SAMPLED_BIT is set and copy back and
|
||||
@@ -714,8 +714,8 @@ transition_stencil_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
base_layer, layer_count);
|
||||
}
|
||||
#elif GFX_VER == 12
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE)
|
||||
return;
|
||||
|
||||
@@ -772,7 +772,7 @@ set_image_compressed_bit(struct anv_cmd_buffer *cmd_buffer,
|
||||
uint32_t base_layer, uint32_t layer_count,
|
||||
bool compressed)
|
||||
{
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
/* We only have compression tracking for CCS_E */
|
||||
if (image->planes[plane].aux_usage != ISL_AUX_USAGE_CCS_E)
|
||||
@@ -947,7 +947,7 @@ anv_cmd_predicated_ccs_resolve(struct anv_cmd_buffer *cmd_buffer,
|
||||
enum isl_aux_op resolve_op,
|
||||
enum anv_fast_clear_type fast_clear_supported)
|
||||
{
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
#if GFX_VER >= 9
|
||||
anv_cmd_compute_resolve_predicate(cmd_buffer, image,
|
||||
@@ -1216,7 +1216,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||
const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
|
||||
|
||||
if (anv_surface_is_valid(&image->planes[plane].shadow_surface) &&
|
||||
final_layout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
|
||||
@@ -5757,8 +5757,8 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
|
||||
info.view = &iview->planes[0].isl;
|
||||
|
||||
if (image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT)) {
|
||||
uint32_t depth_plane =
|
||||
anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
const uint32_t depth_plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
const struct anv_surface *depth_surface =
|
||||
&image->planes[depth_plane].primary_surface;
|
||||
const struct anv_address depth_address =
|
||||
@@ -5796,8 +5796,8 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
|
||||
}
|
||||
|
||||
if (image && (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||
uint32_t stencil_plane =
|
||||
anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t stencil_plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const struct anv_surface *stencil_surface =
|
||||
&image->planes[stencil_plane].primary_surface;
|
||||
const struct anv_address stencil_address =
|
||||
@@ -6534,8 +6534,8 @@ cmd_buffer_end_subpass(struct anv_cmd_buffer *cmd_buffer)
|
||||
dst_state->current_stencil_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
|
||||
enum isl_aux_usage src_aux_usage = ISL_AUX_USAGE_NONE;
|
||||
uint32_t plane = anv_image_aspect_to_plane(dst_iview->image->aspects,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(dst_iview->image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
enum isl_aux_usage dst_aux_usage =
|
||||
dst_iview->image->planes[plane].aux_usage;
|
||||
|
||||
@@ -6584,8 +6584,8 @@ cmd_buffer_end_subpass(struct anv_cmd_buffer *cmd_buffer)
|
||||
const struct anv_image *image = iview->image;
|
||||
|
||||
if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
|
||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects,
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
const uint32_t plane =
|
||||
anv_image_aspect_to_plane(image, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
||||
if (anv_surface_is_valid(&image->planes[plane].shadow_surface) &&
|
||||
att_state->current_stencil_layout == VK_IMAGE_LAYOUT_GENERAL) {
|
||||
|
||||
Reference in New Issue
Block a user