anv,hasvk: migrate to u_minify from util
Signed-off-by: Rohan Garg <rohan.garg@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20104>
This commit is contained in:
@@ -955,12 +955,12 @@ void anv_CmdClearColorImage(
|
||||
|
||||
for (uint32_t i = 0; i < level_count; i++) {
|
||||
const unsigned level = pRanges[r].baseMipLevel + i;
|
||||
const unsigned level_width = anv_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = anv_minify(image->vk.extent.height, level);
|
||||
const unsigned level_width = u_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = u_minify(image->vk.extent.height, level);
|
||||
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D) {
|
||||
base_layer = 0;
|
||||
layer_count = anv_minify(image->vk.extent.depth, level);
|
||||
layer_count = u_minify(image->vk.extent.depth, level);
|
||||
}
|
||||
|
||||
anv_cmd_buffer_mark_image_written(cmd_buffer, image,
|
||||
@@ -1028,11 +1028,11 @@ void anv_CmdClearDepthStencilImage(
|
||||
|
||||
for (uint32_t i = 0; i < level_count; i++) {
|
||||
const unsigned level = pRanges[r].baseMipLevel + i;
|
||||
const unsigned level_width = anv_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = anv_minify(image->vk.extent.height, level);
|
||||
const unsigned level_width = u_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = u_minify(image->vk.extent.height, level);
|
||||
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D)
|
||||
layer_count = anv_minify(image->vk.extent.depth, level);
|
||||
layer_count = u_minify(image->vk.extent.depth, level);
|
||||
|
||||
blorp_clear_depth_stencil(&batch, &depth, &stencil,
|
||||
level, base_layer, layer_count,
|
||||
@@ -1758,8 +1758,8 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,
|
||||
image->planes[plane].aux_usage,
|
||||
&surf);
|
||||
|
||||
uint32_t level_width = anv_minify(surf.surf->logical_level0_px.w, level);
|
||||
uint32_t level_height = anv_minify(surf.surf->logical_level0_px.h, level);
|
||||
uint32_t level_width = u_minify(surf.surf->logical_level0_px.w, level);
|
||||
uint32_t level_height = u_minify(surf.surf->logical_level0_px.h, level);
|
||||
|
||||
/* Blorp will store the clear color for us if we provide the clear color
|
||||
* address and we are doing a fast clear. So we save the clear value into
|
||||
|
||||
@@ -599,7 +599,7 @@ add_aux_state_tracking_buffer(struct anv_device *device,
|
||||
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E) {
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D) {
|
||||
for (uint32_t l = 0; l < image->vk.mip_levels; l++)
|
||||
state_size += anv_minify(image->vk.extent.depth, l) * 4;
|
||||
state_size += u_minify(image->vk.extent.depth, l) * 4;
|
||||
} else {
|
||||
state_size += image->vk.mip_levels * image->vk.array_layers * 4;
|
||||
}
|
||||
@@ -1942,8 +1942,8 @@ void anv_GetImageSubresourceLayout(
|
||||
0 /* logical_z_offset_px */,
|
||||
&offset_B, NULL, NULL);
|
||||
layout->offset += offset_B;
|
||||
layout->size = layout->rowPitch * anv_minify(image->vk.extent.height,
|
||||
subresource->mipLevel) *
|
||||
layout->size = layout->rowPitch * u_minify(image->vk.extent.height,
|
||||
subresource->mipLevel) *
|
||||
image->vk.extent.depth;
|
||||
} else {
|
||||
layout->size = surface->memory_range.size;
|
||||
|
||||
@@ -329,15 +329,6 @@ anv_is_aligned(uintmax_t n, uintmax_t a)
|
||||
return (n & (a - 1)) == 0;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
anv_minify(uint32_t n, uint32_t levels)
|
||||
{
|
||||
if (unlikely(n == 0))
|
||||
return 0;
|
||||
else
|
||||
return u_minify(n, levels);
|
||||
}
|
||||
|
||||
static inline union isl_color_value
|
||||
vk_to_isl_color(VkClearColorValue color)
|
||||
{
|
||||
@@ -3697,7 +3688,7 @@ anv_image_get_compression_state_addr(const struct anv_device *device,
|
||||
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D) {
|
||||
for (uint32_t l = 0; l < level; l++)
|
||||
offset += anv_minify(image->vk.extent.depth, l) * 4;
|
||||
offset += u_minify(image->vk.extent.depth, l) * 4;
|
||||
} else {
|
||||
offset += level * image->vk.array_layers * 4;
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ anv_image_init_aux_tt(struct anv_cmd_buffer *cmd_buffer,
|
||||
* higher the LOD.
|
||||
*/
|
||||
assert(layer < image->vk.extent.depth);
|
||||
if (layer >= anv_minify(image->vk.extent.depth, level))
|
||||
if (layer >= u_minify(image->vk.extent.depth, level))
|
||||
break;
|
||||
logical_z_offset_px = layer;
|
||||
} else {
|
||||
@@ -676,8 +676,8 @@ transition_stencil_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
const VkRect2D clear_rect = {
|
||||
.offset.x = 0,
|
||||
.offset.y = 0,
|
||||
.extent.width = anv_minify(image->vk.extent.width, level),
|
||||
.extent.height = anv_minify(image->vk.extent.height, level),
|
||||
.extent.width = u_minify(image->vk.extent.width, level),
|
||||
.extent.height = u_minify(image->vk.extent.height, level),
|
||||
};
|
||||
|
||||
uint32_t aux_layers =
|
||||
@@ -1016,7 +1016,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
layer_count != VK_REMAINING_ARRAY_LAYERS);
|
||||
/* Ensure the subresource range is valid. */
|
||||
UNUSED uint64_t last_level_num = base_level + level_count;
|
||||
const uint32_t max_depth = anv_minify(image->vk.extent.depth, base_level);
|
||||
const uint32_t max_depth = u_minify(image->vk.extent.depth, base_level);
|
||||
UNUSED const uint32_t image_layers = MAX2(image->vk.array_layers, max_depth);
|
||||
assert((uint64_t)base_layer + layer_count <= image_layers);
|
||||
assert(last_level_num <= image->vk.mip_levels);
|
||||
@@ -3870,7 +3870,7 @@ cmd_buffer_barrier(struct anv_cmd_buffer *cmd_buffer,
|
||||
uint32_t base_layer, layer_count;
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D) {
|
||||
base_layer = 0;
|
||||
layer_count = anv_minify(image->vk.extent.depth, range->baseMipLevel);
|
||||
layer_count = u_minify(image->vk.extent.depth, range->baseMipLevel);
|
||||
} else {
|
||||
base_layer = range->baseArrayLayer;
|
||||
layer_count = vk_image_subresource_layer_count(&image->vk, range);
|
||||
|
||||
@@ -1018,12 +1018,12 @@ void anv_CmdClearColorImage(
|
||||
|
||||
for (uint32_t i = 0; i < level_count; i++) {
|
||||
const unsigned level = pRanges[r].baseMipLevel + i;
|
||||
const unsigned level_width = anv_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = anv_minify(image->vk.extent.height, level);
|
||||
const unsigned level_width = u_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = u_minify(image->vk.extent.height, level);
|
||||
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D) {
|
||||
base_layer = 0;
|
||||
layer_count = anv_minify(image->vk.extent.depth, level);
|
||||
layer_count = u_minify(image->vk.extent.depth, level);
|
||||
}
|
||||
|
||||
anv_cmd_buffer_mark_image_written(cmd_buffer, image,
|
||||
@@ -1097,11 +1097,11 @@ void anv_CmdClearDepthStencilImage(
|
||||
|
||||
for (uint32_t i = 0; i < level_count; i++) {
|
||||
const unsigned level = pRanges[r].baseMipLevel + i;
|
||||
const unsigned level_width = anv_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = anv_minify(image->vk.extent.height, level);
|
||||
const unsigned level_width = u_minify(image->vk.extent.width, level);
|
||||
const unsigned level_height = u_minify(image->vk.extent.height, level);
|
||||
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D)
|
||||
layer_count = anv_minify(image->vk.extent.depth, level);
|
||||
layer_count = u_minify(image->vk.extent.depth, level);
|
||||
|
||||
blorp_clear_depth_stencil(&batch, &depth, &stencil,
|
||||
level, base_layer, layer_count,
|
||||
@@ -1883,8 +1883,8 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,
|
||||
image->planes[plane].aux_usage,
|
||||
&surf);
|
||||
|
||||
uint32_t level_width = anv_minify(surf.surf->logical_level0_px.w, level);
|
||||
uint32_t level_height = anv_minify(surf.surf->logical_level0_px.h, level);
|
||||
uint32_t level_width = u_minify(surf.surf->logical_level0_px.w, level);
|
||||
uint32_t level_height = u_minify(surf.surf->logical_level0_px.h, level);
|
||||
|
||||
/* Blorp will store the clear color for us if we provide the clear color
|
||||
* address and we are doing a fast clear. So we save the clear value into
|
||||
|
||||
@@ -1847,8 +1847,8 @@ void anv_GetImageSubresourceLayout(
|
||||
0 /* logical_z_offset_px */,
|
||||
&offset_B, NULL, NULL);
|
||||
layout->offset += offset_B;
|
||||
layout->size = layout->rowPitch * anv_minify(image->vk.extent.height,
|
||||
subresource->mipLevel) *
|
||||
layout->size = layout->rowPitch * u_minify(image->vk.extent.height,
|
||||
subresource->mipLevel) *
|
||||
image->vk.extent.depth;
|
||||
} else {
|
||||
layout->size = surface->memory_range.size;
|
||||
|
||||
@@ -313,15 +313,6 @@ anv_is_aligned(uintmax_t n, uintmax_t a)
|
||||
return (n & (a - 1)) == 0;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
anv_minify(uint32_t n, uint32_t levels)
|
||||
{
|
||||
if (unlikely(n == 0))
|
||||
return 0;
|
||||
else
|
||||
return MAX2(n >> levels, 1);
|
||||
}
|
||||
|
||||
static inline union isl_color_value
|
||||
vk_to_isl_color(VkClearColorValue color)
|
||||
{
|
||||
|
||||
@@ -882,7 +882,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
layer_count != VK_REMAINING_ARRAY_LAYERS);
|
||||
/* Ensure the subresource range is valid. */
|
||||
UNUSED uint64_t last_level_num = base_level + level_count;
|
||||
const uint32_t max_depth = anv_minify(image->vk.extent.depth, base_level);
|
||||
const uint32_t max_depth = u_minify(image->vk.extent.depth, base_level);
|
||||
UNUSED const uint32_t image_layers = MAX2(image->vk.array_layers, max_depth);
|
||||
assert((uint64_t)base_layer + layer_count <= image_layers);
|
||||
assert(last_level_num <= image->vk.mip_levels);
|
||||
@@ -1952,7 +1952,7 @@ cmd_buffer_barrier(struct anv_cmd_buffer *cmd_buffer,
|
||||
uint32_t base_layer, layer_count;
|
||||
if (image->vk.image_type == VK_IMAGE_TYPE_3D) {
|
||||
base_layer = 0;
|
||||
layer_count = anv_minify(image->vk.extent.depth, range->baseMipLevel);
|
||||
layer_count = u_minify(image->vk.extent.depth, range->baseMipLevel);
|
||||
} else {
|
||||
base_layer = range->baseArrayLayer;
|
||||
layer_count = vk_image_subresource_layer_count(&image->vk, range);
|
||||
|
||||
Reference in New Issue
Block a user