[PATCH 5/5] wined3d: Alpha test emulation for core profile contexts.
matteo.mystral at gmail.com
Wed Apr 6 08:48:10 CDT 2016
2016-04-01 12:01 GMT+02:00 Henri Verbeet <hverbeet at gmail.com>:
> On 1 April 2016 at 01:48, Matteo Bruni <matteo.mystral at gmail.com> wrote:
>> The advantage is to avoid creating two shader variants for alpha test
>> enabled vs disabled and flipping between the two when the
>> WINED3D_RS_ALPHATESTENABLE state is toggled. I only have some limited
>> empiric evidence but it seems like changing the alpha test function is
>> very rare in practice while toggling the alpha test enabled / disabled
>> is relatively common.
> Does that happen with a lot of different shaders though? I.e., if the
> draws with enabled alpha test use different shaders than the ones with
> disabled alpha test it doesn't really matter. Perhaps more importantly
> though, are you sure having discard() in the shader doesn't end up
> disabling HiZ/HiS in some cases?
Right, discard() might disable HiZ or other depth / stencil
optimizations and that seems like a good enough reason on its own for
mapping disabled alpha test to WINED3D_CMP_ALWAYS.
WRT alpha test usage patterns, I tested a few games I had around. The
Witcher was one of the games I used when I wrote the first version of
this patch and, as I recalled, it often toggles ALPHATESTENABLED
between individual draws. But actually it also makes a lot of state
changes on average (many of them redundant like flipping
ALPHATESTENABLE multiple times between 2 draws...) and as a result the
selected GLSL program changes very often. Bottom line is, we might
avoid a handful of shader switches but very little in the big picture.
None of the other games I tried have shown much in avoided shader
switching with the current patch either (with the Blizzard launcher
really being the only application triggering it in a noticeable
amount). I guess dropping the alpha_test uniform it is.
More information about the wine-devel