Commit 43208b63 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Implement fxlc constants (expressions) in effect.

parent 0277ba19
...@@ -193,5 +193,7 @@ struct d3dx_parameter *get_parameter_by_name(struct d3dx9_base_effect *base, ...@@ -193,5 +193,7 @@ struct d3dx_parameter *get_parameter_by_name(struct d3dx9_base_effect *base,
void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code, void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code,
unsigned int byte_code_size, D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval) DECLSPEC_HIDDEN; unsigned int byte_code_size, D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval) DECLSPEC_HIDDEN;
void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN; void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN;
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval,
const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN;
#endif /* __WINE_D3DX9_PRIVATE_H */ #endif /* __WINE_D3DX9_PRIVATE_H */
...@@ -2493,25 +2493,36 @@ static HRESULT d3dx9_base_effect_set_array_range(struct d3dx9_base_effect *base, ...@@ -2493,25 +2493,36 @@ static HRESULT d3dx9_base_effect_set_array_range(struct d3dx9_base_effect *base,
static HRESULT d3dx9_get_param_value_ptr(struct ID3DXEffectImpl *effect, struct d3dx_pass *pass, static HRESULT d3dx9_get_param_value_ptr(struct ID3DXEffectImpl *effect, struct d3dx_pass *pass,
struct d3dx_state *state, void **param_value, struct d3dx_parameter **out_param) struct d3dx_state *state, void **param_value, struct d3dx_parameter **out_param)
{ {
struct d3dx_parameter *param; struct d3dx_parameter *param = &state->parameter;
param = state->parameter.referenced_param ? state->parameter.referenced_param : &state->parameter;
*param_value = NULL;
*out_param = NULL;
switch (state->type) switch (state->type)
{ {
case ST_CONSTANT:
case ST_PARAMETER: case ST_PARAMETER:
*param_value = param->data; param = param->referenced_param;
/* fallthrough */
case ST_CONSTANT:
*out_param = param; *out_param = param;
*param_value = param->data;
return D3D_OK; return D3D_OK;
case ST_ARRAY_SELECTOR: case ST_ARRAY_SELECTOR:
FIXME("Array selector.\n"); FIXME("Array selector.\n");
break; break;
case ST_FXLC: case ST_FXLC:
FIXME("FXLC not supported yet.\n"); if (param->param_eval)
break; {
*out_param = param;
*param_value = param->data;
return d3dx_evaluate_parameter(param->param_eval, param, *param_value);
}
else
{
FIXME("No preshader for FXLC parameter.\n");
return D3DERR_INVALIDCALL;
}
} }
*param_value = NULL;
*out_param = NULL;
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -2524,19 +2535,19 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void ...@@ -2524,19 +2535,19 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void
} }
light_tbl[] = light_tbl[] =
{ {
{FIELD_OFFSET(D3DLIGHT9, Type), "LC_TYPE"}, {FIELD_OFFSET(D3DLIGHT9, Type), "LC_TYPE"},
{FIELD_OFFSET(D3DLIGHT9, Diffuse), "LT_DIFFUSE"}, {FIELD_OFFSET(D3DLIGHT9, Diffuse), "LT_DIFFUSE"},
{FIELD_OFFSET(D3DLIGHT9, Specular), "LT_SPECULAR"}, {FIELD_OFFSET(D3DLIGHT9, Specular), "LT_SPECULAR"},
{FIELD_OFFSET(D3DLIGHT9, Ambient), "LT_AMBIENT"}, {FIELD_OFFSET(D3DLIGHT9, Ambient), "LT_AMBIENT"},
{FIELD_OFFSET(D3DLIGHT9, Position), "LT_POSITION"}, {FIELD_OFFSET(D3DLIGHT9, Position), "LT_POSITION"},
{FIELD_OFFSET(D3DLIGHT9, Direction), "LT_DIRECTION"}, {FIELD_OFFSET(D3DLIGHT9, Direction), "LT_DIRECTION"},
{FIELD_OFFSET(D3DLIGHT9, Range), "LT_RANGE"}, {FIELD_OFFSET(D3DLIGHT9, Range), "LT_RANGE"},
{FIELD_OFFSET(D3DLIGHT9, Falloff), "LT_FALLOFF"}, {FIELD_OFFSET(D3DLIGHT9, Falloff), "LT_FALLOFF"},
{FIELD_OFFSET(D3DLIGHT9, Attenuation0), "LT_ATTENUATION0"}, {FIELD_OFFSET(D3DLIGHT9, Attenuation0), "LT_ATTENUATION0"},
{FIELD_OFFSET(D3DLIGHT9, Attenuation1), "LT_ATTENUATION1"}, {FIELD_OFFSET(D3DLIGHT9, Attenuation1), "LT_ATTENUATION1"},
{FIELD_OFFSET(D3DLIGHT9, Attenuation2), "LT_ATTENUATION2"}, {FIELD_OFFSET(D3DLIGHT9, Attenuation2), "LT_ATTENUATION2"},
{FIELD_OFFSET(D3DLIGHT9, Theta), "LT_THETA"}, {FIELD_OFFSET(D3DLIGHT9, Theta), "LT_THETA"},
{FIELD_OFFSET(D3DLIGHT9, Phi), "LT_PHI"} {FIELD_OFFSET(D3DLIGHT9, Phi), "LT_PHI"}
}; };
switch (op) switch (op)
{ {
...@@ -2550,8 +2561,8 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void ...@@ -2550,8 +2561,8 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void
{ {
D3DCOLORVALUE c = *(D3DCOLORVALUE *)value; D3DCOLORVALUE c = *(D3DCOLORVALUE *)value;
TRACE("%s (%f %f %f %f).\n", light_tbl[op].name, c.r, c.g, c.b, c.a); TRACE("%s (%.8e %.8e %.8e %.8e).\n", light_tbl[op].name, c.r, c.g, c.b, c.a);
*(D3DCOLORVALUE *)((char *)light + light_tbl[op].offset) = c; *(D3DCOLORVALUE *)((BYTE *)light + light_tbl[op].offset) = c;
break; break;
} }
case LT_POSITION: case LT_POSITION:
...@@ -2559,8 +2570,8 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void ...@@ -2559,8 +2570,8 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void
{ {
D3DVECTOR v = *(D3DVECTOR *)value; D3DVECTOR v = *(D3DVECTOR *)value;
TRACE("%s (%f %f %f).\n", light_tbl[op].name, v.x, v.y, v.z); TRACE("%s (%.8e %.8e %.8e).\n", light_tbl[op].name, v.x, v.y, v.z);
*(D3DVECTOR *)((char *)light + light_tbl[op].offset) = v; *(D3DVECTOR *)((BYTE *)light + light_tbl[op].offset) = v;
break; break;
} }
case LT_RANGE: case LT_RANGE:
...@@ -2572,8 +2583,8 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void ...@@ -2572,8 +2583,8 @@ static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void
case LT_PHI: case LT_PHI:
{ {
float v = *(float *)value; float v = *(float *)value;
TRACE("%s %f.\n", light_tbl[op].name, v); TRACE("%s %.8e.\n", light_tbl[op].name, v);
*(float *)((char *)light + light_tbl[op].offset) = v; *(float *)((BYTE *)light + light_tbl[op].offset) = v;
break; break;
} }
default: default:
...@@ -2591,11 +2602,11 @@ static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op, D3DMATERIAL9 *ma ...@@ -2591,11 +2602,11 @@ static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op, D3DMATERIAL9 *ma
} }
material_tbl[] = material_tbl[] =
{ {
{FIELD_OFFSET(D3DMATERIAL9, Diffuse), "MT_DIFFUSE"}, {FIELD_OFFSET(D3DMATERIAL9, Diffuse), "MT_DIFFUSE"},
{FIELD_OFFSET(D3DMATERIAL9, Ambient), "MT_AMBIENT"}, {FIELD_OFFSET(D3DMATERIAL9, Ambient), "MT_AMBIENT"},
{FIELD_OFFSET(D3DMATERIAL9, Specular), "MT_SPECULAR"}, {FIELD_OFFSET(D3DMATERIAL9, Specular), "MT_SPECULAR"},
{FIELD_OFFSET(D3DMATERIAL9, Emissive), "MT_EMISSIVE"}, {FIELD_OFFSET(D3DMATERIAL9, Emissive), "MT_EMISSIVE"},
{FIELD_OFFSET(D3DMATERIAL9, Power), "MT_POWER"} {FIELD_OFFSET(D3DMATERIAL9, Power), "MT_POWER"}
}; };
switch (op) switch (op)
...@@ -2604,7 +2615,7 @@ static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op, D3DMATERIAL9 *ma ...@@ -2604,7 +2615,7 @@ static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op, D3DMATERIAL9 *ma
{ {
float v = *(float *)value; float v = *(float *)value;
TRACE("%s %f.\n", material_tbl[op].name, v); TRACE("%s %.8e.\n", material_tbl[op].name, v);
material->Power = v; material->Power = v;
break; break;
} }
...@@ -2615,8 +2626,8 @@ static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op, D3DMATERIAL9 *ma ...@@ -2615,8 +2626,8 @@ static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op, D3DMATERIAL9 *ma
{ {
D3DCOLORVALUE c = *(D3DCOLORVALUE *)value; D3DCOLORVALUE c = *(D3DCOLORVALUE *)value;
TRACE("%s, value (%f %f %f %f).\n", material_tbl[op].name, c.r, c.g, c.b, c.a); TRACE("%s, value (%.8e %.8e %.8e %.8e).\n", material_tbl[op].name, c.r, c.g, c.b, c.a);
*(D3DCOLORVALUE *)((char *)material + material_tbl[op].offset) = c; *(D3DCOLORVALUE *)((BYTE *)material + material_tbl[op].offset) = c;
break; break;
} }
default: default:
......
...@@ -2917,7 +2917,7 @@ static void test_effect_states(IDirect3DDevice9 *device) ...@@ -2917,7 +2917,7 @@ static void test_effect_states(IDirect3DDevice9 *device)
ok(!memcmp(mat.m, test_mat.m, sizeof(mat)), "World matrix does not match.\n"); ok(!memcmp(mat.m, test_mat.m, sizeof(mat)), "World matrix does not match.\n");
hr = effect->lpVtbl->BeginPass(effect, 0); hr = effect->lpVtbl->BeginPass(effect, 0);
todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLDMATRIX(1), &mat); hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLDMATRIX(1), &mat);
ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
...@@ -2925,7 +2925,7 @@ static void test_effect_states(IDirect3DDevice9 *device) ...@@ -2925,7 +2925,7 @@ static void test_effect_states(IDirect3DDevice9 *device)
hr = IDirect3DDevice9_GetTransform(device, D3DTS_VIEW, &mat); hr = IDirect3DDevice9_GetTransform(device, D3DTS_VIEW, &mat);
ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
todo_wine ok(!memcmp(mat.m, test_mat_camera.m, sizeof(mat)), "View matrix does not match.\n"); ok(!memcmp(mat.m, test_mat_camera.m, sizeof(mat)), "View matrix does not match.\n");
hr = IDirect3DDevice9_GetRenderState(device, D3DRS_BLENDOP, &value); hr = IDirect3DDevice9_GetRenderState(device, D3DRS_BLENDOP, &value);
ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
......
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