summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-10-22 17:38:34 +0200
committerNicolai Hähnle <[email protected]>2017-11-09 11:50:55 +0100
commit8d20c660a9831c367d98ed2fea25e5276e6466f2 (patch)
treeafff3de5f94881690804b2eac6ba0646d7f887a7 /src/mesa
parent0dcf30e55091a0c78fc84d98f5ea36286f3f1961 (diff)
st/mesa: re-arrange st_finalize_texture
Move the early-out for surface-based textures earlier. This narrows the scope of the locking added in a follow-up commit. Fix one remaining case of initializing a surface-based texture without properly finalizing it. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c16
-rw-r--r--src/mesa/state_tracker/st_manager.c3
2 files changed, 11 insertions, 8 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 077319db6bc..3b7a3b5e985 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2473,9 +2473,6 @@ st_finalize_texture(struct gl_context *ctx,
stObj->lastLevel = stObj->base._MaxLevel;
}
- firstImage = st_texture_image_const(stObj->base.Image[cubeMapFace][stObj->base.BaseLevel]);
- assert(firstImage);
-
/* Skip the loop over images in the common case of no images having
* changed. But if the GL_BASE_LEVEL or GL_MAX_LEVEL change to something we
* haven't looked at, then we do need to look at those new images.
@@ -2486,6 +2483,14 @@ st_finalize_texture(struct gl_context *ctx,
return GL_TRUE;
}
+ /* If this texture comes from a window system, there is nothing else to do. */
+ if (stObj->surface_based) {
+ return GL_TRUE;
+ }
+
+ firstImage = st_texture_image_const(stObj->base.Image[cubeMapFace][stObj->base.BaseLevel]);
+ assert(firstImage);
+
/* If both firstImage and stObj point to a texture which can contain
* all active images, favour firstImage. Note that because of the
* completeness requirement, we know that the image dimensions
@@ -2498,11 +2503,6 @@ st_finalize_texture(struct gl_context *ctx,
st_texture_release_all_sampler_views(st, stObj);
}
- /* If this texture comes from a window system, there is nothing else to do. */
- if (stObj->surface_based) {
- return GL_TRUE;
- }
-
/* Find gallium format for the Mesa texture */
firstImageFormat =
st_mesa_format_to_pipe_format(st, firstImage->base.TexFormat);
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 48260df0c34..d27727ae8fb 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -48,6 +48,7 @@
#include "st_cb_fbo.h"
#include "st_cb_flush.h"
#include "st_manager.h"
+#include "st_sampler_view.h"
#include "state_tracker/st_gl_api.h"
@@ -734,6 +735,8 @@ st_context_teximage(struct st_context_iface *stctxi,
width = height = depth = 0;
}
+ pipe_resource_reference(&stObj->pt, tex);
+ st_texture_release_all_sampler_views(st, stObj);
pipe_resource_reference(&stImage->pt, tex);
stObj->surface_format = pipe_format;