#include "anv_private.h"
+/* FIXME: We shouldn't be using the actual hardware enum values here. They
+ * change across gens. Once we get that fixed, this include needs to go.
+ */
+#include "gen8_pack.h"
+
static const uint8_t anv_halign[] = {
[4] = HALIGN4,
[8] = HALIGN8,
};
static const struct anv_tile_info {
- uint32_t width;
- uint32_t height;
-
/**
* Alignment for RENDER_SURFACE_STATE.SurfaceBaseAddress.
*
*/
uint32_t surface_alignment;
} anv_tile_info_table[] = {
- [LINEAR] = { 1, 1, 64 },
- [XMAJOR] = { 512, 8, 4096 },
- [YMAJOR] = { 128, 32, 4096 },
- [WMAJOR] = { 128, 32, 4096 },
+ [ISL_TILING_LINEAR] = { 64 },
+ [ISL_TILING_X] = { 4096 },
+ [ISL_TILING_Y] = { 4096 },
+ [ISL_TILING_Yf] = { 4096 },
+ [ISL_TILING_Ys] = { 4096 },
+ [ISL_TILING_W] = { 4096 },
};
-static uint8_t
-anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info)
+static enum isl_tiling
+anv_image_choose_tiling(const struct anv_image_create_info *anv_info)
{
- if (anv_info->force_tile_mode)
- return anv_info->tile_mode;
+ if (anv_info->force_tiling)
+ return anv_info->tiling;
/* The Sandybridge PRM says that the stencil buffer "is supported
* only in Tile W memory".
switch (anv_info->vk_info->tiling) {
case VK_IMAGE_TILING_LINEAR:
assert(anv_info->vk_info->format != VK_FORMAT_S8_UINT);
- return LINEAR;
+ return ISL_TILING_LINEAR;
case VK_IMAGE_TILING_OPTIMAL:
if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) {
- return WMAJOR;
+ return ISL_TILING_W;
} else {
- return YMAJOR;
+ return ISL_TILING_Y;
}
default:
assert(!"bad VKImageTiling");
- return LINEAR;
+ return ISL_TILING_LINEAR;
}
}
* struct anv_image_create_info.
*/
static VkResult
-anv_image_make_surface(const struct anv_image_create_info *create_info,
+anv_image_make_surface(const struct anv_device *dev,
+ const struct anv_image_create_info *create_info,
const struct anv_format *format,
uint64_t *inout_image_size,
uint32_t *inout_image_alignment,
const VkExtent3D *restrict extent = &create_info->vk_info->extent;
const uint32_t levels = create_info->vk_info->mipLevels;
const uint32_t array_size = create_info->vk_info->arraySize;
- const uint8_t tile_mode = anv_image_choose_tile_mode(create_info);
+ const enum isl_tiling tiling = anv_image_choose_tiling(create_info);
const struct anv_tile_info *tile_info =
- &anv_tile_info_table[tile_mode];
+ &anv_tile_info_table[tiling];
+
+ const uint32_t bs = format->isl_layout->bs;
+ const uint32_t bw = format->isl_layout->bw;
+ const uint32_t bh = format->isl_layout->bh;
- const uint32_t i = 4; /* FINISHME: Stop hardcoding subimage alignment */
- const uint32_t j = 4; /* FINISHME: Stop hardcoding subimage alignment */
+ struct isl_extent2d tile_extent;
+ isl_tiling_get_extent(&dev->isl_dev, tiling, bs, &tile_extent);
+
+ const uint32_t i = MAX(4, bw); /* FINISHME: Stop hardcoding subimage alignment */
+ const uint32_t j = MAX(4, bh); /* FINISHME: Stop hardcoding subimage alignment */
+ assert(i == 4 || i == 8 || i == 16);
+ assert(j == 4 || j == 8 || j == 16);
uint16_t qpitch = min_qpitch;
uint32_t mt_width = 0;
* Views >> Common Surface Formats >> Surface Layout >> 2D Surfaces >>
* Surface Arrays >> For All Surface Other Than Separate Stencil Buffer:
*/
- qpitch = h0 + h1 + 11 * j;
+ assert(bh ==1 || bh == 4);
+ qpitch = (h0 + h1 + 11 * j) / bh;
mt_width = MAX(w0, w1 + w2);
mt_height = array_size * qpitch;
}
*/
assert(anv_is_aligned(qpitch, j));
- uint32_t stride = align_u32(mt_width * format->bs, tile_info->width);
+ uint32_t stride = align_u32(mt_width * bs / bw, tile_extent.width);
if (create_info->stride > 0)
stride = create_info->stride;
- const uint32_t size = stride * align_u32(mt_height, tile_info->height);
+ /* The padding requirement is found in the Broadwell PRM >> Volume 5: Memory
+ * Views >> Common Surface Formats >> Surface Padding Requirements >>
+ * Sampling Engine Surfaces >> Buffer Padding Requirements:
+ */
+ const uint32_t mem_rows = align_u32(mt_height / bh, 2 * bh);
+ const uint32_t size = stride * align_u32(mem_rows, tile_extent.height);
const uint32_t offset = align_u32(*inout_image_size,
tile_info->surface_alignment);
*out_surface = (struct anv_surface) {
.offset = offset,
.stride = stride,
- .tile_mode = tile_mode,
+ .tiling = tiling,
.qpitch = qpitch,
.h_align = i,
.v_align = j,
{
VkImageUsageFlags usage = info->usage;
- if (usage & VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT) {
+ if (usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
/* Meta will transfer from the image by binding it as a texture. */
usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
}
- if (usage & VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT) {
+ if (usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) {
/* Meta will transfer to the image by binding it as a color attachment,
* even if the image format is not a color format.
*/
}
if (likely(anv_format_is_color(image->format))) {
- r = anv_image_make_surface(create_info, image->format,
+ r = anv_image_make_surface(device, create_info, image->format,
&image->size, &image->alignment,
&image->color_surface);
if (r != VK_SUCCESS)
goto fail;
} else {
if (image->format->depth_format) {
- r = anv_image_make_surface(create_info, image->format,
+ r = anv_image_make_surface(device, create_info, image->format,
&image->size, &image->alignment,
&image->depth_surface);
if (r != VK_SUCCESS)
}
if (image->format->has_stencil) {
- r = anv_image_make_surface(create_info, anv_format_s8_uint,
+ r = anv_image_make_surface(device, create_info, anv_format_s8_uint,
&image->size, &image->alignment,
&image->stencil_surface);
if (r != VK_SUCCESS)
layout->size = surface->stride * image->extent.height;
}
-VkResult anv_GetImageSubresourceLayout(
+void anv_GetImageSubresourceLayout(
VkDevice device,
VkImage _image,
const VkImageSubresource* pSubresource,
{
ANV_FROM_HANDLE(anv_image, image, _image);
- switch (pSubresource->aspect) {
- case VK_IMAGE_ASPECT_COLOR:
+ assert(__builtin_popcount(pSubresource->aspectMask) == 1);
+
+ switch (pSubresource->aspectMask) {
+ case VK_IMAGE_ASPECT_COLOR_BIT:
anv_surface_get_subresource_layout(image, &image->color_surface,
pSubresource, pLayout);
break;
- case VK_IMAGE_ASPECT_DEPTH:
+ case VK_IMAGE_ASPECT_DEPTH_BIT:
anv_surface_get_subresource_layout(image, &image->depth_surface,
pSubresource, pLayout);
break;
- case VK_IMAGE_ASPECT_STENCIL:
+ case VK_IMAGE_ASPECT_STENCIL_BIT:
anv_surface_get_subresource_layout(image, &image->stencil_surface,
pSubresource, pLayout);
break;
default:
- return vk_error(VK_UNSUPPORTED);
+ assert(!"Invalid image aspect");
}
-
- return VK_SUCCESS;
}
VkResult
view_format_info = anv_format_for_vk_format(pCreateInfo->format);
/* Validate channel swizzles. */
- assert(pCreateInfo->channels.r >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.r <= VK_CHANNEL_SWIZZLE_END_RANGE);
- assert(pCreateInfo->channels.g >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.g <= VK_CHANNEL_SWIZZLE_END_RANGE);
- assert(pCreateInfo->channels.b >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.b <= VK_CHANNEL_SWIZZLE_END_RANGE);
- assert(pCreateInfo->channels.a >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.a <= VK_CHANNEL_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.r >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.r <= VK_COMPONENT_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.g >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.g <= VK_COMPONENT_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.b >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.b <= VK_COMPONENT_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.a >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.a <= VK_COMPONENT_SWIZZLE_END_RANGE);
/* Validate subresource. */
assert(subresource->aspectMask != 0);
assert(!image->format->has_stencil);
assert(!view_format_info->depth_format);
assert(!view_format_info->has_stencil);
- assert(view_format_info->bs == image->format->bs);
+ assert(view_format_info->isl_layout->bs ==
+ image->format->isl_layout->bs);
} else if (subresource->aspectMask & ds_flags) {
assert((subresource->aspectMask & ~ds_flags) == 0);
if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) {
assert(image->format->depth_format);
assert(view_format_info->depth_format);
- assert(view_format_info->bs == image->format->bs);
+ assert(view_format_info->isl_layout->bs ==
+ image->format->isl_layout->bs);
}
- if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL) {
+ if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) {
/* FINISHME: Is it legal to have an R8 view of S8? */
assert(image->format->has_stencil);
assert(view_format_info->has_stencil);
switch (device->info.gen) {
case 7:
- gen7_image_view_init(iview, device, pCreateInfo, cmd_buffer);
+ 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");
}