[Mesa-dev] [PATCH 02/13] meta: Obvious refactor of _mesa_meta_framebuffer_texture_image
Brian Paul
brianp at vmware.com
Thu Feb 11 14:45:01 UTC 2016
On 02/10/2016 11:13 PM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/mesa/drivers/common/meta.c | 26 +++++---------------------
> 1 file changed, 5 insertions(+), 21 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index 9391ac8..b62f0d4 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -112,28 +112,12 @@ _mesa_meta_framebuffer_texture_image(struct gl_context *ctx,
> {
> struct gl_texture_object *texObj = texImage->TexObject;
> int level = texImage->Level;
> - GLenum texTarget = texObj->Target;
> + const GLenum texTarget = texObj->Target == GL_TEXTURE_CUBE_MAP
> + ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face
> + : texObj->Target;
This pattern appears in quite a few places in Mesa. I'm thinking we
should add a new helper function like this in texobj.h:
/**
* If the target is GL_TEXTURE_CUBE_MAP, return one of the
* GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z targets corresponding to
* the face parameter.
* Else, return target as-is.
*/
static inline GLenum
_mesa_cube_face_target(GLenum target, unsigned face)
{
assert(face < 6);
if (target == GL_TEXTURE_CUBE_MAP)
return GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
else
return target;
}
I can do that as a follow-on clean-up.
-Brian
>
> - switch (texTarget) {
> - case GL_TEXTURE_1D:
> - _mesa_framebuffer_texture(ctx, fb, attachment, texObj, texTarget,
> - level, layer, false, __func__);
> - break;
> - case GL_TEXTURE_1D_ARRAY:
> - case GL_TEXTURE_2D_ARRAY:
> - case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> - case GL_TEXTURE_CUBE_MAP_ARRAY:
> - case GL_TEXTURE_3D:
> - _mesa_framebuffer_texture(ctx, fb, attachment, texObj, texTarget,
> - level, layer, false, __func__);
> - break;
> - default: /* 2D / cube */
> - if (texTarget == GL_TEXTURE_CUBE_MAP)
> - texTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face;
> -
> - _mesa_framebuffer_texture(ctx, fb, attachment, texObj, texTarget,
> - level, layer, false, __func__);
> - }
> + _mesa_framebuffer_texture(ctx, fb, attachment, texObj, texTarget,
> + level, layer, false, __func__);
> }
>
> GLuint
>
More information about the mesa-dev
mailing list