wined3d: Fixup 3D sampler when sampling 2D texture for PS models 2 and 3.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2019-07-03 17:56:41 +03:00 committed by Alexandre Julliard
parent 9607a427de
commit 34eeb0a877
3 changed files with 40 additions and 5 deletions

View File

@ -25946,7 +25946,7 @@ static void test_mismatched_sample_types(void)
{ {
{"2d_2d", (IDirect3DBaseTexture9 **)&tex_2d, &ps_2d, 0x00707070}, {"2d_2d", (IDirect3DBaseTexture9 **)&tex_2d, &ps_2d, 0x00707070},
{"3d_3d", (IDirect3DBaseTexture9 **)&volume, &ps_3d, 0x00303030}, {"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}, {"3d_2d", (IDirect3DBaseTexture9 **)&volume, &ps_2d, 0x00303030, 0x00b2cce5, TRUE, 0x00202020},
}; };

View File

@ -4003,6 +4003,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) if (shader->reg_maps.shader_version.major >= 4)
{ {
@ -4201,7 +4234,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, 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[] = static enum wined3d_shader_resource_type shader_resource_type_from_shader_tex_types[] =
{ {
@ -4212,7 +4245,7 @@ enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct win
unsigned int idx; 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; return reg_maps->resource_info[resource_idx].type;
if (!reg_maps->resource_info[resource_idx].type) if (!reg_maps->resource_info[resource_idx].type)

View File

@ -1365,6 +1365,7 @@ enum wined3d_shader_tex_types
WINED3D_SHADER_TEX_2D = 0, WINED3D_SHADER_TEX_2D = 0,
WINED3D_SHADER_TEX_3D = 1, WINED3D_SHADER_TEX_3D = 1,
WINED3D_SHADER_TEX_CUBE = 2, WINED3D_SHADER_TEX_CUBE = 2,
WINED3D_SHADER_TEX_ERR = 3,
}; };
struct ps_compile_args struct ps_compile_args
@ -1372,8 +1373,8 @@ struct ps_compile_args
struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS]; struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
enum wined3d_vertex_processing_mode vp_mode; enum wined3d_vertex_processing_mode vp_mode;
enum wined3d_ffp_ps_fog_mode fog; 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_transform; /* ps 1.0-1.3, 4 textures */
WORD tex_types; /* ps 1.0 - 1.4, 6 textures */
WORD srgb_correction; WORD srgb_correction;
/* Bitmap for NP2 texcoord fixups (16 samplers max currently). /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
D3D9 has a limit of 16 samplers and the fixup is superfluous D3D9 has a limit of 16 samplers and the fixup is superfluous
@ -1381,6 +1382,7 @@ struct ps_compile_args
WORD np2_fixup; WORD np2_fixup;
WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */ WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */ WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
WORD padding_to_dword;
DWORD pointsprite : 1; DWORD pointsprite : 1;
DWORD flatshading : 1; DWORD flatshading : 1;
DWORD alpha_test_func : 3; DWORD alpha_test_func : 3;
@ -4445,7 +4447,7 @@ struct wined3d_shader
}; };
enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps, 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, void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
BOOL position_transformed, struct ps_compile_args *args, BOOL position_transformed, struct ps_compile_args *args,
const struct wined3d_context *context) DECLSPEC_HIDDEN; const struct wined3d_context *context) DECLSPEC_HIDDEN;