From fa2c886863492cc3eeee6d2059ae24edc1cb2bff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 17 Sep 2011 14:50:48 -0600 Subject: [PATCH] intel: make intel_texture_image a subclass of swrast_texture_image We need to subclass swrast_texture_image because if we use swrast for fallback rendering, we'll need to have swrast_texture_image objects. --- src/mesa/drivers/dri/intel/intel_blit.c | 10 +-- src/mesa/drivers/dri/intel/intel_fbo.c | 20 ++--- .../drivers/dri/intel/intel_mipmap_tree.c | 2 +- src/mesa/drivers/dri/intel/intel_tex_copy.c | 14 ++-- src/mesa/drivers/dri/intel/intel_tex_image.c | 80 +++++++++---------- src/mesa/drivers/dri/intel/intel_tex_obj.h | 12 ++- .../drivers/dri/intel/intel_tex_subimage.c | 2 +- .../drivers/dri/intel/intel_tex_validate.c | 54 ++++++------- 8 files changed, 101 insertions(+), 93 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 45cfb62014e..5a866489b0b 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -534,19 +534,19 @@ intel_set_teximage_alpha_to_one(struct gl_context *ctx, struct intel_region *region = intel_image->mt->region; BATCH_LOCALS; - assert(intel_image->base.TexFormat == MESA_FORMAT_ARGB8888); + assert(intel_image->base.Base.TexFormat == MESA_FORMAT_ARGB8888); /* get dest x/y in destination texture */ intel_miptree_get_image_offset(intel_image->mt, - intel_image->base.Level, - intel_image->base.Face, + intel_image->base.Base.Level, + intel_image->base.Base.Face, 0, &image_x, &image_y); x1 = image_x; y1 = image_y; - x2 = image_x + intel_image->base.Width; - y2 = image_y + intel_image->base.Height; + x2 = image_x + intel_image->base.Base.Width; + y2 = image_y + intel_image->base.Base.Height; pitch = region->pitch; cpp = region->cpp; diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 6c55fdc61c0..418e426e42b 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -611,8 +611,8 @@ intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb, /* compute offset of the particular 2D image within the texture region */ intel_miptree_get_image_offset(intel_image->mt, - intel_image->base.Level, - intel_image->base.Face, + intel_image->base.Base.Level, + intel_image->base.Base.Face, zoffset, &dst_x, &dst_y); @@ -738,18 +738,18 @@ intel_render_texture(struct gl_context * ctx, struct intel_mipmap_tree *new_mt; new_mt = intel_miptree_create(intel, image->TexObject->Target, - intel_image->base.TexFormat, - intel_image->base.Level, - intel_image->base.Level, - intel_image->base.Width, - intel_image->base.Height, - intel_image->base.Depth, + intel_image->base.Base.TexFormat, + intel_image->base.Base.Level, + intel_image->base.Base.Level, + intel_image->base.Base.Width, + intel_image->base.Base.Height, + intel_image->base.Base.Depth, GL_TRUE); intel_miptree_image_copy(intel, new_mt, - intel_image->base.Face, - intel_image->base.Level, + intel_image->base.Base.Face, + intel_image->base.Base.Level, old_mt); intel_miptree_release(intel, &intel_image->mt); diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 7739fa4183f..b77c5d708f1 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -224,7 +224,7 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt, struct gl_texture_image *image) { struct intel_texture_image *intelImage = intel_texture_image(image); - GLuint level = intelImage->base.Level; + GLuint level = intelImage->base.Base.Level; /* Images with borders are never pulled into mipmap trees. */ if (image->Border) diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index a2ae2db165f..326f62f7567 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -71,7 +71,7 @@ intel_copy_texsubimage(struct intel_context *intel, { struct gl_context *ctx = &intel->ctx; struct intel_renderbuffer *irb; - const GLenum internalFormat = intelImage->base.InternalFormat; + const GLenum internalFormat = intelImage->base.Base.InternalFormat; bool copy_supported = false; bool copy_supported_with_alpha_override = false; @@ -85,17 +85,17 @@ intel_copy_texsubimage(struct intel_context *intel, return GL_FALSE; } - copy_supported = intelImage->base.TexFormat == irb->Base.Format; + copy_supported = intelImage->base.Base.TexFormat == irb->Base.Format; /* Converting ARGB8888 to XRGB8888 is trivial: ignore the alpha bits */ if (irb->Base.Format == MESA_FORMAT_ARGB8888 && - intelImage->base.TexFormat == MESA_FORMAT_XRGB8888) { + intelImage->base.Base.TexFormat == MESA_FORMAT_XRGB8888) { copy_supported = true; } /* Converting XRGB8888 to ARGB8888 requires setting the alpha bits to 1.0 */ if (irb->Base.Format == MESA_FORMAT_XRGB8888 && - intelImage->base.TexFormat == MESA_FORMAT_ARGB8888) { + intelImage->base.Base.TexFormat == MESA_FORMAT_ARGB8888) { copy_supported_with_alpha_override = true; } @@ -103,7 +103,7 @@ intel_copy_texsubimage(struct intel_context *intel, if (unlikely(INTEL_DEBUG & DEBUG_FALLBACKS)) fprintf(stderr, "%s mismatched formats %s, %s\n", __FUNCTION__, - _mesa_get_format_name(intelImage->base.TexFormat), + _mesa_get_format_name(intelImage->base.Base.TexFormat), _mesa_get_format_name(irb->Base.Format)); return GL_FALSE; } @@ -117,8 +117,8 @@ intel_copy_texsubimage(struct intel_context *intel, /* get dest x/y in destination texture */ intel_miptree_get_image_offset(intelImage->mt, - intelImage->base.Level, - intelImage->base.Face, + intelImage->base.Base.Level, + intelImage->base.Base.Face, 0, &image_x, &image_y); diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 2ef5d5562af..fd719e43048 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -53,40 +53,40 @@ intel_miptree_create_for_teximage(struct intel_context *intel, { GLuint firstLevel; GLuint lastLevel; - GLuint width = intelImage->base.Width; - GLuint height = intelImage->base.Height; - GLuint depth = intelImage->base.Depth; + GLuint width = intelImage->base.Base.Width; + GLuint height = intelImage->base.Base.Height; + GLuint depth = intelImage->base.Base.Depth; GLuint i; DBG("%s\n", __FUNCTION__); - if (intelImage->base.Border) + if (intelImage->base.Base.Border) return NULL; - if (intelImage->base.Level > intelObj->base.BaseLevel && - (intelImage->base.Width == 1 || + if (intelImage->base.Base.Level > intelObj->base.BaseLevel && + (intelImage->base.Base.Width == 1 || (intelObj->base.Target != GL_TEXTURE_1D && - intelImage->base.Height == 1) || + intelImage->base.Base.Height == 1) || (intelObj->base.Target == GL_TEXTURE_3D && - intelImage->base.Depth == 1))) { + intelImage->base.Base.Depth == 1))) { /* For this combination, we're at some lower mipmap level and * some important dimension is 1. We can't extrapolate up to a * likely base level width/height/depth for a full mipmap stack * from this info, so just allocate this one level. */ - firstLevel = intelImage->base.Level; - lastLevel = intelImage->base.Level; + firstLevel = intelImage->base.Base.Level; + lastLevel = intelImage->base.Base.Level; } else { /* If this image disrespects BaseLevel, allocate from level zero. * Usually BaseLevel == 0, so it's unlikely to happen. */ - if (intelImage->base.Level < intelObj->base.BaseLevel) + if (intelImage->base.Base.Level < intelObj->base.BaseLevel) firstLevel = 0; else firstLevel = intelObj->base.BaseLevel; /* Figure out image dimensions at start level. */ - for (i = intelImage->base.Level; i > firstLevel; i--) { + for (i = intelImage->base.Base.Level; i > firstLevel; i--) { width <<= 1; if (height != 1) height <<= 1; @@ -101,7 +101,7 @@ intel_miptree_create_for_teximage(struct intel_context *intel, */ if ((intelObj->base.Sampler.MinFilter == GL_NEAREST || intelObj->base.Sampler.MinFilter == GL_LINEAR) && - intelImage->base.Level == firstLevel && + intelImage->base.Base.Level == firstLevel && (intel->gen < 4 || firstLevel == 0)) { lastLevel = firstLevel; } else { @@ -111,7 +111,7 @@ intel_miptree_create_for_teximage(struct intel_context *intel, return intel_miptree_create(intel, intelObj->base.Target, - intelImage->base.TexFormat, + intelImage->base.Base.TexFormat, firstLevel, lastLevel, width, @@ -184,8 +184,8 @@ try_pbo_upload(struct intel_context *intel, else src_stride = width; - intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Level, - intelImage->base.Face, 0, + intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level, + intelImage->base.Base.Face, 0, &dst_x, &dst_y); dst_stride = intelImage->mt->region->pitch; @@ -239,8 +239,8 @@ try_pbo_zcopy(struct intel_context *intel, else src_stride = width; - intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Level, - intelImage->base.Face, 0, + intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level, + intelImage->base.Base.Face, 0, &dst_x, &dst_y); dst_stride = intelImage->mt->region->pitch; @@ -271,8 +271,8 @@ intel_tex_image_s8z24_scattergather(struct intel_context *intel, struct gl_renderbuffer *depth_rb = intel_image->depth_rb; struct gl_renderbuffer *stencil_rb = intel_image->stencil_rb; - int w = intel_image->base.Width; - int h = intel_image->base.Height; + int w = intel_image->base.Base.Width; + int h = intel_image->base.Base.Height; uint32_t depth_row[w]; uint8_t stencil_row[w]; @@ -333,15 +333,15 @@ intel_tex_image_s8z24_create_renderbuffers(struct intel_context *intel, struct gl_context *ctx = &intel->ctx; bool ok = true; - int width = image->base.Width; - int height = image->base.Height; + int width = image->base.Base.Width; + int height = image->base.Base.Height; struct gl_renderbuffer *drb; struct gl_renderbuffer *srb; struct intel_renderbuffer *idrb; struct intel_renderbuffer *isrb; assert(intel->has_separate_stencil); - assert(image->base.TexFormat == MESA_FORMAT_S8_Z24); + assert(image->base.Base.TexFormat == MESA_FORMAT_S8_Z24); assert(image->mt != NULL); drb = intel_create_wrapped_renderbuffer(ctx, width, height, @@ -418,11 +418,11 @@ intelTexImage(struct gl_context * ctx, assert(!intelImage->mt); if (intelObj->mt && - intel_miptree_match_image(intelObj->mt, &intelImage->base)) { + intel_miptree_match_image(intelObj->mt, &intelImage->base.Base)) { /* Use an existing miptree when possible */ intel_miptree_reference(&intelImage->mt, intelObj->mt); assert(intelImage->mt); - } else if (intelImage->base.Border == 0) { + } else if (intelImage->base.Base.Border == 0) { /* Didn't fit in the object miptree, but it's suitable for inclusion in * a miptree, so create one just for our level and store it in the image. * It'll get moved into the object miptree at validate time. @@ -448,7 +448,7 @@ intelTexImage(struct gl_context * ctx, intelImage->mt && _mesa_is_bufferobj(unpack->BufferObj) && check_pbo_format(internalFormat, format, - type, intelImage->base.TexFormat)) { + type, intelImage->base.Base.TexFormat)) { DBG("trying pbo upload\n"); @@ -502,10 +502,10 @@ intelTexImage(struct gl_context * ctx, } texImage->Data = intel_miptree_image_map(intel, intelImage->mt, - intelImage->base.Face, - intelImage->base.Level, + intelImage->base.Base.Face, + intelImage->base.Base.Level, &dstRowStride, - intelImage->base.ImageOffsets); + intelImage->base.Base.ImageOffsets); } texImage->RowStride = dstRowStride / intelImage->mt->cpp; @@ -669,25 +669,25 @@ intel_get_tex_image(struct gl_context * ctx, GLenum target, GLint level, /* Image is stored in hardware format in a buffer managed by the * kernel. Need to explicitly map and unmap it. */ - intelImage->base.Data = + intelImage->base.Base.Data = intel_miptree_image_map(intel, intelImage->mt, - intelImage->base.Face, - intelImage->base.Level, - &intelImage->base.RowStride, - intelImage->base.ImageOffsets); - intelImage->base.RowStride /= intelImage->mt->cpp; + intelImage->base.Base.Face, + intelImage->base.Base.Level, + &intelImage->base.Base.RowStride, + intelImage->base.Base.ImageOffsets); + intelImage->base.Base.RowStride /= intelImage->mt->cpp; } else { /* Otherwise, the image should actually be stored in - * intelImage->base.Data. This is pretty confusing for + * intelImage->base.Base.Data. This is pretty confusing for * everybody, I'd much prefer to separate the two functions of * texImage->Data - storage for texture images in main memory * and access (ie mappings) of images. In other words, we'd * create a new texImage->Map field and leave Data simply for * storage. */ - assert(intelImage->base.Data); + assert(intelImage->base.Base.Data); } if (intelImage->stencil_rb) { @@ -712,7 +712,7 @@ intel_get_tex_image(struct gl_context * ctx, GLenum target, GLint level, /* Unmap */ if (intelImage->mt) { intel_miptree_image_unmap(intel, intelImage->mt); - intelImage->base.Data = NULL; + intelImage->base.Base.Data = NULL; } } @@ -806,7 +806,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, texImage->RowStride = rb->region->pitch; intel_miptree_reference(&intelImage->mt, intelObj->mt); - if (!intel_miptree_match_image(intelObj->mt, &intelImage->base)) { + if (!intel_miptree_match_image(intelObj->mt, &intelImage->base.Base)) { fprintf(stderr, "miptree doesn't match image\n"); } @@ -862,7 +862,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target, texImage->RowStride = image->region->pitch; intel_miptree_reference(&intelImage->mt, intelObj->mt); - if (!intel_miptree_match_image(intelObj->mt, &intelImage->base)) + if (!intel_miptree_match_image(intelObj->mt, &intelImage->base.Base)) fprintf(stderr, "miptree doesn't match image\n"); } #endif diff --git a/src/mesa/drivers/dri/intel/intel_tex_obj.h b/src/mesa/drivers/dri/intel/intel_tex_obj.h index e7a4318b8d8..8457879a3d8 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_obj.h +++ b/src/mesa/drivers/dri/intel/intel_tex_obj.h @@ -28,9 +28,12 @@ #ifndef _INTEL_TEX_OBJ_H #define _INTEL_TEX_OBJ_H +#include "swrast/s_context.h" + + struct intel_texture_object { - struct gl_texture_object base; /* The "parent" object */ + struct gl_texture_object base; /* This is a mirror of base._MaxLevel, updated at validate time, * except that we don't bother with the non-base levels for @@ -48,9 +51,14 @@ struct intel_texture_object struct intel_mipmap_tree *mt; }; + +/** + * intel_texture_image is a subclass of swrast_texture_image because we + * sometimes fall back to using the swrast module for software rendering. + */ struct intel_texture_image { - struct gl_texture_image base; + struct swrast_texture_image base; /* If intelImage->mt != NULL, image data is stored here. * Else if intelImage->base.Data != NULL, image is stored there. diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c index 1492740c273..0da348c8fb8 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c @@ -116,7 +116,7 @@ intel_blit_texsubimage(struct gl_context * ctx, dstRowStride = pitch; intel_miptree_get_image_offset(intelImage->mt, level, - intelImage->base.Face, 0, + intelImage->base.Base.Face, 0, &blit_x, &blit_y); blit_x += xoffset; blit_y += yoffset; diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index f47f12ae58a..59f39def204 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -41,26 +41,26 @@ copy_image_data_to_tree(struct intel_context *intel, */ intel_miptree_image_copy(intel, intelObj->mt, - intelImage->base.Face, - intelImage->base.Level, intelImage->mt); + intelImage->base.Base.Face, + intelImage->base.Base.Level, intelImage->mt); intel_miptree_release(intel, &intelImage->mt); } else { - assert(intelImage->base.Data != NULL); + assert(intelImage->base.Base.Data != NULL); /* More straightforward upload. */ intel_miptree_image_data(intel, intelObj->mt, - intelImage->base.Face, - intelImage->base.Level, - intelImage->base.Data, - intelImage->base.RowStride, - intelImage->base.RowStride * - intelImage->base.Height); - _mesa_align_free(intelImage->base.Data); - intelImage->base.Data = NULL; + intelImage->base.Base.Face, + intelImage->base.Base.Level, + intelImage->base.Base.Data, + intelImage->base.Base.RowStride, + intelImage->base.Base.RowStride * + intelImage->base.Base.Height); + _mesa_align_free(intelImage->base.Base.Data); + intelImage->base.Base.Data = NULL; } intel_miptree_reference(&intelImage->mt, intelObj->mt); @@ -91,7 +91,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) /* Fallback case: */ - if (firstImage->base.Border) { + if (firstImage->base.Base.Border) { if (intelObj->mt) { intel_miptree_release(intel, &intelObj->mt); } @@ -108,12 +108,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) */ if (intelObj->mt && (intelObj->mt->target != intelObj->base.Target || - intelObj->mt->format != firstImage->base.TexFormat || + intelObj->mt->format != firstImage->base.Base.TexFormat || intelObj->mt->first_level != tObj->BaseLevel || intelObj->mt->last_level < intelObj->_MaxLevel || - intelObj->mt->width0 != firstImage->base.Width || - intelObj->mt->height0 != firstImage->base.Height || - intelObj->mt->depth0 != firstImage->base.Depth)) { + intelObj->mt->width0 != firstImage->base.Base.Width || + intelObj->mt->height0 != firstImage->base.Base.Height || + intelObj->mt->depth0 != firstImage->base.Base.Depth)) { intel_miptree_release(intel, &intelObj->mt); } @@ -123,12 +123,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) if (!intelObj->mt) { intelObj->mt = intel_miptree_create(intel, intelObj->base.Target, - firstImage->base.TexFormat, + firstImage->base.Base.TexFormat, tObj->BaseLevel, intelObj->_MaxLevel, - firstImage->base.Width, - firstImage->base.Height, - firstImage->base.Depth, + firstImage->base.Base.Width, + firstImage->base.Base.Height, + firstImage->base.Base.Depth, GL_TRUE); if (!intelObj->mt) return GL_FALSE; @@ -173,15 +173,15 @@ intel_tex_map_level_images(struct intel_context *intel, intel_texture_image(intelObj->base.Image[face][level]); if (intelImage && intelImage->mt) { - intelImage->base.Data = + intelImage->base.Base.Data = intel_miptree_image_map(intel, intelImage->mt, - intelImage->base.Face, - intelImage->base.Level, - &intelImage->base.RowStride, - intelImage->base.ImageOffsets); + intelImage->base.Base.Face, + intelImage->base.Base.Level, + &intelImage->base.Base.RowStride, + intelImage->base.Base.ImageOffsets); /* convert stride to texels, not bytes */ - intelImage->base.RowStride /= intelImage->mt->cpp; + intelImage->base.Base.RowStride /= intelImage->mt->cpp; /* intelImage->base.ImageStride /= intelImage->mt->cpp; */ } } @@ -201,7 +201,7 @@ intel_tex_unmap_level_images(struct intel_context *intel, if (intelImage && intelImage->mt) { intel_miptree_image_unmap(intel, intelImage->mt); - intelImage->base.Data = NULL; + intelImage->base.Base.Data = NULL; } } } -- 2.30.2