ReactOS  0.4.15-dev-341-g17c5fb8
effect.c File Reference
#include "initguid.h"
#include <limits.h>
#include "wine/test.h"
#include "d3dx9.h"
Include dependency graph for effect.c:

Go to the source code of this file.

Classes

struct  test_effect_parameter_value_result
 
struct  test_state_manager_update
 
struct  test_manager
 
struct  d3dxinclude
 

Macros

#define COBJMACROS
 
#define INFINITY   __port_infinity()
 
#define NAN   get_nan()
 
#define ADD_PARAMETER_VALUE(x)
 
#define EFFECT_PARAMETER_VALUE_ARRAY_SIZE   48
 
#define INT_FLOAT_MULTI   255.0f
 
#define INT_FLOAT_MULTI_INVERSE   (1/INT_FLOAT_MULTI)
 
#define TEST_EFFECT_STATES_VSHADER_POS   315
 
#define TEST_EFFECT_PRESHADER_VSHADER_POS   2991
 
#define TEST_EFFECT_PRESHADER_VSHADER_LEN   13
 
#define test_effect_preshader_compare_shader_bytecode(a, b, c, d)   test_effect_preshader_compare_shader_bytecode_(__LINE__, a, b, c, d)
 
#define test_effect_preshader_compare_shader(a, b, c)   test_effect_preshader_compare_shader_(__LINE__, a, b, c)
 
#define test_effect_preshader_op_results(a, b, c)   test_effect_preshader_op_results_(__LINE__, a, b, c)
 
#define TEST_EFFECT_BITMASK_BLOCK_SIZE   (sizeof(unsigned int) * 8)
 
#define test_effect_preshader_compare_vconsts(a, b, c)   test_effect_preshader_compare_vconsts_(__LINE__, a, b, c)
 
#define test_effect_preshader_compare_pbool_consts(a, b, c)   test_effect_preshader_compare_pbool_consts_(__LINE__, a, b, c)
 
#define test_isparameterused_param_with_children(args...)   test_isparameterused_param_with_children_(__LINE__, args)
 
#define INITIAL_UPDATE_RECORD_SIZE   64
 
#define test_effect_shared_vs_arr_compare_helper(args...)   test_effect_shared_vs_arr_compare_helper_(__LINE__, args)
 
#define test_effect_shared_parameters_compare_vconst(args...)   test_effect_shared_parameters_compare_vconst_(__LINE__, args)
 
#define TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_POS   81
 
#define TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_LEN   14
 

Enumerations

enum  expected_state_update { EXPECTED_STATE_ZERO, EXPECTED_STATE_UPDATED, EXPECTED_STATE_ANYTHING }
 

Functions

static float __port_infinity (void)
 
static float get_nan (void)
 
static BOOL compare_float (FLOAT f, FLOAT g, UINT ulps)
 
static INT get_int (D3DXPARAMETER_TYPE type, const void *data)
 
static float get_float (D3DXPARAMETER_TYPE type, const void *data)
 
static BOOL get_bool (const void *data)
 
