freedreno/a[345]xx: fix unorm/snorm blend factors when they're "over"

The float value may be out of range, so must be clamped to the allowed
range. Unclear if a3xx also has a SNORM factor that we're just missing
there, but that will be a separate investigation.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13903>
This commit is contained in:
Ilia Mirkin
2021-11-21 13:40:38 -05:00
committed by Marge Bot
parent 43f94ee9f1
commit bb6fb6065f
4 changed files with 20 additions and 24 deletions

View File

@@ -290,10 +290,6 @@ spec@!opengl 3.0@clearbuffer-stencil,Fail
spec@!opengl 3.1@primitive-restart-xfb generated,Fail
spec@!opengl 3.1@primitive-restart-xfb written,Fail
spec@!opengl 3.1@vao-broken-attrib,Crash
spec@arb_color_buffer_float@gl_rgba8_snorm-render,Fail
spec@arb_color_buffer_float@gl_rgba8_snorm-render-fog,Fail
spec@arb_color_buffer_float@gl_rgba8_snorm-render-sanity,Fail
spec@arb_color_buffer_float@gl_rgba8_snorm-render-sanity-fog,Fail
spec@arb_depth_buffer_float@fbo-clear-formats stencil,Fail
spec@arb_depth_buffer_float@fbo-clear-formats stencil@GL_DEPTH32F_STENCIL8,Fail
spec@arb_depth_buffer_float@fbo-depthstencil-gl_depth32f_stencil8-blit,Fail

View File

