wined3d: Improve invalid TEXTURETRANSFORMFLAGS handling.
This commit is contained in:
parent
9d662928f5
commit
472fed41dd
|
@ -1911,20 +1911,46 @@ 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 count, tex_transform;
|
||||
DWORD count, tex_transform = 0;
|
||||
|
||||
/* Filter some invalid flags */
|
||||
count = flags & ~WINED3DTTFF_PROJECTED;
|
||||
if (count > WINED3DTTFF_COUNT4)
|
||||
if (count > WINED3DTTFF_COUNT4 || (!(flags & WINED3DTTFF_PROJECTED) && count != 0))
|
||||
{
|
||||
WARN("The application set an invalid TEXTURETRANSFORMFLAGS value.\n");
|
||||
flags = count = 0;
|
||||
WARN("The application set an invalid %#x TEXTURETRANSFORMFLAGS value.\n", flags);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
tex_transform = count;
|
||||
if (flags & WINED3DTTFF_PROJECTED)
|
||||
{
|
||||
enum wined3d_sampler_texture_type sampler_type = shader->reg_maps.sampler_type[i];
|
||||
DWORD max_valid = WINED3DTTFF_COUNT4;
|
||||
|
||||
if (!count)
|
||||
count = WINED3DTTFF_COUNT4;
|
||||
|
||||
if (!state->vertex_shader)
|
||||
{
|
||||
unsigned int j;
|
||||
unsigned int index = state->texture_states[i][WINED3DTSS_TEXCOORDINDEX];
|
||||
for (j = 0; j < state->vertex_declaration->element_count; ++j)
|
||||
{
|
||||
struct wined3d_vertex_declaration_element *element =
|
||||
&state->vertex_declaration->elements[j];
|
||||
|
||||
if (element->usage == WINED3DDECLUSAGE_TEXCOORD
|
||||
&& element->usage_idx == index)
|
||||
{
|
||||
max_valid = element->format->component_count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tex_transform = min(count, max_valid);
|
||||
if (tex_transform != (flags & ~WINED3DTTFF_PROJECTED))
|
||||
WARN("Fixing up %#x projected texture transform flag to %#x.\n",
|
||||
flags & ~WINED3DTTFF_PROJECTED, tex_transform);
|
||||
|
||||
if ((sampler_type == WINED3DSTT_1D && tex_transform > WINED3DTTFF_COUNT1)
|
||||
|| (sampler_type == WINED3DSTT_2D && tex_transform > WINED3DTTFF_COUNT2)
|
||||
|
@ -1933,6 +1959,7 @@ void find_ps_compile_args(const struct wined3d_state *state,
|
|||
else
|
||||
WARN("Application requested projected texture with unsuitable texture coordinates.\n");
|
||||
}
|
||||
tex_transform &= WINED3D_PSARGS_TEXTRANSFORM_MASK;
|
||||
args->tex_transform |= tex_transform << i * WINED3D_PSARGS_TEXTRANSFORM_SHIFT;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue