union util_color uc;
uint32_t internal_size = 4 << surf->internal_bpp;
- static union pipe_color_union swapped_color;
- if (v3d->swap_color_rb & (1 << i)) {
- swapped_color.f[0] = color->f[2];
- swapped_color.f[1] = color->f[1];
- swapped_color.f[2] = color->f[0];
- swapped_color.f[3] = color->f[3];
- color = &swapped_color;
- }
-
/* While hardware supports clamping, this is not applied on
* the clear values, so we need to do it manually.
*
*/
union pipe_color_union clamped_color =
util_clamp_color(psurf->format, color);
- color = &clamped_color;
+
+ if (v3d->swap_color_rb & (1 << i)) {
+ union pipe_color_union orig_color = clamped_color;
+ clamped_color.f[0] = orig_color.f[2];
+ clamped_color.f[1] = orig_color.f[1];
+ clamped_color.f[2] = orig_color.f[0];
+ clamped_color.f[3] = orig_color.f[3];
+ }
switch (surf->internal_type) {
case V3D_INTERNAL_TYPE_8:
- util_pack_color(color->f, PIPE_FORMAT_R8G8B8A8_UNORM,
+ util_pack_color(clamped_color.f, PIPE_FORMAT_R8G8B8A8_UNORM,
&uc);
memcpy(job->clear_color[i], uc.ui, internal_size);
break;
case V3D_INTERNAL_TYPE_8I:
case V3D_INTERNAL_TYPE_8UI:
- job->clear_color[i][0] = ((color->ui[0] & 0xff) |
- (color->ui[1] & 0xff) << 8 |
- (color->ui[2] & 0xff) << 16 |
- (color->ui[3] & 0xff) << 24);
+ job->clear_color[i][0] = ((clamped_color.ui[0] & 0xff) |
+ (clamped_color.ui[1] & 0xff) << 8 |
+ (clamped_color.ui[2] & 0xff) << 16 |
+ (clamped_color.ui[3] & 0xff) << 24);
break;
case V3D_INTERNAL_TYPE_16F:
- util_pack_color(color->f, PIPE_FORMAT_R16G16B16A16_FLOAT,
+ util_pack_color(clamped_color.f, PIPE_FORMAT_R16G16B16A16_FLOAT,
&uc);
memcpy(job->clear_color[i], uc.ui, internal_size);
break;
case V3D_INTERNAL_TYPE_16I:
case V3D_INTERNAL_TYPE_16UI:
- job->clear_color[i][0] = ((color->ui[0] & 0xffff) |
- color->ui[1] << 16);
- job->clear_color[i][1] = ((color->ui[2] & 0xffff) |
- color->ui[3] << 16);
+ job->clear_color[i][0] = ((clamped_color.ui[0] & 0xffff) |
+ clamped_color.ui[1] << 16);
+ job->clear_color[i][1] = ((clamped_color.ui[2] & 0xffff) |
+ clamped_color.ui[3] << 16);
break;
case V3D_INTERNAL_TYPE_32F:
case V3D_INTERNAL_TYPE_32I:
case V3D_INTERNAL_TYPE_32UI:
- memcpy(job->clear_color[i], color->ui, internal_size);
+ memcpy(job->clear_color[i], clamped_color.ui, internal_size);
break;
}