ReactOS  0.4.15-dev-2945-g7100a24
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 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 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)
 
static void test_effect_parameter_block (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 971 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 996 of file effect.c.

◆ INITIAL_UPDATE_RECORD_SIZE

#define INITIAL_UPDATE_RECORD_SIZE   64

Definition at line 6063 of file effect.c.

◆ INT_FLOAT_MULTI

#define INT_FLOAT_MULTI   255.0f

Definition at line 998 of file effect.c.

◆ INT_FLOAT_MULTI_INVERSE

#define INT_FLOAT_MULTI_INVERSE   (1/INT_FLOAT_MULTI)

Definition at line 999 of file effect.c.

◆ TEST_EFFECT_BITMASK_BLOCK_SIZE

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

Definition at line 4447 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 4517 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 4294 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 4267 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 4449 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 4371 of file effect.c.

◆ TEST_EFFECT_PRESHADER_VSHADER_LEN

#define TEST_EFFECT_PRESHADER_VSHADER_LEN   13

Definition at line 4265 of file effect.c.

◆ TEST_EFFECT_PRESHADER_VSHADER_POS

#define TEST_EFFECT_PRESHADER_VSHADER_POS   2991

Definition at line 4264 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 6587 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 6561 of file effect.c.

◆ TEST_EFFECT_STATES_VSHADER_POS

#define TEST_EFFECT_STATES_VSHADER_POS   315

Definition at line 2992 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 7198 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 7197 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 5132 of file effect.c.

Enumeration Type Documentation

◆ expected_state_update

Enumerator
EXPECTED_STATE_ZERO 
EXPECTED_STATE_UPDATED 
EXPECTED_STATE_ANYTHING 

Definition at line 4364 of file effect.c.

Function Documentation

◆ compare_float()

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

Definition at line 26 of file effect.c.

27 {
28  INT x = *(INT *)&f;
29  INT y = *(INT *)&g;
30 
31  if (x < 0)
32  x = INT_MIN - x;
33  if (y < 0)
34  y = INT_MIN - y;
35 
36  if (abs(x - y) > ulps)
37  return FALSE;
38 
39  return TRUE;
40 }
#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:58
#define FALSE
Definition: types.h:117
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:4332

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 6298 of file effect.c.

6299 {
6300  const struct test_state_manager_update *r1 = (const struct test_state_manager_update *)a;
6301  const struct test_state_manager_update *r2 = (const struct test_state_manager_update *)b;
6302 
6303  if (r1->state_op != r2->state_op)
6304  return r1->state_op - r2->state_op;
6305  if (r1->param1 != r2->param1)
6306  return r1->param1 - r2->param1;
6307  return r1->param2 - r2->param2;
6308 }
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 131 of file effect.c.

132 {
133  D3DPRESENT_PARAMETERS present_parameters = { 0 };
134  IDirect3DDevice9 *device;
135  IDirect3D9 *d3d;
136  HRESULT hr;
137  HWND wnd;
138 
139  *window = NULL;
140 
141  if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
142  640, 480, NULL, NULL, NULL, NULL)))
143  {
144  skip("Couldn't create application window.\n");
145  return NULL;
146  }
147 
148  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
149  {
150  skip("Couldn't create IDirect3D9 object.\n");
151  DestroyWindow(wnd);
152  return NULL;
153  }
154 
155  present_parameters.Windowed = TRUE;
156  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
158  &present_parameters, &device);
159  IDirect3D9_Release(d3d);
160  if (FAILED(hr))
161  {
162  skip("Failed to create IDirect3DDevice9 object %#x.\n", hr);
163  DestroyWindow(wnd);
164  return NULL;
165  }
166 
167  *window = wnd;
168  return device;
169 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
BOOL WINAPI DestroyWindow(_In_ HWND)
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
FxDevice * device
#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 D3D_SDK_VERSION
Definition: d3d8.h:56
LONG HRESULT
Definition: typedefs.h:79
static IHTMLWindow2 * window
Definition: events.c:77
#define NULL
Definition: types.h:112
#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 210 of file effect.c.

211 {
212  char path[MAX_PATH];
213 
215  strcat(path, name);
216  return CreateDirectoryA(path, NULL);
217 }
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
#define MAX_PATH
Definition: compat.h:34
static char temp_path[MAX_PATH]
Definition: effect.c:171
#define NULL
Definition: types.h:112
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 173 of file effect.c.

174 {
175  DWORD written;
176  HANDLE hfile;
177  char path[MAX_PATH];
178 
179  if (!*temp_path)
180  GetTempPathA(sizeof(temp_path), temp_path);
181 
183  strcat(path, filename);
185  if (hfile == INVALID_HANDLE_VALUE)
186  return FALSE;
187 
188  if (WriteFile(hfile, data, size, &written, NULL))
189  {
190  CloseHandle(hfile);
191 
192  if (out_path)
193  strcpy(out_path, path);
194  return TRUE;
195  }
196 
197  CloseHandle(hfile);
198  return FALSE;
199 }
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 CloseHandle
Definition: compat.h:598
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
const char * filename
Definition: ioapi.h:135
#define FALSE
Definition: types.h:117
#define GENERIC_WRITE
Definition: nt_native.h:90
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:34
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:171
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define NULL
Definition: types.h:112
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599

Referenced by test_create_effect_from_file().

◆ d3dxinclude_close()

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

Definition at line 7657 of file effect.c.

7658 {
7659  HeapFree(GetProcessHeap(), 0, (void *)data);
7660  return S_OK;
7661 }
#define GetProcessHeap()
Definition: compat.h:595
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:51
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ 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 7579 of file effect.c.

7581 {
7582  static const char include1[] =
7583  "float4 light;\n"
7584  "float4x4 mat;\n"
7585  "float4 color;\n"
7586  "\n"
7587  "struct vs_input\n"
7588  "{\n"
7589  " float4 position : POSITION;\n"
7590  " float3 normal : NORMAL;\n"
7591  "};\n"
7592  "\n"
7593  "struct vs_output\n"
7594  "{\n"
7595  " float4 position : POSITION;\n"
7596  " float4 diffuse : COLOR;\n"
7597  "};\n";
7598  static const char include2[] =
7599  "#include \"include1.h\"\n"
7600  "\n"
7601  "vs_output vs_main(const vs_input v)\n"
7602  "{\n"
7603  " vs_output o;\n"
7604  " const float4 scaled_color = 0.5 * color;\n"
7605  "\n"
7606  " o.position = mul(v.position, mat);\n"
7607  " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
7608  "\n"
7609  " return o;\n"
7610  "}\n";
7611  static const char effect2[] =
7612  "#include \"include\\include2.h\"\n"
7613  "\n"
7614  "technique t\n"
7615  "{\n"
7616  " pass p\n"
7617  " {\n"
7618  " VertexShader = compile vs_2_0 vs_main();\n"
7619  " }\n"
7620  "}\n";
7621  char *buffer;
7622 
7623  trace("filename %s.\n", filename);
7624  trace("parent_data %p: %s.\n", parent_data, parent_data ? (char *)parent_data : "(null)");
7625 
7626  if (!strcmp(filename, "effect2.fx"))
7627  {
7628  buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(effect2));
7629  memcpy(buffer, effect2, sizeof(effect2));
7630  *bytes = sizeof(effect2);
7631  ok(!parent_data, "Unexpected parent_data value.\n");
7632  }
7633  else if (!strcmp(filename, "include1.h"))
7634  {
7635  buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include1));
7636  memcpy(buffer, include1, sizeof(include1));
7637  *bytes = sizeof(include1);
7638  ok(!strncmp(parent_data, include2, strlen(include2)), "Unexpected parent_data value.\n");
7639  }
7640  else if (!strcmp(filename, "include\\include2.h"))
7641  {
7642  buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2));
7643  memcpy(buffer, include2, sizeof(include2));
7644  *bytes = sizeof(include2);
7645  todo_wine ok(parent_data && !strncmp(parent_data, effect2, strlen(effect2)),
7646  "unexpected parent_data value.\n");
7647  }
7648  else
7649  {
7650  ok(0, "Unexpected #include for file %s.\n", filename);
7651  return D3DERR_INVALIDCALL;
7652  }
7653  *data = buffer;
7654  return S_OK;
7655 }
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:595
#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:164
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:51
#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 219 of file effect.c.

