2 * Copyright © 2015 Intel Corporation
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:
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
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
30 #include "anv_private.h"
32 /* FIXME: We shouldn't be using the actual hardware enum values here. They
33 * change across gens. Once we get that fixed, this include needs to go.
35 #include "gen8_pack.h"
38 * The \a format argument is required and overrides any format found in struct
39 * anv_image_create_info. Exactly one bit must be set in \a aspect.
41 static isl_surf_usage_flags_t
42 choose_isl_surf_usage(const struct anv_image_create_info
*info
,
43 VkImageAspectFlags aspect
)
45 const VkImageCreateInfo
*vk_info
= info
->vk_info
;
46 isl_surf_usage_flags_t isl_flags
= 0;
48 /* FINISHME: Support aux surfaces */
49 isl_flags
|= ISL_SURF_USAGE_DISABLE_AUX_BIT
;
51 if (vk_info
->usage
& VK_IMAGE_USAGE_SAMPLED_BIT
)
52 isl_flags
|= ISL_SURF_USAGE_TEXTURE_BIT
;
54 if (vk_info
->usage
& VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
)
55 isl_flags
|= ISL_SURF_USAGE_TEXTURE_BIT
;
57 if (vk_info
->usage
& VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
)
58 isl_flags
|= ISL_SURF_USAGE_RENDER_TARGET_BIT
;
60 if (vk_info
->flags
& VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
)
61 isl_flags
|= ISL_SURF_USAGE_CUBE_BIT
;
63 if (vk_info
->usage
& VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
) {
66 unreachable("bad VkImageAspect");
67 case VK_IMAGE_ASPECT_DEPTH_BIT
:
68 isl_flags
|= ISL_SURF_USAGE_DEPTH_BIT
;
70 case VK_IMAGE_ASPECT_STENCIL_BIT
:
71 isl_flags
|= ISL_SURF_USAGE_STENCIL_BIT
;
76 if (vk_info
->usage
& VK_IMAGE_USAGE_TRANSFER_SRC_BIT
) {
77 /* Meta implements transfers by sampling from the source image. */
78 isl_flags
|= ISL_SURF_USAGE_TEXTURE_BIT
;
81 if (vk_info
->usage
& VK_IMAGE_USAGE_TRANSFER_DST_BIT
) {
82 /* Meta implements transfers by rendering into the destination image. */
83 isl_flags
|= ISL_SURF_USAGE_RENDER_TARGET_BIT
;
90 * Exactly one bit must be set in \a aspect.
92 static struct anv_surface
*
93 get_surface(struct anv_image
*image
, VkImageAspectFlags aspect
)
97 unreachable("bad VkImageAspect");
98 case VK_IMAGE_ASPECT_COLOR_BIT
:
99 return &image
->color_surface
;
100 case VK_IMAGE_ASPECT_DEPTH_BIT
:
101 return &image
->depth_surface
;
102 case VK_IMAGE_ASPECT_STENCIL_BIT
:
103 return &image
->stencil_surface
;
108 * Initialize the anv_image::*_surface selected by \a aspect. Then update the
109 * image's memory requirements (that is, the image's size and alignment).
111 * Exactly one bit must be set in \a aspect.
114 make_surface(const struct anv_device
*dev
,
115 struct anv_image
*image
,
116 const struct anv_image_create_info
*anv_info
,
117 VkImageAspectFlags aspect
)
119 const VkImageCreateInfo
*vk_info
= anv_info
->vk_info
;
122 static const enum isl_surf_dim vk_to_isl_surf_dim
[] = {
123 [VK_IMAGE_TYPE_1D
] = ISL_SURF_DIM_1D
,
124 [VK_IMAGE_TYPE_2D
] = ISL_SURF_DIM_2D
,
125 [VK_IMAGE_TYPE_3D
] = ISL_SURF_DIM_3D
,
128 isl_tiling_flags_t tiling_flags
= anv_info
->isl_tiling_flags
;
129 if (vk_info
->tiling
== VK_IMAGE_TILING_LINEAR
)
130 tiling_flags
&= ISL_TILING_LINEAR_BIT
;
132 struct anv_surface
*anv_surf
= get_surface(image
, aspect
);
134 ok
= isl_surf_init(&dev
->isl_dev
, &anv_surf
->isl
,
135 .dim
= vk_to_isl_surf_dim
[vk_info
->imageType
],
136 .format
= anv_get_isl_format(vk_info
->format
, aspect
, vk_info
->tiling
),
137 .width
= vk_info
->extent
.width
,
138 .height
= vk_info
->extent
.height
,
139 .depth
= vk_info
->extent
.depth
,
140 .levels
= vk_info
->mipLevels
,
141 .array_len
= vk_info
->arrayLayers
,
142 .samples
= vk_info
->samples
,
145 .usage
= choose_isl_surf_usage(anv_info
, aspect
),
146 .tiling_flags
= tiling_flags
);
148 /* isl_surf_init() will fail only if provided invalid input. Invalid input
149 * is illegal in Vulkan.
153 anv_surf
->offset
= align_u32(image
->size
, anv_surf
->isl
.alignment
);
154 image
->size
= anv_surf
->offset
+ anv_surf
->isl
.size
;
155 image
->alignment
= MAX(image
->alignment
, anv_surf
->isl
.alignment
);
160 static VkImageUsageFlags
161 anv_image_get_full_usage(const VkImageCreateInfo
*info
)
163 VkImageUsageFlags usage
= info
->usage
;
165 if (usage
& VK_IMAGE_USAGE_TRANSFER_SRC_BIT
) {
166 /* Meta will transfer from the image by binding it as a texture. */
167 usage
|= VK_IMAGE_USAGE_SAMPLED_BIT
;
170 if (usage
& VK_IMAGE_USAGE_TRANSFER_DST_BIT
) {
171 /* Meta will transfer to the image by binding it as a color attachment,
172 * even if the image format is not a color format.
174 usage
|= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
;
181 anv_image_create(VkDevice _device
,
182 const struct anv_image_create_info
*create_info
,
183 const VkAllocationCallbacks
* alloc
,
186 ANV_FROM_HANDLE(anv_device
, device
, _device
);
187 const VkImageCreateInfo
*pCreateInfo
= create_info
->vk_info
;
188 struct anv_image
*image
= NULL
;
191 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
);
193 anv_assert(pCreateInfo
->mipLevels
> 0);
194 anv_assert(pCreateInfo
->arrayLayers
> 0);
195 anv_assert(pCreateInfo
->samples
== VK_SAMPLE_COUNT_1_BIT
);
196 anv_assert(pCreateInfo
->extent
.width
> 0);
197 anv_assert(pCreateInfo
->extent
.height
> 0);
198 anv_assert(pCreateInfo
->extent
.depth
> 0);
200 image
= anv_alloc2(&device
->alloc
, alloc
, sizeof(*image
), 8,
201 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
203 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
205 memset(image
, 0, sizeof(*image
));
206 image
->type
= pCreateInfo
->imageType
;
207 image
->extent
= pCreateInfo
->extent
;
208 image
->vk_format
= pCreateInfo
->format
;
209 image
->format
= anv_format_for_vk_format(pCreateInfo
->format
);
210 image
->levels
= pCreateInfo
->mipLevels
;
211 image
->array_size
= pCreateInfo
->arrayLayers
;
212 image
->usage
= anv_image_get_full_usage(pCreateInfo
);
213 image
->tiling
= pCreateInfo
->tiling
;
215 if (image
->usage
& VK_IMAGE_USAGE_SAMPLED_BIT
) {
216 image
->needs_nonrt_surface_state
= true;
219 if (image
->usage
& VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
) {
220 image
->needs_color_rt_surface_state
= true;
223 if (image
->usage
& VK_IMAGE_USAGE_STORAGE_BIT
) {
224 image
->needs_storage_surface_state
= true;
227 if (likely(anv_format_is_color(image
->format
))) {
228 r
= make_surface(device
, image
, create_info
,
229 VK_IMAGE_ASPECT_COLOR_BIT
);
233 if (image
->format
->depth_format
) {
234 r
= make_surface(device
, image
, create_info
,
235 VK_IMAGE_ASPECT_DEPTH_BIT
);
240 if (image
->format
->has_stencil
) {
241 r
= make_surface(device
, image
, create_info
,
242 VK_IMAGE_ASPECT_STENCIL_BIT
);
248 *pImage
= anv_image_to_handle(image
);
254 anv_free2(&device
->alloc
, alloc
, image
);
260 anv_CreateImage(VkDevice device
,
261 const VkImageCreateInfo
*pCreateInfo
,
262 const VkAllocationCallbacks
*pAllocator
,
265 return anv_image_create(device
,
266 &(struct anv_image_create_info
) {
267 .vk_info
= pCreateInfo
,
268 .isl_tiling_flags
= ISL_TILING_ANY_MASK
,
275 anv_DestroyImage(VkDevice _device
, VkImage _image
,
276 const VkAllocationCallbacks
*pAllocator
)
278 ANV_FROM_HANDLE(anv_device
, device
, _device
);
280 anv_free2(&device
->alloc
, pAllocator
, anv_image_from_handle(_image
));
284 anv_surface_get_subresource_layout(struct anv_image
*image
,
285 struct anv_surface
*surface
,
286 const VkImageSubresource
*subresource
,
287 VkSubresourceLayout
*layout
)
289 /* If we are on a non-zero mip level or array slice, we need to
290 * calculate a real offset.
292 anv_assert(subresource
->mipLevel
== 0);
293 anv_assert(subresource
->arrayLayer
== 0);
295 layout
->offset
= surface
->offset
;
296 layout
->rowPitch
= surface
->isl
.row_pitch
;
297 layout
->depthPitch
= isl_surf_get_array_pitch(&surface
->isl
);
298 layout
->size
= surface
->isl
.size
;
301 void anv_GetImageSubresourceLayout(
304 const VkImageSubresource
* pSubresource
,
305 VkSubresourceLayout
* pLayout
)
307 ANV_FROM_HANDLE(anv_image
, image
, _image
);
309 assert(__builtin_popcount(pSubresource
->aspectMask
) == 1);
311 switch (pSubresource
->aspectMask
) {
312 case VK_IMAGE_ASPECT_COLOR_BIT
:
313 anv_surface_get_subresource_layout(image
, &image
->color_surface
,
314 pSubresource
, pLayout
);
316 case VK_IMAGE_ASPECT_DEPTH_BIT
:
317 anv_surface_get_subresource_layout(image
, &image
->depth_surface
,
318 pSubresource
, pLayout
);
320 case VK_IMAGE_ASPECT_STENCIL_BIT
:
321 anv_surface_get_subresource_layout(image
, &image
->stencil_surface
,
322 pSubresource
, pLayout
);
325 assert(!"Invalid image aspect");
330 anv_validate_CreateImageView(VkDevice _device
,
331 const VkImageViewCreateInfo
*pCreateInfo
,
332 const VkAllocationCallbacks
*pAllocator
,
335 ANV_FROM_HANDLE(anv_image
, image
, pCreateInfo
->image
);
336 const VkImageSubresourceRange
*subresource
;
337 const struct anv_format
*view_format_info
;
339 /* Validate structure type before dereferencing it. */
341 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
);
342 subresource
= &pCreateInfo
->subresourceRange
;
344 /* Validate viewType is in range before using it. */
345 assert(pCreateInfo
->viewType
>= VK_IMAGE_VIEW_TYPE_BEGIN_RANGE
);
346 assert(pCreateInfo
->viewType
<= VK_IMAGE_VIEW_TYPE_END_RANGE
);
348 /* Validate format is in range before using it. */
349 assert(pCreateInfo
->format
>= VK_FORMAT_BEGIN_RANGE
);
350 assert(pCreateInfo
->format
<= VK_FORMAT_END_RANGE
);
351 view_format_info
= anv_format_for_vk_format(pCreateInfo
->format
);
353 /* Validate channel swizzles. */
354 assert(pCreateInfo
->components
.r
>= VK_COMPONENT_SWIZZLE_BEGIN_RANGE
);
355 assert(pCreateInfo
->components
.r
<= VK_COMPONENT_SWIZZLE_END_RANGE
);
356 assert(pCreateInfo
->components
.g
>= VK_COMPONENT_SWIZZLE_BEGIN_RANGE
);
357 assert(pCreateInfo
->components
.g
<= VK_COMPONENT_SWIZZLE_END_RANGE
);
358 assert(pCreateInfo
->components
.b
>= VK_COMPONENT_SWIZZLE_BEGIN_RANGE
);
359 assert(pCreateInfo
->components
.b
<= VK_COMPONENT_SWIZZLE_END_RANGE
);
360 assert(pCreateInfo
->components
.a
>= VK_COMPONENT_SWIZZLE_BEGIN_RANGE
);
361 assert(pCreateInfo
->components
.a
<= VK_COMPONENT_SWIZZLE_END_RANGE
);
363 /* Validate subresource. */
364 assert(subresource
->aspectMask
!= 0);
365 assert(subresource
->levelCount
> 0);
366 assert(subresource
->layerCount
> 0);
367 assert(subresource
->baseMipLevel
< image
->levels
);
368 assert(subresource
->baseMipLevel
+ subresource
->levelCount
<= image
->levels
);
369 assert(subresource
->baseArrayLayer
< image
->array_size
);
370 assert(subresource
->baseArrayLayer
+ subresource
->layerCount
<= image
->array_size
);
373 const VkImageAspectFlags ds_flags
= VK_IMAGE_ASPECT_DEPTH_BIT
374 | VK_IMAGE_ASPECT_STENCIL_BIT
;
376 /* Validate format. */
377 if (subresource
->aspectMask
& VK_IMAGE_ASPECT_COLOR_BIT
) {
378 assert(subresource
->aspectMask
== VK_IMAGE_ASPECT_COLOR_BIT
);
379 assert(!image
->format
->depth_format
);
380 assert(!image
->format
->has_stencil
);
381 assert(!view_format_info
->depth_format
);
382 assert(!view_format_info
->has_stencil
);
383 assert(view_format_info
->isl_layout
->bs
==
384 image
->format
->isl_layout
->bs
);
385 } else if (subresource
->aspectMask
& ds_flags
) {
386 assert((subresource
->aspectMask
& ~ds_flags
) == 0);
388 if (subresource
->aspectMask
& VK_IMAGE_ASPECT_STENCIL_BIT
) {
389 assert(image
->format
->depth_format
);
390 assert(view_format_info
->depth_format
);
391 assert(view_format_info
->isl_layout
->bs
==
392 image
->format
->isl_layout
->bs
);
395 if (subresource
->aspectMask
& VK_IMAGE_ASPECT_STENCIL_BIT
) {
396 /* FINISHME: Is it legal to have an R8 view of S8? */
397 assert(image
->format
->has_stencil
);
398 assert(view_format_info
->has_stencil
);
401 assert(!"bad VkImageSubresourceRange::aspectFlags");
404 return anv_CreateImageView(_device
, pCreateInfo
, pAllocator
, pView
);
408 anv_image_view_init(struct anv_image_view
*iview
,
409 struct anv_device
*device
,
410 const VkImageViewCreateInfo
* pCreateInfo
,
411 struct anv_cmd_buffer
*cmd_buffer
)
413 ANV_FROM_HANDLE(anv_image
, image
, pCreateInfo
->image
);
414 const VkImageSubresourceRange
*range
= &pCreateInfo
->subresourceRange
;
416 assert(range
->layerCount
> 0);
417 assert(range
->baseMipLevel
< image
->levels
);
418 assert(image
->usage
& (VK_IMAGE_USAGE_SAMPLED_BIT
|
419 VK_IMAGE_USAGE_STORAGE_BIT
|
420 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
421 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
));
423 switch (image
->type
) {
425 unreachable("bad VkImageType");
426 case VK_IMAGE_TYPE_1D
:
427 case VK_IMAGE_TYPE_2D
:
428 assert(range
->baseArrayLayer
+ range
->layerCount
- 1 <= image
->array_size
);
430 case VK_IMAGE_TYPE_3D
:
431 assert(range
->baseArrayLayer
+ range
->layerCount
- 1
432 <= anv_minify(image
->extent
.depth
, range
->baseMipLevel
));
436 struct anv_surface
*surface
=
437 anv_image_get_surface_for_aspect_mask(image
, range
->aspectMask
);
439 iview
->image
= image
;
440 iview
->bo
= image
->bo
;
441 iview
->offset
= image
->offset
+ surface
->offset
;
443 iview
->aspect_mask
= pCreateInfo
->subresourceRange
.aspectMask
;
444 iview
->vk_format
= pCreateInfo
->format
;
445 iview
->format
= anv_get_isl_format(pCreateInfo
->format
, iview
->aspect_mask
,
448 iview
->extent
= (VkExtent3D
) {
449 .width
= anv_minify(image
->extent
.width
, range
->baseMipLevel
),
450 .height
= anv_minify(image
->extent
.height
, range
->baseMipLevel
),
451 .depth
= anv_minify(image
->extent
.depth
, range
->baseMipLevel
),
454 switch (device
->info
.gen
) {
456 if (device
->info
.is_haswell
)
457 gen75_image_view_init(iview
, device
, pCreateInfo
, cmd_buffer
);
459 gen7_image_view_init(iview
, device
, pCreateInfo
, cmd_buffer
);
462 gen8_image_view_init(iview
, device
, pCreateInfo
, cmd_buffer
);
465 gen9_image_view_init(iview
, device
, pCreateInfo
, cmd_buffer
);
468 unreachable("unsupported gen\n");
473 anv_CreateImageView(VkDevice _device
,
474 const VkImageViewCreateInfo
*pCreateInfo
,
475 const VkAllocationCallbacks
*pAllocator
,
478 ANV_FROM_HANDLE(anv_device
, device
, _device
);
479 struct anv_image_view
*view
;
481 view
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*view
), 8,
482 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
484 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
486 anv_image_view_init(view
, device
, pCreateInfo
, NULL
);
488 *pView
= anv_image_view_to_handle(view
);
494 anv_DestroyImageView(VkDevice _device
, VkImageView _iview
,
495 const VkAllocationCallbacks
*pAllocator
)
497 ANV_FROM_HANDLE(anv_device
, device
, _device
);
498 ANV_FROM_HANDLE(anv_image_view
, iview
, _iview
);
500 if (iview
->image
->needs_color_rt_surface_state
) {
501 anv_state_pool_free(&device
->surface_state_pool
,
502 iview
->color_rt_surface_state
);
505 if (iview
->image
->needs_nonrt_surface_state
) {
506 anv_state_pool_free(&device
->surface_state_pool
,
507 iview
->nonrt_surface_state
);
510 if (iview
->image
->needs_storage_surface_state
) {
511 anv_state_pool_free(&device
->surface_state_pool
,
512 iview
->storage_surface_state
);
515 anv_free2(&device
->alloc
, pAllocator
, iview
);
519 anv_CreateBufferView(VkDevice _device
,
520 const VkBufferViewCreateInfo
*pCreateInfo
,
521 const VkAllocationCallbacks
*pAllocator
,
524 ANV_FROM_HANDLE(anv_device
, device
, _device
);
525 ANV_FROM_HANDLE(anv_buffer
, buffer
, pCreateInfo
->buffer
);
526 struct anv_buffer_view
*view
;
528 view
= anv_alloc2(&device
->alloc
, pAllocator
, sizeof(*view
), 8,
529 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
531 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
533 const struct anv_format
*format
=
534 anv_format_for_vk_format(pCreateInfo
->format
);
536 view
->format
= format
->surface_format
;
537 view
->bo
= buffer
->bo
;
538 view
->offset
= buffer
->offset
+ pCreateInfo
->offset
;
539 view
->range
= pCreateInfo
->range
;
541 if (buffer
->usage
& VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
) {
542 view
->surface_state
=
543 anv_state_pool_alloc(&device
->surface_state_pool
, 64, 64);
545 anv_fill_buffer_surface_state(device
, view
->surface_state
.map
,
547 view
->offset
, pCreateInfo
->range
,
548 format
->isl_layout
->bs
);
550 view
->surface_state
= (struct anv_state
){ 0 };
553 if (buffer
->usage
& VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
) {
554 view
->storage_surface_state
=
555 anv_state_pool_alloc(&device
->surface_state_pool
, 64, 64);
557 enum isl_format storage_format
=
558 isl_lower_storage_image_format(&device
->isl_dev
, view
->format
);
560 anv_fill_buffer_surface_state(device
, view
->storage_surface_state
.map
,
562 view
->offset
, pCreateInfo
->range
,
563 format
->isl_layout
->bs
);
565 view
->storage_surface_state
= (struct anv_state
){ 0 };
568 *pView
= anv_buffer_view_to_handle(view
);
574 anv_DestroyBufferView(VkDevice _device
, VkBufferView bufferView
,
575 const VkAllocationCallbacks
*pAllocator
)
577 ANV_FROM_HANDLE(anv_device
, device
, _device
);
578 ANV_FROM_HANDLE(anv_buffer_view
, view
, bufferView
);
580 if (view
->surface_state
.alloc_size
> 0)
581 anv_state_pool_free(&device
->surface_state_pool
,
582 view
->surface_state
);
584 if (view
->storage_surface_state
.alloc_size
> 0)
585 anv_state_pool_free(&device
->surface_state_pool
,
586 view
->storage_surface_state
);
588 anv_free2(&device
->alloc
, pAllocator
, view
);
592 anv_image_get_surface_for_aspect_mask(struct anv_image
*image
, VkImageAspectFlags aspect_mask
)
594 switch (aspect_mask
) {
595 case VK_IMAGE_ASPECT_COLOR_BIT
:
596 /* Dragons will eat you.
598 * Meta attaches all destination surfaces as color render targets. Guess
599 * what surface the Meta Dragons really want.
601 if (image
->format
->depth_format
&& image
->format
->has_stencil
) {
602 anv_finishme("combined depth stencil formats");
603 return &image
->depth_surface
;
604 } else if (image
->format
->depth_format
) {
605 return &image
->depth_surface
;
606 } else if (image
->format
->has_stencil
) {
607 return &image
->stencil_surface
;
609 return &image
->color_surface
;
612 case VK_IMAGE_ASPECT_DEPTH_BIT
:
613 assert(image
->format
->depth_format
);
614 return &image
->depth_surface
;
615 case VK_IMAGE_ASPECT_STENCIL_BIT
:
616 assert(image
->format
->has_stencil
);
617 return &image
->stencil_surface
;
618 case VK_IMAGE_ASPECT_DEPTH_BIT
| VK_IMAGE_ASPECT_STENCIL_BIT
:
619 if (image
->format
->depth_format
&& image
->format
->has_stencil
) {
620 /* FINISHME: The Vulkan spec (git a511ba2) requires support for combined
621 * depth stencil formats. Specifically, it states:
623 * At least one of ename:VK_FORMAT_D24_UNORM_S8_UINT or
624 * ename:VK_FORMAT_D32_SFLOAT_S8_UINT must be supported.
626 anv_finishme("combined depthstencil aspect");
627 return &image
->depth_surface
;
628 } else if (image
->format
->depth_format
) {
629 return &image
->depth_surface
;
630 } else if (image
->format
->has_stencil
) {
631 return &image
->stencil_surface
;
635 unreachable("image does not have aspect");
641 anv_image_view_fill_image_param(struct anv_device
*device
,
642 struct anv_image_view
*view
,
643 struct brw_image_param
*param
)
645 memset(param
, 0, sizeof *param
);
646 anv_finishme("Actually fill out brw_image_param");
650 anv_buffer_view_fill_image_param(struct anv_device
*device
,
651 struct anv_buffer_view
*view
,
652 struct brw_image_param
*param
)
654 /* Set the swizzling shifts to all-ones to effectively disable swizzling --
655 * See emit_address_calculation() in brw_fs_surface_builder.cpp for a more
656 * detailed explanation of these parameters.
658 param
->swizzling
[0] = 0xff;
659 param
->swizzling
[1] = 0xff;
661 param
->stride
[0] = isl_format_layouts
[view
->format
].bs
;
662 param
->size
[0] = view
->range
/ param
->stride
[0];