[Mesa-dev] State tracker pipe_surface woes...

Roland Scheidegger sroland at vmware.com
Thu Sep 8 09:08:03 PDT 2011

Am 08.09.2011 09:08, schrieb Marek Olšák:
> 2011/9/7 Roland Scheidegger <sroland at vmware.com>:
>> That said I'm not really sure why pipe_sampler_view and pipe_surface
>> actually have a context pointer in them, since they are only supposed to
>> be used with the context in which they were created I think those
>> shouldn't actually exist - surface_destroy and sampler_view_destroy will
>> have context as a parameter, and if they aren't shared between contexts
>> it's pointless to store the context pointer. Might be a relic from when
>> those structs were created/destroyed using screen functions...
> The ctx pointer is there because of pipe_surface_reference and
> pipe_sampler_view_reference. When the refcount becomes 0, the
> corresponding pipe...reference function uses the ctx pointer to do
> ctx->...destroy(ctx, ...
> So that we can destroy objects just by:
> pipe_surface_reference(&surface, NULL);
> This ctx pointer also ensures that the destroy function is called with
> the right context.

Yes. It's arguable though that these really need refcounting - the state
tracker could probably create/destroy them like any other object (e.g.
they could follow just the normal create/bind/destroy pattern).
Only resources really need refcounting.
Even with refcounting you could just pass in the context probably, since
the context when creating/destroying them always has to be the same anyway.
(pipe_surface though definitely needed refcounting in the past because
it was a sharable screen entity once used for things like gl system
framebuffers which were not backed by a resource.)
It works for now though so I'm not really proposing to change it.


More information about the mesa-dev mailing list