summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/meta.c14
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c19
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_texture.c5
-rw-r--r--src/mesa/drivers/dri/r200/r200_texstate.c20
-rw-r--r--src/mesa/drivers/dri/r300/r300_texstate.c19
-rw-r--r--src/mesa/drivers/dri/r600/evergreen_tex.c18
-rw-r--r--src/mesa/drivers/dri/r600/r600_texstate.c18
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texstate.c18
-rw-r--r--src/mesa/drivers/dri/swrast/swrast.c11
-rw-r--r--src/mesa/main/mipmap.c4
-rw-r--r--src/mesa/main/texfetch.c12
-rw-r--r--src/mesa/main/teximage.c237
-rw-r--r--src/mesa/main/teximage.h7
-rw-r--r--src/mesa/main/texobj.c8
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c8
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c12
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c5
-rw-r--r--src/mesa/state_tracker/st_manager.c12
18 files changed, 261 insertions, 186 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 4533d82743..ba8be12571 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2593,7 +2593,6 @@ copy_tex_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
{
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
- GLsizei postConvWidth = width, postConvHeight = height;
GLenum format, type;
GLint bpp;
void *buf;
@@ -2601,6 +2600,7 @@ copy_tex_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
texObj = _mesa_get_current_tex_object(ctx, target);
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
+ /* Choose format/type for temporary image buffer */
format = _mesa_base_tex_format(ctx, internalFormat);
type = get_temp_image_type(ctx, format);
bpp = _mesa_bytes_per_pixel(format, type);
@@ -2632,12 +2632,8 @@ copy_tex_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
ctx->Driver.FreeTexImageData(ctx, texImage);
}
- _mesa_init_teximage_fields(ctx, target, texImage,
- postConvWidth, postConvHeight, 1,
- border, internalFormat);
-
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ /* The texture's format was already chosen in _mesa_CopyTexImage() */
+ ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
/*
* Store texture data (with pixel transfer ops)
@@ -2690,7 +2686,8 @@ _mesa_meta_CopyTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
* Have to be careful with locking and meta state for pixel transfer.
*/
static void
-copy_tex_sub_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
+copy_tex_sub_image(struct gl_context *ctx,
+ GLuint dims, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint x, GLint y,
GLsizei width, GLsizei height)
@@ -2704,6 +2701,7 @@ copy_tex_sub_image(struct gl_context *ctx, GLuint dims, GLenum target, GLint lev
texObj = _mesa_get_current_tex_object(ctx, target);
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ /* Choose format/type for temporary image buffer */
format = _mesa_get_format_base_format(texImage->TexFormat);
type = get_temp_image_type(ctx, format);
bpp = _mesa_bytes_per_pixel(format, type);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 50fe9bd9f3..41cdbfd2cb 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -682,6 +682,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
int level = 0, internalFormat;
+ gl_format texFormat;
texObj = _mesa_get_current_tex_object(ctx, target);
intelObj = intel_texture_object(texObj);
@@ -700,10 +701,14 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
if (rb->region == NULL)
return;
- if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
+ if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
internalFormat = GL_RGB;
- else
+ texFormat = MESA_FORMAT_XRGB8888;
+ }
+ else {
internalFormat = GL_RGBA;
+ texFormat = MESA_FORMAT_ARGB8888;
+ }
mt = intel_miptree_create_for_region(intel, target,
internalFormat,
@@ -724,16 +729,13 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
intel_miptree_release(intel, &intelObj->mt);
intelObj->mt = mt;
+
_mesa_init_teximage_fields(&intel->ctx, target, texImage,
rb->region->width, rb->region->height, 1,
- 0, internalFormat);
+ 0, internalFormat, texFormat);
intelImage->face = target_to_face(target);
intelImage->level = level;
- if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
- texImage->TexFormat = MESA_FORMAT_XRGB8888;
- else
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
texImage->RowStride = rb->region->pitch;
intel_miptree_reference(&intelImage->mt, intelObj->mt);
@@ -789,11 +791,10 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
intelObj->mt = mt;
_mesa_init_teximage_fields(&intel->ctx, target, texImage,
image->region->width, image->region->height, 1,
- 0, image->internal_format);
+ 0, image->internal_format, image->format);
intelImage->face = target_to_face(target);
intelImage->level = 0;
- texImage->TexFormat = image->format;
texImage->RowStride = image->region->pitch;
intel_miptree_reference(&intelImage->mt, intelObj->mt);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 060c2c5bcc..2480b1ea50 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -603,11 +603,12 @@ nouveau_set_texbuffer(__DRIcontext *dri_ctx,
nouveau_update_renderbuffers(dri_ctx, draw);
nouveau_surface_ref(&to_nouveau_renderbuffer(rb)->surface, s);
+ s->format = get_texbuffer_format(rb, format);
+
/* Update the image fields. */
_mesa_init_teximage_fields(ctx, target, ti, s->width, s->height,
- 1, 0, s->cpp);
+ 1, 0, s->cpp, s->format);
ti->RowStride = s->pitch / s->cpp;
- ti->TexFormat = s->format = get_texbuffer_format(rb, format);
/* Try to validate it. */
if (!validate_teximage(ctx, t, 0, 0, 0, 0, s->width, s->height, 1))
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index ee968d69f6..24fb031ecb 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -778,6 +778,7 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
radeonTexObjPtr t;
uint32_t pitch_val;
uint32_t internalFormat, type, format;
+ gl_format texFormat;
type = GL_BGRA;
format = GL_UNSIGNED_BYTE;
@@ -817,10 +818,6 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
radeon_miptree_unreference(&t->mt);
radeon_miptree_unreference(&rImage->mt);
- _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
- rb->base.Width, rb->base.Height, 1, 0, rb->cpp);
- texImage->RowStride = rb->pitch / rb->cpp;
-
rImage->bo = rb->bo;
radeon_bo_ref(rImage->bo);
t->bo = rb->bo;
@@ -833,27 +830,34 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
switch (rb->cpp) {
case 4:
if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
t->pp_txformat = tx_table_le[MESA_FORMAT_RGB888].format;
}
else {
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_ARGB8888;
t->pp_txformat = tx_table_le[MESA_FORMAT_ARGB8888].format;
}
t->pp_txfilter |= tx_table_le[MESA_FORMAT_ARGB8888].filter;
break;
case 3:
default:
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
t->pp_txformat = tx_table_le[MESA_FORMAT_RGB888].format;
t->pp_txfilter |= tx_table_le[MESA_FORMAT_RGB888].filter;
break;
case 2:
- texImage->TexFormat = MESA_FORMAT_RGB565;
+ texFormat = MESA_FORMAT_RGB565;
t->pp_txformat = tx_table_le[MESA_FORMAT_RGB565].format;
t->pp_txfilter |= tx_table_le[MESA_FORMAT_RGB565].filter;
break;
}
+
+ _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+ rb->base.Width, rb->base.Height, 1, 0,
+ rb->cpp, texFormat);
+ texImage->RowStride = rb->pitch / rb->cpp;
+
+
t->pp_txsize = ((rb->base.Width - 1) << RADEON_TEX_USIZE_SHIFT)
| ((rb->base.Height - 1) << RADEON_TEX_VSIZE_SHIFT);
t->pp_txformat |= R200_TXFORMAT_NON_POWER2;
diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c
index a4fbd99308..ed9955b05d 100644
--- a/src/mesa/drivers/dri/r300/r300_texstate.c
+++ b/src/mesa/drivers/dri/r300/r300_texstate.c
@@ -428,6 +428,7 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
radeonTexObjPtr t;
uint32_t pitch_val;
uint32_t internalFormat, type, format;
+ gl_format texFormat;
type = GL_BGRA;
format = GL_UNSIGNED_BYTE;
@@ -467,9 +468,6 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
radeon_miptree_unreference(&t->mt);
radeon_miptree_unreference(&rImage->mt);
- _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
- rb->base.Width, rb->base.Height, 1, 0, rb->cpp);
- texImage->RowStride = rb->pitch / rb->cpp;
rImage->bo = rb->bo;
radeon_bo_ref(rImage->bo);
t->bo = rb->bo;
@@ -482,27 +480,34 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
switch (rb->cpp) {
case 4:
if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
}
else {
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_ARGB8888;
t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
}
pitch_val /= 4;
break;
case 3:
default:
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
pitch_val /= 4;
break;
case 2:
- texImage->TexFormat = MESA_FORMAT_RGB565;
+ texFormat = MESA_FORMAT_RGB565;
t->pp_txformat = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
pitch_val /= 2;
break;
}
+
+ _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+ rb->base.Width, rb->base.Height, 1, 0,
+ rb->cpp, texFormat);
+ texImage->RowStride = rb->pitch / rb->cpp;
+
+
pitch_val--;
t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT)))
| ((R300_TX_HEIGHTMASK_MASK & ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT))));
diff --git a/src/mesa/drivers/dri/r600/evergreen_tex.c b/src/mesa/drivers/dri/r600/evergreen_tex.c
index d4c2cb9686..40a465b878 100644
--- a/src/mesa/drivers/dri/r600/evergreen_tex.c
+++ b/src/mesa/drivers/dri/r600/evergreen_tex.c
@@ -1152,6 +1152,7 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
radeonTexObjPtr t;
uint32_t pitch_val;
uint32_t internalFormat, type, format;
+ gl_format texFormat;
type = GL_BGRA;
format = GL_UNSIGNED_BYTE;
@@ -1191,10 +1192,6 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
radeon_miptree_unreference(&t->mt);
radeon_miptree_unreference(&rImage->mt);
- _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
- rb->base.Width, rb->base.Height, 1, 0, rb->cpp);
- texImage->RowStride = rb->pitch / rb->cpp;
-
rImage->bo = rb->bo;
radeon_bo_ref(rImage->bo);
t->bo = rb->bo;
@@ -1205,7 +1202,7 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
switch (rb->cpp) {
case 4:
if (glx_texture_format == __DRI_TEXTURE_FORMAT_RGB) {
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
SETfield(t->SQ_TEX_RESOURCE7, FMT_8_8_8_8,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_shift,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_mask);
@@ -1219,7 +1216,7 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
} else {
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_ARGB8888;
SETfield(t->SQ_TEX_RESOURCE7, FMT_8_8_8_8,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_shift,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_mask);
@@ -1238,7 +1235,7 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
case 3:
default:
// FMT_8_8_8 ???
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
SETfield(t->SQ_TEX_RESOURCE7, FMT_8_8_8_8,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_shift,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_mask);
@@ -1254,7 +1251,7 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
pitch_val /= 4;
break;
case 2:
- texImage->TexFormat = MESA_FORMAT_RGB565;
+ texFormat = MESA_FORMAT_RGB565;
SETfield(t->SQ_TEX_RESOURCE7, FMT_5_6_5,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_shift,
EG_SQ_TEX_RESOURCE_WORD7_0__DATA_FORMAT_mask);
@@ -1271,6 +1268,11 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur
break;
}
+ _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+ rb->base.Width, rb->base.Height, 1, 0,
+ rb->cpp, texFormat);
+ texImage->RowStride = rb->pitch / rb->cpp;
+
pitch_val = (pitch_val + R700_TEXEL_PITCH_ALIGNMENT_MASK)
& ~R700_TEXEL_PITCH_ALIGNMENT_MASK;
diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c
index 20fe32ae9e..aafa687577 100644
--- a/src/mesa/drivers/dri/r600/r600_texstate.c
+++ b/src/mesa/drivers/dri/r600/r600_texstate.c
@@ -1001,6 +1001,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
radeonTexObjPtr t;
uint32_t pitch_val;
uint32_t internalFormat, type, format;
+ gl_format texFormat;
type = GL_BGRA;
format = GL_UNSIGNED_BYTE;
@@ -1046,10 +1047,6 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
radeon_miptree_unreference(&t->mt);
radeon_miptree_unreference(&rImage->mt);
- _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
- rb->base.Width, rb->base.Height, 1, 0, rb->cpp);
- texImage->RowStride = rb->pitch / rb->cpp;
-
rImage->bo = rb->bo;
radeon_bo_ref(rImage->bo);
t->bo = rb->bo;
@@ -1060,7 +1057,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
switch (rb->cpp) {
case 4:
if (glx_texture_format == __DRI_TEXTURE_FORMAT_RGB) {
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
@@ -1073,7 +1070,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1,
SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask);
} else {
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_ARGB8888;
SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
@@ -1091,7 +1088,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
case 3:
default:
// FMT_8_8_8 ???
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8,
SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
@@ -1106,7 +1103,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
pitch_val /= 4;
break;
case 2:
- texImage->TexFormat = MESA_FORMAT_RGB565;
+ texFormat = MESA_FORMAT_RGB565;
SETfield(t->SQ_TEX_RESOURCE1, FMT_5_6_5,
SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask);
@@ -1122,6 +1119,11 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
break;
}
+ _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+ rb->base.Width, rb->base.Height, 1, 0,
+ rb->cpp, texFormat);
+ texImage->RowStride = rb->pitch / rb->cpp;
+
pitch_val = (pitch_val + R700_TEXEL_PITCH_ALIGNMENT_MASK)
& ~R700_TEXEL_PITCH_ALIGNMENT_MASK;
diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c
index 7409aeeeaa..32c021cb54 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texstate.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c
@@ -653,6 +653,7 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form
radeonTexObjPtr t;
uint32_t pitch_val;
uint32_t internalFormat, type, format;
+ gl_format texFormat;
type = GL_BGRA;
format = GL_UNSIGNED_BYTE;
@@ -692,10 +693,6 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form
radeon_miptree_unreference(&t->mt);
radeon_miptree_unreference(&rImage->mt);
- _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
- rb->base.Width, rb->base.Height, 1, 0, rb->cpp);
- texImage->RowStride = rb->pitch / rb->cpp;
-
rImage->bo = rb->bo;
radeon_bo_ref(rImage->bo);
t->bo = rb->bo;
@@ -707,27 +704,32 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form
case 4:
if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
}
else {
t->pp_txformat = tx_table[MESA_FORMAT_ARGB8888].format;
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_ARGB8888;
}
t->pp_txfilter |= tx_table[MESA_FORMAT_ARGB8888].filter;
break;
case 3:
default:
- texImage->TexFormat = MESA_FORMAT_RGB888;
+ texFormat = MESA_FORMAT_RGB888;
t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
t->pp_txfilter |= tx_table[MESA_FORMAT_RGB888].filter;
break;
case 2:
- texImage->TexFormat = MESA_FORMAT_RGB565;
+ texFormat = MESA_FORMAT_RGB565;
t->pp_txformat = tx_table[MESA_FORMAT_RGB565].format;
t->pp_txfilter |= tx_table[MESA_FORMAT_RGB565].filter;
break;
}
+ _mesa_init_teximage_fields(radeon->glCtx, target, texImage,
+ rb->base.Width, rb->base.Height, 1, 0,
+ rb->cpp, texFormat);
+ texImage->RowStride = rb->pitch / rb->cpp;
+
t->pp_txpitch &= (1 << 13) -1;
pitch_val = rb->pitch;
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index 52ba3acf65..c7aaafcee8 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -69,6 +69,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
uint32_t internalFormat;
+ gl_format texFormat;
dri_ctx = pDRICtx->driverPrivate;
@@ -82,15 +83,13 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
sPriv->swrast_loader->getDrawableInfo(dPriv, &x, &y, &w, &h, dPriv->loaderPrivate);
- _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage,
- w, h, 1, 0, internalFormat);
-
if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
- texImage->TexFormat = MESA_FORMAT_XRGB8888;
+ texFormat = MESA_FORMAT_XRGB8888;
else
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_ARGB8888;
- _mesa_set_fetch_functions(texImage, 2);
+ _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage,
+ w, h, 1, 0, internalFormat, texFormat);
sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)texImage->Data,
dPriv->loaderPrivate);
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index b1989b4b91..ad63b178df 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1790,9 +1790,9 @@ _mesa_generate_mipmap(struct gl_context *ctx, GLenum target,
/* initialize new image */
_mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
- dstDepth, border, srcImage->InternalFormat);
+ dstDepth, border, srcImage->InternalFormat,
+ srcImage->TexFormat);
dstImage->DriverData = NULL;
- dstImage->TexFormat = srcImage->TexFormat;
dstImage->FetchTexelc = srcImage->FetchTexelc;
dstImage->FetchTexelf = srcImage->FetchTexelf;
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
index aa3a6961b6..372ef2654a 100644
--- a/src/mesa/main/texfetch.c
+++ b/src/mesa/main/texfetch.c
@@ -823,17 +823,11 @@ void
_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
{
ASSERT(dims == 1 || dims == 2 || dims == 3);
- ASSERT(texImage->TexFormat);
- if (!texImage->FetchTexelf) {
- texImage->FetchTexelf =
- _mesa_get_texel_fetch_func(texImage->TexFormat, dims);
- }
+ texImage->FetchTexelf =
+ _mesa_get_texel_fetch_func(texImage->TexFormat, dims);
- /* now check if we need to use a float/chan adaptor */
- if (!texImage->FetchTexelc) {
- texImage->FetchTexelc = fetch_texel_float_to_chan;
- }
+ texImage->FetchTexelc = fetch_texel_float_to_chan;
ASSERT(texImage->FetchTexelc);
ASSERT(texImage->FetchTexelf);
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e196e700f7..b3ce5d95b7 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -887,6 +887,45 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target)
}
+/**
+ * Return number of dimenions per image for the given texture target.
+ */
+static GLint
+get_texture_dimensions(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D_ARRAY:
+ return 1;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D_ARRAY:
+ case GL_PROXY_TEXTURE_RECTANGLE:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ return 2;
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ return 3;
+ default:
+ _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()",
+ target);
+ return 2;
+ }
+}
+
+
+
#if 000 /* not used anymore */
/*
@@ -992,6 +1031,7 @@ clear_teximage_fields(struct gl_texture_image *img)
* \param depth image depth.
* \param border image border.
* \param internalFormat internal format.
+ * \param format the actual hardware format (one of MESA_FORMAT_*)
*
* Fills in the fields of \p img with the given information.
* Note: width, height and depth include the border.
@@ -1000,9 +1040,10 @@ void
_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum internalFormat)
+ GLint border, GLenum internalFormat,
+ gl_format format)
{
- GLint i;
+ GLint i, dims;
ASSERT(img);
ASSERT(width >= 0);
@@ -1073,8 +1114,11 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
img->DepthScale = (GLfloat) img->Depth;
}
- img->FetchTexelc = NULL;
- img->FetchTexelf = NULL;
+ img->TexFormat = format;
+
+ dims = get_texture_dimensions(target);
+
+ _mesa_set_fetch_functions(img, dims);
}
@@ -2262,13 +2306,14 @@ override_internal_format(GLenum internalFormat, GLint width, GLint height)
* for efficient texture memory layout/allocation. In particular, this
* comes up during automatic mipmap generation.
*/
-void
+gl_format
_mesa_choose_texture_format(struct gl_context *ctx,
struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
GLenum target, GLint level,
GLenum internalFormat, GLenum format, GLenum type)
{
+ gl_format f;
+
/* see if we've already chosen a format for the previous level */
if (level > 0) {
struct gl_texture_image *prevImage =
@@ -2280,16 +2325,15 @@ _mesa_choose_texture_format(struct gl_context *ctx,
prevImage->Width > 0 &&
prevImage->InternalFormat == internalFormat) {
/* use the same format */
- texImage->TexFormat = prevImage->TexFormat;
- ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
- return;
+ ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE);
+ return prevImage->TexFormat;
}
}
/* choose format from scratch */
- texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
- format, type);
- ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
+ f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
+ ASSERT(f != MESA_FORMAT_NONE);
+ return f;
}
@@ -2336,19 +2380,22 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- clear_teximage_fields(texImage); /* not really needed, but helpful */
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, format,
+ type);
+
_mesa_init_teximage_fields(ctx, target, texImage,
width, 1, 1,
- border, internalFormat);
-
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ border, internalFormat,
+ texFormat);
/* Give the texture to the driver. <pixels> may be null. */
ASSERT(ctx->Driver.TexImage1D);
@@ -2356,8 +2403,6 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
width, border, format, type, pixels,
&ctx->Unpack, texObj, texImage);
- _mesa_set_fetch_functions(texImage, 1);
-
check_gen_mipmap(ctx, target, texObj, level);
update_fbo_texture(ctx, texObj, face, level);
@@ -2383,12 +2428,12 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
/* no error, set the tex image parameters */
struct gl_texture_object *texObj =
_mesa_get_current_tex_object(ctx, target);
- ASSERT(texImage);
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, 1, 1,
- border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, target,
+ level,
+ internalFormat,
+ format, type);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
+ border, internalFormat, texFormat);
}
}
else {
@@ -2445,18 +2490,20 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, height, 1,
- border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, format,
+ type);
+
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat, texFormat);
/* Give the texture to the driver. <pixels> may be null. */
ASSERT(ctx->Driver.TexImage2D);
@@ -2464,8 +2511,6 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
width, height, border, format, type,
pixels, &ctx->Unpack, texObj, texImage);
- _mesa_set_fetch_functions(texImage, 2);
-
check_gen_mipmap(ctx, target, texObj, level);
update_fbo_texture(ctx, texObj, face, level);
@@ -2497,11 +2542,12 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
/* no error, set the tex image parameters */
struct gl_texture_object *texObj =
_mesa_get_current_tex_object(ctx, target);
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, height, 1,
- border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ gl_format texFormat = _mesa_choose_texture_format(ctx, texObj,
+ target, level,
+ internalFormat,
+ format, type);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat, texFormat);
}
}
else {
@@ -2557,18 +2603,19 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- clear_teximage_fields(texImage); /* not really needed, but helpful */
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, format,
+ type);
_mesa_init_teximage_fields(ctx, target, texImage,
width, height, depth,
- border, internalFormat);
-
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ border, internalFormat, texFormat);
/* Give the texture to the driver. <pixels> may be null. */
ASSERT(ctx->Driver.TexImage3D);
@@ -2576,8 +2623,6 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
width, height, depth, border, format, type,
pixels, &ctx->Unpack, texObj, texImage);
- _mesa_set_fetch_functions(texImage, 3);
-
check_gen_mipmap(ctx, target, texObj, level);
update_fbo_texture(ctx, texObj, face, level);
@@ -2605,10 +2650,12 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
/* no error, set the tex image parameters */
struct gl_texture_object *texObj =
_mesa_get_current_tex_object(ctx, target);
+ gl_format texFormat = _mesa_choose_texture_format(ctx, texObj,
+ target, level,
+ internalFormat,
+ format, type);
_mesa_init_teximage_fields(ctx, target, texImage, width, height,
- depth, border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ depth, border, internalFormat, texFormat);
}
}
else {
@@ -2885,25 +2932,25 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
- border, internalFormat);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
+ border, internalFormat, texFormat);
ASSERT(ctx->Driver.CopyTexImage1D);
ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat,
x, y, width, border);
- _mesa_set_fetch_functions(texImage, 1);
-
check_gen_mipmap(ctx, target, texObj, level);
update_fbo_texture(ctx, texObj, face, level);
@@ -2952,26 +2999,25 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, height, 1,
- border, internalFormat);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat, texFormat);
ASSERT(ctx->Driver.CopyTexImage2D);
ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat,
x, y, width, height, border);
- _mesa_set_fetch_functions(texImage, 2);
-
check_gen_mipmap(ctx, target, texObj, level);
update_fbo_texture(ctx, texObj, face, level);
@@ -3453,16 +3499,19 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
- border, internalFormat);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
+ border, internalFormat, texFormat);
ASSERT(ctx->Driver.CompressedTexImage1D);
ctx->Driver.CompressedTexImage1D(ctx, target, level,
@@ -3470,8 +3519,6 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
imageSize, data,
texObj, texImage);
- _mesa_set_fetch_functions(texImage, 1);
-
check_gen_mipmap(ctx, target, texObj, level);
/* state update */
@@ -3502,16 +3549,18 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
/* store the teximage parameters */
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ gl_format texFormat;
texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
_mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
- border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ border, internalFormat, texFormat);
}
_mesa_unlock_texture(ctx, texObj);
}
@@ -3579,16 +3628,19 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
- _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
- border, internalFormat);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat, texFormat);
ASSERT(ctx->Driver.CompressedTexImage2D);
ctx->Driver.CompressedTexImage2D(ctx, target, level,
@@ -3596,8 +3648,6 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
border, imageSize, data,
texObj, texImage);
- _mesa_set_fetch_functions(texImage, 2);
-
check_gen_mipmap(ctx, target, texObj, level);
/* state update */
@@ -3630,16 +3680,18 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
/* store the teximage parameters */
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ gl_format texFormat;
texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
_mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
- border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ border, internalFormat, texFormat);
}
_mesa_unlock_texture(ctx, texObj);
}
@@ -3686,18 +3738,20 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3D");
}
else {
+ gl_format texFormat;
+
if (texImage->Data) {
ctx->Driver.FreeTexImageData( ctx, texImage );
}
ASSERT(texImage->Data == NULL);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
+
_mesa_init_teximage_fields(ctx, target, texImage,
width, height, depth,
- border, internalFormat);
-
- /* Choose actual texture format */
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ border, internalFormat, texFormat);
ASSERT(ctx->Driver.CompressedTexImage3D);
ctx->Driver.CompressedTexImage3D(ctx, target, level,
@@ -3706,8 +3760,6 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
border, imageSize, data,
texObj, texImage);
- _mesa_set_fetch_functions(texImage, 3);
-
check_gen_mipmap(ctx, target, texObj, level);
/* state update */
@@ -3738,16 +3790,19 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
/* store the teximage parameters */
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ gl_format texFormat;
texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, GL_NONE,
+ GL_NONE);
_mesa_init_teximage_fields(ctx, target, texImage, width, height,
- depth, border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, GL_NONE, GL_NONE);
+ depth, border, internalFormat,
+ texFormat);
}
_mesa_unlock_texture(ctx, texObj);
}
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index d4317c301b..5bb9d492e9 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -33,6 +33,7 @@
#include "mtypes.h"
+#include "formats.h"
extern void *
@@ -69,13 +70,13 @@ extern void
_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum internalFormat);
+ GLint border, GLenum internalFormat,
+ gl_format format);
-extern void
+extern gl_format
_mesa_choose_texture_format(struct gl_context *ctx,
struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
GLenum target, GLint level,
GLenum internalFormat, GLenum format, GLenum type);
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 495903df55..72dbf10cc4 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -719,6 +719,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx)
static GLubyte texels[8 * 8][4];
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ gl_format texFormat;
GLuint i;
for (i = 0; i < 8 * 8; i++) {
@@ -737,12 +738,13 @@ _mesa_get_fallback_texture(struct gl_context *ctx)
/* create level[0] texture image */
texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0);
+ texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+
/* init the image fields */
_mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage,
- 8, 8, 1, 0, GL_RGBA);
+ 8, 8, 1, 0, GL_RGBA, texFormat);
- texImage->TexFormat =
- ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
/* set image data */
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index b39a624a61..c4b84de790 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -106,6 +106,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target,
struct st_texture_object *stObj;
struct st_texture_image *stImage;
GLenum internalFormat;
+ gl_format texFormat;
/* map pipe format to base format */
if (util_format_get_component_bits(ps->format, UTIL_FORMAT_COLORSPACE_RGB, 3) > 0)
@@ -122,10 +123,11 @@ st_bind_surface(struct gl_context *ctx, GLenum target,
stObj->surface_based = GL_TRUE;
}
+ texFormat = st_pipe_format_to_mesa_format(ps->format);
+
_mesa_init_teximage_fields(ctx, target, texImage,
- ps->width, ps->height, 1, 0, internalFormat);
- texImage->TexFormat = st_pipe_format_to_mesa_format(ps->format);
- _mesa_set_fetch_functions(texImage, 2);
+ ps->width, ps->height, 1, 0, internalFormat,
+ texFormat);
/* FIXME create a non-default sampler view from the pipe_surface? */
pipe_resource_reference(&stObj->pt, ps->texture);
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 4c2f7d7896..15e69e1fa0 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -549,14 +549,18 @@ st_TexImage(struct gl_context * ctx,
/* switch to "normal" */
if (stObj->surface_based) {
+ gl_format texFormat;
+
_mesa_clear_texture_object(ctx, texObj);
pipe_resource_reference(&stObj->pt, NULL);
/* oops, need to init this image again */
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
+ internalFormat, format, type);
+
_mesa_init_teximage_fields(ctx, target, texImage,
- width, height, depth, border, internalFormat);
- _mesa_choose_texture_format(ctx, texObj, texImage, target, level,
- internalFormat, format, type);
+ width, height, depth, border,
+ internalFormat, texFormat);
stObj->surface_based = GL_FALSE;
}
@@ -1950,7 +1954,7 @@ st_get_default_texture(struct st_context *st)
_mesa_init_teximage_fields(st->ctx, target, texImg,
16, 16, 1, 0, /* w, h, d, border */
- GL_RGBA);
+ GL_RGBA, MESA_FORMAT_RGBA8888);
st_TexImage(st->ctx, 2, target,
0, GL_RGBA, /* level, intformat */
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index fe31418ddd..a4011b22b9 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -400,9 +400,8 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
/* initialize new image */
_mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
- dstDepth, border, srcImage->InternalFormat);
-
- dstImage->TexFormat = srcImage->TexFormat;
+ dstDepth, border, srcImage->InternalFormat,
+ srcImage->TexFormat);
stImage = st_texture_image(dstImage);
stImage->level = dstLevel;
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 15e7b8921c..98e95e239e 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -556,6 +556,8 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
stImage = st_texture_image(texImage);
if (tex) {
+ gl_format texFormat;
+
/*
* XXX When internal_format and tex->format differ, st_finalize_texture
* needs to allocate a new texture with internal_format and copy the
@@ -573,11 +575,13 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
internalFormat = GL_RGBA;
else
internalFormat = GL_RGB;
+
+ texFormat = st_ChooseTextureFormat(ctx, internalFormat,
+ GL_RGBA, GL_UNSIGNED_BYTE);
+
_mesa_init_teximage_fields(ctx, target, texImage,
- tex->width0, tex->height0, 1, 0, internalFormat);
- texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
- GL_RGBA, GL_UNSIGNED_BYTE);
- _mesa_set_fetch_functions(texImage, 2);
+ tex->width0, tex->height0, 1, 0,
+ internalFormat, texFormat);
width = tex->width0;
height = tex->height0;