Mesa (main): v3d: clamp clear color
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Dec 3 16:10:52 UTC 2021
Module: Mesa
Branch: main
Commit: 54cba7d297aadb6a088ef91bff860f40e201e8c6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=54cba7d297aadb6a088ef91bff860f40e201e8c6
Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date: Wed Sep 22 09:10:53 2021 +0200
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 at igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13409>
---
src/gallium/drivers/v3d/v3dx_draw.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c
index 25ef97f888e..e9e8f1889af 100644
--- a/src/gallium/drivers/v3d/v3dx_draw.c
+++ b/src/gallium/drivers/v3d/v3dx_draw.c
@@ -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,
More information about the mesa-commit
mailing list