[Mesa-dev] [PATCH v2] st/mesa: directly compute level=0 texture size in st_finalize_texture
Nicolai Hähnle
nhaehnle at gmail.com
Tue Jun 7 23:10:34 UTC 2016
On 08.06.2016 01:03, Ilia Mirkin wrote:
> On Tue, Jun 7, 2016 at 7:00 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
>> @@ -2554,16 +2564,23 @@ st_finalize_texture(struct gl_context *ctx,
>> /* Need to import images in main memory or held in other textures.
>> */
>> if (stImage && stObj->pt != stImage->pt) {
>> - GLuint height = stObj->height0;
>> - GLuint depth = stObj->depth0;
>> + GLuint height;
>> + GLuint depth;
>>
>> if (stObj->base.Target != GL_TEXTURE_1D_ARRAY)
>> - height = u_minify(height, level);
>> + height = u_minify(ptHeight, level);
>> + else
>> + height = ptLayers;
>> +
>> if (stObj->base.Target == GL_TEXTURE_3D)
>> - depth = u_minify(depth, level);
>> + depth = u_minify(ptDepth, level);
>> + else if (stObj->base.Target == GL_TEXTURE_CUBE_MAP)
>> + depth = 1;
>
> Should this be 6? If not, should you divide ptLayers by 6 for CUBE_MAP_ARRAY?
>
> [haven't carefully grok'd what you're doing... just observed this inconsistency]
This code is trying to be the inverse of
st_gl_texture_dims_to_pipe_dims. Cube maps have GL depth == 1, but cube
map arrays have GL depth == number of Gallium layers. The inconsistency
is part of OpenGL...
Nicolai
>
>> + else
>> + depth = ptLayers;
>>
>> if (level == 0 ||
>> - (stImage->base.Width == u_minify(stObj->width0, level) &&
>> + (stImage->base.Width == u_minify(ptWidth, level) &&
>> stImage->base.Height == height &&
>> stImage->base.Depth == depth)) {
>> /* src image fits expected dest mipmap level size */
>> @@ -2599,10 +2616,6 @@ st_AllocTextureStorage(struct gl_context *ctx,
>>
>> assert(levels > 0);
>>
>> - /* Save the level=0 dimensions */
>> - stObj->width0 = width;
>> - stObj->height0 = height;
>> - stObj->depth0 = depth;
>> stObj->lastLevel = levels - 1;
>>
>> fmt = st_mesa_format_to_pipe_format(st, texImage->TexFormat);
>> @@ -2740,9 +2753,6 @@ st_TextureView(struct gl_context *ctx,
>> tex->surface_format =
>> st_mesa_format_to_pipe_format(st_context(ctx), image->TexFormat);
>>
>> - tex->width0 = image->Width;
>> - tex->height0 = image->Height;
>> - tex->depth0 = image->Depth;
>> tex->lastLevel = numLevels - 1;
>>
>> return GL_TRUE;
>> diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
>> index a983d64..33f56ea 100644
>> --- a/src/mesa/state_tracker/st_manager.c
>> +++ b/src/mesa/state_tracker/st_manager.c
>> @@ -587,9 +587,6 @@ st_context_teximage(struct st_context_iface *stctxi,
>> }
>>
>> pipe_resource_reference(&stImage->pt, tex);
>> - stObj->width0 = width;
>> - stObj->height0 = height;
>> - stObj->depth0 = depth;
>> stObj->surface_format = pipe_format;
>>
>> _mesa_dirty_texobj(ctx, texObj);
>> diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
>> index d8cd7c7..ae9e2b4 100644
>> --- a/src/mesa/state_tracker/st_texture.h
>> +++ b/src/mesa/state_tracker/st_texture.h
>> @@ -79,12 +79,6 @@ struct st_texture_object
>> */
>> GLuint lastLevel;
>>
>> - /** The size of the level=0 mipmap image.
>> - * Note that the number of 1D array layers will be in height0 and the
>> - * number of 2D array layers will be in depth0, as in GL.
>> - */
>> - GLuint width0, height0, depth0;
>> -
>> /* On validation any active images held in main memory or in other
>> * textures will be copied to this texture and the old storage freed.
>> */
>> diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
>> index 08f2553..dffa52f 100644
>> --- a/src/mesa/state_tracker/st_vdpau.c
>> +++ b/src/mesa/state_tracker/st_vdpau.c
>> @@ -238,9 +238,6 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
>> sampler_view = st_texture_get_sampler_view(st, stObj);
>> *sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ);
>>
>> - stObj->width0 = res->width0;
>> - stObj->height0 = res->height0;
>> - stObj->depth0 = 1;
>> stObj->surface_format = res->format;
>>
>> _mesa_dirty_texobj(ctx, texObj);
>> --
>> 2.7.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list