gallium/util: Add u_bit_scan_consecutive_range64.
[mesa.git] / src / intel / isl / isl_surface_state.c
index 1607aa6233d035c82759da58cc3a318f474deffd..cac59fab78e2b1b1dab2b441f976a7fcf3a1b0d4 100644 (file)
@@ -257,11 +257,10 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
       .SurfaceQPitch = get_qpitch(info->surf) >> 2,
 #endif
 
-      .Width = info->level0_extent_px.width - 1,
-      .Height = info->level0_extent_px.height - 1,
+      .Width = info->surf->logical_level0_px.width - 1,
+      .Height = info->surf->logical_level0_px.height - 1,
       .Depth = 0, /* TEMPLATE */
 
-      .SurfacePitch = info->surf->row_pitch - 1,
       .RenderTargetViewExtent = 0, /* TEMPLATE */
       .MinimumArrayElement = 0, /* TEMPLATE */
 
@@ -295,6 +294,19 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
 #endif
    };
 
+   if (info->surf->tiling == ISL_TILING_W) {
+      /* From the Broadwell PRM documentation for this field:
+       *
+       *    "If the surface is a stencil buffer (and thus has Tile Mode set
+       *    to TILEMODE_WMAJOR), the pitch must be set to 2x the value
+       *    computed based on width, as the stencil buffer is stored with
+       *    two rows interleaved."
+       */
+      s.SurfacePitch = info->surf->row_pitch * 2 - 1;
+   } else {
+      s.SurfacePitch = info->surf->row_pitch - 1;
+   }
+
    if (info->view->usage & ISL_SURF_USAGE_STORAGE_BIT) {
       s.SurfaceFormat = isl_lower_storage_image_format(dev, info->view->format);
    } else {
@@ -338,7 +350,7 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
        *    If the volume texture is MIP-mapped, this field specifies the
        *    depth of the base MIP level.
        */
-      s.Depth = info->level0_extent_px.depth - 1;
+      s.Depth = info->surf->logical_level0_px.depth - 1;
 
       /* From the Broadwell PRM >> RENDER_SURFACE_STATE::RenderTargetViewExtent:
        *
@@ -346,7 +358,8 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
        *    indicates the extent of the accessible 'R' coordinates minus 1 on
        *    the LOD currently being rendered to.
        */
-      s.RenderTargetViewExtent = info->level0_extent_px.depth - 1;
+      s.RenderTargetViewExtent = isl_minify(info->surf->logical_level0_px.depth,
+                                            info->view->base_level) - 1;
       break;
    default:
       unreachable(!"bad SurfaceType");
@@ -392,9 +405,11 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
    }
 #endif
 
-#if 0
-   if (GEN_GEN == 8) {
-      if (isl_format_is_integer(info->view->format)) {
+   if (GEN_GEN <= 8) {
+      /* Prior to Sky Lake, we only have one bit for the clear color which
+       * gives us 0 or 1 in whatever the surface's format happens to be.
+       */
+      if (isl_format_has_int_channel(info->view->format)) {
          for (unsigned i = 0; i < 4; i++) {
             assert(info->clear_color.u32[i] == 0 ||
                    info->clear_color.u32[i] == 1);
@@ -405,17 +420,16 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
                    info->clear_color.f32[i] == 1.0f);
          }
       }
-      s.RedClearColor = info->clear_color.u32[0] != 0,
-      s.GreenClearColor = info->clear_color.u32[1] != 0,
-      s.BlueClearColor = info->clear_color.u32[2] != 0,
-      s.AlphaClearColor = info->clear_color.u32[3] != 0,
+      s.RedClearColor = info->clear_color.u32[0] != 0;
+      s.GreenClearColor = info->clear_color.u32[1] != 0;
+      s.BlueClearColor = info->clear_color.u32[2] != 0;
+      s.AlphaClearColor = info->clear_color.u32[3] != 0;
    } else {
-      .RedClearColor = info->clear_color.u32[0],
-      .GreenClearColor = info->clear_color.u32[1],
-      .BlueClearColor = info->clear_color.u32[2],
-      .AlphaClearColor = info->clear_color.u32[3],
+      s.RedClearColor = info->clear_color.u32[0];
+      s.GreenClearColor = info->clear_color.u32[1];
+      s.BlueClearColor = info->clear_color.u32[2];
+      s.AlphaClearColor = info->clear_color.u32[3];
    }
-#endif
 
    GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &s);
 }