summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_texture.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2016-09-30 16:41:46 -0600
committerBrian Paul <[email protected]>2016-10-06 11:29:32 -0600
commite5cc84dd43be066c1dd418e32f5ad258e31a150a (patch)
treefc693054ebad7517d3c63f1796e3bbc9b68e63b9 /src/mesa/state_tracker/st_texture.c
parent0f3aee888efa820cb9875cfebc83cf8cc855f599 (diff)
st/mesa: optimize pipe_sampler_view validation
Before, st_get_texture_sampler_view_from_stobj() did a lot of work to check if the texture parameters matched the sampler view (format, swizzle, min/max lod, first/last layer, etc). We did this every time we validated the texture state. Now, we use a ctx->Driver.TexParameter() callback and a couple other checks to proactively release texture views when we know that view-related parameters have changed. Then, the validation step is simplified: - Search the texture's list of sampler views (just match the context). - If found, we're done. - Else, create a new sampler view. There will never be old, out-of-date sampler views attached to texture objects that we have to test. Most apps create textures and set the texture parameters once. This make sampler view validation much cheaper for that case. Note that the old texture/sampler comparison code has been converted into a set of assertions to verify that the sampler view is in fact consistent with the texture parameters. This should help to spot any potential regressions. Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_texture.c')
-rw-r--r--src/mesa/state_tracker/st_texture.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 42616ca4cb4..32e5b84a5af 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -428,19 +428,17 @@ struct pipe_sampler_view **
st_texture_get_sampler_view(struct st_context *st,
struct st_texture_object *stObj)
{
- struct pipe_sampler_view *used = NULL, **free = NULL;
+ struct pipe_sampler_view **free = NULL;
GLuint i;
for (i = 0; i < stObj->num_sampler_views; ++i) {
struct pipe_sampler_view **sv = &stObj->sampler_views[i];
/* Is the array entry used ? */
if (*sv) {
- /* Yes, check if it's the right one */
- if ((*sv)->context == st->pipe)
+ /* check if the context matches */
+ if ((*sv)->context == st->pipe) {
return sv;
-
- /* Wasn't the right one, but remember it as template */
- used = *sv;
+ }
} else {
/* Found a free slot, remember that */
free = sv;
@@ -458,9 +456,7 @@ st_texture_get_sampler_view(struct st_context *st,
*free = NULL;
}
- /* Add just any sampler view to be used as a template */
- if (used)
- pipe_sampler_view_reference(free, used);
+ assert(*free == NULL);
return free;
}
@@ -512,4 +508,6 @@ st_texture_free_sampler_views(struct st_texture_object *stObj)
* those two headers we can trash the heap.
*/
FREE(stObj->sampler_views);
+ stObj->sampler_views = NULL;
+ stObj->num_sampler_views = 0;
}