vk/image: Add anv_image::h_align,v_align
authorChad Versace <chad.versace@intel.com>
Tue, 9 Jun 2015 19:11:46 +0000 (12:11 -0700)
committerChad Versace <chad.versace@intel.com>
Tue, 9 Jun 2015 19:19:24 +0000 (12:19 -0700)
Use the new fields to compute RENDER_SURFACE_STATE.Surface*Alignment.
We still hardcode them to 4, though.

src/vulkan/image.c
src/vulkan/private.h

index a7d1d49114d0df445ca96d82712b4244c3fd80b2..529f7ad977499b0dc45f954134e413c073130d63 100644 (file)
 
 // 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,
index 82dd5738316aa863a17105e836af9be44b05162c..794449c27c66a77c2f580f06297e7058bf8c9e08 100644 (file)
@@ -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 {