Commit 1e968480 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Introduce a texture_binding_might_invalidate_ps() helper.

Make a complex conditional a bit easier to read.
parent 707198ba
......@@ -1454,6 +1454,34 @@ void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_cont
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
static bool texture_binding_might_invalidate_ps(struct wined3d_texture *texture,
struct wined3d_texture *prev, const struct wined3d_d3d_info *d3d_info)
{
const struct wined3d_format *old_format, *new_format;
unsigned int old_caps, new_caps;
if (!prev)
return true;
if (wined3d_texture_gl(texture)->target != wined3d_texture_gl(prev)->target)
return true;
old_format = prev->resource.format;
new_format = texture->resource.format;
old_caps = prev->resource.format_caps;
new_caps = texture->resource.format_caps;
if ((old_caps & WINED3D_FORMAT_CAP_SHADOW) != (new_caps & WINED3D_FORMAT_CAP_SHADOW))
return true;
if (is_same_fixup(old_format->color_fixup, new_format->color_fixup))
return false;
if (can_use_texture_swizzle(d3d_info, new_format) && can_use_texture_swizzle(d3d_info, old_format))
return false;
return true;
}
static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_d3d_info *d3d_info = &cs->c.device->adapter->d3d_info;
......@@ -1466,18 +1494,10 @@ static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data)
if (op->texture)
{
const struct wined3d_format *new_format = op->texture->resource.format;
const struct wined3d_format *old_format = prev ? prev->resource.format : NULL;
unsigned int old_fmt_caps = prev ? prev->resource.format_caps : 0;
unsigned int new_fmt_caps = op->texture->resource.format_caps;
if (InterlockedIncrement(&op->texture->resource.bind_count) == 1)
op->texture->sampler = op->stage;
if (!prev || wined3d_texture_gl(op->texture)->target != wined3d_texture_gl(prev)->target
|| (!is_same_fixup(new_format->color_fixup, old_format->color_fixup)
&& !(can_use_texture_swizzle(d3d_info, new_format) && can_use_texture_swizzle(d3d_info, old_format)))
|| (new_fmt_caps & WINED3D_FORMAT_CAP_SHADOW) != (old_fmt_caps & WINED3D_FORMAT_CAP_SHADOW))
if (texture_binding_might_invalidate_ps(op->texture, prev, d3d_info))
device_invalidate_state(cs->c.device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL));
if (!prev && op->stage < d3d_info->ffp_fragment_caps.max_blend_stages)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment