From 4d0d9118756325ea83d254515d4c7a410df96f0e Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sun, 24 Jun 2018 22:10:28 +0200 Subject: [PATCH] nouveau: fix 3D blitter for unsigned to signed integer conversions fixes a couple of packed_pixel CTS tests. No regressions inside a CTS run. v2: simplify the changes a bit Reviewed-by: Ilia Mirkin Signed-off-by: Karol Herbst --- src/gallium/drivers/nouveau/nv50/nv50_blit.h | 21 +++++++++++---------- src/gallium/drivers/nouveau/nv50/nv50_surface.c | 11 +++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_blit.h b/src/gallium/drivers/nouveau/nv50/nv50_blit.h index 10fe527..01667bb 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_blit.h +++ b/src/gallium/drivers/nouveau/nv50/nv50_blit.h @@ -17,16 +17,17 @@ nv50_blit_select_mode(const struct pipe_blit_info *); void nv50_resource_resolve(struct pipe_context *, const struct pipe_resolve_info *); -#define NV50_BLIT_MODE_PASS 0 /* pass through TEX $t0/$s0 output */ -#define NV50_BLIT_MODE_Z24S8 1 /* encode ZS values for RGBA unorm8 */ -#define NV50_BLIT_MODE_S8Z24 2 -#define NV50_BLIT_MODE_X24S8 3 -#define NV50_BLIT_MODE_S8X24 4 -#define NV50_BLIT_MODE_Z24X8 5 -#define NV50_BLIT_MODE_X8Z24 6 -#define NV50_BLIT_MODE_ZS 7 /* put $t0/$s0 into R, $t1/$s1 into G */ -#define NV50_BLIT_MODE_XS 8 /* put $t1/$s1 into G */ -#define NV50_BLIT_MODES 9 +#define NV50_BLIT_MODE_PASS 0 /* pass through TEX $t0/$s0 output */ +#define NV50_BLIT_MODE_Z24S8 1 /* encode ZS values for RGBA unorm8 */ +#define NV50_BLIT_MODE_S8Z24 2 +#define NV50_BLIT_MODE_X24S8 3 +#define NV50_BLIT_MODE_S8X24 4 +#define NV50_BLIT_MODE_Z24X8 5 +#define NV50_BLIT_MODE_X8Z24 6 +#define NV50_BLIT_MODE_ZS 7 /* put $t0/$s0 into R, $t1/$s1 into G */ +#define NV50_BLIT_MODE_XS 8 /* put $t1/$s1 into G */ +#define NV50_BLIT_MODE_INT_CLAMP 9 /* unsigned to signed integer conversion */ +#define NV50_BLIT_MODES 10 /* CUBE and RECT textures are reinterpreted as 2D(_ARRAY) */ #define NV50_BLIT_TEXTURE_BUFFER 0 diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c index 037e14a..1ef0f50 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c @@ -892,6 +892,10 @@ nv50_blitter_make_fp(struct pipe_context *pipe, bool tex_s = false; bool cvt_un8 = false; + bool int_clamp = mode == NV50_BLIT_MODE_INT_CLAMP; + if (int_clamp) + mode = NV50_BLIT_MODE_PASS; + if (mode != NV50_BLIT_MODE_PASS && mode != NV50_BLIT_MODE_Z24X8 && mode != NV50_BLIT_MODE_X8Z24) @@ -936,6 +940,10 @@ nv50_blitter_make_fp(struct pipe_context *pipe, target, tc, ureg_DECL_sampler(ureg, 0)); } + /* handle signed to unsigned integer conversions */ + if (int_clamp) + ureg_UMIN(ureg, data, ureg_src(data), ureg_imm1u(ureg, 0x7fffffff)); + if (cvt_un8) { struct ureg_src mask; struct ureg_src scale; @@ -1058,6 +1066,9 @@ nv50_blit_select_mode(const struct pipe_blit_info *info) return NV50_BLIT_MODE_XS; } default: + if (util_format_is_pure_uint(info->src.format) && + util_format_is_pure_sint(info->dst.format)) + return NV50_BLIT_MODE_INT_CLAMP; return NV50_BLIT_MODE_PASS; } } -- 2.7.4