diff options
author | Marek Olšák <[email protected]> | 2014-03-16 03:45:27 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2014-04-10 20:50:16 +0200 |
commit | 38858207a11819a3c68f14b589c0779fb82152ff (patch) | |
tree | b67aba5d2ccef8c3173d81b88ef04531c54ba71d /src/mesa | |
parent | 26c41398cc47c0f72259a34406831443238b7ba9 (diff) |
gallium/u_gen_mipmap: rewrite using pipe->blit (v2)
This replaces u_gen_mipmap with an extremely simple implementation based
on pipe->blit. st/mesa is also cleaned up.
Pros:
- less code
- correct mipmap generation for NPOT 3D textures (u_blitter uses a better
formula)
- queries are not affected by mipmap generation if drivers disable them
v2: add "first_layer", "last_layer" parameters, drop "face"
v2.1: add format
v2.2: document the format parameter
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.c | 73 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.h | 8 |
4 files changed, 11 insertions, 73 deletions
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 807a86fdf93..c7f3ec6be41 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -152,7 +152,6 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, st_init_bitmap(st); st_init_clear(st); st_init_draw( st ); - st_init_generate_mipmap(st); /* Choose texture target for glDrawPixels, glBitmap, renderbuffers */ if (pipe->screen->get_param(pipe->screen, PIPE_CAP_NPOT_TEXTURES)) @@ -254,7 +253,6 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_atoms( st ); st_destroy_draw( st ); - st_destroy_generate_mipmap(st); st_destroy_clear(st); st_destroy_bitmap(st); st_destroy_drawpix(st); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 0e00dd4fab6..361a24b1d71 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -188,7 +188,6 @@ struct st_context void *passthrough_fs; /**< simple pass-through frag shader */ enum pipe_texture_target internal_target; - struct gen_mipmap_state *gen_mipmap; struct cso_context *cso_context; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index f1864fcdebc..18cf504a759 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -44,64 +44,6 @@ /** - * one-time init for generate mipmap - * XXX Note: there may be other times we need no-op/simple state like this. - * In that case, some code refactoring would be good. - */ -void -st_init_generate_mipmap(struct st_context *st) -{ - st->gen_mipmap = util_create_gen_mipmap(st->pipe, st->cso_context); -} - - -void -st_destroy_generate_mipmap(struct st_context *st) -{ - util_destroy_gen_mipmap(st->gen_mipmap); - st->gen_mipmap = NULL; -} - - -/** - * Generate mipmap levels using hardware rendering. - * \return TRUE if successful, FALSE if not possible - */ -static boolean -st_render_mipmap(struct st_context *st, - GLenum target, - struct st_texture_object *stObj, - uint baseLevel, uint lastLevel) -{ - struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; - struct pipe_sampler_view *psv; - const uint face = _mesa_tex_target_to_face(target); - -#if 0 - assert(target != GL_TEXTURE_3D); /* implemented but untested */ -#endif - - /* check if we can render in the texture's format */ - /* XXX should probably kill this and always use util_gen_mipmap - since this implements a sw fallback as well */ - if (!screen->is_format_supported(screen, stObj->pt->format, - stObj->pt->target, - 0, PIPE_BIND_RENDER_TARGET)) { - return FALSE; - } - - psv = st_create_texture_sampler_view(pipe, stObj->pt); - - util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel, - PIPE_TEX_FILTER_LINEAR); - - pipe_sampler_view_reference(&psv, NULL); - - return TRUE; -} - -/** * Compute the expected number of mipmap levels in the texture given * the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/ * GL_TEXTURE_MAX_LEVEL settings. This will tell us how many mipmap @@ -136,7 +78,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; - uint lastLevel; + uint lastLevel, first_layer, last_layer; uint dstLevel; if (!pt) @@ -195,12 +137,19 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, assert(pt->last_level >= lastLevel); + if (pt->target == PIPE_TEXTURE_CUBE) { + first_layer = last_layer = _mesa_tex_target_to_face(target); + } + else { + first_layer = 0; + last_layer = util_max_layer(pt, baseLevel); + } + /* Try to generate the mipmap by rendering/texturing. If that fails, * use the software fallback. */ - if (!st_render_mipmap(st, target, stObj, baseLevel, lastLevel)) { - /* since the util code actually also has a fallback, should - probably make it never fail and kill this */ + if (!util_gen_mipmap(st->pipe, pt, pt->format, baseLevel, lastLevel, + first_layer, last_layer, PIPE_TEX_FILTER_LINEAR)) { _mesa_generate_mipmap(ctx, target, texObj); } diff --git a/src/mesa/state_tracker/st_gen_mipmap.h b/src/mesa/state_tracker/st_gen_mipmap.h index 64eb39723bf..4cc20895178 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.h +++ b/src/mesa/state_tracker/st_gen_mipmap.h @@ -34,14 +34,6 @@ struct gl_context; struct gl_texture_object; -struct st_context; - -extern void -st_init_generate_mipmap(struct st_context *st); - - -extern void -st_destroy_generate_mipmap(struct st_context *st); extern void |