diff options
author | Jason Ekstrand <[email protected]> | 2015-12-07 17:17:30 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-12-07 21:08:22 -0800 |
commit | ff05f634f643ba867838d34c1a99d8152debe8ac (patch) | |
tree | 7ba2dc8c9cb1539214d5a52fd8a07251f8319114 /src/vulkan | |
parent | 8f83222d3752f1855e6861ea5e29b5f2487b26e4 (diff) |
anv/image: Add a separate storage image surface state
Thanks to hardware limitations, storage images may need a different surface
format and/or other bits in the surface state.
Diffstat (limited to 'src/vulkan')
-rw-r--r-- | src/vulkan/anv_image.c | 12 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 4 | ||||
-rw-r--r-- | src/vulkan/gen7_state.c | 14 | ||||
-rw-r--r-- | src/vulkan/gen8_state.c | 15 |
4 files changed, 43 insertions, 2 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 37a0d8faaa9..09993180e7e 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -252,8 +252,7 @@ anv_image_create(VkDevice _device, image->usage = anv_image_get_full_usage(pCreateInfo); image->surface_type = surf_type; - if (image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | - VK_IMAGE_USAGE_STORAGE_BIT)) { + if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT) { image->needs_nonrt_surface_state = true; } @@ -261,6 +260,10 @@ anv_image_create(VkDevice _device, image->needs_color_rt_surface_state = true; } + if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) { + image->needs_storage_surface_state = true; + } + if (likely(anv_format_is_color(image->format))) { r = make_surface(device, image, create_info, VK_IMAGE_ASPECT_COLOR_BIT); @@ -533,6 +536,11 @@ anv_DestroyImageView(VkDevice _device, VkImageView _iview, iview->nonrt_surface_state); } + if (iview->image->needs_storage_surface_state) { + anv_state_pool_free(&device->surface_state_pool, + iview->storage_surface_state); + } + anv_free2(&device->alloc, pAllocator, iview); } diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index cb3f9a7b367..a6db547e5e3 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1433,6 +1433,7 @@ struct anv_image { bool needs_nonrt_surface_state:1; bool needs_color_rt_surface_state:1; + bool needs_storage_surface_state:1; /** * Image subsurfaces @@ -1468,6 +1469,9 @@ struct anv_image_view { /** RENDER_SURFACE_STATE when using image as a non render target. */ struct anv_state nonrt_surface_state; + + /** RENDER_SURFACE_STATE when using image as a storage image. */ + struct anv_state storage_surface_state; }; struct anv_image_create_info { diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index 6ffbacd8e77..4101e84f827 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -332,4 +332,18 @@ genX(image_view_init)(struct anv_image_view *iview, if (!device->info.has_llc) anv_state_clflush(iview->color_rt_surface_state); } + + if (image->needs_storage_surface_state) { + iview->storage_surface_state = alloc_surface_state(device, cmd_buffer); + + surface_state.SurfaceFormat = + isl_lower_storage_image_format(&device->isl_dev, + format->surface_format); + + surface_state.SurfaceMinLOD = range->baseMipLevel; + surface_state.MIPCountLOD = range->levelCount - 1; + + GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->storage_surface_state.map, + &surface_state); + } } diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index 901cc3b25a8..59134d5214e 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -302,6 +302,21 @@ genX(image_view_init)(struct anv_image_view *iview, if (!device->info.has_llc) anv_state_clflush(iview->color_rt_surface_state); } + + if (image->needs_storage_surface_state) { + iview->storage_surface_state = + alloc_surface_state(device, cmd_buffer); + + surface_state.SurfaceFormat = + isl_lower_storage_image_format(&device->isl_dev, + format_info->surface_format); + + surface_state.SurfaceMinLOD = range->baseMipLevel; + surface_state.MIPCountLOD = range->levelCount - 1; + + GENX(RENDER_SURFACE_STATE_pack)(NULL, iview->storage_surface_state.map, + &surface_state); + } } VkResult genX(CreateSampler)( |