From 0d8477543578bc5c561e5972fce1bcce596db9b4 Mon Sep 17 00:00:00 2001 From: Italo Nicola Date: Mon, 13 Sep 2021 08:57:16 -0300 Subject: [PATCH] vrend: make sure color read from a buffer is always unclamped Tipically mesa handles CLAMP_READ_COLOR in gallium frontend, and the default value for CLAMP_READ_COLOR as defined by the GL spec is GL_FIXED_ONLY. As CLAMP_READ_COLOR is really only used for reading pixel color values from a buffer, there's no problem always returning unclamped colors and letting the guest mesa clamp it if it wants. On the other hand, if we clamp it on the host, as we do now, then the guest mesa only has clamped values to work with, which needless to say, can't be "unclamped". Unfortunaly, this fix doesn't work for the GL ES backend, because in GL ES the colors read with glReadPixels are always clamped. Fixes piglit's fbo-blending-snorm tests. Signed-off-by: Italo Nicola Reviewed-by: Gert Wollny --- src/vrend_renderer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 27e2efd..4b5f881 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -5775,6 +5775,11 @@ static void vrend_hw_emit_rs(struct vrend_context *ctx) report_core_warn(ctx, CORE_PROFILE_WARN_CLAMP); } + /* read-color-clamping is handled in the mesa frontend */ + if (!vrend_state.use_gles) { + glClampColor(GL_CLAMP_READ_COLOR_ARB, GL_FALSE); + } + if (has_feature(feat_multisample)) { if (has_feature(feat_sample_mask)) { if (state->multisample)