[Mesa-dev] [PATCH] radv: Add CPU color packing for VK_FORMAT_A2B10G10R10_UNORM_PACK32.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Wed Feb 8 22:43:51 UTC 2017



On Wed, Feb 8, 2017, at 23:33, Andres Rodriguez wrote:
> 
> 
> On 2017-02-08 12:19 PM, Bas Nieuwenhuizen wrote:
> > For allowing fast color clears in the main render targets of dota2.
> >
> > Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
> > ---
> >  src/amd/vulkan/radv_formats.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c
> > index f18ecee9d2a..284e7025fbc 100644
> > --- a/src/amd/vulkan/radv_formats.c
> > +++ b/src/amd/vulkan/radv_formats.c
> > @@ -940,8 +940,11 @@ bool radv_format_pack_clear_color(VkFormat format,
> >  		clear_vals[1] |= ((uint16_t)util_iround(CLAMP(value->float32[3], 0.0f, 1.0f) * 0xffff)) << 16;
> >  		break;
> >  	case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
> > -		/* TODO */
> > -		return false;
> > +		clear_vals[0] = ((uint16_t)util_iround(CLAMP(value->float32[0], 0.0f, 1.0f) * 0x3ff)) & 0x3ff;
> > +		clear_vals[0] |= (((uint16_t)util_iround(CLAMP(value->float32[1], 0.0f, 1.0f) * 0x3ff)) & 0x3ff) << 10;
> > +		clear_vals[0] |= (((uint16_t)util_iround(CLAMP(value->float32[2], 0.0f, 1.0f) * 0x3ff)) & 0x3ff) << 20;
> > +		clear_vals[0] |= (((uint16_t)util_iround(CLAMP(value->float32[1], 0.0f, 1.0f) * 0x3)) & 0x3) << 30;
> 
> Does clear_vals[1] need to also be initialized here? Otherwise it is 
> going to be garbage I believe.

I don't think it matters, given that the format is 32 bits, but can
clear it anyway.

> 
> > +		return true;
> >  	case VK_FORMAT_R32G32_SFLOAT:
> >  		clear_vals[0] = fui(value->float32[0]);
> >  		clear_vals[1] = fui(value->float32[1]);
> >
> _______________________________________________
> 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