Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2015 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include <assert.h> |
| 25 | #include <stdbool.h> |
| 26 | #include <string.h> |
| 27 | #include <unistd.h> |
| 28 | #include <fcntl.h> |
| 29 | |
| 30 | #include "private.h" |
| 31 | |
Chad Versace | e6162c2 | 2015-06-09 12:11:46 -0700 | [diff] [blame] | 32 | static const uint8_t anv_halign[] = { |
| 33 | [4] = HALIGN4, |
| 34 | [8] = HALIGN8, |
| 35 | [16] = HALIGN16, |
| 36 | }; |
| 37 | |
| 38 | static const uint8_t anv_valign[] = { |
| 39 | [4] = VALIGN4, |
| 40 | [8] = VALIGN8, |
| 41 | [16] = VALIGN16, |
| 42 | }; |
| 43 | |
Chad Versace | cb30aca | 2015-05-28 07:37:59 -0700 | [diff] [blame] | 44 | static const uint8_t anv_surf_type_from_image_type[] = { |
| 45 | [VK_IMAGE_TYPE_1D] = SURFTYPE_1D, |
| 46 | [VK_IMAGE_TYPE_2D] = SURFTYPE_2D, |
| 47 | [VK_IMAGE_TYPE_3D] = SURFTYPE_3D, |
| 48 | }; |
| 49 | |
| 50 | static const uint8_t anv_surf_type_from_image_view_type[] = { |
| 51 | [VK_IMAGE_VIEW_TYPE_1D] = SURFTYPE_1D, |
| 52 | [VK_IMAGE_VIEW_TYPE_2D] = SURFTYPE_2D, |
| 53 | [VK_IMAGE_VIEW_TYPE_3D] = SURFTYPE_3D, |
| 54 | [VK_IMAGE_VIEW_TYPE_CUBE] = SURFTYPE_CUBE, |
| 55 | }; |
| 56 | |
Chad Versace | fa35296 | 2015-05-28 07:40:22 -0700 | [diff] [blame] | 57 | static const struct anv_surf_type_limits { |
| 58 | int32_t width; |
| 59 | int32_t height; |
| 60 | int32_t depth; |
| 61 | } anv_surf_type_limits[] = { |
| 62 | [SURFTYPE_1D] = {16384, 0, 2048}, |
| 63 | [SURFTYPE_2D] = {16384, 16384, 2048}, |
| 64 | [SURFTYPE_3D] = {2048, 2048, 2048}, |
| 65 | [SURFTYPE_CUBE] = {16384, 16384, 340}, |
| 66 | [SURFTYPE_BUFFER] = {128, 16384, 64}, |
| 67 | [SURFTYPE_STRBUF] = {128, 16384, 64}, |
| 68 | }; |
| 69 | |
Chad Versace | e6bd568 | 2015-06-09 13:29:08 -0700 | [diff] [blame] | 70 | static const struct anv_tile_info { |
| 71 | uint32_t width; |
| 72 | uint32_t height; |
| 73 | |
| 74 | /** |
| 75 | * Alignment for RENDER_SURFACE_STATE.SurfaceBaseAddress. |
| 76 | * |
| 77 | * To simplify calculations, the alignments defined in the table are |
| 78 | * sometimes larger than required. For example, Skylake requires that X and |
| 79 | * Y tiled buffers be aligned to 4K, but Broadwell permits smaller |
| 80 | * alignment. We choose 4K to accomodate both chipsets. The alignment of |
| 81 | * a linear buffer depends on its element type and usage. Linear depth |
| 82 | * buffers have the largest alignment, 64B, so we choose that for all linear |
| 83 | * buffers. |
| 84 | */ |
| 85 | uint32_t surface_alignment; |
| 86 | } anv_tile_info_table[] = { |
| 87 | [LINEAR] = { 1, 1, 64 }, |
| 88 | [XMAJOR] = { 512, 8, 4096 }, |
| 89 | [YMAJOR] = { 128, 32, 4096 }, |
| 90 | [WMAJOR] = { 128, 32, 4096 }, |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
Chad Versace | f1db3b3 | 2015-06-09 14:33:05 -0700 | [diff] [blame] | 93 | static uint32_t |
Chad Versace | fdcd71f | 2015-06-26 20:06:08 -0700 | [diff] [blame] | 94 | anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) |
Chad Versace | f1db3b3 | 2015-06-09 14:33:05 -0700 | [diff] [blame] | 95 | { |
Chad Versace | fdcd71f | 2015-06-26 20:06:08 -0700 | [diff] [blame] | 96 | if (anv_info->force_tile_mode) |
Chad Versace | f1db3b3 | 2015-06-09 14:33:05 -0700 | [diff] [blame] | 97 | return anv_info->tile_mode; |
| 98 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 99 | if (anv_info->vk_info->format == VK_FORMAT_S8_UINT) |
| 100 | return WMAJOR; |
| 101 | |
Chad Versace | fdcd71f | 2015-06-26 20:06:08 -0700 | [diff] [blame] | 102 | switch (anv_info->vk_info->tiling) { |
Chad Versace | f1db3b3 | 2015-06-09 14:33:05 -0700 | [diff] [blame] | 103 | case VK_IMAGE_TILING_LINEAR: |
| 104 | return LINEAR; |
| 105 | case VK_IMAGE_TILING_OPTIMAL: |
Kristian Høgsberg Kristensen | 00494c6 | 2015-06-11 22:07:16 -0700 | [diff] [blame] | 106 | return YMAJOR; |
Chad Versace | f1db3b3 | 2015-06-09 14:33:05 -0700 | [diff] [blame] | 107 | default: |
| 108 | assert(!"bad VKImageTiling"); |
| 109 | return LINEAR; |
| 110 | } |
| 111 | } |
| 112 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 113 | static VkResult |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 114 | anv_image_make_surface(const struct anv_image_create_info *create_info, |
| 115 | uint64_t *inout_image_size, |
| 116 | uint32_t *inout_image_alignment, |
| 117 | struct anv_surface *out_surface) |
| 118 | { |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 119 | /* See RENDER_SURFACE_STATE.SurfaceQPitch */ |
| 120 | static const uint16_t min_qpitch UNUSED = 0x4; |
| 121 | static const uint16_t max_qpitch UNUSED = 0x1ffc; |
| 122 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 123 | const VkExtent3D *restrict extent = &create_info->vk_info->extent; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 124 | const uint32_t levels = create_info->vk_info->mipLevels; |
| 125 | const uint32_t array_size = create_info->vk_info->arraySize; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 126 | |
| 127 | const uint8_t tile_mode = anv_image_choose_tile_mode(create_info); |
| 128 | |
| 129 | const struct anv_tile_info *tile_info = |
| 130 | &anv_tile_info_table[tile_mode]; |
| 131 | |
| 132 | const struct anv_format *format_info = |
| 133 | anv_format_for_vk_format(create_info->vk_info->format); |
| 134 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 135 | const uint32_t i = 4; /* FINISHME: Stop hardcoding subimage alignment */ |
| 136 | const uint32_t j = 4; /* FINISHME: Stop hardcoding subimage alignment */ |
| 137 | const uint32_t w0 = align_u32(extent->width, i); |
| 138 | const uint32_t h0 = align_u32(extent->height, j); |
| 139 | |
| 140 | uint16_t qpitch; |
| 141 | uint32_t mt_width; |
| 142 | uint32_t mt_height; |
| 143 | |
| 144 | if (levels == 1 && array_size == 1) { |
| 145 | qpitch = min_qpitch; |
| 146 | mt_width = w0; |
| 147 | mt_height = h0; |
| 148 | } else { |
| 149 | uint32_t w1 = align_u32(anv_minify(extent->width, 1), i); |
| 150 | uint32_t h1 = align_u32(anv_minify(extent->height, 1), j); |
| 151 | uint32_t w2 = align_u32(anv_minify(extent->width, 2), i); |
| 152 | |
| 153 | qpitch = h0 + h1 + 11 * j; |
| 154 | mt_width = MAX(w0, w1 + w2); |
| 155 | mt_height = array_size * qpitch; |
| 156 | } |
| 157 | |
| 158 | assert(qpitch >= min_qpitch); |
| 159 | if (qpitch > max_qpitch) { |
| 160 | anv_loge("image qpitch > 0x%x\n", max_qpitch); |
| 161 | return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY); |
| 162 | } |
| 163 | |
| 164 | /* From the Broadwell PRM, RENDER_SURFACE_STATE.SurfaceQpitch: |
| 165 | * |
| 166 | * This field must be set an integer multiple of the Surface Vertical |
| 167 | * Alignment. |
| 168 | */ |
| 169 | assert(anv_is_aligned(qpitch, j)); |
| 170 | |
| 171 | const uint32_t stride = align_u32(mt_width * format_info->cpp, |
| 172 | tile_info->width); |
| 173 | const uint32_t size = stride * align_u32(mt_height, tile_info->height); |
| 174 | const uint32_t offset = align_u32(*inout_image_size, |
| 175 | tile_info->surface_alignment); |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 176 | |
| 177 | *inout_image_size = offset + size; |
| 178 | *inout_image_alignment = MAX(*inout_image_alignment, |
| 179 | tile_info->surface_alignment); |
| 180 | |
| 181 | *out_surface = (struct anv_surface) { |
| 182 | .offset = offset, |
| 183 | .stride = stride, |
| 184 | .tile_mode = tile_mode, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 185 | .qpitch = qpitch, |
| 186 | .h_align = i, |
| 187 | .v_align = j, |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 188 | }; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 189 | |
| 190 | return VK_SUCCESS; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Chad Versace | 127cb3f | 2015-06-26 20:12:42 -0700 | [diff] [blame] | 193 | VkResult |
| 194 | anv_image_create(VkDevice _device, |
| 195 | const struct anv_image_create_info *create_info, |
| 196 | VkImage *pImage) |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 197 | { |
| 198 | struct anv_device *device = (struct anv_device *) _device; |
Chad Versace | fdcd71f | 2015-06-26 20:06:08 -0700 | [diff] [blame] | 199 | const VkImageCreateInfo *pCreateInfo = create_info->vk_info; |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 200 | const VkExtent3D *restrict extent = &pCreateInfo->extent; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 201 | struct anv_image *image = NULL; |
| 202 | VkResult r; |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 203 | |
| 204 | assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO); |
| 205 | |
Jason Ekstrand | 2a3c296 | 2015-06-10 21:04:51 -0700 | [diff] [blame] | 206 | /* XXX: We don't handle any of these */ |
| 207 | anv_assert(pCreateInfo->imageType == VK_IMAGE_TYPE_2D); |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 208 | anv_assert(pCreateInfo->mipLevels > 0); |
| 209 | anv_assert(pCreateInfo->arraySize > 0); |
Jason Ekstrand | 2a3c296 | 2015-06-10 21:04:51 -0700 | [diff] [blame] | 210 | anv_assert(pCreateInfo->samples == 1); |
Chad Versace | 5d7103e | 2015-06-26 09:05:46 -0700 | [diff] [blame] | 211 | anv_assert(pCreateInfo->extent.width > 0); |
| 212 | anv_assert(pCreateInfo->extent.height > 0); |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 213 | anv_assert(pCreateInfo->extent.depth > 0); |
Jason Ekstrand | 2a3c296 | 2015-06-10 21:04:51 -0700 | [diff] [blame] | 214 | |
Chad Versace | 7ea1216 | 2015-05-28 07:45:31 -0700 | [diff] [blame] | 215 | /* TODO(chadv): How should we validate inputs? */ |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 216 | const uint8_t surf_type = |
| 217 | anv_surf_type_from_image_type[pCreateInfo->imageType]; |
Chad Versace | 7ea1216 | 2015-05-28 07:45:31 -0700 | [diff] [blame] | 218 | |
Chad Versace | fa35296 | 2015-05-28 07:40:22 -0700 | [diff] [blame] | 219 | const struct anv_surf_type_limits *limits = |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 220 | &anv_surf_type_limits[surf_type]; |
Chad Versace | fa35296 | 2015-05-28 07:40:22 -0700 | [diff] [blame] | 221 | |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 222 | if (extent->width > limits->width || |
| 223 | extent->height > limits->height || |
| 224 | extent->depth > limits->depth) { |
Chad Versace | fa35296 | 2015-05-28 07:40:22 -0700 | [diff] [blame] | 225 | /* TODO(chadv): What is the correct error? */ |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 226 | anv_loge("image extent is too large"); |
Chad Versace | fa35296 | 2015-05-28 07:40:22 -0700 | [diff] [blame] | 227 | return vk_error(VK_ERROR_INVALID_MEMORY_SIZE); |
| 228 | } |
| 229 | |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 230 | const struct anv_format *format_info = |
| 231 | anv_format_for_vk_format(pCreateInfo->format); |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 232 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 233 | image = anv_device_alloc(device, sizeof(*image), 8, |
| 234 | VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
| 235 | if (!image) |
| 236 | return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 237 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 238 | memset(image, 0, sizeof(*image)); |
| 239 | image->type = pCreateInfo->imageType; |
| 240 | image->extent = pCreateInfo->extent; |
| 241 | image->format = pCreateInfo->format; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 242 | image->levels = pCreateInfo->mipLevels; |
| 243 | image->array_size = pCreateInfo->arraySize; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 244 | image->surf_type = surf_type; |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 245 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 246 | if (likely(!format_info->has_stencil || format_info->depth_format)) { |
| 247 | /* The image's primary surface is a color or depth surface. */ |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 248 | r = anv_image_make_surface(create_info, &image->size, &image->alignment, |
| 249 | &image->primary_surface); |
| 250 | if (r != VK_SUCCESS) |
| 251 | goto fail; |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Chad Versace | 45b804a | 2015-06-25 19:03:43 -0700 | [diff] [blame] | 254 | if (format_info->has_stencil) { |
Chad Versace | 37d6e04 | 2015-06-26 09:47:17 -0700 | [diff] [blame] | 255 | /* From the GPU's perspective, the depth buffer and stencil buffer are |
| 256 | * separate buffers. From Vulkan's perspective, though, depth and |
| 257 | * stencil reside in the same image. To satisfy Vulkan and the GPU, we |
| 258 | * place the depth and stencil buffers in the same bo. |
| 259 | */ |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 260 | VkImageCreateInfo stencil_info = *pCreateInfo; |
| 261 | stencil_info.format = VK_FORMAT_S8_UINT; |
Chad Versace | 67a7659 | 2015-06-26 09:17:52 -0700 | [diff] [blame] | 262 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 263 | r = anv_image_make_surface( |
| 264 | &(struct anv_image_create_info) { |
| 265 | .vk_info = &stencil_info, |
| 266 | }, |
| 267 | &image->size, &image->alignment, &image->stencil_surface); |
| 268 | |
| 269 | if (r != VK_SUCCESS) |
| 270 | goto fail; |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 271 | } |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 272 | |
| 273 | *pImage = (VkImage) image; |
| 274 | |
| 275 | return VK_SUCCESS; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 276 | |
| 277 | fail: |
| 278 | if (image) |
| 279 | anv_device_free(device, image); |
| 280 | |
| 281 | return r; |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Chad Versace | 127cb3f | 2015-06-26 20:12:42 -0700 | [diff] [blame] | 284 | VkResult |
| 285 | anv_CreateImage(VkDevice device, |
| 286 | const VkImageCreateInfo *pCreateInfo, |
| 287 | VkImage *pImage) |
Kristian Høgsberg | a29df71 | 2015-05-15 22:04:52 -0700 | [diff] [blame] | 288 | { |
Chad Versace | fdcd71f | 2015-06-26 20:06:08 -0700 | [diff] [blame] | 289 | return anv_image_create(device, |
| 290 | &(struct anv_image_create_info) { |
| 291 | .vk_info = pCreateInfo, |
| 292 | }, |
| 293 | pImage); |
Kristian Høgsberg | a29df71 | 2015-05-15 22:04:52 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Chad Versace | 127cb3f | 2015-06-26 20:12:42 -0700 | [diff] [blame] | 296 | VkResult |
| 297 | anv_GetImageSubresourceInfo(VkDevice device, |
| 298 | VkImage image, |
| 299 | const VkImageSubresource *pSubresource, |
| 300 | VkSubresourceInfoType infoType, |
| 301 | size_t *pDataSize, |
| 302 | void *pData) |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 303 | { |
Jason Ekstrand | ffe9f60 | 2015-05-12 13:44:43 -0700 | [diff] [blame] | 304 | stub_return(VK_UNSUPPORTED); |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 307 | void |
Jason Ekstrand | 9d6f55d | 2015-06-09 11:08:03 -0700 | [diff] [blame] | 308 | anv_surface_view_destroy(struct anv_device *device, |
| 309 | struct anv_object *obj, VkObjectType obj_type) |
| 310 | { |
| 311 | struct anv_surface_view *view = (struct anv_surface_view *)obj; |
| 312 | |
| 313 | assert(obj_type == VK_OBJECT_TYPE_BUFFER_VIEW || |
| 314 | obj_type == VK_OBJECT_TYPE_IMAGE_VIEW || |
| 315 | obj_type == VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW); |
| 316 | |
| 317 | anv_state_pool_free(&device->surface_state_pool, view->surface_state); |
| 318 | |
| 319 | anv_device_free(device, view); |
| 320 | } |
| 321 | |
| 322 | void |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 323 | anv_image_view_init(struct anv_surface_view *view, |
| 324 | struct anv_device *device, |
| 325 | const VkImageViewCreateInfo* pCreateInfo, |
| 326 | struct anv_cmd_buffer *cmd_buffer) |
| 327 | { |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 328 | const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange; |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 329 | struct anv_image *image = (struct anv_image *) pCreateInfo->image; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 330 | struct anv_surface *surface; |
Chad Versace | ca6cef3 | 2015-06-26 19:50:04 -0700 | [diff] [blame] | 331 | |
| 332 | const struct anv_format *format_info = |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 333 | anv_format_for_vk_format(pCreateInfo->format); |
| 334 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 335 | anv_assert(range->mipLevels > 0); |
| 336 | anv_assert(range->arraySize > 0); |
| 337 | anv_assert(range->baseMipLevel + range->mipLevels <= image->levels); |
| 338 | anv_assert(range->baseArraySlice + range->arraySize <= image->array_size); |
Jason Ekstrand | 2a3c296 | 2015-06-10 21:04:51 -0700 | [diff] [blame] | 339 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 340 | if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D) |
| 341 | anv_finishme("non-2D image views"); |
Chad Versace | ca6cef3 | 2015-06-26 19:50:04 -0700 | [diff] [blame] | 342 | |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 343 | switch (pCreateInfo->subresourceRange.aspect) { |
| 344 | case VK_IMAGE_ASPECT_STENCIL: |
Chad Versace | 9c46ba9 | 2015-06-26 19:23:21 -0700 | [diff] [blame] | 345 | anv_finishme("stencil image views"); |
| 346 | abort(); |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 347 | break; |
| 348 | case VK_IMAGE_ASPECT_DEPTH: |
| 349 | case VK_IMAGE_ASPECT_COLOR: |
| 350 | view->offset = image->offset; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 351 | surface = &image->primary_surface; |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 352 | break; |
| 353 | default: |
Kristian Høgsberg Kristensen | 52637c0 | 2015-06-05 11:51:30 -0700 | [diff] [blame] | 354 | unreachable(""); |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 355 | break; |
| 356 | } |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 357 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 358 | view->bo = image->bo; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 359 | view->offset = image->offset + surface->offset; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 360 | view->format = pCreateInfo->format; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 361 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 362 | view->extent = (VkExtent3D) { |
| 363 | .width = anv_minify(image->extent.width, range->baseMipLevel), |
| 364 | .height = anv_minify(image->extent.height, range->baseMipLevel), |
| 365 | .depth = anv_minify(image->extent.depth, range->baseMipLevel), |
| 366 | }; |
| 367 | |
| 368 | uint32_t depth = 1; |
| 369 | if (range->arraySize > 1) { |
| 370 | depth = range->arraySize; |
| 371 | } else if (image->extent.depth > 1) { |
| 372 | depth = image->extent.depth; |
| 373 | } |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 374 | |
| 375 | static const uint32_t vk_to_gen_swizzle[] = { |
Kristian Høgsberg Kristensen | 5caa408 | 2015-05-31 22:35:11 -0700 | [diff] [blame] | 376 | [VK_CHANNEL_SWIZZLE_ZERO] = SCS_ZERO, |
| 377 | [VK_CHANNEL_SWIZZLE_ONE] = SCS_ONE, |
| 378 | [VK_CHANNEL_SWIZZLE_R] = SCS_RED, |
| 379 | [VK_CHANNEL_SWIZZLE_G] = SCS_GREEN, |
| 380 | [VK_CHANNEL_SWIZZLE_B] = SCS_BLUE, |
| 381 | [VK_CHANNEL_SWIZZLE_A] = SCS_ALPHA |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 382 | }; |
| 383 | |
| 384 | struct GEN8_RENDER_SURFACE_STATE surface_state = { |
Chad Versace | 99031aa | 2015-05-28 07:46:31 -0700 | [diff] [blame] | 385 | .SurfaceType = anv_surf_type_from_image_view_type[pCreateInfo->viewType], |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 386 | .SurfaceArray = image->array_size > 1, |
Chad Versace | ca6cef3 | 2015-06-26 19:50:04 -0700 | [diff] [blame] | 387 | .SurfaceFormat = format_info->surface_format, |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 388 | .SurfaceVerticalAlignment = anv_valign[surface->v_align], |
| 389 | .SurfaceHorizontalAlignment = anv_halign[surface->h_align], |
| 390 | .TileMode = surface->tile_mode, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 391 | .VerticalLineStride = 0, |
| 392 | .VerticalLineStrideOffset = 0, |
| 393 | .SamplerL2BypassModeDisable = true, |
| 394 | .RenderCacheReadWriteMode = WriteOnlyCache, |
| 395 | .MemoryObjectControlState = GEN8_MOCS, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 396 | .BaseMipLevel = (float) pCreateInfo->minLod, |
| 397 | .SurfaceQPitch = surface->qpitch >> 2, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 398 | .Height = image->extent.height - 1, |
| 399 | .Width = image->extent.width - 1, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 400 | .Depth = depth - 1, |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 401 | .SurfacePitch = surface->stride - 1, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 402 | .MinimumArrayElement = range->baseArraySlice, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 403 | .NumberofMultisamples = MULTISAMPLECOUNT_1, |
| 404 | .XOffset = 0, |
| 405 | .YOffset = 0, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 406 | |
| 407 | /* For sampler surfaces, the hardware interprets field MIPCount/LOD as |
| 408 | * MIPCount. The range of levels accessible by the sampler engine is |
| 409 | * [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD]. |
| 410 | */ |
| 411 | .MIPCountLOD = range->mipLevels - 1, |
| 412 | .SurfaceMinLOD = range->baseMipLevel, |
| 413 | |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 414 | .AuxiliarySurfaceMode = AUX_NONE, |
| 415 | .RedClearColor = 0, |
| 416 | .GreenClearColor = 0, |
| 417 | .BlueClearColor = 0, |
| 418 | .AlphaClearColor = 0, |
| 419 | .ShaderChannelSelectRed = vk_to_gen_swizzle[pCreateInfo->channels.r], |
| 420 | .ShaderChannelSelectGreen = vk_to_gen_swizzle[pCreateInfo->channels.g], |
| 421 | .ShaderChannelSelectBlue = vk_to_gen_swizzle[pCreateInfo->channels.b], |
| 422 | .ShaderChannelSelectAlpha = vk_to_gen_swizzle[pCreateInfo->channels.a], |
Kristian Høgsberg Kristensen | a5b49d2 | 2015-06-10 23:11:37 -0700 | [diff] [blame] | 423 | .ResourceMinLOD = 0.0, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 424 | .SurfaceBaseAddress = { NULL, view->offset }, |
| 425 | }; |
| 426 | |
| 427 | if (cmd_buffer) |
| 428 | view->surface_state = |
| 429 | anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64); |
| 430 | else |
| 431 | view->surface_state = |
| 432 | anv_state_pool_alloc(&device->surface_state_pool, 64, 64); |
| 433 | |
| 434 | GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 435 | } |
| 436 | |
Chad Versace | 127cb3f | 2015-06-26 20:12:42 -0700 | [diff] [blame] | 437 | VkResult |
| 438 | anv_CreateImageView(VkDevice _device, |
| 439 | const VkImageViewCreateInfo *pCreateInfo, |
| 440 | VkImageView *pView) |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 441 | { |
| 442 | struct anv_device *device = (struct anv_device *) _device; |
Kristian Høgsberg | f5b0f13 | 2015-05-13 15:31:26 -0700 | [diff] [blame] | 443 | struct anv_surface_view *view; |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 444 | |
| 445 | assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO); |
| 446 | |
| 447 | view = anv_device_alloc(device, sizeof(*view), 8, |
| 448 | VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
| 449 | if (view == NULL) |
| 450 | return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); |
| 451 | |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 452 | anv_image_view_init(view, device, pCreateInfo, NULL); |
Jason Ekstrand | 1f7dcf9 | 2015-05-13 17:37:12 -0700 | [diff] [blame] | 453 | |
Jason Ekstrand | 9d6f55d | 2015-06-09 11:08:03 -0700 | [diff] [blame] | 454 | view->base.destructor = anv_surface_view_destroy; |
| 455 | |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 456 | *pView = (VkImageView) view; |
| 457 | |
| 458 | return VK_SUCCESS; |
| 459 | } |
| 460 | |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 461 | void |
| 462 | anv_color_attachment_view_init(struct anv_surface_view *view, |
| 463 | struct anv_device *device, |
| 464 | const VkColorAttachmentViewCreateInfo* pCreateInfo, |
| 465 | struct anv_cmd_buffer *cmd_buffer) |
| 466 | { |
| 467 | struct anv_image *image = (struct anv_image *) pCreateInfo->image; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 468 | struct anv_surface *surface = &image->primary_surface; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 469 | const struct anv_format *format_info = |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 470 | anv_format_for_vk_format(pCreateInfo->format); |
| 471 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 472 | anv_assert(pCreateInfo->arraySize > 0); |
| 473 | anv_assert(pCreateInfo->mipLevel < image->levels); |
| 474 | anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size); |
| 475 | |
| 476 | if (pCreateInfo->msaaResolveImage) |
| 477 | anv_finishme("msaaResolveImage"); |
Jason Ekstrand | 2a3c296 | 2015-06-10 21:04:51 -0700 | [diff] [blame] | 478 | |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 479 | view->bo = image->bo; |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 480 | view->offset = image->offset + surface->offset; |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 481 | view->format = pCreateInfo->format; |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 482 | |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 483 | view->extent = (VkExtent3D) { |
| 484 | .width = anv_minify(image->extent.width, pCreateInfo->mipLevel), |
| 485 | .height = anv_minify(image->extent.height, pCreateInfo->mipLevel), |
| 486 | .depth = anv_minify(image->extent.depth, pCreateInfo->mipLevel), |
| 487 | }; |
| 488 | |
| 489 | uint32_t depth = 1; |
| 490 | if (pCreateInfo->arraySize > 1) { |
| 491 | depth = pCreateInfo->arraySize; |
| 492 | } else if (image->extent.depth > 1) { |
| 493 | depth = image->extent.depth; |
| 494 | } |
| 495 | |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 496 | if (cmd_buffer) |
| 497 | view->surface_state = |
| 498 | anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64); |
| 499 | else |
| 500 | view->surface_state = |
| 501 | anv_state_pool_alloc(&device->surface_state_pool, 64, 64); |
| 502 | |
| 503 | struct GEN8_RENDER_SURFACE_STATE surface_state = { |
| 504 | .SurfaceType = SURFTYPE_2D, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 505 | .SurfaceArray = image->array_size > 1, |
| 506 | .SurfaceFormat = format_info->surface_format, |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 507 | .SurfaceVerticalAlignment = anv_valign[surface->v_align], |
| 508 | .SurfaceHorizontalAlignment = anv_halign[surface->h_align], |
| 509 | .TileMode = surface->tile_mode, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 510 | .VerticalLineStride = 0, |
| 511 | .VerticalLineStrideOffset = 0, |
| 512 | .SamplerL2BypassModeDisable = true, |
| 513 | .RenderCacheReadWriteMode = WriteOnlyCache, |
| 514 | .MemoryObjectControlState = GEN8_MOCS, |
Kristian Høgsberg Kristensen | a5b49d2 | 2015-06-10 23:11:37 -0700 | [diff] [blame] | 515 | .BaseMipLevel = 0.0, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 516 | .SurfaceQPitch = surface->qpitch >> 2, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 517 | .Height = image->extent.height - 1, |
| 518 | .Width = image->extent.width - 1, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 519 | .Depth = depth - 1, |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 520 | .SurfacePitch = surface->stride - 1, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 521 | .MinimumArrayElement = pCreateInfo->baseArraySlice, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 522 | .NumberofMultisamples = MULTISAMPLECOUNT_1, |
| 523 | .XOffset = 0, |
| 524 | .YOffset = 0, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 525 | |
| 526 | /* For render target surfaces, the hardware interprets field MIPCount/LOD as |
| 527 | * LOD. The Broadwell PRM says: |
| 528 | * |
| 529 | * MIPCountLOD defines the LOD that will be rendered into. |
| 530 | * SurfaceMinLOD is ignored. |
| 531 | */ |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 532 | .SurfaceMinLOD = 0, |
Chad Versace | 5b3a1ce | 2015-06-26 21:27:54 -0700 | [diff] [blame^] | 533 | .MIPCountLOD = pCreateInfo->mipLevel, |
| 534 | |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 535 | .AuxiliarySurfaceMode = AUX_NONE, |
| 536 | .RedClearColor = 0, |
| 537 | .GreenClearColor = 0, |
| 538 | .BlueClearColor = 0, |
| 539 | .AlphaClearColor = 0, |
| 540 | .ShaderChannelSelectRed = SCS_RED, |
| 541 | .ShaderChannelSelectGreen = SCS_GREEN, |
| 542 | .ShaderChannelSelectBlue = SCS_BLUE, |
| 543 | .ShaderChannelSelectAlpha = SCS_ALPHA, |
Kristian Høgsberg Kristensen | a5b49d2 | 2015-06-10 23:11:37 -0700 | [diff] [blame] | 544 | .ResourceMinLOD = 0.0, |
Kristian Høgsberg | 0dbed61 | 2015-05-25 22:12:24 -0700 | [diff] [blame] | 545 | .SurfaceBaseAddress = { NULL, view->offset }, |
| 546 | }; |
| 547 | |
| 548 | GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Chad Versace | 127cb3f | 2015-06-26 20:12:42 -0700 | [diff] [blame] | 551 | VkResult |
| 552 | anv_CreateColorAttachmentView(VkDevice _device, |
| 553 | const VkColorAttachmentViewCreateInfo *pCreateInfo, |
| 554 | VkColorAttachmentView *pView) |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 555 | { |
| 556 | struct anv_device *device = (struct anv_device *) _device; |
Kristian Høgsberg | f5b0f13 | 2015-05-13 15:31:26 -0700 | [diff] [blame] | 557 | struct anv_surface_view *view; |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 558 | |
| 559 | assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO); |
| 560 | |
| 561 | view = anv_device_alloc(device, sizeof(*view), 8, |
| 562 | VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
| 563 | if (view == NULL) |
| 564 | return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); |
| 565 | |
Jason Ekstrand | 4668bbb | 2015-05-18 20:42:03 -0700 | [diff] [blame] | 566 | anv_color_attachment_view_init(view, device, pCreateInfo, NULL); |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 567 | |
Jason Ekstrand | 9d6f55d | 2015-06-09 11:08:03 -0700 | [diff] [blame] | 568 | view->base.destructor = anv_surface_view_destroy; |
| 569 | |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 570 | *pView = (VkColorAttachmentView) view; |
| 571 | |
| 572 | return VK_SUCCESS; |
| 573 | } |
| 574 | |
Chad Versace | 127cb3f | 2015-06-26 20:12:42 -0700 | [diff] [blame] | 575 | VkResult |
| 576 | anv_CreateDepthStencilView(VkDevice _device, |
| 577 | const VkDepthStencilViewCreateInfo *pCreateInfo, |
| 578 | VkDepthStencilView *pView) |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 579 | { |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 580 | struct anv_device *device = (struct anv_device *) _device; |
| 581 | struct anv_depth_stencil_view *view; |
| 582 | struct anv_image *image = (struct anv_image *) pCreateInfo->image; |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 583 | struct anv_surface *depth_surface = &image->primary_surface; |
| 584 | struct anv_surface *stencil_surface = &image->stencil_surface; |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 585 | const struct anv_format *format = |
| 586 | anv_format_for_vk_format(image->format); |
| 587 | |
| 588 | assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO); |
| 589 | |
| 590 | view = anv_device_alloc(device, sizeof(*view), 8, |
| 591 | VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
| 592 | if (view == NULL) |
| 593 | return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); |
| 594 | |
Jason Ekstrand | 2a3c296 | 2015-06-10 21:04:51 -0700 | [diff] [blame] | 595 | /* XXX: We don't handle any of these */ |
| 596 | anv_assert(pCreateInfo->mipLevel == 0); |
| 597 | anv_assert(pCreateInfo->baseArraySlice == 0); |
| 598 | anv_assert(pCreateInfo->arraySize == 1); |
| 599 | anv_assert(pCreateInfo->msaaResolveImage == 0); |
| 600 | |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 601 | view->bo = image->bo; |
| 602 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 603 | view->depth_stride = depth_surface->stride; |
| 604 | view->depth_offset = image->offset + depth_surface->offset; |
Chad Versace | ebe1e76 | 2015-06-25 19:29:59 -0700 | [diff] [blame] | 605 | view->depth_format = format->depth_format; |
Chad Versace | 7ea707a | 2015-06-25 19:46:42 -0700 | [diff] [blame] | 606 | view->depth_qpitch = 0; /* FINISHME: QPitch */ |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 607 | |
Chad Versace | c6e76ae | 2015-06-26 18:48:34 -0700 | [diff] [blame] | 608 | view->stencil_stride = stencil_surface->stride; |
| 609 | view->stencil_offset = image->offset + stencil_surface->offset; |
Chad Versace | 7ea707a | 2015-06-25 19:46:42 -0700 | [diff] [blame] | 610 | view->stencil_qpitch = 0; /* FINISHME: QPitch */ |
Kristian Høgsberg | 37743f9 | 2015-05-22 22:59:12 -0700 | [diff] [blame] | 611 | |
| 612 | *pView = (VkDepthStencilView) view; |
| 613 | |
| 614 | return VK_SUCCESS; |
Kristian Høgsberg | 769785c | 2015-05-08 22:32:37 -0700 | [diff] [blame] | 615 | } |