static void set_number (void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
 
static IDirect3DDevice9 * create_device (HWND *window)
 
static BOOL create_file (const char *filename, const char *data, const unsigned int size, char *out_path)
 
static void delete_file (const char *filename)
 
static BOOL create_directory (const char *name)
 
static void delete_directory (const char *name)
 
static void test_create_effect_and_pool (IDirect3DDevice9 *device)
 
static void test_create_effect_compiler (void)
 
static void test_effect_parameter_value_GetValue (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetBool (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetBoolArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetInt (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetIntArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetFloat (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetFloatArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetVector (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetVectorArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetMatrix (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetMatrixArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetMatrixPointerArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetMatrixTranspose (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetMatrixTransposeArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetMatrixTransposePointerArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_GetTestGroup (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value_ResetValue (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
 
static void test_effect_parameter_value (IDirect3DDevice9 *device)
 
static void test_effect_setvalue_object (IDirect3DDevice9 *device)
 
static void test_effect_variable_names (IDirect3DDevice9 *device)
 
static void test_effect_compilation_errors (IDirect3DDevice9 *device)
 
static void test_effect_clear_vconsts (IDirect3DDevice9 *device)
 
static void test_effect_states (IDirect3DDevice9 *device)
 
static void test_effect_preshader_compare_shader_bytecode_ (unsigned int line, const DWORD *bytecode, unsigned int bytecode_size, int expected_shader_index, BOOL todo)
 
static void test_effect_preshader_compare_shader_ (unsigned int line, IDirect3DDevice9 *device, int expected_shader_index, BOOL todo)
 
static void test_effect_preshader_op_results_ (unsigned int line, IDirect3DDevice9 *device, const enum expected_state_update *expected_state, const char *updated_param)
 
static void test_effect_preshader_compare_vconsts_ (unsigned int line, IDirect3DDevice9 *device, const unsigned int *const_updated_mask, const char *updated_param)
 
static void test_effect_preshader_clear_pbool_consts (IDirect3DDevice9 *device)
 
static void test_effect_preshader_compare_pbool_consts_ (unsigned int line, IDirect3DDevice9 *device, const unsigned int *const_updated_mask, const char *updated_param)
 
static void test_effect_preshader (IDirect3DDevice9 *device)
 
static void test_effect_preshader_ops (IDirect3DDevice9 *device)
 
static void test_isparameterused_children (unsigned int line, ID3DXEffect *effect, D3DXHANDLE tech, D3DXHANDLE param)
 
static void test_isparameterused_param_with_children_ (unsigned int line, ID3DXEffect *effect, ID3DXEffect *effect2, D3DXHANDLE tech, const char *name, BOOL expected_result)
 
static void test_effect_isparameterused (IDirect3DDevice9 *device)
 
static void test_effect_out_of_bounds_selector (IDirect3DDevice9 *device)
 
static void test_effect_commitchanges (IDirect3DDevice9 *device)
 
static void test_effect_preshader_relative_addressing (IDirect3DDevice9 *device)
 
static struct test_managerimpl_from_ID3DXEffectStateManager (ID3DXEffectStateManager *iface)
 
static void free_test_effect_state_manager (struct test_manager *state_manager)
 
static ULONG WINAPI test_manager_AddRef (ID3DXEffectStateManager *iface)
 
static ULONG WINAPI test_manager_Release (ID3DXEffectStateManager *iface)
 
static HRESULT test_process_set_state (ID3DXEffectStateManager *iface, unsigned int state_op, DWORD param1, DWORD param2)
 
static HRESULT WINAPI test_manager_SetTransform (ID3DXEffectStateManager *iface, D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix)
 
static HRESULT WINAPI test_manager_SetMaterial (ID3DXEffectStateManager *iface, const D3DMATERIAL9 *material)
 
static HRESULT WINAPI test_manager_SetLight (ID3DXEffectStateManager *iface, DWORD index, const D3DLIGHT9 *light)
 
static HRESULT WINAPI test_manager_LightEnable (ID3DXEffectStateManager *iface, DWORD index, BOOL enable)
 
static HRESULT WINAPI test_manager_SetRenderState (ID3DXEffectStateManager *iface, D3DRENDERSTATETYPE state, DWORD value)
 
static HRESULT WINAPI test_manager_SetTexture (ID3DXEffectStateManager *iface, DWORD stage, struct IDirect3DBaseTexture9 *texture)
 
static HRESULT WINAPI test_manager_SetTextureStageState (ID3DXEffectStateManager *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD value)
 
static HRESULT WINAPI test_manager_SetSamplerState (ID3DXEffectStateManager *iface, DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value)
 
static HRESULT WINAPI test_manager_SetNPatchMode (ID3DXEffectStateManager *iface, FLOAT num_segments)
 
static HRESULT WINAPI test_manager_SetFVF (ID3DXEffectStateManager *iface, DWORD format)
 
static HRESULT WINAPI test_manager_SetVertexShader (ID3DXEffectStateManager *iface, struct IDirect3DVertexShader9 *shader)
 
static HRESULT WINAPI test_manager_SetVertexShaderConstantF (ID3DXEffectStateManager *iface, UINT register_index, const FLOAT *constant_data, UINT register_count)
 
static HRESULT WINAPI test_manager_SetVertexShaderConstantI (ID3DXEffectStateManager *iface, UINT register_index, const INT *constant_data, UINT register_count)
 
static HRESULT WINAPI test_manager_SetVertexShaderConstantB (ID3DXEffectStateManager *iface, UINT register_index, const BOOL *constant_data, UINT register_count)
 
static HRESULT WINAPI test_manager_SetPixelShader (ID3DXEffectStateManager *iface, struct IDirect3DPixelShader9 *shader)
 
static HRESULT WINAPI test_manager_SetPixelShaderConstantF (ID3DXEffectStateManager *iface, UINT register_index, const FLOAT *constant_data, UINT register_count)
 
static HRESULT WINAPI test_manager_SetPixelShaderConstantI (ID3DXEffectStateManager *iface, UINT register_index, const INT *constant_data, UINT register_count)
 
static HRESULT WINAPI test_manager_SetPixelShaderConstantB (ID3DXEffectStateManager *iface, UINT register_index, const BOOL *constant_data, UINT register_count)
 
static void test_effect_state_manager_init (struct test_manager *state_manager, IDirect3DDevice9 *device)
 
static int compare_update_record (const void *a, const void *b)
 
static void test_effect_state_manager (IDirect3DDevice9 *device)
 
static void test_cross_effect_handle (IDirect3DDevice9 *device)
 
static void test_effect_shared_vs_arr_compare_helper_ (unsigned int line, ID3DXEffect *effect, D3DXHANDLE param_child, struct IDirect3DVertexShader9 *vshader1, unsigned int element, BOOL todo)
 
static void test_effect_shared_parameters_compare_vconst_ (unsigned int line, IDirect3DDevice9 *device, unsigned int index, const D3DXVECTOR4 *expected_fvect, BOOL todo)
 
static void test_effect_shared_parameters (IDirect3DDevice9 *device)
 
static void test_effect_large_address_aware_flag (IDirect3DDevice9 *device)
 
static void test_effect_get_pass_desc (IDirect3DDevice9 *device)
 
static void test_effect_skip_constants (IDirect3DDevice9 *device)
 
static void test_effect_unsupported_shader (void)
 
static void test_effect_null_shader (void)
 
static void test_effect_clone (void)
 
static unsigned int get_texture_refcount (IDirect3DTexture9 *iface)
 
static void test_refcount (void)
 
static HRESULT WINAPI d3dxinclude_open (ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
 
static HRESULT WINAPI d3dxinclude_close (ID3DXInclude *iface, const void *data)
 
static void test_create_effect_from_file (void)
 
static void test_effect_find_next_valid_technique (void)
 
 START_TEST (effect)
 

Variables

static char temp_path [MAX_PATH]
 
static const char effect_desc []
 
static const DWORD test_effect_parameter_value_blob_float []
 
struct test_effect_parameter_value_result test_effect_parameter_value_result_float []
 
static const DWORD test_effect_parameter_value_blob_int []
 
struct test_effect_parameter_value_result test_effect_parameter_value_result_int []
 
static const DWORD test_effect_parameter_value_blob_object []
 
struct test_effect_parameter_value_result test_effect_parameter_value_result_object []
 
static const DWORD test_effect_parameter_value_blob_special []
 
struct test_effect_parameter_value_result test_effect_parameter_value_result_special []
 
struct {
   const DWORD *   blob
 
   UINT   blob_size
 
   const struct test_effect_parameter_value_result *   res
 
   UINT   res_count
 
test_effect_parameter_value_data []
 
static const DWORD test_effect_variable_names_blob []
 
static const DWORD test_effect_states_effect_blob []
 
static const D3DXVECTOR4 fvect_filler = {-9999.0f, -9999.0f, -9999.0f, -9999.0f}
 
static const DWORD test_effect_preshader_effect_blob []
 
struct {
   const char *   comment
 
   BOOL   todo [4]
 
   unsigned int   result [4]
 
   unsigned int   ulps
 
test_effect_preshader_op_expected []
 
static const D3DXVECTOR4 test_effect_preshader_fvect_v []
 
static const BOOL test_effect_preshader_bconsts []
 
static const DWORD test_effect_preshader_ops_blob []
 
static const chartest_effect_state_manager_state_names []
 
static const DWORD test_effect_shared_parameters_blob []
 
static const DWORD test_effect_skip_constants_blob []
 
static const DWORD test_effect_unsupported_shader_blob []
 
static const DWORD test_effect_null_shader_blob []
 
static const struct ID3DXIncludeVtbl d3dxinclude_vtbl
 
static const DWORD test_two_techniques_blob []
 

Macro Definition Documentation

◆ ADD_PARAMETER_VALUE

#define ADD_PARAMETER_VALUE (   x)
Value:
{\
test_effect_parameter_value_blob_ ## x,\
sizeof(test_effect_parameter_value_blob_ ## x),\
test_effect_parameter_value_result_ ## x,\
ARRAY_SIZE(test_effect_parameter_value_result_ ## x),\
}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Definition at line 990 of file effect.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file effect.c.

◆ EFFECT_PARAMETER_VALUE_ARRAY_SIZE

#define EFFECT_PARAMETER_VALUE_ARRAY_SIZE   48

Definition at line 1015 of file effect.c.

◆ INFINITY

#define INFINITY   __port_infinity()

Definition at line 31 of file effect.c.

◆ INITIAL_UPDATE_RECORD_SIZE

#define INITIAL_UPDATE_RECORD_SIZE   64

Definition at line 6082 of file effect.c.

◆ INT_FLOAT_MULTI

#define INT_FLOAT_MULTI   255.0f

Definition at line 1017 of file effect.c.

◆ INT_FLOAT_MULTI_INVERSE

#define INT_FLOAT_MULTI_INVERSE   (1/INT_FLOAT_MULTI)

Definition at line 1018 of file effect.c.

◆ NAN

#define NAN   get_nan()

Definition at line 41 of file effect.c.

◆ TEST_EFFECT_BITMASK_BLOCK_SIZE

#define TEST_EFFECT_BITMASK_BLOCK_SIZE   (sizeof(unsigned int) * 8)

Definition at line 4466 of file effect.c.

◆ test_effect_preshader_compare_pbool_consts

#define test_effect_preshader_compare_pbool_consts (   a,
  b,
  c 
)    test_effect_preshader_compare_pbool_consts_(__LINE__, a, b, c)

Definition at line 4536 of file effect.c.

◆ test_effect_preshader_compare_shader

#define test_effect_preshader_compare_shader (   a,
  b,
  c 
)    test_effect_preshader_compare_shader_(__LINE__, a, b, c)

Definition at line 4313 of file effect.c.

◆ test_effect_preshader_compare_shader_bytecode

#define test_effect_preshader_compare_shader_bytecode (   a,
  b,
  c,
  d 
)    test_effect_preshader_compare_shader_bytecode_(__LINE__, a, b, c, d)

Definition at line 4286 of file effect.c.

◆ test_effect_preshader_compare_vconsts

#define test_effect_preshader_compare_vconsts (   a,
  b,
  c 
)    test_effect_preshader_compare_vconsts_(__LINE__, a, b, c)

Definition at line 4468 of file effect.c.

◆ test_effect_preshader_op_results

#define test_effect_preshader_op_results (   a,
  b,
  c 
)    test_effect_preshader_op_results_(__LINE__, a, b, c)

Definition at line 4390 of file effect.c.

◆ TEST_EFFECT_PRESHADER_VSHADER_LEN

#define TEST_EFFECT_PRESHADER_VSHADER_LEN   13

Definition at line 4284 of file effect.c.

◆ TEST_EFFECT_PRESHADER_VSHADER_POS

#define TEST_EFFECT_PRESHADER_VSHADER_POS   2991

Definition at line 4283 of file effect.c.

◆ test_effect_shared_parameters_compare_vconst

#define test_effect_shared_parameters_compare_vconst (   args...)    test_effect_shared_parameters_compare_vconst_(__LINE__, args)

Definition at line 6606 of file effect.c.

◆ test_effect_shared_vs_arr_compare_helper

#define test_effect_shared_vs_arr_compare_helper (   args...)    test_effect_shared_vs_arr_compare_helper_(__LINE__, args)

Definition at line 6580 of file effect.c.

◆ TEST_EFFECT_STATES_VSHADER_POS

#define TEST_EFFECT_STATES_VSHADER_POS   315

Definition at line 3011 of file effect.c.

◆ TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_LEN

#define TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_LEN   14

Definition at line 7217 of file effect.c.

◆ TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_POS

#define TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_POS   81

Definition at line 7216 of file effect.c.

◆ test_isparameterused_param_with_children

#define test_isparameterused_param_with_children (   args...)    test_isparameterused_param_with_children_(__LINE__, args)

Definition at line 5151 of file effect.c.

Enumeration Type Documentation

◆ expected_state_update

Enumerator
EXPECTED_STATE_ZERO 
EXPECTED_STATE_UPDATED 
EXPECTED_STATE_ANYTHING 

Definition at line 4383 of file effect.c.

Function Documentation

◆ __port_infinity()

static float __port_infinity ( void  )
inlinestatic

Definition at line 26 of file effect.c.

27 {
28  static const unsigned __inf_bytes = 0x7f800000;
29  return *(const float *)&__inf_bytes;
30 }

◆ compare_float()

static BOOL compare_float ( FLOAT  f,
FLOAT  g,
UINT  ulps 
)
static

Definition at line 45 of file effect.c.

46 {
47  INT x = *(INT *)&f;
48  INT y = *(INT *)&g;
49 
50  if (x < 0)
51  x = INT_MIN - x;
52  if (y < 0)
53  y = INT_MIN - y;
54 
55  if (abs(x - y) > ulps)
56  return FALSE;
57 
58  return TRUE;
59 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:57
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat f
Definition: glext.h:7540
#define INT_MIN
Definition: limits.h:39
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned int ulps
Definition: effect.c:4351

Referenced by test_effect_parameter_value_GetFloat(), test_effect_parameter_value_GetFloatArray(), test_effect_parameter_value_GetMatrix(), test_effect_parameter_value_GetMatrixArray(), test_effect_parameter_value_GetMatrixPointerArray(), test_effect_parameter_value_GetMatrixTranspose(), test_effect_parameter_value_GetMatrixTransposeArray(), test_effect_parameter_value_GetMatrixTransposePointerArray(), test_effect_parameter_value_GetVector(), test_effect_parameter_value_GetVectorArray(), test_effect_preshader_op_results_(), test_effect_preshader_ops(), and test_effect_preshader_relative_addressing().

◆ compare_update_record()

static int compare_update_record ( const void a,
const void b 
)
static

Definition at line 6317 of file effect.c.

6318 {
6319  const struct test_state_manager_update *r1 = (const struct test_state_manager_update *)a;
6320  const struct test_state_manager_update *r2 = (const struct test_state_manager_update *)b;
6321 
6322  if (r1->state_op != r2->state_op)
6323  return r1->state_op - r2->state_op;
6324  if (r1->param1 != r2->param1)
6325  return r1->param1 - r2->param1;
6326  return r1->param2 - r2->param2;
6327 }
static DNS_RECORDW r1
Definition: record.c:37
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
static DNS_RECORDW r2
Definition: record.c:38
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by test_effect_state_manager().

◆ create_device()

static IDirect3DDevice9* create_device ( HWND window)
static

Definition at line 150 of file effect.c.

151 {
152  D3DPRESENT_PARAMETERS present_parameters = { 0 };
153  IDirect3DDevice9 *device;
154  IDirect3D9 *d3d;
155  HRESULT hr;
156  HWND wnd;
157 
158  *window = NULL;
159 
160  if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
161  640, 480, NULL, NULL, NULL, NULL)))
162  {
163  skip("Couldn't create application window.\n");
164  return NULL;
165  }
166 
167  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
168  {
169  skip("Couldn't create IDirect3D9 object.\n");
170  DestroyWindow(wnd);
171  return NULL;
172  }
173 
174  present_parameters.Windowed = TRUE;
175  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
177  &present_parameters, &device);
178  IDirect3D9_Release(d3d);
179  if (FAILED(hr))
180  {
181  skip("Failed to create IDirect3DDevice9 object %#x.\n", hr);
182  DestroyWindow(wnd);
183  return NULL;
184  }
185 
186  *window = wnd;
187  return device;
188 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI DestroyWindow(_In_ HWND)
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
Definition: devices.h:37
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
smooth NULL
Definition: ftsmooth.c:416
#define D3D_SDK_VERSION
Definition: d3d8.h:56
LONG HRESULT
Definition: typedefs.h:78
static IHTMLWindow2 * window
Definition: events.c:77
#define skip(...)
Definition: atltest.h:64
#define D3DCREATE_HARDWARE_VERTEXPROCESSING
Definition: d3d8.h:45
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128

Referenced by START_TEST(), test_effect_clone(), test_effect_null_shader(), test_effect_unsupported_shader(), and test_refcount().

◆ create_directory()

static BOOL create_directory ( const char name)
static

Definition at line 229 of file effect.c.

230 {
231  char path[MAX_PATH];
232 
234  strcat(path, name);
235  return CreateDirectoryA(path, NULL);
236 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
static char temp_path[MAX_PATH]
Definition: effect.c:190
Definition: name.c:38
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by test_create_effect_from_file().

◆ create_file()

static BOOL create_file ( const char filename,
const char data,
const unsigned int  size,
char out_path 
)
static

Definition at line 192 of file effect.c.

193 {
194  DWORD written;
195  HANDLE hfile;
196  char path[MAX_PATH];
197 
198  if (!*temp_path)
199  GetTempPathA(sizeof(temp_path), temp_path);
200 
202  strcat(path, filename);
204  if (hfile == INVALID_HANDLE_VALUE)
205  return FALSE;
206 
207  if (WriteFile(hfile, data, size, &written, NULL))
208  {
209  CloseHandle(hfile);
210 
211  if (out_path)
212  strcpy(out_path, path);
213  return TRUE;
214  }
215 
216  CloseHandle(hfile);
217  return FALSE;
218 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:407
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
const char * filename
Definition: ioapi.h:135
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static char temp_path[MAX_PATH]
Definition: effect.c:190
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:408

Referenced by test_create_effect_from_file().

◆ d3dxinclude_close()

static HRESULT WINAPI d3dxinclude_close ( ID3DXInclude *  iface,
const void data 
)
static

Definition at line 7682 of file effect.c.

7683 {
7684  HeapFree(GetProcessHeap(), 0, (void *)data);
7685  return S_OK;
7686 }
#define GetProcessHeap()
Definition: compat.h:404
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ d3dxinclude_open()

static HRESULT WINAPI d3dxinclude_open ( ID3DXInclude *  iface,
D3DXINCLUDE_TYPE  include_type,
const char filename,
const void parent_data,
const void **  data,
UINT bytes 
)
static

Definition at line 7604 of file effect.c.

7606 {
7607  static const char include1[] =
7608  "float4 light;\n"
7609  "float4x4 mat;\n"
7610  "float4 color;\n"
7611  "\n"
7612  "struct vs_input\n"
7613  "{\n"
7614  " float4 position : POSITION;\n"
7615  " float3 normal : NORMAL;\n"
7616  "};\n"
7617  "\n"
7618  "struct vs_output\n"
7619  "{\n"
7620  " float4 position : POSITION;\n"
7621  " float4 diffuse : COLOR;\n"
7622  "};\n";
7623  static const char include2[] =
7624  "#include \"include1.h\"\n"
7625  "\n"
7626  "vs_output vs_main(const vs_input v)\n"
7627  "{\n"
7628  " vs_output o;\n"
7629  " const float4 scaled_color = 0.5 * color;\n"
7630  "\n"
7631  " o.position = mul(v.position, mat);\n"
7632  " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
7633  "\n"
7634  " return o;\n"
7635  "}\n";
7636  static const char effect2[] =
7637  "#include \"include\\include2.h\"\n"
7638  "\n"
7639  "technique t\n"
7640  "{\n"
7641  " pass p\n"
7642  " {\n"
7643  " VertexShader = compile vs_2_0 vs_main();\n"
7644  " }\n"
7645  "}\n";
7646  char *buffer;
7647 
7648  trace("filename %s.\n", filename);
7649  trace("parent_data %p: %s.\n", parent_data, parent_data ? (char *)parent_data : "(null)");
7650 
7651  if (!strcmp(filename, "effect2.fx"))
7652  {
7653  buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(effect2));
7654  memcpy(buffer, effect2, sizeof(effect2));
7655  *bytes = sizeof(effect2);
7656  ok(!parent_data, "Unexpected parent_data value.\n");
7657  }
7658  else if (!strcmp(filename, "include1.h"))
7659  {
7660  buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include1));
7661  memcpy(buffer, include1, sizeof(include1));
7662  *bytes = sizeof(include1);
7663  ok(!strncmp(parent_data, include2, strlen(include2)), "Unexpected parent_data value.\n");
7664  }
7665  else if (!strcmp(filename, "include\\include2.h"))
7666  {
7667  buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2));
7668  memcpy(buffer, include2, sizeof(include2));
7669  *bytes = sizeof(include2);
7670  todo_wine ok(parent_data && !strncmp(parent_data, effect2, strlen(effect2)),
7671  "unexpected parent_data value.\n");
7672  }
7673  else
7674  {
7675  ok(0, "Unexpected #include for file %s.\n", filename);
7676  return D3DERR_INVALIDCALL;
7677  }
7678  *data = buffer;
7679  return S_OK;
7680 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:135
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define GetProcessHeap()
Definition: compat.h:404
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define todo_wine
Definition: test.h:162
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

◆ delete_directory()

static void delete_directory ( const char name)
static

Definition at line 238 of file effect.c.

239 {
240  char path[MAX_PATH];
241 
243  strcat(path, name);
245 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define MAX_PATH
Definition: compat.h:26
static char temp_path[MAX_PATH]
Definition: effect.c:190
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
Definition: name.c:38
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by test_create_effect_from_file().

◆ delete_file()

static void delete_file ( const char filename)
static

Definition at line 220 of file effect.c.

221 {
222  char path[MAX_PATH];
223 
225  strcat(path, filename);
226  DeleteFileA(path);
227 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
const char * filename
Definition: ioapi.h:135
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define MAX_PATH
Definition: compat.h:26
static char temp_path[MAX_PATH]
Definition: effect.c:190
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by test_create_effect_from_file().

◆ free_test_effect_state_manager()

static void free_test_effect_state_manager ( struct test_manager state_manager)
static

Definition at line 6089 of file effect.c.

6090 {
6091  HeapFree(GetProcessHeap(), 0, state_manager->update_record);
6092  state_manager->update_record = NULL;
6093 
6094  IDirect3DDevice9_Release(state_manager->device);
6095 }
struct test_state_manager_update * update_record
Definition: effect.c:6077
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:404
IDirect3DDevice9 * device
Definition: effect.c:6076
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by test_manager_Release().

◆ get_bool()

static BOOL get_bool ( const void data)
inlinestatic

Definition at line 115 of file effect.c.

116 {
117  return !!*(BOOL *)data;
118 }
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by set_number(), test_effect_parameter_value_GetBool(), and test_effect_parameter_value_GetBoolArray().

◆ get_float()

static float get_float ( D3DXPARAMETER_TYPE  type,
const void data 
)
inlinestatic

Definition at line 88 of file effect.c.

89 {
90  float f;
91 
92  switch (type)
93  {
94  case D3DXPT_FLOAT:
95  f = *(FLOAT *)data;
96  break;
97 
98  case D3DXPT_INT:
99  f = *(INT *)data;
100  break;
101 
102  case D3DXPT_BOOL:
103  f = *(BOOL *)data;
104  break;
105 
106  default:
107  f = 0.0f;
108  ok(0, "Unhandled type %x.\n", type);
109  break;
110  }
111 
112  return f;
113 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:57
unsigned int BOOL
Definition: ntddk_ex.h:94
GLfloat f
Definition: glext.h:7540
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define f
Definition: ke_i.h:83
#define ok(value,...)
Definition: atltest.h:57
float FLOAT
Definition: typedefs.h:68

Referenced by set_number(), test_effect_parameter_value_GetFloat(), test_effect_parameter_value_GetFloatArray(), test_effect_parameter_value_GetMatrix(), test_effect_parameter_value_GetMatrixArray(), test_effect_parameter_value_GetMatrixPointerArray(), test_effect_parameter_value_GetMatrixTranspose(), test_effect_parameter_value_GetMatrixTransposeArray(), test_effect_parameter_value_GetMatrixTransposePointerArray(), test_effect_parameter_value_GetVector(), and test_effect_parameter_value_GetVectorArray().

◆ get_int()

static INT get_int ( D3DXPARAMETER_TYPE  type,
const void data 
)
inlinestatic

Definition at line 61 of file effect.c.

62 {
63  INT i;
64 
65  switch (type)
66  {
67  case D3DXPT_FLOAT:
68  i = *(FLOAT *)data;
69  break;
70 
71  case D3DXPT_INT:
72  i = *(INT *)data;
73  break;
74 
75  case D3DXPT_BOOL:
76  i = *(BOOL *)data;
77  break;
78 
79  default:
80  i = 0;
81  ok(0, "Unhandled type %x.\n", type);
82  break;
83  }
84 
85  return i;
86 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ok(value,...)
Definition: atltest.h:57
float FLOAT
Definition: typedefs.h:68

Referenced by set_number(), test_effect_parameter_value_GetInt(), and test_effect_parameter_value_GetIntArray().

◆ get_nan()

static float get_nan ( void  )
static

Definition at line 35 of file effect.c.

36 {
37  DWORD nan = 0x7fc00000;
38 
39  return *(float *)&nan;
40 }
double __cdecl nan(const char *tagp)
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ get_texture_refcount()

static unsigned int get_texture_refcount ( IDirect3DTexture9 *  iface)
static

Definition at line 7487 of file effect.c.

7488 {
7489  IDirect3DTexture9_AddRef(iface);
7490  return IDirect3DTexture9_Release(iface);
7491 }
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
#define IDirect3DTexture9_AddRef(p)
Definition: d3d9.h:1013

Referenced by test_refcount().

◆ impl_from_ID3DXEffectStateManager()

static struct test_manager* impl_from_ID3DXEffectStateManager ( ID3DXEffectStateManager *  iface)
static

Definition at line 6084 of file effect.c.

6085 {
6086  return CONTAINING_RECORD(iface, struct test_manager, ID3DXEffectStateManager_iface);
6087 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by test_manager_AddRef(), test_manager_LightEnable(), test_manager_Release(), test_manager_SetLight(), and test_process_set_state().

◆ set_number()

static void set_number ( void outdata,
D3DXPARAMETER_TYPE  outtype,
const void indata,
D3DXPARAMETER_TYPE  intype 
)
static

Definition at line 120 of file effect.c.

121 {
122  switch (outtype)
123  {
124  case D3DXPT_FLOAT:
125  *(FLOAT *)outdata = get_float(intype, indata);
126  break;
127 
128  case D3DXPT_BOOL:
129  *(BOOL *)outdata = get_bool(indata);
130  break;
131 
132  case D3DXPT_INT:
133  *(INT *)outdata = get_int(intype, indata);
134  break;
135 
136  case D3DXPT_PIXELSHADER:
137  case D3DXPT_VERTEXSHADER:
138  case D3DXPT_TEXTURE2D:
139  case D3DXPT_STRING:
140  *(INT *)outdata = 0x12345678;
141  break;
142 
143  default:
144  ok(0, "Unhandled type %x.\n", outtype);
145  *(INT *)outdata = 0;
146  break;
147  }
148 }
static BOOL get_bool(const void *data)
Definition: effect.c:115
int32_t INT
Definition: typedefs.h:57
unsigned int BOOL
Definition: ntddk_ex.h:94
static INT get_int(D3DXPARAMETER_TYPE type, const void *data)
Definition: effect.c:61
#define ok(value,...)
Definition: atltest.h:57
static float get_float(D3DXPARAMETER_TYPE type, const void *data)
Definition: effect.c:88
float FLOAT
Definition: typedefs.h:68

Referenced by d3dx9_base_effect_get_bool(), d3dx9_base_effect_get_bool_array(), d3dx9_base_effect_get_float(), d3dx9_base_effect_get_float_array(), d3dx9_base_effect_get_int(), d3dx9_base_effect_get_int_array(), d3dx9_base_effect_set_bool(), d3dx9_base_effect_set_bool_array(), d3dx9_base_effect_set_float(), d3dx9_base_effect_set_float_array(), d3dx9_base_effect_set_int(), d3dx9_base_effect_set_int_array(), get_matrix(), get_vector(), set_matrix(), set_matrix_transpose(), set_vector(), and test_effect_parameter_value().

◆ START_TEST()

START_TEST ( effect  )

Definition at line 8038 of file effect.c.

8039 {
8040  IDirect3DDevice9 *device;
8041  ULONG refcount;
8042  HWND wnd;
8043 
8044  if (!(device = create_device(&wnd)))
8045  return;
8046 
8066 
8067  refcount = IDirect3DDevice9_Release(device);
8068  ok(!refcount, "Device has %u references left.\n", refcount);
8069  DestroyWindow(wnd);
8070 
8074  test_refcount();
8077 }
static IDirect3DDevice9 * create_device(HWND *window)
Definition: effect.c:150
static void test_effect_commitchanges(IDirect3DDevice9 *device)
Definition: effect.c:5385
static void test_effect_null_shader(void)
Definition: effect.c:7351
static void test_create_effect_and_pool(IDirect3DDevice9 *device)
Definition: effect.c:252
static void test_effect_preshader(IDirect3DDevice9 *device)
Definition: effect.c:4586
static void test_effect_compilation_errors(IDirect3DDevice9 *device)
Definition: effect.c:2884
static void test_effect_get_pass_desc(IDirect3DDevice9 *device)
Definition: effect.c:6928
BOOL WINAPI DestroyWindow(_In_ HWND)
static void test_effect_unsupported_shader(void)
Definition: effect.c:7219
static void test_effect_setvalue_object(IDirect3DDevice9 *device)
Definition: effect.c:2521
static void test_effect_find_next_valid_technique(void)
Definition: effect.c:7926
Definition: devices.h:37
static void test_create_effect_from_file(void)
Definition: effect.c:7699
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
static void test_effect_isparameterused(IDirect3DDevice9 *device)
Definition: effect.c:5174
static void test_effect_large_address_aware_flag(IDirect3DDevice9 *device)
Definition: effect.c:6895
static void test_effect_preshader_ops(IDirect3DDevice9 *device)
Definition: effect.c:5046
static void test_effect_preshader_relative_addressing(IDirect3DDevice9 *device)
Definition: effect.c:5796
static void test_effect_parameter_value(IDirect3DDevice9 *device)
Definition: effect.c:1784
static void test_cross_effect_handle(IDirect3DDevice9 *device)
Definition: effect.c:6442
static void test_effect_out_of_bounds_selector(IDirect3DDevice9 *device)
Definition: effect.c:5236
static void test_effect_clone(void)
Definition: effect.c:7406
static void test_refcount(void)
Definition: effect.c:7493
#define ok(value,...)
Definition: atltest.h:57
static void test_effect_variable_names(IDirect3DDevice9 *device)
Definition: effect.c:2643
static void test_create_effect_compiler(void)
Definition: effect.c:374
unsigned int ULONG
Definition: retypes.h:1
static void test_effect_skip_constants(IDirect3DDevice9 *device)
Definition: effect.c:7081
static void test_effect_state_manager(IDirect3DDevice9 *device)
Definition: effect.c:6329
static void test_effect_shared_parameters(IDirect3DDevice9 *device)
Definition: effect.c:6622
static void test_effect_states(IDirect3DDevice9 *device)
Definition: effect.c:3027

◆ test_create_effect_and_pool()

static void test_create_effect_and_pool ( IDirect3DDevice9 *  device)
static

Definition at line 252 of file effect.c.

253 {
254  HRESULT hr;
255  ID3DXEffect *effect;
256  ID3DXBaseEffect *base;
257  ULONG count;
258  IDirect3DDevice9 *device2;
259  ID3DXEffectStateManager *manager = (ID3DXEffectStateManager *)0xdeadbeef;
260  ID3DXEffectPool *pool = (ID3DXEffectPool *)0xdeadbeef, *pool2;
261 
263  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
264 
266  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
267 
269  ok(hr == E_FAIL, "Got result %x, expected %x (D3DXERR_INVALIDDATA)\n", hr, E_FAIL);
270 
272  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
273 
274  hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, &effect, NULL);
275  todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
276  if (FAILED(hr))
277  {
278  skip("Failed to compile effect, skipping test.\n");
279  return;
280  }
281 
282  hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3DXBaseEffect, (void **)&base);
283  ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
284 
285  hr = effect->lpVtbl->GetStateManager(effect, NULL);
286  ok(hr == D3DERR_INVALIDCALL, "GetStateManager failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
287 
288  hr = effect->lpVtbl->GetStateManager(effect, &manager);
289  ok(hr == D3D_OK, "GetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
290  ok(!manager, "GetStateManager failed, got %p\n", manager);
291 
292  /* this works, but it is not recommended! */
293  hr = effect->lpVtbl->SetStateManager(effect, (ID3DXEffectStateManager *)device);
294  ok(hr == D3D_OK, "SetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
295 
296  hr = effect->lpVtbl->GetStateManager(effect, &manager);
297  ok(hr == D3D_OK, "GetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
298  ok(manager != NULL, "GetStateManager failed\n");
299 
302  ok(count == 4, "Release failed, got %u, expected 4\n", count);
303 
304  count = IUnknown_Release(manager);
305  ok(count == 3, "Release failed, got %u, expected 3\n", count);
306 
307  hr = effect->lpVtbl->SetStateManager(effect, NULL);
308  ok(hr == D3D_OK, "SetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
309 
310  hr = effect->lpVtbl->GetPool(effect, &pool);
311  ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr);
312  ok(!pool, "GetPool failed, got %p\n", pool);
313 
314  hr = effect->lpVtbl->GetPool(effect, NULL);
315  ok(hr == D3DERR_INVALIDCALL, "GetPool failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
316 
317  hr = effect->lpVtbl->GetDevice(effect, &device2);
318  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
319 
320  hr = effect->lpVtbl->GetDevice(effect, NULL);
321  ok(hr == D3DERR_INVALIDCALL, "GetDevice failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
322 
323  count = IDirect3DDevice9_Release(device2);
324  ok(count == 2, "Release failed, got %u, expected 2\n", count);
325 
326  count = effect->lpVtbl->Release(effect);
327  ok(count == 0, "Release failed %u\n", count);
328 
330  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
331 
333  ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr);
334 
335  count = pool->lpVtbl->Release(pool);
336  ok(count == 0, "Release failed %u\n", count);
337 
339  ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr);
340 
342  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
343 
344  hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3DXEffectPool, (void **)&pool2);
345  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
346  ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool);
347 
348  count = pool2->lpVtbl->Release(pool2);
349  ok(count == 1, "Release failed, got %u, expected 1\n", count);
350 
351  hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9, (void **)&device2);
352  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
353 
354  count = IDirect3DDevice9_Release(device2);
355  ok(count == 1, "Release failed, got %u, expected 1\n", count);
356 
357  hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, pool, &effect, NULL);
358  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
359 
360  hr = effect->lpVtbl->GetPool(effect, &pool);
361  ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr);
362  ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool);
363 
364  count = pool2->lpVtbl->Release(pool2);
365  ok(count == 2, "Release failed, got %u, expected 2\n", count);
366 
367  count = effect->lpVtbl->Release(effect);
368  ok(count == 0, "Release failed %u\n", count);
369 
370  count = pool->lpVtbl->Release(pool);
371  ok(count == 0, "Release failed %u\n", count);
372 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define D3DERR_INVALIDCALL
#define IDirect3DDevice9_QueryInterface(p, a, b)
Definition: d3d9.h:1506
#define E_FAIL
Definition: ddrawi.h:102
GLuint base
Definition: 3dtext.c:35
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
static const char effect_desc[]
Definition: effect.c:247
nsrefcnt Release()
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
#define todo_wine
Definition: test.h:162
#define S_OK
Definition: intsafe.h:59
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
HRESULT WINAPI D3DXCreateEffectPool(ID3DXEffectPool **pool)
Definition: effect.c:6970

Referenced by START_TEST().

◆ test_create_effect_compiler()

static void test_create_effect_compiler ( void  )
static

Definition at line 374 of file effect.c.

375 {
376  HRESULT hr;
377  ID3DXEffectCompiler *compiler, *compiler2;
378  ID3DXBaseEffect *base;
379  IUnknown *unknown;
380  ULONG count;
381 
382  hr = D3DXCreateEffectCompiler(NULL, 0, NULL, NULL, 0, &compiler, NULL);
383  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
384 
386  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
387 
388  hr = D3DXCreateEffectCompiler(effect_desc, 0, NULL, NULL, 0, &compiler, NULL);
389  ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
390  if (FAILED(hr))
391  {
392  skip("D3DXCreateEffectCompiler failed, skipping test.\n");
393  return;
394  }
395 
396  count = compiler->lpVtbl->Release(compiler);
397  ok(count == 0, "Release failed %u\n", count);
398 
400  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
401 
402  hr = D3DXCreateEffectCompiler(NULL, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL);
403  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
404 
406  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
407 
409  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
410 
411  hr = D3DXCreateEffectCompiler(effect_desc, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL);
412  ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
413 
414  hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXBaseEffect, (void **)&base);
415  ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
416 
417  hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXEffectCompiler, (void **)&compiler2);
418  ok(hr == D3D_OK, "QueryInterface failed, got %x, expected %x (D3D_OK)\n", hr, D3D_OK);
419 
420  hr = compiler->lpVtbl->QueryInterface(compiler, &IID_IUnknown, (void **)&unknown);
421  ok(hr == D3D_OK, "QueryInterface failed, got %x, expected %x (D3D_OK)\n", hr, D3D_OK);
422 
423  count = unknown->lpVtbl->Release(unknown);
424  ok(count == 2, "Release failed, got %u, expected %u\n", count, 2);
425 
426  count = compiler2->lpVtbl->Release(compiler2);
427  ok(count == 1, "Release failed, got %u, expected %u\n", count, 1);
428 
429  count = compiler->lpVtbl->Release(compiler);
430  ok(count == 0, "Release failed %u\n", count);
431 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define D3DERR_INVALIDCALL
HRESULT WINAPI D3DXCreateEffectCompiler(const char *srcdata, UINT srcdatalen, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXEffectCompiler **compiler, ID3DXBuffer **parse_errors)
Definition: effect.c:6859
GLuint base
Definition: 3dtext.c:35
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
const GUID IID_IUnknown
static const char effect_desc[]
Definition: effect.c:247
nsrefcnt Release()
Definition: id3.c:18
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1

Referenced by START_TEST().

◆ test_create_effect_from_file()

static void test_create_effect_from_file ( void  )
static

Definition at line 7699 of file effect.c.

7700 {
7701  static const char effect1[] =
7702  "float4 light;\n"
7703  "float4x4 mat;\n"
7704  "float4 color;\n"
7705  "\n"
7706  "struct vs_input\n"
7707  "{\n"
7708  " float4 position : POSITION;\n"
7709  " float3 normal : NORMAL;\n"
7710  "};\n"
7711  "\n"
7712  "struct vs_output\n"
7713  "{\n"
7714  " float4 position : POSITION;\n"
7715  " float4 diffuse : COLOR;\n"
7716  "};\n"
7717  "\n"
7718  "vs_output vs_main(const vs_input v)\n"
7719  "{\n"
7720  " vs_output o;\n"
7721  " const float4 scaled_color = 0.5 * color;\n"
7722  "\n"
7723  " o.position = mul(v.position, mat);\n"
7724  " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
7725  "\n"
7726  " return o;\n"
7727  "}\n"
7728  "\n"
7729  "technique t\n"
7730  "{\n"
7731  " pass p\n"
7732  " {\n"
7733  " VertexShader = compile vs_2_0 vs_main();\n"
7734  " }\n"
7735  "}\n";
7736  static const char include1[] =
7737  "float4 light;\n"
7738  "float4x4 mat;\n"
7739  "float4 color;\n"
7740  "\n"
7741  "struct vs_input\n"
7742  "{\n"
7743  " float4 position : POSITION;\n"
7744  " float3 normal : NORMAL;\n"
7745  "};\n"
7746  "\n"
7747  "struct vs_output\n"
7748  "{\n"
7749  " float4 position : POSITION;\n"
7750  " float4 diffuse : COLOR;\n"
7751  "};\n";
7752  static const char include1_wrong[] =
7753  "#error \"wrong include\"\n";
7754  static const char include2[] =
7755  "#include \"include1.h\"\n"
7756  "\n"
7757  "vs_output vs_main(const vs_input v)\n"
7758  "{\n"
7759  " vs_output o;\n"
7760  " const float4 scaled_color = 0.5 * color;\n"
7761  "\n"
7762  " o.position = mul(v.position, mat);\n"
7763  " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
7764  "\n"
7765  " return o;\n"
7766  "}\n";
7767  static const char effect2[] =
7768  "#include \"include\\include2.h\"\n"
7769  "\n"
7770  "technique t\n"
7771  "{\n"
7772  " pass p\n"
7773  " {\n"
7774  " VertexShader = compile vs_2_0 vs_main();\n"
7775  " }\n"
7776  "}\n";
7777  static const WCHAR effect1_filename_w[] = {'e','f','f','e','c','t','1','.','f','x',0};
7778  static const WCHAR effect2_filename_w[] = {'e','f','f','e','c','t','2','.','f','x',0};
7779  WCHAR effect_path_w[MAX_PATH], filename_w[MAX_PATH];
7780  char effect_path[MAX_PATH], filename[MAX_PATH];
7781  D3DPRESENT_PARAMETERS present_parameters = {0};
7782  unsigned int filename_size;
7783  struct d3dxinclude include;
7784  IDirect3DDevice9 *device;
7786  ID3DXEffect *effect;
7787  IDirect3D9 *d3d;
7788  ULONG refcount;
7789  HWND window;
7790  HRESULT hr;
7791 
7792  if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
7793  640, 480, NULL, NULL, NULL, NULL)))
7794  {
7795  skip("Failed to create window.\n");
7796  return;
7797  }
7798  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
7799  {
7800  skip("Failed to create IDirect3D9 object.\n");
7802  return;
7803  }
7804  present_parameters.Windowed = TRUE;
7805  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
7807  D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
7808  if (FAILED(hr))
7809  {
7810  skip("Failed to create IDirect3DDevice9 object, hr %#x.\n", hr);
7811  IDirect3D9_Release(d3d);
7813  return;
7814  }
7815 
7816  if (!create_file("effect1.fx", effect1, sizeof(effect1) - 1, filename))
7817  {
7818  skip("Couldn't create temporary file, skipping test.\n");
7819  return;
7820  }
7821 
7822  filename_size = strlen(filename);
7823  filename_size -= sizeof("effect1.fx") - 1;
7824  memcpy(effect_path, filename, filename_size);
7825  effect_path[filename_size] = 0;
7826  MultiByteToWideChar(CP_ACP, 0, effect_path, -1, effect_path_w, ARRAY_SIZE(effect_path_w));
7827 
7828  create_directory("include");
7829  create_file("effect2.fx", effect2, sizeof(effect2) - 1, NULL);
7830  create_file("include\\include1.h", include1, sizeof(include1) - 1, NULL);
7831  create_file("include\\include2.h", include2, sizeof(include2) - 1, NULL);
7832  create_file("include1.h", include1_wrong, sizeof(include1_wrong) - 1, NULL);
7833 
7834  lstrcpyW(filename_w, effect_path_w);
7835  lstrcatW(filename_w, effect1_filename_w);
7836  effect = NULL;
7837  messages = NULL;
7839  0, NULL, &effect, &messages);
7840  todo_wine ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
7841  if (messages)
7842  {
7843  trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
7845  }
7846  if (effect)
7847  effect->lpVtbl->Release(effect);
7848 
7849  lstrcpyW(filename_w, effect_path_w);
7850  lstrcatW(filename_w, effect2_filename_w);
7851  effect = NULL;
7852  messages = NULL;
7853  /* This is apparently broken on native, it ends up using the wrong include. */
7855  0, NULL, &effect, &messages);
7856  todo_wine ok(hr == E_FAIL, "Unexpected error, hr %#x.\n", hr);
7857  if (messages)
7858  {
7859  trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
7861  }
7862  if (effect)
7863  effect->lpVtbl->Release(effect);
7864 
7865  delete_file("effect1.fx");
7866  delete_file("effect2.fx");
7867  delete_file("include\\include1.h");
7868  delete_file("include\\include2.h");
7869  delete_file("include2.h");
7870  delete_directory("include");
7871 
7872  lstrcpyW(filename_w, effect2_filename_w);
7873  effect = NULL;
7874  messages = NULL;
7875  include.ID3DXInclude_iface.lpVtbl = &d3dxinclude_vtbl;
7876  /* This is actually broken in native d3dx9 (manually tried multiple
7877  * versions, all are affected). For reference, the message printed below
7878  * is "ID3DXEffectCompiler: There were no techniques" */
7879  hr = D3DXCreateEffectFromFileExW(device, filename_w, NULL, &include.ID3DXInclude_iface, NULL,
7880  0, NULL, &effect, &messages);
7881  todo_wine ok(hr == E_FAIL, "D3DXInclude test failed with error %#x.\n", hr);
7882  if (messages)
7883  {
7884  trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
7886  }
7887 
7888  refcount = IDirect3DDevice9_Release(device);
7889  ok(!refcount, "Device has %u references left.\n", refcount);
7890  IDirect3D9_Release(d3d);
7892 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
static const struct ID3DXIncludeVtbl d3dxinclude_vtbl
Definition: effect.c:7688
#define TRUE
Definition: types.h:120
static BOOL create_directory(const char *name)
Definition: effect.c:229
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI DestroyWindow(_In_ HWND)
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
Definition: devices.h:37
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define trace
Definition: atltest.h:70
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:30
#define D3D_SDK_VERSION
Definition: d3d8.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
HRESULT WINAPI D3DXCreateEffectFromFileExW(struct IDirect3DDevice9 *device, const WCHAR *srcfile, const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skipconstants, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilationerrors)
Definition: effect.c:6991
#define MAX_PATH
Definition: compat.h:26
static void delete_file(const char *filename)
Definition: effect.c:220
#define todo_wine
Definition: test.h:162
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static IHTMLWindow2 * window
Definition: events.c:77
#define D3D_OK
Definition: d3d.h:106
#define lstrcpyW
Definition: compat.h:415
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define ok(value,...)
Definition: atltest.h:57
#define MultiByteToWideChar
Definition: compat.h:100
#define skip(...)
Definition: atltest.h:64
#define D3DCREATE_HARDWARE_VERTEXPROCESSING
Definition: d3d8.h:45
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
unsigned int ULONG
Definition: retypes.h:1
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static BOOL create_file(const char *filename, const char *data, const unsigned int size, char *out_path)
Definition: effect.c:192
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
static void delete_directory(const char *name)
Definition: effect.c:238
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128

Referenced by START_TEST().

◆ test_cross_effect_handle()

static void test_cross_effect_handle ( IDirect3DDevice9 *  device)
static

Definition at line 6442 of file effect.c.

6443 {
6444  ID3DXEffect *effect1, *effect2;
6445  D3DXHANDLE param1, param2;
6446  static int expected_ivect[4] = {28, 29, 30, 31};
6447  int ivect[4];
6448  HRESULT hr;
6449 
6451  NULL, NULL, 0, NULL, &effect1, NULL);
6452  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6454  NULL, NULL, 0, NULL, &effect2, NULL);
6455  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6456 
6457  ok(effect1 != effect2, "Got same effect unexpectedly.\n");
6458 
6459  param1 = effect1->lpVtbl->GetParameterByName(effect1, NULL, "g_iVect");
6460  ok(!!param1, "GetParameterByName failed.\n");
6461 
6462  param2 = effect2->lpVtbl->GetParameterByName(effect2, NULL, "g_iVect");
6463  ok(!!param2, "GetParameterByName failed.\n");
6464 
6465  ok(param1 != param2, "Got same parameter handle unexpectedly.\n");
6466 
6467  hr = effect2->lpVtbl->SetValue(effect2, param1, expected_ivect, sizeof(expected_ivect));
6468  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6469 
6470  hr = effect1->lpVtbl->GetValue(effect1, param1, ivect, sizeof(ivect));
6471  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6472 
6473  ok(!memcmp(ivect, expected_ivect, sizeof(expected_ivect)), "Vector value mismatch.\n");
6474 
6475  effect2->lpVtbl->Release(effect2);
6476  effect1->lpVtbl->Release(effect1);
6477 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ test_effect_clear_vconsts()

static void test_effect_clear_vconsts ( IDirect3DDevice9 *  device)
static

Definition at line 3015 of file effect.c.

3016 {
3017  unsigned int i;
3018  HRESULT hr;
3019 
3020  for (i = 0; i < 256; ++i)
3021  {
3023  ok(hr == D3D_OK, "Got result %#x.\n", hr);
3024  }
3025 }
HRESULT hr
Definition: shlfolder.c:183
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: devices.h:37
#define IDirect3DDevice9_SetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1601
LONG HRESULT
Definition: typedefs.h:78
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
static const D3DXVECTOR4 fvect_filler
Definition: effect.c:3013

Referenced by test_effect_commitchanges(), test_effect_preshader(), test_effect_shared_parameters(), test_effect_skip_constants(), and test_effect_states().

◆ test_effect_clone()

static void test_effect_clone ( void  )
static

Definition at line 7406 of file effect.c.

7407 {
7408  IDirect3DDevice9 *device, *device2, *device3;
7409  ID3DXEffect *effect, *cloned;
7410  HWND window, window2;
7411  ULONG refcount;
7412  HRESULT hr;
7413 
7414  if (!(device = create_device(&window)))
7415  return;
7416 
7417  /* D3DXFX_NOT_CLONEABLE */
7419  NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
7420  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7421 
7422  hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
7423  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7424 
7425  cloned = (void *)0xdeadbeef;
7426  hr = effect->lpVtbl->CloneEffect(effect, NULL, &cloned);
7427  ok(hr == E_FAIL, "Got result %#x.\n", hr);
7428  ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7429 
7430  hr = effect->lpVtbl->CloneEffect(effect, device, NULL);
7431  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7432 
7433  cloned = (void *)0xdeadbeef;
7434  hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7435  ok(hr == E_FAIL, "Got result %#x.\n", hr);
7436  ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7437 
7438  effect->lpVtbl->Release(effect);
7439 
7441  NULL, NULL, 0, NULL, &effect, NULL);
7442  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7443 
7444  hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
7445  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7446 
7447  cloned = (void *)0xdeadbeef;
7448  hr = effect->lpVtbl->CloneEffect(effect, NULL, &cloned);
7449  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7450  ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7451 
7452  hr = effect->lpVtbl->CloneEffect(effect, device, NULL);
7453  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7454 
7455  hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7456 todo_wine
7457  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7458 if (hr == D3D_OK)
7459 {
7460  ok(cloned != effect, "Expected new effect instance.\n");
7461  cloned->lpVtbl->Release(cloned);
7462 }
7463  /* Try with different device. */
7464  device2 = create_device(&window2);
7465  hr = effect->lpVtbl->CloneEffect(effect, device2, &cloned);
7466 todo_wine
7467  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7468 if (hr == D3D_OK)
7469 {
7470  ok(cloned != effect, "Expected new effect instance.\n");
7471 
7472  hr = cloned->lpVtbl->GetDevice(cloned, &device3);
7473  ok(hr == S_OK, "Failed to get effect device.\n");
7474  ok(device3 == device2, "Unexpected device instance.\n");
7475  IDirect3DDevice9_Release(device3);
7476 
7477  cloned->lpVtbl->Release(cloned);
7478 }
7479  IDirect3DDevice9_Release(device2);
7480  DestroyWindow(window2);
7481  effect->lpVtbl->Release(effect);
7482  refcount = IDirect3DDevice9_Release(device);
7483  ok(!refcount, "Device has %u references left.\n", refcount);
7485 }
static IDirect3DDevice9 * create_device(HWND *window)
Definition: effect.c:150
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI DestroyWindow(_In_ HWND)
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define todo_wine
Definition: test.h:162
static IHTMLWindow2 * window
Definition: events.c:77
#define S_OK
Definition: intsafe.h:59
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
#define D3DXFX_NOT_CLONEABLE
Definition: d3dx9effect.h:27

Referenced by START_TEST().

◆ test_effect_commitchanges()

static void test_effect_commitchanges ( IDirect3DDevice9 *  device)
static

Definition at line 5385 of file effect.c.

5386 {
5387  static const struct
5388  {
5389  const char *param_name;
5391  }
5392  check_op_parameters[] =
5393  {
5409  };
5410  static const struct
5411  {
5412  const char *param_name;
5413  const unsigned int const_updated_mask[(ARRAY_SIZE(test_effect_preshader_fvect_v)
5415  }
5416  check_vconsts_parameters[] =
5417  {
5418  {"g_Selector", {0x00000000, 0x00000002}},
5419  {"g_Pos1", {0x80000000, 0x00000002}},
5420  {"g_Pos2", {0x00000000, 0x00000002}},
5421  {"m4x3column", {0x03800000, 0x00000000}},
5422  {"m3x4column", {0x000f0000, 0x00000000}},
5423  {"m4x3row", {0x0000f000, 0x00000000}},
5424  {"m3x4row", {0x00700000, 0x00000000}},
5425  {"ts1", {0x1c000000, 0x00000000}},
5426  {"ts2", {0x0000003f, 0x00000000}},
5427  {"arr1", {0x00000000, 0x00000001}},
5428  {"arr2", {0x60000000, 0x00000000}},
5429  {"ts3", {0x00000fc0, 0x00000000}},
5430  };
5431  static const struct
5432  {
5433  const char *param_name;
5434  const unsigned int const_updated_mask[(ARRAY_SIZE(test_effect_preshader_bconsts)
5436  }
5437  check_bconsts_parameters[] =
5438  {
5439  {"mb2x3row", {0x0000001f}},
5440  {"mb2x3column", {0x00000060}},
5441  };
5442  static const unsigned int const_no_update_mask[(ARRAY_SIZE(test_effect_preshader_fvect_v)
5444  static const D3DLIGHT9 light_filler = {D3DLIGHT_POINT};
5445 
5446  ID3DXEffect *effect;
5447  HRESULT hr;
5448  D3DXHANDLE param;
5449  unsigned int i, passes_count, value;
5450  int ivect[4];
5451  D3DXVECTOR4 fvect;
5452  IDirect3DVertexShader9 *vshader;
5453  unsigned char buffer[256];
5454 
5455 
5457  NULL, NULL, 0, NULL, &effect, NULL);
5458  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5459 
5460  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5461  ok(!!param, "GetParameterByName failed.\n");
5462 
5463  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5464  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5465 
5467  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5468 
5469  hr = effect->lpVtbl->BeginPass(effect, 0);
5470  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5471 
5472  for (i = 0; i < ARRAY_SIZE(check_op_parameters); ++i)
5473  {
5474  unsigned int j;
5475 
5476  for (j = 0; j < 8; ++j)
5477  {
5478  hr = IDirect3DDevice9_SetLight(device, j, &light_filler);
5479  ok(hr == D3D_OK, "Got result %#x, i %u, j %u.\n", hr, i, j);
5480  }
5481  param = effect->lpVtbl->GetParameterByName(effect, NULL, check_op_parameters[i].param_name);
5482  ok(!!param, "Failed to get parameter (test %u).\n", i);
5483  hr = effect->lpVtbl->GetValue(effect, param, &fvect, sizeof(fvect));
5484  ok(hr == D3D_OK, "Failed to get parameter value, hr %#x (test %u).\n", hr, i);
5485  hr = effect->lpVtbl->SetValue(effect, param, &fvect, sizeof(fvect));
5486  ok(hr == D3D_OK, "Failed to set parameter value, hr %#x (test %u).\n", hr, i);
5487  hr = effect->lpVtbl->CommitChanges(effect);
5488  ok(hr == D3D_OK, "Failed to commit changes, hr %#x (test %u).\n", hr, i);
5489 
5490  test_effect_preshader_op_results(device, check_op_parameters[i].state_updated,
5491  check_op_parameters[i].param_name);
5492  }
5493 
5494  for (i = 0; i < ARRAY_SIZE(check_vconsts_parameters); ++i)
5495  {
5497  param = effect->lpVtbl->GetParameterByName(effect, NULL, check_vconsts_parameters[i].param_name);
5498  ok(!!param, "GetParameterByName failed.\n");
5499  hr = effect->lpVtbl->GetValue(effect, param, buffer, sizeof(buffer));
5500  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5501  hr = effect->lpVtbl->SetValue(effect, param, buffer, sizeof(buffer));
5502  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5503  hr = effect->lpVtbl->CommitChanges(effect);
5504  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5505 
5506  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[i].const_updated_mask,
5507  check_vconsts_parameters[i].param_name);
5508  }
5509 
5510  for (i = 0; i < ARRAY_SIZE(check_bconsts_parameters); ++i)
5511  {
5513  param = effect->lpVtbl->GetParameterByName(effect, NULL, check_bconsts_parameters[i].param_name);
5514  ok(!!param, "GetParameterByName failed.\n");
5515  hr = effect->lpVtbl->GetValue(effect, param, buffer, sizeof(buffer));
5516  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5517  hr = effect->lpVtbl->SetValue(effect, param, buffer, sizeof(buffer));
5518  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5519  hr = effect->lpVtbl->CommitChanges(effect);
5520  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5521 
5522  test_effect_preshader_compare_pbool_consts(device, check_bconsts_parameters[i].const_updated_mask,
5523  check_bconsts_parameters[i].param_name);
5524  }
5525 
5527  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Selector");
5528  ok(!!param, "GetParameterByName failed.\n");
5529  fvect.x = fvect.y = fvect.z = fvect.w = 0.0f;
5530  hr = effect->lpVtbl->SetVectorArray(effect, param, &fvect, 1);
5531  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5532  hr = effect->lpVtbl->CommitChanges(effect);
5533  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5534  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[0].const_updated_mask,
5535  check_vconsts_parameters[0].param_name);
5536 
5538  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5539  ok(!!param, "GetParameterByName failed.\n");
5540  param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5541  ok(!!param, "GetParameterElement failed.\n");
5542  hr = effect->lpVtbl->SetFloat(effect, param, 92.0f);
5543  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5544  hr = effect->lpVtbl->CommitChanges(effect);
5545  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5546  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5547  check_vconsts_parameters[10].param_name);
5548 
5550  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5551  ok(!!param, "GetParameterByName failed.\n");
5552  param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5553  ok(!!param, "GetParameterElement failed.\n");
5554  fvect.x = 93.0f;
5555  hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(fvect.x));
5556  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5557  hr = effect->lpVtbl->CommitChanges(effect);
5558  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5559  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[10].const_updated_mask,
5560  check_vconsts_parameters[10].param_name);
5561 
5563  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5564  ok(!!param, "GetParameterByName failed.\n");
5565  fvect.x = 92.0f;
5566  hr = effect->lpVtbl->SetFloatArray(effect, param, &fvect.x, 1);
5567  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5568  hr = effect->lpVtbl->CommitChanges(effect);
5569  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5570  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[10].const_updated_mask,
5571  check_vconsts_parameters[10].param_name);
5572 
5574  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5575  ok(!!param, "GetParameterByName failed.\n");
5576  param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5577  ok(!!param, "GetParameterElement failed.\n");
5578  hr = effect->lpVtbl->SetInt(effect, param, 93);
5579  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5580  hr = effect->lpVtbl->CommitChanges(effect);
5581  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5582  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5583  check_vconsts_parameters[10].param_name);
5584 
5586  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Pos1");
5587  ok(!!param, "GetParameterByName failed.\n");
5588  fvect.x = fvect.y = fvect.z = fvect.w = 0.0f;
5589  hr = effect->lpVtbl->SetVector(effect, param, &fvect);
5590  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5591  hr = effect->lpVtbl->CommitChanges(effect);
5592  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5593  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[1].const_updated_mask,
5594  check_vconsts_parameters[1].param_name);
5595 
5597  param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts1");
5598  ok(!!param, "GetParameterByName failed.\n");
5599  param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5600  ok(!!param, "GetParameterByName failed.\n");
5601  param = effect->lpVtbl->GetParameterByName(effect, param, "fv");
5602  ok(!!param, "GetParameterByName failed.\n");
5603  fvect.x = 12;
5604  hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(float));
5605  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5606  hr = effect->lpVtbl->CommitChanges(effect);
5607  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5608  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[7].const_updated_mask,
5609  check_vconsts_parameters[7].param_name);
5610 
5611  *(float *)&value = 9999.0f;
5613  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5615  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5617  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5619  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5621  param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts2");
5622  ok(!!param, "GetParameterByName failed.\n");
5623  param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5624  ok(!!param, "GetParameterByName failed.\n");
5625  param = effect->lpVtbl->GetParameterByName(effect, param, "v1");
5626  ok(!!param, "GetParameterByName failed.\n");
5627  hr = effect->lpVtbl->GetValue(effect, param, &fvect, sizeof(float) * 3);
5628  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5629  hr = effect->lpVtbl->SetValue(effect, param, &fvect, sizeof(float) * 3);
5630  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5631  hr = effect->lpVtbl->CommitChanges(effect);
5632  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5634  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5635  ok(value == 0, "Unexpected fog density %g.\n", *(float *)&value);
5637  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5638  ok(*(float *)&value == 4.0f, "Unexpected fog start %g.\n", *(float *)&value);
5640  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5641  ok(*(float *)&value == 9999.0f, "Unexpected point scale A %g.\n", *(float *)&value);
5643  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5644  ok(*(float *)&value == 9999.0f, "Unexpected point scale B %g.\n", *(float *)&value);
5645  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[8].const_updated_mask,
5646  check_vconsts_parameters[8].param_name);
5647 
5648  *(float *)&value = 9999.0f;
5650  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5652  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5654  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5656  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5658  param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts3");
5659  ok(!!param, "GetParameterByName failed.\n");
5660  param = effect->lpVtbl->GetParameterByName(effect, param, "ts");
5661  ok(!!param, "GetParameterByName failed.\n");
5662  param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5663  ok(!!param, "GetParameterByName failed.\n");
5664  param = effect->lpVtbl->GetParameterByName(effect, param, "fv");
5665  ok(!!param, "GetParameterByName failed.\n");
5666  hr = effect->lpVtbl->GetValue(effect, param, &fvect.x, sizeof(float));
5667  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5668  hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(float));
5669  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5670  hr = effect->lpVtbl->CommitChanges(effect);
5671  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5673  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5674  ok(*(float *)&value == 9999.0f, "Unexpected fog density %g.\n", *(float *)&value);
5676  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5677  ok(*(float *)&value == 9999.0f, "Unexpected fog start %g.\n", *(float *)&value);
5679  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5680  ok(*(float *)&value == 4.0f, "Unexpected point scale A %g.\n", *(float *)&value);
5682  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5683  ok(*(float *)&value == 12.0f, "Unexpected point scale B %g.\n", *(float *)&value);
5684  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[11].const_updated_mask,
5685  check_vconsts_parameters[11].param_name);
5686 
5688  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5689  ok(value == 1, "Unexpected sampler 0 minfilter %u.\n", value);
5691  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5692  todo_wine
5693  ok(value == 0, "Unexpected sampler 1 minfilter %u.\n", value);
5695  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5696  ok(value == 3, "Unexpected sampler 2 minfilter %u.\n", value);
5697 
5698  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5699  ok(!!param, "GetParameterByName failed.\n");
5700  ivect[0] = ivect[1] = ivect[2] = ivect[3] = 1;
5701  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5702  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5703 
5704  for (i = 0; i < 3; ++i)
5705  {
5707  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5709  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5710  }
5711 
5713  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5715  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5716 
5718  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5720 
5721  hr = effect->lpVtbl->CommitChanges(effect);
5722  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5723 
5725  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5726  ok(!vshader, "Got non NULL vshader.\n");
5727  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5728  "selector g_iVect");
5729 
5731  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5732  ok(value == 0, "Unexpected sampler 0 minfilter %u.\n", value);
5734  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5735  ok(value == 0, "Unexpected sampler 1 minfilter %u.\n", value);
5736 
5738  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5739  ok(value == 1, "Unexpected sampler 2 minfilter %u.\n", value);
5741  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5742  ok(value == 0, "Unexpected sampler 2 minfilter %u.\n", value);
5744  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5745  ok(value == 1, "Unexpected sampler 0 minfilter %u.\n", value);
5747  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5748  ok(value == 0, "Unexpected sampler 0 minfilter %u.\n", value);
5749 
5750  ivect[3] = 2;
5751  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5752  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5753  ivect[3] = 1;
5754  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5755  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5756  hr = effect->lpVtbl->CommitChanges(effect);
5757  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5759  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5760  ok(!vshader, "Got non NULL vshader.\n");
5761  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5762  "selector g_iVect");
5763  ivect[3] = 2;
5764  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5765  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5766  hr = effect->lpVtbl->CommitChanges(effect);
5767  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5769  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5770  ok(!!vshader, "Got NULL vshader.\n");
5773  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5774  ok(fvect.x == 0.0f && fvect.y == 0.0f && fvect.z == 0.0f && fvect.w == 0.0f,
5775  "Vertex shader float constants do not match.\n");
5777  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5778  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5779  "selector g_iVect");
5780  ivect[3] = 1;
5781  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5782  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5783  hr = effect->lpVtbl->CommitChanges(effect);
5784  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5786 
5787  hr = effect->lpVtbl->EndPass(effect);
5788  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5789 
5790  hr = effect->lpVtbl->End(effect);
5791  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5792 
5793  effect->lpVtbl->Release(effect);
5794 }
#define IDirect3DDevice9_GetRenderState(p, a, b)
Definition: d3d9.h:1565
static const struct @1629 test_effect_preshader_op_expected[]
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
static void test_effect_clear_vconsts(IDirect3DDevice9 *device)
Definition: effect.c:3015
static void test_effect_preshader_clear_pbool_consts(IDirect3DDevice9 *device)
Definition: effect.c:4522
GLuint buffer
Definition: glext.h:5915
#define test_effect_preshader_compare_vconsts(a, b, c)
Definition: effect.c:4468
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
expected_state_update
Definition: effect.c:4383
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
#define IDirect3DDevice9_SetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1601
#define test_effect_preshader_compare_pbool_consts(a, b, c)
Definition: effect.c:4536
smooth NULL
Definition: ftsmooth.c:416
static const D3DXVECTOR4 test_effect_preshader_fvect_v[]
Definition: effect.c:4429
#define IDirect3DDevice9_GetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1602
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define IDirect3DDevice9_GetVertexShader(p, a)
Definition: d3d9.h:1600
GLfloat f
Definition: glext.h:7540
LONG HRESULT
Definition: typedefs.h:78
#define IDirect3DVertexShader9_Release(p)
Definition: d3d9.h:1223
GLfloat param
Definition: glext.h:5796
#define IDirect3DDevice9_SetLight(p, a, b)
Definition: d3d9.h:1558
#define todo_wine
Definition: test.h:162
GLsizei const GLfloat * value
Definition: glext.h:6069
#define IDirect3DDevice9_SetVertexShader(p, a)
Definition: d3d9.h:1599
#define IDirect3DDevice9_SetRenderState(p, a, b)
Definition: d3d9.h:1564
#define test_effect_preshader_op_results(a, b, c)
Definition: effect.c:4390
#define D3D_OK
Definition: d3d.h:106
static const BOOL test_effect_preshader_bconsts[]
Definition: effect.c:4517
#define D3DVERTEXTEXTURESAMPLER1
Definition: d3d9types.h:194
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define D3DVERTEXTEXTURESAMPLER2
Definition: d3d9types.h:195
#define IDirect3DDevice9_GetSamplerState(p, a, b, c)
Definition: d3d9.h:1575
#define IDirect3DDevice9_SetSamplerState(p, a, b, c)
Definition: d3d9.h:1576
#define D3DVERTEXTEXTURESAMPLER0
Definition: d3d9types.h:193
#define TEST_EFFECT_BITMASK_BLOCK_SIZE
Definition: effect.c:4466
static const D3DXVECTOR4 fvect_filler
Definition: effect.c:3013

