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;
}
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);
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);
}
bool needs_nonrt_surface_state:1;
bool needs_color_rt_surface_state:1;
+ bool needs_storage_surface_state:1;
/**
* Image subsurfaces
/** 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 {
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);
+ }
}
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)(