[Mesa-dev] [PATCH 1/4] gallium: add pipe_surface::alpha_one field

Brian Paul brianp at vmware.com
Mon Jun 27 13:57:52 UTC 2016


On 06/24/2016 08:45 AM, Roland Scheidegger wrote:
> For what formats is this really needed? I think that usually if you have
> a rgb surface, the corresponding rgbx format should be used instead of
> rgba (which implicitly has the alpha == 1 property for blending). But
> maybe some formats are missing...

This all came about while finishing up support for GL_ARB_copy_image. 
Briefly, supporting RGBX caused quite a bit of grief that could be 
avoided by disabling the RGBX format and using RGBA instead.  But this 
leads to the blending issue (which, again, is a corner case not likely 
to be hit in practice).

Some 'fallback' paths for GL_ARB_copy_image use pipe_context::blit() and 
involves creating RGBA8_UNORM sampler views and surface views of the 
underlying resource.  Since our svga3d device doesn't have RGBX8_UINT, 
RGBX8_SNORM, etc. we use RGBA8_UINT, RGBA8_SNORM, etc. but we do support 
RGBX8_UNORM.  So copying from GL_RGB8UI to GL_RGB8, for example, 
involves creating a RGBA8_UNORM view of a RGBX8_TYPLESS surface, which 
IIRC, is disallowed by our svga3d device.

Before I quit on Friday, however, I think I found another piece of this 
puzzle that might make RGBX work.  I'll try to get back on that today.

-Brian


> Am 24.06.2016 um 04:07 schrieb Brian Paul:
>> If the user requests an RGB drawing surface but we actually create an
>> RGBA surface, we need it to act as if A=1.  For blending, this means
>> adjusting the blending terms to use 1/0 instead of DST_ALPHA/INV_DST_ALPHA.
>> Drivers can use this flag to determine when that's needed.
>>
>> A previous patch I posted last year did this entirely in the state tracker
>> but it involved making blend state dependent on the framebuffer state.
>> This approach avoids that dependency.
>> ---
>>   src/gallium/include/pipe/p_state.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
>> index 9c69355..8b0c3a2 100644
>> --- a/src/gallium/include/pipe/p_state.h
>> +++ b/src/gallium/include/pipe/p_state.h
>> @@ -387,6 +387,7 @@ struct pipe_surface
>>      unsigned height;              /**< logical height in pixels */
>>
>>      unsigned writable:1;          /**< writable shader resource */
>> +   unsigned alpha_one:1;    /**< Should an RGBA surface should act like RGB? */
>>
>>      union {
>>         struct {
>>
>



More information about the mesa-dev mailing list