220 {
221  char path[MAX_PATH];
222 
224  strcat(path, name);
226 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define MAX_PATH
Definition: compat.h:34
static char temp_path[MAX_PATH]
Definition: effect.c:171
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 201 of file effect.c.

202 {
203  char path[MAX_PATH];
204 
206  strcat(path, filename);
207  DeleteFileA(path);
208 }
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:34
static char temp_path[MAX_PATH]
Definition: effect.c:171
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 6070 of file effect.c.

6071 {
6072  HeapFree(GetProcessHeap(), 0, state_manager->update_record);
6073  state_manager->update_record = NULL;
6074 
6075  IDirect3DDevice9_Release(state_manager->device);
6076 }
struct test_state_manager_update * update_record
Definition: effect.c:6058
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define GetProcessHeap()
Definition: compat.h:595
#define NULL
Definition: types.h:112
IDirect3DDevice9 * device
Definition: effect.c:6057
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by test_manager_Release().

◆ get_bool()

static BOOL get_bool ( const void data)
inlinestatic

Definition at line 96 of file effect.c.

97 {
98  return !!*(BOOL *)data;
99 }
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 69 of file effect.c.

70 {
71  float f;
72 
73  switch (type)
74  {
75  case D3DXPT_FLOAT:
76  f = *(FLOAT *)data;
77  break;
78 
79  case D3DXPT_INT:
80  f = *(INT *)data;
81  break;
82 
83  case D3DXPT_BOOL:
84  f = *(BOOL *)data;
85  break;
86 
87  default:
88  f = 0.0f;
89  ok(0, "Unhandled type %x.\n", type);
90  break;
91  }
92 
93  return f;
94 }
int32_t INT
Definition: typedefs.h:58
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:69
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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 42 of file effect.c.

43 {
44  INT i;
45 
46  switch (type)
47  {
48  case D3DXPT_FLOAT:
49  i = *(FLOAT *)data;
50  break;
51 
52  case D3DXPT_INT:
53  i = *(INT *)data;
54  break;
55 
56  case D3DXPT_BOOL:
57  i = *(BOOL *)data;
58  break;
59 
60  default:
61  i = 0;
62  ok(0, "Unhandled type %x.\n", type);
63  break;
64  }
65 
66  return i;
67 }
int32_t INT
Definition: typedefs.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
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
#define ok(value,...)
Definition: atltest.h:57
float FLOAT
Definition: typedefs.h:69
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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

◆ get_texture_refcount()

static unsigned int get_texture_refcount ( IDirect3DTexture9 *  iface)
static

Definition at line 7462 of file effect.c.

7463 {
7464  IDirect3DTexture9_AddRef(iface);
7465  return IDirect3DTexture9_Release(iface);
7466 }
#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 6065 of file effect.c.

6066 {
6067  return CONTAINING_RECORD(iface, struct test_manager, ID3DXEffectStateManager_iface);
6068 }
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 101 of file effect.c.

102 {
103  switch (outtype)
104  {
105  case D3DXPT_FLOAT:
106  *(FLOAT *)outdata = get_float(intype, indata);
107  break;
108 
109  case D3DXPT_BOOL:
110  *(BOOL *)outdata = get_bool(indata);
111  break;
112 
113  case D3DXPT_INT:
114  *(INT *)outdata = get_int(intype, indata);
115  break;
116 
117  case D3DXPT_PIXELSHADER:
118  case D3DXPT_VERTEXSHADER:
119  case D3DXPT_TEXTURE2D:
120  case D3DXPT_STRING:
121  *(INT *)outdata = 0x12345678;
122  break;
123 
124  default:
125  ok(0, "Unhandled type %x.\n", outtype);
126  *(INT *)outdata = 0;
127  break;
128  }
129 }
static BOOL get_bool(const void *data)
Definition: effect.c:96
int32_t INT
Definition: typedefs.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
static INT get_int(D3DXPARAMETER_TYPE type, const void *data)
Definition: effect.c:42
#define ok(value,...)
Definition: atltest.h:57
static float get_float(D3DXPARAMETER_TYPE type, const void *data)
Definition: effect.c:69
float FLOAT
Definition: typedefs.h:69

Referenced by d3dx_effect_GetBool(), d3dx_effect_GetBoolArray(), d3dx_effect_GetFloat(), d3dx_effect_GetFloatArray(), d3dx_effect_GetInt(), d3dx_effect_GetIntArray(), d3dx_effect_SetBool(), d3dx_effect_SetBoolArray(), d3dx_effect_SetFloat(), d3dx_effect_SetFloatArray(), d3dx_effect_SetInt(), d3dx_effect_SetIntArray(), get_matrix(), get_vector(), set_matrix(), set_matrix_transpose(), set_vector(), and test_effect_parameter_value().

◆ START_TEST()

START_TEST ( effect  )

Definition at line 8359 of file effect.c.

8360 {
8361  IDirect3DDevice9 *device;
8362  ULONG refcount;
8363  HWND wnd;
8364 
8365  if (!(device = create_device(&wnd)))
8366  return;
8367 
8387 
8388  refcount = IDirect3DDevice9_Release(device);
8389  ok(!refcount, "Device has %u references left.\n", refcount);
8390  DestroyWindow(wnd);
8391 
8395  test_refcount();
8399 }
static IDirect3DDevice9 * create_device(HWND *window)
Definition: effect.c:131
static void test_effect_commitchanges(IDirect3DDevice9 *device)
Definition: effect.c:5366
static void test_effect_null_shader(void)
Definition: effect.c:7332
static void test_create_effect_and_pool(IDirect3DDevice9 *device)
Definition: effect.c:233
static void test_effect_preshader(IDirect3DDevice9 *device)
Definition: effect.c:4567
static void test_effect_parameter_block(void)
Definition: effect.c:8011
static void test_effect_compilation_errors(IDirect3DDevice9 *device)
Definition: effect.c:2865
static void test_effect_get_pass_desc(IDirect3DDevice9 *device)
Definition: effect.c:6909
BOOL WINAPI DestroyWindow(_In_ HWND)
static void test_effect_unsupported_shader(void)
Definition: effect.c:7200
static void test_effect_setvalue_object(IDirect3DDevice9 *device)
Definition: effect.c:2502
FxDevice * device
static void test_effect_find_next_valid_technique(void)
Definition: effect.c:7899
Definition: devices.h:37
static void test_create_effect_from_file(void)
Definition: effect.c:7674
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
static void test_effect_isparameterused(IDirect3DDevice9 *device)
Definition: effect.c:5155
static void test_effect_large_address_aware_flag(IDirect3DDevice9 *device)
Definition: effect.c:6876
static void test_effect_preshader_ops(IDirect3DDevice9 *device)
Definition: effect.c:5027
static void test_effect_preshader_relative_addressing(IDirect3DDevice9 *device)
Definition: effect.c:5777
static void test_effect_parameter_value(IDirect3DDevice9 *device)
Definition: effect.c:1765
static void test_cross_effect_handle(IDirect3DDevice9 *device)
Definition: effect.c:6423
static void test_effect_out_of_bounds_selector(IDirect3DDevice9 *device)
Definition: effect.c:5217
static void test_effect_clone(void)
Definition: effect.c:7387
static void test_refcount(void)
Definition: effect.c:7468
#define ok(value,...)
Definition: atltest.h:57
static void test_effect_variable_names(IDirect3DDevice9 *device)
Definition: effect.c:2624
static void test_create_effect_compiler(void)
Definition: effect.c:355
unsigned int ULONG
Definition: retypes.h:1
static void test_effect_skip_constants(IDirect3DDevice9 *device)
Definition: effect.c:7062
static void test_effect_state_manager(IDirect3DDevice9 *device)
Definition: effect.c:6310
static void test_effect_shared_parameters(IDirect3DDevice9 *device)
Definition: effect.c:6603
static void test_effect_states(IDirect3DDevice9 *device)
Definition: effect.c:3008

◆ test_create_effect_and_pool()

static void test_create_effect_and_pool ( IDirect3DDevice9 *  device)
static

Definition at line 233 of file effect.c.

234 {
235  HRESULT hr;
236  ID3DXEffect *effect;
237  ID3DXBaseEffect *base;
238  ULONG count;
239  IDirect3DDevice9 *device2;
240  ID3DXEffectStateManager *manager = (ID3DXEffectStateManager *)0xdeadbeef;
241  ID3DXEffectPool *pool = (ID3DXEffectPool *)0xdeadbeef, *pool2;
242 
244  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
245 
247  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
248 
250  ok(hr == E_FAIL, "Got result %x, expected %x (D3DXERR_INVALIDDATA)\n", hr, E_FAIL);
251 
253  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
254 
255  hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, &effect, NULL);
256  todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
257  if (FAILED(hr))
258  {
259  skip("Failed to compile effect, skipping test.\n");
260  return;
261  }
262 
263  hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3DXBaseEffect, (void **)&base);
264  ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
265 
266  hr = effect->lpVtbl->GetStateManager(effect, NULL);
267  ok(hr == D3DERR_INVALIDCALL, "GetStateManager failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
268 
269  hr = effect->lpVtbl->GetStateManager(effect, &manager);
270  ok(hr == D3D_OK, "GetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
271  ok(!manager, "GetStateManager failed, got %p\n", manager);
272 
273  /* this works, but it is not recommended! */
274  hr = effect->lpVtbl->SetStateManager(effect, (ID3DXEffectStateManager *)device);
275  ok(hr == D3D_OK, "SetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
276 
277  hr = effect->lpVtbl->GetStateManager(effect, &manager);
278  ok(hr == D3D_OK, "GetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
279  ok(manager != NULL, "GetStateManager failed\n");
280 
283  ok(count == 4, "Release failed, got %u, expected 4\n", count);
284 
285  count = IUnknown_Release(manager);
286  ok(count == 3, "Release failed, got %u, expected 3\n", count);
287 
288  hr = effect->lpVtbl->SetStateManager(effect, NULL);
289  ok(hr == D3D_OK, "SetStateManager failed, got %x, expected 0 (D3D_OK)\n", hr);
290 
291  hr = effect->lpVtbl->GetPool(effect, &pool);
292  ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr);
293  ok(!pool, "GetPool failed, got %p\n", pool);
294 
295  hr = effect->lpVtbl->GetPool(effect, NULL);
296  ok(hr == D3DERR_INVALIDCALL, "GetPool failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
297 
298  hr = effect->lpVtbl->GetDevice(effect, &device2);
299  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
300 
301  hr = effect->lpVtbl->GetDevice(effect, NULL);
302  ok(hr == D3DERR_INVALIDCALL, "GetDevice failed, got %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
303 
304  count = IDirect3DDevice9_Release(device2);
305  ok(count == 2, "Release failed, got %u, expected 2\n", count);
306 
307  count = effect->lpVtbl->Release(effect);
308  ok(count == 0, "Release failed %u\n", count);
309 
311  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
312 
314  ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr);
315 
316  count = pool->lpVtbl->Release(pool);
317  ok(count == 0, "Release failed %u\n", count);
318 
320  ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr);
321 
323  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
324 
325  hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3DXEffectPool, (void **)&pool2);
326  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
327  ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool);
328 
329  count = pool2->lpVtbl->Release(pool2);
330  ok(count == 1, "Release failed, got %u, expected 1\n", count);
331 
332  hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9, (void **)&device2);
333  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
334 
335  count = IDirect3DDevice9_Release(device2);
336  ok(count == 1, "Release failed, got %u, expected 1\n", count);
337 
338  hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, pool, &effect, NULL);
339  ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
340 
341  hr = effect->lpVtbl->GetPool(effect, &pool);
342  ok(hr == D3D_OK, "GetPool failed, got %x, expected 0 (D3D_OK)\n", hr);
343  ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool);
344 
345  count = pool2->lpVtbl->Release(pool2);
346  ok(count == 2, "Release failed, got %u, expected 2\n", count);
347 
348  count = effect->lpVtbl->Release(effect);
349  ok(count == 0, "Release failed %u\n", count);
350 
351  count = pool->lpVtbl->Release(pool);
352  ok(count == 0, "Release failed %u\n", count);
353 }
#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:6601
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
LONG HRESULT
Definition: typedefs.h:79
static const char effect_desc[]
Definition: effect.c:228
nsrefcnt Release()
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
#define todo_wine
Definition: test.h:164
#define S_OK
Definition: intsafe.h:51
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
HRESULT WINAPI D3DXCreateEffectPool(ID3DXEffectPool **pool)
Definition: effect.c:6746

