summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-03-06 01:56:53 -0800
committerKenneth Graunke <[email protected]>2014-03-07 22:45:25 -0800
commit14ca611258d8737cb79f9f5f2e0aaf58d80a1b1c (patch)
treeef219c80843cc95113f40f48a0090fa3e8be5f54
parent158a7440c37c27783e2968408c74c03858520ec2 (diff)
meta: Support GenerateMipmaps on 1DArray textures.
I don't know how many people care about this case, but it's easy enough to do, so we may as well. The tricky part is that for some reason Mesa stores the number of array slices in Height, not Depth. I thought the easiest way to handle that here was to make Height = 1 (the actual height), and srcDepth = srcImage->Height. This requires some munging when calling _mesa_prepare_mipmap_level, so I created a wrapper that sorts it out for us. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r--src/mesa/drivers/common/meta_generate_mipmap.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index 9d352e9fe2a..3db073ab16e 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -94,7 +94,7 @@ fallback_required(struct gl_context *ctx, GLenum target,
GLenum status;
/* check for fallbacks */
- if (target == GL_TEXTURE_3D || target == GL_TEXTURE_1D_ARRAY) {
+ if (target == GL_TEXTURE_3D) {
_mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH,
"glGenerateMipmap() to %s target\n",
_mesa_lookup_enum_by_nr(target));
@@ -163,6 +163,22 @@ _mesa_meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap)
_mesa_meta_blit_shader_table_cleanup(&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()
* Note: We don't yet support 3D textures, 1D/2D array textures or texture
@@ -276,8 +292,13 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
/* src size */
srcWidth = srcImage->Width;
- srcHeight = srcImage->Height;
- srcDepth = srcImage->Depth;
+ if (target == GL_TEXTURE_1D_ARRAY) {
+ srcHeight = 1;
+ srcDepth = srcImage->Height;
+ } else {
+ srcHeight = srcImage->Height;
+ srcDepth = srcImage->Depth;
+ }
/* new dst size */
dstWidth = minify(srcWidth, 1);
@@ -296,11 +317,10 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
/* Set MaxLevel large enough to hold the new level when we allocate it */
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel);
- if (!_mesa_prepare_mipmap_level(ctx, texObj, dstLevel,
- dstWidth, dstHeight, dstDepth,
- srcImage->Border,
- srcImage->InternalFormat,
- srcImage->TexFormat)) {
+ 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.
*/
@@ -339,7 +359,11 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
}
assert(dstWidth == ctx->DrawBuffer->Width);
- assert(dstHeight == ctx->DrawBuffer->Height);
+ if (target == GL_TEXTURE_1D_ARRAY) {
+ assert(dstHeight == 1);
+ } else {
+ assert(dstHeight == ctx->DrawBuffer->Height);
+ }
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
}