anv: Update the HiZ sampling helper
Validate the inputs, verify that this image has a depth buffer, use gen_device_info instead of v2: - Add parenthesis (Jason Ekstrand) - Make parameters const - Use gen_device_info instead of gen - Pass aspect to missed function in transition_depth_buffer Signed-off-by: Nanley Chery <nanley.g.chery@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -1275,7 +1275,8 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer)
|
|||||||
*/
|
*/
|
||||||
clear_with_hiz = false;
|
clear_with_hiz = false;
|
||||||
} else if (gen == 8 &&
|
} else if (gen == 8 &&
|
||||||
anv_can_sample_with_hiz(cmd_buffer->device->info.gen,
|
anv_can_sample_with_hiz(&cmd_buffer->device->info,
|
||||||
|
iview->aspect_mask,
|
||||||
iview->image->samples)) {
|
iview->image->samples)) {
|
||||||
/* Only gen9+ supports returning ANV_HZ_FC_VAL when sampling a
|
/* Only gen9+ supports returning ANV_HZ_FC_VAL when sampling a
|
||||||
* fast-cleared portion of a HiZ buffer. Testing has revealed
|
* fast-cleared portion of a HiZ buffer. Testing has revealed
|
||||||
|
@@ -483,7 +483,6 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
|
|||||||
if (devinfo->gen < 8 && aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
|
if (devinfo->gen < 8 && aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||||
return ISL_AUX_USAGE_NONE;
|
return ISL_AUX_USAGE_NONE;
|
||||||
|
|
||||||
const bool has_depth = aspects & VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
||||||
const bool color_aspect = aspects == VK_IMAGE_ASPECT_COLOR_BIT;
|
const bool color_aspect = aspects == VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
|
||||||
/* The following switch currently only handles depth stencil aspects.
|
/* The following switch currently only handles depth stencil aspects.
|
||||||
@@ -523,7 +522,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
|
|||||||
assert(!color_aspect);
|
assert(!color_aspect);
|
||||||
/* Fall-through */
|
/* Fall-through */
|
||||||
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
||||||
if (has_depth && anv_can_sample_with_hiz(devinfo->gen, image->samples))
|
if (anv_can_sample_with_hiz(devinfo, aspects, image->samples))
|
||||||
return ISL_AUX_USAGE_HIZ;
|
return ISL_AUX_USAGE_HIZ;
|
||||||
else
|
else
|
||||||
return ISL_AUX_USAGE_NONE;
|
return ISL_AUX_USAGE_NONE;
|
||||||
@@ -684,8 +683,8 @@ anv_CreateImageView(VkDevice _device,
|
|||||||
float red_clear_color = 0.0f;
|
float red_clear_color = 0.0f;
|
||||||
enum isl_aux_usage surf_usage = image->aux_usage;
|
enum isl_aux_usage surf_usage = image->aux_usage;
|
||||||
if (image->aux_usage == ISL_AUX_USAGE_HIZ) {
|
if (image->aux_usage == ISL_AUX_USAGE_HIZ) {
|
||||||
if (iview->aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT &&
|
if (anv_can_sample_with_hiz(&device->info, iview->aspect_mask,
|
||||||
anv_can_sample_with_hiz(device->info.gen, image->samples)) {
|
image->samples)) {
|
||||||
/* When a HiZ buffer is sampled on gen9+, ensure that
|
/* When a HiZ buffer is sampled on gen9+, ensure that
|
||||||
* the constant fast clear value is set in the surface state.
|
* the constant fast clear value is set in the surface state.
|
||||||
*/
|
*/
|
||||||
|
@@ -1767,9 +1767,14 @@ struct anv_image {
|
|||||||
|
|
||||||
/* Returns true if a HiZ-enabled depth buffer can be sampled from. */
|
/* Returns true if a HiZ-enabled depth buffer can be sampled from. */
|
||||||
static inline bool
|
static inline bool
|
||||||
anv_can_sample_with_hiz(uint8_t gen, uint32_t samples)
|
anv_can_sample_with_hiz(const struct gen_device_info * const devinfo,
|
||||||
|
const VkImageAspectFlags aspect_mask,
|
||||||
|
const uint32_t samples)
|
||||||
{
|
{
|
||||||
return gen >= 8 && samples == 1;
|
/* Validate the inputs. */
|
||||||
|
assert(devinfo && aspect_mask && samples);
|
||||||
|
return devinfo->gen >= 8 && (aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) &&
|
||||||
|
samples == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -383,7 +383,8 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
* required by this transition was not already a HiZ resolve.
|
* required by this transition was not already a HiZ resolve.
|
||||||
*/
|
*/
|
||||||
if (final_layout == VK_IMAGE_LAYOUT_GENERAL &&
|
if (final_layout == VK_IMAGE_LAYOUT_GENERAL &&
|
||||||
anv_can_sample_with_hiz(GEN_GEN, image->samples) &&
|
anv_can_sample_with_hiz(&cmd_buffer->device->info, image->aspects,
|
||||||
|
image->samples) &&
|
||||||
hiz_op != BLORP_HIZ_OP_HIZ_RESOLVE) {
|
hiz_op != BLORP_HIZ_OP_HIZ_RESOLVE) {
|
||||||
anv_gen8_hiz_op_resolve(cmd_buffer, image, BLORP_HIZ_OP_HIZ_RESOLVE);
|
anv_gen8_hiz_op_resolve(cmd_buffer, image, BLORP_HIZ_OP_HIZ_RESOLVE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user