From 34b95f88e677c30cbdd0541a88a863e539ce36d6 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Sat, 11 Nov 2017 12:12:57 -0800 Subject: [PATCH] anv: Move get_fast_clear_state_address into anv_private.h While we're at it, we break it into two nicely named functions. Reviewed-by: Lionel Landwerlin Reviewed-by: Nanley Chery --- src/intel/vulkan/anv_private.h | 27 ++++++++++++++ src/intel/vulkan/genX_cmd_buffer.c | 56 ++++-------------------------- 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 6d4e43f2e68..2c2e0b31bf6 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2488,6 +2488,33 @@ anv_fast_clear_state_entry_size(const struct anv_device *device) return device->isl_dev.ss.clear_value_size + 4; } +static inline struct anv_address +anv_image_get_clear_color_addr(const struct anv_device *device, + const struct anv_image *image, + VkImageAspectFlagBits aspect, + unsigned level) +{ + uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect); + return (struct anv_address) { + .bo = image->planes[plane].bo, + .offset = image->planes[plane].bo_offset + + image->planes[plane].fast_clear_state_offset + + anv_fast_clear_state_entry_size(device) * level, + }; +} + +static inline struct anv_address +anv_image_get_needs_resolve_addr(const struct anv_device *device, + const struct anv_image *image, + VkImageAspectFlagBits aspect, + unsigned level) +{ + struct anv_address addr = + anv_image_get_clear_color_addr(device, image, aspect, level); + addr.offset += device->isl_dev.ss.clear_value_size; + return addr; +} + /* Returns true if a HiZ-enabled depth buffer can be sampled from. */ static inline bool anv_can_sample_with_hiz(const struct gen_device_info * const devinfo, diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index da4691121b7..cc437ff16b0 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -426,45 +426,6 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer, anv_gen8_hiz_op_resolve(cmd_buffer, image, hiz_op); } -enum fast_clear_state_field { - FAST_CLEAR_STATE_FIELD_CLEAR_COLOR, - FAST_CLEAR_STATE_FIELD_NEEDS_RESOLVE, -}; - -static inline struct anv_address -get_fast_clear_state_address(const struct anv_device *device, - const struct anv_image *image, - VkImageAspectFlagBits aspect, - unsigned level, - enum fast_clear_state_field field) -{ - assert(device && image); - assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV); - assert(level < anv_image_aux_levels(image, aspect)); - - uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect); - - /* Refer to the definition of anv_image for the memory layout. */ - uint32_t offset = image->planes[plane].fast_clear_state_offset; - - offset += anv_fast_clear_state_entry_size(device) * level; - - switch (field) { - case FAST_CLEAR_STATE_FIELD_NEEDS_RESOLVE: - offset += device->isl_dev.ss.clear_value_size; - /* Fall-through */ - case FAST_CLEAR_STATE_FIELD_CLEAR_COLOR: - break; - } - - assert(offset < image->planes[plane].surface.offset + image->planes[plane].size); - - return (struct anv_address) { - .bo = image->planes[plane].bo, - .offset = image->planes[plane].bo_offset + offset, - }; -} - #define MI_PREDICATE_SRC0 0x2400 #define MI_PREDICATE_SRC1 0x2408 @@ -481,16 +442,13 @@ genX(set_image_needs_resolve)(struct anv_cmd_buffer *cmd_buffer, assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV); assert(level < anv_image_aux_levels(image, aspect)); - const struct anv_address resolve_flag_addr = - get_fast_clear_state_address(cmd_buffer->device, image, aspect, level, - FAST_CLEAR_STATE_FIELD_NEEDS_RESOLVE); - /* The HW docs say that there is no way to guarantee the completion of * the following command. We use it nevertheless because it shows no * issues in testing is currently being used in the GL driver. */ anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_DATA_IMM), sdi) { - sdi.Address = resolve_flag_addr; + sdi.Address = anv_image_get_needs_resolve_addr(cmd_buffer->device, + image, aspect, level); sdi.ImmediateData = needs_resolve; } } @@ -506,8 +464,8 @@ genX(load_needs_resolve_predicate)(struct anv_cmd_buffer *cmd_buffer, assert(level < anv_image_aux_levels(image, aspect)); const struct anv_address resolve_flag_addr = - get_fast_clear_state_address(cmd_buffer->device, image, aspect, level, - FAST_CLEAR_STATE_FIELD_NEEDS_RESOLVE); + anv_image_get_needs_resolve_addr(cmd_buffer->device, + image, aspect, level); /* Make the pending predicated resolve a no-op if one is not needed. * predicate = do_resolve = resolve_flag != 0; @@ -558,8 +516,7 @@ init_fast_clear_state_entry(struct anv_cmd_buffer *cmd_buffer, * values in the clear value dword(s). */ struct anv_address addr = - get_fast_clear_state_address(cmd_buffer->device, image, aspect, level, - FAST_CLEAR_STATE_FIELD_CLEAR_COLOR); + anv_image_get_clear_color_addr(cmd_buffer->device, image, aspect, level); unsigned i = 0; for (; i < cmd_buffer->device->isl_dev.ss.clear_value_size; i += 4) { anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_DATA_IMM), sdi) { @@ -612,8 +569,7 @@ genX(copy_fast_clear_dwords)(struct anv_cmd_buffer *cmd_buffer, uint32_t ss_clear_offset = surface_state.offset + cmd_buffer->device->isl_dev.ss.clear_value_offset; const struct anv_address entry_addr = - get_fast_clear_state_address(cmd_buffer->device, image, aspect, level, - FAST_CLEAR_STATE_FIELD_CLEAR_COLOR); + anv_image_get_clear_color_addr(cmd_buffer->device, image, aspect, level); unsigned copy_size = cmd_buffer->device->isl_dev.ss.clear_value_size; if (copy_from_surface_state) { -- 2.30.2