mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 11:28:05 +02:00
radv: fix color conversions for normalized uint/sint formats
The hardware actually rounds before conversion. This now matches
what values are used when performing fast clears vs slow clears.
This fixes a rendering issue with Far Cry 3&4. This also fixes
a bunch of CTS tests that use a 8-bit UNORM format (only when
the 512*512 image size hint is manually disabled).
Cc: "19.0" "19.1" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
(cherry picked from commit e03e7c510f)
This commit is contained in:
parent
015e8974ab
commit
585c25be1e
1 changed files with 16 additions and 4 deletions
|
|
@ -990,10 +990,22 @@ bool radv_format_pack_clear_color(VkFormat format,
|
||||||
assert(channel->size == 8);
|
assert(channel->size == 8);
|
||||||
|
|
||||||
v = util_format_linear_float_to_srgb_8unorm(value->float32[c]);
|
v = util_format_linear_float_to_srgb_8unorm(value->float32[c]);
|
||||||
} else if (channel->type == VK_FORMAT_TYPE_UNSIGNED) {
|
|
||||||
v = MAX2(MIN2(value->float32[c], 1.0f), 0.0f) * ((1ULL << channel->size) - 1);
|
|
||||||
} else {
|
} else {
|
||||||
v = MAX2(MIN2(value->float32[c], 1.0f), -1.0f) * ((1ULL << (channel->size - 1)) - 1);
|
float f = MIN2(value->float32[c], 1.0f);
|
||||||
|
|
||||||
|
if (channel->type == VK_FORMAT_TYPE_UNSIGNED) {
|
||||||
|
f = MAX2(f, 0.0f) * ((1ULL << channel->size) - 1);
|
||||||
|
} else {
|
||||||
|
f = MAX2(f, -1.0f) * ((1ULL << (channel->size - 1)) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The hardware rounds before conversion. */
|
||||||
|
if (f > 0)
|
||||||
|
f += 0.5f;
|
||||||
|
else
|
||||||
|
f -= 0.5f;
|
||||||
|
|
||||||
|
v = (uint64_t)f;
|
||||||
}
|
}
|
||||||
} else if (channel->type == VK_FORMAT_TYPE_FLOAT) {
|
} else if (channel->type == VK_FORMAT_TYPE_FLOAT) {
|
||||||
if (channel->size == 32) {
|
if (channel->size == 32) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue