From: Chad Versace Date: Tue, 9 Jun 2015 19:11:46 +0000 (-0700) Subject: vk/image: Add anv_image::h_align,v_align X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6162c2feff6dee48cd5c1e99e2fe70b5ce07f9f;p=mesa.git vk/image: Add anv_image::h_align,v_align Use the new fields to compute RENDER_SURFACE_STATE.Surface*Alignment. We still hardcode them to 4, though. --- diff --git a/src/vulkan/image.c b/src/vulkan/image.c index a7d1d49114d..529f7ad9774 100644 --- a/src/vulkan/image.c +++ b/src/vulkan/image.c @@ -31,6 +31,18 @@ // Image functions +static const uint8_t anv_halign[] = { + [4] = HALIGN4, + [8] = HALIGN8, + [16] = HALIGN16, +}; + +static const uint8_t anv_valign[] = { + [4] = VALIGN4, + [8] = VALIGN8, + [16] = VALIGN16, +}; + static const struct anv_tile_mode_info { int32_t tile_width; int32_t tile_height; @@ -86,6 +98,10 @@ VkResult anv_image_create( if (extra) image->tile_mode = extra->tile_mode; + /* FINISHME: Stop hardcoding miptree image alignment */ + image->h_align = 4; + image->v_align = 4; + if (image->tile_mode == LINEAR) { /* Linear depth buffers must be 64 byte aligned, which is the strictest * requirement for all kinds of linear surfaces. @@ -192,8 +208,8 @@ anv_image_view_init(struct anv_surface_view *view, .SurfaceType = SURFTYPE_2D, .SurfaceArray = false, .SurfaceFormat = format, - .SurfaceVerticalAlignment = VALIGN4, - .SurfaceHorizontalAlignment = HALIGN4, + .SurfaceVerticalAlignment = anv_valign[image->v_align], + .SurfaceHorizontalAlignment = anv_halign[image->h_align], .TileMode = tile_mode, .VerticalLineStride = 0, .VerticalLineStrideOffset = 0, @@ -283,8 +299,8 @@ anv_color_attachment_view_init(struct anv_surface_view *view, .SurfaceType = SURFTYPE_2D, .SurfaceArray = false, .SurfaceFormat = format->format, - .SurfaceVerticalAlignment = VALIGN4, - .SurfaceHorizontalAlignment = HALIGN4, + .SurfaceVerticalAlignment = anv_valign[image->v_align], + .SurfaceHorizontalAlignment = anv_halign[image->h_align], .TileMode = image->tile_mode, .VerticalLineStride = 0, .VerticalLineStrideOffset = 0, diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 82dd5738316..794449c27c6 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -738,6 +738,21 @@ struct anv_image { VkDeviceSize offset; struct anv_swap_chain * swap_chain; + + /** + * \name Alignment of miptree images, in units of pixels. + * + * These fields contain the actual alignment values, not the values the + * hardware expects. For example, if h_align is 4, then program the hardware + * with HALIGN_4. + * + * \see RENDER_SURFACE_STATE.SurfaceHorizontalAlignment + * \see RENDER_SURFACE_STATE.SurfaceVerticalAlignment + * \{ + */ + uint8_t h_align; + uint8_t v_align; + /** \} */ }; struct anv_surface_view {