From: Chad Versace Date: Fri, 13 Nov 2015 18:24:57 +0000 (-0800) Subject: anv: Use enum isl_tiling everywhere X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba467467f49577381be651643dd7ff184b998590;p=mesa.git anv: Use enum isl_tiling everywhere In anv_surface and anv_image_create_info, replace member 'uint8_t tile_mode' with 'enum isl_tiling'. As a nice side-effect, this patch also reduces bug potential because the hardware enum values for tile modes are unstable across hardware generations. --- diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index ecd34e3ab5b..e90257e8faa 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -80,9 +80,6 @@ static const struct anv_surf_type_limits { }; static const struct anv_tile_info { - uint32_t width; - uint32_t height; - /** * Alignment for RENDER_SURFACE_STATE.SurfaceBaseAddress. * @@ -96,17 +93,19 @@ static const struct anv_tile_info { */ 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". @@ -115,16 +114,16 @@ anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) 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; } } @@ -134,7 +133,8 @@ anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) * 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, @@ -147,15 +147,18 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, 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; + 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); @@ -232,7 +235,7 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, */ assert(anv_is_aligned(qpitch, j)); - uint32_t stride = align_u32(mt_width * bs / bw, tile_info->width); + uint32_t stride = align_u32(mt_width * bs / bw, tile_extent.width); if (create_info->stride > 0) stride = create_info->stride; @@ -241,7 +244,7 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, * 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_info->height); + 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); @@ -252,7 +255,7 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, *out_surface = (struct anv_surface) { .offset = offset, .stride = stride, - .tile_mode = tile_mode, + .tiling = tiling, .qpitch = qpitch, .h_align = i, .v_align = j, @@ -337,14 +340,14 @@ anv_image_create(VkDevice _device, } 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) @@ -352,7 +355,7 @@ anv_image_create(VkDevice _device, } 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) diff --git a/src/vulkan/anv_intel.c b/src/vulkan/anv_intel.c index f64e2dcb1e4..48ac183ad79 100644 --- a/src/vulkan/anv_intel.c +++ b/src/vulkan/anv_intel.c @@ -68,8 +68,8 @@ VkResult anv_CreateDmaBufImageINTEL( anv_image_create(_device, &(struct anv_image_create_info) { - .force_tile_mode = true, - .tile_mode = XMAJOR, + .force_tiling = true, + .tiling = ISL_TILING_X, .stride = pCreateInfo->strideInBytes, .vk_info = &(VkImageCreateInfo) { diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 8269c7e8509..a6728392130 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1272,7 +1272,7 @@ struct anv_surface { uint8_t v_align; /**< RENDER_SURFACE_STATE.SurfaceVerticalAlignment */ /** \} */ - uint8_t tile_mode; /**< RENDER_SURFACE_STATE.TileMode */ + enum isl_tiling tiling; }; struct anv_image { @@ -1333,8 +1333,8 @@ struct anv_image_view { struct anv_image_create_info { const VkImageCreateInfo *vk_info; - bool force_tile_mode; - uint8_t tile_mode; + bool force_tiling; + enum isl_tiling tiling; uint32_t stride; }; diff --git a/src/vulkan/anv_wsi_wayland.c b/src/vulkan/anv_wsi_wayland.c index d3d73b8ae2d..f32fda20c09 100644 --- a/src/vulkan/anv_wsi_wayland.c +++ b/src/vulkan/anv_wsi_wayland.c @@ -547,8 +547,8 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image) VkImage vk_image; result = anv_image_create(vk_device, &(struct anv_image_create_info) { - .force_tile_mode = true, - .tile_mode = XMAJOR, + .force_tiling = true, + .tiling = ISL_TILING_X, .stride = 0, .vk_info = &(VkImageCreateInfo) { diff --git a/src/vulkan/anv_wsi_x11.c b/src/vulkan/anv_wsi_x11.c index 38a5e15d1a6..9a5e41d025a 100644 --- a/src/vulkan/anv_wsi_x11.c +++ b/src/vulkan/anv_wsi_x11.c @@ -299,8 +299,8 @@ x11_create_swapchain(struct anv_wsi_implementation *impl, anv_image_create(anv_device_to_handle(device), &(struct anv_image_create_info) { - .force_tile_mode = true, - .tile_mode = XMAJOR, + .force_tiling = true, + .tiling = ISL_TILING_X, .stride = 0, .vk_info = &(VkImageCreateInfo) { diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index 6f1cb8553e9..a53b6e3faf3 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -219,8 +219,9 @@ gen7_image_view_init(struct anv_image_view *iview, /* From bspec (DevSNB, DevIVB): "Set Tile Walk to TILEWALK_XMAJOR if * Tiled Surface is False." */ - .TiledSurface = surface->tile_mode > LINEAR, - .TileWalk = surface->tile_mode == YMAJOR ? TILEWALK_YMAJOR : TILEWALK_XMAJOR, + .TiledSurface = surface->tiling != ISL_TILING_LINEAR, + .TileWalk = surface->tiling == ISL_TILING_Y ? + TILEWALK_YMAJOR : TILEWALK_XMAJOR, .VerticalLineStride = 0, .VerticalLineStrideOffset = 0, diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index ce69377fd77..22fe21db1a8 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -162,13 +162,22 @@ gen8_image_view_init(struct anv_image_view *iview, [VK_CHANNEL_SWIZZLE_A] = SCS_ALPHA }; + static const uint8_t isl_to_gen_tiling[] = { + [ISL_TILING_LINEAR] = LINEAR, + [ISL_TILING_X] = XMAJOR, + [ISL_TILING_Y] = YMAJOR, + [ISL_TILING_Yf] = YMAJOR, + [ISL_TILING_Ys] = YMAJOR, + [ISL_TILING_W] = WMAJOR, + }; + struct GEN8_RENDER_SURFACE_STATE surface_state = { .SurfaceType = image->surface_type, .SurfaceArray = image->array_size > 1, .SurfaceFormat = format_info->surface_format, .SurfaceVerticalAlignment = anv_valign[surface->v_align], .SurfaceHorizontalAlignment = anv_halign[surface->h_align], - .TileMode = surface->tile_mode, + .TileMode = isl_to_gen_tiling[surface->tiling], .VerticalLineStride = 0, .VerticalLineStrideOffset = 0, .SamplerL2BypassModeDisable = true,