<div dir="ltr"><div>The way I see it, pipe_surface is a render target view for pipe_framebuffer_state. The fact that other functions also accept pipe_surface is a historic artifact. resource_copy_region used to accept 2 pipe_surfaces before it was changed to 2 pipe_resources + parameters. Somebody might decide to change invalidate_subresource to take pipe_resource in the future.<br></div><div><br></div><div>It seems to me that you really want e.g. invalidate_framebuffer(ctx, PIPE_FRAMEBUFFER_COLOR0 | PIPE_FRAMEBUFFER_COLOR1), not pipe_surface.</div><div><br></div><div>I'm not too crazy about this, just pointing out the way I understand the conventions.<br></div><div><br></div><div>Marek<br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 14, 2018 at 3:51 PM Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I don't mind renaming it to invalidate_subsurface() if you prefer<br>
that, but I really prefer that it takes a surface rather than a<br>
resource... pipe_resource is the wrong level to do this.<br>
<br>
Even though surfaces are transient, tracking the invalidate state in<br>
the surface works out much easier in the driver.  And I don't want to<br>
have to map resource+params back to a surface.  If another driver<br>
wants to track this at the resource level, it is easier for them to go<br>
from surface to resource+params, compared to the opposite direction.<br>
<br>
BR,<br>
-R<br>
<br>
<br>
On Fri, Dec 14, 2018 at 3:38 PM Marek Olšák <<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>> wrote:<br>
><br>
> Can you please call it invalidate_subresource and inline relevant pipe_surface variables inside the parameters?<br>
><br>
> Thanks,<br>
> Marek<br>
><br>
> On Wed, Dec 12, 2018 at 10:48 AM Rob Clark <<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>> wrote:<br>
>><br>
>> A new API to implement glInvalidateFramebuffer() and friends.  It is<br>
>> similar to invalidate_resource() but can be used to invalidate a<br>
>> specific layer/level, so it is suitable to use for user FBOs in addition<br>
>> to window system framebuffer.<br>
>><br>
>> Signed-off-by: Rob Clark <<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>><br>
>> ---<br>
>>  src/gallium/docs/source/context.rst  | 18 ++++++++++++++++++<br>
>>  src/gallium/include/pipe/p_context.h | 18 ++++++++++++++++++<br>
>>  2 files changed, 36 insertions(+)<br>
>><br>
>> diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst<br>
>> index 20d0df79312..9f3cd49ee31 100644<br>
>> --- a/src/gallium/docs/source/context.rst<br>
>> +++ b/src/gallium/docs/source/context.rst<br>
>> @@ -740,7 +740,25 @@ of the buffer is not a multiple of the page size, changing the commit state of<br>
>>  the last (partial) page requires a box that ends at the end of the buffer<br>
>>  (i.e., box->x + box->width == buffer->width0).<br>
>><br>
>> +.. _invalidate_surface:<br>
>><br>
>> +invalidate_surface<br>
>> +%%%%%%%%%%%%%%%%%%<br>
>> +<br>
>> +This optional function marks a surface, or a portion of a surface, as invalid,<br>
>> +for example to implement glInvalidateFramebuffer() (and friends).  It is<br>
>> +useful in particular for tiler GPUs, as a way to avoid unnecessary transfers<br>
>> +between system memory and tile buffer.<br>
>> +<br>
>> +For example, invalidating a surface after rendering, but before flush, can<br>
>> +be used to avoid tile to system memory transfer (for example, if zs can be<br>
>> +discarded).  And an invalidate after flush before rendering can be used to<br>
>> +avoid a system memory to tile buffer transfer.<br>
>> +<br>
>> +Invalidating a partial surface can also be used to avoid unnecessary transfer<br>
>> +from system memory to tile buffer in the case of a scissored clear (which is<br>
>> +implemented via ->draw_vbo() by the state tracker) by invalidating the<br>
>> +scissored region.<br>
>><br>
>>  .. _pipe_transfer:<br>
>><br>
>> diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h<br>
>> index e07b76d4f03..4dfc87faff6 100644<br>
>> --- a/src/gallium/include/pipe/p_context.h<br>
>> +++ b/src/gallium/include/pipe/p_context.h<br>
>> @@ -803,6 +803,24 @@ struct pipe_context {<br>
>>     void (*invalidate_resource)(struct pipe_context *ctx,<br>
>>                                 struct pipe_resource *resource);<br>
>><br>
>> +   /**<br>
>> +    * Like ->invalidate_resource, but can invalidate a specific layer and level<br>
>> +    * of a resource, and optionally a specific sub-region of the resource (if<br>
>> +    * region is not NULL).<br>
>> +    *<br>
>> +    * If the backing surf->texture has just a single layer and level (like<br>
>> +    * window system buffers), and region is NULL, it is equivalent to<br>
>> +    * ->invalidate_resource().<br>
>> +    *<br>
>> +    * \param ctx    pipe context<br>
>> +    * \param surf   surface to invalidate<br>
>> +    * \param region NULL to invalidate whole surface, otherwise specifies which<br>
>> +    *               portion of the surface is invalidated<br>
>> +    */<br>
>> +   void (*invalidate_surface)(struct pipe_context *ctx,<br>
>> +                              struct pipe_surface *surf,<br>
>> +                              const struct pipe_box *region);<br>
>> +<br>
>>     /**<br>
>>      * Return information about unexpected device resets.<br>
>>      */<br>
>> --<br>
>> 2.19.2<br>
>><br>
>> _______________________________________________<br>
>> mesa-dev mailing list<br>
>> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
>> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>