Referenced by START_TEST().

◆ test_create_effect_compiler()

static void test_create_effect_compiler ( void  )
static

Definition at line 355 of file effect.c.

356 {
357  HRESULT hr;
358  ID3DXEffectCompiler *compiler, *compiler2;
359  ID3DXBaseEffect *base;
360  IUnknown *unknown;
361  ULONG count;
362 
363  hr = D3DXCreateEffectCompiler(NULL, 0, NULL, NULL, 0, &compiler, NULL);
364  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
365 
367  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
368 
369  hr = D3DXCreateEffectCompiler(effect_desc, 0, NULL, NULL, 0, &compiler, NULL);
370  ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
371  if (FAILED(hr))
372  {
373  skip("D3DXCreateEffectCompiler failed, skipping test.\n");
374  return;
375  }
376 
377  count = compiler->lpVtbl->Release(compiler);
378  ok(count == 0, "Release failed %u\n", count);
379 
381  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
382 
383  hr = D3DXCreateEffectCompiler(NULL, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL);
384  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
385 
387  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
388 
390  ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
391 
392  hr = D3DXCreateEffectCompiler(effect_desc, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL);
393  ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
394 
395  hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXBaseEffect, (void **)&base);
396  ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
397 
398  hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXEffectCompiler, (void **)&compiler2);
399  ok(hr == D3D_OK, "QueryInterface failed, got %x, expected %x (D3D_OK)\n", hr, D3D_OK);
400 
401  hr = compiler->lpVtbl->QueryInterface(compiler, &IID_IUnknown, (void **)&unknown);
402  ok(hr == D3D_OK, "QueryInterface failed, got %x, expected %x (D3D_OK)\n", hr, D3D_OK);
403 
404  count = unknown->lpVtbl->Release(unknown);
405  ok(count == 2, "Release failed, got %u, expected %u\n", count, 2);
406 
407  count = compiler2->lpVtbl->Release(compiler2);
408  ok(count == 1, "Release failed, got %u, expected %u\n", count, 1);
409 
410  count = compiler->lpVtbl->Release(compiler);
411  ok(count == 0, "Release failed %u\n", count);
412 }
#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:6626
GLuint base
Definition: 3dtext.c:35
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
static const char effect_desc[]
Definition: effect.c:228
nsrefcnt Release()
Definition: id3.c:95
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#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 7674 of file effect.c.

7675 {
7676  static const char effect1[] =
7677  "float4 light;\n"
7678  "float4x4 mat;\n"
7679  "float4 color;\n"
7680  "\n"
7681  "struct vs_input\n"
7682  "{\n"
7683  " float4 position : POSITION;\n"
7684  " float3 normal : NORMAL;\n"
7685  "};\n"
7686  "\n"
7687  "struct vs_output\n"
7688  "{\n"
7689  " float4 position : POSITION;\n"
7690  " float4 diffuse : COLOR;\n"
7691  "};\n"
7692  "\n"
7693  "vs_output vs_main(const vs_input v)\n"
7694  "{\n"
7695  " vs_output o;\n"
7696  " const float4 scaled_color = 0.5 * color;\n"
7697  "\n"
7698  " o.position = mul(v.position, mat);\n"
7699  " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
7700  "\n"
7701  " return o;\n"
7702  "}\n"
7703  "\n"
7704  "technique t\n"
7705  "{\n"
7706  " pass p\n"
7707  " {\n"
7708  " VertexShader = compile vs_2_0 vs_main();\n"
7709  " }\n"
7710  "}\n";
7711  static const char include1[] =
7712  "float4 light;\n"
7713  "float4x4 mat;\n"
7714  "float4 color;\n"
7715  "\n"
7716  "struct vs_input\n"
7717  "{\n"
7718  " float4 position : POSITION;\n"
7719  " float3 normal : NORMAL;\n"
7720  "};\n"
7721  "\n"
7722  "struct vs_output\n"
7723  "{\n"
7724  " float4 position : POSITION;\n"
7725  " float4 diffuse : COLOR;\n"
7726  "};\n";
7727  static const char include1_wrong[] =
7728  "#error \"wrong include\"\n";
7729  static const char include2[] =
7730  "#include \"include1.h\"\n"
7731  "\n"
7732  "vs_output vs_main(const vs_input v)\n"
7733  "{\n"
7734  " vs_output o;\n"
7735  " const float4 scaled_color = 0.5 * color;\n"
7736  "\n"
7737  " o.position = mul(v.position, mat);\n"
7738  " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
7739  "\n"
7740  " return o;\n"
7741  "}\n";
7742  static const char effect2[] =
7743  "#include \"include\\include2.h\"\n"
7744  "\n"
7745  "technique t\n"
7746  "{\n"
7747  " pass p\n"
7748  " {\n"
7749  " VertexShader = compile vs_2_0 vs_main();\n"
7750  " }\n"
7751  "}\n";
7752  WCHAR effect_path_w[MAX_PATH], filename_w[MAX_PATH];
7753  char effect_path[MAX_PATH], filename[MAX_PATH];
7754  D3DPRESENT_PARAMETERS present_parameters = {0};
7755  unsigned int filename_size;
7756  struct d3dxinclude include;
7757  IDirect3DDevice9 *device;
7759  ID3DXEffect *effect;
7760  IDirect3D9 *d3d;
7761  ULONG refcount;
7762  HWND window;
7763  HRESULT hr;
7764 
7765  if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
7766  640, 480, NULL, NULL, NULL, NULL)))
7767  {
7768  skip("Failed to create window.\n");
7769  return;
7770  }
7771  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
7772  {
7773  skip("Failed to create IDirect3D9 object.\n");
7775  return;
7776  }
7777  present_parameters.Windowed = TRUE;
7778  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
7780  D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
7781  if (FAILED(hr))
7782  {
7783  skip("Failed to create IDirect3DDevice9 object, hr %#x.\n", hr);
7784  IDirect3D9_Release(d3d);
7786  return;
7787  }
7788 
7789  if (!create_file("effect1.fx", effect1, sizeof(effect1) - 1, filename))
7790  {
7791  skip("Couldn't create temporary file, skipping test.\n");
7792  return;
7793  }
7794 
7795  filename_size = strlen(filename);
7796  filename_size -= sizeof("effect1.fx") - 1;
7797  memcpy(effect_path, filename, filename_size);
7798  effect_path[filename_size] = 0;
7799  MultiByteToWideChar(CP_ACP, 0, effect_path, -1, effect_path_w, ARRAY_SIZE(effect_path_w));
7800 
7801  create_directory("include");
7802  create_file("effect2.fx", effect2, sizeof(effect2) - 1, NULL);
7803  create_file("include\\include1.h", include1, sizeof(include1) - 1, NULL);
7804  create_file("include\\include2.h", include2, sizeof(include2) - 1, NULL);
7805  create_file("include1.h", include1_wrong, sizeof(include1_wrong) - 1, NULL);
7806 
7807  lstrcpyW(filename_w, effect_path_w);
7808  lstrcatW(filename_w, L"effect1.fx");
7809  effect = NULL;
7810  messages = NULL;
7812  0, NULL, &effect, &messages);
7813  todo_wine ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
7814  if (messages)
7815  {
7816  trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
7818  }
7819  if (effect)
7820  effect->lpVtbl->Release(effect);
7821 
7822  lstrcpyW(filename_w, effect_path_w);
7823  lstrcatW(filename_w, L"effect2.fx");
7824  effect = NULL;
7825  messages = NULL;
7826  /* This is apparently broken on native, it ends up using the wrong include. */
7828  0, NULL, &effect, &messages);
7829  todo_wine ok(hr == E_FAIL, "Unexpected error, hr %#x.\n", hr);
7830  if (messages)
7831  {
7832  trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
7834  }
7835  if (effect)
7836  effect->lpVtbl->Release(effect);
7837 
7838  delete_file("effect1.fx");
7839  delete_file("effect2.fx");
7840  delete_file("include\\include1.h");
7841  delete_file("include\\include2.h");
7842  delete_file("include2.h");
7843  delete_directory("include");
7844 
7845  lstrcpyW(filename_w, L"effect2.fx");
7846  effect = NULL;
7847  messages = NULL;
7848  include.ID3DXInclude_iface.lpVtbl = &d3dxinclude_vtbl;
7849  /* This is actually broken in native d3dx9 (manually tried multiple
7850  * versions, all are affected). For reference, the message printed below
7851  * is "ID3DXEffectCompiler: There were no techniques" */
7852  hr = D3DXCreateEffectFromFileExW(device, filename_w, NULL, &include.ID3DXInclude_iface, NULL,
7853  0, NULL, &effect, &messages);
7854  todo_wine ok(hr == E_FAIL, "D3DXInclude test failed with error %#x.\n", hr);
7855  if (messages)
7856  {
7857  trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
7859  }
7860 
7861  refcount = IDirect3DDevice9_Release(device);
7862  ok(!refcount, "Device has %u references left.\n", refcount);
7863  IDirect3D9_Release(d3d);
7865 }
#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:7663
static BOOL create_directory(const char *name)
Definition: effect.c:210
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
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
FxDevice * device
#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
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:79
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:6767
#define MAX_PATH
Definition: compat.h:34
static void delete_file(const char *filename)
Definition: effect.c:201
static const WCHAR L[]
Definition: oid.c:1250
#define todo_wine
Definition: test.h:164
#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:608
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#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:173
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
static void delete_directory(const char *name)
Definition: effect.c:219
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 6423 of file effect.c.

