From 5a961e8de7f3b0ffb812f6f8e0972345084fce24 Mon Sep 17 00:00:00 2001 From: Daniel Ansorregui Date: Sat, 24 Nov 2018 20:13:32 +0000 Subject: [PATCH] wined3d: Simplify "glsl_generate_ffp" texture projection. This is to simplify the code before adding the FETCH4 modifications. No change is intended in the shader generation. Signed-off-by: Daniel Ansorregui Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 63 ++++++++++---------------------------- 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ad59e97e3fc..5f1a86608ba 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -9869,65 +9869,34 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * switch (settings->op[stage].tex_type) { case WINED3D_GL_RES_TYPE_TEX_1D: - if (proj) - { - texture_function = "texture1DProj"; - coord_mask = "xw"; - } - else - { - texture_function = "texture1D"; - coord_mask = "x"; - } + texture_function = "texture1D"; + coord_mask = "x"; break; case WINED3D_GL_RES_TYPE_TEX_2D: - if (proj) - { - texture_function = "texture2DProj"; - coord_mask = "xyw"; - } - else - { - texture_function = "texture2D"; - coord_mask = "xy"; - } + texture_function = "texture2D"; + coord_mask = "xy"; break; case WINED3D_GL_RES_TYPE_TEX_3D: - if (proj) - { - texture_function = "texture3DProj"; - coord_mask = "xyzw"; - } - else - { - texture_function = "texture3D"; - coord_mask = "xyz"; - } + texture_function = "texture3D"; + coord_mask = "xyz"; break; case WINED3D_GL_RES_TYPE_TEX_CUBE: texture_function = "textureCube"; coord_mask = "xyz"; break; case WINED3D_GL_RES_TYPE_TEX_RECT: - if (proj) - { - texture_function = "texture2DRectProj"; - coord_mask = "xyw"; - } - else - { - texture_function = "texture2DRect"; - coord_mask = "xy"; - } + texture_function = "texture2DRect"; + coord_mask = "xy"; break; default: FIXME("Unhandled texture type %#x.\n", settings->op[stage].tex_type); texture_function = ""; coord_mask = "xyzw"; + proj = FALSE; break; } if (!legacy_syntax) - texture_function = proj ? "textureProj" : "texture"; + texture_function = "texture"; if (stage > 0 && (settings->op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP @@ -9959,8 +9928,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * shader_addline(buffer, "ret = ffp_texcoord[%u] + ret.xyxy;\n", stage); } - shader_addline(buffer, "tex%u = %s(ps_sampler%u, ret.%s);\n", - stage, texture_function, stage, coord_mask); + shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ret.%s%s);\n", + stage, texture_function, proj ? "Proj" : "", stage, coord_mask, proj ? "w" : ""); if (settings->op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP_LUMINANCE) shader_addline(buffer, "tex%u *= clamp(tex%u.z * bumpenv_lum_scale%u + bumpenv_lum_offset%u, 0.0, 1.0);\n", @@ -9968,13 +9937,13 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * } else if (settings->op[stage].projected == WINED3D_PROJECTION_COUNT3) { - shader_addline(buffer, "tex%u = %s(ps_sampler%u, ffp_texcoord[%u].xyz);\n", - stage, texture_function, stage, stage); + shader_addline(buffer, "tex%u = %s%s(ps_sampler%u, ffp_texcoord[%u].xyz);\n", + stage, texture_function, proj ? "Proj" : "", stage, stage); } else { - shader_addline(buffer, "tex%u = %s(ps_sampler%u, ffp_texcoord[%u].%s);\n", - stage, texture_function, stage, stage, coord_mask); + 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" : ""); } string_buffer_sprintf(tex_reg_name, "tex%u", stage);