Re: [PATCH 3/4] wined3d: Add a slop for color keying.
On 20 August 2015 at 10:03, Stefan Dösinger <stefan(a)codeweavers.com> wrote:
@@ -6332,7 +6332,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * }
if (settings->color_key_enabled) - shader_addline(buffer, "if (all(equal(tex0, color_key))) discard;\n"); + shader_addline(buffer, "if (all(lessThan(abs(tex0 - color_key), vec4(%s)))) discard;\n", + wined3d_color_key_precision);
...
+/* Normalization of B5G6R5_UNORM textures is horribly imprecise if we don't have + * GL_RGB_565 support. 1 / 256 (~0.0039) works in practice, but is awfully close + * to the next possible value in 8 bit formats. 1 / 384 is too precise for some + * 5 and 6 bit channel values at least on Nvidia. + * + * An exact comparison isn't reliable for any format, except for the normalized + * values 0.0 and 1.0. */ +const char *wined3d_color_key_precision = "0.003";
Shouldn't you just pass the color key as a range to the shader instead? E.g. in a 6 bpc format anything between 0.484f and 0.500f would get quantized to 0x1f. (Which, other floating point issues aside, would correspond to about 0.008 slop here. For a 5 bpc format you'd even have 0.016.)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 2015-08-20 um 11:06 schrieb Henri Verbeet:
Shouldn't you just pass the color key as a range to the shader instead? E.g. in a 6 bpc format anything between 0.484f and 0.500f would get quantized to 0x1f. (Which, other floating point issues aside, would correspond to about 0.008 slop here. For a 5 bpc format you'd even have 0.016.) That would mean two uniforms instead of one, but could help with range color keys. I'll investigate the idea.
Otoh the idea of re-testing this stuff on old those GPUs doesn't really appeal to me :-( . -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJV1avAAAoJEN0/YqbEcdMwGmYP/3eX7u3M3OqSSZJ+lo5+aae7 3a9n7bA2cO8Z2Q5dBdJ/hNU4ifFy5jhHptUGBevc7d9tqKAMV8aU9994aW731kI1 PUHqQxGvluebjHTQiDNqHZ8PwUklglOPThW/6sYrOaBgktNoQOHa3O+HsrFHeTZg HkhMeIg+y+HUQvf+JZlAlNkyhQFji7J8055R3nAqmH/2FOp/3zsbE9m0okT2Qo5q nU+BcMzEdHliWcsa6xJ8/ki4roo4+4eIcNhMXLT/GuPry8TP3wO8VVyDTGmJW4oT JvHt3JdTZpngJd0cOR4Kcac/dmK+yeSoFWCg5UyEW5B5JgpysLbC/5ukONlXiijP Ta+3m8YOEznE8ue63ewo67Gm2/aTfM40tfO7c/boqJODkBtnQTdxXO2oWwWR2MbI SBx9d1/8huHSvF40xLLnSri1V5xdWJtTV4UaJm+t6XRxPtrAZm/enk9k2MT2I0Kp 55VHpL5VyqThlBpNoLI8GiLQjCl2t0fxeh4SGzuzRAifkkeWFAhBx5PLO3ROSW82 KlnsS+kCBqWJHy/HdYZAOQ2tjVLzgWAfbWJbV5H30hpu5Ywb6lo+JEOVu8m0UKfG RQrQNAbiAcTnywCmiZ6C8fsUk6Y0CyeEmfTqfrw1VlTFSalxPeHzct4RLzbPSL7d VtkChui4HR38UziAblMG =Jo61 -----END PGP SIGNATURE-----
On 20 August 2015 at 12:28, Stefan Dösinger <stefandoesinger(a)gmail.com> wrote:
Am 2015-08-20 um 11:06 schrieb Henri Verbeet:
Shouldn't you just pass the color key as a range to the shader instead? E.g. in a 6 bpc format anything between 0.484f and 0.500f would get quantized to 0x1f. (Which, other floating point issues aside, would correspond to about 0.008 slop here. For a 5 bpc format you'd even have 0.016.) That would mean two uniforms instead of one, but could help with range color keys. I'll investigate the idea.
You could of course also derive the slop from the format's channel sizes, but it would need to be a vector because of formats like WINED3DFMT_B5G6R5_UNORM, still need an extra uniform, and not make range color keys any easier.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 2015-08-20 um 12:50 schrieb Henri Verbeet:
You could of course also derive the slop from the format's channel sizes, but it would need to be a vector because of formats like WINED3DFMT_B5G6R5_UNORM, still need an extra uniform, and not make range color keys any easier. Ya, and the hardcoded 0.003 also needs a uniform, so we're not winning anything there. Besides, we have plenty of uniforms for blits and fixed function fragment processing.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJV1cTtAAoJEN0/YqbEcdMwxhMP/jH3hepAVbF8GBWR+HvUhDOo 9XGpOAJ9Fve6ncYazIvTmHrtg2TKDNLoYTDtqiBA+srX4T519ZBmzjD+h3UQRxmA 5d9kv5jZBWZ7pWoUmCJrdDo2fFgMRYjhX9hd+gcnF34kXC4VA6IkWy0psuf7JBjR OxGfz8vBOwVzdQr/LivjwbldBBYjm2F17Nreso4NLoOrZXtC62vA1JKx0wNlAORH JfnXAyKSHStH8wBa7f35B1EpvwFmFSEbZdKPhqiZ/qRWT9jtpIrpjbxIYGbS3euR qJs1msRcVe5HJzQu2F5CAsIQJbB0X6M3r0gjgPAUmgpXODcEG803PzHxK23kqcGP JSkBVykVJzc6PPlqGAtCX3GV1lz8MN6FIYuDLHRtU9tG8FKI/hWr4mQueKg6qKIT NZzvCiqZnEbElx/I9FeiqNH60HBKZx536i6YX8tjj7mnRMMcnAC1UwgiDOFyJ2Cb aA07y8lgSpVahsCfcsvzA2FzwaZrq8tpxuLpqoyX0qpWK+e5rzhhrbf4U9Drj9jL 1fsS+IBObd1pQUI+1XmJAII9mm+7ITJODPl4rnTVYY+4L9pJIiULY6crsOscGofB mBZyVhfhyPA8jDv9fC/KsE7J9WEA9BsNsV7WgKCu4bh2PpM0/O9f0mMOK0zlflaz D9iLIbsXDnRZUkzQvYta =ecOw -----END PGP SIGNATURE-----
participants (2)
-
Henri Verbeet -
Stefan Dösinger