From the OpenGL 4.6 spec, section 18.2.8:
"For a signed normalized fixed-point color buffer, each component is
clamped to [0,1] if read color clamping is enabled, or if type
represents un- signed integer components; otherwise type represents
signed integer components, and each component is clamped to [−1,1]."
Signed-off-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12749>
type != GL_UNSIGNED_INT_10F_11F_11F_REV)) {
transferOps |= IMAGE_CLAMP_BIT;
}
+
+ /* For SNORM formats we only clamp if `type` is signed and clamp is `true` */
+ if (!_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) &&
+ _mesa_get_format_datatype(texFormat) == GL_SIGNED_NORMALIZED &&
+ (type == GL_BYTE || type == GL_SHORT || type == GL_INT)) {
+ transferOps &= ~IMAGE_CLAMP_BIT;
+ }
}
/* If the format is unsigned normalized, we can ignore clamping