diff options
author | Eric Anholt <[email protected]> | 2016-07-14 17:26:43 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-07-15 13:54:00 -0700 |
commit | 3bcd0f1912a60cc9d3813923d18d29465e41ff56 (patch) | |
tree | a453cbfb302a1e70b0704c3725f9ce6e5172db0d /src/gallium/drivers/vc4/vc4_state.c | |
parent | 88152d7dc0e2cf233cd2c38a4e9affb1ea73fa97 (diff) |
vc4: Speed up glGenerateMipmaps by avoiding shadow baselevel.
To support general GL_TEXTURE_BASE_LEVEL we have to copy to a temporary
miptree. However, if a single level is being selected, we can use the
existing miptree and force all the sampling to be from that particular
level.
This avoids a ton of software fallbacks in glGenerateMipmaps(), which uses
base levels in the blit implementation in gallium. Improves "glmark2 -b
terrain" from 2 fps to 3 (perhaps some more precision would be useful?),
and cuts its CPU usage during the benchmarking from ~30% to ~10% (total
CPU time from 8.8s to 7.6s).
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_state.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_state.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gallium/drivers/vc4/vc4_state.c b/src/gallium/drivers/vc4/vc4_state.c index bf4e0232daf..df9e1a3ab03 100644 --- a/src/gallium/drivers/vc4/vc4_state.c +++ b/src/gallium/drivers/vc4/vc4_state.c @@ -603,7 +603,8 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, * Also, Raspberry Pi doesn't support sampling from raster textures, * so we also have to copy to a temporary then. */ - if (cso->u.tex.first_level || + if ((cso->u.tex.first_level && + (cso->u.tex.first_level != cso->u.tex.last_level)) || rsc->vc4_format == VC4_TEXTURE_TYPE_RGBA32R) { struct vc4_resource *shadow_parent = vc4_resource(prsc); struct pipe_resource tmpl = shadow_parent->base.b; @@ -626,6 +627,8 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, clone->writes = shadow_parent->writes - 1; assert(clone->vc4_format != VC4_TEXTURE_TYPE_RGBA32R); + } else if (cso->u.tex.first_level) { + so->force_first_level = true; } so->base.texture = prsc; so->base.reference.count = 1; @@ -634,7 +637,9 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, so->texture_p0 = (VC4_SET_FIELD(rsc->slices[0].offset >> 12, VC4_TEX_P0_OFFSET) | VC4_SET_FIELD(rsc->vc4_format & 15, VC4_TEX_P0_TYPE) | - VC4_SET_FIELD(cso->u.tex.last_level - + VC4_SET_FIELD(so->force_first_level ? + cso->u.tex.last_level : + cso->u.tex.last_level - cso->u.tex.first_level, VC4_TEX_P0_MIPLVLS) | VC4_SET_FIELD(cso->target == PIPE_TEXTURE_CUBE, VC4_TEX_P0_CMMODE)); |