i965: Prepare image validation for isl based miptrees
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Tue, 25 Apr 2017 06:56:33 +0000 (09:56 +0300)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Mon, 19 Jun 2017 19:41:45 +0000 (22:41 +0300)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/intel_mipmap_tree.c

index 0fdf7117af884371f6fb55c5947aef3b7a194e99..d589a59104210c2208385ab6bed1f42d26c20ab5 100644 (file)
@@ -1090,6 +1090,21 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
    if (mt->target == GL_TEXTURE_CUBE_MAP)
       depth = 6;
 
+   if (mt->surf.size > 0) {
+      if (level >= mt->surf.levels)
+         return false;
+
+      const unsigned level_depth =
+         mt->surf.dim == ISL_SURF_DIM_3D ?
+            minify(mt->surf.logical_level0_px.depth, level) :
+            mt->surf.logical_level0_px.array_len;
+
+      return width == minify(mt->surf.logical_level0_px.width, level) &&
+             height == minify(mt->surf.logical_level0_px.height, level) &&
+             depth == level_depth &&
+             MAX2(image->NumSamples, 1) == mt->surf.samples;
+   }
+
    int level_depth = mt->level[level].depth;
    if (mt->num_samples > 1) {
       switch (mt->msaa_layout) {