v3d: clamp clear color
On clearing a color buffer, clamp the passed color values to the allowed ones. Hardware do clamping for TLB values, but not for clear values. v2 (Iago) - Add comment about hardware-based clamping on clear values. v3 (Iago): - Use format utils to simplify clamping - Move clamp color function as utility Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13409>
This commit is contained in:
parent
fa1cd83fef
commit
54cba7d297
|
@ -25,6 +25,7 @@
|
|||
#include "util/u_draw.h"
|
||||
#include "util/u_prim.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_helpers.h"
|
||||
#include "util/u_pack_color.h"
|
||||
#include "util/u_prim_restart.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
|
@ -1564,6 +1565,17 @@ v3d_tlb_clear(struct v3d_job *job, unsigned buffers,
|
|||
color = &swapped_color;
|
||||
}
|
||||
|
||||
/* While hardware supports clamping, this is not applied on
|
||||
* the clear values, so we need to do it manually.
|
||||
*
|
||||
* "Clamping is performed on color values immediately as they
|
||||
* enter the TLB and after blending. Clamping is not
|
||||
* performed on the clear color."
|
||||
*/
|
||||
union pipe_color_union clamped_color =
|
||||
util_clamp_color(psurf->format, color);
|
||||
color = &clamped_color;
|
||||
|
||||
switch (surf->internal_type) {
|
||||
case V3D_INTERNAL_TYPE_8:
|
||||
util_pack_color(color->f, PIPE_FORMAT_R8G8B8A8_UNORM,
|
||||
|
|
Loading…
Reference in New Issue