6424 {
6425  ID3DXEffect *effect1, *effect2;
6426  D3DXHANDLE param1, param2;
6427  static int expected_ivect[4] = {28, 29, 30, 31};
6428  int ivect[4];
6429  HRESULT hr;
6430 
6432  NULL, NULL, 0, NULL, &effect1, NULL);
6433  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6435  NULL, NULL, 0, NULL, &effect2, NULL);
6436  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6437 
6438  ok(effect1 != effect2, "Got same effect unexpectedly.\n");
6439 
6440  param1 = effect1->lpVtbl->GetParameterByName(effect1, NULL, "g_iVect");
6441  ok(!!param1, "GetParameterByName failed.\n");
6442 
6443  param2 = effect2->lpVtbl->GetParameterByName(effect2, NULL, "g_iVect");
6444  ok(!!param2, "GetParameterByName failed.\n");
6445 
6446  ok(param1 != param2, "Got same parameter handle unexpectedly.\n");
6447 
6448  hr = effect2->lpVtbl->SetValue(effect2, param1, expected_ivect, sizeof(expected_ivect));
6449  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6450 
6451  hr = effect1->lpVtbl->GetValue(effect1, param1, ivect, sizeof(ivect));
6452  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6453 
6454  ok(!memcmp(ivect, expected_ivect, sizeof(expected_ivect)), "Vector value mismatch.\n");
6455 
6456  effect2->lpVtbl->Release(effect2);
6457  effect1->lpVtbl->Release(effect1);
6458 }
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:3474
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:6601
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_effect_clear_vconsts()

static void test_effect_clear_vconsts ( IDirect3DDevice9 *  device)
static

Definition at line 2996 of file effect.c.

2997 {
2998  unsigned int i;
2999  HRESULT hr;
3000 
3001  for (i = 0; i < 256; ++i)
3002  {
3004  ok(hr == D3D_OK, "Got result %#x.\n", hr);
3005  }
3006 }
HRESULT hr
Definition: shlfolder.c:183
Definition: devices.h:37
#define IDirect3DDevice9_SetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1601
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
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
#define ok(value,...)
Definition: atltest.h:57
static const D3DXVECTOR4 fvect_filler
Definition: effect.c:2994

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 7387 of file effect.c.

7388 {
7389  IDirect3DDevice9 *device, *device2, *device3;
7390  ID3DXEffect *effect, *cloned;
7391  HWND window, window2;
7392  ULONG refcount;
7393  HRESULT hr;
7394 
7395  if (!(device = create_device(&window)))
7396  return;
7397 
7398  /* D3DXFX_NOT_CLONEABLE */
7400  NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
7401  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7402 
7403  hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
7404  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7405 
7406  cloned = (void *)0xdeadbeef;
7407  hr = effect->lpVtbl->CloneEffect(effect, NULL, &cloned);
7408  ok(hr == E_FAIL, "Got result %#x.\n", hr);
7409  ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7410 
7411  hr = effect->lpVtbl->CloneEffect(effect, device, NULL);
7412  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7413 
7414  cloned = (void *)0xdeadbeef;
7415  hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7416  ok(hr == E_FAIL, "Got result %#x.\n", hr);
7417  ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7418 
7419  effect->lpVtbl->Release(effect);
7420 
7422  NULL, NULL, 0, NULL, &effect, NULL);
7423  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7424 
7425  hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
7426  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7427 
7428  cloned = (void *)0xdeadbeef;
7429  hr = effect->lpVtbl->CloneEffect(effect, NULL, &cloned);
7430  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7431  ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7432 
7433  hr = effect->lpVtbl->CloneEffect(effect, device, NULL);
7434  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
7435 
7436  hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7437  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7438 
7439  todo_wine ok(cloned != effect, "Expected new effect instance.\n");
7440  cloned->lpVtbl->Release(cloned);
7441  /* Try with different device. */
7442  device2 = create_device(&window2);
7443  hr = effect->lpVtbl->CloneEffect(effect, device2, &cloned);
7444  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7445  todo_wine ok(cloned != effect, "Expected new effect instance.\n");
7446 
7447  hr = cloned->lpVtbl->GetDevice(cloned, &device3);
7448  ok(hr == S_OK, "Failed to get effect device.\n");
7449  todo_wine ok(device3 == device2, "Unexpected device instance, device3 %p, device2 %p.\n", device3, device2);
7450  IDirect3DDevice9_Release(device3);
7451 
7452  cloned->lpVtbl->Release(cloned);
7453 
7454  IDirect3DDevice9_Release(device2);
7455  DestroyWindow(window2);
7456  effect->lpVtbl->Release(effect);
7457  refcount = IDirect3DDevice9_Release(device);
7458  ok(!refcount, "Device has %u references left.\n", refcount);
7460 }
static IDirect3DDevice9 * create_device(HWND *window)
Definition: effect.c:131
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:3474
FxDevice * device
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:6601
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
LONG HRESULT
Definition: typedefs.h:79
#define todo_wine
Definition: test.h:164
static IHTMLWindow2 * window
Definition: events.c:77
#define S_OK
Definition: intsafe.h:51
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
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 5366 of file effect.c.

