From: Stefan Dösinger Subject: Re: [PATCH v5 2/4] wined3d: Add fetch4 to shader FFP generate texture stage Message-Id: <4E265147-9233-46D3-A95F-CECD78BC1D79@gmail.com> Date: Thu, 14 Feb 2019 17:03:24 +0100 In-Reply-To: <20190211134839.4274-2-mailszeros@gmail.com> References: <20190108004217.10267-2-mailszeros@gmail.com> <20190211134839.4274-1-mailszeros@gmail.com> <20190211134839.4274-2-mailszeros@gmail.com> > Am 11.02.2019 um 14:48 schrieb Daniel Ansorregui : > > @@ -9879,6 +9883,7 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * > case WINED3D_GL_RES_TYPE_TEX_1D: > texture_function = "texture1D"; > coord_mask = "x"; > + fetch4 = FALSE; > break; > case WINED3D_GL_RES_TYPE_TEX_2D: > texture_function = "texture2D"; > @@ -9887,6 +9892,9 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * > case WINED3D_GL_RES_TYPE_TEX_3D: > texture_function = "texture3D"; > coord_mask = "xyz"; > + if (fetch4) > + FIXME("Unsupported Fetch4 and texture3D sampling"); > + fetch4 = FALSE; > break; > case WINED3D_GL_RES_TYPE_TEX_CUBE: > texture_function = "textureCube"; > @@ -9901,11 +9909,24 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * > texture_function = ""; > coord_mask = "xyzw"; > proj = FALSE; > + fetch4 = FALSE; I think this is dead code, now that you are filtering for WINED3D_GL_RES_TYPE_TEX_2D or WINED3D_GL_RES_TYPE_TEX_RECT in gen_ffp_frag_op? > else if (settings->op[stage].projected == WINED3D_PROJECTION_COUNT3) > { > - shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].xyz);\n", > - stage, texture_function, proj ? "Proj" : "", stage, stage); > + shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].xyz%s);\n", stage, > + texture_function, proj ? "Proj" : "", stage, stage, offset.buffer); > } > else > { > - shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].%s%s);\n", > - stage, texture_function, proj ? "Proj" : "", stage, stage, coord_mask, proj ? "w" : ""); > + shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].%s%s", stage, > + texture_function, proj ? "Proj" : "", stage, stage, coord_mask, proj ? "w" : ""); > + if (fetch4_proj) > + shader_addline(buffer, " / ffp_texcoord[%u].w", stage); > + shader_addline(buffer, "%s);\n", offset.buffer); Why don't you have to do the manual divide in the WINED3D_PROJECTION_COUNT3 case too? (in that case, divide by /z)? Your code may be right, I am not 100% sure about it.

Am 11.02.2019 um 14:48 schrieb Daniel Ansorregui <mailszeros@gmail.com>:

@@ -9879,6 +9883,7 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
            case WINED3D_GL_RES_TYPE_TEX_1D:
                texture_function = "texture1D";
                coord_mask = "x";
+                fetch4 = FALSE;
                break;
            case WINED3D_GL_RES_TYPE_TEX_2D:
                texture_function = "texture2D";
@@ -9887,6 +9892,9 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
            case WINED3D_GL_RES_TYPE_TEX_3D:
                texture_function = "texture3D";
                coord_mask = "xyz";
+                if (fetch4)
+                    FIXME("Unsupported Fetch4 and texture3D sampling");
+                fetch4 = FALSE;
                break;
            case WINED3D_GL_RES_TYPE_TEX_CUBE:
                texture_function = "textureCube";
@@ -9901,11 +9909,24 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
                texture_function = "";
                coord_mask = "xyzw";
                proj = FALSE;
+                fetch4 = FALSE;
I think this is dead code, now that you are filtering for WINED3D_GL_RES_TYPE_TEX_2D or WINED3D_GL_RES_TYPE_TEX_RECT in gen_ffp_frag_op?

        else if (settings->op[stage].projected == WINED3D_PROJECTION_COUNT3)
        {
-            shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].xyz);\n",
-                    stage, texture_function, proj ? "Proj" : "", stage, stage);
+            shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].xyz%s);\n", stage,
+                    texture_function, proj ? "Proj" : "", stage, stage, offset.buffer);
        }
        else
        {
-            shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].%s%s);\n",
-                    stage, texture_function, proj ? "Proj" : "", stage, stage, coord_mask, proj ? "w" : "");
+            shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].%s%s", stage,
+                    texture_function, proj ? "Proj" : "", stage, stage, coord_mask, proj ? "w" : "");
+            if (fetch4_proj)
+                shader_addline(buffer, " / ffp_texcoord[%u].w", stage);
+            shader_addline(buffer, "%s);\n", offset.buffer);
Why don't you have to do the manual divide in the WINED3D_PROJECTION_COUNT3 case too? (in that case, divide by /z)? Your code may be right, I am not 100% sure about it.

= -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEQxb0tqoFWyeVMl1sPRO8yFRPGiIFAlxlkUwACgkQPRO8yFRP GiLvZxAAlA3X62jZDZ2p8+yUprKt0ZjIN1PDNYoS2Wc451euDcTBzyZB5g3fGpxJ C6HZ69lRLfe3BUYAb7ldqDm43G33XrjnC5/HraAEfLdAs7lUnOn2VE1NcNdpkkQG V1Hjs1szMGY+BbDj4T7IhlpDsVhfk2vDF6piagS9/BvVr9ZwUWY/r7Y7Z4tt2WOB dDp8QUsMXAGrmjL3V1P1Bkg4zpwaLWIjtS1mwcHi/ReyMRE8n7JCnhBT/BuE8f2i LvuF7/4dyEe25rtuqsDp8K9eEvi73WkdRVR7MpEv8dseCvJFZCZUCR0v6MW9GlmM SwpSf77fDuYYpesFZVDue/Rznu4ORTb3wgs2RHLjYbU0JnHq9Ff1+EAgsd7bR8EM KIvIJXmSm6WDoKtulioibRuAh71r9vcQONHxtZHRMvrRT6aN4sqd+ps4qx9VUWfq ShyCivsFKvDkACWxzrHxKK2rOwz/Ubrbqtwa6moA0vzFv9v0/qJgc76tk8Ks/FTY CpOT7baGyE2XgMnxGrqwm/scinLLa5DW4MDfVowJfgToh4L/hzQMJ/Wdz6qDf8Pq j6D8MeN4TAFrgM9HARPXfzLlPJRPntuP5KBIbIzuYI7GHYWBeT7k72wEneHNNCkN BNADEF7hT6M2csgQI/lGGJrFVXdjoUqx+TiormZ9WU19ui181hQ= =jnU1 -----END PGP SIGNATURE-----