Referenced by START_TEST().

◆ test_effect_compilation_errors()

static void test_effect_compilation_errors ( IDirect3DDevice9 *  device)
static

Definition at line 2884 of file effect.c.

2885 {
2886  ID3DXEffect *effect;
2887  ID3DXBuffer *compilation_errors;
2888  HRESULT hr;
2889 
2890  /* Test binary effect */
2891  compilation_errors = (ID3DXBuffer*)0xdeadbeef;
2892  hr = D3DXCreateEffect(NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, &compilation_errors);
2893  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2894  ok(!compilation_errors, "Returned %p\n", compilation_errors);
2895 
2896  compilation_errors = (ID3DXBuffer*)0xdeadbeef;
2898  sizeof(test_effect_variable_names_blob), NULL, NULL, 0, NULL, &effect, &compilation_errors);
2899  ok(hr == D3D_OK, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3D_OK);
2900  ok(!compilation_errors, "Returned %p\n", compilation_errors);
2901  effect->lpVtbl->Release(effect);
2902 }
HRESULT hr
Definition: shlfolder.c:183
#define D3DERR_INVALIDCALL
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
smooth NULL
Definition: ftsmooth.c:416
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
static const DWORD test_effect_variable_names_blob[]
Definition: effect.c:2614
LONG HRESULT
Definition: typedefs.h:78
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ test_effect_find_next_valid_technique()