5367 {
5368  static const struct
5369  {
5370  const char *param_name;
5372  }
5373  check_op_parameters[] =
5374  {
5390  };
5391  static const struct
5392  {
5393  const char *param_name;
5394  const unsigned int const_updated_mask[(ARRAY_SIZE(test_effect_preshader_fvect_v)
5396  }
5397  check_vconsts_parameters[] =
5398  {
5399  {"g_Selector", {0x00000000, 0x00000002}},
5400  {"g_Pos1", {0x80000000, 0x00000002}},
5401  {"g_Pos2", {0x00000000, 0x00000002}},
5402  {"m4x3column", {0x03800000, 0x00000000}},
5403  {"m3x4column", {0x000f0000, 0x00000000}},
5404  {"m4x3row", {0x0000f000, 0x00000000}},
5405  {"m3x4row", {0x00700000, 0x00000000}},
5406  {"ts1", {0x1c000000, 0x00000000}},
5407  {"ts2", {0x0000003f, 0x00000000}},
5408  {"arr1", {0x00000000, 0x00000001}},
5409  {"arr2", {0x60000000, 0x00000000}},
5410  {"ts3", {0x00000fc0, 0x00000000}},
5411  };
5412  static const struct
5413  {
5414  const char *param_name;
5415  const unsigned int const_updated_mask[(ARRAY_SIZE(test_effect_preshader_bconsts)
5417  }
5418  check_bconsts_parameters[] =
5419  {
5420  {"mb2x3row", {0x0000001f}},
5421  {"mb2x3column", {0x00000060}},
5422  };
5423  static const unsigned int const_no_update_mask[(ARRAY_SIZE(test_effect_preshader_fvect_v)
5425  static const D3DLIGHT9 light_filler = {D3DLIGHT_POINT};
5426 
5427  ID3DXEffect *effect;
5428  HRESULT hr;
5429  D3DXHANDLE param;
5430  unsigned int i, passes_count, value;
5431  int ivect[4];
5432  D3DXVECTOR4 fvect;
5433  IDirect3DVertexShader9 *vshader;
5434  unsigned char buffer[256];
5435 
5436 
5438  NULL, NULL, 0, NULL, &effect, NULL);
5439  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5440 
5441  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5442  ok(!!param, "GetParameterByName failed.\n");
5443 
5444  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5445  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5446 
5448  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5449 
5450  hr = effect->lpVtbl->BeginPass(effect, 0);
5451  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5452 
5453  for (i = 0; i < ARRAY_SIZE(check_op_parameters); ++i)
5454  {
5455  unsigned int j;
5456 
5457  for (j = 0; j < 8; ++j)
5458  {
5459  hr = IDirect3DDevice9_SetLight(device, j, &light_filler);
5460  ok(hr == D3D_OK, "Got result %#x, i %u, j %u.\n", hr, i, j);
5461  }
5462  param = effect->lpVtbl->GetParameterByName(effect, NULL, check_op_parameters[i].param_name);
5463  ok(!!param, "Failed to get parameter (test %u).\n", i);
5464  hr = effect->lpVtbl->GetValue(effect, param, &fvect, sizeof(fvect));
5465  ok(hr == D3D_OK, "Failed to get parameter value, hr %#x (test %u).\n", hr, i);
5466  hr = effect->lpVtbl->SetValue(effect, param, &fvect, sizeof(fvect));
5467  ok(hr == D3D_OK, "Failed to set parameter value, hr %#x (test %u).\n", hr, i);
5468  hr = effect->lpVtbl->CommitChanges(effect);
5469  ok(hr == D3D_OK, "Failed to commit changes, hr %#x (test %u).\n", hr, i);
5470 
5471  test_effect_preshader_op_results(device, check_op_parameters[i].state_updated,
5472  check_op_parameters[i].param_name);
5473  }
5474 
5475  for (i = 0; i < ARRAY_SIZE(check_vconsts_parameters); ++i)
5476  {
5478  param = effect->lpVtbl->GetParameterByName(effect, NULL, check_vconsts_parameters[i].param_name);
5479  ok(!!param, "GetParameterByName failed.\n");
5480  hr = effect->lpVtbl->GetValue(effect, param, buffer, sizeof(buffer));
5481  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5482  hr = effect->lpVtbl->SetValue(effect, param, buffer, sizeof(buffer));
5483  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5484  hr = effect->lpVtbl->CommitChanges(effect);
5485  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5486 
5487  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[i].const_updated_mask,
5488  check_vconsts_parameters[i].param_name);
5489  }
5490 
5491  for (i = 0; i < ARRAY_SIZE(check_bconsts_parameters); ++i)
5492  {
5494  param = effect->lpVtbl->GetParameterByName(effect, NULL, check_bconsts_parameters[i].param_name);
5495  ok(!!param, "GetParameterByName failed.\n");
5496  hr = effect->lpVtbl->GetValue(effect, param, buffer, sizeof(buffer));
5497  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5498  hr = effect->lpVtbl->SetValue(effect, param, buffer, sizeof(buffer));
5499  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5500  hr = effect->lpVtbl->CommitChanges(effect);
5501  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5502 
5503  test_effect_preshader_compare_pbool_consts(device, check_bconsts_parameters[i].const_updated_mask,
5504  check_bconsts_parameters[i].param_name);
5505  }
5506 
5508  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Selector");
5509  ok(!!param, "GetParameterByName failed.\n");
5510  fvect.x = fvect.y = fvect.z = fvect.w = 0.0f;
5511  hr = effect->lpVtbl->SetVectorArray(effect, param, &fvect, 1);
5512  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5513  hr = effect->lpVtbl->CommitChanges(effect);
5514  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5515  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[0].const_updated_mask,
5516  check_vconsts_parameters[0].param_name);
5517 
5519  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5520  ok(!!param, "GetParameterByName failed.\n");
5521  param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5522  ok(!!param, "GetParameterElement failed.\n");
5523  hr = effect->lpVtbl->SetFloat(effect, param, 92.0f);
5524  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5525  hr = effect->lpVtbl->CommitChanges(effect);
5526  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5527  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5528  check_vconsts_parameters[10].param_name);
5529 
5531  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5532  ok(!!param, "GetParameterByName failed.\n");
5533  param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5534  ok(!!param, "GetParameterElement failed.\n");
5535  fvect.x = 93.0f;
5536  hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(fvect.x));
5537  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5538  hr = effect->lpVtbl->CommitChanges(effect);
5539  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5540  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[10].const_updated_mask,
5541  check_vconsts_parameters[10].param_name);
5542 
5544  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5545  ok(!!param, "GetParameterByName failed.\n");
5546  fvect.x = 92.0f;
5547  hr = effect->lpVtbl->SetFloatArray(effect, param, &fvect.x, 1);
5548  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5549  hr = effect->lpVtbl->CommitChanges(effect);
5550  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5551  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[10].const_updated_mask,
5552  check_vconsts_parameters[10].param_name);
5553 
5555  param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5556  ok(!!param, "GetParameterByName failed.\n");
5557  param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5558  ok(!!param, "GetParameterElement failed.\n");
5559  hr = effect->lpVtbl->SetInt(effect, param, 93);
5560  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5561  hr = effect->lpVtbl->CommitChanges(effect);
5562  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5563  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5564  check_vconsts_parameters[10].param_name);
5565 
5567  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Pos1");
5568  ok(!!param, "GetParameterByName failed.\n");
5569  fvect.x = fvect.y = fvect.z = fvect.w = 0.0f;
5570  hr = effect->lpVtbl->SetVector(effect, param, &fvect);
5571  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5572  hr = effect->lpVtbl->CommitChanges(effect);
5573  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5574  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[1].const_updated_mask,
5575  check_vconsts_parameters[1].param_name);
5576 
5578  param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts1");
5579  ok(!!param, "GetParameterByName failed.\n");
5580  param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5581  ok(!!param, "GetParameterByName failed.\n");
5582  param = effect->lpVtbl->GetParameterByName(effect, param, "fv");
5583  ok(!!param, "GetParameterByName failed.\n");
5584  fvect.x = 12;
5585  hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(float));
5586  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5587  hr = effect->lpVtbl->CommitChanges(effect);
5588  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5589  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[7].const_updated_mask,
5590  check_vconsts_parameters[7].param_name);
5591 
5592  *(float *)&value = 9999.0f;
5594  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5596  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5598  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5600  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5602  param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts2");
5603  ok(!!param, "GetParameterByName failed.\n");
5604  param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5605  ok(!!param, "GetParameterByName failed.\n");
5606  param = effect->lpVtbl->GetParameterByName(effect, param, "v1");
5607  ok(!!param, "GetParameterByName failed.\n");
5608  hr = effect->lpVtbl->GetValue(effect, param, &fvect, sizeof(float) * 3);
5609  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5610  hr = effect->lpVtbl->SetValue(effect, param, &fvect, sizeof(float) * 3);
5611  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5612  hr = effect->lpVtbl->CommitChanges(effect);
5613  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5615  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5616  ok(value == 0, "Unexpected fog density %g.\n", *(float *)&value);
5618  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5619  ok(*(float *)&value == 4.0f, "Unexpected fog start %g.\n", *(float *)&value);
5621  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5622  ok(*(float *)&value == 9999.0f, "Unexpected point scale A %g.\n", *(float *)&value);
5624  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5625  ok(*(float *)&value == 9999.0f, "Unexpected point scale B %g.\n", *(float *)&value);
5626  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[8].const_updated_mask,
5627  check_vconsts_parameters[8].param_name);
5628 
5629  *(float *)&value = 9999.0f;
5631  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5633  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5635  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5637  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5639  param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts3");
5640  ok(!!param, "GetParameterByName failed.\n");
5641  param = effect->lpVtbl->GetParameterByName(effect, param, "ts");
5642  ok(!!param, "GetParameterByName failed.\n");
5643  param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5644  ok(!!param, "GetParameterByName failed.\n");
5645  param = effect->lpVtbl->GetParameterByName(effect, param, "fv");
5646  ok(!!param, "GetParameterByName failed.\n");
5647  hr = effect->lpVtbl->GetValue(effect, param, &fvect.x, sizeof(float));
5648  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5649  hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(float));
5650  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5651  hr = effect->lpVtbl->CommitChanges(effect);
5652  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5654  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5655  ok(*(float *)&value == 9999.0f, "Unexpected fog density %g.\n", *(float *)&value);
5657  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5658  ok(*(float *)&value == 9999.0f, "Unexpected fog start %g.\n", *(float *)&value);
5660  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5661  ok(*(float *)&value == 4.0f, "Unexpected point scale A %g.\n", *(float *)&value);
5663  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5664  ok(*(float *)&value == 12.0f, "Unexpected point scale B %g.\n", *(float *)&value);
5665  test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[11].const_updated_mask,
5666  check_vconsts_parameters[11].param_name);
5667 
5669  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5670  ok(value == 1, "Unexpected sampler 0 minfilter %u.\n", value);
5672  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5673  todo_wine
5674  ok(value == 0, "Unexpected sampler 1 minfilter %u.\n", value);
5676  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5677  ok(value == 3, "Unexpected sampler 2 minfilter %u.\n", value);
5678 
5679  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5680  ok(!!param, "GetParameterByName failed.\n");
5681  ivect[0] = ivect[1] = ivect[2] = ivect[3] = 1;
5682  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5683  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5684 
5685  for (i = 0; i < 3; ++i)
5686  {
5688  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5690  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5691  }
5692 
5694  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5696  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5697 
5699  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5701 
5702  hr = effect->lpVtbl->CommitChanges(effect);
5703  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5704 
5706  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5707  ok(!vshader, "Got non NULL vshader.\n");
5708  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5709  "selector g_iVect");
5710 
5712  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5713  ok(value == 0, "Unexpected sampler 0 minfilter %u.\n", value);
5715  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5716  ok(value == 0, "Unexpected sampler 1 minfilter %u.\n", value);
5717 
5719  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5720  ok(value == 1, "Unexpected sampler 2 minfilter %u.\n", value);
5722  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5723  ok(value == 0, "Unexpected sampler 2 minfilter %u.\n", value);
5725  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5726  ok(value == 1, "Unexpected sampler 0 minfilter %u.\n", value);
5728  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5729  ok(value == 0, "Unexpected sampler 0 minfilter %u.\n", value);
5730 
5731  ivect[3] = 2;
5732  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5733  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5734  ivect[3] = 1;
5735  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5736  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5737  hr = effect->lpVtbl->CommitChanges(effect);
5738  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5740  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5741  ok(!vshader, "Got non NULL vshader.\n");
5742  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5743  "selector g_iVect");
5744  ivect[3] = 2;
5745  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5746  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5747  hr = effect->lpVtbl->CommitChanges(effect);
5748  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5750  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5751  ok(!!vshader, "Got NULL vshader.\n");
5754  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5755  ok(fvect.x == 0.0f && fvect.y == 0.0f && fvect.z == 0.0f && fvect.w == 0.0f,
5756  "Vertex shader float constants do not match.\n");
5758  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5759  test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5760  "selector g_iVect");
5761  ivect[3] = 1;
5762  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5763  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5764  hr = effect->lpVtbl->CommitChanges(effect);
5765  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5767 
5768  hr = effect->lpVtbl->EndPass(effect);
5769  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5770 
5771  hr = effect->lpVtbl->End(effect);
5772  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5773 
5774  effect->lpVtbl->Release(effect);
5775 }
Definition: pdh_main.c:93
#define IDirect3DDevice9_GetRenderState(p, a, b)
Definition: d3d9.h:1565
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
static void test_effect_clear_vconsts(IDirect3DDevice9 *device)
Definition: effect.c:2996
static void test_effect_preshader_clear_pbool_consts(IDirect3DDevice9 *device)
Definition: effect.c:4503
GLuint buffer
Definition: glext.h:5915
#define test_effect_preshader_compare_vconsts(a, b, c)
Definition: effect.c:4449
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3474
expected_state_update
Definition: effect.c:4364
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:6601
#define IDirect3DDevice9_SetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1601
#define test_effect_preshader_compare_pbool_consts(a, b, c)
Definition: effect.c:4517
static const D3DXVECTOR4 test_effect_preshader_fvect_v[]
Definition: effect.c:4410
#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:79
#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:164
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:4371
#define D3D_OK
Definition: d3d.h:106
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
static const BOOL test_effect_preshader_bconsts[]
Definition: effect.c:4498
#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 NULL
Definition: types.h:112
#define IDirect3DDevice9_GetSamplerState(p, a, b, c)
Definition: d3d9.h:1575
static const struct @1638 test_effect_preshader_op_expected[]
#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:4447
static const D3DXVECTOR4 fvect_filler
Definition: effect.c:2994

