[v2 5/6] d3dx9: implement sampler and texture effect states application.

Matteo Bruni matteo.mystral at gmail.com
Wed Mar 2 10:11:15 CST 2016


2016-03-01 18:10 GMT+01:00 Paul Gofman <gofmanp at gmail.com>:
> Signed-off-by: Paul Gofman <gofmanp at gmail.com>
> ---
>  dlls/d3dx9_36/effect.c       | 37 +++++++++++++++++++++++++++++++++++--
>  dlls/d3dx9_36/tests/effect.c |  2 +-
>  2 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
> index decc048..8a359d0 100644
> --- a/dlls/d3dx9_36/effect.c
> +++ b/dlls/d3dx9_36/effect.c
> @@ -2676,7 +2676,7 @@ HRESULT d3dx_set_shader_const_state(IDirect3DDevice9 *device, enum SHADER_CONSTA
>      return D3D_OK;
>  }
>
> -static HRESULT d3dx9_apply_state(struct ID3DXEffectImpl *effect, struct d3dx_pass *pass, struct d3dx_state *state)
> +static HRESULT d3dx9_apply_state(struct ID3DXEffectImpl *effect, struct d3dx_pass *pass, struct d3dx_state *state, int parent_index)
>  {
>      IDirect3DDevice9 *device = effect->device;
>      struct d3dx_parameter *param;
> @@ -2696,9 +2696,42 @@ static HRESULT d3dx9_apply_state(struct ID3DXEffectImpl *effect, struct d3dx_pas
>          case SC_FVF:
>              TRACE("%s: value %#x.\n", state_table[state->operation].name, *(DWORD *)param_value);
>              return IDirect3DDevice9_SetFVF(device, *(DWORD *)param_value);
> +        case SC_TEXTURE:
> +        {
> +            UINT sampler;

Technically this would be a texture unit (or texture stage) more than
a sampler index.

> +
> +            sampler = parent_index == -1 ? state->index : parent_index;
> +            TRACE("%s: sampler %u value %p.\n", state_table[state->operation].name, sampler, *(IDirect3DBaseTexture9 **)param_value);
> +            return IDirect3DDevice9_SetTexture(device, sampler, *(IDirect3DBaseTexture9 **)param_value);
> +        }
>          case SC_TEXTURESTAGE:
>              TRACE("%s: stage %u value %u.\n", state_table[state->operation].name, state->index, *(DWORD *)param_value);
>              return IDirect3DDevice9_SetTextureStageState(device, state->index, state_table[state->operation].op, *(DWORD *)param_value);
> +        case SC_SETSAMPLER:
> +        {
> +            struct d3dx_sampler *sampler;
> +            HRESULT ret, hr;
> +            int i;
> +
> +            sampler = (struct d3dx_sampler *)param_value;
> +            TRACE("%s: sampler %u applying %u states.\n", state_table[state->operation].name, state->index, sampler->state_count);
> +            ret = D3D_OK;
> +            for (i = 0; i < sampler->state_count; i++)
> +            {
> +                hr = d3dx9_apply_state(effect, pass, &sampler->states[i], state->index);
> +                if (FAILED(hr))
> +                    ret = hr;
> +            }
> +            return ret;
> +        }
> +        case SC_SAMPLERSTATE:
> +        {
> +            UINT sampler;
> +
> +            sampler = parent_index == -1 ? state->index : parent_index;
> +            TRACE("%s sampler %u:%u.\n", state_table[state->operation].name, sampler, *(DWORD *)param_value);

Please use the same trace style you're using for the other states.

> +            return IDirect3DDevice9_SetSamplerState(device, sampler, state_table[state->operation].op, *(DWORD *)param_value);
> +        }
>          case SC_VERTEXSHADER:
>              TRACE("%s vertex shader %p.\n", state_table[state->operation].name, *(IDirect3DVertexShader9 **)param_value);
>              hr = IDirect3DDevice9_SetVertexShader(device, *(IDirect3DVertexShader9 **)param_value);
> @@ -2772,7 +2805,7 @@ static HRESULT d3dx9_apply_pass_states(struct ID3DXEffectImpl *effect, struct d3
>      {
>          HRESULT hr;
>
> -        hr = d3dx9_apply_state(effect, pass, &pass->states[i]);
> +        hr = d3dx9_apply_state(effect, pass, &pass->states[i], -1);
>          if (FAILED(hr))
>          {
>              WARN("Error applying state: %#x.\n", hr);
> diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
> index 3184f26..a052bce 100644
> --- a/dlls/d3dx9_36/tests/effect.c
> +++ b/dlls/d3dx9_36/tests/effect.c
> @@ -2929,7 +2929,7 @@ static void test_effect_states(IDirect3DDevice9 *device)
>
>      hr = IDirect3DDevice9_GetSamplerState(device, 1, D3DSAMP_MIPFILTER, &value);
>      ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
> -    todo_wine ok(value == D3DTEXF_LINEAR, "Unexpected sampler 1 mipfilter %u.\n", value);
> +    ok(value == D3DTEXF_LINEAR, "Unexpected sampler 1 mipfilter %u.\n", value);
>
>      hr = IDirect3DDevice9_GetTextureStageState(device, 3, D3DTSS_ALPHAOP, &value);
>      ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
> --
> 2.5.0



More information about the wine-devel mailing list