static void test_effect_find_next_valid_technique ( void  )
static

Definition at line 7926 of file effect.c.

7927 {
7928  D3DPRESENT_PARAMETERS present_parameters = {0};
7929  IDirect3DDevice9 *device;
7931  ID3DXEffect *effect;
7932  IDirect3D9 *d3d;
7933  D3DXHANDLE tech;
7934  ULONG refcount;
7935  HWND window;
7936  HRESULT hr;
7937 
7938  if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
7939  640, 480, NULL, NULL, NULL, NULL)))
7940  {
7941  skip("Failed to create window.\n");
7942  return;
7943  }
7944  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
7945  {
7946  skip("Failed to create IDirect3D9 object.\n");
7948  return;
7949  }
7950  present_parameters.Windowed = TRUE;
7951  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
7953  D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
7954  if (FAILED(hr))
7955  {
7956  skip("Failed to create IDirect3DDevice9 object, hr %#x.\n", hr);
7957  IDirect3D9_Release(d3d);
7959  return;
7960  }
7961 
7963  NULL, NULL, NULL, 0, NULL, &effect, NULL);
7964  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7965 
7966  hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
7967  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7968  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7969  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7970  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
7971 
7972  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7973  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7974  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7975  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7976  ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
7977 
7978  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7979  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7980  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7981  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7982  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
7983 
7984  effect->lpVtbl->Release(effect);
7985 
7987  NULL, NULL, NULL, 0, NULL, &effect, NULL);
7988  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7989 
7990  hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
7991  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7992  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7993  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7994  ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
7995 
7996  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7997  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7998  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7999  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8000  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
8001 
8002  hr = effect->lpVtbl->SetInt(effect, "i", 1);
8003  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8004 
8005  tech = (D3DXHANDLE)0xdeadbeef;
8006  hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
8007  ok(hr == S_FALSE, "Got result %#x.\n", hr);
8008  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8009  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8010  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
8011 
8012  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
8013  ok(hr == S_FALSE, "Got result %#x.\n", hr);
8014 
8015  hr = effect->lpVtbl->SetInt(effect, "i", 0);
8016  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8017 
8018  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
8019  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8020  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8021  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8022  ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
8023 
8024  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
8025  ok(hr == S_FALSE, "Got result %#x.\n", hr);
8026 
8027  hr = effect->lpVtbl->FindNextValidTechnique(effect, "nope", &tech);
8028  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
8029 
8030  effect->lpVtbl->Release(effect);
8031 
8032  refcount = IDirect3DDevice9_Release(device);
8033  ok(!refcount, "Device has %u references left.\n", refcount);
8034  IDirect3D9_Release(d3d);
8036 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define D3DERR_INVALIDCALL
HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skip_constants, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6789
BOOL WINAPI DestroyWindow(_In_ HWND)
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
static const DWORD test_two_techniques_blob[]
Definition: effect.c:7912
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
#define S_FALSE
Definition: winerror.h:2357
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
#define D3D_SDK_VERSION
Definition: d3d8.h:56
LONG HRESULT
Definition: typedefs.h:78
static const DWORD test_effect_unsupported_shader_blob[]
Definition: effect.c:7189
static IHTMLWindow2 * window
Definition: events.c:77
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define D3DCREATE_HARDWARE_VERTEXPROCESSING
Definition: d3d8.h:45
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128

