[v3 5/7] d3dx9: implement sampler and texture effect states application.
Paul Gofman
gofmanp at gmail.com
Thu Mar 3 06:22:13 CST 2016
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
dlls/d3dx9_36/effect.c | 41 +++++++++++++++++++++++++++++++++++++++--
dlls/d3dx9_36/tests/effect.c | 2 +-
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index e1f01f2..6813c79 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -2681,7 +2681,8 @@ 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;
@@ -2702,10 +2703,46 @@ 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 unit;
+
+ unit = parent_index == -1 ? state->index : parent_index;
+ TRACE("%s, unit %u, value %p.\n", state_table[state->operation].name, unit,
+ *(IDirect3DBaseTexture9 **)param_value);
+ return IDirect3DDevice9_SetTexture(device, unit, *(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;
+ unsigned 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, value %u.\n", state_table[state->operation].name, sampler, *(DWORD *)param_value);
+ return IDirect3DDevice9_SetSamplerState(device, sampler, state_table[state->operation].op,
+ *(DWORD *)param_value);
+ }
case SC_VERTEXSHADER:
TRACE("%s, shader %p.\n", state_table[state->operation].name, *(IDirect3DVertexShader9 **)param_value);
hr = IDirect3DDevice9_SetVertexShader(device, *(IDirect3DVertexShader9 **)param_value);
@@ -2784,7 +2821,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, hr %#x.\n", hr);
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index a1be37f..916f69a 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -2936,7 +2936,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-patches
mailing list