Referenced by START_TEST().

◆ test_effect_compilation_errors()

static void test_effect_compilation_errors ( IDirect3DDevice9 *  device)
static

Definition at line 2865 of file effect.c.

2866 {
2867  ID3DXEffect *effect;
2868  ID3DXBuffer *compilation_errors;
2869  HRESULT hr;
2870 
2871  /* Test binary effect */
2872  compilation_errors = (ID3DXBuffer*)0xdeadbeef;
2873  hr = D3DXCreateEffect(NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, &compilation_errors);
2874  ok(hr == D3DERR_INVALIDCALL, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
2875  ok(!compilation_errors, "Returned %p\n", compilation_errors);
2876 
2877  compilation_errors = (ID3DXBuffer*)0xdeadbeef;
2879  sizeof(test_effect_variable_names_blob), NULL, NULL, 0, NULL, &effect, &compilation_errors);
2880  ok(hr == D3D_OK, "D3DXCreateEffect failed, got %#x, expected %#x\n", hr, D3D_OK);
2881  ok(!compilation_errors, "Returned %p\n", compilation_errors);
2882  effect->lpVtbl->Release(effect);
2883 }
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:6601
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
static const DWORD test_effect_variable_names_blob[]
Definition: effect.c:2595
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_effect_find_next_valid_technique()

static void test_effect_find_next_valid_technique ( void  )
static

Definition at line 7899 of file effect.c.

7900 {
7901  D3DPRESENT_PARAMETERS present_parameters = {0};
7902  IDirect3DDevice9 *device;
7904  ID3DXEffect *effect;
7905  IDirect3D9 *d3d;
7906  D3DXHANDLE tech;
7907  ULONG refcount;
7908  HWND window;
7909  HRESULT hr;
7910 
7911  if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
7912  640, 480, NULL, NULL, NULL, NULL)))
7913  {
7914  skip("Failed to create window.\n");
7915  return;
7916  }
7917  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
7918  {
7919  skip("Failed to create IDirect3D9 object.\n");
7921  return;
7922  }
7923  present_parameters.Windowed = TRUE;
7924  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
7926  D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
7927  if (FAILED(hr))
7928  {
7929  skip("Failed to create IDirect3DDevice9 object, hr %#x.\n", hr);
7930  IDirect3D9_Release(d3d);
7932  return;
7933  }
7934 
7936  NULL, NULL, NULL, 0, NULL, &effect, NULL);
7937  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7938 
7939  hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
7940  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7941  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7942  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7943  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
7944 
7945  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7946  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7947  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7948  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7949  ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
7950 
7951  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7952  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7953  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7954  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7955  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
7956 
7957  effect->lpVtbl->Release(effect);
7958 
7960  NULL, NULL, NULL, 0, NULL, &effect, NULL);
7961  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7962 
7963  hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
7964  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7965  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7966  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7967  ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
7968 
7969  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7970  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7971  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7972  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7973  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
7974 
7975  hr = effect->lpVtbl->SetInt(effect, "i", 1);
7976  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7977 
7978  tech = (D3DXHANDLE)0xdeadbeef;
7979  hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
7980  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7981  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7982  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7983  ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
7984 
7985  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7986  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7987 
7988  hr = effect->lpVtbl->SetInt(effect, "i", 0);
7989  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
7990 
7991  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7992  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7993  hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
7994  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7995  ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
7996 
7997  hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
7998  ok(hr == S_FALSE, "Got result %#x.\n", hr);
7999 
8000  hr = effect->lpVtbl->FindNextValidTechnique(effect, "nope", &tech);
8001  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
8002 
8003  effect->lpVtbl->Release(effect);
8004 
8005  refcount = IDirect3DDevice9_Release(device);
8006  ok(!refcount, "Device has %u references left.\n", refcount);
8007  IDirect3D9_Release(d3d);
8009 }
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define TRUE
Definition: types.h:120
#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:6556
BOOL WINAPI DestroyWindow(_In_ HWND)
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
FxDevice * device
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
static const DWORD test_two_techniques_blob[]
Definition: effect.c:7885
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
#define D3D_SDK_VERSION
Definition: d3d8.h:56
LONG HRESULT
Definition: typedefs.h:79
static const DWORD test_effect_unsupported_shader_blob[]
Definition: effect.c:7170
static IHTMLWindow2 * window
Definition: events.c:77
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#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 6909 of file effect.c.

6910 {
6911  unsigned int passes_count;
6912  ID3DXEffect *effect;
6914  D3DXVECTOR4 fvect;
6915  D3DXHANDLE pass;
6916  HRESULT hr;
6917 
6919  NULL, NULL, 0, NULL, &effect, NULL);
6920  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6921 
6922  pass = effect->lpVtbl->GetPass(effect, "tech0", 1);
6923  ok(!!pass, "GetPass() failed.\n");
6924 
6925  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6926  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6927  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 2, FALSE);
6928 
6929  fvect.x = fvect.y = fvect.w = 0.0f;
6930  fvect.z = 0.0f;
6931  hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6932  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6933 
6934  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6935  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6936  ok(!desc.pPixelShaderFunction, "Unexpected non null desc.pPixelShaderFunction.\n");
6937 
6938  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 0, FALSE);
6939 
6940  fvect.z = 3.0f;
6941  hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6942  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6943 
6944  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6945  ok(hr == E_FAIL, "Got result %#x.\n", hr);
6946  ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
6947 
6948  /* Repeating call to confirm GetPassDesc() returns same error on the second call,
6949  * as it is not the case sometimes for BeginPass() with out of bound access. */
6950  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6951  ok(hr == E_FAIL, "Got result %#x.\n", hr);
6952  ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
6953 
6954  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
6955  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6956 
6957  hr = effect->lpVtbl->BeginPass(effect, 1);
6958  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6959 
6960  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6961  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6962 
6963  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 0, FALSE);
6964 
6965  fvect.z = 2.0f;
6966  hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6967  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6968  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6969  test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 2, FALSE);
6970 
6971  effect->lpVtbl->Release(effect);
6972 
6974  NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
6975  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6976 
6977  pass = effect->lpVtbl->GetPass(effect, "tech0", 1);
6978  ok(!!pass, "GetPass() failed.\n");
6979 
6980  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
6981  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6982 
6983  ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
6984  ok(!desc.pPixelShaderFunction, "Unexpected non null desc.pPixelShaderFunction.\n");
6985 
6986  effect->lpVtbl->Release(effect);
6987 }
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:3474
pass
Definition: typegen.h:24
#define FALSE
Definition: types.h:117
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:6601
static const WCHAR desc[]
Definition: protectdata.c:36
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define test_effect_preshader_compare_shader_bytecode(a, b, c, d)
Definition: effect.c:4267
#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 5155 of file effect.c.

