summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-10-06 15:21:51 -0700
committerNanley Chery <nanley.g.chery@intel.com>2016-10-07 12:54:18 -0700
commit9919a2d34deca437bfbb95d7a869616758bb69fd (patch)
tree4fe67c0eaed59b68f0772d7d8e1bdff237bd6e83
parentb4bbabf21b5a80e9ee1700cb9d3306666aa244a4 (diff)
downloadexternal_mesa3d-9919a2d34deca437bfbb95d7a869616758bb69fd.zip
external_mesa3d-9919a2d34deca437bfbb95d7a869616758bb69fd.tar.gz
external_mesa3d-9919a2d34deca437bfbb95d7a869616758bb69fd.tar.bz2
anv/image: Memset hiz surfaces to 0 when binding memory
Nanley Chery (amend): - Change memset value from 0xff to 0 (a defined value for HiZ). Signed-off-by: Nanley Chery <nanley.g.chery@intel.com> Reviewed-by: Chad Versace <chadversary@chromium.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
-rw-r--r--src/intel/vulkan/anv_image.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 7dada66..f125aa6 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -317,11 +317,12 @@ anv_DestroyImage(VkDevice _device, VkImage _image,
}
VkResult anv_BindImageMemory(
- VkDevice device,
+ VkDevice _device,
VkImage _image,
VkDeviceMemory _memory,
VkDeviceSize memoryOffset)
{
+ ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_device_memory, mem, _memory);
ANV_FROM_HANDLE(anv_image, image, _image);
@@ -333,6 +334,34 @@ VkResult anv_BindImageMemory(
image->offset = 0;
}
+ if (anv_image_has_hiz(image)) {
+
+ /* The offset and size must be a multiple of 4K or else the
+ * anv_gem_mmap call below will return NULL.
+ */
+ assert((image->offset + image->hiz_surface.offset) % 4096 == 0);
+ assert(image->hiz_surface.isl.size % 4096 == 0);
+
+ /* HiZ surfaces need to have their memory cleared to 0 before they
+ * can be used. If we let it have garbage data, it can cause GPU
+ * hangs on some hardware.
+ */
+ void *map = anv_gem_mmap(device, image->bo->gem_handle,
+ image->offset + image->hiz_surface.offset,
+ image->hiz_surface.isl.size,
+ device->info.has_llc ? 0 : I915_MMAP_WC);
+
+ /* If anv_gem_mmap returns NULL, it's likely that the kernel was
+ * not able to find space on the host to create a proper mapping.
+ */
+ if (map == NULL)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+ memset(map, 0, image->hiz_surface.isl.size);
+
+ anv_gem_munmap(map, image->hiz_surface.isl.size);
+ }
+
return VK_SUCCESS;
}