*/
#include "main/arrayobj.h"
+#include "main/blend.h"
#include "main/buffers.h"
#include "main/enums.h"
#include "main/enable.h"
_mesa_meta_blit_shader_table_cleanup(ctx, &mipmap->shaders);
}
-static GLboolean
-prepare_mipmap_level(struct gl_context *ctx,
- struct gl_texture_object *texObj, GLuint level,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum intFormat, mesa_format format)
-{
- if (texObj->Target == GL_TEXTURE_1D_ARRAY) {
- /* Work around Mesa expecting the number of array slices in "height". */
- height = depth;
- depth = 1;
- }
-
- return _mesa_prepare_mipmap_level(ctx, texObj, level, width, height, depth,
- 0, intFormat, format);
-}
/**
* Called via ctx->Driver.GenerateMipmap()
}
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS);
+ _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
/* Choose between glsl version and fixed function version of
* GenerateMipmap function.
GL_LINEAR);
_mesa_set_sampler_wrap(ctx, mipmap->samp_obj, GL_CLAMP_TO_EDGE,
GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
+ }
+
+ if (ctx->Extensions.EXT_texture_sRGB_decode) {
+ const struct gl_texture_image *baseImage =
+ _mesa_select_tex_image(texObj, target, texObj->BaseLevel);
+ const bool srgb =
+ _mesa_get_format_color_encoding(baseImage->TexFormat) == GL_SRGB;
- /* We don't want to encode or decode sRGB values; treat them as linear. */
- _mesa_set_sampler_srgb_decode(ctx, mipmap->samp_obj, GL_SKIP_DECODE_EXT);
+ _mesa_set_sampler_srgb_decode(ctx, mipmap->samp_obj,
+ srgb ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
+ _mesa_set_framebuffer_srgb(ctx, srgb);
}
_mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, mipmap->samp_obj);
/* texture is already locked, unlock now */
_mesa_unlock_texture(ctx, texObj);
+ _mesa_prepare_mipmap_levels(ctx, texObj, baseLevel, maxLevel);
+
for (dstLevel = baseLevel + 1; dstLevel <= maxLevel; dstLevel++) {
const struct gl_texture_image *srcImage;
struct gl_texture_image *dstImage;
_mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
(GLint *) &dstLevel, false);
- if (!prepare_mipmap_level(ctx, texObj, dstLevel,
- dstWidth, dstHeight, dstDepth,
- srcImage->InternalFormat,
- srcImage->TexFormat)) {
- /* All done. We either ran out of memory or we would go beyond the
- * last valid level of an immutable texture if we continued.
- */
- break;
- }
dstImage = _mesa_select_tex_image(texObj, faceTarget, dstLevel);
+ /* All done. We either ran out of memory or we would go beyond the last
+ * valid level of an immutable texture if we continued.
+ */
+ if (dstImage == NULL)
+ break;
+
/* limit minification to src level */
_mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
(GLint *) &srcLevel, false);