5156 {
5157  static const struct
5158  {
5159  const char *name;
5161  }
5162  check_parameters[] =
5163  {
5164  {"g_Pos1", TRUE},
5165  {"g_Pos2", TRUE},
5166  {"g_Selector", TRUE},
5167  {"opvect1", TRUE},
5168  {"opvect2", TRUE},
5169  {"opvect3", TRUE},
5170  {"arr2", TRUE},
5171  {"vs_arr", TRUE},
5172  {"g_iVect", TRUE},
5173  {"vect_sampler", TRUE},
5174  {"tex1", TRUE},
5175  {"tex2", FALSE},
5176  {"sampler1", TRUE},
5177  {"ts1", TRUE},
5178  {"ts2", TRUE},
5179  {"ts3", TRUE},
5180  };
5181  ID3DXEffect *effect, *effect2;
5182  HRESULT hr;
5183  D3DXHANDLE tech;
5184  unsigned int i;
5185 
5187  NULL, NULL, 0, NULL, &effect, NULL);
5188  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5189 
5190  tech = effect->lpVtbl->GetTechniqueByName(effect, "tech0");
5191  ok(!!tech, "GetTechniqueByName failed.\n");
5192 
5193  for (i = 0; i < ARRAY_SIZE(check_parameters); ++i)
5194  test_isparameterused_param_with_children(effect, NULL, tech, check_parameters[i].name,
5195  check_parameters[i].expected_result);
5196 
5198  NULL, NULL, 0, NULL, &effect2, NULL);
5199  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5200 
5201  for (i = 0; i < ARRAY_SIZE(check_parameters); ++i)
5202  test_isparameterused_param_with_children(effect, effect2, tech, check_parameters[i].name,
5203  check_parameters[i].expected_result);
5204 
5205  effect2->lpVtbl->Release(effect2);
5206 
5208  NULL, NULL, 0, NULL, &effect2, NULL);
5209  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5210 
5211  test_isparameterused_param_with_children(effect, effect2, tech, "sampler1", TRUE);
5212  effect2->lpVtbl->Release(effect2);
5213 
5214  effect->lpVtbl->Release(effect);
5215 }
HRESULT hr
Definition: shlfolder.c:183
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
#define TRUE
Definition: types.h:120
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3474
#define FALSE
Definition: types.h:117
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:6601
static const DWORD test_effect_states_effect_blob[]
Definition: effect.c:2933
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
#define test_isparameterused_param_with_children(args...)
Definition: effect.c:5132
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
const char * name
Definition: effect.c:237
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
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 6876 of file effect.c.

6877 {
6878  ID3DXEffect *effect;
6879  D3DXHANDLE param;
6880  static int expected_ivect[4] = {28, 29, 30, 31};
6881  int ivect[4];
6882  HRESULT hr;
6883 
6885  NULL, NULL, D3DXFX_LARGEADDRESSAWARE, NULL, &effect, NULL);
6886  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6887 
6888  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
6889  ok(!!param, "GetParameterByName failed.\n");
6890 
6891  hr = effect->lpVtbl->SetValue(effect, param, expected_ivect, sizeof(expected_ivect));
6892  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6893 
6894  hr = effect->lpVtbl->GetValue(effect, param, ivect, sizeof(ivect));
6895  ok(hr == D3D_OK, "Got result %#x.\n", hr);
6896 
6897  ok(!memcmp(ivect, expected_ivect, sizeof(expected_ivect)), "Vector value mismatch.\n");
6898 
6899  if (0)
6900  {
6901  /* Native d3dx crashes in GetValue(). */
6902  hr = effect->lpVtbl->GetValue(effect, "g_iVect", ivect, sizeof(ivect));
6903  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
6904  }
6905 
6906  effect->lpVtbl->Release(effect);
6907 }
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:3474
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:6601
LONG HRESULT
Definition: typedefs.h:79
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
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ test_effect_null_shader()

static void test_effect_null_shader ( void  )
static

Definition at line 7332 of file effect.c.

7333 {
7334  IDirect3DDevice9 *device;
7335  ID3DXEffect *effect;
7337  D3DXHANDLE pass;
7338  ULONG refcount;
7339  HWND window;
7340  HRESULT hr;
7341 
7342  /* Creating a fresh device because the existing device can have invalid
7343  * render states from previous tests. If IDirect3DDevice9_ValidateDevice()
7344  * returns certain error codes, native ValidateTechnique() fails. */
7345  if (!(device = create_device(&window)))
7346  return;
7347 
7349  sizeof(test_effect_null_shader_blob), NULL, NULL, NULL, 0, NULL, &effect, NULL);
7350  ok(hr == D3D_OK, "Failed to create effect, hr %#x.\n", hr);
7351 
7352  pass = effect->lpVtbl->GetPass(effect, "tech0", 0);
7353  ok(!!pass, "GetPass() failed.\n");
7354  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7355  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7356  ok(!desc.pVertexShaderFunction, "Got non NULL vertex function.\n");
7357 
7358  pass = effect->lpVtbl->GetPass(effect, "tech1", 0);
7359  ok(!!pass, "GetPass() failed.\n");
7360  hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7361  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7362  ok(!desc.pVertexShaderFunction, "Got non NULL vertex function.\n");
7363 
7364  hr = effect->lpVtbl->ValidateTechnique(effect, "tech0");
7365  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7366  hr = effect->lpVtbl->SetInt(effect, "i", 0);
7367  ok(hr == D3D_OK, "Failed to set parameter, hr %#x.\n", hr);
7368  hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7369  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7370  hr = effect->lpVtbl->SetInt(effect, "i", 1);
7371  ok(hr == D3D_OK, "Failed to set parameter, hr %#x.\n", hr);
7372  hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7373  ok(hr == D3D_OK, "Got result %#x.\n", hr);
7374 
7375  hr = effect->lpVtbl->SetInt(effect, "i", 2);
7376  ok(hr == D3D_OK, "Failed to set parameter, hr %#x.\n", hr);
7377  hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7378  ok(hr == E_FAIL, "Got result %#x.\n", hr);
7379 
7380  effect->lpVtbl->Release(effect);
7381 
7382  refcount = IDirect3DDevice9_Release(device);
7383  ok(!refcount, "Device has %u references left.\n", refcount);
7385 }
static IDirect3DDevice9 * create_device(HWND *window)
Definition: effect.c:131
HRESULT hr
Definition: shlfolder.c:183
static const DWORD test_effect_null_shader_blob[]
Definition: effect.c:7309
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:6556
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI DestroyWindow(_In_ HWND)
FxDevice * device
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
LONG HRESULT
Definition: typedefs.h:79
static IHTMLWindow2 * window
Definition: events.c:77
#define D3D_OK
Definition: d3d.h:106
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
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 5217 of file effect.c.

5218 {
5219  ID3DXEffect *effect;
5220  HRESULT hr;
5221  D3DXHANDLE param;
5222  int ivect[4];
5223  unsigned int passes_count;
5224  IDirect3DVertexShader9 *vshader;
5225 
5227  NULL, NULL, 0, NULL, &effect, NULL);
5228 
5229  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5230  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5231 
5232  ivect[0] = ivect[1] = ivect[3] = 1;
5233 
5234  param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5235  ok(!!param, "GetParameterByName failed.\n");
5236  ivect[2] = 3;
5237  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5238  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5239 
5240  hr = effect->lpVtbl->BeginPass(effect, 0);
5241  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5242  hr = effect->lpVtbl->EndPass(effect);
5243  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5244 
5246  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5247 
5248  hr = effect->lpVtbl->BeginPass(effect, 1);
5249  ok(hr == E_FAIL, "Got result %#x.\n", hr);
5250 
5251  /* Second try reports success and selects array element used previously.
5252  * Probably array index is not recomputed and previous index value is used. */
5253  hr = effect->lpVtbl->BeginPass(effect, 1);
5254  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5256 
5257  /* Confirm that array element selected is the previous good one and does not depend
5258  * on computed (out of bound) index value. */
5259  ivect[2] = 1;
5260  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5261  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5263  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5264  hr = effect->lpVtbl->CommitChanges(effect);
5265  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5267  hr = effect->lpVtbl->EndPass(effect);
5268  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5269  ivect[2] = 3;
5270  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5271  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5273  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5274  hr = effect->lpVtbl->BeginPass(effect, 1);
5275  ok(hr == E_FAIL, "Got result %#x.\n", hr);
5276  hr = effect->lpVtbl->BeginPass(effect, 1);
5277  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5279 
5280  /* End and begin effect again to ensure it will not trigger array
5281  * index recompute and error return from BeginPass. */
5282  hr = effect->lpVtbl->EndPass(effect);
5283  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5284  hr = effect->lpVtbl->End(effect);
5285  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5286  hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5287  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5288  hr = effect->lpVtbl->BeginPass(effect, 1);
5289  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5291  hr = effect->lpVtbl->EndPass(effect);
5292  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5293 
5294 
5296  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5297 
5298  ivect[2] = -2;
5299  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5300  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5301 
5302  hr = effect->lpVtbl->BeginPass(effect, 1);
5303  ok(hr == E_FAIL, "Got result %#x.\n", hr);
5304 
5306  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5307  ok(!vshader, "Got non NULL vshader.\n");
5308 
5309  hr = effect->lpVtbl->BeginPass(effect, 1);
5310  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5311 
5313 
5314  hr = effect->lpVtbl->EndPass(effect);
5315  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5316 
5317  ivect[2] = -1;
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 == D3D_OK, "Got result %#x.\n", hr);
5323 
5325 
5327  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5328 
5329  ivect[2] = 3;
5330  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5331  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5332  hr = effect->lpVtbl->CommitChanges(effect);
5333  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5334 
5336  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5337  ok(!vshader, "Got non NULL vshader.\n");
5338 
5339  ivect[2] = -1;
5340  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5341  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5342  hr = effect->lpVtbl->CommitChanges(effect);
5343  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5344 
5346  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5347  ok(!vshader, "Got non NULL vshader.\n");
5348 
5349  ivect[2] = 1;
5350  hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5351  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5352  hr = effect->lpVtbl->CommitChanges(effect);
5353  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5354 
5356 
5357  hr = effect->lpVtbl->EndPass(effect);
5358  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5359 
5360  hr = effect->lpVtbl->End(effect);
5361  ok(hr == D3D_OK, "Got result %#x.\n", hr);
5362 
5363  effect->lpVtbl->Release(effect);
5364 }
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:3474
#define FALSE
Definition: types.h:117
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:6601
#define IDirect3DDevice9_GetVertexShader(p, a)
Definition: d3d9.h:1600
LONG HRESULT
Definition: typedefs.h:79
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 NULL
Definition: types.h:112
#define test_effect_preshader_compare_shader(a, b, c)
Definition: effect.c:4294

