diff options
author | Jason Ekstrand <[email protected]> | 2016-01-22 11:57:01 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-01-22 11:57:01 -0800 |
commit | e5558ffa64207e121f0745ff62eeec10fce08b23 (patch) | |
tree | 88836cfa4290009e6027ee14b4fdcbe6db87a460 /src/vulkan/anv_image.c | |
parent | 84612f4014089b089c9a04a6592b5a1ea7423c70 (diff) |
anv/image: Move common code to anv_image.c
Diffstat (limited to 'src/vulkan/anv_image.c')
-rw-r--r-- | src/vulkan/anv_image.c | 85 |
1 files changed, 70 insertions, 15 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index ba3b3b254cd..b51938740bd 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -401,6 +401,48 @@ anv_validate_CreateImageView(VkDevice _device, } void +anv_fill_image_surface_state(struct anv_device *device, void *state_map, + struct anv_image_view *iview, + const VkImageViewCreateInfo *pCreateInfo, + VkImageUsageFlagBits usage) +{ + switch (device->info.gen) { + case 7: + if (device->info.is_haswell) + gen75_fill_image_surface_state(device, state_map, iview, + pCreateInfo, usage); + else + gen7_fill_image_surface_state(device, state_map, iview, + pCreateInfo, usage); + break; + case 8: + gen8_fill_image_surface_state(device, state_map, iview, + pCreateInfo, usage); + break; + case 9: + gen9_fill_image_surface_state(device, state_map, iview, + pCreateInfo, usage); + break; + default: + unreachable("unsupported gen\n"); + } + + if (!device->info.has_llc) + anv_state_clflush(iview->nonrt_surface_state); +} + +static struct anv_state +alloc_surface_state(struct anv_device *device, + struct anv_cmd_buffer *cmd_buffer) +{ + if (cmd_buffer) { + return anv_cmd_buffer_alloc_surface_state(cmd_buffer); + } else { + return anv_state_pool_alloc(&device->surface_state_pool, 64, 64); + } +} + +void anv_image_view_init(struct anv_image_view *iview, struct anv_device *device, const VkImageViewCreateInfo* pCreateInfo, @@ -447,21 +489,34 @@ anv_image_view_init(struct anv_image_view *iview, .depth = anv_minify(image->extent.depth, range->baseMipLevel), }; - switch (device->info.gen) { - case 7: - if (device->info.is_haswell) - gen75_image_view_init(iview, device, pCreateInfo, cmd_buffer); - else - gen7_image_view_init(iview, device, pCreateInfo, cmd_buffer); - break; - case 8: - gen8_image_view_init(iview, device, pCreateInfo, cmd_buffer); - break; - case 9: - gen9_image_view_init(iview, device, pCreateInfo, cmd_buffer); - break; - default: - unreachable("unsupported gen\n"); + if (image->needs_nonrt_surface_state) { + iview->nonrt_surface_state = alloc_surface_state(device, cmd_buffer); + + anv_fill_image_surface_state(device, iview->nonrt_surface_state.map, + iview, pCreateInfo, + VK_IMAGE_USAGE_SAMPLED_BIT); + } else { + iview->nonrt_surface_state.alloc_size = 0; + } + + if (image->needs_color_rt_surface_state) { + iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer); + + anv_fill_image_surface_state(device, iview->color_rt_surface_state.map, + iview, pCreateInfo, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); + } else { + iview->color_rt_surface_state.alloc_size = 0; + } + + if (image->needs_storage_surface_state) { + iview->storage_surface_state = alloc_surface_state(device, cmd_buffer); + + anv_fill_image_surface_state(device, iview->storage_surface_state.map, + iview, pCreateInfo, + VK_IMAGE_USAGE_STORAGE_BIT); + } else { + iview->storage_surface_state.alloc_size = 0; } } |