Referenced by START_TEST().

◆ test_effect_get_pass_desc()

static void test_effect_get_pass_desc ( IDirect3DDevice9 *  device)
static

Definition at line 6928 of file effect.c.

6929 {
6930  unsigned int passes_count;
6931  ID3DXEffect *effect;
6933  D3DXVECTOR4 fvect;
6934  D3DXHANDLE pass;
6935  HRESULT hr;
6936 
6938  NULL, NULL, 0, NULL, &effect, NULL);
6939  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6940 
6941  pass = effect->lpVtbl->GetPass(effect, "tech0", 1);
6942  ok(!!pass, "GetPass() failed.\n");
6943 
6944  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6945  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6946  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 2, FALSE);
6947 
6948  fvect.x = fvect.y = fvect.w = 0.0f;
6949  fvect.z = 0.0f;
6950  hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6951  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6952 
6953  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6954  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6955  ok(!desc.pPixelShaderFunction, "Unexpected non null desc.pPixelShaderFunction.\n");
6956 
6957  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 0, FALSE);
6958 
6959  fvect.z = 3.0f;
6960  hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6961  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6962 
6963  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6964  ok(hr == E_FAIL, "Got result %#x.\n", hr);
6965  ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
6966 
6967  /* Repeating call to confirm GetPassDesc() returns same error on the second call,
6968  * as it is not the case sometimes for BeginPass() with out of bound access. */
6969  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6970  ok(hr == E_FAIL, "Got result %#x.\n", hr);
6971  ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
6972 
6973  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
6974  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6975 
6976  hr = effect->lpVtbl->BeginPass(effect, 1);
6977  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6978 
6979  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6980  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6981 
6982  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 0, FALSE);
6983 
6984  fvect.z = 2.0f;
6985  hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6986  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6987  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6988  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 2, FALSE);
6989 
6990  effect->lpVtbl->Release(effect);
6991 
6993  NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
6994  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6995 
6996  pass = effect->lpVtbl->GetPass(effect, "tech0", 1);
6997  ok(!!pass, "GetPass() failed.\n");
6998 
6999  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7000  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7001 
7002  ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
7003  ok(!desc.pPixelShaderFunction, "Unexpected non null desc.pPixelShaderFunction.\n");
7004 
7005  effect->lpVtbl->Release(effect);
7006 }
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define E_FAIL
Definition: ddrawi.h:102
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
pass
Definition: typegen.h:24
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
static const WCHAR desc[]
Definition: protectdata.c:36
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define test_effect_preshader_compare_shader_bytecode(a, b, c, d)
Definition: effect.c:4286
#define D3DXFX_NOT_CLONEABLE
Definition: d3dx9effect.h:27