@@ -816,13 +816,13 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
if (dirty & FD_DIRTY_BLEND_COLOR) {
struct pipe_blend_color *bcolor = &ctx->blend_color;
OUT_PKT0(ring, REG_A3XX_RB_BLEND_RED, 4);
OUT_RING(ring, A3XX_RB_BLEND_RED_UINT(bcolor->color[0] * 255.0f) |
OUT_RING(ring, A3XX_RB_BLEND_RED_UINT(CLAMP(bcolor->color[0], 0.f, 1.f) * 0xff) |
A3XX_RB_BLEND_RED_FLOAT(bcolor->color[0]));
OUT_RING(ring, A3XX_RB_BLEND_GREEN_UINT(bcolor->color[1] * 255.0f) |
OUT_RING(ring, A3XX_RB_BLEND_GREEN_UINT(CLAMP(bcolor->color[1], 0.f, 1.f) * 0xff) |
A3XX_RB_BLEND_GREEN_FLOAT(bcolor->color[1]));
OUT_RING(ring, A3XX_RB_BLEND_BLUE_UINT(bcolor->color[2] * 255.0f) |
OUT_RING(ring, A3XX_RB_BLEND_BLUE_UINT(CLAMP(bcolor->color[2], 0.f, 1.f) * 0xff) |
A3XX_RB_BLEND_BLUE_FLOAT(bcolor->color[2]));
OUT_RING(ring, A3XX_RB_BLEND_ALPHA_UINT(bcolor->color[3] * 255.0f) |
OUT_RING(ring, A3XX_RB_BLEND_ALPHA_UINT(CLAMP(bcolor->color[3], 0.f, 1.f) * 0xff) |
A3XX_RB_BLEND_ALPHA_FLOAT(bcolor->color[3]));
}

View File

@@ -754,20 +754,20 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
OUT_PKT0(ring, REG_A4XX_RB_BLEND_RED, 8);
OUT_RING(ring, A4XX_RB_BLEND_RED_FLOAT(bcolor->color[0]) |
A4XX_RB_BLEND_RED_UINT(bcolor->color[0] * 0xff) |
A4XX_RB_BLEND_RED_SINT(bcolor->color[0] * 0x7f));
A4XX_RB_BLEND_RED_UINT(CLAMP(bcolor->color[0], 0.f, 1.f) * 0xff) |
A4XX_RB_BLEND_RED_SINT(CLAMP(bcolor->color[0], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A4XX_RB_BLEND_RED_F32(bcolor->color[0]));
OUT_RING(ring, A4XX_RB_BLEND_GREEN_FLOAT(bcolor->color[1]) |
A4XX_RB_BLEND_GREEN_UINT(bcolor->color[1] * 0xff) |
A4XX_RB_BLEND_GREEN_SINT(bcolor->color[1] * 0x7f));
A4XX_RB_BLEND_GREEN_UINT(CLAMP(bcolor->color[1], 0.f, 1.f) * 0xff) |
A4XX_RB_BLEND_GREEN_SINT(CLAMP(bcolor->color[1], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A4XX_RB_BLEND_RED_F32(bcolor->color[1]));
OUT_RING(ring, A4XX_RB_BLEND_BLUE_FLOAT(bcolor->color[2]) |
A4XX_RB_BLEND_BLUE_UINT(bcolor->color[2] * 0xff) |
A4XX_RB_BLEND_BLUE_SINT(bcolor->color[2] * 0x7f));
A4XX_RB_BLEND_BLUE_UINT(CLAMP(bcolor->color[2], 0.f, 1.f) * 0xff) |
A4XX_RB_BLEND_BLUE_SINT(CLAMP(bcolor->color[2], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A4XX_RB_BLEND_BLUE_F32(bcolor->color[2]));
OUT_RING(ring, A4XX_RB_BLEND_ALPHA_FLOAT(bcolor->color[3]) |
A4XX_RB_BLEND_ALPHA_UINT(bcolor->color[3] * 0xff) |
A4XX_RB_BLEND_ALPHA_SINT(bcolor->color[3] * 0x7f));
A4XX_RB_BLEND_ALPHA_UINT(CLAMP(bcolor->color[3], 0.f, 1.f) * 0xff) |
A4XX_RB_BLEND_ALPHA_SINT(CLAMP(bcolor->color[3], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A4XX_RB_BLEND_ALPHA_F32(bcolor->color[3]));
}

View File

@@ -835,20 +835,20 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
OUT_PKT4(ring, REG_A5XX_RB_BLEND_RED, 8);
OUT_RING(ring, A5XX_RB_BLEND_RED_FLOAT(bcolor->color[0]) |
A5XX_RB_BLEND_RED_UINT(bcolor->color[0] * 0xff) |
A5XX_RB_BLEND_RED_SINT(bcolor->color[0] * 0x7f));
A5XX_RB_BLEND_RED_UINT(CLAMP(bcolor->color[0], 0.f, 1.f) * 0xff) |
A5XX_RB_BLEND_RED_SINT(CLAMP(bcolor->color[0], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A5XX_RB_BLEND_RED_F32(bcolor->color[0]));
OUT_RING(ring, A5XX_RB_BLEND_GREEN_FLOAT(bcolor->color[1]) |
A5XX_RB_BLEND_GREEN_UINT(bcolor->color[1] * 0xff) |
A5XX_RB_BLEND_GREEN_SINT(bcolor->color[1] * 0x7f));
A5XX_RB_BLEND_GREEN_UINT(CLAMP(bcolor->color[1], 0.f, 1.f) * 0xff) |
A5XX_RB_BLEND_GREEN_SINT(CLAMP(bcolor->color[1], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A5XX_RB_BLEND_RED_F32(bcolor->color[1]));
OUT_RING(ring, A5XX_RB_BLEND_BLUE_FLOAT(bcolor->color[2]) |
A5XX_RB_BLEND_BLUE_UINT(bcolor->color[2] * 0xff) |
A5XX_RB_BLEND_BLUE_SINT(bcolor->color[2] * 0x7f));
A5XX_RB_BLEND_BLUE_UINT(CLAMP(bcolor->color[2], 0.f, 1.f) * 0xff) |
A5XX_RB_BLEND_BLUE_SINT(CLAMP(bcolor->color[2], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A5XX_RB_BLEND_BLUE_F32(bcolor->color[2]));
OUT_RING(ring, A5XX_RB_BLEND_ALPHA_FLOAT(bcolor->color[3]) |
A5XX_RB_BLEND_ALPHA_UINT(bcolor->color[3] * 0xff) |
A5XX_RB_BLEND_ALPHA_SINT(bcolor->color[3] * 0x7f));
A5XX_RB_BLEND_ALPHA_UINT(CLAMP(bcolor->color[3], 0.f, 1.f) * 0xff) |
A5XX_RB_BLEND_ALPHA_SINT(CLAMP(bcolor->color[3], -1.f, 1.f) * 0x7f));
OUT_RING(ring, A5XX_RB_BLEND_ALPHA_F32(bcolor->color[3]));
}