[Mesa-dev] [PATCH 04/17] swrast: Clean up and explain the mapping process.

Brian Paul brianp at vmware.com
Tue Apr 30 07:07:26 PDT 2013


On 04/22/2013 10:14 AM, Eric Anholt wrote:
> ---
>   src/mesa/swrast/s_texture.c |   17 ++++++++---------
>   1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
> index 36a90dd..b6dd8cb 100644
> --- a/src/mesa/swrast/s_texture.c
> +++ b/src/mesa/swrast/s_texture.c
> @@ -218,18 +218,17 @@ _swrast_map_teximage(struct gl_context *ctx,
>      map = swImage->Buffer;
>
>      assert(slice<  texture_slices(texImage));
> +   if (slice != 0) {
> +      int sliceHeight = texImage->Height;
> +      /* For 1D array textures, the slices are all 1 pixel high, and Height is
> +       * the number of slices.
> +       */
> +      if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY)
> +         sliceHeight = 1;

Maybe move this logic into a slice_height() helper function as you did 
for texture_slices().


>
> -   if (texImage->TexObject->Target == GL_TEXTURE_3D ||
> -       texImage->TexObject->Target == GL_TEXTURE_2D_ARRAY) {
>         GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat,
>                                                    texImage->Width,
> -                                                 texImage->Height,
> -                                                 1);
> -      map += slice * sliceSize;
> -   } else if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
> -      GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat,
> -                                                 texImage->Width,
> -                                                 1,
> +                                                 sliceHeight,
>                                                    1);
>         map += slice * sliceSize;
>      }



More information about the mesa-dev mailing list