Referenced by START_TEST().

◆ test_effect_parameter_block()

static void test_effect_parameter_block ( void  )
static

Definition at line 8011 of file effect.c.

8012 {
8013  static const D3DXMATRIX test_mat =
8014  {{{
8015  -11.0f, -12.0f, 0.0f, 0.0f,
8016  -21.0f, -22.0f, 0.0f, 0.0f,
8017  -31.0f, -32.0f, 0.0f, 0.0f,
8018  }}};
8019  static const D3DXMATRIX effect_orig_mat =
8020  {{{
8021  11.0f, 12.0f, 0.0f, 0.0f,
8022  21.0f, 22.0f, 0.0f, 0.0f,
8023  31.0f, 32.0f, 0.0f, 0.0f,
8024  }}};
8025  D3DPRESENT_PARAMETERS present_parameters = {0};
8026  static const float float_array_zero[4];
8027  IDirect3DTexture9 *texture, *tex_test;
8029  ID3DXEffect *effect, *effect2;
8030  D3DXMATRIX mat, mat_arr[2];
8031  IDirect3DDevice9 *device;
8032  ID3DXEffectPool *pool;
8033  float float_array[4];
8034  float float_value;
8035  IDirect3D9 *d3d;
8036  ULONG refcount;
8037  HWND window;
8038  HRESULT hr;
8039 
8040  if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
8041  640, 480, NULL, NULL, NULL, NULL)))
8042  {
8043  skip("Failed to create window.\n");
8044  return;
8045  }
8046  if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
8047  {
8048  skip("Failed to create IDirect3D9 object.\n");
8050  return;
8051  }
8052  present_parameters.Windowed = TRUE;
8053  present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
8055  D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
8056  if (FAILED(hr))
8057  {
8058  skip("Failed to create IDirect3DDevice9 object, hr %#x.\n", hr);
8059  IDirect3D9_Release(d3d);
8061  return;
8062  }
8063 
8065  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8066 
8068  NULL, NULL, 0, pool, &effect, NULL);
8069  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8071  NULL, NULL, 0, pool, &effect2, NULL);
8072  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8073 
8074  hr = effect->lpVtbl->BeginParameterBlock(effect);
8075  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8076  hr = effect->lpVtbl->BeginParameterBlock(effect);
8077  ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
8078  block = effect->lpVtbl->EndParameterBlock(effect);
8079  ok(!!block, "Got unexpected block %p.\n", block);
8080  handle = effect->lpVtbl->EndParameterBlock(effect);
8081  ok(!handle, "Got unexpected handle %p.\n", handle);
8082 
8083  /* Block doesn't hold effect reference. */
8084  effect->lpVtbl->AddRef(effect);
8085  refcount = effect->lpVtbl->Release(effect);
8086  ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
8087 
8088  hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8089  ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
8090  hr = effect->lpVtbl->DeleteParameterBlock(effect, block);
8091  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8092 
8093  hr = effect->lpVtbl->BeginParameterBlock(effect);
8094  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8095  hr = effect->lpVtbl->SetFloat(effect, "vec3[0]", 1001.0f);
8096  ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
8097  hr = effect->lpVtbl->SetFloat(effect, "arr1[0]", 91.0f);
8098  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8099  block = effect->lpVtbl->EndParameterBlock(effect);
8100  ok(!!block, "Got unexpected block %p.\n", block);
8101  hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8102  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8103 
8104  hr = effect->lpVtbl->DeleteParameterBlock(effect2, block);
8105  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
8106  hr = effect->lpVtbl->DeleteParameterBlock(effect, block);
8107  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8108 
8109  hr = effect->lpVtbl->ApplyParameterBlock(effect, NULL);
8110  ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
8111  hr = effect->lpVtbl->ApplyParameterBlock(effect, "parameter_block");
8112  ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
8113 
8115  ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
8116 
8117  hr = effect->lpVtbl->BeginParameterBlock(effect);
8118  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8119 
8120  /* Effect parameters are not updated during recording. */
8121  hr = effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)texture);
8122  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8123 
8124  hr = effect->lpVtbl->GetTexture(effect, "tex1", (IDirect3DBaseTexture9 **)&tex_test);
8125  ok(hr == D3D_OK && !tex_test, "Got unexpected hr %#x, tex_test %p.\n", hr, tex_test);
8126 
8127  /* Child parameters and array members are recorded separately (the whole
8128  * parameter is not updated when parameter block is applied). */
8129  hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 92.0f);
8130  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8131  hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 28.0f);
8132  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8133  hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
8134  ok(hr == D3D_OK && float_value == 12.0, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
8135 
8136  float_array[0] = -29.0f;
8137  hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array, 1);
8138  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8139  hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 1);
8140  ok(hr == D3D_OK && float_array[0] == 13.0, "Got unexpected hr %#x, float_array[0] %g.\n",
8141  hr, float_array[0]);
8142 
8143  memset(&mat, 0, sizeof(mat));
8144  hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &test_mat);
8145  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8146  hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
8147  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8148  ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n");
8149 
8150  hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &test_mat);
8151  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8152  hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
8153  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8154  ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n");
8155 
8156  /* Setting shared parameter through effect2 is not recorded to effect
8157  * parameter block. */
8158  hr = effect2->lpVtbl->SetFloat(effect2, "arr2[1]", -1.0f);
8159  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8160  hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
8161  ok(float_value == -1.0f, "Unexpected value %g.\n", float_value);
8162 
8164  refcount = IDirect3DTexture9_Release(texture);
8165  ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
8166 
8167  block = effect->lpVtbl->EndParameterBlock(effect);
8168  ok(!!block, "Got unexpected block %p.\n", block);
8169 
8171  refcount = IDirect3DTexture9_Release(texture);
8172  ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
8173 
8174  hr = effect->lpVtbl->DeleteParameterBlock(effect2, block);
8175  ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
8176 
8178  refcount = IDirect3DTexture9_Release(texture);
8179  ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
8180 
8181  hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f);
8182  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8183  hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f);
8184  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8185  hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3);
8186  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8187  hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f);
8188  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8189  hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4);
8190  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8191  memset(&mat, 0, sizeof(mat));
8192  hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &mat);
8193  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8194  hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &mat);
8195  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8196 
8197  hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8198  ok(hr == D3D_OK, "Got result %#x.\n", hr);
8199 
8201  refcount = IDirect3DTexture9_Release(texture);
8202  ok(refcount == 3, "Got unexpected refcount %u.\n", refcount);
8203 
8204  hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value);
8205  ok(hr == D3D_OK && float_value == 92.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
8206  hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
8207  ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
8208 
8209  hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3);
8210  ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)),
8211  "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n", hr,
8212  float_array[0], float_array[1], float_array[2]);
8213 
8214  hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
8215  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8216  ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
8217  hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
8218  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8219  ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
8220 
8221  hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
8222  ok(hr == D3D_OK && float_value == 28.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
8223 
8224  hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4);
8225  ok(hr == D3D_OK && float_array[0] == -29.0f
8226  && !memcmp(float_array + 1, float_array_zero, 3 * sizeof(*float_array)),
8227  "Got unexpected hr %#x, ts1[0].v2 (%g, %g, %g, %g).\n", hr,
8228  float_array[0], float_array[1], float_array[2], float_array[3]);
8229 
8230  /* Test applying a parameter block while recording a new one. */
8231  hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f);
8232  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8233  hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f);
8234  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8235  hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3);
8236  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8237  hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f);
8238  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8239  hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4);
8240  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8241  memset(&mat, 0, sizeof(mat));
8242  hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &effect_orig_mat);
8243  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8244  hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &effect_orig_mat);
8245  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8246 
8247  hr = effect->lpVtbl->BeginParameterBlock(effect);
8248  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8249  hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8250  ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
8251 
8252  hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value);
8253  ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
8254  hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);