[PATCH] d3d11: Honor render state FrontCounterClockwise.

Józef Kucia joseph.kucia at gmail.com
Sun May 22 07:29:26 CDT 2016


On Sun, May 22, 2016 at 1:32 PM, Johannes Brandstätter <jbrandst at 2ds.eu> wrote:
> This fixes geometry flickering in Unigine's Valley and Heaven bechmarks.
> The user interface would at least show some parts, but using this patch
> it completly vanishes as well as the credits image upon closing.
>
> Signed-off-by: Johannes Brandstätter <jbrandst at 2ds.eu>
> ---
>  dlls/d3d11/device.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
> index 7fb28ac..d54f81f 100644
> --- a/dlls/d3d11/device.c
> +++ b/dlls/d3d11/device.c
> @@ -808,10 +808,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
>
>      desc = &device->rasterizer_state->desc;
>      wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_FILLMODE, desc->FillMode);
> -    wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
>      /* glFrontFace() */
>      if (desc->FrontCounterClockwise)
> -        FIXME("Ignoring FrontCounterClockwise %#x.\n", desc->FrontCounterClockwise);
> +        wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_CCW);
> +    else
> +        wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
>      /* OpenGL style depth bias. */
>      if (desc->DepthBias || desc->SlopeScaledDepthBias)
>          FIXME("Ignoring depth bias.\n");
> --
> 2.8.1
>
>
>

This patch doesn't make sense. The FrontCounterClockwise field needs
to be mapped to glFrontFace(). The best what you can get using the
current wined3d API is to invert the cull mode when
FrontCounterClockwise is true.

if (desc->FrontCounterClockwise)
{
    switch (desc->CullMode)
    {
        default:
        case D3D11_CULL_NONE:
            cullmode = WINED3D_CULL_NONE;
            break;
        case D3D11_CULL_FRONT:
            cullmode = WINED3D_CULL_CCW;
            break;
        case D3D11_CULL_BACK:
            cullmode = WINED3D_CULL_CW;
            break;
}

This still is not a proper solution because the front face property
can be read in shaders, see the SV_IsFrontFace system-value semantic.
The proper solution is to introduce a rasterizer state object in
wined3d API. You could probably start with a rasterizer state object
containing a single property for FrontCounterClockwise.



More information about the wine-devel mailing list