Referenced by START_TEST().

◆ test_effect_isparameterused()

static void test_effect_isparameterused ( IDirect3DDevice9 *  device)
static

Definition at line 5174 of file effect.c.

5175 {
5176  static const struct
5177  {
5178  const char *name;
5180  }
5181  check_parameters[] =
5182  {
5183  {"g_Pos1", TRUE},
5184  {"g_Pos2", TRUE},
5185  {"g_Selector", TRUE},
5186  {"opvect1", TRUE},
5187  {"opvect2", TRUE},
5188  {"opvect3", TRUE},
5189  {"arr2", TRUE},
5190  {"vs_arr", TRUE},
5191  {"g_iVect", TRUE},
5192  {"vect_sampler", TRUE},
5193  {"tex1", TRUE},
5194  {"tex2", FALSE},
5195  {"sampler1", TRUE},
5196  {"ts1", TRUE},
5197  {"ts2", TRUE},
5198  {"ts3", TRUE},
5199  };
5200  ID3DXEffect *effect, *effect2;
5201  HRESULT hr;
5202  D3DXHANDLE tech;
5203  unsigned int i;
5204 
5206  NULL, NULL, 0, NULL, &effect, NULL);
5207  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5208 
5209  tech = effect->lpVtbl->GetTechniqueByName(effect, "tech0");
5210  ok(!!tech, "GetTechniqueByName failed.\n");
5211 
5212  for (i = 0; i < ARRAY_SIZE(check_parameters); ++i)
5213  test_isparameterused_param_with_children(effect, NULL, tech, check_parameters[i].name,
5214  check_parameters[i].expected_result);
5215 
5217  NULL, NULL, 0, NULL, &effect2, NULL);
5218  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5219 
5220  for (i = 0; i < ARRAY_SIZE(check_parameters); ++i)
5221  test_isparameterused_param_with_children(effect, effect2, tech, check_parameters[i].name,
5222  check_parameters[i].expected_result);
5223 
5224  effect2->lpVtbl->Release(effect2);
5225 
5227  NULL, NULL, 0, NULL, &effect2, NULL);
5228  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5229 
5230  test_isparameterused_param_with_children(effect, effect2, tech, "sampler1", TRUE);
5231  effect2->lpVtbl->Release(effect2);
5232 
5233  effect->lpVtbl->Release(effect);
5234 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
smooth NULL
Definition: ftsmooth.c:416
static const DWORD test_effect_states_effect_blob[]
Definition: effect.c:2952
LONG HRESULT
Definition: typedefs.h:78
#define D3D_OK
Definition: d3d.h:106
#define test_isparameterused_param_with_children(args...)
Definition: effect.c:5151
const char * name
Definition: effect.c:225
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
const char * expected_result
Definition: mimeole.c:1468
Definition: name.c:38

