Re: [PATCH 4/7] wined3d: Initialize unwritten texcoord varyings in the VS.
On 2 October 2015 at 14:54, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
@@ -4998,7 +4996,22 @@ static GLuint generate_param_reorder_function(struct shader_glsl_priv *priv, output->register_idx, reg_mask[1]); } } - shader_addline(buffer, "}\n"); + + for (i = 0; i < MAX_TEXTURES; ++i) + { + if (ps && !(ps->reg_maps.texcoord & (1u << i))) + continue; + + if (texcoords_written_mask[i] != WINED3DSP_WRITEMASK_ALL) + { + if (gl_info->limits.glsl_varyings < wined3d_max_compat_varyings(gl_info) + && !texcoords_written_mask[i]) + continue; + + shader_glsl_write_mask_to_str(~texcoords_written_mask[i] & WINED3DSP_WRITEMASK_ALL, reg_mask); + shader_addline(buffer, "gl_TexCoord[%u]%s = vec4(0.0)%s;\n", i, reg_mask, reg_mask); + } + } } else { Doesn't this end up writing 0.0 to .w instead of 1.0? IIRC unwritten texture coordinates are assumed to be (0, 0, 0, 1) in D3D. May apply to the previous patch in the series as well.
2015-10-05 11:49 GMT+02:00 Henri Verbeet <hverbeet(a)gmail.com>:
On 2 October 2015 at 14:54, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
@@ -4998,7 +4996,22 @@ static GLuint generate_param_reorder_function(struct shader_glsl_priv *priv, output->register_idx, reg_mask[1]); } } - shader_addline(buffer, "}\n"); + + for (i = 0; i < MAX_TEXTURES; ++i) + { + if (ps && !(ps->reg_maps.texcoord & (1u << i))) + continue; + + if (texcoords_written_mask[i] != WINED3DSP_WRITEMASK_ALL) + { + if (gl_info->limits.glsl_varyings < wined3d_max_compat_varyings(gl_info) + && !texcoords_written_mask[i]) + continue; + + shader_glsl_write_mask_to_str(~texcoords_written_mask[i] & WINED3DSP_WRITEMASK_ALL, reg_mask); + shader_addline(buffer, "gl_TexCoord[%u]%s = vec4(0.0)%s;\n", i, reg_mask, reg_mask); + } + } } else { Doesn't this end up writing 0.0 to .w instead of 1.0? IIRC unwritten texture coordinates are assumed to be (0, 0, 0, 1) in D3D. May apply to the previous patch in the series as well.
My test (which is still a few patches ahead in the series but I can send you somewhere) shows that on Nvidia the texture coordinate defaults to (0, 0, 0, 0), while on AMD it defaults to (0, 0, 0, 1), so the value of the .w component probably doesn't matter much. Assuming the test is correct, of course...
On 5 October 2015 at 12:39, Matteo Bruni <matteo.mystral(a)gmail.com> wrote:
My test (which is still a few patches ahead in the series but I can send you somewhere) shows that on Nvidia the texture coordinate defaults to (0, 0, 0, 0), while on AMD it defaults to (0, 0, 0, 1), so the value of the .w component probably doesn't matter much. Assuming the test is correct, of course...
Does that include partially written coordinates? I'm fairly sure there were applications that cared about this. It may have been Half-Life 2 (which is probably totally different today) or some other Source Engine game. Maybe Stefan remembers. I suppose we could also just try if anything breaks if we change it, although in that case we could get rid of WINED3D_QUIRK_SET_TEXCOORD_W as well.
2015-10-05 13:01 GMT+02:00 Henri Verbeet <hverbeet(a)gmail.com>:
On 5 October 2015 at 12:39, Matteo Bruni <matteo.mystral(a)gmail.com> wrote:
My test (which is still a few patches ahead in the series but I can send you somewhere) shows that on Nvidia the texture coordinate defaults to (0, 0, 0, 0), while on AMD it defaults to (0, 0, 0, 1), so the value of the .w component probably doesn't matter much. Assuming the test is correct, of course...
Does that include partially written coordinates? I'm fairly sure there were applications that cared about this. It may have been Half-Life 2 (which is probably totally different today) or some other Source Engine game. Maybe Stefan remembers. I suppose we could also just try if anything breaks if we change it, although in that case we could get rid of WINED3D_QUIRK_SET_TEXCOORD_W as well.
Yes, same with partially written coordinates. I've kept the quirk around for the time being because it's still used in the ARB backend, although I guess I could update that.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Am 2015-10-05 um 13:01 schrieb Henri Verbeet:
Does that include partially written coordinates? I'm fairly sure there were applications that cared about this. It may have been Half-Life 2 (which is probably totally different today) or some other Source Engine game. Maybe Stefan remembers. I suppose we could also just try if anything breaks if we change it, although in that case we could get rid of WINED3D_QUIRK_SET_TEXCOORD_W as well. That problem was about the fixed function pipeline. A vertex shader wrote a partial texcoord, and fixed fucntion fragment processing was used. Normally GL always divides by .w, so it caused problems. ARBfp, GLSL and ATIfs can disable the .w divide, so the undefined content in .w doesn't matter.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWEoVDAAoJEN0/YqbEcdMwr9cP/j4qmjBn4VRO0mrfy7HpIPr2 sVziLdnMNE1cylxqjOP1zFEfoejM12ubsRvszeNnl8Gswj369ERWTo4YBHB3FUX5 h2WhWpMyj/mPfUtu+pBcpinTN/F+HlnPzpS9HtukSTZkq1UQJ8hnwmItURHYGdSI Pa397h+GWNl5RIYninFI1swyER3rkpfszVAQ9/TtZBVv1dTlA7XvIvuyuJrM+vDN spT8mRldlvk2FLXg3oUg9fCQrZ/X0Ji8f1h34fWpERNLa5Iwebv68D5Tj0Y6Kyz1 oamYVIPsr0b9xNbyS1HoOYAJs2gT+CNAxvhvF0k8Eochclli+qo74WHcJfBv5v1h aH4I3fcdFTVNK3TQKU0ePYu4XG6HMrwJ6kYqqf1R4PWP4j0OBoPJoUNgZ5Biepp+ ZaEs1GRUU9lmBlT7R6qau9KLFuHLi6ZQAHPVPSzbo9mprnFNUKHCstRl76wi6s8I tZNIeuzshhVi1TNquCQMhFL15Nf7O87Uq/Iqrq9F8lzKXqOP9CMreioSfKtJ3GgK p8su6/fUwX6ZYDGL5sD8V5bUrn+DP8h7XQiO1vLpavN0kyi/uJ8G52qyHvvxFGVh eXuaiH1308ipVWvRsGzRI64wv4GNlrQ2Lgi50qkIid4UjvDS3UlFMCxcWDRIDNX6 oXyk5FWsCAojmbF4p78R =I8AB -----END PGP SIGNATURE-----
participants (3)
-
Henri Verbeet -
Matteo Bruni -
Stefan Dösinger