[Mesa-dev] [RFC PATCH] mesa/st/cb_clear: in st_Clear also validate the render state (needed by virgl)

Ilia Mirkin imirkin at alum.mit.edu
Fri May 4 12:21:09 UTC 2018


On Fri, May 4, 2018 at 7:36 AM, Gert Wollny <gert.wollny at collabora.com> wrote:
> Am Donnerstag, den 03.05.2018, 19:52 +0200 schrieb Gert Wollny:
>> Am Donnerstag, den 03.05.2018, 13:24 -0400 schrieb Ilia Mirkin:
>> >
>> > The api call is "clear", not "glClear in the context of whatever
>> > random GL state there might be". When the gallium clear API is
>> > invoked, the bound framebuffer needs to be cleared. This is how the
>> > API works, this is how all drivers implement it. It's basically
>> > memset(). It doesn't care about rasterizer discard or anything
>> > else.
>> >
>>
>> I stand corrected and sorry for the noise.
> Actually no:
>
> The OpenGL standard section 14.1 says:

Not sure what this has to do with anything. We're not talking about
glClear(). We're talking about the gallium clear API. Here's how it's
specified:

http://gallium.readthedocs.io/en/latest/context.html

"""
clear initializes some or all of the surfaces currently bound to the
framebuffer to particular RGBA, depth, or stencil values. Currently,
this does not take into account color or stencil write masks (as used
by GL), and always clears the whole surfaces (no scissoring as used by
GL clear or explicit rectangles like d3d9 uses). It can, however, also
clear only depth or stencil in a combined depth/stencil surface. If a
surface includes several layers then all layers will be cleared.
"""

What you need to do in the virgl_clear() function is to make that
happen. The fact that you're messing around with GL state on the
driver end isn't the gallium api's concern, nor is it the gallium
api's users'. My recommendation is instead of virgl_clear working
around virglrenderer's limitations by sending extra state (such as to
force-disable raster discard), to instead have virglrenderer track it
properly, and if raster discard has been enabled, to first disable it
before calling glClear() (and then re-enable it).

Cheers,

  -ilia


More information about the mesa-dev mailing list