[Mesa-dev] [PATCH V2 16/22] i965: add support for multisample textures
Chris Forbes
chrisf at ijw.co.nz
Mon Feb 4 21:48:50 PST 2013
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 at ijw.co.nz>
---
src/mesa/drivers/dri/i965/brw_tex_layout.c | 1 +
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 ++
src/mesa/drivers/dri/intel/intel_fbo.c | 24 +++++++++++++++++++++---
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 24 +++++++++++++++++++++---
src/mesa/drivers/dri/intel/intel_tex.c | 9 +++++++++
src/mesa/drivers/dri/intel/intel_tex_image.c | 2 +-
6 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c
index 1428396..d28e5af 100644
--- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
+++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index f8251b2..46f0d2e 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -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:
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 4810809..4b45310 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -507,15 +507,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);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 3c4749f..e68285c 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -625,9 +625,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;
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
index a2a3693..1564f6c 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -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:
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index d227ee5..63a1be0 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -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 */);
}
--
1.8.1.2
More information about the mesa-dev
mailing list