i965: add support for multisample textures
authorChris Forbes <chrisf@ijw.co.nz>
Sun, 16 Dec 2012 06:50:26 +0000 (19:50 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Fri, 1 Mar 2013 22:35:24 +0000 (11:35 +1300)
V2: - Fix for state moving from texobj to image
    - Rebased onto Paul's logical/physical cleanup
    - Fixed missing quantization of sample count
    - Fold in IMS renderbuffer wrapper fixes from later in the series
    - Use correct physical slice offset for UMS/CMS surfaces on Gen7

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_tex.c
src/mesa/drivers/dri/intel/intel_tex_image.c

index 1428396c9072a2e040d5853fcda7d2639d9919fe..d28e5aff009f4f0d8c396548df027018d88412f7 100644 (file)
@@ -168,6 +168,7 @@ brw_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree *mt)
 
    case GL_TEXTURE_2D_ARRAY:
    case GL_TEXTURE_1D_ARRAY:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
       brw_miptree_layout_texture_array(intel, mt);
       break;
 
index 587ad0530813ecb4cc358b72242a677b4bb07d06..267d00b60eee7203c0eb0acc911246ff529d39c7 100644 (file)
@@ -60,6 +60,8 @@ translate_tex_target(GLenum target)
    case GL_TEXTURE_2D: 
    case GL_TEXTURE_2D_ARRAY_EXT:
    case GL_TEXTURE_EXTERNAL_OES:
+   case GL_TEXTURE_2D_MULTISAMPLE:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
       return BRW_SURFACE_2D;
 
    case GL_TEXTURE_3D: 
index 9a9bb9f3abc05f2f5212b164eff57095f593fe75..7186978b4a0c6eca08c46f58e75ca9fba276628d 100644 (file)
@@ -499,15 +499,33 @@ intel_renderbuffer_update_wrapper(struct intel_context *intel,
    rb->Format = image->TexFormat;
    rb->InternalFormat = image->InternalFormat;
    rb->_BaseFormat = image->_BaseFormat;
-   rb->Width = mt->level[level].width;
-   rb->Height = mt->level[level].height;
+   rb->NumSamples = mt->num_samples;
+
+   if (mt->msaa_layout != INTEL_MSAA_LAYOUT_NONE) {
+      assert(level == 0);
+      rb->Width = mt->logical_width0;
+      rb->Height = mt->logical_height0;
+   }
+   else {
+      rb->Width = mt->level[level].width;
+      rb->Height = mt->level[level].height;
+   }
 
    rb->Delete = intel_delete_renderbuffer;
    rb->AllocStorage = intel_nop_alloc_storage;
 
    intel_miptree_check_level_layer(mt, level, layer);
    irb->mt_level = level;
-   irb->mt_layer = layer;
+
+   switch (mt->msaa_layout) {
+      case INTEL_MSAA_LAYOUT_UMS:
+      case INTEL_MSAA_LAYOUT_CMS:
+         irb->mt_layer = layer * mt->num_samples;
+         break;
+
+      default:
+         irb->mt_layer = layer;
+   }
 
    intel_miptree_reference(&irb->mt, mt);
 
index ee058a1029e6ef59c3250e0f1843fb5700b4ae6e..749508f8ae8489ee02fe5634b33ae57961857c2f 100644 (file)
@@ -624,9 +624,27 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
     * minification.  This will also catch images not present in the
     * tree, changed targets, etc.
     */
-   if (width != mt->level[level].width ||
-       height != mt->level[level].height ||
-       depth != mt->level[level].depth)
+   if (mt->target == GL_TEXTURE_2D_MULTISAMPLE ||
+         mt->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
+      /* nonzero level here is always bogus */
+      assert(level == 0);
+
+      if (width != mt->logical_width0 ||
+            height != mt->logical_height0 ||
+            depth != mt->logical_depth0) {
+         return false;
+      }
+   }
+   else {
+      /* all normal textures, renderbuffers, etc */
+      if (width != mt->level[level].width ||
+          height != mt->level[level].height ||
+          depth != mt->level[level].depth) {
+         return false;
+      }
+   }
+
+   if (image->NumSamples != mt->num_samples)
       return false;
 
    return true;
index a2a3693749029e6a912f4ec803ceda1d21c7eb23..1564f6cd97e02c2d60cb03de90664722d21233af 100644 (file)
@@ -7,6 +7,7 @@
 #include "intel_context.h"
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
+#include "intel_fbo.h"
 
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
@@ -63,6 +64,13 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
 
    assert(image->Border == 0);
 
+   /* Quantize sample count */
+   if (image->NumSamples) {
+      image->NumSamples = intel_quantize_num_samples(intel->intelScreen, image->NumSamples);
+      if (!image->NumSamples)
+         return false;
+   }
+
    /* Because the driver uses AllocTextureImageBuffer() internally, it may end
     * up mismatched with FreeTextureImageBuffer(), but that is safe to call
     * multiple times.
@@ -73,6 +81,7 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
    switch (texobj->Target) {
    case GL_TEXTURE_3D:
    case GL_TEXTURE_2D_ARRAY:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
       slices = image->Depth;
       break;
    case GL_TEXTURE_1D_ARRAY:
index d227ee5a8c60d99aeb50e398a5a274bd01499ffe..63a1be03775e14004b56d589afa922ad3a8a0535 100644 (file)
@@ -104,7 +104,7 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
                               height,
                               depth,
                               expect_accelerated_upload,
-                               0 /* num_samples */,
+                               intelImage->base.Base.NumSamples,
                                false /* force_y_tiling */);
 }