[PATCH 3/4] wined3d: Fixup 3D sampler when sampling 2D texture for PS models 2 and 3.

Paul Gofman gofmanp at gmail.com
Wed Jul 3 09:56:41 CDT 2019


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/d3d9/tests/visual.c       |  2 +-
 dlls/wined3d/shader.c          | 37 ++++++++++++++++++++++++++++++++--
 dlls/wined3d/wined3d_private.h |  6 ++++--
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 45c6e03dd9..747750f81c 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26366,7 +26366,7 @@ static void test_mismatched_sample_types(void)
     {
         {"2d_2d", (IDirect3DBaseTexture9 **)&tex_2d, &ps_2d, 0x00707070},
         {"3d_3d", (IDirect3DBaseTexture9 **)&volume, &ps_3d, 0x00303030},
-        {"2d_3d", (IDirect3DBaseTexture9 **)&tex_2d, &ps_3d, 0x00707070, 0x00b2cce5, TRUE},
+        {"2d_3d", (IDirect3DBaseTexture9 **)&tex_2d, &ps_3d, 0x00707070, 0x00b2cce5},
         {"3d_2d", (IDirect3DBaseTexture9 **)&volume, &ps_2d, 0x00303030, 0x00b2cce5, TRUE, 0x00202020},
     };
 
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 73acb65a19..4561eb95ff 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -4023,6 +4023,39 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
             }
         }
     }
+    else if (shader->reg_maps.shader_version.major <= 3)
+    {
+        for (i = 0; i < shader->limits->sampler; ++i)
+        {
+            enum wined3d_shader_resource_type resource_type;
+            enum wined3d_shader_tex_types tex_type;
+
+            if (!(resource_type = shader->reg_maps.resource_info[i].type))
+                continue;
+
+            switch (resource_type)
+            {
+                case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
+                    tex_type = WINED3D_SHADER_TEX_3D;
+                    break;
+                case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
+                    tex_type = WINED3D_SHADER_TEX_CUBE;
+                    break;
+                default:
+                    tex_type = WINED3D_SHADER_TEX_2D;
+                    break;
+            }
+
+            if ((texture = state->textures[i]))
+            {
+                if (texture->resource.type == WINED3D_RTYPE_TEXTURE_2D
+                        && resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_3D
+                        && !(texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP))
+                    tex_type = WINED3D_SHADER_TEX_2D;
+            }
+            args->tex_types |= tex_type << i * WINED3D_PSARGS_TEXTYPE_SHIFT;
+        }
+    }
 
     if (shader->reg_maps.shader_version.major >= 4)
     {
@@ -4221,7 +4254,7 @@ static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_d
 }
 
 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
-        unsigned int resource_idx, WORD tex_types)
+        unsigned int resource_idx, DWORD tex_types)
 {
     static enum wined3d_shader_resource_type shader_resource_type_from_shader_tex_types[] =
     {
@@ -4232,7 +4265,7 @@ enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct win
 
     unsigned int idx;
 
-    if (reg_maps->shader_version.major != 1)
+    if (reg_maps->shader_version.major > 3)
         return reg_maps->resource_info[resource_idx].type;
 
     if (!reg_maps->resource_info[resource_idx].type)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f9596e9c85..08cd723478 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1372,6 +1372,7 @@ enum wined3d_shader_tex_types
     WINED3D_SHADER_TEX_2D   = 0,
     WINED3D_SHADER_TEX_3D   = 1,
     WINED3D_SHADER_TEX_CUBE = 2,
+    WINED3D_SHADER_TEX_ERR  = 3,
 };
 
 struct ps_compile_args
@@ -1379,8 +1380,8 @@ struct ps_compile_args
     struct color_fixup_desc     color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
     enum wined3d_vertex_processing_mode vp_mode;
     enum wined3d_ffp_ps_fog_mode fog;
+    DWORD                       tex_types; /* ps 1 - 3, 16 textures */
     WORD                        tex_transform; /* ps 1.0-1.3, 4 textures */
-    WORD                        tex_types; /* ps 1.0 - 1.4, 6 textures */
     WORD                        srgb_correction;
     /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
        D3D9 has a limit of 16 samplers and the fixup is superfluous
@@ -1388,6 +1389,7 @@ struct ps_compile_args
     WORD                        np2_fixup;
     WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
     WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
+    WORD padding_to_dword;
     DWORD pointsprite : 1;
     DWORD flatshading : 1;
     DWORD alpha_test_func : 3;
@@ -4456,7 +4458,7 @@ struct wined3d_shader
 };
 
 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
-        unsigned int resource_idx, WORD tex_types) DECLSPEC_HIDDEN;
+        unsigned int resource_idx, DWORD tex_types) DECLSPEC_HIDDEN;
 void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
         BOOL position_transformed, struct ps_compile_args *args,
         const struct wined3d_context *context) DECLSPEC_HIDDEN;
-- 
2.21.0




More information about the wine-devel mailing list