Referenced by START_TEST().

◆ test_effect_large_address_aware_flag()

static void test_effect_large_address_aware_flag ( IDirect3DDevice9 *  device)
static

Definition at line 6895 of file effect.c.

6896 {
6897  ID3DXEffect *effect;
6898  D3DXHANDLE param;
6899  static int expected_ivect[4] = {28, 29, 30, 31};
6900  int ivect[4];
6901  HRESULT hr;
6902 
6904  NULL, NULL, D3DXFX_LARGEADDRESSAWARE, NULL, &effect, NULL);
6905  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6906 
6907  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
6908  ok(!!param, "GetParameterByName failed.\n");
6909 
6910  hr = effect->lpVtbl->SetValue(effect, param, expected_ivect, sizeof(expected_ivect));
6911  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6912 
6913  hr = effect->lpVtbl->GetValue(effect, param, ivect, sizeof(ivect));
6914  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6915 
6916  ok(!memcmp(ivect, expected_ivect, sizeof(expected_ivect)), "Vector value mismatch.\n");
6917 
6918  if (0)
6919  {
6920  /* Native d3dx crashes in GetValue(). */
6921  hr = effect->lpVtbl->GetValue(effect, "g_iVect", ivect, sizeof(ivect));
6922  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
6923  }
6924 
6925  effect->lpVtbl->Release(effect);
6926 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define D3DERR_INVALIDCALL
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
GLfloat param
Definition: glext.h:5796
#define D3DXFX_LARGEADDRESSAWARE
Definition: d3dx9effect.h:28
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

◆ test_effect_null_shader()

static void test_effect_null_shader ( void  )
static

Definition at line 7351 of file effect.c.

7352 {
7353  IDirect3DDevice9 *device;
7354  ID3DXEffect *effect;
7356  D3DXHANDLE pass;
7357  ULONG refcount;
7358  HWND window;
7359  HRESULT hr;
7360 
7361  /* Creating a fresh device because the existing device can have invalid
7362  * render states from previous tests. If IDirect3DDevice9_ValidateDevice()
7363  * returns certain error codes, native ValidateTechnique() fails. */
7364  if (!(device = create_device(&window)))
7365  return;
7366 
7368  sizeof(test_effect_null_shader_blob), NULL, NULL, NULL, 0, NULL, &effect, NULL);
7369  ok(hr == D3D_OK, "Failed to create effect, hr %#x.\n", hr);
7370 
7371  pass = effect->lpVtbl->GetPass(effect, "tech0", 0);
7372  ok(!!pass, "GetPass() failed.\n");
7373  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7374  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7375  ok(!desc.pVertexShaderFunction, "Got non NULL vertex function.\n");
7376 
7377  pass = effect->lpVtbl->GetPass(effect, "tech1", 0);
7378  ok(!!pass, "GetPass() failed.\n");
7379  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7380  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7381  ok(!desc.pVertexShaderFunction, "Got non NULL vertex function.\n");
7382 
7383  hr = effect->lpVtbl->ValidateTechnique(effect, "tech0");
7384  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7385  hr = effect->lpVtbl->SetInt(effect, "i", 0);
7386  ok(hr == D3D_OK, "Failed to set parameter, hr %#x.\n", hr);
7387  hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7388  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7389  hr = effect->lpVtbl->SetInt(effect, "i", 1);
7390  ok(hr == D3D_OK, "Failed to set parameter, hr %#x.\n", hr);
7391  hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7392  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7393 
7394  hr = effect->lpVtbl->SetInt(effect, "i", 2);
7395  ok(hr == D3D_OK, "Failed to set parameter, hr %#x.\n", hr);
7396  hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7397  ok(hr == E_FAIL, "Got result %#x.\n", hr);
7398 
7399  effect->lpVtbl->Release(effect);
7400 
7401  refcount = IDirect3DDevice9_Release(device);
7402  ok(!refcount, "Device has %u references left.\n", refcount);
7404 }
static IDirect3DDevice9 * create_device(HWND *window)
Definition: effect.c:150
HRESULT hr
Definition: shlfolder.c:183
static const DWORD test_effect_null_shader_blob[]
Definition: effect.c:7328
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, const char *skip_constants, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6789
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI DestroyWindow(_In_ HWND)
pass
Definition: typegen.h:24
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
static IHTMLWindow2 * window
Definition: events.c:77
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1

Referenced by START_TEST().

◆ test_effect_out_of_bounds_selector()

static void test_effect_out_of_bounds_selector ( IDirect3DDevice9 *  device)
static

Definition at line 5236 of file effect.c.

5237 {
5238  ID3DXEffect *effect;
5239  HRESULT hr;
5240  D3DXHANDLE param;
5241  int ivect[4];
5242  unsigned int passes_count;
5243  IDirect3DVertexShader9 *vshader;
5244 
5246  NULL, NULL, 0, NULL, &effect, NULL);
5247 
5248  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5249  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5250 
5251  ivect[0] = ivect[1] = ivect[3] = 1;
5252 
5253  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5254  ok(!!param, "GetParameterByName failed.\n");
5255  ivect[2] = 3;
5256  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5257  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5258 
5259  hr = effect->lpVtbl->BeginPass(effect, 0);
5260  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5261  hr = effect->lpVtbl->EndPass(effect);
5262  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5263 
5265  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5266 
5267  hr = effect->lpVtbl->BeginPass(effect, 1);
5268  ok(hr == E_FAIL, "Got result %#x.\n", hr);
5269 
5270  /* Second try reports success and selects array element used previously.
5271  * Probably array index is not recomputed and previous index value is used. */
5272  hr = effect->lpVtbl->BeginPass(effect, 1);
5273  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5275 
5276  /* Confirm that array element selected is the previous good one and does not depend
5277  * on computed (out of bound) index value. */
5278  ivect[2] = 1;
5279  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5280  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5282  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5283  hr = effect->lpVtbl->CommitChanges(effect);
5284  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5286  hr = effect->lpVtbl->EndPass(effect);
5287  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5288  ivect[2] = 3;
5289  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5290  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5292  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5293  hr = effect->lpVtbl->BeginPass(effect, 1);
5294  ok(hr == E_FAIL, "Got result %#x.\n", hr);
5295  hr = effect->lpVtbl->BeginPass(effect, 1);
5296  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5298 
5299  /* End and begin effect again to ensure it will not trigger array
5300  * index recompute and error return from BeginPass. */
5301  hr = effect->lpVtbl->EndPass(effect);
5302  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5303  hr = effect->lpVtbl->End(effect);
5304  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5305  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5306  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5307  hr = effect->lpVtbl->BeginPass(effect, 1);
5308  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5310  hr = effect->lpVtbl->EndPass(effect);
5311  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5312 
5313 
5315  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5316 
5317  ivect[2] = -2;
5318  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5319  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5320 
5321  hr = effect->lpVtbl->BeginPass(effect, 1);
5322  ok(hr == E_FAIL, "Got result %#x.\n", hr);
5323 
5325  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5326  ok(!vshader, "Got non NULL vshader.\n");
5327 
5328  hr = effect->lpVtbl->BeginPass(effect, 1);
5329  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5330 
5332 
5333  hr = effect->lpVtbl->EndPass(effect);
5334  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5335 
5336  ivect[2] = -1;
5337  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5338  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5339 
5340  hr = effect->lpVtbl->BeginPass(effect, 1);
5341  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5342 
5344 
5346  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5347 
5348  ivect[2] = 3;
5349  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5350  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5351  hr = effect->lpVtbl->CommitChanges(effect);
5352  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5353 
5355  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5356  ok(!vshader, "Got non NULL vshader.\n");
5357 
5358  ivect[2] = -1;
5359  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5360  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5361  hr = effect->lpVtbl->CommitChanges(effect);
5362  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5363 
5365  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5366  ok(!vshader, "Got non NULL vshader.\n");
5367 
5368  ivect[2] = 1;
5369  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5370  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5371  hr = effect->lpVtbl->CommitChanges(effect);
5372  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5373 
5375 
5376  hr = effect->lpVtbl->EndPass(effect);
5377  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5378 
5379  hr = effect->lpVtbl->End(effect);
5380  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5381 
5382  effect->lpVtbl->Release(effect);
5383 }
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define E_FAIL
Definition: ddrawi.h:102
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3493
Definition: devices.h:37
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *srcdata, UINT srcdatalen, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **compilation_errors)
Definition: effect.c:6834
smooth NULL
Definition: ftsmooth.c:416
#define IDirect3DDevice9_GetVertexShader(p, a)
Definition: d3d9.h:1600
LONG HRESULT
Definition: typedefs.h:78
GLfloat param
Definition: glext.h:5796
#define IDirect3DDevice9_SetVertexShader(p, a)
Definition: d3d9.h:1599
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define test_effect_preshader_compare_shader(a, b, c)
Definition: effect.c:4313

Referenced by START_TEST().

◆ test_effect_parameter_value()

static void test_effect_parameter_value ( IDirect3DDevice9 *  device)
static

Definition at line 1784 of file effect.c.

