[Mesa-dev] [PATCH 11/41] intel: Kill intel_mipmap_level::nr_images
Eric Anholt
eric at anholt.net
Fri Nov 18 12:22:37 PST 2011
On Thu, 17 Nov 2011 19:58:38 -0800, Chad Versace <chad.versace at linux.intel.com> wrote:
> For all texture targets except GL_TEXTURE_CUBE_MAP, the 'nr_images' and
> 'depth' fields of intel_mipmap_level were identical. In the exceptional
> case, nr_images == 6 and depth == 1.
>
> It is simple to determine if a texture is a cube or not, so the presence
> of two fields here was not helpful. Worse, it was confusing. When we
> eventually implement GL_ARB_texture_cube_map_array, this mess would have
> become even more confusing.
>
> This patch removes 'nr_images' and assigns to 'depth' a consistent
> meaning: depth is the number of 2D slices at each miplevel. The exact
> semantics of depth varies according to the texture target:
> - For GL_TEXTURE_CUBE_MAP, depth is 6.
> - For GL_TEXTURE_2D_ARRAY, depth is the number of array slices. It is
> identical for all miplevels in the texture.
> - For GL_TEXTURE_3D, it is the texture's depth at each miplevel. It's
> value, like width and height, varies with miplevel.
"Its"
> diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
> index 9398dbd..8c41956 100644
> --- a/src/mesa/drivers/dri/intel/intel_fbo.c
> +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
> @@ -947,8 +947,9 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx,
>
> static bool
> intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,
> - struct gl_texture_image *texImage)
> + struct gl_renderbuffer_attachment *att)
> {
> + struct gl_texture_image *texImage = _mesa_get_attachment_teximage(att);
> struct intel_texture_image *intel_image = intel_texture_image(texImage);
> int width, height, depth;
>
> @@ -993,7 +994,8 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,
> * This will have the region info needed for hardware rendering.
> */
> static struct intel_renderbuffer *
> -intel_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage)
> +intel_wrap_texture(struct gl_context * ctx,
> + struct gl_renderbuffer_attachment *att)
> {
> const GLuint name = ~0; /* not significant, but distinct for debugging */
> struct intel_renderbuffer *irb;
> @@ -1008,7 +1010,7 @@ intel_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage)
> _mesa_init_renderbuffer(&irb->Base, name);
> irb->Base.ClassID = INTEL_RB_CLASS;
>
> - if (!intel_update_wrapper(ctx, irb, texImage)) {
> + if (!intel_update_wrapper(ctx, irb, att)) {
> free(irb);
> return NULL;
> }
> @@ -1113,7 +1115,7 @@ intel_render_texture(struct gl_context * ctx,
> return;
> }
> else if (!irb) {
> - irb = intel_wrap_texture(ctx, image);
> + irb = intel_wrap_texture(ctx, att);
> if (irb) {
> /* bind the wrapper to the attachment point */
> _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base);
> @@ -1125,7 +1127,7 @@ intel_render_texture(struct gl_context * ctx,
> }
> }
>
> - if (!intel_update_wrapper(ctx, irb, image)) {
> + if (!intel_update_wrapper(ctx, irb, att)) {
> _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
> _swrast_render_texture(ctx, fb, att);
> return;
The changes in this file don't seem to fit in this patch.
> - /** Depth of the mipmap at this level: 1 for 1D/2D/CUBE, n for 3D. */
> +
> + /**
> + * \brief Number of 2D slices in this miplevel.
> + *
> + * The exact semantics of depth varies according to the texture target:
> + * - For GL_TEXTURE_CUBE_MAP, depth is 6.
> + * - For GL_TEXTURE_2D_ARRAY, depth is the number of array slices. It is
> + * identical for all miplevels in the texture.
> + * - For GL_TEXTURE_3D, it is the texture's depth at this miplevel. It's
> + * value, like width and height, varies with miplevel.
"Its"
> diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
> index f4c1a68..8dad011 100644
> --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
> +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
> @@ -140,12 +140,13 @@ intel_tex_map_image_for_swrast(struct intel_context *intel,
> if (mt->target == GL_TEXTURE_3D ||
> mt->target == GL_TEXTURE_2D_ARRAY ||
> mt->target == GL_TEXTURE_1D_ARRAY) {
> - int i;
>
> /* ImageOffsets[] is only used for swrast's fetch_texel_3d, so we can't
> * share code with the normal path.
> */
> - for (i = 0; i < mt->level[level].depth; i++) {
> + assert(face == 0);
> + int depth = mt->level[level].depth;
> + for (int i = 0; i < depth; i++) {
> intel_miptree_get_image_offset(mt, level, face, i, &x, &y);
> intel_image->base.ImageOffsets[i] = x + y * mt->region->pitch;
> }
Not really seeing the point of this hunk (pulling depth out of the loop)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111118/104c5420/attachment-0001.pgp>
More information about the mesa-dev
mailing list