pipe_reference(&stImage->compressed_data->reference, NULL)) {
free(stImage->compressed_data->ptr);
free(stImage->compressed_data);
+ stImage->compressed_data = NULL;
}
/* if the texture image is being deallocated, the structure of the
struct st_context *st = st_context(ctx);
struct st_texture_image *stImage = st_texture_image(texImage);
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
- const GLuint level = texImage->Level;
GLuint width = texImage->Width;
GLuint height = texImage->Height;
GLuint depth = texImage->Depth;
stObj->needs_validation = true;
compressed_tex_fallback_allocate(st, stImage);
+ const bool allowAllocateToStObj = !stObj->pt ||
+ stObj->pt->last_level == 0 ||
+ texImage->Level == 0;
- /* Look if the parent texture object has space for this image */
- if (stObj->pt &&
- level <= stObj->pt->last_level &&
- st_texture_match_image(st, stObj->pt, texImage)) {
- /* this image will fit in the existing texture object's memory */
- pipe_resource_reference(&stImage->pt, stObj->pt);
- return GL_TRUE;
- }
+ if (allowAllocateToStObj) {
+ /* Look if the parent texture object has space for this image */
+ if (stObj->pt &&
+ st_texture_match_image(st, stObj->pt, texImage)) {
+ /* this image will fit in the existing texture object's memory */
+ pipe_resource_reference(&stImage->pt, stObj->pt);
+ assert(stImage->pt);
+ return GL_TRUE;
+ }
- /* The parent texture object does not have space for this image */
+ /* The parent texture object does not have space for this image */
- pipe_resource_reference(&stObj->pt, NULL);
- st_texture_release_all_sampler_views(st, stObj);
+ pipe_resource_reference(&stObj->pt, NULL);
+ st_texture_release_all_sampler_views(st, stObj);
- if (!guess_and_alloc_texture(st, stObj, stImage)) {
- /* Probably out of memory.
- * Try flushing any pending rendering, then retry.
- */
- st_finish(st);
if (!guess_and_alloc_texture(st, stObj, stImage)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
- return GL_FALSE;
+ /* Probably out of memory.
+ * Try flushing any pending rendering, then retry.
+ */
+ st_finish(st);
+ if (!guess_and_alloc_texture(st, stObj, stImage)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ return GL_FALSE;
+ }
}
}
pt.bind = bind;
/* only set this for OpenGL textures, not renderbuffers */
pt.flags = PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY;
+ if (memObj->TextureTiling == GL_LINEAR_TILING_EXT)
+ pt.bind |= PIPE_BIND_LINEAR;
+
pt.nr_samples = nr_samples;
pt.nr_storage_samples = nr_samples;
bindings = default_bindings(st, fmt);
+ if (smObj) {
+ smObj->TextureTiling = texObj->TextureTiling;
+ bindings |= PIPE_BIND_SHARED;
+ }
+
if (num_samples > 0) {
/* Find msaa sample count which is actually supported. For example,
* if the user requests 1x but only 4x or 8x msaa is supported, we'll