1785 {
1786  unsigned int effect_count = ARRAY_SIZE(test_effect_parameter_value_data), i;
1787 
1788  for (i = 0; i < effect_count; ++i)
1789  {
1794  HRESULT hr;
1795  ID3DXEffect *effect;
1796  D3DXEFFECT_DESC edesc;
1797  ULONG count;
1798  UINT k;
1799 
1800  hr = D3DXCreateEffect(device, blob, blob_size, NULL, NULL, 0, NULL, &effect, NULL);
1801  ok(hr == D3D_OK, "%u: D3DXCreateEffect failed, got %#x, expected %#x\n", i, hr, D3D_OK);
1802 
1803  hr = effect->lpVtbl->GetDesc(effect, &edesc);
1804  ok(hr == D3D_OK, "%u: GetDesc failed, got %#x, expected %#x\n", i, hr, D3D_OK);
1805  ok(edesc.Parameters == res_count, "%u: Parameters failed, got %u, expected %u\n",
1806  i, edesc.Parameters, res_count);
1807 
1808  for (k = 0; k < res_count; ++k)
1809  {
1810  const D3DXPARAMETER_DESC *res_desc = &res[k].desc;
1811  const char *res_full_name = res[k].full_name;
1812  UINT res_value_offset = res[k].value_offset;
1813  D3DXHANDLE parameter;
1814  D3DXPARAMETER_DESC pdesc;
1815  BOOL bvalue = TRUE;
1816  INT ivalue = 42;
1817  FLOAT fvalue = 2.71828f;
1819  DWORD expected_value[EFFECT_PARAMETER_VALUE_ARRAY_SIZE];
1820  UINT l, n, m, element;
1821  const D3DXMATRIX *matrix_pointer_array[sizeof(input_value)/sizeof(D3DXMATRIX)];
1822 
1823  parameter = effect->lpVtbl->GetParameterByName(effect, NULL, res_full_name);
1824  ok(parameter != NULL, "%u - %s: GetParameterByName failed\n", i, res_full_name);
1825 
1826  hr = effect->lpVtbl->GetParameterDesc(effect, parameter, &pdesc);
1827  ok(hr == D3D_OK, "%u - %s: GetParameterDesc failed, got %#x, expected %#x\n", i, res_full_name, hr, D3D_OK);
1828 
1829  ok(res_desc->Name ? !strcmp(pdesc.Name, res_desc->Name) : !pdesc.Name,
1830  "%u - %s: GetParameterDesc Name failed, got \"%s\", expected \"%s\"\n",
1831  i, res_full_name, pdesc.Name, res_desc->Name);
1832  ok(res_desc->Semantic ? !strcmp(pdesc.Semantic, res_desc->Semantic) : !pdesc.Semantic,
1833  "%u - %s: GetParameterDesc Semantic failed, got \"%s\", expected \"%s\"\n",
1834  i, res_full_name, pdesc.Semantic, res_desc->Semantic);
1835  ok(res_desc->Class == pdesc.Class, "%u - %s: GetParameterDesc Class failed, got %#x, expected %#x\n",
1836  i, res_full_name, pdesc.Class, res_desc->Class);
1837  ok(res_desc->Type == pdesc.Type, "%u - %s: GetParameterDesc Type failed, got %#x, expected %#x\n",
1838  i, res_full_name, pdesc.Type, res_desc->Type);
1839  ok(res_desc->Rows == pdesc.Rows, "%u - %s: GetParameterDesc Rows failed, got %u, expected %u\n",
1840  i, res_full_name, pdesc.Rows, res_desc->Rows);
1841  ok(res_desc->Columns == pdesc.Columns, "%u - %s: GetParameterDesc Columns failed, got %u, expected %u\n",
1842  i, res_full_name, pdesc.Columns, res_desc->Columns);
1843  ok(res_desc->Elements == pdesc.Elements, "%u - %s: GetParameterDesc Elements failed, got %u, expected %u\n",
1844  i, res_full_name, pdesc.Elements, res_desc->Elements);
1845  ok(res_desc->Annotations == pdesc.Annotations, "%u - %s: GetParameterDesc Annotations failed, got %u, expected %u\n",
1846  i, res_full_name, pdesc.Annotations, res_desc->Annotations);
1847  ok(res_desc->StructMembers == pdesc.StructMembers, "%u - %s: GetParameterDesc StructMembers failed, got %u, expected %u\n",
1848  i, res_full_name, pdesc.StructMembers, res_desc->StructMembers);
1849  ok(res_desc->Flags == pdesc.Flags, "%u - %s: GetParameterDesc Flags failed, got %u, expected %u\n",
1850  i, res_full_name, pdesc.Flags, res_desc->Flags);
1851  ok(res_desc->Bytes == pdesc.Bytes, "%u - %s: GetParameterDesc Bytes, got %u, expected %u\n",
1852  i, res_full_name, pdesc.Bytes, res_desc->Bytes);
1853 
1854  /* check size */
1855  ok(EFFECT_PARAMETER_VALUE_ARRAY_SIZE >= res_desc->Bytes / 4 +
1856  (res_desc->Elements ? res_desc->Bytes / 4 / res_desc->Elements : 0),
1857  "%u - %s: Warning: Array size too small\n", i, res_full_name);
1858 
1859  test_effect_parameter_value_GetTestGroup(&res[k], effect, &blob[res_value_offset], parameter, i);
1860  test_effect_parameter_value_ResetValue(&res[k], effect, &blob[res_value_offset], parameter, i);
1861  test_effect_parameter_value_GetTestGroup(&res[k], effect, &blob[res_value_offset], parameter, i);
1862 
1863  /*
1864  * check invalid calls
1865  * These will crash:
1866  * effect->lpVtbl->SetBoolArray(effect, parameter, NULL, res_desc->Bytes / sizeof(BOOL));
1867  * effect->lpVtbl->SetIntArray(effect, parameter, NULL, res_desc->Bytes / sizeof(INT));
1868  * effect->lpVtbl->SetFloatArray(effect, parameter, NULL, res_desc->Bytes / sizeof(FLOAT));
1869  * effect->lpVtbl->SetVector(effect, parameter, NULL);
1870  * effect->lpVtbl->SetVectorArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1871  * effect->lpVtbl->SetMatrix(effect, parameter, NULL);
1872  * effect->lpVtbl->GetMatrix(effect, parameter, NULL);
1873  * effect->lpVtbl->SetMatrixArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1874  * effect->lpVtbl->SetMatrixPointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1875  * effect->lpVtbl->SetMatrixTranspose(effect, parameter, NULL);
1876  * effect->lpVtbl->SetMatrixTransposeArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1877  * effect->lpVtbl->SetMatrixTransposePointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1878  * effect->lpVtbl->GetValue(effect, parameter, NULL, res_desc->Bytes);
1879  * effect->lpVtbl->SetValue(effect, parameter, NULL, res_desc->Bytes);
1880  */
1881  hr = effect->lpVtbl->SetBool(effect, NULL, bvalue);
1882  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetBool failed, got %#x, expected %#x\n",
1883  i, res_full_name, hr, D3DERR_INVALIDCALL);
1884 
1885  hr = effect->lpVtbl->GetBool(effect, NULL, &bvalue);
1886  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBool failed, got %#x, expected %#x\n",
1887  i, res_full_name, hr, D3DERR_INVALIDCALL);
1888 
1889  hr = effect->lpVtbl->GetBool(effect, parameter, NULL);
1890  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBool failed, got %#x, expected %#x\n",
1891  i, res_full_name, hr, D3DERR_INVALIDCALL);
1892 
1893  hr = effect->lpVtbl->SetBoolArray(effect, NULL, (BOOL *)input_value, res_desc->Bytes / sizeof(BOOL));
1894  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetBoolArray failed, got %#x, expected %#x\n",
1895  i, res_full_name, hr, D3DERR_INVALIDCALL);
1896 
1897  hr = effect->lpVtbl->GetBoolArray(effect, NULL, (BOOL *)input_value, res_desc->Bytes / sizeof(BOOL));
1898  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBoolArray failed, got %#x, expected %#x\n",
1899  i, res_full_name, hr, D3DERR_INVALIDCALL);
1900 
1901  hr = effect->lpVtbl->GetBoolArray(effect, parameter, NULL, res_desc->Bytes / sizeof(BOOL));
1902  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetBoolArray failed, got %#x, expected %#x\n",
1903  i, res_full_name, hr, D3DERR_INVALIDCALL);
1904 
1905  hr = effect->lpVtbl->SetInt(effect, NULL, ivalue);
1906  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetInt failed, got %#x, expected %#x\n",
1907  i, res_full_name, hr, D3DERR_INVALIDCALL);
1908 
1909  hr = effect->lpVtbl->GetInt(effect, NULL, &ivalue);
1910  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetInt failed, got %#x, expected %#x\n",
1911  i, res_full_name, hr, D3DERR_INVALIDCALL);
1912 
1913  hr = effect->lpVtbl->GetInt(effect, parameter, NULL);
1914  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetInt failed, got %#x, expected %#x\n",
1915  i, res_full_name, hr, D3DERR_INVALIDCALL);
1916 
1917  hr = effect->lpVtbl->SetIntArray(effect, NULL, (INT *)input_value, res_desc->Bytes / sizeof(INT));
1918  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetIntArray failed, got %#x, expected %#x\n",
1919  i, res_full_name, hr, D3DERR_INVALIDCALL);
1920 
1921  hr = effect->lpVtbl->GetIntArray(effect, NULL, (INT *)input_value, res_desc->Bytes / sizeof(INT));
1922  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetIntArray failed, got %#x, expected %#x\n",
1923  i, res_full_name, hr, D3DERR_INVALIDCALL);
1924 
1925  hr = effect->lpVtbl->GetIntArray(effect, parameter, NULL, res_desc->Bytes / sizeof(INT));
1926  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetIntArray failed, got %#x, expected %#x\n",
1927  i, res_full_name, hr, D3DERR_INVALIDCALL);
1928 
1929  hr = effect->lpVtbl->SetFloat(effect, NULL, fvalue);
1930  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetFloat failed, got %#x, expected %#x\n",
1931  i, res_full_name, hr, D3DERR_INVALIDCALL);
1932 
1933  hr = effect->lpVtbl->GetFloat(effect, NULL, &fvalue);
1934  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloat failed, got %#x, expected %#x\n",
1935  i, res_full_name, hr, D3DERR_INVALIDCALL);
1936 
1937  hr = effect->lpVtbl->GetFloat(effect, parameter, NULL);
1938  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloat failed, got %#x, expected %#x\n",
1939  i, res_full_name, hr, D3DERR_INVALIDCALL);
1940 
1941  hr = effect->lpVtbl->SetFloatArray(effect, NULL, (FLOAT *)input_value, res_desc->Bytes / sizeof(FLOAT));
1942  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetFloatArray failed, got %#x, expected %#x\n",
1943  i, res_full_name, hr, D3DERR_INVALIDCALL);
1944 
1945  hr = effect->lpVtbl->GetFloatArray(effect, NULL, (FLOAT *)input_value, res_desc->Bytes / sizeof(FLOAT));
1946  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloatArray failed, got %#x, expected %#x\n",
1947  i, res_full_name, hr, D3DERR_INVALIDCALL);
1948 
1949  hr = effect->lpVtbl->GetFloatArray(effect, parameter, NULL, res_desc->Bytes / sizeof(FLOAT));
1950  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetFloatArray failed, got %#x, expected %#x\n",
1951  i, res_full_name, hr, D3DERR_INVALIDCALL);
1952 
1953  hr = effect->lpVtbl->SetVector(effect, NULL, (D3DXVECTOR4 *)input_value);
1954  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetVector failed, got %#x, expected %#x\n",
1955  i, res_full_name, hr, D3DERR_INVALIDCALL);
1956 
1957  hr = effect->lpVtbl->GetVector(effect, NULL, (D3DXVECTOR4 *)input_value);
1958  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVector failed, got %#x, expected %#x\n",
1959  i, res_full_name, hr, D3DERR_INVALIDCALL);
1960 
1961  hr = effect->lpVtbl->GetVector(effect, parameter, NULL);
1962  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVector failed, got %#x, expected %#x\n",
1963  i, res_full_name, hr, D3DERR_INVALIDCALL);
1964 
1965  hr = effect->lpVtbl->SetVectorArray(effect, NULL, (D3DXVECTOR4 *)input_value, res_desc->Elements ? res_desc->Elements : 1);
1966  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetVectorArray failed, got %#x, expected %#x\n",
1967  i, res_full_name, hr, D3DERR_INVALIDCALL);
1968 
1969  hr = effect->lpVtbl->GetVectorArray(effect, NULL, (D3DXVECTOR4 *)input_value, res_desc->Elements ? res_desc->Elements : 1);
1970  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVectorArray failed, got %#x, expected %#x\n",
1971  i, res_full_name, hr, D3DERR_INVALIDCALL);
1972 
1973  hr = effect->lpVtbl->GetVectorArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1974  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetVectorArray failed, got %#x, expected %#x\n",
1975  i, res_full_name, hr, D3DERR_INVALIDCALL);
1976 
1977  hr = effect->lpVtbl->SetMatrix(effect, NULL, (D3DXMATRIX *)input_value);
1978  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrix failed, got %#x, expected %#x\n",
1979  i, res_full_name, hr, D3DERR_INVALIDCALL);
1980 
1981  hr = effect->lpVtbl->GetMatrix(effect, NULL, (D3DXMATRIX *)input_value);
1982  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrix failed, got %#x, expected %#x\n",
1983  i, res_full_name, hr, D3DERR_INVALIDCALL);
1984 
1985  hr = effect->lpVtbl->SetMatrixArray(effect, NULL, (D3DXMATRIX *)input_value, res_desc->Elements ? res_desc->Elements : 1);
1986  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixArray failed, got %#x, expected %#x\n",
1987  i, res_full_name, hr, D3DERR_INVALIDCALL);
1988 
1989  hr = effect->lpVtbl->GetMatrixArray(effect, NULL, (D3DXMATRIX *)input_value, res_desc->Elements ? res_desc->Elements : 1);
1990  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixArray failed, got %#x, expected %#x\n",
1991  i, res_full_name, hr, D3DERR_INVALIDCALL);
1992 
1993  hr = effect->lpVtbl->GetMatrixArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
1994  ok(hr == D3DERR_INVALIDCALL, "%u - %s: GetMatrixArray failed, got %#x, expected %#x\n",
1995  i, res_full_name, hr, D3DERR_INVALIDCALL);
1996 
1997  hr = effect->lpVtbl->SetMatrixPointerArray(effect, NULL, matrix_pointer_array, res_desc->Elements ? res_desc->Elements : 1);
1998  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixPointerArray failed, got %#x, expected %#x\n",
1999  i, res_full_name, hr, D3DERR_INVALIDCALL);
2000 
2001  hr = effect->lpVtbl->SetMatrixPointerArray(effect, NULL, matrix_pointer_array, 0);
2002  ok(hr == D3DERR_INVALIDCALL, "%u - %s: SetMatrixPointerArray failed, got %#x, expected %#x\n",
2003  i, res_full_name, hr, D3DERR_INVALIDCALL);
2004 
2005  hr = effect->lpVtbl->GetMatrixPointerArray(effect, NULL, NULL, 0);
2006  ok(hr == D3D_OK, "%u - %s: GetMatrixPointerArray failed, got %#x, expected %#x\n",
2007  i, res_full_name, hr, D3D_OK);
2008 
2009  hr = effect->lpVtbl->GetMatrixPointerArray(effect,