anv,iris: Pack depth pixels into initialized arrays

Coverity alerts that the uint32_t pointer I was passing into
isl_color_value_pack() could possibly be used as an array. The value is
being used as such, but only the first element of that array should be
accessed. That's because the depth buffer formats I'm also passing into
the function only have a single channel, R. Nonetheless, let's update
the code to avoid the warning.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31123>
This commit is contained in:
Nanley Chery
2024-09-10 18:14:05 -04:00
committed by Marge Bot
parent bb16203a8d
commit e0157abec6
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -522,8 +522,8 @@ fast_clear_depth(struct iris_context *ice,
/* Also set the indirect clear color if it exists. */
if (res->aux.clear_color_bo) {
uint32_t packed_depth;
isl_color_value_pack(&clear_value, res->surf.format, &packed_depth);
uint32_t packed_depth[4] = {};
isl_color_value_pack(&clear_value, res->surf.format, packed_depth);
const uint64_t clear_pixel_offset = res->aux.clear_color_offset +
isl_get_sampler_clear_field_offset(devinfo, res->surf.format);
@@ -531,7 +531,7 @@ fast_clear_depth(struct iris_context *ice,
iris_emit_pipe_control_write(batch, "update fast clear value (Z)",
PIPE_CONTROL_WRITE_IMMEDIATE,
res->aux.clear_color_bo,
clear_pixel_offset, packed_depth);
clear_pixel_offset, packed_depth[0]);
/* From the TGL PRMs, Volume 9: Render Engine, State Caching :
*
+3 -3
View File
@@ -476,8 +476,8 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
const union isl_color_value clear_value =
anv_image_hiz_clear_value(image);
uint32_t depth_value;
isl_color_value_pack(&clear_value, depth_format, &depth_value);
uint32_t depth_value[4] = {};
isl_color_value_pack(&clear_value, depth_format, depth_value);
const uint32_t clear_pixel_offset = clear_color_addr.offset +
isl_get_sampler_clear_field_offset(cmd_buffer->device->info,
@@ -490,7 +490,7 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
struct mi_builder b;
mi_builder_init(&b, cmd_buffer->device->info, &cmd_buffer->batch);
mi_builder_set_write_check(&b, true);
mi_store(&b, mi_mem32(clear_pixel_addr), mi_imm(depth_value));
mi_store(&b, mi_mem32(clear_pixel_addr), mi_imm(depth_value[0]));
}
/* If will_full_fast_clear is set, the caller promises to fast-clear the