From 68e0cd430f2e57e55278acd2422127330628eb6d Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Mon, 12 Dec 2011 20:25:17 +0100 Subject: [PATCH] wined3d: Ignore invalid texture transform flags. --- dlls/wined3d/shader.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 11be333757d..482375009e0 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1911,9 +1911,28 @@ void find_ps_compile_args(const struct wined3d_state *state, for (i = 0; i < 4; ++i) { DWORD flags = state->texture_states[i][WINED3DTSS_TEXTURETRANSFORMFLAGS]; - DWORD tex_transform = flags & ~WINED3DTTFF_PROJECTED; + DWORD count, tex_transform; + + /* Filter some invalid flags */ + count = flags & ~WINED3DTTFF_PROJECTED; + if (count > WINED3DTTFF_COUNT4) + { + WARN("The application set an invalid TEXTURETRANSFORMFLAGS value.\n"); + flags = count = 0; + } + + tex_transform = count; if (flags & WINED3DTTFF_PROJECTED) - tex_transform |= WINED3D_PSARGS_PROJECTED; + { + enum wined3d_sampler_texture_type sampler_type = shader->reg_maps.sampler_type[i]; + + if ((sampler_type == WINED3DSTT_1D && tex_transform > WINED3DTTFF_COUNT1) + || (sampler_type == WINED3DSTT_2D && tex_transform > WINED3DTTFF_COUNT2) + || (sampler_type == WINED3DSTT_VOLUME && tex_transform > WINED3DTTFF_COUNT3)) + tex_transform |= WINED3D_PSARGS_PROJECTED; + else + WARN("Application requested projected texture with unsuitable texture coordinates.\n"); + } args->tex_transform |= tex_transform << i * WINED3D_PSARGS_TEXTRANSFORM_SHIFT; } }