ReactOS 0.4.17-dev-966-gf06eace
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(...)    test_isparameterused_param_with_children_(__LINE__, __VA_ARGS__)
 
#define INITIAL_UPDATE_RECORD_SIZE   64
 
#define test_effect_shared_vs_arr_compare_helper(...)    test_effect_shared_vs_arr_compare_helper_(__LINE__, __VA_ARGS__)
 
#define test_effect_shared_parameters_compare_vconst(...)    test_effect_shared_parameters_compare_vconst_(__LINE__, __VA_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_uint (unsigned int x, unsigned int y, unsigned int max_diff)
 
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)
 
static void test_effect_parameter_value_GetBool (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetBoolArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetInt (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetIntArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetFloat (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetFloatArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetVector (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetVectorArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetMatrix (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetMatrixArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetMatrixPointerArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetMatrixTranspose (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetMatrixTransposeArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_GetMatrixTransposePointerArray (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_values (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
static void test_effect_parameter_value_reset (const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
 
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_manager * impl_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 []
 
static const struct test_effect_parameter_value_result test_effect_parameter_value_result_float []
 
static const DWORD test_effect_parameter_value_blob_int []
 
static const struct test_effect_parameter_value_result test_effect_parameter_value_result_int []
 
static const DWORD test_effect_parameter_value_blob_object []
 
static const struct test_effect_parameter_value_result test_effect_parameter_value_result_object []
 
static const DWORD test_effect_parameter_value_blob_special []
 
static const 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 char * test_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 1143 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 1168 of file effect.c.

◆ INITIAL_UPDATE_RECORD_SIZE

#define INITIAL_UPDATE_RECORD_SIZE   64

Definition at line 6249 of file effect.c.

◆ INT_FLOAT_MULTI

#define INT_FLOAT_MULTI   255.0f

Definition at line 1170 of file effect.c.

◆ INT_FLOAT_MULTI_INVERSE

#define INT_FLOAT_MULTI_INVERSE   (1/INT_FLOAT_MULTI)

Definition at line 1171 of file effect.c.

◆ TEST_EFFECT_BITMASK_BLOCK_SIZE

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

Definition at line 4582 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 4652 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 4429 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 4402 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 4584 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 4506 of file effect.c.

◆ TEST_EFFECT_PRESHADER_VSHADER_LEN

#define TEST_EFFECT_PRESHADER_VSHADER_LEN   13

Definition at line 4400 of file effect.c.

◆ TEST_EFFECT_PRESHADER_VSHADER_POS

#define TEST_EFFECT_PRESHADER_VSHADER_POS   2991

Definition at line 4399 of file effect.c.

◆ test_effect_shared_parameters_compare_vconst

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

Definition at line 6758 of file effect.c.

◆ test_effect_shared_vs_arr_compare_helper

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

Definition at line 6737 of file effect.c.

◆ TEST_EFFECT_STATES_VSHADER_POS

#define TEST_EFFECT_STATES_VSHADER_POS   315

Definition at line 3119 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 7391 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 7390 of file effect.c.

◆ test_isparameterused_param_with_children

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

Definition at line 5284 of file effect.c.

Enumeration Type Documentation

◆ expected_state_update

Enumerator
EXPECTED_STATE_ZERO 
EXPECTED_STATE_UPDATED 
EXPECTED_STATE_ANYTHING 

Definition at line 4499 of file effect.c.

4500{
4504};
@ EXPECTED_STATE_ZERO
Definition: effect.c:4501
@ EXPECTED_STATE_UPDATED
Definition: effect.c:4502
@ EXPECTED_STATE_ANYTHING
Definition: effect.c:4503

Function Documentation

◆ compare_float()

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

Definition at line 33 of file effect.c.

34{
35 INT x = *(INT *)&f;
36 INT y = *(INT *)&g;
37
38 if (x < 0)
39 x = INT_MIN - x;
40 if (y < 0)
41 y = INT_MIN - y;
42
43 return compare_uint(x, y, ulps);
44}
#define INT_MIN
Definition: limits.h:25
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean g
Definition: glext.h:6204
static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
Definition: effect.c:26
unsigned int ulps
Definition: effect.c:4467
int32_t INT
Definition: typedefs.h:58

◆ compare_uint()

static BOOL compare_uint ( unsigned int  x,
unsigned int  y,
unsigned int  max_diff 
)
static

Definition at line 26 of file effect.c.

27{
28 unsigned int diff = x > y ? x - y : y - x;
29
30 return diff <= max_diff;
31}

Referenced by compare_float().

◆ compare_update_record()

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

Definition at line 6478 of file effect.c.

6479{
6480 const struct test_state_manager_update *r1 = (const struct test_state_manager_update *)a;
6481 const struct test_state_manager_update *r2 = (const struct test_state_manager_update *)b;
6482
6483 if (r1->state_op != r2->state_op)
6484 return r1->state_op - r2->state_op;
6485 if (r1->param1 != r2->param1)
6486 return r1->param1 - r2->param1;
6487 return r1->param2 - r2->param2;
6488}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38

Referenced by test_effect_state_manager().

◆ create_device()

static IDirect3DDevice9 * create_device ( HWND *  window)
static

Definition at line 135 of file effect.c.

136{
137 D3DPRESENT_PARAMETERS present_parameters = { 0 };
139 IDirect3D9 *d3d;
140 HRESULT hr;
141 HWND wnd;
142
143 *window = NULL;
144
145 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
146 640, 480, NULL, NULL, NULL, NULL)))
147 {
148 skip("Couldn't create application window.\n");
149 return NULL;
150 }
151
152 if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
153 {
154 skip("Couldn't create IDirect3D9 object.\n");
155 DestroyWindow(wnd);
156 return NULL;
157 }
158
159 present_parameters.Windowed = TRUE;
160 present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
162 &present_parameters, &device);
164 if (FAILED(hr))
165 {
166 skip("Failed to create IDirect3DDevice9 object %#lx.\n", hr);
167 DestroyWindow(wnd);
168 return NULL;
169 }
170
171 *window = wnd;
172 return device;
173}
#define skip(...)
Definition: atltest.h:64
@ D3DSWAPEFFECT_DISCARD
Definition: d3d8types.h:851
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:224
#define IDirect3D9_Release(p)
Definition: d3d9.h:209
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
#define FAILED(hr)
Definition: intsafe.h:51
static IHTMLWindow2 * window
Definition: events.c:77
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI DestroyWindow(_In_ HWND)
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:53
#define D3DCREATE_HARDWARE_VERTEXPROCESSING
Definition: d3d8.h:41
#define D3D_SDK_VERSION
Definition: d3d8.h:52
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: devices.h:37

◆ create_directory()

static BOOL create_directory ( const char *  name)
static

Definition at line 214 of file effect.c.

215{
216 char path[MAX_PATH];
217
219 strcat(path, name);
220 return CreateDirectoryA(path, NULL);
221}
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
static char temp_path[MAX_PATH]
Definition: effect.c:175
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
Definition: name.c:39

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

178{
179 DWORD written;
180 HANDLE hfile;
181 char path[MAX_PATH];
182
183 if (!*temp_path)
185
189 if (hfile == INVALID_HANDLE_VALUE)
190 return FALSE;
191
192 if (WriteFile(hfile, data, size, &written, NULL))
193 {
194 CloseHandle(hfile);
195
196 if (out_path)
197 strcpy(out_path, path);
198 return TRUE;
199 }
200
201 CloseHandle(hfile);
202 return FALSE;
203}
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2072
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
const char * filename
Definition: ioapi.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90

◆ d3dxinclude_close()

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

Definition at line 8106 of file effect.c.

8107{
8108 free((void *)data);
8109 return S_OK;
8110}
#define free
Definition: debug_ros.c:5
#define S_OK
Definition: intsafe.h:52

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

8026{
8027 static const char include1[] =
8028 "float4 light;\n"
8029 "float4x4 mat;\n"
8030 "float4 color;\n"
8031 "\n"
8032 "struct vs_input\n"
8033 "{\n"
8034 " float4 position : POSITION;\n"
8035 " float3 normal : NORMAL;\n"
8036 "};\n"
8037 "\n"
8038 "struct vs_output\n"
8039 "{\n"
8040 " float4 position : POSITION;\n"
8041 " float4 diffuse : COLOR;\n"
8042 "};\n";
8043 static const char include2[] =
8044 "#include \"include1.h\"\n"
8045 "\n"
8046 "vs_output vs_main(const vs_input v)\n"
8047 "{\n"
8048 " vs_output o;\n"
8049 " const float4 scaled_color = 0.5 * color;\n"
8050 "\n"
8051 " o.position = mul(v.position, mat);\n"
8052 " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
8053 "\n"
8054 " return o;\n"
8055 "}\n";
8056 static const char effect2[] =
8057 "#include \"include\\include2.h\"\n"
8058 "\n"
8059 "technique t\n"
8060 "{\n"
8061 " pass p\n"
8062 " {\n"
8063 " VertexShader = compile vs_2_0 vs_main();\n"
8064 " }\n"
8065 "}\n";
8066 char *buffer;
8067
8068 if (winetest_debug > 1)
8069 {
8070 trace("filename %s.\n", filename);
8071 trace("parent_data %p: %s.\n", parent_data, parent_data ? (char *)parent_data : "(null)");
8072 }
8073
8074 if (!strcmp(filename, "effect2.fx"))
8075 {
8076 buffer = malloc(sizeof(effect2));
8077 memcpy(buffer, effect2, sizeof(effect2));
8078 *bytes = sizeof(effect2);
8079 ok(!parent_data, "Unexpected parent_data value.\n");
8080 }
8081 else if (!strcmp(filename, "include1.h"))
8082 {
8083 buffer = malloc(sizeof(include1));
8084 memcpy(buffer, include1, sizeof(include1));
8085 *bytes = sizeof(include1);
8086 ok(!strncmp(parent_data, include2, strlen(include2)), "Unexpected parent_data value.\n");
8087 }
8088 else if (!strcmp(filename, "include\\include2.h"))
8089 {
8090 buffer = malloc(sizeof(include2));
8091 memcpy(buffer, include2, sizeof(include2));
8092 *bytes = sizeof(include2);
8093 /* d3dx9_36 passes parent_data even for includes from the main file. */
8094 ok(!parent_data || (parent_data && !strncmp(parent_data, effect2, strlen(effect2))),
8095 "unexpected parent_data value.\n");
8096 }
8097 else
8098 {
8099 ok(0, "Unexpected #include for file %s.\n", filename);
8100 return D3DERR_INVALIDCALL;
8101 }
8102 *data = buffer;
8103 return S_OK;
8104}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
#define malloc
Definition: debug_ros.c:4
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3335
GLuint buffer
Definition: glext.h:5915
int winetest_debug
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

◆ delete_directory()

static void delete_directory ( const char *  name)
static

Definition at line 223 of file effect.c.

224{
225 char path[MAX_PATH];
226
228 strcat(path, name);
230}
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:682

Referenced by test_create_effect_from_file().

◆ delete_file()

static void delete_file ( const char *  filename)
static

Definition at line 205 of file effect.c.

206{
207 char path[MAX_PATH];
208
212}
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24

◆ free_test_effect_state_manager()

static void free_test_effect_state_manager ( struct test_manager *  state_manager)
static

Definition at line 6256 of file effect.c.

6257{
6258 free(state_manager->update_record);
6259 state_manager->update_record = NULL;
6260
6261 IDirect3DDevice9_Release(state_manager->device);
6262}
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
struct test_state_manager_update * update_record
Definition: effect.c:6244
IDirect3DDevice9 * device
Definition: effect.c:6243

Referenced by test_manager_Release().

◆ get_bool()

static BOOL get_bool ( const void *  data)
inlinestatic

Definition at line 100 of file effect.c.

101{
102 return !!*(BOOL *)data;
103}
unsigned int BOOL
Definition: ntddk_ex.h:94

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

74{
75 float f;
76
77 switch (type)
78 {
79 case D3DXPT_FLOAT:
80 f = *(FLOAT *)data;
81 break;
82
83 case D3DXPT_INT:
84 f = *(INT *)data;
85 break;
86
87 case D3DXPT_BOOL:
88 f = *(BOOL *)data;
89 break;
90
91 default:
92 f = 0.0f;
93 ok(0, "Unhandled type %x.\n", type);
94 break;
95 }
96
97 return f;
98}
@ D3DXPT_FLOAT
Definition: d3dx9shader.h:76
@ D3DXPT_BOOL
Definition: d3dx9shader.h:74
@ D3DXPT_INT
Definition: d3dx9shader.h:75
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define f
Definition: ke_i.h:83
float FLOAT
Definition: typedefs.h:69

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

47{
48 INT i;
49
50 switch (type)
51 {
52 case D3DXPT_FLOAT:
53 i = *(FLOAT *)data;
54 break;
55
56 case D3DXPT_INT:
57 i = *(INT *)data;
58 break;
59
60 case D3DXPT_BOOL:
61 i = *(BOOL *)data;
62 break;
63
64 default:
65 i = 0;
66 ok(0, "Unhandled type %x.\n", type);
67 break;
68 }
69
70 return i;
71}
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

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

7908{
7910 return IDirect3DTexture9_Release(iface);
7911}
#define IDirect3DTexture9_AddRef(p)
Definition: d3d9.h:841
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:842

Referenced by test_refcount().

◆ impl_from_ID3DXEffectStateManager()

static struct test_manager * impl_from_ID3DXEffectStateManager ( ID3DXEffectStateManager *  iface)
static

Definition at line 6251 of file effect.c.

6252{
6253 return CONTAINING_RECORD(iface, struct test_manager, ID3DXEffectStateManager_iface);
6254}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

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

106{
107 switch (outtype)
108 {
109 case D3DXPT_FLOAT:
110 *(FLOAT *)outdata = get_float(intype, indata);
111 break;
112
113 case D3DXPT_BOOL:
114 *(BOOL *)outdata = get_bool(indata);
115 break;
116
117 case D3DXPT_INT:
118 *(INT *)outdata = get_int(intype, indata);
119 break;
120
123 case D3DXPT_TEXTURE2D:
124 case D3DXPT_STRING:
125 *(INT *)outdata = 0x12345678;
126 break;
127
128 default:
129 ok(0, "Unhandled type %x.\n", outtype);
130 *(INT *)outdata = 0;
131 break;
132 }
133}
@ D3DXPT_STRING
Definition: d3dx9shader.h:77
@ D3DXPT_VERTEXSHADER
Definition: d3dx9shader.h:89
@ D3DXPT_PIXELSHADER
Definition: d3dx9shader.h:88
@ D3DXPT_TEXTURE2D
Definition: d3dx9shader.h:80
static INT get_int(D3DXPARAMETER_TYPE type, const void *data)
Definition: effect.c:46
static float get_float(D3DXPARAMETER_TYPE type, const void *data)
Definition: effect.c:73
static BOOL get_bool(const void *data)
Definition: effect.c:100

◆ START_TEST()

START_TEST ( effect  )

Definition at line 8893 of file effect.c.

8894{
8896 ULONG refcount;
8897 HWND wnd;
8898
8899 if (!(device = create_device(&wnd)))
8900 return;
8901
8921
8922 refcount = IDirect3DDevice9_Release(device);
8923 ok(!refcount, "Device has %lu references left.\n", refcount);
8924 DestroyWindow(wnd);
8925
8929 test_refcount();
8933}
static ID3D11Device * create_device(void)
Definition: hlsl_d3d11.c:102
static void test_effect_get_pass_desc(IDirect3DDevice9 *device)
Definition: effect.c:7088
static void test_effect_isparameterused(IDirect3DDevice9 *device)
Definition: effect.c:5306
static void test_effect_compilation_errors(IDirect3DDevice9 *device)
Definition: effect.c:2992
static void test_effect_parameter_value(IDirect3DDevice9 *device)
Definition: effect.c:1952
static void test_effect_unsupported_shader(void)
Definition: effect.c:7393
static void test_create_effect_from_file(void)
Definition: effect.c:8123
static void test_effect_shared_parameters(IDirect3DDevice9 *device)
Definition: effect.c:6773
static void test_effect_null_shader(void)
Definition: effect.c:7525
static void test_effect_state_manager(IDirect3DDevice9 *device)
Definition: effect.c:6490
static void test_effect_skip_constants(IDirect3DDevice9 *device)
Definition: effect.c:7247
static void test_effect_states(IDirect3DDevice9 *device)
Definition: effect.c:3135
static void test_effect_parameter_block(void)
Definition: effect.c:8471
static void test_effect_preshader_ops(IDirect3DDevice9 *device)
Definition: effect.c:5170
static void test_effect_large_address_aware_flag(IDirect3DDevice9 *device)
Definition: effect.c:7055
static void test_effect_clone(void)
Definition: effect.c:7580
static void test_effect_preshader(IDirect3DDevice9 *device)
Definition: effect.c:4702
static void test_effect_preshader_relative_addressing(IDirect3DDevice9 *device)
Definition: effect.c:5963
static void test_refcount(void)
Definition: effect.c:7913
static void test_effect_commitchanges(IDirect3DDevice9 *device)
Definition: effect.c:5533
static void test_effect_out_of_bounds_selector(IDirect3DDevice9 *device)
Definition: effect.c:5376
static void test_create_effect_and_pool(IDirect3DDevice9 *device)
Definition: effect.c:237
static void test_cross_effect_handle(IDirect3DDevice9 *device)
Definition: effect.c:6603
static void test_effect_setvalue_object(IDirect3DDevice9 *device)
Definition: effect.c:2613
static void test_effect_variable_names(IDirect3DDevice9 *device)
Definition: effect.c:2743
static void test_create_effect_compiler(void)
Definition: effect.c:362
static void test_effect_find_next_valid_technique(void)
Definition: effect.c:8346
uint32_t ULONG
Definition: typedefs.h:59

◆ test_create_effect_and_pool()

static void test_create_effect_and_pool ( IDirect3DDevice9 *  device)
static

Definition at line 237 of file effect.c.

238{
240 HRESULT hr;
241 ID3DXEffect *effect;
242 ID3DXBaseEffect *base;
243 ULONG count;
244 IDirect3DDevice9 *device2;
245 ID3DXEffectStateManager *manager = (ID3DXEffectStateManager *)0xdeadbeef;
246 ID3DXEffectPool *pool = (ID3DXEffectPool *)0xdeadbeef, *pool2;
247
249 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
250
252 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
253
255 ok(hr == E_FAIL, "Got result %lx, expected %lx (D3DXERR_INVALIDDATA)\n", hr, E_FAIL);
256
258 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
259
260 hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, &effect, NULL);
261 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
262
263 hr = effect->lpVtbl->GetDesc(effect, &desc);
264 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
265 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
266 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
267 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
268 ok(!desc.Parameters, "Unexpected value %u.\n", desc.Parameters);
269
270 hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3DXBaseEffect, (void **)&base);
271 ok(hr == E_NOINTERFACE, "QueryInterface failed, got %lx, expected %lx (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
272
273 hr = effect->lpVtbl->GetStateManager(effect, NULL);
274 ok(hr == D3DERR_INVALIDCALL, "GetStateManager failed, got %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
275
276 hr = effect->lpVtbl->GetStateManager(effect, &manager);
277 ok(hr == D3D_OK, "GetStateManager failed, got %lx, expected 0 (D3D_OK)\n", hr);
278 ok(!manager, "GetStateManager failed, got %p\n", manager);
279
280 /* this works, but it is not recommended! */
281 hr = effect->lpVtbl->SetStateManager(effect, (ID3DXEffectStateManager *)device);
282 ok(hr == D3D_OK, "SetStateManager failed, got %lx, expected 0 (D3D_OK)\n", hr);
283
284 hr = effect->lpVtbl->GetStateManager(effect, &manager);
285 ok(hr == D3D_OK, "GetStateManager failed, got %lx, expected 0 (D3D_OK)\n", hr);
286 ok(manager != NULL, "GetStateManager failed\n");
287
290 ok(count == 4, "Release failed, got %lu, expected 4\n", count);
291
292 count = IUnknown_Release(manager);
293 ok(count == 3, "Release failed, got %lu, expected 3\n", count);
294
295 hr = effect->lpVtbl->SetStateManager(effect, NULL);
296 ok(hr == D3D_OK, "SetStateManager failed, got %lx, expected 0 (D3D_OK)\n", hr);
297
298 hr = effect->lpVtbl->GetPool(effect, &pool);
299 ok(hr == D3D_OK, "GetPool failed, got %lx, expected 0 (D3D_OK)\n", hr);
300 ok(!pool, "GetPool failed, got %p\n", pool);
301
302 hr = effect->lpVtbl->GetPool(effect, NULL);
303 ok(hr == D3DERR_INVALIDCALL, "GetPool failed, got %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
304
305 hr = effect->lpVtbl->GetDevice(effect, &device2);
306 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
307
308 hr = effect->lpVtbl->GetDevice(effect, NULL);
309 ok(hr == D3DERR_INVALIDCALL, "GetDevice failed, got %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
310
312 ok(count == 2, "Release failed, got %lu, expected 2\n", count);
313
314 count = effect->lpVtbl->Release(effect);
315 ok(count == 0, "Release failed %lu\n", count);
316
318 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
319
321 ok(hr == S_OK, "Got result %lx, expected 0 (S_OK)\n", hr);
322
323 count = pool->lpVtbl->Release(pool);
324 ok(count == 0, "Release failed %lu\n", count);
325
327 ok(hr == S_OK, "Got result %lx, expected 0 (S_OK)\n", hr);
328
330 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
331
332 hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3DXEffectPool, (void **)&pool2);
333 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
334 ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool);
335
336 count = pool2->lpVtbl->Release(pool2);
337 ok(count == 1, "Release failed, got %lu, expected 1\n", count);
338
339 hr = IDirect3DDevice9_QueryInterface(device, &IID_IDirect3DDevice9, (void **)&device2);
340 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
341
343 ok(count == 1, "Release failed, got %lu, expected 1\n", count);
344
345 hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, pool, &effect, NULL);
346 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
347
348 hr = effect->lpVtbl->GetPool(effect, &pool);
349 ok(hr == D3D_OK, "GetPool failed, got %lx, expected 0 (D3D_OK)\n", hr);
350 ok(pool == pool2, "Got effect pool %p, expected %p.\n", pool2, pool);
351
352 count = pool2->lpVtbl->Release(pool2);
353 ok(count == 2, "Release failed, got %lu, expected 2\n", count);
354
355 count = effect->lpVtbl->Release(effect);
356 ok(count == 0, "Release failed %lu\n", count);
357
358 count = pool->lpVtbl->Release(pool);
359 ok(count == 0, "Release failed %lu\n", count);
360}
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1335
#define IDirect3DDevice9_QueryInterface(p, a, b)
Definition: d3d9.h:1334
#define D3D_OK
Definition: d3d.h:106
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI D3DXCreateEffectPool(ID3DXEffectPool **pool)
Definition: effect.c:6875
HRESULT WINAPI D3DXCreateEffect(struct IDirect3DDevice9 *device, const void *data, UINT data_size, const D3DXMACRO *defines, struct ID3DXInclude *include, DWORD flags, struct ID3DXEffectPool *pool, struct ID3DXEffect **effect, struct ID3DXBuffer **messages)
Definition: effect.c:6729
GLuint GLuint GLsizei count
Definition: gl.h:1545
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
nsrefcnt Release()
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static const char effect_desc[]
Definition: effect.c:232
#define E_NOINTERFACE
Definition: winerror.h:3479

Referenced by START_TEST().

◆ test_create_effect_compiler()

static void test_create_effect_compiler ( void  )
static

Definition at line 362 of file effect.c.

363{
364 HRESULT hr;
365 ID3DXEffectCompiler *compiler, *compiler2;
366 ID3DXBaseEffect *base;
368 ULONG count;
369
370 hr = D3DXCreateEffectCompiler(NULL, 0, NULL, NULL, 0, &compiler, NULL);
371 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
372
374 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
375
376 hr = D3DXCreateEffectCompiler(effect_desc, 0, NULL, NULL, 0, &compiler, NULL);
377 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
378 if (FAILED(hr))
379 {
380 skip("D3DXCreateEffectCompiler failed, skipping test.\n");
381 return;
382 }
383
384 count = compiler->lpVtbl->Release(compiler);
385 ok(count == 0, "Release failed %lu\n", count);
386
388 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
389
390 hr = D3DXCreateEffectCompiler(NULL, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL);
391 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
392
394 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
395
397 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
398
399 hr = D3DXCreateEffectCompiler(effect_desc, sizeof(effect_desc), NULL, NULL, 0, &compiler, NULL);
400 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
401
402 hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXBaseEffect, (void **)&base);
403 ok(hr == E_NOINTERFACE, "QueryInterface failed, got %lx, expected %lx (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
404
405 hr = compiler->lpVtbl->QueryInterface(compiler, &IID_ID3DXEffectCompiler, (void **)&compiler2);
406 ok(hr == D3D_OK, "QueryInterface failed, got %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
407
408 hr = compiler->lpVtbl->QueryInterface(compiler, &IID_IUnknown, (void **)&unknown);
409 ok(hr == D3D_OK, "QueryInterface failed, got %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
410
411 count = unknown->lpVtbl->Release(unknown);
412 ok(count == 2, "Release failed, got %lu, expected %u\n", count, 2);
413
414 count = compiler2->lpVtbl->Release(compiler2);
415 ok(count == 1, "Release failed, got %lu, expected %u\n", count, 1);
416
417 count = compiler->lpVtbl->Release(compiler);
418 ok(count == 0, "Release failed %lu\n", count);
419}
const GUID IID_IUnknown
HRESULT WINAPI D3DXCreateEffectCompiler(const char *data, UINT data_size, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXEffectCompiler **compiler, ID3DXBuffer **messages)
Definition: effect.c:6755
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674

Referenced by START_TEST().

◆ test_create_effect_from_file()

static void test_create_effect_from_file ( void  )
static

Definition at line 8123 of file effect.c.

8124{
8125 static const char effect1[] =
8126 "float4 light;\n"
8127 "float4x4 mat;\n"
8128 "float4 color;\n"
8129 "\n"
8130 "struct vs_input\n"
8131 "{\n"
8132 " float4 position : POSITION;\n"
8133 " float3 normal : NORMAL;\n"
8134 "};\n"
8135 "\n"
8136 "struct vs_output\n"
8137 "{\n"
8138 " float4 position : POSITION;\n"
8139 " float4 diffuse : COLOR;\n"
8140 "};\n"
8141 "\n"
8142 "vs_output vs_main(const vs_input v)\n"
8143 "{\n"
8144 " vs_output o;\n"
8145 " const float4 scaled_color = 0.5 * color;\n"
8146 "\n"
8147 " o.position = mul(v.position, mat);\n"
8148 " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
8149 "\n"
8150 " return o;\n"
8151 "}\n"
8152 "\n"
8153 "technique t\n"
8154 "{\n"
8155 " pass p\n"
8156 " {\n"
8157 " VertexShader = compile vs_2_0 vs_main();\n"
8158 " }\n"
8159 "}\n";
8160 static const char include1[] =
8161 "float4 light;\n"
8162 "float4x4 mat;\n"
8163 "float4 color;\n"
8164 "\n"
8165 "struct vs_input\n"
8166 "{\n"
8167 " float4 position : POSITION;\n"
8168 " float3 normal : NORMAL;\n"
8169 "};\n"
8170 "\n"
8171 "struct vs_output\n"
8172 "{\n"
8173 " float4 position : POSITION;\n"
8174 " float4 diffuse : COLOR;\n"
8175 "};\n";
8176 static const char include1_wrong[] =
8177 "#error \"wrong include\"\n";
8178 static const char include2[] =
8179 "#include \"include1.h\"\n"
8180 "\n"
8181 "vs_output vs_main(const vs_input v)\n"
8182 "{\n"
8183 " vs_output o;\n"
8184 " const float4 scaled_color = 0.5 * color;\n"
8185 "\n"
8186 " o.position = mul(v.position, mat);\n"
8187 " o.diffuse = dot((float3)light, v.normal) * scaled_color;\n"
8188 "\n"
8189 " return o;\n"
8190 "}\n";
8191 static const char effect2[] =
8192 "#include \"include\\include2.h\"\n"
8193 "\n"
8194 "technique t\n"
8195 "{\n"
8196 " pass p\n"
8197 " {\n"
8198 " VertexShader = compile vs_2_0 vs_main();\n"
8199 " }\n"
8200 "}\n";
8201 WCHAR effect_path_w[MAX_PATH], filename_w[MAX_PATH];
8202 char effect_path[MAX_PATH], filename[MAX_PATH];
8203 D3DPRESENT_PARAMETERS present_parameters = {0};
8204 unsigned int filename_size;
8205 struct d3dxinclude include;
8208 ID3DXEffect *effect;
8209 IDirect3D9 *d3d;
8210 ULONG refcount;
8211 HWND window;
8212 HRESULT hr;
8213
8214 if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
8215 640, 480, NULL, NULL, NULL, NULL)))
8216 {
8217 skip("Failed to create window.\n");
8218 return;
8219 }
8220 if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
8221 {
8222 skip("Failed to create IDirect3D9 object.\n");
8224 return;
8225 }
8226 present_parameters.Windowed = TRUE;
8227 present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
8229 D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
8230 if (FAILED(hr))
8231 {
8232 skip("Failed to create IDirect3DDevice9 object, hr %#lx.\n", hr);
8233 IDirect3D9_Release(d3d);
8235 return;
8236 }
8237
8238 if (!create_file("effect1.fx", effect1, sizeof(effect1) - 1, filename))
8239 {
8240 skip("Couldn't create temporary file, skipping test.\n");
8241 return;
8242 }
8243
8244 filename_size = strlen(filename);
8245 filename_size -= sizeof("effect1.fx") - 1;
8246 memcpy(effect_path, filename, filename_size);
8247 effect_path[filename_size] = 0;
8248 MultiByteToWideChar(CP_ACP, 0, effect_path, -1, effect_path_w, ARRAY_SIZE(effect_path_w));
8249
8250 create_directory("include");
8251 create_file("effect2.fx", effect2, sizeof(effect2) - 1, NULL);
8252 create_file("include\\include1.h", include1, sizeof(include1) - 1, NULL);
8253 create_file("include\\include2.h", include2, sizeof(include2) - 1, NULL);
8254 create_file("include1.h", include1_wrong, sizeof(include1_wrong) - 1, NULL);
8255
8256 lstrcpyW(filename_w, effect_path_w);
8257 lstrcatW(filename_w, L"effect1.fx");
8258 effect = NULL;
8259 messages = NULL;
8261 0, NULL, &effect, &messages);
8262 todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
8263 if (messages)
8264 {
8265 trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
8267 }
8268 if (effect)
8269 effect->lpVtbl->Release(effect);
8270
8271 lstrcpyW(filename_w, effect_path_w);
8272 lstrcatW(filename_w, L"effect2.fx");
8273 effect = NULL;
8274 messages = NULL;
8275 /* This is apparently broken on native, it ends up using the wrong include. */
8277 0, NULL, &effect, &messages);
8278 todo_wine ok(hr == E_FAIL, "Unexpected error, hr %#lx.\n", hr);
8279 if (messages)
8280 {
8281 trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
8283 }
8284
8285 delete_file("effect1.fx");
8286 delete_file("effect2.fx");
8287 delete_file("include\\include1.h");
8288 delete_file("include\\include2.h");
8289 delete_file("include2.h");
8290 delete_directory("include");
8291
8292 lstrcpyW(filename_w, L"effect2.fx");
8293 effect = NULL;
8294 messages = NULL;
8295 include.ID3DXInclude_iface.lpVtbl = &d3dxinclude_vtbl;
8296 /* This is actually broken in native d3dx9 (manually tried multiple
8297 * versions, all are affected). For reference, the message printed below
8298 * is "ID3DXEffectCompiler: There were no techniques" */
8299 hr = D3DXCreateEffectFromFileExW(device, filename_w, NULL, &include.ID3DXInclude_iface, NULL,
8300 0, NULL, &effect, &messages);
8301 todo_wine ok(hr == E_FAIL, "D3DXInclude test failed with error %#lx.\n", hr);
8302 if (messages)
8303 {
8304 trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
8306 }
8307
8308 refcount = IDirect3DDevice9_Release(device);
8309 ok(!refcount, "Device has %lu references left.\n", refcount);
8310 IDirect3D9_Release(d3d);
8312}
#define ARRAY_SIZE(A)
Definition: main.h:20
static SIZE_T const char const D3D_SHADER_MACRO ID3DInclude * include
Definition: asm.c:31
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
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 **messages)
Definition: effect.c:6896
#define CP_ACP
Definition: compat.h:109
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define L(x)
Definition: resources.c:13
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define todo_wine
Definition: minitest.h:80
static BOOL create_directory(const char *name)
Definition: effect.c:214
static void delete_directory(const char *name)
Definition: effect.c:223
static const struct ID3DXIncludeVtbl d3dxinclude_vtbl
Definition: effect.c:8112
#define create_file(name, size)
Definition: asmcache.c:811
short WCHAR
Definition: pedump.c:58
#define delete_file(f)
Definition: reg_test.h:97

Referenced by START_TEST().

◆ test_cross_effect_handle()

static void test_cross_effect_handle ( IDirect3DDevice9 *  device)
static

Definition at line 6603 of file effect.c.

6604{
6605 ID3DXEffect *effect1, *effect2;
6606 D3DXHANDLE param1, param2;
6607 static int expected_ivect[4] = {28, 29, 30, 31};
6608 int ivect[4];
6609 HRESULT hr;
6610
6612 NULL, NULL, 0, NULL, &effect1, NULL);
6613 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6615 NULL, NULL, 0, NULL, &effect2, NULL);
6616 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6617
6618 ok(effect1 != effect2, "Got same effect unexpectedly.\n");
6619
6620 param1 = effect1->lpVtbl->GetParameterByName(effect1, NULL, "g_iVect");
6621 ok(!!param1, "GetParameterByName failed.\n");
6622
6623 param2 = effect2->lpVtbl->GetParameterByName(effect2, NULL, "g_iVect");
6624 ok(!!param2, "GetParameterByName failed.\n");
6625
6626 ok(param1 != param2, "Got same parameter handle unexpectedly.\n");
6627
6628 hr = effect2->lpVtbl->SetValue(effect2, param1, expected_ivect, sizeof(expected_ivect));
6629 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6630
6631 hr = effect1->lpVtbl->GetValue(effect1, param1, ivect, sizeof(ivect));
6632 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6633
6634 ok(!memcmp(ivect, expected_ivect, sizeof(expected_ivect)), "Vector value mismatch.\n");
6635
6636 effect2->lpVtbl->Release(effect2);
6637 effect1->lpVtbl->Release(effect1);
6638}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
static const DWORD test_effect_preshader_effect_blob[]
Definition: effect.c:3609

Referenced by START_TEST().

◆ test_effect_clear_vconsts()

static void test_effect_clear_vconsts ( IDirect3DDevice9 *  device)
static

Definition at line 3123 of file effect.c.

3124{
3125 unsigned int i;
3126 HRESULT hr;
3127
3128 for (i = 0; i < 256; ++i)
3129 {
3131 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
3132 }
3133}
#define IDirect3DDevice9_SetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1429
static const D3DXVECTOR4 fvect_filler
Definition: effect.c:3121

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

7581{
7582 D3DXHANDLE parameter, parameter2, technique, technique2, block, annotation;
7583 IDirect3DDevice9 *device, *device2, *device3;
7584 IDirect3DBaseTexture9 *texture, *texture2;
7585 ID3DXEffectStateManager *ret_manager;
7586 struct test_manager *state_manager;
7587 IDirect3DVertexShader9 *vs, *vs2;
7588 ID3DXEffect *effect, *cloned;
7589 unsigned int passes_count;
7590 HWND window, window2;
7591 const char *string;
7592 ULONG refcount;
7593 HRESULT hr;
7594 float f;
7595
7596 static const DWORD effect_code[] =
7597 {
7598#if 0
7599 Texture2D tex;
7600 float f <float a = 1.0;>;
7601 string s;
7602 float skipped : register(c4);
7603
7604 float4 vs0_main(float4 pos : POSITION) : POSITION
7605 {
7606 return pos;
7607 }
7608
7609 vertexshader vs = compile vs_2_0 vs0_main();
7610
7611 technique tech0 <float a = 1.0;>
7612 {
7613 pass p
7614 {
7615 VertexShader = vs;
7616 }
7617 }
7618
7619 float4 vs1_main(float4 pos : POSITION) : POSITION
7620 {
7621 return skipped;
7622 }
7623
7624 technique tech1
7625 {
7626 pass p
7627 {
7628 VertexShader = compile vs_2_0 vs1_main();
7629 }
7630 }
7631#endif
7632 0xfeff0901, 0x00000160, 0x00000000, 0x00000007, 0x00000004, 0x0000001c, 0x00000000, 0x00000000,
7633 0x00000001, 0x00000004, 0x00786574, 0x00000003, 0x00000000, 0x0000006c, 0x00000000, 0x00000000,
7634 0x00000001, 0x00000001, 0x00000000, 0x3f800000, 0x00000003, 0x00000000, 0x00000064, 0x00000000,
7635 0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x00000061, 0x00000002, 0x00000066, 0x00000004,
7636 0x00000004, 0x0000008c, 0x00000000, 0x00000000, 0x00000002, 0x00000002, 0x00000073, 0x00000003,
7637 0x00000000, 0x000000b4, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000008,
7638 0x70696b73, 0x00646570, 0x00000010, 0x00000004, 0x000000d8, 0x00000000, 0x00000000, 0x00000003,
7639 0x00000003, 0x00007376, 0x3f800000, 0x00000003, 0x00000000, 0x00000100, 0x00000000, 0x00000000,
7640 0x00000001, 0x00000001, 0x00000002, 0x00000061, 0x00000004, 0x00000010, 0x00000004, 0x00000000,
7641 0x00000000, 0x00000000, 0x00000002, 0x00000070, 0x00000006, 0x68636574, 0x00000030, 0x00000005,
7642 0x00000010, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000070, 0x00000006,
7643 0x68636574, 0x00000031, 0x00000005, 0x00000002, 0x00000005, 0x00000006, 0x00000004, 0x00000018,
7644 0x00000000, 0x00000000, 0x00000024, 0x00000040, 0x00000000, 0x00000001, 0x00000048, 0x00000044,
7645 0x00000074, 0x00000088, 0x00000000, 0x00000000, 0x00000094, 0x000000b0, 0x00000000, 0x00000000,
7646 0x000000c0, 0x000000d4, 0x00000000, 0x00000000, 0x00000128, 0x00000001, 0x00000001, 0x000000e4,
7647 0x000000e0, 0x00000120, 0x00000000, 0x00000001, 0x00000092, 0x00000000, 0x0000010c, 0x00000108,
7648 0x00000154, 0x00000000, 0x00000001, 0x0000014c, 0x00000000, 0x00000001, 0x00000092, 0x00000000,
7649 0x00000138, 0x00000134, 0x00000003, 0x00000002, 0x00000003, 0x00000074, 0xfffe0200, 0x0014fffe,
7650 0x42415443, 0x0000001c, 0x00000023, 0xfffe0200, 0x00000000, 0x00000000, 0x00000400, 0x0000001c,
7651 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461,
7652 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x0200001f, 0x80000000, 0x900f0000, 0x02000001,
7653 0xc00f0000, 0x90e40000, 0x0000ffff, 0x00000002, 0x00000000, 0x00000001, 0x00000000, 0x00000001,
7654 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x000000a4, 0xfffe0200, 0x0023fffe, 0x42415443,
7655 0x0000001c, 0x0000005f, 0xfffe0200, 0x00000001, 0x0000001c, 0x20000400, 0x00000058, 0x00000030,
7656 0x00040002, 0x00120001, 0x00000038, 0x00000048, 0x70696b73, 0x00646570, 0x00030000, 0x00010001,
7657 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x325f7376, 0x4d00305f,
7658 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970,
7659 0x30312072, 0xab00312e, 0x02000001, 0xc00f0000, 0xa0000004, 0x0000ffff, 0x00000000, 0x00000000,
7660 0xffffffff, 0x00000000, 0x00000001, 0x00000003, 0x00007376,
7661 };
7662
7663 if (!(device = create_device(&window)))
7664 return;
7665
7666 state_manager = calloc(1, sizeof(*state_manager));
7667 test_effect_state_manager_init(state_manager, device);
7668
7670 D3DPOOL_DEFAULT, (IDirect3DTexture9 **)&texture, NULL);
7671 ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
7672
7673 /* D3DXFX_NOT_CLONEABLE */
7674 hr = D3DXCreateEffect(device, effect_code, sizeof(effect_code),
7675 NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
7676 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7677
7678 technique = effect->lpVtbl->GetTechniqueByName(effect, "tech0");
7679 ok(!!technique, "Expected a technique.\n");
7680
7681 technique2 = effect->lpVtbl->GetCurrentTechnique(effect);
7682 ok(technique2 == technique, "Got unexpected technique %p.\n", technique2);
7683
7684 hr = effect->lpVtbl->SetTechnique(effect, "tech1");
7685 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7686
7687 hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
7688 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7689
7690 cloned = (void *)0xdeadbeef;
7691 hr = effect->lpVtbl->CloneEffect(effect, NULL, &cloned);
7692 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7693 ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7694
7695 hr = effect->lpVtbl->CloneEffect(effect, device, NULL);
7696 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7697
7698 cloned = (void *)0xdeadbeef;
7699 hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7700 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7701 ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7702
7703 effect->lpVtbl->Release(effect);
7704
7705 hr = D3DXCreateEffectEx(device, effect_code, sizeof(effect_code),
7706 NULL, NULL, "skipped", 0, NULL, &effect, NULL);
7707 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7708
7709 hr = effect->lpVtbl->SetStateManager(effect, &state_manager->ID3DXEffectStateManager_iface);
7710 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7711
7712 hr = effect->lpVtbl->SetTexture(effect, "tex", texture);
7713 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7714
7715 hr = effect->lpVtbl->SetFloat(effect, "f", 123.0f);
7716 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7717
7718 hr = effect->lpVtbl->SetString(effect, "s", "tiny silver hammers");
7719 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7720
7721 hr = effect->lpVtbl->SetFloat(effect, "f@a", 4.0f);
7722 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7723
7724 annotation = effect->lpVtbl->GetAnnotationByName(effect, "tech0", "a");
7725 ok(!!annotation, "Failed to get annotation.\n");
7726 hr = effect->lpVtbl->SetFloat(effect, annotation, 4.0f);
7727 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7728
7729 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "tex");
7730 ok(!!parameter, "Failed to get parameter.\n");
7731
7732 hr = effect->lpVtbl->GetVertexShader(effect, "vs", &vs);
7733 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7734
7735 ok(!effect->lpVtbl->IsParameterUsed(effect, "skipped", "tech1"),
7736 "Unexpected IsParameterUsed result.\n");
7737
7738 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
7739 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7740
7741 hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
7742 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7743
7744 cloned = (void *)0xdeadbeef;
7745 hr = effect->lpVtbl->CloneEffect(effect, NULL, &cloned);
7746 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7747 ok(cloned == (void *)0xdeadbeef, "Unexpected effect pointer.\n");
7748
7749 hr = effect->lpVtbl->CloneEffect(effect, device, NULL);
7750 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7751
7752 hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7753 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7754 ok(cloned != effect, "Expected new effect instance.\n");
7755
7756 hr = cloned->lpVtbl->GetStateManager(cloned, &ret_manager);
7757 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7758 ok(!ret_manager, "Unexpected state manager %p.\n", ret_manager);
7759
7760 hr = cloned->lpVtbl->GetTexture(cloned, "tex", &texture2);
7761 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7762 ok(texture2 == texture, "Expected the same texture.\n");
7764
7765 hr = cloned->lpVtbl->GetVertexShader(cloned, "vs", &vs2);
7766 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7767 ok(vs2 == vs, "Expected the same vertex shader.\n");
7769
7770 ok(!effect->lpVtbl->IsParameterUsed(effect, "skipped", "tech1"),
7771 "Unexpected IsParameterUsed result.\n");
7772
7773 f = 0.0f;
7774 hr = cloned->lpVtbl->GetFloat(cloned, "f", &f);
7775 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7776 ok(f == 123.0f, "Got float %.8e.\n", f);
7777
7778 hr = cloned->lpVtbl->GetString(cloned, "s", &string);
7779 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7780 ok(!strcmp(string, "tiny silver hammers"), "Got string %s.\n", debugstr_a(string));
7781
7782 f = 0.0f;
7783 hr = cloned->lpVtbl->GetFloat(cloned, "f@a", &f);
7784 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7785 ok(f == 4.0f, "Got float %.8e.\n", f);
7786
7787 annotation = cloned->lpVtbl->GetAnnotationByName(cloned, "tech0", "a");
7788 ok(!!annotation, "Failed to get annotation.\n");
7789 f = 0.0f;
7790 hr = cloned->lpVtbl->GetFloat(cloned, annotation, &f);
7791 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7792 ok(f == 4.0f, "Got float %.8e.\n", f);
7793
7794 parameter2 = cloned->lpVtbl->GetParameterByName(cloned, NULL, "tex");
7795 ok(!!parameter2, "Failed to get parameter.\n");
7796 ok(parameter2 != parameter, "Parameters should not match.\n");
7797
7798 hr = cloned->lpVtbl->BeginPass(cloned, 0);
7799 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7800
7801 technique = cloned->lpVtbl->GetTechniqueByName(cloned, "tech0");
7802 ok(!!technique, "Expected a technique.\n");
7803
7804 technique2 = cloned->lpVtbl->GetCurrentTechnique(cloned);
7805 ok(technique2 == technique, "Got unexpected technique %p.\n", technique2);
7806
7807 cloned->lpVtbl->Release(cloned);
7808
7809 /* Try with different device. */
7810 device2 = create_device(&window2);
7811
7812 hr = effect->lpVtbl->CloneEffect(effect, device2, &cloned);
7813 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7814 ok(cloned != effect, "Expected new effect instance.\n");
7815
7816 hr = cloned->lpVtbl->GetDevice(cloned, &device3);
7817 ok(hr == S_OK, "Failed to get effect device.\n");
7818 ok(device3 == device2, "Unexpected device instance.\n");
7819 IDirect3DDevice9_Release(device3);
7820
7821 hr = cloned->lpVtbl->GetTexture(cloned, "tex", &texture2);
7822 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7823 ok(!texture2, "Expected a NULL texture.\n");
7824
7825 hr = cloned->lpVtbl->GetVertexShader(cloned, "vs", &vs2);
7826 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7827 ok(vs2 != vs, "Expected a different vertex shader.\n");
7829
7830 f = 0.0f;
7831 hr = cloned->lpVtbl->GetFloat(cloned, "f", &f);
7832 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7833 ok(f == 123.0f, "Got float %.8e.\n", f);
7834
7835 hr = cloned->lpVtbl->GetString(cloned, "s", &string);
7836 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7837 ok(!strcmp(string, "tiny silver hammers"), "Got string %s.\n", debugstr_a(string));
7838
7839 f = 0.0f;
7840 hr = cloned->lpVtbl->GetFloat(cloned, "f@a", &f);
7841 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7842 ok(f == 4.0f, "Got float %.8e.\n", f);
7843
7844 annotation = cloned->lpVtbl->GetAnnotationByName(cloned, "tech0", "a");
7845 ok(!!annotation, "Failed to get annotation.\n");
7846 f = 0.0f;
7847 hr = cloned->lpVtbl->GetFloat(cloned, annotation, &f);
7848 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7849 ok(f == 4.0f, "Got float %.8e.\n", f);
7850
7851 parameter2 = cloned->lpVtbl->GetParameterByName(cloned, NULL, "tex");
7852 ok(!!parameter2, "Failed to get parameter.\n");
7853 ok(parameter2 != parameter, "Parameters should not match.\n");
7854
7855 hr = cloned->lpVtbl->BeginPass(cloned, 0);
7856 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7857
7858 technique = cloned->lpVtbl->GetTechniqueByName(cloned, "tech0");
7859 ok(!!technique, "Expected a technique.\n");
7860
7861 technique2 = cloned->lpVtbl->GetCurrentTechnique(cloned);
7862 ok(technique2 == technique, "Got unexpected technique %p.\n", technique2);
7863
7864 cloned->lpVtbl->Release(cloned);
7865
7866 hr = effect->lpVtbl->BeginPass(effect, 0);
7867 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7868
7869 hr = effect->lpVtbl->EndPass(effect);
7870 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7871
7872 hr = effect->lpVtbl->End(effect);
7873 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7874
7875 /* Test parameter blocks (we can't do this above since we can't record a
7876 * parameter block while started). */
7877
7878 hr = effect->lpVtbl->BeginParameterBlock(effect);
7879 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7880
7881 hr = effect->lpVtbl->SetFloat(effect, "f", 456.0f);
7882 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7883
7884 hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
7885 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7886 block = cloned->lpVtbl->EndParameterBlock(cloned);
7887 ok(!block, "Expected no active parameter block.\n");
7888
7889 cloned->lpVtbl->Release(cloned);
7890
7891 block = effect->lpVtbl->EndParameterBlock(effect);
7892 ok(!!block, "Expected an active parameter block.\n");
7893
7895 IDirect3DDevice9_Release(device2);
7896 DestroyWindow(window2);
7897 effect->lpVtbl->Release(effect);
7898 refcount = state_manager->ID3DXEffectStateManager_iface.lpVtbl->Release(
7899 &state_manager->ID3DXEffectStateManager_iface);
7900 ok(!refcount, "State manager was not properly freed, refcount %lu.\n", refcount);
7902 refcount = IDirect3DDevice9_Release(device);
7903 ok(!refcount, "Device has %lu references left.\n", refcount);
7905}
@ D3DFMT_X8R8G8B8
Definition: d3d8types.h:605
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1358
#define IDirect3DVertexShader9_Release(p)
Definition: d3d9.h:1051
#define IDirect3DBaseTexture9_Release(p)
Definition: d3d9.h:663
static const DWORD vs_2_0[]
Definition: asm.c:1726
#define annotation(x)
Definition: dispex.idl:19
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:6685
#define D3DXFX_NOT_CLONEABLE
Definition: d3dx9effect.h:27
GLdouble s
Definition: gl.h:2039
GLenum GLuint texture
Definition: glext.h:6295
GLfloat GLfloat p
Definition: glext.h:8902
#define debugstr_a
Definition: kernel32.h:31
char string[160]
Definition: util.h:11
static void test_effect_state_manager_init(struct test_manager *state_manager, IDirect3DDevice9 *device)
Definition: effect.c:6419
static vector_t * vs
Definition: server.c:146
#define calloc
Definition: rosglue.h:14
ID3DXEffectStateManager ID3DXEffectStateManager_iface
Definition: effect.c:6240
pass
Definition: typegen.h:25
static unsigned int block
Definition: xmlmemory.c:101

Referenced by START_TEST().

◆ test_effect_commitchanges()

static void test_effect_commitchanges ( IDirect3DDevice9 *  device)
static

Definition at line 5533 of file effect.c.

5534{
5535 static const struct
5536 {
5537 const char *param_name;
5539 }
5540 check_op_parameters[] =
5541 {
5557 };
5558 static const struct
5559 {
5560 const char *param_name;
5561 const unsigned int const_updated_mask[(ARRAY_SIZE(test_effect_preshader_fvect_v)
5563 }
5564 check_vconsts_parameters[] =
5565 {
5566 {"g_Selector", {0x00000000, 0x00000002}},
5567 {"g_Pos1", {0x80000000, 0x00000002}},
5568 {"g_Pos2", {0x00000000, 0x00000002}},
5569 {"m4x3column", {0x03800000, 0x00000000}},
5570 {"m3x4column", {0x000f0000, 0x00000000}},
5571 {"m4x3row", {0x0000f000, 0x00000000}},
5572 {"m3x4row", {0x00700000, 0x00000000}},
5573 {"ts1", {0x1c000000, 0x00000000}},
5574 {"ts2", {0x0000003f, 0x00000000}},
5575 {"arr1", {0x00000000, 0x00000001}},
5576 {"arr2", {0x60000000, 0x00000000}},
5577 {"ts3", {0x00000fc0, 0x00000000}},
5578 };
5579 static const struct
5580 {
5581 const char *param_name;
5582 const unsigned int const_updated_mask[(ARRAY_SIZE(test_effect_preshader_bconsts)
5584 }
5585 check_bconsts_parameters[] =
5586 {
5587 {"mb2x3row", {0x0000001f}},
5588 {"mb2x3column", {0x00000060}},
5589 };
5590 static const unsigned int const_no_update_mask[(ARRAY_SIZE(test_effect_preshader_fvect_v)
5592 static const D3DLIGHT9 light_filler = {D3DLIGHT_POINT};
5593
5595 ID3DXEffect *effect;
5596 HRESULT hr;
5598 unsigned int i, passes_count;
5599 union
5600 {
5601 DWORD dw;
5602 float f;
5603 } float_value;
5604 DWORD value;
5605 int ivect[4];
5606 D3DXVECTOR4 fvect;
5607 IDirect3DVertexShader9 *vshader;
5608 unsigned char buffer[256];
5609
5611 NULL, NULL, 0, NULL, &effect, NULL);
5612 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5613
5614 hr = effect->lpVtbl->GetDesc(effect, &desc);
5615 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5616 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
5617 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
5618 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
5619 ok(desc.Parameters == 34, "Unexpected value %u.\n", desc.Parameters);
5620
5621 param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5622 ok(!!param, "GetParameterByName failed.\n");
5623
5624 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5625 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5626
5628 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5629
5630 hr = effect->lpVtbl->BeginPass(effect, 0);
5631 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5632
5633 for (i = 0; i < ARRAY_SIZE(check_op_parameters); ++i)
5634 {
5635 unsigned int j;
5636
5637 winetest_push_context("Parameter %s", check_op_parameters[i].param_name);
5638 for (j = 0; j < 8; ++j)
5639 {
5640 winetest_push_context("Light %u", j);
5641 hr = IDirect3DDevice9_SetLight(device, j, &light_filler);
5642 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5644 }
5645 param = effect->lpVtbl->GetParameterByName(effect, NULL, check_op_parameters[i].param_name);
5646 ok(!!param, "Unexpected parameter %p.\n", param);
5647 hr = effect->lpVtbl->GetValue(effect, param, &fvect, sizeof(fvect));
5648 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5649 hr = effect->lpVtbl->SetValue(effect, param, &fvect, sizeof(fvect));
5650 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5651 hr = effect->lpVtbl->CommitChanges(effect);
5652 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5653
5654 test_effect_preshader_op_results(device, check_op_parameters[i].state_updated,
5655 check_op_parameters[i].param_name);
5657 }
5658
5659 for (i = 0; i < ARRAY_SIZE(check_vconsts_parameters); ++i)
5660 {
5661 winetest_push_context("Float constants, parameter %s", check_vconsts_parameters[i].param_name);
5663 param = effect->lpVtbl->GetParameterByName(effect, NULL, check_vconsts_parameters[i].param_name);
5664 ok(!!param, "Unexpected parameter %p.\n", param);
5665 hr = effect->lpVtbl->GetValue(effect, param, buffer, sizeof(buffer));
5666 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5667 hr = effect->lpVtbl->SetValue(effect, param, buffer, sizeof(buffer));
5668 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5669 hr = effect->lpVtbl->CommitChanges(effect);
5670 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5671
5672 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[i].const_updated_mask,
5673 check_vconsts_parameters[i].param_name);
5675 }
5676
5677 for (i = 0; i < ARRAY_SIZE(check_bconsts_parameters); ++i)
5678 {
5679 winetest_push_context("Bool constants, parameter %s", check_bconsts_parameters[i].param_name);
5681 param = effect->lpVtbl->GetParameterByName(effect, NULL, check_bconsts_parameters[i].param_name);
5682 ok(!!param, "GetParameterByName failed.\n");
5683 hr = effect->lpVtbl->GetValue(effect, param, buffer, sizeof(buffer));
5684 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5685 hr = effect->lpVtbl->SetValue(effect, param, buffer, sizeof(buffer));
5686 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5687 hr = effect->lpVtbl->CommitChanges(effect);
5688 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5689
5690 test_effect_preshader_compare_pbool_consts(device, check_bconsts_parameters[i].const_updated_mask,
5691 check_bconsts_parameters[i].param_name);
5693 }
5694
5696 param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Selector");
5697 ok(!!param, "Unexpected parameter %p.\n", param);
5698 fvect.x = fvect.y = fvect.z = fvect.w = 0.0f;
5699 hr = effect->lpVtbl->SetVectorArray(effect, param, &fvect, 1);
5700 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5701 hr = effect->lpVtbl->CommitChanges(effect);
5702 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5703 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[0].const_updated_mask,
5704 check_vconsts_parameters[0].param_name);
5705
5707 param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5708 ok(!!param, "GetParameterByName failed.\n");
5709 param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5710 ok(!!param, "GetParameterElement failed.\n");
5711 hr = effect->lpVtbl->SetFloat(effect, param, 92.0f);
5712 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5713 hr = effect->lpVtbl->CommitChanges(effect);
5714 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5715 test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5716 check_vconsts_parameters[10].param_name);
5717
5719 param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5720 ok(!!param, "GetParameterByName failed.\n");
5721 param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5722 ok(!!param, "GetParameterElement failed.\n");
5723 fvect.x = 93.0f;
5724 hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(fvect.x));
5725 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5726 hr = effect->lpVtbl->CommitChanges(effect);
5727 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5728 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[10].const_updated_mask,
5729 check_vconsts_parameters[10].param_name);
5730
5732 param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5733 ok(!!param, "GetParameterByName failed.\n");
5734 fvect.x = 92.0f;
5735 hr = effect->lpVtbl->SetFloatArray(effect, param, &fvect.x, 1);
5736 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5737 hr = effect->lpVtbl->CommitChanges(effect);
5738 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5739 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[10].const_updated_mask,
5740 check_vconsts_parameters[10].param_name);
5741
5743 param = effect->lpVtbl->GetParameterByName(effect, NULL, "arr2");
5744 ok(!!param, "GetParameterByName failed.\n");
5745 param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5746 ok(!!param, "GetParameterElement failed.\n");
5747 hr = effect->lpVtbl->SetInt(effect, param, 93);
5748 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5749 hr = effect->lpVtbl->CommitChanges(effect);
5750 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5751 test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5752 check_vconsts_parameters[10].param_name);
5753
5755 param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Pos1");
5756 ok(!!param, "GetParameterByName failed.\n");
5757 fvect.x = fvect.y = fvect.z = fvect.w = 0.0f;
5758 hr = effect->lpVtbl->SetVector(effect, param, &fvect);
5759 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5760 hr = effect->lpVtbl->CommitChanges(effect);
5761 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5762 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[1].const_updated_mask,
5763 check_vconsts_parameters[1].param_name);
5764
5766 param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts1");
5767 ok(!!param, "GetParameterByName failed.\n");
5768 param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5769 ok(!!param, "GetParameterByName failed.\n");
5770 param = effect->lpVtbl->GetParameterByName(effect, param, "fv");
5771 ok(!!param, "GetParameterByName failed.\n");
5772 fvect.x = 12;
5773 hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(float));
5774 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5775 hr = effect->lpVtbl->CommitChanges(effect);
5776 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5777 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[7].const_updated_mask,
5778 check_vconsts_parameters[7].param_name);
5779
5780 float_value.f = 9999.0f;
5782 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5784 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5786 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5788 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5790 param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts2");
5791 ok(!!param, "GetParameterByName failed.\n");
5792 param = effect->lpVtbl->GetParameterElement(effect, param, 0);
5793 ok(!!param, "GetParameterByName failed.\n");
5794 param = effect->lpVtbl->GetParameterByName(effect, param, "v1");
5795 ok(!!param, "GetParameterByName failed.\n");
5796 hr = effect->lpVtbl->GetValue(effect, param, &fvect, sizeof(float) * 3);
5797 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5798 hr = effect->lpVtbl->SetValue(effect, param, &fvect, sizeof(float) * 3);
5799 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5800 hr = effect->lpVtbl->CommitChanges(effect);
5801 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5803 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5804 ok(float_value.f == 0, "Unexpected fog density %.8e.\n", float_value.f);
5806 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5807 ok(float_value.f == 4.0f, "Unexpected fog start %.8e.\n", float_value.f);
5809 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5810 ok(float_value.f == 9999.0f, "Unexpected point scale A %.8e.\n", float_value.f);
5812 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5813 ok(float_value.f == 9999.0f, "Unexpected point scale B %.8e.\n", float_value.f);
5814 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[8].const_updated_mask,
5815 check_vconsts_parameters[8].param_name);
5816
5817 float_value.f = 9999.0f;
5819 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5821 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5823 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5825 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5827 param = effect->lpVtbl->GetParameterByName(effect, NULL, "ts3");
5828 ok(!!param, "GetParameterByName failed.\n");
5829 param = effect->lpVtbl->GetParameterByName(effect, param, "ts");
5830 ok(!!param, "GetParameterByName failed.\n");
5831 param = effect->lpVtbl->GetParameterElement(effect, param, 1);
5832 ok(!!param, "GetParameterByName failed.\n");
5833 param = effect->lpVtbl->GetParameterByName(effect, param, "fv");
5834 ok(!!param, "GetParameterByName failed.\n");
5835 hr = effect->lpVtbl->GetValue(effect, param, &fvect.x, sizeof(float));
5836 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5837 hr = effect->lpVtbl->SetValue(effect, param, &fvect.x, sizeof(float));
5838 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5839 hr = effect->lpVtbl->CommitChanges(effect);
5840 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5842 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5843 ok(float_value.f == 9999.0f, "Unexpected fog density %.8e.\n", float_value.f);
5845 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5846 ok(float_value.f == 9999.0f, "Unexpected fog start %.8e.\n", float_value.f);
5848 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5849 ok(float_value.f == 4.0f, "Unexpected point scale A %.8e.\n", float_value.f);
5851 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5852 ok(float_value.f == 12.0f, "Unexpected point scale B %.8e.\n", float_value.f);
5853 test_effect_preshader_compare_vconsts(device, check_vconsts_parameters[11].const_updated_mask,
5854 check_vconsts_parameters[11].param_name);
5855
5857 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5858 ok(value == 1, "Unexpected sampler 0 minfilter %lu.\n", value);
5860 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5861 todo_wine
5862 ok(value == 0, "Unexpected sampler 1 minfilter %lu.\n", value);
5864 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5865 ok(value == 3, "Unexpected sampler 2 minfilter %lu.\n", value);
5866
5867 param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5868 ok(!!param, "GetParameterByName failed.\n");
5869 ivect[0] = ivect[1] = ivect[2] = ivect[3] = 1;
5870 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5871 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5872
5873 for (i = 0; i < 3; ++i)
5874 {
5876 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5878 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5879 }
5880
5882 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5884 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5885
5887 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5889
5890 hr = effect->lpVtbl->CommitChanges(effect);
5891 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5892
5894 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5895 ok(!vshader, "Unexpected vshader %p.\n", vshader);
5896 test_effect_preshader_compare_vconsts(device, const_no_update_mask, "selector g_iVect");
5897
5899 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5900 ok(value == 0, "Unexpected sampler 0 minfilter %lu.\n", value);
5902 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5903 ok(value == 0, "Unexpected sampler 1 minfilter %lu.\n", value);
5904
5906 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5907 ok(value == 1, "Unexpected sampler 2 minfilter %lu.\n", value);
5909 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5910 ok(value == 0, "Unexpected sampler 2 minfilter %lu.\n", value);
5912 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5913 ok(value == 1, "Unexpected sampler 0 minfilter %lu.\n", value);
5915 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5916 ok(value == 0, "Unexpected sampler 0 minfilter %lu.\n", value);
5917
5918 ivect[3] = 2;
5919 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5920 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5921 ivect[3] = 1;
5922 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5923 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5924 hr = effect->lpVtbl->CommitChanges(effect);
5925 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5927 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5928 ok(!vshader, "Unexpected vshader %p.\n", vshader);
5929 test_effect_preshader_compare_vconsts(device, const_no_update_mask, "selector g_iVect");
5930 ivect[3] = 2;
5931 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5932 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5933 hr = effect->lpVtbl->CommitChanges(effect);
5934 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5936 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5937 ok(!!vshader, "Unexpected vshader %p.\n", vshader);
5940 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5941 ok(fvect.x == 0.0f && fvect.y == 0.0f && fvect.z == 0.0f && fvect.w == 0.0f,
5942 "Vertex shader float constants do not match.\n");
5944 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5945 test_effect_preshader_compare_vconsts(device, const_no_update_mask,
5946 "selector g_iVect");
5947 ivect[3] = 1;
5948 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5949 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5950 hr = effect->lpVtbl->CommitChanges(effect);
5951 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5953
5954 hr = effect->lpVtbl->EndPass(effect);
5955 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5956
5957 hr = effect->lpVtbl->End(effect);
5958 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5959
5960 effect->lpVtbl->Release(effect);
5961}
@ D3DRS_FOGDENSITY
Definition: d3d8types.h:751
@ D3DRS_FOGSTART
Definition: d3d8types.h:749
@ D3DRS_POINTSCALE_B
Definition: d3d8types.h:791
@ D3DRS_POINTSCALE_A
Definition: d3d8types.h:790
@ D3DLIGHT_POINT
Definition: d3d8types.h:656
#define IDirect3DDevice9_SetLight(p, a, b)
Definition: d3d9.h:1386
#define IDirect3DDevice9_GetVertexShader(p, a)
Definition: d3d9.h:1428
#define IDirect3DDevice9_SetRenderState(p, a, b)
Definition: d3d9.h:1392
#define IDirect3DDevice9_SetVertexShader(p, a)
Definition: d3d9.h:1427
#define IDirect3DDevice9_GetRenderState(p, a, b)
Definition: d3d9.h:1393
#define IDirect3DDevice9_GetVertexShaderConstantF(p, a, b, c)
Definition: d3d9.h:1430
#define IDirect3DDevice9_GetSamplerState(p, a, b, c)
Definition: d3d9.h:1403
#define IDirect3DDevice9_SetSamplerState(p, a, b, c)
Definition: d3d9.h:1404
@ D3DSAMP_MINFILTER
Definition: d3d9types.h:1238
@ D3DSAMP_MAGFILTER
Definition: d3d9types.h:1237
#define D3DVERTEXTEXTURESAMPLER2
Definition: d3d9types.h:204
#define D3DVERTEXTEXTURESAMPLER0
Definition: d3d9types.h:202
#define D3DVERTEXTEXTURESAMPLER1
Definition: d3d9types.h:203
GLfloat param
Definition: glext.h:5796
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
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
static const struct @1913 test_effect_preshader_op_expected[]
expected_state_update
Definition: effect.c:4500
#define test_effect_preshader_compare_pbool_consts(a, b, c)
Definition: effect.c:4652
#define TEST_EFFECT_BITMASK_BLOCK_SIZE
Definition: effect.c:4582
static const BOOL test_effect_preshader_bconsts[]
Definition: effect.c:4633
static void test_effect_preshader_clear_pbool_consts(IDirect3DDevice9 *device)
Definition: effect.c:4638
#define test_effect_preshader_compare_vconsts(a, b, c)
Definition: effect.c:4584
#define test_effect_preshader_op_results(a, b, c)
Definition: effect.c:4506
static void test_effect_clear_vconsts(IDirect3DDevice9 *device)
Definition: effect.c:3123
static const D3DXVECTOR4 test_effect_preshader_fvect_v[]
Definition: effect.c:4545
Definition: pdh_main.c:64

Referenced by START_TEST().

◆ test_effect_compilation_errors()

static void test_effect_compilation_errors ( IDirect3DDevice9 *  device)
static

Definition at line 2992 of file effect.c.

2993{
2994 ID3DXEffect *effect;
2995 ID3DXBuffer *compilation_errors;
2996 HRESULT hr;
2997
2998 /* Test binary effect */
2999 compilation_errors = (ID3DXBuffer*)0xdeadbeef;
3000 hr = D3DXCreateEffect(NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, &compilation_errors);
3001 ok(hr == D3DERR_INVALIDCALL, "D3DXCreateEffect failed, got %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
3002 ok(!compilation_errors, "Returned %p\n", compilation_errors);
3003
3004 compilation_errors = (ID3DXBuffer*)0xdeadbeef;
3006 sizeof(test_effect_variable_names_blob), NULL, NULL, 0, NULL, &effect, &compilation_errors);
3007 ok(hr == D3D_OK, "D3DXCreateEffect failed, got %#lx, expected %#lx\n", hr, D3D_OK);
3008 ok(!compilation_errors, "Returned %p\n", compilation_errors);
3009 effect->lpVtbl->Release(effect);
3010}
static const DWORD test_effect_variable_names_blob[]
Definition: effect.c:2714

Referenced by START_TEST().

◆ test_effect_find_next_valid_technique()

static void test_effect_find_next_valid_technique ( void  )
static

Definition at line 8346 of file effect.c.

8347{
8348 D3DPRESENT_PARAMETERS present_parameters = {0};
8352 D3DXHANDLE tech, tech2;
8353 ID3DXEffect *effect;
8354 IDirect3D9 *d3d;
8355 ULONG refcount;
8356 HWND window;
8357 HRESULT hr;
8358
8359 if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
8360 640, 480, NULL, NULL, NULL, NULL)))
8361 {
8362 skip("Failed to create window.\n");
8363 return;
8364 }
8365 if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
8366 {
8367 skip("Failed to create IDirect3D9 object.\n");
8369 return;
8370 }
8371 present_parameters.Windowed = TRUE;
8372 present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
8374 D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
8375 if (FAILED(hr))
8376 {
8377 skip("Failed to create IDirect3DDevice9 object, hr %#lx.\n", hr);
8378 IDirect3D9_Release(d3d);
8380 return;
8381 }
8382
8384 NULL, NULL, NULL, 0, NULL, &effect, NULL);
8385 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8386
8387 hr = effect->lpVtbl->GetDesc(effect, &effect_desc);
8388 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
8389 ok(!strcmp(effect_desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", effect_desc.Creator);
8390 ok(!effect_desc.Functions, "Unexpected value %u.\n", effect_desc.Functions);
8391 ok(effect_desc.Techniques == 2, "Unexpected value %u.\n", effect_desc.Techniques);
8392 ok(!effect_desc.Parameters, "Unexpected value %u.\n", effect_desc.Parameters);
8393
8394 hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
8395 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8396 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8397 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8398 ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
8399
8400 hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
8401 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8402 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8403 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8404 ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
8405
8406 tech2 = tech;
8407 hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech2);
8408 ok(hr == S_FALSE, "Got result %#lx.\n", hr);
8409 ok(!tech2, "Unexpected technique handle %p.\n", tech2);
8410 /* Test GetTechniqueDesc() with a NULL handle. */
8411 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech2, &desc);
8412 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8413 ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
8414
8415 effect->lpVtbl->Release(effect);
8416
8418 NULL, NULL, NULL, 0, NULL, &effect, NULL);
8419 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8420
8421 hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
8422 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8423 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8424 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8425 ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
8426
8427 hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech2);
8428 ok(hr == S_FALSE, "Got result %#lx.\n", hr);
8429 ok(!tech2, "Unexpected technique handle %p.\n", tech2);
8430 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech2, &desc);
8431 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8432 ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
8433
8434 hr = effect->lpVtbl->SetInt(effect, "i", 1);
8435 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8436
8437 tech = (D3DXHANDLE)0xdeadbeef;
8438 hr = effect->lpVtbl->FindNextValidTechnique(effect, NULL, &tech);
8439 ok(hr == S_FALSE, "Got result %#lx.\n", hr);
8440 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8441 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8442 ok(!strcmp(desc.Name, "tech0"), "Got unexpected technique %s.\n", desc.Name);
8443
8444 hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
8445 ok(hr == S_FALSE, "Got result %#lx.\n", hr);
8446
8447 hr = effect->lpVtbl->SetInt(effect, "i", 0);
8448 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8449
8450 hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech);
8451 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8452 hr = effect->lpVtbl->GetTechniqueDesc(effect, tech, &desc);
8453 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8454 ok(!strcmp(desc.Name, "tech1"), "Got unexpected technique %s.\n", desc.Name);
8455
8456 hr = effect->lpVtbl->FindNextValidTechnique(effect, tech, &tech2);
8457 ok(hr == S_FALSE, "Got result %#lx.\n", hr);
8458 ok(!tech2, "Unexpected technique handle %p.\n", tech2);
8459
8460 hr = effect->lpVtbl->FindNextValidTechnique(effect, "nope", &tech);
8461 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
8462
8463 effect->lpVtbl->Release(effect);
8464
8465 refcount = IDirect3DDevice9_Release(device);
8466 ok(!refcount, "Device has %lu references left.\n", refcount);
8467 IDirect3D9_Release(d3d);
8469}
static const DWORD test_effect_unsupported_shader_blob[]
Definition: effect.c:7363
static const DWORD test_two_techniques_blob[]
Definition: effect.c:8332
#define S_FALSE
Definition: winerror.h:3451

Referenced by START_TEST().

◆ test_effect_get_pass_desc()

static void test_effect_get_pass_desc ( IDirect3DDevice9 *  device)
static

Definition at line 7088 of file effect.c.

7089{
7090 unsigned int passes_count;
7091 ID3DXEffect *effect;
7093 D3DXVECTOR4 fvect;
7095 HRESULT hr;
7096
7098 NULL, NULL, 0, NULL, &effect, NULL);
7099 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7100
7101 pass = effect->lpVtbl->GetPass(effect, "tech0", 1);
7102 ok(!!pass, "GetPass() failed.\n");
7103
7104 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7105 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7106 test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 2, FALSE);
7107
7108 fvect.x = fvect.y = fvect.w = 0.0f;
7109 fvect.z = 0.0f;
7110 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
7111 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7112
7113 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7114 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7115 ok(!desc.pPixelShaderFunction, "Unexpected non null desc.pPixelShaderFunction.\n");
7116
7117 test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 0, FALSE);
7118
7119 fvect.z = 3.0f;
7120 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
7121 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7122
7123 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7124 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7125 ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
7126
7127 /* Repeating call to confirm GetPassDesc() returns same error on the second call,
7128 * as it is not the case sometimes for BeginPass() with out of bound access. */
7129 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7130 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7131 ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
7132
7133 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
7134 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7135
7136 hr = effect->lpVtbl->BeginPass(effect, 1);
7137 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7138
7139 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7140 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7141
7142 test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 0, FALSE);
7143
7144 fvect.z = 2.0f;
7145 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
7146 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7147 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7148 test_effect_preshader_compare_shader_bytecode(desc.pVertexShaderFunction, 0, 2, FALSE);
7149
7150 effect->lpVtbl->Release(effect);
7151
7153 NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
7154 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7155
7156 pass = effect->lpVtbl->GetPass(effect, "tech0", 1);
7157 ok(!!pass, "GetPass() failed.\n");
7158
7159 /* Calling GetPassDesc() on a D3DXFX_NOT_CLONEABLE effect is apparently
7160 * not safe on Windows: the following Release() would crash with a
7161 * STATUS_ACCESS_VIOLATION exception on the GitLab CI instance. */
7162 if (0)
7163 {
7164 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7165 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7166
7167 ok(!desc.pVertexShaderFunction, "Unexpected non null desc.pVertexShaderFunction.\n");
7168 ok(!desc.pPixelShaderFunction, "Unexpected non null desc.pPixelShaderFunction.\n");
7169 }
7170
7171 effect->lpVtbl->Release(effect);
7172}
#define test_effect_preshader_compare_shader_bytecode(a, b, c, d)
Definition: effect.c:4402

Referenced by START_TEST().

◆ test_effect_isparameterused()

static void test_effect_isparameterused ( IDirect3DDevice9 *  device)
static

Definition at line 5306 of file effect.c.

5307{
5308 static const struct
5309 {
5310 const char *name;
5312 }
5313 check_parameters[] =
5314 {
5315 {"g_Pos1", TRUE},
5316 {"g_Pos2", TRUE},
5317 {"g_Selector", TRUE},
5318 {"opvect1", TRUE},
5319 {"opvect2", TRUE},
5320 {"opvect3", TRUE},
5321 {"arr2", TRUE},
5322 {"vs_arr", TRUE},
5323 {"g_iVect", TRUE},
5324 {"vect_sampler", TRUE},
5325 {"tex1", TRUE},
5326 {"tex2", FALSE},
5327 {"sampler1", TRUE},
5328 {"ts1", TRUE},
5329 {"ts2", TRUE},
5330 {"ts3", TRUE},
5331 };
5332 ID3DXEffect *effect, *effect2;
5334 HRESULT hr;
5335 D3DXHANDLE tech;
5336 unsigned int i;
5337
5339 NULL, NULL, 0, NULL, &effect, NULL);
5340 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5341
5342 hr = effect->lpVtbl->GetDesc(effect, &desc);
5343 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5344 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
5345 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
5346 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
5347 ok(desc.Parameters == 34, "Unexpected value %u.\n", desc.Parameters);
5348
5349 tech = effect->lpVtbl->GetTechniqueByName(effect, "tech0");
5350 ok(!!tech, "GetTechniqueByName failed.\n");
5351
5352 for (i = 0; i < ARRAY_SIZE(check_parameters); ++i)
5353 test_isparameterused_param_with_children(effect, NULL, tech, check_parameters[i].name,
5354 check_parameters[i].expected_result);
5355
5357 NULL, NULL, 0, NULL, &effect2, NULL);
5358 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5359
5360 for (i = 0; i < ARRAY_SIZE(check_parameters); ++i)
5361 test_isparameterused_param_with_children(effect, effect2, tech, check_parameters[i].name,
5362 check_parameters[i].expected_result);
5363
5364 effect2->lpVtbl->Release(effect2);
5365
5367 NULL, NULL, 0, NULL, &effect2, NULL);
5368 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5369
5370 test_isparameterused_param_with_children(effect, effect2, tech, "sampler1", TRUE);
5371 effect2->lpVtbl->Release(effect2);
5372
5373 effect->lpVtbl->Release(effect);
5374}
static const DWORD test_effect_states_effect_blob[]
Definition: effect.c:3060
#define test_isparameterused_param_with_children(...)
Definition: effect.c:5284
const WCHAR * expected_result
Definition: mimeole.c:1441

Referenced by START_TEST().

◆ test_effect_large_address_aware_flag()

static void test_effect_large_address_aware_flag ( IDirect3DDevice9 *  device)
static

Definition at line 7055 of file effect.c.

7056{
7057 ID3DXEffect *effect;
7059 static int expected_ivect[4] = {28, 29, 30, 31};
7060 int ivect[4];
7061 HRESULT hr;
7062
7065 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7066
7067 param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
7068 ok(!!param, "GetParameterByName failed.\n");
7069
7070 hr = effect->lpVtbl->SetValue(effect, param, expected_ivect, sizeof(expected_ivect));
7071 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7072
7073 hr = effect->lpVtbl->GetValue(effect, param, ivect, sizeof(ivect));
7074 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7075
7076 ok(!memcmp(ivect, expected_ivect, sizeof(expected_ivect)), "Vector value mismatch.\n");
7077
7078 if (0)
7079 {
7080 /* Native d3dx crashes in GetValue(). */
7081 hr = effect->lpVtbl->GetValue(effect, "g_iVect", ivect, sizeof(ivect));
7082 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7083 }
7084
7085 effect->lpVtbl->Release(effect);
7086}
#define D3DXFX_LARGEADDRESSAWARE
Definition: d3dx9effect.h:28

Referenced by START_TEST().

◆ test_effect_null_shader()

static void test_effect_null_shader ( void  )
static

Definition at line 7525 of file effect.c.

7526{
7528 ID3DXEffect *effect;
7531 ULONG refcount;
7532 HWND window;
7533 HRESULT hr;
7534
7535 /* Creating a fresh device because the existing device can have invalid
7536 * render states from previous tests. If IDirect3DDevice9_ValidateDevice()
7537 * returns certain error codes, native ValidateTechnique() fails. */
7538 if (!(device = create_device(&window)))
7539 return;
7540
7542 sizeof(test_effect_null_shader_blob), NULL, NULL, NULL, 0, NULL, &effect, NULL);
7543 ok(hr == D3D_OK, "Failed to create effect, hr %#lx.\n", hr);
7544
7545 pass = effect->lpVtbl->GetPass(effect, "tech0", 0);
7546 ok(!!pass, "GetPass() failed.\n");
7547 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7548 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7549 ok(!desc.pVertexShaderFunction, "Got non NULL vertex function.\n");
7550
7551 pass = effect->lpVtbl->GetPass(effect, "tech1", 0);
7552 ok(!!pass, "GetPass() failed.\n");
7553 hr = effect->lpVtbl->GetPassDesc(effect, pass, &desc);
7554 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7555 ok(!desc.pVertexShaderFunction, "Got non NULL vertex function.\n");
7556
7557 hr = effect->lpVtbl->ValidateTechnique(effect, "tech0");
7558 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7559 hr = effect->lpVtbl->SetInt(effect, "i", 0);
7560 ok(hr == D3D_OK, "Failed to set parameter, hr %#lx.\n", hr);
7561 hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7562 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7563 hr = effect->lpVtbl->SetInt(effect, "i", 1);
7564 ok(hr == D3D_OK, "Failed to set parameter, hr %#lx.\n", hr);
7565 hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7566 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7567
7568 hr = effect->lpVtbl->SetInt(effect, "i", 2);
7569 ok(hr == D3D_OK, "Failed to set parameter, hr %#lx.\n", hr);
7570 hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7571 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7572
7573 effect->lpVtbl->Release(effect);
7574
7575 refcount = IDirect3DDevice9_Release(device);
7576 ok(!refcount, "Device has %lu references left.\n", refcount);
7578}
static const DWORD test_effect_null_shader_blob[]
Definition: effect.c:7502

Referenced by START_TEST().

◆ test_effect_out_of_bounds_selector()

static void test_effect_out_of_bounds_selector ( IDirect3DDevice9 *  device)
static

Definition at line 5376 of file effect.c.

5377{
5379 ID3DXEffect *effect;
5380 HRESULT hr;
5382 int ivect[4];
5383 unsigned int passes_count;
5384 IDirect3DVertexShader9 *vshader;
5385
5387 NULL, NULL, 0, NULL, &effect, NULL);
5388
5389 hr = effect->lpVtbl->GetDesc(effect, &desc);
5390 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5391 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
5392 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
5393 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
5394 ok(desc.Parameters == 34, "Unexpected value %u.\n", desc.Parameters);
5395
5396 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5397 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5398
5399 ivect[0] = ivect[1] = ivect[3] = 1;
5400
5401 param = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
5402 ok(!!param, "GetParameterByName failed.\n");
5403 ivect[2] = 3;
5404 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5405 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5406
5407 hr = effect->lpVtbl->BeginPass(effect, 0);
5408 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5409 hr = effect->lpVtbl->EndPass(effect);
5410 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5411
5413 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5414
5415 hr = effect->lpVtbl->BeginPass(effect, 1);
5416 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
5417
5418 /* Second try reports success and selects array element used previously.
5419 * Probably array index is not recomputed and previous index value is used. */
5420 hr = effect->lpVtbl->BeginPass(effect, 1);
5421 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5423
5424 /* Confirm that array element selected is the previous good one and does not depend
5425 * on computed (out of bound) index value. */
5426 ivect[2] = 1;
5427 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5428 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5430 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5431 hr = effect->lpVtbl->CommitChanges(effect);
5432 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5434 hr = effect->lpVtbl->EndPass(effect);
5435 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5436 ivect[2] = 3;
5437 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5438 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5440 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5441 hr = effect->lpVtbl->BeginPass(effect, 1);
5442 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
5443 hr = effect->lpVtbl->BeginPass(effect, 1);
5444 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5446
5447 /* End and begin effect again to ensure it will not trigger array
5448 * index recompute and error return from BeginPass. */
5449 hr = effect->lpVtbl->EndPass(effect);
5450 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5451 hr = effect->lpVtbl->End(effect);
5452 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5453 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5454 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5455 hr = effect->lpVtbl->BeginPass(effect, 1);
5456 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5458 hr = effect->lpVtbl->EndPass(effect);
5459 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5460
5461
5463 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5464
5465 ivect[2] = -2;
5466 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5467 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5468
5469 hr = effect->lpVtbl->BeginPass(effect, 1);
5470 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
5471
5473 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5474 ok(!vshader, "Got non NULL vshader.\n");
5475
5476 hr = effect->lpVtbl->BeginPass(effect, 1);
5477 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5478
5480
5481 hr = effect->lpVtbl->EndPass(effect);
5482 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5483
5484 ivect[2] = -1;
5485 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5486 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5487
5488 hr = effect->lpVtbl->BeginPass(effect, 1);
5489 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5490
5492
5494 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5495
5496 ivect[2] = 3;
5497 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5498 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5499 hr = effect->lpVtbl->CommitChanges(effect);
5500 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5501
5503 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5504 ok(!vshader, "Got non NULL vshader.\n");
5505
5506 ivect[2] = -1;
5507 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5508 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5509 hr = effect->lpVtbl->CommitChanges(effect);
5510 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5511
5513 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5514 ok(!vshader, "Got non NULL vshader.\n");
5515
5516 ivect[2] = 1;
5517 hr = effect->lpVtbl->SetValue(effect, param, ivect, sizeof(ivect));
5518 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5519 hr = effect->lpVtbl->CommitChanges(effect);
5520 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5521
5523
5524 hr = effect->lpVtbl->EndPass(effect);
5525 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5526
5527 hr = effect->lpVtbl->End(effect);
5528 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
5529
5530 effect->lpVtbl->Release(effect);
5531}
#define test_effect_preshader_compare_shader(a, b, c)
Definition: effect.c:4429

Referenced by START_TEST().

◆ test_effect_parameter_block()

static void test_effect_parameter_block ( void  )
static

Definition at line 8471 of file effect.c.

8472{
8473 static const D3DXMATRIX test_mat =
8474 {{{
8475 -11.0f, -12.0f, 0.0f, 0.0f,
8476 -21.0f, -22.0f, 0.0f, 0.0f,
8477 -31.0f, -32.0f, 0.0f, 0.0f,
8478 }}};
8479 static const D3DXMATRIX effect_orig_mat =
8480 {{{
8481 11.0f, 12.0f, 0.0f, 0.0f,
8482 21.0f, 22.0f, 0.0f, 0.0f,
8483 31.0f, 32.0f, 0.0f, 0.0f,
8484 }}};
8485 D3DPRESENT_PARAMETERS present_parameters = {0};
8486 static const float float_array_zero[4];
8487 IDirect3DTexture9 *texture, *tex_test;
8489 ID3DXEffect *effect, *effect2;
8490 D3DXMATRIX mat, mat_arr[2];
8493 ID3DXEffectPool *pool;
8494 float float_array[4];
8495 float float_value;
8496 IDirect3D9 *d3d;
8497 ULONG refcount;
8498 HWND window;
8499 HRESULT hr;
8500
8501 static const DWORD annotation_code[] =
8502 {
8503#if 0
8504 float f <float a = 1.0;>;
8505
8506 float4 vs_main(float4 pos : POSITION) : POSITION
8507 {
8508 return pos;
8509 }
8510
8511 technique tech0
8512 {
8513 pass p
8514 {
8515 VertexShader = compile vs_2_0 vs_main();
8516 }
8517 }
8518#endif
8519 0xfeff0901, 0x00000080, 0x00000000, 0x00000003, 0x00000000, 0x0000004c, 0x00000000, 0x00000000,
8520 0x00000001, 0x00000001, 0x00000000, 0x3f800000, 0x00000003, 0x00000000, 0x00000044, 0x00000000,
8521 0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x00000061, 0x00000002, 0x00000066, 0x00000001,
8522 0x00000010, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000070, 0x00000006,
8523 0x68636574, 0x00000030, 0x00000001, 0x00000001, 0x00000002, 0x00000002, 0x00000004, 0x00000020,
8524 0x00000000, 0x00000001, 0x00000028, 0x00000024, 0x00000074, 0x00000000, 0x00000001, 0x0000006c,
8525 0x00000000, 0x00000001, 0x00000092, 0x00000000, 0x00000058, 0x00000054, 0x00000000, 0x00000001,
8526 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000074, 0xfffe0200, 0x0014fffe,
8527 0x42415443, 0x0000001c, 0x00000023, 0xfffe0200, 0x00000000, 0x00000000, 0x20000400, 0x0000001c,
8528 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461,
8529 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x0200001f, 0x80000000, 0x900f0000, 0x02000001,
8530 0xc00f0000, 0x90e40000, 0x0000ffff,
8531 };
8532
8533 if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
8534 640, 480, NULL, NULL, NULL, NULL)))
8535 {
8536 skip("Failed to create window.\n");
8537 return;
8538 }
8539 if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
8540 {
8541 skip("Failed to create IDirect3D9 object.\n");
8543 return;
8544 }
8545 present_parameters.Windowed = TRUE;
8546 present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
8548 D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
8549 if (FAILED(hr))
8550 {
8551 skip("Failed to create IDirect3DDevice9 object, hr %#lx.\n", hr);
8552 IDirect3D9_Release(d3d);
8554 return;
8555 }
8556
8558 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8559
8561 NULL, NULL, 0, pool, &effect, NULL);
8562 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8564 NULL, NULL, 0, pool, &effect2, NULL);
8565 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8566
8567 hr = effect->lpVtbl->BeginParameterBlock(effect);
8568 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8569 hr = effect->lpVtbl->BeginParameterBlock(effect);
8570 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
8571 block = effect->lpVtbl->EndParameterBlock(effect);
8572 ok(!!block, "Got unexpected block %p.\n", block);
8573 handle = effect->lpVtbl->EndParameterBlock(effect);
8574 ok(!handle, "Got unexpected handle %p.\n", handle);
8575
8576 /* Block doesn't hold effect reference. */
8577 effect->lpVtbl->AddRef(effect);
8578 refcount = effect->lpVtbl->Release(effect);
8579 ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
8580
8581 hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8582 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
8583 hr = effect->lpVtbl->DeleteParameterBlock(effect, block);
8584 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8585
8586 hr = effect->lpVtbl->BeginParameterBlock(effect);
8587 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8588 hr = effect->lpVtbl->SetFloat(effect, "vec3[0]", 1001.0f);
8589 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
8590 hr = effect->lpVtbl->SetFloat(effect, "arr1[0]", 91.0f);
8591 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8592 block = effect->lpVtbl->EndParameterBlock(effect);
8593 ok(!!block, "Got unexpected block %p.\n", block);
8594 hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8595 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8596
8597 hr = effect->lpVtbl->DeleteParameterBlock(effect2, block);
8598 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
8599 hr = effect->lpVtbl->DeleteParameterBlock(effect, block);
8600 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8601
8602 hr = effect->lpVtbl->ApplyParameterBlock(effect, NULL);
8603 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
8604 hr = effect->lpVtbl->ApplyParameterBlock(effect, "parameter_block");
8605 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
8606
8608 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK).\n", hr);
8609
8610 hr = effect->lpVtbl->BeginParameterBlock(effect);
8611 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8612
8613 /* Effect parameters are not updated during recording. */
8614 hr = effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)texture);
8615 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8616
8617 hr = effect->lpVtbl->GetTexture(effect, "tex1", (IDirect3DBaseTexture9 **)&tex_test);
8618 ok(hr == D3D_OK && !tex_test, "Got unexpected hr %#lx, tex_test %p.\n", hr, tex_test);
8619
8620 /* Child parameters and array members are recorded separately (the whole
8621 * parameter is not updated when parameter block is applied). */
8622 hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 92.0f);
8623 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8624 hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 28.0f);
8625 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8626 hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
8627 ok(hr == D3D_OK && float_value == 12.0, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8628
8629 float_array[0] = -29.0f;
8630 hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array, 1);
8631 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8632 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 1);
8633 ok(hr == D3D_OK && float_array[0] == 13.0, "Got unexpected hr %#lx, float_array[0] %g.\n",
8634 hr, float_array[0]);
8635
8636 memset(&mat, 0, sizeof(mat));
8637 hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &test_mat);
8638 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8639 hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
8640 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8641 ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n");
8642 handle = effect->lpVtbl->GetParameterByName(effect, NULL, "m3x2row");
8643 ok(!!handle, "Failed to find a parameter.\n");
8644 hr = effect->lpVtbl->GetParameterDesc(effect, handle, &desc);
8645 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8646 ok(desc.Class == D3DXPC_MATRIX_ROWS, "Unexpected class %u.\n", desc.Class);
8647
8648 hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &test_mat);
8649 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8650 hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
8651 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8652 ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n");
8653 handle = effect->lpVtbl->GetParameterByName(effect, NULL, "m3x2column");
8654 ok(!!handle, "Failed to find a parameter.\n");
8655 hr = effect->lpVtbl->GetParameterDesc(effect, handle, &desc);
8656 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8657 ok(desc.Class == D3DXPC_MATRIX_ROWS, "Unexpected class %u.\n", desc.Class);
8658
8659 /* Setting shared parameter through effect2 is not recorded to effect
8660 * parameter block. */
8661 hr = effect2->lpVtbl->SetFloat(effect2, "arr2[1]", -1.0f);
8662 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8663 hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
8664 ok(float_value == -1.0f, "Unexpected value %g.\n", float_value);
8665
8668 ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
8669
8670 block = effect->lpVtbl->EndParameterBlock(effect);
8671 ok(!!block, "Got unexpected block %p.\n", block);
8672
8675 ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
8676
8677 hr = effect->lpVtbl->DeleteParameterBlock(effect2, block);
8678 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
8679
8682 ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
8683
8684 hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f);
8685 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8686 hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f);
8687 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8688 hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3);
8689 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8690 hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f);
8691 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8692 hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4);
8693 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8694 memset(&mat, 0, sizeof(mat));
8695 hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &mat);
8696 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8697 hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &mat);
8698 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8699
8700 hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8701 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8702
8705 ok(refcount == 3, "Got unexpected refcount %lu.\n", refcount);
8706
8707 hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value);
8708 ok(hr == D3D_OK && float_value == 92.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8709 hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
8710 ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8711
8712 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3);
8713 ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)),
8714 "Got unexpected hr %#lx, ts1[0].v1 (%g, %g, %g).\n", hr,
8715 float_array[0], float_array[1], float_array[2]);
8716
8717 hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
8718 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8719 ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
8720 hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
8721 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8722 ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
8723
8724 hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
8725 ok(hr == D3D_OK && float_value == 28.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8726
8727 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4);
8728 ok(hr == D3D_OK && float_array[0] == -29.0f
8729 && !memcmp(float_array + 1, float_array_zero, 3 * sizeof(*float_array)),
8730 "Got unexpected hr %#lx, ts1[0].v2 (%g, %g, %g, %g).\n", hr,
8731 float_array[0], float_array[1], float_array[2], float_array[3]);
8732
8733 /* Test applying a parameter block while recording a new one. */
8734 hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f);
8735 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8736 hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f);
8737 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8738 hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3);
8739 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8740 hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f);
8741 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8742 hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4);
8743 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8744 memset(&mat, 0, sizeof(mat));
8745 hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &effect_orig_mat);
8746 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8747 hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &effect_orig_mat);
8748 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8749
8750 hr = effect->lpVtbl->BeginParameterBlock(effect);
8751 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8752 hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8753 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8754
8755 hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value);
8756 ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8757 hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
8758 ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8759
8760 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3);
8761 ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)),
8762 "Got unexpected hr %#lx, ts1[0].v1 (%g, %g, %g).\n", hr,
8763 float_array[0], float_array[1], float_array[2]);
8764
8765 hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
8766 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8767 ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n");
8768 hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
8769 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8770 ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n");
8771
8772 hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
8773 ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8774
8775 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4);
8776 ok(hr == D3D_OK && float_array[0] == 0.0f
8777 && !memcmp(float_array + 1, float_array_zero, 3 * sizeof(*float_array)),
8778 "Got unexpected hr %#lx, ts1[0].v2 (%g, %g, %g, %g).\n", hr,
8779 float_array[0], float_array[1], float_array[2], float_array[3]);
8780
8781 block2 = effect->lpVtbl->EndParameterBlock(effect);
8782 ok(!!block2, "Got unexpected block %p.\n", block2);
8783
8784 hr = effect->lpVtbl->ApplyParameterBlock(effect, block2);
8785 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8786
8787 hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value);
8788 ok(hr == D3D_OK && float_value == 92.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8789 hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
8790 ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8791
8792 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3);
8793 ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)),
8794 "Got unexpected hr %#lx, ts1[0].v1 (%g, %g, %g).\n", hr,
8795 float_array[0], float_array[1], float_array[2]);
8796
8797 hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
8798 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8799 ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
8800 hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
8801 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8802 ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
8803
8804 hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
8805 ok(hr == D3D_OK && float_value == 28.0f, "Got unexpected hr %#lx, float_value %g.\n", hr, float_value);
8806
8807 hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4);
8808 ok(hr == D3D_OK && float_array[0] == -29.0f
8809 && !memcmp(float_array + 1, float_array_zero, 3 * sizeof(*float_array)),
8810 "Got unexpected hr %#lx, ts1[0].v2 (%g, %g, %g, %g).\n", hr,
8811 float_array[0], float_array[1], float_array[2], float_array[3]);
8812
8813 hr = effect->lpVtbl->DeleteParameterBlock(effect, block);
8814 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8815 hr = effect->lpVtbl->DeleteParameterBlock(effect, block2);
8816 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8817
8818 hr = effect->lpVtbl->SetTexture(effect, "tex1", NULL);
8819 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8821 ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
8822
8823 refcount = effect->lpVtbl->Release(effect);
8824 ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
8825
8826 refcount = effect2->lpVtbl->Release(effect2);
8827 ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
8828
8829 refcount = pool->lpVtbl->Release(pool);
8830 ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
8831
8833 NULL, NULL, 0, NULL, &effect, NULL);
8834 hr = effect->lpVtbl->BeginParameterBlock(effect);
8835 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8836 mat_arr[0] = mat_arr[1] = test_mat;
8837 hr = effect->lpVtbl->SetMatrixArray(effect, "f33_2", mat_arr, 2);
8838 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8839 block = effect->lpVtbl->EndParameterBlock(effect);
8840 ok(!!block, "Got unexpected block %p.\n", block);
8841
8842 memset(mat_arr, 0, sizeof(mat_arr));
8843 hr = effect->lpVtbl->SetMatrixArray(effect, "f33_2", mat_arr, 2);
8844 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8845 hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8846 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8847
8848 hr = effect->lpVtbl->GetMatrixArray(effect, "f33_2", mat_arr, 2);
8849 ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
8850 ok(!memcmp(&mat_arr[0], &test_mat, sizeof(test_mat))
8851 && !memcmp(&mat_arr[1], &test_mat, sizeof(test_mat)), "Got unexpected matrix array.\n");
8852
8853 refcount = effect->lpVtbl->Release(effect);
8854 ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
8855
8856 hr = D3DXCreateEffect(device, annotation_code, sizeof(annotation_code),
8857 NULL, NULL, 0, NULL, &effect, NULL);
8858 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8859
8860 hr = effect->lpVtbl->GetFloat(effect, "f@a", &float_value);
8861 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8862 ok(float_value == 1.0f, "Got float %.8e.\n", float_value);
8863 hr = effect->lpVtbl->SetFloat(effect, "f@a", 2.0f);
8864 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8865 hr = effect->lpVtbl->GetFloat(effect, "f@a", &float_value);
8866 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8867 ok(float_value == 2.0f, "Got float %.8e.\n", float_value);
8868
8869 hr = effect->lpVtbl->BeginParameterBlock(effect);
8870 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8871 hr = effect->lpVtbl->SetFloat(effect, "f@a", 3.0f);
8872 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8873 hr = effect->lpVtbl->GetFloat(effect, "f@a", &float_value);
8874 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8875 ok(float_value == 2.0f, "Got float %.8e.\n", float_value);
8876 block = effect->lpVtbl->EndParameterBlock(effect);
8877 ok(!!block, "Got unexpected block %p.\n", block);
8878 hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
8879 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8880 hr = effect->lpVtbl->GetFloat(effect, "f@a", &float_value);
8881 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
8882 ok(float_value == 3.0f, "Got float %.8e.\n", float_value);
8883
8884 refcount = effect->lpVtbl->Release(effect);
8885 ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
8886
8887 refcount = IDirect3DDevice9_Release(device);
8888 ok(!refcount, "Device has %lu references left.\n", refcount);
8889 IDirect3D9_Release(d3d);
8891}
HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format, D3DPOOL pool, struct IDirect3DTexture9 **texture)
Definition: texture.c:528
#define D3DX_DEFAULT
Definition: d3dx9.h:24
@ D3DXPC_MATRIX_ROWS
Definition: d3dx9shader.h:64
static const DWORD test_effect_parameter_value_blob_float[]
Definition: effect.c:506
static const MAT2 mat
Definition: font.c:51
static const struct metadata_block block2[]
Definition: metadata.c:3639
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_effect_parameter_value()

static void test_effect_parameter_value ( IDirect3DDevice9 *  device)
static

Definition at line 1952 of file effect.c.

1953{
1954 unsigned int effect_count = ARRAY_SIZE(test_effect_parameter_value_data), i;
1955
1956 for (i = 0; i < effect_count; ++i)
1957 {
1962 D3DXEFFECT_DESC edesc;
1963 ID3DXEffect *effect;
1964 unsigned int k;
1965 ULONG refcount;
1966 HRESULT hr;
1967
1968 winetest_push_context("Test %u", i);
1969 hr = D3DXCreateEffect(device, blob, blob_size, NULL, NULL, 0, NULL, &effect, NULL);
1970 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1971
1972 hr = effect->lpVtbl->GetDesc(effect, &edesc);
1973 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1974 ok(edesc.Parameters == res_count, "Unexpected Parameters %u, expected %u.\n",
1975 edesc.Parameters, res_count);
1976
1977 for (k = 0; k < res_count; ++k)
1978 {
1979 const char *name = res[k].name;
1980 D3DXHANDLE parameter;
1981 D3DXPARAMETER_DESC pdesc;
1982 BOOL bvalue = TRUE;
1983 INT ivalue = 42;
1984 FLOAT fvalue = 2.71828f;
1987 UINT l, n, m, count;
1988 const D3DXMATRIX *matrix_pointer_array[sizeof(input_value)/(sizeof(D3DXMATRIX))];
1989
1990 winetest_push_context("Parameter %s", name);
1991 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, name);
1992 ok(!!parameter, "Unexpected parameter %p.\n", parameter);
1993
1994 hr = effect->lpVtbl->GetParameterDesc(effect, parameter, &pdesc);
1995 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1996
1997 ok(!strcmp(pdesc.Name, name), "Unexpected Name %s, expected %s.\n", debugstr_a(pdesc.Name), debugstr_a(name));
1998 ok(!pdesc.Semantic, "Unexpected Semantic %s.\n", debugstr_a(pdesc.Semantic));
1999
2000 ok(res[k].class == pdesc.Class, "Unexpected Class %#x, expected %#x.\n",
2001 pdesc.Class, res[k].class);
2002 ok(res[k].type == pdesc.Type, "Unexpected Type %#x, expected %#x.\n", pdesc.Type, res[k].type);
2003 ok(res[k].rows == pdesc.Rows, "Unexpected Rows %u, expected %u.\n",
2004 pdesc.Rows, res[k].rows);
2005 ok(res[k].columns == pdesc.Columns, "Unexpected Columns %u, expected %u.\n",
2006 pdesc.Columns, res[k].columns);
2007 ok(res[k].elements == pdesc.Elements, "Unexpected Elements %u, expected %u.\n",
2008 pdesc.Elements, res[k].elements);
2009 ok(!pdesc.Annotations, "Unexpected Annotations %u.\n", pdesc.Annotations);
2010 ok(!pdesc.StructMembers, "Unexpected StructMembers %u.\n", pdesc.StructMembers);
2011 ok(!pdesc.Flags, "Unexpected Flags %lu.\n", pdesc.Flags);
2012 ok(res[k].bytes == pdesc.Bytes, "Unexpected Bytes %u, expected %u.\n",
2013 pdesc.Bytes, res[k].bytes);
2014
2015 test_effect_parameter_values(&res[k], effect, res[k].value.dword, parameter);
2016 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2017 test_effect_parameter_values(&res[k], effect, res[k].value.dword, parameter);
2018
2019 /*
2020 * check invalid calls
2021 * These will crash:
2022 * effect->lpVtbl->SetBoolArray(effect, parameter, NULL, res_desc->Bytes / sizeof(BOOL));
2023 * effect->lpVtbl->SetIntArray(effect, parameter, NULL, res_desc->Bytes / sizeof(INT));
2024 * effect->lpVtbl->SetFloatArray(effect, parameter, NULL, res_desc->Bytes / sizeof(FLOAT));
2025 * effect->lpVtbl->SetVector(effect, parameter, NULL);
2026 * effect->lpVtbl->SetVectorArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
2027 * effect->lpVtbl->SetMatrix(effect, parameter, NULL);
2028 * effect->lpVtbl->GetMatrix(effect, parameter, NULL);
2029 * effect->lpVtbl->SetMatrixArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
2030 * effect->lpVtbl->SetMatrixPointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
2031 * effect->lpVtbl->SetMatrixTranspose(effect, parameter, NULL);
2032 * effect->lpVtbl->SetMatrixTransposeArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
2033 * effect->lpVtbl->SetMatrixTransposePointerArray(effect, parameter, NULL, res_desc->Elements ? res_desc->Elements : 1);
2034 * effect->lpVtbl->GetValue(effect, parameter, NULL, res_desc->Bytes);
2035 * effect->lpVtbl->SetValue(effect, parameter, NULL, res_desc->Bytes);
2036 */
2037 hr = effect->lpVtbl->SetBool(effect, NULL, bvalue);
2038 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2039
2040 hr = effect->lpVtbl->GetBool(effect, NULL, &bvalue);
2041 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2042
2043 hr = effect->lpVtbl->GetBool(effect, parameter, NULL);
2044 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2045
2046 hr = effect->lpVtbl->SetBoolArray(effect, NULL, (BOOL *)input_value, res[k].bytes / sizeof(BOOL));
2047 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2048
2049 hr = effect->lpVtbl->GetBoolArray(effect, NULL, (BOOL *)input_value, res[k].bytes / sizeof(BOOL));
2050 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2051
2052 hr = effect->lpVtbl->GetBoolArray(effect, parameter, NULL, res[k].bytes / sizeof(BOOL));
2053 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2054
2055 hr = effect->lpVtbl->SetInt(effect, NULL, ivalue);
2056 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2057
2058 hr = effect->lpVtbl->GetInt(effect, NULL, &ivalue);
2059 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2060
2061 hr = effect->lpVtbl->GetInt(effect, parameter, NULL);
2062 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2063
2064 hr = effect->lpVtbl->SetIntArray(effect, NULL, (INT *)input_value, res[k].bytes / sizeof(INT));
2065 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2066
2067 hr = effect->lpVtbl->GetIntArray(effect, NULL, (INT *)input_value, res[k].bytes / sizeof(INT));
2068 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2069
2070 hr = effect->lpVtbl->GetIntArray(effect, parameter, NULL, res[k].bytes / sizeof(INT));
2071 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2072
2073 hr = effect->lpVtbl->SetFloat(effect, NULL, fvalue);
2074 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2075
2076 hr = effect->lpVtbl->GetFloat(effect, NULL, &fvalue);
2077 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2078
2079 hr = effect->lpVtbl->GetFloat(effect, parameter, NULL);
2080 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2081
2082 hr = effect->lpVtbl->SetFloatArray(effect, NULL, (FLOAT *)input_value, res[k].bytes / sizeof(FLOAT));
2083 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2084
2085 hr = effect->lpVtbl->GetFloatArray(effect, NULL, (FLOAT *)input_value, res[k].bytes / sizeof(FLOAT));
2086 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2087
2088 hr = effect->lpVtbl->GetFloatArray(effect, parameter, NULL, res[k].bytes / sizeof(FLOAT));
2089 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2090
2091 hr = effect->lpVtbl->SetVector(effect, NULL, (D3DXVECTOR4 *)input_value);
2092 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2093
2094 hr = effect->lpVtbl->GetVector(effect, NULL, (D3DXVECTOR4 *)input_value);
2095 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2096
2097 hr = effect->lpVtbl->GetVector(effect, parameter, NULL);
2098 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2099
2100 hr = effect->lpVtbl->SetVectorArray(effect, NULL, (D3DXVECTOR4 *)input_value, res[k].elements ? res[k].elements : 1);
2101 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2102
2103 hr = effect->lpVtbl->GetVectorArray(effect, NULL, (D3DXVECTOR4 *)input_value, res[k].elements ? res[k].elements : 1);
2104 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2105
2106 hr = effect->lpVtbl->GetVectorArray(effect, parameter, NULL, res[k].elements ? res[k].elements : 1);
2107 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2108
2109 hr = effect->lpVtbl->SetMatrix(effect, NULL, (D3DXMATRIX *)input_value);
2110 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2111
2112 hr = effect->lpVtbl->GetMatrix(effect, NULL, (D3DXMATRIX *)input_value);
2113 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2114
2115 hr = effect->lpVtbl->SetMatrixArray(effect, NULL, (D3DXMATRIX *)input_value, res[k].elements ? res[k].elements : 1);
2116 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2117
2118 hr = effect->lpVtbl->GetMatrixArray(effect, NULL, (D3DXMATRIX *)input_value, res[k].elements ? res[k].elements : 1);
2119 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2120
2121 hr = effect->lpVtbl->GetMatrixArray(effect, parameter, NULL, res[k].elements ? res[k].elements : 1);
2122 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2123
2124 hr = effect->lpVtbl->SetMatrixPointerArray(effect, NULL, matrix_pointer_array, res[k].elements ? res[k].elements : 1);
2125 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2126
2127 hr = effect->lpVtbl->SetMatrixPointerArray(effect, NULL, matrix_pointer_array, 0);
2128 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2129
2130 hr = effect->lpVtbl->GetMatrixPointerArray(effect, NULL, NULL, 0);
2131 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2132
2133 hr = effect->lpVtbl->GetMatrixPointerArray(effect, NULL, NULL, res[k].elements ? res[k].elements : 1);
2134 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2135
2136 hr = effect->lpVtbl->GetMatrixPointerArray(effect, parameter, NULL, res[k].elements ? res[k].elements : 1);
2137 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2138
2139 hr = effect->lpVtbl->SetMatrixTranspose(effect, NULL, (D3DXMATRIX *)input_value);
2140 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2141
2142 hr = effect->lpVtbl->GetMatrixTranspose(effect, NULL, (D3DXMATRIX *)input_value);
2143 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2144
2145 hr = effect->lpVtbl->GetMatrixTranspose(effect, parameter, NULL);
2146 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2147
2148 hr = effect->lpVtbl->SetMatrixTransposeArray(effect, NULL, (D3DXMATRIX *)input_value, res[k].elements ? res[k].elements : 1);
2149 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2150
2151 hr = effect->lpVtbl->GetMatrixTransposeArray(effect, NULL, (D3DXMATRIX *)input_value, res[k].elements ? res[k].elements : 1);
2152 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2153
2154 hr = effect->lpVtbl->GetMatrixTransposeArray(effect, parameter, NULL, res[k].elements ? res[k].elements : 1);
2155 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2156
2157 hr = effect->lpVtbl->SetMatrixTransposePointerArray(effect, NULL, matrix_pointer_array, res[k].elements ? res[k].elements : 1);
2158 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2159
2160 hr = effect->lpVtbl->SetMatrixTransposePointerArray(effect, NULL, matrix_pointer_array, 0);
2161 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2162
2163 hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, NULL, NULL, 0);
2164 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2165
2166 hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, NULL, NULL, res[k].elements ? res[k].elements : 1);
2167 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2168
2169 hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, parameter, NULL, res[k].elements ? res[k].elements : 1);
2170 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2171
2172 hr = effect->lpVtbl->SetValue(effect, NULL, input_value, res[k].bytes);
2173 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2174
2175 hr = effect->lpVtbl->SetValue(effect, parameter, input_value, res[k].bytes - 1);
2176 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2177
2178 hr = effect->lpVtbl->GetValue(effect, NULL, input_value, res[k].bytes);
2179 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2180
2181 hr = effect->lpVtbl->GetValue(effect, parameter, input_value, res[k].bytes - 1);
2182 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2183
2184 test_effect_parameter_values(&res[k], effect, res[k].value.dword, parameter);
2185
2186 /* SetBool */
2187 bvalue = 5;
2188 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2189 hr = effect->lpVtbl->SetBool(effect, parameter, bvalue);
2190 if (!res[k].elements && res[k].rows == 1 && res[k].columns == 1)
2191 {
2192 bvalue = TRUE;
2193 set_number(expected_value, res[k].type, &bvalue, D3DXPT_BOOL);
2194 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2195 }
2196 else
2197 {
2198 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2199 }
2200 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2201 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2202
2203 /* SetBoolArray */
2204 *input_value = 1;
2205 for (l = 1; l < res[k].bytes / sizeof(*input_value); ++l)
2206 {
2207 *(input_value + l) = *(input_value + l - 1) + 1;
2208 }
2209 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2210 hr = effect->lpVtbl->SetBoolArray(effect, parameter, (BOOL *)input_value, res[k].bytes / sizeof(*input_value));
2211 if (res[k].class == D3DXPC_SCALAR
2212 || res[k].class == D3DXPC_VECTOR
2213 || res[k].class == D3DXPC_MATRIX_ROWS)
2214 {
2215 for (l = 0; l < res[k].bytes / sizeof(*input_value); ++l)
2216 {
2217 set_number(expected_value + l, res[k].type, input_value + l, D3DXPT_BOOL);
2218 }
2219 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2220 }
2221 else
2222 {
2223 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2224 }
2225 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2226 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2227
2228 /* SetInt */
2229 ivalue = 0x1fbf02ff;
2230 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2231 hr = effect->lpVtbl->SetInt(effect, parameter, ivalue);
2232 if (!res[k].elements && res[k].rows == 1 && res[k].columns == 1)
2233 {
2234 set_number(expected_value, res[k].type, &ivalue, D3DXPT_INT);
2235 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2236 }
2237 else if (!res[k].elements && res[k].type == D3DXPT_FLOAT &&
2238 ((res[k].class == D3DXPC_VECTOR && res[k].columns != 2) ||
2239 (res[k].class == D3DXPC_MATRIX_ROWS && res[k].rows != 2 && res[k].columns == 1)))
2240 {
2241 FLOAT tmp = ((ivalue & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE;
2242 set_number(expected_value, res[k].type, &tmp, D3DXPT_FLOAT);
2243 tmp = ((ivalue & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE;
2244 set_number(expected_value + 1, res[k].type, &tmp, D3DXPT_FLOAT);
2245 tmp = (ivalue & 0xff) * INT_FLOAT_MULTI_INVERSE;
2246 set_number(expected_value + 2, res[k].type, &tmp, D3DXPT_FLOAT);
2247 tmp = ((ivalue & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE;
2248 set_number(expected_value + 3, res[k].type, &tmp, D3DXPT_FLOAT);
2249
2250 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2251 }
2252 else
2253 {
2254 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2255 }
2256 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2257 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2258
2259 /* SetIntArray */
2260 *input_value = 123456;
2261 for (l = 1; l < res[k].bytes / sizeof(*input_value); ++l)
2262 {
2263 *(input_value + l) = *(input_value + l - 1) + 23;
2264 }
2265 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2266 hr = effect->lpVtbl->SetIntArray(effect, parameter, (INT *)input_value, res[k].bytes / sizeof(*input_value));
2267 if (res[k].class == D3DXPC_SCALAR
2268 || res[k].class == D3DXPC_VECTOR
2269 || res[k].class == D3DXPC_MATRIX_ROWS)
2270 {
2271 for (l = 0; l < res[k].bytes / sizeof(*input_value); ++l)
2272 {
2273 set_number(expected_value + l, res[k].type, input_value + l, D3DXPT_INT);
2274 }
2275 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2276 }
2277 else
2278 {
2279 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2280 }
2281 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2282 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2283
2284 /* SetFloat */
2285 fvalue = 1.33;
2286 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2287 hr = effect->lpVtbl->SetFloat(effect, parameter, fvalue);
2288 if (!res[k].elements && res[k].rows == 1 && res[k].columns == 1)
2289 {
2290 set_number(expected_value, res[k].type, &fvalue, D3DXPT_FLOAT);
2291 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2292 }
2293 else
2294 {
2295 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2296 }
2297 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2298 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2299
2300 /* SetFloatArray */
2301 fvalue = 1.33;
2302 for (l = 0; l < res[k].bytes / sizeof(fvalue); ++l)
2303 {
2304 *(input_value + l) = *(DWORD *)&fvalue;
2305 fvalue += 1.12;
2306 }
2307 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2308 hr = effect->lpVtbl->SetFloatArray(effect, parameter, (FLOAT *)input_value, res[k].bytes / sizeof(*input_value));
2309 if (res[k].class == D3DXPC_SCALAR
2310 || res[k].class == D3DXPC_VECTOR
2311 || res[k].class == D3DXPC_MATRIX_ROWS)
2312 {
2313 for (l = 0; l < res[k].bytes / sizeof(*input_value); ++l)
2314 {
2315 set_number(expected_value + l, res[k].type, input_value + l, D3DXPT_FLOAT);
2316 }
2317 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2318 }
2319 else
2320 {
2321 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2322 }
2323 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2324 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2325
2326 /* SetVector */
2327 fvalue = -1.33;
2328 for (l = 0; l < 4; ++l)
2329 {
2330 *(input_value + l) = *(DWORD *)&fvalue;
2331 fvalue += 1.12;
2332 }
2333 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2334 hr = effect->lpVtbl->SetVector(effect, parameter, (D3DXVECTOR4 *)input_value);
2335 if (!res[k].elements &&
2336 (res[k].class == D3DXPC_SCALAR
2337 || res[k].class == D3DXPC_VECTOR))
2338 {
2339 /* only values between 0 and INT_FLOAT_MULTI are valid */
2340 if (res[k].type == D3DXPT_INT && res[k].bytes == 4)
2341 {
2342 *expected_value = (DWORD)(max(min(*(FLOAT *)(input_value + 2), 1.0f), 0.0f) * INT_FLOAT_MULTI);
2343 *expected_value += ((DWORD)(max(min(*(FLOAT *)(input_value + 1), 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 8;
2344 *expected_value += ((DWORD)(max(min(*(FLOAT *)input_value, 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 16;
2345 *expected_value += ((DWORD)(max(min(*(FLOAT *)(input_value + 3), 1.0f), 0.0f) * INT_FLOAT_MULTI)) << 24;
2346 }
2347 else
2348 {
2349 for (l = 0; l < 4; ++l)
2350 {
2351 set_number(expected_value + l, res[k].type, input_value + l, D3DXPT_FLOAT);
2352 }
2353 }
2354 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2355 }
2356 else
2357 {
2358 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2359 }
2360 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2361 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2362
2363 /* SetVectorArray */
2364 for (count = 0; count < res[k].elements + 1; ++count)
2365 {
2366 fvalue = 1.33;
2367 for (l = 0; l < count * 4; ++l)
2368 {
2369 *(input_value + l) = *(DWORD *)&fvalue;
2370 fvalue += 1.12;
2371 }
2372 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2373 hr = effect->lpVtbl->SetVectorArray(effect, parameter, (D3DXVECTOR4 *)input_value, count);
2374 if (res[k].elements && res[k].class == D3DXPC_VECTOR && count <= res[k].elements)
2375 {
2376 for (m = 0; m < count; ++m)
2377 {
2378 for (l = 0; l < res[k].columns; ++l)
2379 {
2380 set_number(expected_value + m * res[k].columns + l, res[k].type, input_value + m * 4 + l, D3DXPT_FLOAT);
2381 }
2382 }
2383 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2384 }
2385 else
2386 {
2387 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2388 }
2389 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2390 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2391 }
2392
2393 /* SetMatrix */
2394 fvalue = 1.33;
2395 for (l = 0; l < 16; ++l)
2396 {
2397 *(input_value + l) = *(DWORD *)&fvalue;
2398 fvalue += 1.12;
2399 }
2400 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2401 hr = effect->lpVtbl->SetMatrix(effect, parameter, (D3DXMATRIX *)input_value);
2402 if (!res[k].elements && res[k].class == D3DXPC_MATRIX_ROWS)
2403 {
2404 for (l = 0; l < 4; ++l)
2405 {
2406 for (m = 0; m < 4; ++m)
2407 {
2408 if (m < res[k].rows && l < res[k].columns)
2409 set_number(expected_value + l + m * res[k].columns, res[k].type,
2410 input_value + l + m * 4, D3DXPT_FLOAT);
2411 }
2412
2413 }
2414 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2415 }
2416 else
2417 {
2418 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2419 }
2420 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2421 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2422
2423 /* SetMatrixArray */
2424 for (count = 0; count < res[k].elements + 1; ++count)
2425 {
2426 fvalue = 1.33;
2427 for (l = 0; l < count * 16; ++l)
2428 {
2429 *(input_value + l) = *(DWORD *)&fvalue;
2430 fvalue += 1.12;
2431 }
2432 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2433 hr = effect->lpVtbl->SetMatrixArray(effect, parameter, (D3DXMATRIX *)input_value, count);
2434 if (res[k].class == D3DXPC_MATRIX_ROWS && count <= res[k].elements)
2435 {
2436 for (n = 0; n < count; ++n)
2437 {
2438 for (l = 0; l < 4; ++l)
2439 {
2440 for (m = 0; m < 4; ++m)
2441 {
2442 if (m < res[k].rows && l < res[k].columns)
2443 set_number(expected_value + l + m * res[k].columns + n * res[k].columns * res[k].rows,
2444 res[k].type, input_value + l + m * 4 + n * 16, D3DXPT_FLOAT);
2445 }
2446
2447 }
2448 }
2449 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2450 }
2451 else
2452 {
2453 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2454 }
2455 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2456 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2457 }
2458
2459 /* SetMatrixPointerArray */
2460 for (count = 0; count < res[k].elements + 1; ++count)
2461 {
2462 fvalue = 1.33;
2463 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
2464 {
2465 *(input_value + l) = *(DWORD *)&fvalue;
2466 fvalue += 1.12;
2467 }
2468 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2469 for (l = 0; l < count; ++l)
2470 {
2471 matrix_pointer_array[l] = (D3DXMATRIX *)&input_value[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)];
2472 }
2473 hr = effect->lpVtbl->SetMatrixPointerArray(effect, parameter, matrix_pointer_array, count);
2474 if (res[k].class == D3DXPC_MATRIX_ROWS && res[k].elements >= count)
2475 {
2476 for (n = 0; n < count; ++n)
2477 {
2478 for (l = 0; l < 4; ++l)
2479 {
2480 for (m = 0; m < 4; ++m)
2481 {
2482 if (m < res[k].rows && l < res[k].columns)
2483 set_number(expected_value + l + m * res[k].columns + n * res[k].columns * res[k].rows,
2484 res[k].type, input_value + l + m * 4 + n * 16, D3DXPT_FLOAT);
2485 }
2486
2487 }
2488 }
2489 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2490 }
2491 else
2492 {
2493 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2494 }
2495 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2496 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2497 }
2498
2499 /* SetMatrixTranspose */
2500 fvalue = 1.33;
2501 for (l = 0; l < 16; ++l)
2502 {
2503 *(input_value + l) = *(DWORD *)&fvalue;
2504 fvalue += 1.12;
2505 }
2506 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2507 hr = effect->lpVtbl->SetMatrixTranspose(effect, parameter, (D3DXMATRIX *)input_value);
2508 if (!res[k].elements && res[k].class == D3DXPC_MATRIX_ROWS)
2509 {
2510 for (l = 0; l < 4; ++l)
2511 {
2512 for (m = 0; m < 4; ++m)
2513 {
2514 if (m < res[k].rows && l < res[k].columns)
2515 set_number(expected_value + l + m * res[k].columns, res[k].type,
2516 input_value + l * 4 + m, D3DXPT_FLOAT);
2517 }
2518
2519 }
2520 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2521 }
2522 else
2523 {
2524 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2525 }
2526 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2527 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2528
2529 /* SetMatrixTransposeArray */
2530 for (count = 0; count < res[k].elements + 1; ++count)
2531 {
2532 fvalue = 1.33;
2533 for (l = 0; l < count * 16; ++l)
2534 {
2535 *(input_value + l) = *(DWORD *)&fvalue;
2536 fvalue += 1.12;
2537 }
2538 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2539 hr = effect->lpVtbl->SetMatrixTransposeArray(effect, parameter, (D3DXMATRIX *)input_value, count);
2540 if (res[k].class == D3DXPC_MATRIX_ROWS && count <= res[k].elements)
2541 {
2542 for (n = 0; n < count; ++n)
2543 {
2544 for (l = 0; l < 4; ++l)
2545 {
2546 for (m = 0; m < 4; ++m)
2547 {
2548 if (m < res[k].rows && l < res[k].columns)
2549 set_number(expected_value + l + m * res[k].columns + n * res[k].columns * res[k].rows,
2550 res[k].type, input_value + l * 4 + m + n * 16, D3DXPT_FLOAT);
2551 }
2552
2553 }
2554 }
2555 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2556 }
2557 else
2558 {
2559 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2560 }
2561 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2562 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2563 }
2564
2565 /* SetMatrixTransposePointerArray */
2566 for (count = 0; count < res[k].elements + 1; ++count)
2567 {
2568 fvalue = 1.33;
2569 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
2570 {
2571 *(input_value + l) = *(DWORD *)&fvalue;
2572 fvalue += 1.12;
2573 }
2574 memcpy(expected_value, res[k].value.dword, res[k].bytes);
2575 for (l = 0; l < count; ++l)
2576 {
2577 matrix_pointer_array[l] = (D3DXMATRIX *)&input_value[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)];
2578 }
2579 hr = effect->lpVtbl->SetMatrixTransposePointerArray(effect, parameter, matrix_pointer_array, count);
2580 if (res[k].class == D3DXPC_MATRIX_ROWS && res[k].elements >= count)
2581 {
2582 for (n = 0; n < count; ++n)
2583 {
2584 for (l = 0; l < 4; ++l)
2585 {
2586 for (m = 0; m < 4; ++m)
2587 {
2588 if (m < res[k].rows && l < res[k].columns)
2589 set_number(expected_value + l + m * res[k].columns + n * res[k].columns * res[k].rows,
2590 res[k].type, input_value + l * 4 + m + n * 16, D3DXPT_FLOAT);
2591 }
2592
2593 }
2594 }
2595 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2596 }
2597 else
2598 {
2599 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
2600 }
2601 test_effect_parameter_values(&res[k], effect, expected_value, parameter);
2602 test_effect_parameter_value_reset(&res[k], effect, res[k].value.dword, parameter);
2603 }
2605 }
2606
2607 refcount = effect->lpVtbl->Release(effect);
2608 ok(!refcount, "Unexpected refcount %lu.\n", refcount);
2610 }
2611}
r l[0]
Definition: byte_order.h:168
static void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
#define INT_FLOAT_MULTI_INVERSE
Definition: effect.c:31
#define INT_FLOAT_MULTI
Definition: effect.c:30
@ D3DXPC_SCALAR
Definition: d3dx9shader.h:62
@ D3DXPC_VECTOR
Definition: d3dx9shader.h:63
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
const GLfloat * m
Definition: glext.h:10848
unsigned int UINT
Definition: sysinfo.c:13
#define FLOAT
Definition: i386-dis.c:525
#define EFFECT_PARAMETER_VALUE_ARRAY_SIZE
Definition: effect.c:1168
static void test_effect_parameter_value_reset(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1922
UINT res_count
Definition: effect.c:1155
static const struct @1912 test_effect_parameter_value_data[]
static void test_effect_parameter_values(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1902
UINT blob_size
Definition: effect.c:1153
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
#define DWORD
Definition: nt_native.h:44
const char * Semantic
Definition: d3dx9effect.h:45
const char * Name
Definition: d3dx9effect.h:44
D3DXPARAMETER_CLASS Class
Definition: d3dx9effect.h:46
D3DXPARAMETER_TYPE Type
Definition: d3dx9effect.h:47
Definition: image.c:229
WCHAR * name
Definition: name.c:42
#define max(a, b)
Definition: svc.c:63

Referenced by START_TEST().

◆ test_effect_parameter_value_GetBool()

static void test_effect_parameter_value_GetBool ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1235 of file effect.c.

1237{
1238 BOOL bvalue = 0xabababab;
1239 HRESULT hr;
1240
1241 hr = effect->lpVtbl->GetBool(effect, parameter, &bvalue);
1242 if (!res->elements && res->rows == 1 && res->columns == 1)
1243 {
1244 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1245 ok(bvalue == get_bool(res_value), "Unexpected value %#x, expected %#x.\n",
1246 bvalue, get_bool(res_value));
1247 }
1248 else
1249 {
1250 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1251 ok(bvalue == 0xabababab, "Unexpected value %#x.\n", bvalue);
1252 }
1253}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetBoolArray()

static void test_effect_parameter_value_GetBoolArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1255 of file effect.c.

1257{
1259 unsigned int l, err = 0;
1260 HRESULT hr;
1261
1262 memset(bavalue, 0xab, sizeof(bavalue));
1263 hr = effect->lpVtbl->GetBoolArray(effect, parameter, bavalue, res->bytes / sizeof(*bavalue));
1264 if (res->class == D3DXPC_SCALAR
1265 || res->class == D3DXPC_VECTOR
1266 || res->class == D3DXPC_MATRIX_ROWS)
1267 {
1268 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1269
1270 for (l = 0; l < res->bytes / sizeof(*bavalue); ++l)
1271 {
1272 if (bavalue[l] != get_bool(&res_value[l]))
1273 ++err;
1274 }
1275
1276 for (l = res->bytes / sizeof(*bavalue); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1277 {
1278 if (bavalue[l] != 0xabababab)
1279 ++err;
1280 }
1281 }
1282 else
1283 {
1284 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1285
1286 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1287 if (bavalue[l] != 0xabababab)
1288 ++err;
1289 }
1290 ok(!err, "Unexpected value in %u elements.\n", err);
1291}
#define err(...)

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetFloat()

static void test_effect_parameter_value_GetFloat ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1365 of file effect.c.

1367{
1368 DWORD cmp = 0xabababab;
1369 float fvalue;
1370 HRESULT hr;
1371
1372 fvalue = *(float *)&cmp;
1373 hr = effect->lpVtbl->GetFloat(effect, parameter, &fvalue);
1374 if (!res->elements && res->columns == 1 && res->rows == 1)
1375 {
1376 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1377 ok(compare_float(fvalue, get_float(res->type, res_value), 512), "Unexpected value %.8e, expected %.8e.\n",
1378 fvalue, get_float(res->type, res_value));
1379 }
1380 else
1381 {
1382 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1383 ok(fvalue == *(float *)&cmp, "Unexpected value %.8e, expected %.8e.\n", fvalue, *(float *)&cmp);
1384 }
1385}
#define compare_float(got, exp)
Definition: mesh.c:43
#define cmp(status, error)
Definition: error.c:118

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetFloatArray()

static void test_effect_parameter_value_GetFloatArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1387 of file effect.c.

1389{
1390 float favalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE];
1391 unsigned int l, err = 0;
1392 DWORD cmp = 0xabababab;
1393 HRESULT hr;
1394
1395 memset(favalue, 0xab, sizeof(favalue));
1396 hr = effect->lpVtbl->GetFloatArray(effect, parameter, favalue, res->bytes / sizeof(*favalue));
1397 if (res->class == D3DXPC_SCALAR
1398 || res->class == D3DXPC_VECTOR
1399 || res->class == D3DXPC_MATRIX_ROWS)
1400 {
1401 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1402
1403 for (l = 0; l < res->bytes / sizeof(*favalue); ++l)
1404 {
1405 if (!compare_float(favalue[l], get_float(res->type, &res_value[l]), 512))
1406 ++err;
1407 }
1408
1409 for (l = res->bytes / sizeof(*favalue); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1410 {
1411 if (favalue[l] != *(float *)&cmp)
1412 ++err;
1413 }
1414 }
1415 else
1416 {
1417 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1418
1419 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (favalue[l] != *(FLOAT *)&cmp) ++err;
1420 }
1421 ok(!err, "Unexpected value in %u elements.\n", err);
1422}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetInt()

static void test_effect_parameter_value_GetInt ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1293 of file effect.c.

1295{
1296 int ivalue = 0xabababab;
1297 HRESULT hr;
1298
1299 hr = effect->lpVtbl->GetInt(effect, parameter, &ivalue);
1300 if (!res->elements && res->columns == 1 && res->rows == 1)
1301 {
1302 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1303 ok(ivalue == get_int(res->type, res_value), "Unexpected value %d, expected %d.\n",
1304 ivalue, get_int(res->type, res_value));
1305 }
1306 else if (!res->elements && res->type == D3DXPT_FLOAT &&
1307 ((res->class == D3DXPC_VECTOR && res->columns != 2) ||
1308 (res->class == D3DXPC_MATRIX_ROWS && res->rows != 2 && res->columns == 1)))
1309 {
1310 int tmp;
1311
1312 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1313
1314 tmp = (int)(min(max(0.0f, *((float *)res_value + 2)), 1.0f) * INT_FLOAT_MULTI);
1315 tmp |= ((int)(min(max(0.0f, *((float *)res_value + 1)), 1.0f) * INT_FLOAT_MULTI)) << 8;
1316 tmp |= ((int)(min(max(0.0f, *((float *)res_value + 0)), 1.0f) * INT_FLOAT_MULTI)) << 16;
1317 if (res->columns * res->rows > 3)
1318 {
1319 tmp |= ((int)(min(max(0.0f, *((float *)res_value + 3)), 1.0f) * INT_FLOAT_MULTI)) << 24;
1320 }
1321
1322 ok(ivalue == tmp, "Unexpected value %x, expected %x.\n", ivalue, tmp);
1323 }
1324 else
1325 {
1326 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1327 ok(ivalue == 0xabababab, "Unexpected value %d.\n", ivalue);
1328 }
1329}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetIntArray()

static void test_effect_parameter_value_GetIntArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1331 of file effect.c.

1333{
1335 unsigned int l, err = 0;
1336 HRESULT hr;
1337
1338 memset(iavalue, 0xab, sizeof(iavalue));
1339 hr = effect->lpVtbl->GetIntArray(effect, parameter, iavalue, res->bytes / sizeof(*iavalue));
1340 if (res->class == D3DXPC_SCALAR
1341 || res->class == D3DXPC_VECTOR
1342 || res->class == D3DXPC_MATRIX_ROWS)
1343 {
1344 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1345
1346 for (l = 0; l < res->bytes / sizeof(*iavalue); ++l)
1347 {
1348 if (iavalue[l] != get_int(res->type, &res_value[l])) ++err;
1349 }
1350
1351 for (l = res->bytes / sizeof(*iavalue); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1352 {
1353 if (iavalue[l] != 0xabababab) ++err;
1354 }
1355 }
1356 else
1357 {
1358 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1359
1360 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (iavalue[l] != 0xabababab) ++err;
1361 }
1362 ok(!err, "Unexpected value in %u elements.\n", err);
1363}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetMatrix()

static void test_effect_parameter_value_GetMatrix ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1529 of file effect.c.

1531{
1532 unsigned int l, k, err = 0;
1533 float fvalue[16];
1534 union
1535 {
1536 DWORD d;
1537 float f;
1538 } cmp;
1539 HRESULT hr;
1540
1541 cmp.d = 0xabababab;
1542 memset(fvalue, 0xab, sizeof(fvalue));
1543 hr = effect->lpVtbl->GetMatrix(effect, parameter, (D3DXMATRIX *)&fvalue);
1544 if (!res->elements && res->class == D3DXPC_MATRIX_ROWS)
1545 {
1546 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1547
1548 for (k = 0; k < 4; ++k)
1549 {
1550 for (l = 0; l < 4; ++l)
1551 {
1552 if (k < res->columns && l < res->rows)
1553 {
1554 if (!compare_float(fvalue[l * 4 + k], get_float(res->type,
1555 &res_value[l * res->columns + k]), 512))
1556 ++err;
1557 }
1558 else if (fvalue[l * 4 + k] != 0.0f) ++err;
1559 }
1560 }
1561 }
1562 else
1563 {
1564 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1565
1566 for (l = 0; l < ARRAY_SIZE(fvalue); ++l)
1567 if (fvalue[l] != cmp.f)
1568 ++err;
1569 }
1570 ok(!err, "Unexpected value in %u elements.\n", err);
1571}
#define d
Definition: ke_i.h:81

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetMatrixArray()

static void test_effect_parameter_value_GetMatrixArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1573 of file effect.c.

1575{
1577 unsigned int l, k, m, count, err = 0;
1578 DWORD cmp = 0xabababab;
1579 HRESULT hr;
1580
1581 for (count = 0; count <= res->elements + 1; ++count)
1582 {
1583 winetest_push_context("Count %u", count);
1584 memset(fvalue, 0xab, sizeof(fvalue));
1585 hr = effect->lpVtbl->GetMatrixArray(effect, parameter, (D3DXMATRIX *)&fvalue, count);
1586 if (!count)
1587 {
1588 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1589
1590 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1591 if (fvalue[l] != *(float *)&cmp)
1592 ++err;
1593 }
1594 else if (count <= res->elements && res->class == D3DXPC_MATRIX_ROWS)
1595 {
1596 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1597
1598 for (m = 0; m < count; ++m)
1599 {
1600 for (k = 0; k < 4; ++k)
1601 {
1602 for (l = 0; l < 4; ++l)
1603 {
1604 if (k < res->columns && l < res->rows)
1605 {
1606 if (!compare_float(fvalue[m * 16 + l * 4 + k], get_float(res->type,
1607 &res_value[m * res->columns * res->rows
1608 + l * res->columns + k]), 512))
1609 ++err;
1610 }
1611 else if (fvalue[m * 16 + l * 4 + k] != 0.0f)
1612 ++err;
1613 }
1614 }
1615 }
1616
1617 for (l = count * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1618 if (fvalue[l] != *(float *)&cmp)
1619 ++err;
1620 }
1621 else
1622 {
1623 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1624
1625 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1626 if (fvalue[l] != *(float *)&cmp)
1627 ++err;
1628 }
1629 ok(!err, "Unexpected value in %u elements.\n", err);
1631 }
1632}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetMatrixPointerArray()

static void test_effect_parameter_value_GetMatrixPointerArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1634 of file effect.c.

1636{
1637 union
1638 {
1639 float f[sizeof(D3DXMATRIX) / sizeof(float)];
1640 D3DXMATRIX m;
1641 } fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE * sizeof(float) / sizeof(D3DXMATRIX)];
1642 D3DXMATRIX *matrix_pointer_array[ARRAY_SIZE(fvalue)];
1643 unsigned int l, k, m, count, err = 0;
1644 union
1645 {
1646 DWORD d;
1647 float f;
1648 } cmp = {0xabababab};
1649 HRESULT hr;
1650
1651 for (count = 0; count <= res->elements + 1; ++count)
1652 {
1653 winetest_push_context("Count %u", count);
1654 memset(fvalue, 0xab, sizeof(fvalue));
1655 for (l = 0; l < count; ++l)
1656 {
1657 matrix_pointer_array[l] = &fvalue[l].m;
1658 }
1659 hr = effect->lpVtbl->GetMatrixPointerArray(effect, parameter, matrix_pointer_array, count);
1660 if (!count)
1661 {
1662 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1663
1664 for (m = 0; m < ARRAY_SIZE(fvalue); ++m)
1665 for (l = 0; l < ARRAY_SIZE(fvalue[l].f); ++l)
1666 if (fvalue[m].f[l] != cmp.f)
1667 ++err;
1668 }
1669 else if (count <= res->elements && res->class == D3DXPC_MATRIX_ROWS)
1670 {
1671 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1672
1673 for (m = 0; m < count; ++m)
1674 {
1675 for (k = 0; k < 4; ++k)
1676 {
1677 for (l = 0; l < 4; ++l)
1678 {
1679 if (k < res->columns && l < res->rows)
1680 {
1681 if (!compare_float(fvalue[m].m.m[l][k], get_float(res->type,
1682 &res_value[m * res->columns * res->rows + l * res->columns + k]), 512))
1683 ++err;
1684 }
1685 else if (fvalue[m].m.m[l][k] != 0.0f)
1686 ++err;
1687 }
1688 }
1689 }
1690
1691 for (m = count; m < ARRAY_SIZE(fvalue); ++m)
1692 for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
1693 if (fvalue[m].f[l] != cmp.f)
1694 ++err;
1695 }
1696 else
1697 {
1698 for (m = 0; m < ARRAY_SIZE(fvalue); ++m)
1699 for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
1700 if (fvalue[m].f[l] != cmp.f)
1701 ++err;
1702
1703 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1704 }
1705 ok(!err, "Unexpected value in %u elements.\n", err);
1707 }
1708}
struct _D3DMATRIX D3DXMATRIX
Definition: d3dx9math.h:169
static float(__cdecl *square_half_float)(float x
float m[4][4]
Definition: d3d8types.h:1116

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetMatrixTranspose()

static void test_effect_parameter_value_GetMatrixTranspose ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1710 of file effect.c.

1712{
1713 unsigned int l, k, err = 0;
1714 HRESULT hr;
1715 union
1716 {
1717 DWORD d;
1718 float f;
1719 } cmp;
1720 float fvalue[16];
1721
1722 cmp.d = 0xabababab;
1723 memset(fvalue, 0xab, sizeof(fvalue));
1724 hr = effect->lpVtbl->GetMatrixTranspose(effect, parameter, (D3DXMATRIX *)&fvalue);
1725 if (!res->elements && res->class == D3DXPC_MATRIX_ROWS)
1726 {
1727 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1728
1729 for (k = 0; k < 4; ++k)
1730 {
1731 for (l = 0; l < 4; ++l)
1732 {
1733 if (k < res->columns && l < res->rows)
1734 {
1735 if (!compare_float(fvalue[l + k * 4], get_float(res->type,
1736 &res_value[l * res->columns + k]), 512))
1737 ++err;
1738 }
1739 else if (fvalue[l + k * 4] != 0.0f) ++err;
1740 }
1741 }
1742 }
1743 else if (!res->elements && (res->class == D3DXPC_VECTOR || res->class == D3DXPC_SCALAR))
1744 {
1745 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1746
1747 for (k = 0; k < 4; ++k)
1748 {
1749 for (l = 0; l < 4; ++l)
1750 {
1751 if (k < res->columns && l < res->rows)
1752 {
1753 if (!compare_float(fvalue[l * 4 + k], get_float(res->type,
1754 &res_value[l * res->columns + k]), 512))
1755 ++err;
1756 }
1757 else if (fvalue[l * 4 + k] != 0.0f) ++err;
1758 }
1759 }
1760 }
1761 else
1762 {
1763 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1764
1765 for (l = 0; l < ARRAY_SIZE(fvalue); ++l)
1766 if (fvalue[l] != cmp.f)
1767 ++err;
1768 }
1769 ok(!err, "Unexpected value in %u elements.\n", err);
1770}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetMatrixTransposeArray()

static void test_effect_parameter_value_GetMatrixTransposeArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1772 of file effect.c.

1774{
1776 unsigned int l, k, m, count, err = 0;
1777 DWORD cmp = 0xabababab;
1778 HRESULT hr;
1779
1780 for (count = 0; count <= res->elements + 1; ++count)
1781 {
1782 winetest_push_context("Count %u", count);
1783 memset(fvalue, 0xab, sizeof(fvalue));
1784 hr = effect->lpVtbl->GetMatrixTransposeArray(effect, parameter, (D3DXMATRIX *)&fvalue, count);
1785 if (!count)
1786 {
1787 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1788
1789 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err;
1790 }
1791 else if (count <= res->elements && res->class == D3DXPC_MATRIX_ROWS)
1792 {
1793 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1794
1795 for (m = 0; m < count; ++m)
1796 {
1797 for (k = 0; k < 4; ++k)
1798 {
1799 for (l = 0; l < 4; ++l)
1800 {
1801 if (k < res->columns && l < res->rows)
1802 {
1803 if (!compare_float(fvalue[m * 16 + l + k * 4], get_float(res->type,
1804 &res_value[m * res->columns * res->rows + l * res->columns + k]), 512))
1805 ++err;
1806 }
1807 else if (fvalue[m * 16 + l + k * 4] != 0.0f) ++err;
1808 }
1809 }
1810 }
1811
1812 for (l = count * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err;
1813 }
1814 else
1815 {
1816 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1817
1818 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err;
1819 }
1820 ok(!err, "Unexpected value in %u elements.\n", err);
1822 }
1823}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetMatrixTransposePointerArray()

static void test_effect_parameter_value_GetMatrixTransposePointerArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1825 of file effect.c.

1828{
1829 union
1830 {
1831 float f[sizeof(D3DXMATRIX) / sizeof(float)];
1832 D3DXMATRIX m;
1833 } fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE * sizeof(float) / sizeof(D3DXMATRIX)];
1834 D3DXMATRIX *matrix_pointer_array[sizeof(fvalue)];
1835 unsigned int l, k, m, count, err = 0;
1836 union
1837 {
1838 DWORD d;
1839 float f;
1840 } cmp = {0xabababab};
1841 HRESULT hr;
1842
1843 for (count = 0; count <= res->elements + 1; ++count)
1844 {
1845 winetest_push_context("Count %u", count);
1846 memset(fvalue, 0xab, sizeof(fvalue));
1847 for (l = 0; l < count; ++l)
1848 {
1849 matrix_pointer_array[l] = &fvalue[l].m;
1850 }
1851 hr = effect->lpVtbl->GetMatrixTransposePointerArray(effect, parameter, matrix_pointer_array, count);
1852 if (!count)
1853 {
1854 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1855
1856 for (m = 0; m < ARRAY_SIZE(fvalue); ++m)
1857 for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
1858 if (fvalue[m].f[l] != cmp.f)
1859 ++err;
1860 }
1861 else if (count <= res->elements && res->class == D3DXPC_MATRIX_ROWS)
1862 {
1863 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1864
1865 for (m = 0; m < count; ++m)
1866 {
1867 for (k = 0; k < 4; ++k)
1868 {
1869 for (l = 0; l < 4; ++l)
1870 {
1871 if (k < res->columns && l < res->rows)
1872 {
1873 if (!compare_float(fvalue[m].m.m[k][l], get_float(res->type,
1874 &res_value[m * res->columns * res->rows + l * res->columns + k]), 512))
1875 ++err;
1876 }
1877 else if (fvalue[m].m.m[k][l] != 0.0f)
1878 ++err;
1879 }
1880 }
1881 }
1882
1883 for (m = count; m < ARRAY_SIZE(fvalue); ++m)
1884 for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
1885 if (fvalue[m].f[l] != cmp.f)
1886 ++err;
1887 }
1888 else
1889 {
1890 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1891
1892 for (m = 0; m < ARRAY_SIZE(fvalue); ++m)
1893 for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
1894 if (fvalue[m].f[l] != cmp.f)
1895 ++err;
1896 }
1897 ok(!err, "Unexpected value in %u elements.\n", err);
1899 }
1900}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetValue()

static void test_effect_parameter_value_GetValue ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1173 of file effect.c.

1175{
1177 unsigned int l;
1178 HRESULT hr;
1179
1180 memset(value, 0xab, sizeof(value));
1181 hr = effect->lpVtbl->GetValue(effect, parameter, value, res->bytes);
1182 if (res->class == D3DXPC_SCALAR
1183 || res->class == D3DXPC_VECTOR
1184 || res->class == D3DXPC_MATRIX_ROWS)
1185 {
1186 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1187
1188 for (l = 0; l < res->bytes / sizeof(*value); ++l)
1189 {
1190 ok(value[l] == res_value[l], "Unexpected value[%u] %#lx, expected %#lx.\n",
1191 l, value[l], res_value[l]);
1192 }
1193
1194 for (l = res->bytes / sizeof(*value); l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1195 {
1196 ok(value[l] == 0xabababab, "Unexpected value[%u] %#lx.\n", l, value[l]);
1197 }
1198 }
1199 else if (res->class == D3DXPC_OBJECT)
1200 {
1201 switch (res->type)
1202 {
1203 case D3DXPT_PIXELSHADER:
1205 case D3DXPT_TEXTURE2D:
1206 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1207
1208 for (l = 0; l < (res->elements ? res->elements : 1); ++l)
1209 {
1210 IUnknown *unk = *((IUnknown **)value + l);
1211 if (unk) IUnknown_Release(unk);
1212 }
1213 break;
1214
1215 case D3DXPT_STRING:
1216 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1217 break;
1218
1219 default:
1220 ok(0, "Type is %u, this should not happen!\n", res->type);
1221 break;
1222 }
1223 }
1224 else
1225 {
1226 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1227
1228 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1229 {
1230 ok(value[l] == 0xabababab, "Unexpected value[%u] %#lx.\n", l, value[l]);
1231 }
1232 }
1233}
@ D3DXPC_OBJECT
Definition: d3dx9shader.h:66

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetVector()

static void test_effect_parameter_value_GetVector ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1424 of file effect.c.

1426{
1427 unsigned int l, err = 0;
1428 DWORD cmp = 0xabababab;
1429 float fvalue[4];
1430 HRESULT hr;
1431
1432 memset(fvalue, 0xab, sizeof(fvalue));
1433 hr = effect->lpVtbl->GetVector(effect, parameter, (D3DXVECTOR4 *)&fvalue);
1434 if (!res->elements &&
1435 (res->class == D3DXPC_SCALAR || res->class == D3DXPC_VECTOR) &&
1436 res->type == D3DXPT_INT && res->bytes == 4)
1437 {
1438 DWORD tmp;
1439
1440 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1441
1442 tmp = (DWORD)(*(fvalue + 2) * INT_FLOAT_MULTI);
1443 tmp += ((DWORD)(*(fvalue + 1) * INT_FLOAT_MULTI)) << 8;
1444 tmp += ((DWORD)(*fvalue * INT_FLOAT_MULTI)) << 16;
1445 tmp += ((DWORD)(*(fvalue + 3) * INT_FLOAT_MULTI)) << 24;
1446
1447 if (*res_value != tmp)
1448 ++err;
1449 }
1450 else if (!res->elements && (res->class == D3DXPC_SCALAR || res->class == D3DXPC_VECTOR))
1451 {
1452 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1453
1454 for (l = 0; l < res->columns; ++l)
1455 if (!compare_float(fvalue[l], get_float(res->type, &res_value[l]), 512))
1456 ++err;
1457
1458 for (l = res->columns; l < 4; ++l)
1459 if (fvalue[l] != 0.0f)
1460 ++err;
1461 }
1462 else
1463 {
1464 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1465
1466 for (l = 0; l < 4; ++l)
1467 if (fvalue[l] != *(float *)&cmp)
1468 ++err;
1469 }
1470 ok(!err, "Unexpected value in %u elements.\n", err);
1471}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_GetVectorArray()

static void test_effect_parameter_value_GetVectorArray ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1473 of file effect.c.

1475{
1477 unsigned int l, k, element, err = 0;
1478 DWORD cmp = 0xabababab;
1479 HRESULT hr;
1480
1481 for (element = 0; element <= res->elements + 1; ++element)
1482 {
1483 winetest_push_context("Element %u", element);
1484 memset(fvalue, 0xab, sizeof(fvalue));
1485 hr = effect->lpVtbl->GetVectorArray(effect, parameter, (D3DXVECTOR4 *)&fvalue, element);
1486 if (!element)
1487 {
1488 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1489
1490 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1491 if (fvalue[l] != *(float *)&cmp)
1492 ++err;
1493 }
1494 else if (element <= res->elements && res->class == D3DXPC_VECTOR)
1495 {
1496 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1497
1498 for (k = 0; k < element; ++k)
1499 {
1500 for (l = 0; l < res->columns; ++l)
1501 {
1502 if (!compare_float(fvalue[l + k * 4], get_float(res->type,
1503 &res_value[l + k * res->columns]), 512))
1504 ++err;
1505 }
1506
1507 for (l = res->columns; l < 4; ++l)
1508 if (fvalue[l + k * 4] != 0.0f)
1509 ++err;
1510 }
1511
1513 if (fvalue[l] != *(float *)&cmp)
1514 ++err;
1515 }
1516 else
1517 {
1518 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
1519
1520 for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l)
1521 if (fvalue[l] != *(float *)&cmp)
1522 ++err;
1523 }
1524 ok(!err, "Unexpected value in %u elements.\n", err);
1526 }
1527}

Referenced by test_effect_parameter_values().

◆ test_effect_parameter_value_reset()

static void test_effect_parameter_value_reset ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1922 of file effect.c.

1924{
1925 HRESULT hr;
1926
1927 if (res->class == D3DXPC_SCALAR
1928 || res->class == D3DXPC_VECTOR
1929 || res->class == D3DXPC_MATRIX_ROWS)
1930 {
1931 hr = effect->lpVtbl->SetValue(effect, parameter, res_value, res->bytes);
1932 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
1933 }
1934 else
1935 {
1936 /* nothing to do */
1937 switch (res->type)
1938 {
1939 case D3DXPT_PIXELSHADER:
1941 case D3DXPT_TEXTURE2D:
1942 case D3DXPT_STRING:
1943 break;
1944
1945 default:
1946 ok(0, "Type is %u, this should not happen!\n", res->type);
1947 break;
1948 }
1949 }
1950}

Referenced by test_effect_parameter_value().

◆ test_effect_parameter_values()

static void test_effect_parameter_values ( const struct test_effect_parameter_value_result *  res,
ID3DXEffect *  effect,
const DWORD *  res_value,
D3DXHANDLE  parameter 
)
static

Definition at line 1902 of file effect.c.

1904{
1905 test_effect_parameter_value_GetValue(res, effect, res_value, parameter);
1906 test_effect_parameter_value_GetBool(res, effect, res_value, parameter);
1907 test_effect_parameter_value_GetBoolArray(res, effect, res_value, parameter);
1908 test_effect_parameter_value_GetInt(res, effect, res_value, parameter);
1909 test_effect_parameter_value_GetIntArray(res, effect, res_value, parameter);
1910 test_effect_parameter_value_GetFloat(res, effect, res_value, parameter);
1911 test_effect_parameter_value_GetFloatArray(res, effect, res_value, parameter);
1912 test_effect_parameter_value_GetVector(res, effect, res_value, parameter);
1913 test_effect_parameter_value_GetVectorArray(res, effect, res_value, parameter);
1914 test_effect_parameter_value_GetMatrix(res, effect, res_value, parameter);
1915 test_effect_parameter_value_GetMatrixArray(res, effect, res_value, parameter);
1916 test_effect_parameter_value_GetMatrixPointerArray(res, effect, res_value, parameter);
1917 test_effect_parameter_value_GetMatrixTranspose(res, effect, res_value, parameter);
1918 test_effect_parameter_value_GetMatrixTransposeArray(res, effect, res_value, parameter);
1920}
static void test_effect_parameter_value_GetMatrixTransposeArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1772
static void test_effect_parameter_value_GetBoolArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1255
static void test_effect_parameter_value_GetInt(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1293
static void test_effect_parameter_value_GetMatrixTransposePointerArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1825
static void test_effect_parameter_value_GetBool(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1235
static void test_effect_parameter_value_GetMatrixArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1573
static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1634
static void test_effect_parameter_value_GetFloat(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1365
static void test_effect_parameter_value_GetVectorArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1473
static void test_effect_parameter_value_GetIntArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1331
static void test_effect_parameter_value_GetFloatArray(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1387
static void test_effect_parameter_value_GetMatrix(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1529
static void test_effect_parameter_value_GetValue(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1173
static void test_effect_parameter_value_GetMatrixTranspose(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1710
static void test_effect_parameter_value_GetVector(const struct test_effect_parameter_value_result *res, ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter)
Definition: effect.c:1424

Referenced by test_effect_parameter_value().

◆ test_effect_preshader()

static void test_effect_preshader ( IDirect3DDevice9 *  device)
static

Definition at line 4702 of file effect.c.

4703{
4704 static const D3DXVECTOR4 test_effect_preshader_fvect_p[] =
4705 {
4706 {11.0f, 21.0f, 0.0f, 0.0f},
4707 {12.0f, 22.0f, 0.0f, 0.0f},
4708 {13.0f, 23.0f, 0.0f, 0.0f},
4709 {11.0f, 12.0f, 0.0f, 0.0f},
4710 {21.0f, 22.0f, 0.0f, 0.0f},
4711 {31.0f, 32.0f, 0.0f, 0.0f},
4712 {11.0f, 12.0f, 0.0f, 0.0f},
4713 {21.0f, 22.0f, 0.0f, 0.0f},
4714 {11.0f, 21.0f, 0.0f, 0.0f},
4715 {12.0f, 22.0f, 0.0f, 0.0f},
4716 {11.0f, 12.0f, 13.0f, 0.0f},
4717 {21.0f, 22.0f, 23.0f, 0.0f},
4718 {11.0f, 21.0f, 31.0f, 0.0f},
4719 {12.0f, 22.0f, 32.0f, 0.0f}
4720 };
4721 static const int test_effect_preshader_iconsts[][4] =
4722 {
4723 {4, 3, 2, 1}
4724 };
4725 static const D3DXVECTOR4 fvect1 = {28.0f, 29.0f, 30.0f, 31.0f};
4726 static const D3DXVECTOR4 fvect2 = {0.0f, 0.0f, 1.0f, 0.0f};
4727 static const int ivect_empty[4] = {-1, -1, -1, -1};
4728 HRESULT hr;
4729 ID3DXEffect *effect;
4730 D3DXHANDLE par;
4731 unsigned int npasses;
4732 DWORD value;
4733 D3DXVECTOR4 fdata[ARRAY_SIZE(test_effect_preshader_fvect_p)];
4734 int idata[ARRAY_SIZE(test_effect_preshader_iconsts)][4];
4735 IDirect3DVertexShader9 *vshader;
4737 unsigned int i;
4738 D3DCAPS9 caps;
4739
4741 ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
4742 if (caps.VertexShaderVersion < D3DVS_VERSION(3, 0)
4743 || caps.PixelShaderVersion < D3DPS_VERSION(3, 0))
4744 {
4745 skip("Test requires VS >= 3 and PS >= 3, skipping.\n");
4746 return;
4747 }
4748
4750 NULL, NULL, 0, NULL, &effect, NULL);
4751 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4752
4753 hr = effect->lpVtbl->GetDesc(effect, &desc);
4754 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
4755 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
4756 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
4757 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
4758 ok(desc.Parameters == 34, "Unexpected value %u.\n", desc.Parameters);
4759
4761
4762 for (i = 0; i < 224; ++i)
4763 {
4765 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4766 }
4767
4769
4770 for (i = 0; i < 16; ++i)
4771 {
4773 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4774 }
4775
4776 hr = effect->lpVtbl->Begin(effect, &npasses, 0);
4777 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4778
4779 par = effect->lpVtbl->GetParameterByName(effect, NULL, "g_Pos2");
4780 ok(par != NULL, "GetParameterByName failed.\n");
4781
4782 hr = effect->lpVtbl->SetVector(effect, par, &fvect1);
4783 ok(hr == D3D_OK, "SetVector failed, hr %#lx.\n", hr);
4784
4785 hr = effect->lpVtbl->BeginPass(effect, 0);
4786 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4787
4788 hr = effect->lpVtbl->BeginPass(effect, 0);
4789 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
4790
4791 hr = effect->lpVtbl->BeginPass(effect, 1);
4792 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
4793
4795
4797 ARRAY_SIZE(test_effect_preshader_fvect_p));
4798 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4799 ok(!memcmp(fdata, test_effect_preshader_fvect_p, sizeof(test_effect_preshader_fvect_p)),
4800 "Pixel shader float constants do not match.\n");
4801 for (i = ARRAY_SIZE(test_effect_preshader_fvect_p); i < 224; ++i)
4802 {
4804 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4805 ok(!memcmp(fdata, &fvect_filler, sizeof(fvect_filler)),
4806 "Pixel shader float constants do not match.\n");
4807 }
4809 ARRAY_SIZE(test_effect_preshader_iconsts));
4810 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4811 ok(!memcmp(idata, test_effect_preshader_iconsts, sizeof(test_effect_preshader_iconsts)),
4812 "Pixel shader integer constants do not match.\n");
4813 for (i = ARRAY_SIZE(test_effect_preshader_iconsts); i < 16; ++i)
4814 {
4816 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4817 ok(!memcmp(idata[0], ivect_empty, sizeof(ivect_empty)),
4818 "Pixel shader integer constants do not match.\n");
4819 }
4820
4822
4824
4826 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4827 ok(value == 3, "Unexpected sampler 0 minfilter %lu.\n", value);
4829 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4830 todo_wine ok(value == 3, "Unexpected sampler 0 magfilter %lu.\n", value);
4831
4833 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4834 ok(value == 1, "Unexpected sampler 1 minfilter %lu.\n", value);
4836 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4837 todo_wine
4838 ok(value == 1, "Unexpected sampler 1 magfilter %lu.\n", value);
4839
4841 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4842 ok(value == 1, "Unexpected vertex sampler 0 minfilter %lu.\n", value);
4844 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4845 todo_wine
4846 ok(value == 1, "Unexpected vertex sampler 0 magfilter %lu.\n", value);
4847
4849 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4850 todo_wine
4851 ok(value == 0, "Unexpected vertex sampler 1 minfilter %lu.\n", value);
4853 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4854 todo_wine
4855 ok(value == 0, "Unexpected vertex sampler 1 magfilter %lu.\n", value);
4856
4858 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4859 ok(value == 3, "Unexpected vertex sampler 2 minfilter %lu.\n", value);
4861 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4862 todo_wine ok(value == 3, "Unexpected vertex sampler 2 magfilter %lu.\n", value);
4863
4865 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4866 ok(value == 0, "Unexpected fog density %g.\n", *(float *)&value);
4868 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4869 ok(*(float *)&value == 4.0f, "Unexpected fog start %g.\n", *(float *)&value);
4871 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4872 ok(*(float *)&value == 4.0f, "Unexpected point scale A %g.\n", *(float *)&value);
4874 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4875 ok(*(float *)&value == 12.0f, "Unexpected point scale B %g.\n", *(float *)&value);
4876
4877 hr = effect->lpVtbl->EndPass(effect);
4878
4879 par = effect->lpVtbl->GetParameterByName(effect, NULL, "g_iVect");
4880 ok(par != NULL, "GetParameterByName failed.\n");
4881 hr = effect->lpVtbl->SetVector(effect, par, &fvect2);
4882 ok(hr == D3D_OK, "SetVector failed, hr %#lx.\n", hr);
4883 hr = effect->lpVtbl->BeginPass(effect, 1);
4884 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4885
4887
4889 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4890
4891 hr = effect->lpVtbl->SetVector(effect, par, &fvect1);
4892 ok(hr == D3D_OK, "SetVector failed, hr %#lx.\n", hr);
4893 hr = effect->lpVtbl->CommitChanges(effect);
4894 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4896 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4897 ok(!vshader, "Incorrect shader selected.\n");
4898
4899 hr = effect->lpVtbl->EndPass(effect);
4900 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4901
4902 hr = effect->lpVtbl->End(effect);
4903 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4904
4905 effect->lpVtbl->Release(effect);
4906
4908 NULL, NULL, 0, NULL, &effect, NULL);
4909 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4910
4911 hr = effect->lpVtbl->Begin(effect, &npasses, D3DXFX_DONOTSAVESTATE);
4912 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4913
4914 hr = effect->lpVtbl->BeginPass(effect, 0);
4915 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4916
4918 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4919 ok(value == 3, "Unexpected sampler 0 minfilter %lu.\n", value);
4921 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4922 todo_wine ok(value == 3, "Unexpected sampler 0 magfilter %lu.\n", value);
4923
4925 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4926 ok(value == 1, "Unexpected sampler 1 minfilter %lu.\n", value);
4928 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4929 todo_wine
4930 ok(value == 1, "Unexpected sampler 1 magfilter %lu.\n", value);
4931
4933 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4934 ok(value == 1, "Unexpected vertex sampler 0 minfilter %lu.\n", value);
4936 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4937 todo_wine
4938 ok(value == 1, "Unexpected vertex sampler 0 magfilter %lu.\n", value);
4939
4941 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4942 ok(value == 2, "Unexpected vertex sampler 1 minfilter %lu.\n", value);
4944 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4945 todo_wine
4946 ok(value == 2, "Unexpected vertex sampler 1 magfilter %lu.\n", value);
4947
4949 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4950 ok(value == 3, "Unexpected vertex sampler 2 minfilter %lu.\n", value);
4952 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4953 todo_wine
4954 ok(value == 3, "Unexpected vertex sampler 2 magfilter %lu.\n", value);
4955
4956 hr = effect->lpVtbl->EndPass(effect);
4957 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4958 hr = effect->lpVtbl->End(effect);
4959 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4960 effect->lpVtbl->Release(effect);
4961}
#define D3DPS_VERSION(major, minor)
Definition: d3d8types.h:474
#define D3DVS_VERSION(major, minor)
Definition: d3d8types.h:475
#define IDirect3DDevice9_GetPixelShaderConstantI(p, a, b, c)
Definition: d3d9.h:1447
#define IDirect3DDevice9_GetPixelShaderConstantF(p, a, b, c)
Definition: d3d9.h:1445
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1342
#define IDirect3DDevice9_SetPixelShaderConstantI(p, a, b, c)
Definition: d3d9.h:1446
#define IDirect3DDevice9_SetPixelShaderConstantF(p, a, b, c)
Definition: d3d9.h:1444
#define D3DXFX_DONOTSAVESTATE
Definition: d3dx9effect.h:24
#define SUCCEEDED(hr)
Definition: intsafe.h:50
DWORD PixelShaderVersion
Definition: d3d9caps.h:315
DWORD VertexShaderVersion
Definition: d3d9caps.h:313

Referenced by START_TEST().

◆ test_effect_preshader_clear_pbool_consts()

static void test_effect_preshader_clear_pbool_consts ( IDirect3DDevice9 *  device)
static

Definition at line 4638 of file effect.c.

4639{
4640 BOOL bval;
4641 unsigned int i;
4642 HRESULT hr;
4643
4644 for (i = 0; i < 16; ++i)
4645 {
4648 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
4649 }
4650}
float bval
Definition: cylfrac.c:48
#define IDirect3DDevice9_SetPixelShaderConstantB(p, a, b, c)
Definition: d3d9.h:1448

Referenced by test_effect_commitchanges(), and test_effect_preshader().

◆ test_effect_preshader_compare_pbool_consts_()

static void test_effect_preshader_compare_pbool_consts_ ( unsigned int  line,
IDirect3DDevice9 *  device,
const unsigned int *  const_updated_mask,
const char *  updated_param 
)
static

Definition at line 4654 of file effect.c.

4656{
4657 unsigned int i;
4658 BOOL bdata[16];
4659 HRESULT hr;
4660
4662 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
4663
4664 if (!const_updated_mask)
4665 {
4667 {
4668 /* The negation on both sides is actually needed, sometimes you
4669 * get 0xffffffff instead of 1 on native. */
4670 ok_(__FILE__, line)(!bdata[i] == !test_effect_preshader_bconsts[i],
4671 "Pixel shader boolean constants do not match, expected %#x, got %#x, i %u.\n",
4673 }
4674 }
4675 else
4676 {
4678 {
4679 if (const_updated_mask[i / TEST_EFFECT_BITMASK_BLOCK_SIZE]
4680 & (1u << (i % TEST_EFFECT_BITMASK_BLOCK_SIZE)))
4681 {
4682 /* The negation on both sides is actually needed, sometimes
4683 * you get 0xffffffff instead of 1 on native. */
4684 ok_(__FILE__, line)(!bdata[i] == !test_effect_preshader_bconsts[i],
4685 "Pixel shader boolean constants do not match, expected %#x, got %#x, i %u, parameter %s.\n",
4686 test_effect_preshader_bconsts[i], bdata[i], i, updated_param);
4687 }
4688 else
4689 {
4690 ok_(__FILE__, line)(bdata[i] == !test_effect_preshader_bconsts[i],
4691 "Pixel shader boolean constants updated unexpectedly, parameter %s.\n", updated_param);
4692 }
4693 }
4694 }
4695
4696 for (; i < 16; ++i)
4697 {
4698 ok_(__FILE__, line)(!bdata[i], "Got result %#lx, boolean register value %u.\n", hr, bdata[i]);
4699 }
4700}
#define ok_(x1, x2)
Definition: atltest.h:61
#define IDirect3DDevice9_GetPixelShaderConstantB(p, a, b, c)
Definition: d3d9.h:1449
Definition: parser.c:49

◆ test_effect_preshader_compare_shader_()

static void test_effect_preshader_compare_shader_ ( unsigned int  line,
IDirect3DDevice9 *  device,
int  expected_shader_index,
BOOL  todo 
)
static

Definition at line 4431 of file effect.c.

4433{
4434 IDirect3DVertexShader9 *vshader;
4435 void *byte_code;
4436 unsigned int byte_code_size;
4437 HRESULT hr;
4438
4440 ok_(__FILE__, line)(hr == D3D_OK, "IDirect3DDevice9_GetVertexShader result %#lx.\n", hr);
4441
4443 ok_(__FILE__, line)(!!vshader, "Got NULL vshader.\n");
4444 if (!vshader)
4445 return;
4446
4447 hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size);
4448 ok_(__FILE__, line)(hr == D3D_OK, "IDirect3DVertexShader9_GetFunction %#lx.\n", hr);
4449 ok_(__FILE__, line)(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size);
4450
4451 byte_code = calloc(1, byte_code_size);
4452 hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
4453 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
4454
4456 byte_code_size, expected_shader_index, todo);
4457
4458 free(byte_code);
4460 }
#define IDirect3DVertexShader9_GetFunction(p, a, b)
Definition: d3d9.h:1054
#define todo_wine_if(is_todo)
Definition: minitest.h:81
static void test_effect_preshader_compare_shader_bytecode_(unsigned int line, const DWORD *bytecode, unsigned int bytecode_size, int expected_shader_index, BOOL todo)
Definition: effect.c:4404
BOOL todo[4]
Definition: effect.c:4465

◆ test_effect_preshader_compare_shader_bytecode_()

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

Definition at line 4404 of file effect.c.

4406{
4407 unsigned int i = 0;
4408
4410 ok_(__FILE__, line)(!!bytecode, "NULL shader bytecode.\n");
4411
4412 if (!bytecode)
4413 return;
4414
4415 while (bytecode[i++] != 0x0000ffff)
4416 ;
4417
4418 if (!bytecode_size)
4419 bytecode_size = i * sizeof(*bytecode);
4420 else
4421 ok(i * sizeof(*bytecode) == bytecode_size, "Unexpected byte code size %u.\n", bytecode_size);
4422
4425 + expected_shader_index * TEST_EFFECT_PRESHADER_VSHADER_LEN], bytecode_size),
4426 "Incorrect shader selected.\n");
4427}
#define TEST_EFFECT_PRESHADER_VSHADER_LEN
Definition: effect.c:4400
#define TEST_EFFECT_PRESHADER_VSHADER_POS
Definition: effect.c:4399

Referenced by test_effect_preshader_compare_shader_().

◆ test_effect_preshader_compare_vconsts_()

static void test_effect_preshader_compare_vconsts_ ( unsigned int  line,
IDirect3DDevice9 *  device,
const unsigned int *  const_updated_mask,
const char *  updated_param 
)
static

Definition at line 4586 of file effect.c.

4588{
4589 HRESULT hr;
4590 unsigned int i;
4592
4595 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
4596
4597 if (!const_updated_mask)
4598 {
4600 "Vertex shader float constants do not match.\n");
4601 }
4602 else
4603 {
4605 {
4606 if (const_updated_mask[i / TEST_EFFECT_BITMASK_BLOCK_SIZE]
4607 & (1u << (i % TEST_EFFECT_BITMASK_BLOCK_SIZE)))
4608 {
4609 ok_(__FILE__, line)(!memcmp(&fdata[i], &test_effect_preshader_fvect_v[i], sizeof(fdata[i])),
4610 "Vertex shader float constants do not match, expected (%g, %g, %g, %g), "
4611 "got (%g, %g, %g, %g), parameter %s.\n",
4614 fdata[i].x, fdata[i].y, fdata[i].z, fdata[i].w, updated_param);
4615 }
4616 else
4617 {
4618 ok_(__FILE__, line)(!memcmp(&fdata[i], &fvect_filler, sizeof(fdata[i])),
4619 "Vertex shader float constants updated unexpectedly, parameter %s.\n", updated_param);
4620 }
4621 }
4622 }
4623
4624 for (i = ARRAY_SIZE(test_effect_preshader_fvect_v); i < 256; ++i)
4625 {
4627 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
4628 ok_(__FILE__, line)(!memcmp(fdata, &fvect_filler, sizeof(fvect_filler)),
4629 "Vertex shader float constants do not match.\n");
4630 }
4631}

◆ test_effect_preshader_op_results_()

static void test_effect_preshader_op_results_ ( unsigned int  line,
IDirect3DDevice9 *  device,
const enum expected_state_update *  expected_state,
const char *  updated_param 
)
static

Definition at line 4507 of file effect.c.

4509{
4510 static const D3DCOLORVALUE black = {0.0f};
4511 unsigned int i, j;
4513 const float *v;
4514 HRESULT hr;
4515
4517 {
4519 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
4520
4521 v = i < 8 ? &light.Diffuse.r : (i < 16 ? &light.Ambient.r : &light.Specular.r);
4522 if (!expected_state || expected_state[i] == EXPECTED_STATE_UPDATED)
4523 {
4524 for (j = 0; j < 4; ++j)
4525 {
4527 ok_(__FILE__, line)(compare_float(v[j],
4528 ((const float *)test_effect_preshader_op_expected[i].result)[j],
4530 "Operation %s, component %u, expected %#x, got %#x (%g).\n",
4533 ((const unsigned int *)v)[j], v[j]);
4534 }
4535 }
4536 else if (expected_state[i] == EXPECTED_STATE_ZERO)
4537 {
4538 ok_(__FILE__, line)(!memcmp(v, &black, sizeof(black)),
4539 "Parameter %s, test %d, operation %s, state updated unexpectedly.\n",
4540 updated_param, i, test_effect_preshader_op_expected[i].comment);
4541 }
4542 }
4543}
#define IDirect3DDevice9_GetLight(p, a, b)
Definition: d3d9.h:1387
const GLdouble * v
Definition: gl.h:2040
GLuint64EXT * result
Definition: glext.h:11304
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 light
Definition: glfuncs.h:170

◆ test_effect_preshader_ops()

static void test_effect_preshader_ops ( IDirect3DDevice9 *  device)
static

Definition at line 5170 of file effect.c.

5171{
5172 static D3DLIGHT9 light;
5173 const struct
5174 {
5175 const char *mnem;
5176 unsigned int expected_result[4];
5177 unsigned int result_index;
5178 float *result;
5179 D3DXVECTOR4 opvect1, opvect2, opvect3;
5180 unsigned int ulps;
5181 BOOL todo[4];
5182 }
5183 op_tests[] =
5184 {
5185 {"exp", {0x3f800000, 0x3f800000, 0x3e5edc66, 0x7f800000}, 0, &light.Diffuse.r,
5186 {0.0f, -0.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}},
5187 {"log", {0, 0x40000000, 0x3f9199b7, 0x43000000}, 1, &light.Diffuse.r,
5188 {0.0f, 4.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}},
5189 {"asin", {0xbe9c00ad, 0xffc00000, 0xffc00000, 0xffc00000}, 2, &light.Diffuse.r,
5190 {-0.3f, 4.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}},
5191 {"acos", {0x3ff01006, 0xffc00000, 0xffc00000, 0xffc00000}, 3, &light.Diffuse.r,
5192 {-0.3f, 4.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}},
5193 {"atan", {0xbe9539d4, 0x3fa9b465, 0xbf927420, 0x3fc90fdb}, 4, &light.Diffuse.r,
5194 {-0.3f, 4.0f, -2.2f, 3.402823466e+38f}, {1.0f, 2.0f, -3.0f, 4.0f}},
5195 {"atan2 test #1", {0xbfc90fdb, 0x40490fdb, 0x80000000, 0x7fc00000}, 5, &light.Diffuse.r,
5196 {-0.3f, 0.0f, -0.0f, NAN}, {0.0f, -0.0f, 0.0f, 1.0f}},
5197 {"atan2 test #2", {0xbfc90fdb, 0, 0xc0490fdb, 0}, 5, &light.Diffuse.r,
5198 {-0.3f, 0.0f, -0.0f, -0.0f}, {-0.0f, 0.0f, -0.0f, 1.0f}},
5199 {"div", {0, 0, 0, 0}, 7, &light.Diffuse.r,
5200 {-0.3f, 0.0f, -2.2f, NAN}, {0.0f, -0.0f, -3.0f, 1.0f}},
5201 {"cmp", {0x40a00000, 0x40000000, 0x40400000, 0x41000000}, 0, &light.Ambient.r,
5202 {-0.3f, 0.0f, 2.2f, NAN}, {1.0f, 2.0f, 3.0f, 4.0f}, {5.0f, 6.0f, 7.0f, 8.0f}},
5203 {"0 * INF", {0xffc00000, 0xffc00000, 0xc0d33334, 0x7f800000}, 6, &light.Diffuse.r,
5204 {0.0f, -0.0f, -2.2f, 3.402823466e+38f}, {INFINITY, INFINITY, 3.0f, 4.0f}},
5205 };
5206 unsigned int i, j, passes_count;
5208 ID3DXEffect *effect;
5209 HRESULT hr;
5210
5212 NULL, NULL, 0, NULL, &effect, NULL);
5213 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5214
5215 hr = effect->lpVtbl->GetDesc(effect, &desc);
5216 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5217 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
5218 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
5219 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
5220 ok(desc.Parameters == 3, "Unexpected value %u.\n", desc.Parameters);
5221
5222 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
5223 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5224 hr = effect->lpVtbl->BeginPass(effect, 0);
5225 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5226
5227 for (i = 0; i < ARRAY_SIZE(op_tests); ++i)
5228 {
5229 const float *result = op_tests[i].result;
5230 const float *expected_float = (float *)op_tests[i].expected_result;
5231
5232 winetest_push_context("Test %u", i);
5233 hr = effect->lpVtbl->SetVector(effect, "opvect1", &op_tests[i].opvect1);
5234 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5235 hr = effect->lpVtbl->SetVector(effect, "opvect2", &op_tests[i].opvect2);
5236 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5237 hr = effect->lpVtbl->SetVector(effect, "opvect3", &op_tests[i].opvect3);
5238 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5239 hr = effect->lpVtbl->CommitChanges(effect);
5240 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5241
5242 hr = IDirect3DDevice9_GetLight(device, op_tests[i].result_index, &light);
5243 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5244 for (j = 0; j < 4; ++j)
5245 {
5246 winetest_push_context("Light %u", j);
5247 todo_wine_if(op_tests[i].todo[j])
5248 ok(compare_float(result[j], expected_float[j], op_tests[i].ulps),
5249 "Operation %s, component %u, expected %#x (%.8e), got %#x (%.8e).\n", op_tests[i].mnem,
5250 j, op_tests[i].expected_result[j], expected_float[j],
5251 ((unsigned int *)result)[j], result[j]);
5253 }
5255 }
5256
5257 hr = effect->lpVtbl->End(effect);
5258 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
5259 effect->lpVtbl->Release(effect);
5260}
#define NAN
Definition: math.h:273
#define INFINITY
Definition: math.h:272
static const DWORD test_effect_preshader_ops_blob[]
Definition: effect.c:5008
unsigned int result[4]
Definition: effect.c:4466

Referenced by START_TEST().

◆ test_effect_preshader_relative_addressing()

static void test_effect_preshader_relative_addressing ( IDirect3DDevice9 *  device)
static

Definition at line 5963 of file effect.c.

5964{
5965 static const struct
5966 {
5967 D3DXVECTOR4 opvect2;
5968 D3DXVECTOR4 g_ivect;
5969 unsigned int expected[4];
5970 }
5971 test_out_of_bounds_index[] =
5972 {
5973 {{1.0f, 2.0f, 3.0f, 4.0f}, {101.0f, 101.0f, 101.0f, 101.0f}, {0, 0x42ca0000, 0x3f800000, 0}},
5974 {{1.0f, 2.0f, 3.0f, 4.0f}, {3333.0f, 1094.0f, 2222.0f, 3333.0f},
5975 {0x447ac000, 0x45505000, 0x3f800000, 0}},
5976 {{1.0f, 2.0f, 3.0f, 4.0f}, {3333.0f, 1094.0f, 2222.0f, 1.0f},
5977 {0x447ac000, 0x3f800000, 0x447a8000, 0x453b9000}},
5978 {{1.0f, 2.0f, 3.0f, 4.0f}, {1.0f, 1094.0f, 2222.0f, 3333.0f},
5979 {0x447ac000, 0x45505000, 0x3f800000, 0x453ba000}},
5980 {{1.0f, 2.0f, 3.0f, 4.0f}, {1111.0f, 1094.0f, 2222.0f, 1111.0f},
5981 {0x447ac000, 0x448ae000, 0, 0}},
5982 {{1.0f, 2.0f, 3.0f, 4.0f}, {1111.0f, 1094.0f, 2222.0f, 3333.0f},
5983 {0x447ac000, 0x45505000, 0x3f800000, 0}},
5984 {{-1111.0f, 1094.0f, -2222.0f, -3333.0f}, {4.0f, 3.0f, 2.0f, 1.0f},
5985 {0x447ac000, 0x40800000, 0x447a8000, 0x453b9000}},
5986 {{1.0f, 2.0f, 3.0f, 4.0f}, {-1.0f, -1.0f, -1.0f, -1.0f}, {0, 0xbf800000, 0, 0}},
5987 {{1.0f, 2.0f, 3.0f, 4.0f}, {-2.0f, -2.0f, -2.0f, -2.0f}, {0, 0xc0000000, 0x459c4800, 0}},
5988 {{1.0f, 2.0f, 3.0f, 4.0f}, {-3.0f, -3.0f, -3.0f, -3.0f}, {0, 0xc0400000, 0x453b9000, 0}},
5989 {{1.0f, 2.0f, 3.0f, 4.0f}, {-4.0f, -4.0f, -4.0f, -4.0f}, {0, 0xc0800000, 0x44fa2000, 0}},
5990 {{1.0f, 2.0f, 3.0f, 4.0f}, {-5.0f, -5.0f, -5.0f, -5.0f}, {0, 0xc0a00000, 0x459c5000, 0}},
5991 {{1.0f, 2.0f, 3.0f, 4.0f}, {-6.0f, -6.0f, -6.0f, -6.0f}, {0, 0xc0c00000, 0x453ba000, 0xc1400000}},
5992 {{1.0f, 2.0f, 3.0f, 4.0f}, {-7.0f, -7.0f, -7.0f, -7.0f}, {0, 0xc0e00000, 0x44fa4000, 0x40400000}},
5993 {{1.0f, 2.0f, 3.0f, 4.0f}, {-8.0f, -8.0f, -8.0f, -8.0f}, {0, 0xc1000000, 0, 0x44fa6000}},
5994 {{1.0f, 2.0f, 3.0f, 4.0f}, {-9.0f, -9.0f, -9.0f, -9.0f}, {0, 0xc1100000, 0, 0}},
5995 {{1.0f, 2.0f, 3.0f, 4.0f}, {-10.0f, -10.0f, -10.0f, -10.0f}, {0, 0xc1200000, 0xc1200000, 0}},
5996 {{1.0f, 2.0f, 3.0f, 4.0f}, {-11.0f, -11.0f, -11.0f, -11.0f}, {0, 0xc1300000, 0x3f800000, 0}},
5997 {{1.0f, 2.0f, 3.0f, 4.0f}, {-12.0f, -12.0f, -12.0f, -12.0f}, {0, 0xc1400000, 0x447a4000, 0}},
5998 {{1.0f, 2.0f, 3.0f, 4.0f}, {5.0f, 5.0f, 5.0f, 5.0f}, {0, 0x40a00000, 0x3f800000, 0}},
5999 {{1.0f, 2.0f, 3.0f, 4.0f}, {-1111.0f, 1094.0f, -2222.0f, -3333.0f},
6000 {0x447ac000, 0xc5505000, 0x459c5000, 0x40000000}},
6001 {{1.0f, 2.0f, 3.0f, 4.0f}, {-3333.0f, 1094.0f, -2222.0f, -1111.0f},
6002 {0x447ac000, 0xc48ae000, 0x44fa4000, 0x3f800000}},
6003 {{1.0f, 2.0f, 3.0f, 4.0f}, {-3333.0f, 1094.0f, -2222.0f, -3333.0f},
6004 {0x447ac000, 0xc5505000, 0x459c5000, 0}},
6005 {{1.0f, 2.0f, 3.0f, 4.0f}, {-1111.0f, 1094.0f, -2222.0f, -1111.0f},
6006 {0x447ac000, 0xc48ae000, 0x44fa4000, 0x40400000}},
6007 };
6008 static const struct
6009 {
6010 unsigned int zw[2];
6011 }
6012 expected_light_specular[] =
6013 {
6014 {{0, 0x44fa2000}},
6015 {{0x447a8000, 0x453b9000}},
6016 {{0x40000000, 0x459c4800}},
6017 {{0xbf800000, 0}},
6018 {{0x447a4000, 0}},
6019 {{0x3f800000, 0}},
6020 {{0xbf800000, 0}},
6021 {{0, 0}},
6022 {{0, 0x447a4000}},
6023 {{0x44fa4000, 0x3f800000}},
6024 {{0x453ba000, 0xbf800000}},
6025 {{0x459c5000, 0}},
6026 {{0x44fa2000, 0}},
6027 {{0x453b9000, 0}},
6028 {{0x459c4800, 0}},
6029 {{0, 0}},
6030 };
6031 static const struct
6032 {
6033 int index_value;
6034 unsigned int expected[4];
6035 }
6036 test_index_to_immediate_table[] =
6037 {
6038 {-1000000, {0, 0x40800000, 0x45bbd800, 0x41300000}},
6039 {-1001, {0x448d4000, 0x41300000, 0, 0}},
6040 {-32, {0x448d4000, 0x40800000, 0, 0}},
6041 {-31, {0x45843000, 0x41400000, 0, 0}},
6042 {-30, {0x46a64000, 0x41400000, 0x447a4000, 0x3f800000}},
6043 {-29, {0, 0x447a4000, 0x447a8000, 0x40000000}},
6044 {-28, {0, 0, 0x447ac000, 0x40400000}},
6045 {-27, {0, 0x3f800000, 0, 0}},
6046 {-26, {0, 0x41100000, 0x45bbd800, 0x41300000}},
6047 {-25, {0, 0x41300000, 0, 0}},
6048 {-24, {0, 0x41600000, 0, 0}},
6049 {-23, {0, 0, 0, 0}},
6050 {-22, {0, 0, 0, 0}},
6051 {-21, {0, 0x40a00000, 0, 0}},
6052 {-20, {0, 0x41500000, 0, 0}},
6053 {-19, {0, 0x41500000, 0, 0}},
6054 {-18, {0, 0xc1900000, 0, 0}},
6055 {-17, {0, 0, 0, 0}},
6056 {-16, {0, 0x40800000, 0, 0}},
6057 {-15, {0, 0x41400000, 0, 0}},
6058 {-14, {0, 0x41400000, 0, 0}},
6059 {-13, {0, 0x447a4000, 0x447a4000, 0x3f800000}},
6060 {-12, {0, 0, 0, 0}},
6061 {-11, {0, 0x3f800000, 0, 0}},
6062 {-10, {0, 0x41100000, 0, 0}},
6063 {-9, {0, 0x41300000, 0, 0}},
6064 {-8, {0, 0x41600000, 0, 0}},
6065 {-7, {0, 0, 0, 0}},
6066 {-6, {0, 0, 0, 0}},
6067 {-5, {0, 0x40a00000, 0, 0}},
6068 {-4, {0, 0x41500000, 0, 0}},
6069 {-3, {0, 0x41500000, 0, 0}},
6070 {-2, {0, 0xc0000000, 0, 0}},
6071 {-1, {0, 0, 0, 0}},
6072 {0, {0x45052000, 0x40800000, 0x447a4000, 0x3f800000}},
6073 {1, {0x467e6000, 0x41400000, 0x447a8000, 0x40000000}},
6074 {2, {0, 0x41400000, 0x447ac000, 0x40400000}},
6075 {3, {0, 0x447a4000, 0, 0}},
6076 {4, {0, 0, 0x45bbd800, 0x41300000}},
6077 {5, {0, 0x3f800000, 0, 0}},
6078 {6, {0, 0x41100000, 0, 0}},
6079 {7, {0, 0x41300000, 0, 0}},
6080 {8, {0, 0x41600000, 0, 0}},
6081 {9, {0, 0, 0, 0}},
6082 {10, {0, 0, 0, 0}},
6083 {11, {0, 0x40a00000, 0, 0}},
6084 {12, {0, 0x41500000, 0, 0}},
6085 {13, {0, 0x41500000, 0, 0}},
6086 {14, {0, 0x41600000, 0, 0}},
6087 {15, {0, 0, 0, 0}},
6088 {16, {0, 0x40800000, 0, 0}},
6089 {17, {0x45052000, 0x41400000, 0x447a4000, 0x3f800000}},
6090 {18, {0x467e6000, 0x41400000, 0x447a8000, 0x40000000}},
6091 {19, {0, 0x447a4000, 0x447ac000, 0x40400000}},
6092 {20, {0, 0, 0, 0}},
6093 {21, {0, 0x3f800000, 0x45bbd800, 0x41300000}},
6094 {22, {0, 0x41100000, 0, 0}},
6095 {23, {0, 0x41300000, 0, 0}},
6096 {24, {0, 0x41600000, 0, 0}},
6097 {25, {0, 0, 0, 0}},
6098 {26, {0, 0, 0, 0}},
6099 {27, {0, 0x40a00000, 0, 0}},
6100 {28, {0, 0x41500000, 0, 0}},
6101 {29, {0, 0x41500000, 0, 0}},
6102 {30, {0, 0x41f00000, 0, 0}},
6103 {31, {0, 0, 0, 0}},
6104 {1001, {0, 0, 0, 0}},
6105 {1000000, {0, 0x40800000, 0, 0}},
6106 };
6107 static const D3DLIGHT9 light_filler = {D3DLIGHT_POINT, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f},
6108 {1.0f, 1.0f, 1.0f, 1.0f}};
6109 unsigned int j, passes_count;
6110 const unsigned int *expected;
6111 const float *expected_float;
6112 ID3DXEffect *effect;
6113 D3DXVECTOR4 fvect;
6115 const float *v;
6116 HRESULT hr;
6117 int i;
6118
6120 NULL, NULL, 0, NULL, &effect, NULL);
6121 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6122
6123 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
6124 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6125 hr = effect->lpVtbl->BeginPass(effect, 0);
6126 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6127
6128 fvect.x = 1001.0f; fvect.y = 1002.0f; fvect.z = 1003.0f; fvect.w = 1004.0f;
6129 hr = effect->lpVtbl->SetVector(effect, "opvect1", &fvect);
6130 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6131
6132 fvect.x = 2001.0f; fvect.y = 2002.0f; fvect.z = 2003.0f; fvect.w = 2004.0f;
6133 hr = effect->lpVtbl->SetVector(effect, "g_Selector[0]", &fvect);
6134 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6135
6136 fvect.x = 3001.0f; fvect.y = 3002.0f; fvect.z = 3003.0f; fvect.w = 3004.0f;
6137 hr = effect->lpVtbl->SetVector(effect, "g_Selector[1]", &fvect);
6138 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6139
6140 v = &light.Specular.r;
6141 for (i = 0; i < ARRAY_SIZE(test_out_of_bounds_index); ++i)
6142 {
6143 hr = effect->lpVtbl->SetVector(effect, "opvect2", &test_out_of_bounds_index[i].opvect2);
6144 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6145 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &test_out_of_bounds_index[i].g_ivect);
6146 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6147
6148 hr = IDirect3DDevice9_SetLight(device, 1, &light_filler);
6149 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6150
6151 hr = effect->lpVtbl->CommitChanges(effect);
6152 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6153
6155 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6156
6157 expected = test_out_of_bounds_index[i].expected;
6158 expected_float = (const float *)expected;
6159
6160 for (j = 0; j < 4; ++j)
6161 {
6162 ok(compare_float(v[j], expected_float[j], 0),
6163 "Test %d, component %u, expected %#x (%g), got %#x (%g).\n",
6164 i, j, expected[j], expected_float[j], ((const unsigned int *)v)[j], v[j]);
6165 }
6166 }
6167
6168 hr = effect->lpVtbl->SetVector(effect, "opvect2", &test_out_of_bounds_index[7].opvect2);
6169 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6170 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &test_out_of_bounds_index[7].g_ivect);
6171 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6172
6173 hr = IDirect3DDevice9_SetLight(device, 1, &light_filler);
6174 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6175
6176 fvect = test_out_of_bounds_index[7].g_ivect;
6177 v = &light.Specular.b;
6178 for (i = -100; i < 100; ++i)
6179 {
6180 fvect.w = i;
6181 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6182 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6183 hr = effect->lpVtbl->CommitChanges(effect);
6184 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6185
6187 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6188
6189 expected = expected_light_specular[(unsigned int)i % ARRAY_SIZE(expected_light_specular)].zw;
6190 expected_float = (const float *)expected;
6191
6192 for (j = 0; j < 2; ++j)
6193 {
6194 ok(compare_float(v[j], expected_float[j], 0),
6195 "i %d, component %u, expected %#x (%g), got %#x (%g).\n",
6196 i, j + 2, expected[j], expected_float[j], ((const unsigned int *)v)[j], v[j]);
6197 }
6198 }
6199
6200 v = &light.Specular.r;
6201 for (i = 0; i < ARRAY_SIZE(test_index_to_immediate_table); ++i)
6202 {
6203 fvect.x = fvect.y = fvect.z = fvect.w = test_index_to_immediate_table[i].index_value;
6204 hr = effect->lpVtbl->SetVector(effect, "g_iVect", &fvect);
6205 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6206 hr = effect->lpVtbl->CommitChanges(effect);
6207 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6208
6210 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6211
6212 expected = test_index_to_immediate_table[i].expected;
6213 expected_float = (const float *)expected;
6214
6215 for (j = 0; j < 4; ++j)
6216 {
6217 ok(compare_float(v[j], expected_float[j], 0),
6218 "Test %d, component %u, expected %#x (%g), got %#x (%g).\n",
6219 i, j, expected[j], expected_float[j], ((const unsigned int *)v)[j], v[j]);
6220 }
6221 }
6222
6223 hr = effect->lpVtbl->EndPass(effect);
6224 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6225 hr = effect->lpVtbl->End(effect);
6226 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6227
6228 effect->lpVtbl->Release(effect);
6229}
BOOL expected
Definition: store.c:2000

Referenced by START_TEST().

◆ test_effect_setvalue_object()

static void test_effect_setvalue_object ( IDirect3DDevice9 *  device)
static

Definition at line 2613 of file effect.c.

2614{
2615 static const char expected_string[] = "test_string_1";
2616 static const char expected_string2[] = "test_longer_string_2";
2617 static const char *expected_string_array[] = {expected_string, expected_string2};
2618 const char *string_array[ARRAY_SIZE(expected_string_array)];
2619 const char *string, *string2;
2620 IDirect3DTexture9 *texture_set;
2621 IDirect3DTexture9 *texture;
2622 D3DXHANDLE parameter;
2624 ID3DXEffect *effect;
2625 unsigned int i;
2626 ULONG count;
2627 HRESULT hr;
2628
2631 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK).\n", hr);
2632
2633 hr = effect->lpVtbl->GetDesc(effect, &desc);
2634 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2635 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
2636 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
2637 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
2638 ok(desc.Parameters == 7, "Unexpected value %u.\n", desc.Parameters);
2639
2640 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "tex");
2641 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2642
2643 texture = NULL;
2645 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK).\n", hr);
2646 hr = effect->lpVtbl->SetValue(effect, parameter, &texture, sizeof(texture));
2647 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK).\n", hr);
2648 texture_set = NULL;
2649 hr = effect->lpVtbl->GetValue(effect, parameter, &texture_set, sizeof(texture_set));
2650 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK).\n", hr);
2651 ok(texture == texture_set, "Texture does not match.\n");
2652
2653 count = IDirect3DTexture9_Release(texture_set);
2654 ok(count == 2, "Got reference count %lu, expected 2.\n", count);
2655 texture_set = NULL;
2656 hr = effect->lpVtbl->SetValue(effect, parameter, &texture_set, sizeof(texture_set));
2657 ok(hr == D3D_OK, "Got result %#lx, expected 0 (D3D_OK).\n", hr);
2659 ok(!count, "Got reference count %lu, expected 0.\n", count);
2660
2661 hr = effect->lpVtbl->SetString(effect, "s", expected_string);
2662 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2663 string = NULL;
2664 hr = effect->lpVtbl->GetString(effect, "s", &string);
2665 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2666 hr = effect->lpVtbl->GetString(effect, "s", &string2);
2667 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2668
2669 ok(string != expected_string, "String pointers are the same.\n");
2670 ok(string == string2, "String pointers differ.\n");
2671 ok(!strcmp(string, expected_string), "Unexpected string '%s'.\n", string);
2672
2673 string = expected_string2;
2674 hr = effect->lpVtbl->SetValue(effect, "s", &string, sizeof(string) - 1);
2675 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
2676 hr = effect->lpVtbl->SetValue(effect, "s", &string, sizeof(string));
2677 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2678 hr = effect->lpVtbl->SetValue(effect, "s", &string, sizeof(string) * 2);
2679 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2680 string = NULL;
2681 hr = effect->lpVtbl->GetValue(effect, "s", &string, sizeof(string));
2682 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2683
2684 ok(string != expected_string2, "String pointers are the same.\n");
2685 ok(!strcmp(string, expected_string2), "Unexpected string '%s'.\n", string);
2686
2687 hr = effect->lpVtbl->SetValue(effect, "s_2", expected_string_array,
2688 sizeof(expected_string_array));
2689 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2690 hr = effect->lpVtbl->GetValue(effect, "s_2", string_array,
2691 sizeof(string_array));
2692 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
2693 for (i = 0; i < ARRAY_SIZE(expected_string_array); ++i)
2694 {
2695 ok(!strcmp(string_array[i], expected_string_array[i]), "Unexpected string '%s', i %u.\n",
2696 string_array[i], i);
2697 }
2698 effect->lpVtbl->Release(effect);
2699}
static const DWORD test_effect_parameter_value_blob_object[]
Definition: effect.c:1069
static CHAR string2[MAX_PATH]
Definition: automation.c:345

Referenced by START_TEST().

◆ test_effect_shared_parameters()

static void test_effect_shared_parameters ( IDirect3DDevice9 *  device)
static

Definition at line 6773 of file effect.c.

6774{
6775 ID3DXEffect *effect1, *effect2, *effect3, *effect4;
6776 ID3DXEffectPool *pool;
6778 HRESULT hr;
6779 D3DXHANDLE param, param_child, param2, param_child2;
6780 unsigned int i, passes_count;
6781 ULONG refcount;
6782 D3DXVECTOR4 fvect;
6783 float fval[2];
6784
6786 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6787
6789 NULL, NULL, 0, pool, &effect2, NULL);
6790 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6791
6792 hr = effect2->lpVtbl->GetDesc(effect2, &desc);
6793 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
6794 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
6795 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
6796 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
6797 ok(desc.Parameters == 34, "Unexpected value %u.\n", desc.Parameters);
6798
6799 effect2->lpVtbl->SetFloat(effect2, "arr2[0]", 28.0f);
6800 effect2->lpVtbl->Release(effect2);
6801
6803 NULL, NULL, 0, pool, &effect2, NULL);
6804 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6805 effect2->lpVtbl->GetFloat(effect2, "arr2[0]", &fvect.x);
6806 ok(fvect.x == 92.0f, "Unexpected parameter value %g.\n", fvect.x);
6807 effect2->lpVtbl->SetFloat(effect2, "arr2[0]", 28.0f);
6808
6810 NULL, NULL, 0, pool, &effect1, NULL);
6811 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6812
6813 effect1->lpVtbl->GetFloat(effect1, "arr2[0]", &fvect.x);
6814 ok(fvect.x == 28.0f, "Unexpected parameter value %g.\n", fvect.x);
6815
6817 NULL, NULL, 0, pool, &effect3, NULL);
6818 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6820 NULL, NULL, 0, pool, &effect4, NULL);
6821 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6822
6823 effect2->lpVtbl->SetFloat(effect2, "arr2[0]", 3.0f);
6824 effect2->lpVtbl->SetFloat(effect2, "ts2[0].fv", 3.0f);
6825
6826 effect3->lpVtbl->GetFloat(effect3, "arr2[0]", &fvect.x);
6827 ok(fvect.x == 0.0f, "Unexpected parameter value %g.\n", fvect.x);
6828 effect4->lpVtbl->SetFloat(effect4, "arr2[0]", 28.0f);
6829 effect3->lpVtbl->GetFloat(effect3, "arr2[0]", &fvect.x);
6830 ok(fvect.x == 28.0f, "Unexpected parameter value %g.\n", fvect.x);
6831 effect1->lpVtbl->GetFloat(effect1, "arr2[0]", &fvect.x);
6832 ok(fvect.x == 3.0f, "Unexpected parameter value %g.\n", fvect.x);
6833
6834 param = effect3->lpVtbl->GetParameterByName(effect3, NULL, "ts2[0].fv_2");
6835 ok(!!param, "GetParameterByName failed.\n");
6836 effect3->lpVtbl->GetFloat(effect3, param, &fvect.x);
6837 ok(fvect.x == 0.0f, "Unexpected parameter value %g.\n", fvect.x);
6838
6839 param = effect1->lpVtbl->GetParameterByName(effect1, NULL, "arr2");
6840 ok(!!param, "GetParameterByName failed.\n");
6841 ok(!effect3->lpVtbl->IsParameterUsed(effect3, param, "tech0"),
6842 "Unexpected IsParameterUsed result.\n");
6843
6844 param = effect3->lpVtbl->GetParameterByName(effect3, NULL, "arr2");
6845 ok(!!param, "GetParameterByName failed.\n");
6846 ok(effect3->lpVtbl->IsParameterUsed(effect3, param, "tech0"),
6847 "Unexpected IsParameterUsed result.\n");
6848
6849 param = effect1->lpVtbl->GetParameterByName(effect1, NULL, "vs_arr2");
6850 ok(!!param, "GetParameterByName failed.\n");
6851 todo_wine
6852 ok(!effect3->lpVtbl->IsParameterUsed(effect3, param, "tech0"),
6853 "Unexpected IsParameterUsed result.\n");
6854
6855 ok(effect3->lpVtbl->IsParameterUsed(effect3, "vs_arr2", "tech0"),
6856 "Unexpected IsParameterUsed result.\n");
6857 ok(!effect3->lpVtbl->IsParameterUsed(effect3, "vs_arr2[0]", "tech0"),
6858 "Unexpected IsParameterUsed result.\n");
6859 ok(!effect3->lpVtbl->IsParameterUsed(effect3, "vs_arr2[1]", "tech0"),
6860 "Unexpected IsParameterUsed result.\n");
6861
6862 ok(effect1->lpVtbl->IsParameterUsed(effect1, param, "tech0"),
6863 "Unexpected IsParameterUsed result.\n");
6864
6865 hr = effect3->lpVtbl->Begin(effect3, &passes_count, 0);
6866 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6867
6868 if (0)
6869 {
6870 /* Native d3dx crashes in BeginPass(). This is the case of shader array declared shared
6871 * but initialized with different shaders using different parameters. */
6872 hr = effect3->lpVtbl->BeginPass(effect3, 0);
6873 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6874
6875 hr = effect3->lpVtbl->EndPass(effect3);
6876 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6877 }
6878
6880 fvect.x = fvect.y = fvect.z = fvect.w = 28.0f;
6881 hr = effect2->lpVtbl->SetVector(effect2, "g_Pos1", &fvect);
6882 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6883 hr = effect1->lpVtbl->SetVector(effect1, "g_Pos1", &fvect);
6884 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6885
6886 hr = effect3->lpVtbl->BeginPass(effect3, 1);
6887 todo_wine
6888 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6889
6891 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6892 todo_wine
6893 ok(fvect.x == 0.0f && fvect.y == 0.0f && fvect.z == 0.0f && fvect.w == 0.0f,
6894 "Unexpected vector %g, %g, %g, %g.\n", fvect.x, fvect.y, fvect.z, fvect.w);
6895
6896 hr = effect3->lpVtbl->EndPass(effect3);
6897 todo_wine
6898 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6899
6900 hr = effect3->lpVtbl->End(effect3);
6901 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6902
6903 for (i = 0; i < 2; ++i)
6904 {
6905 struct IDirect3DVertexShader9 *vshader1;
6906
6907 param_child = effect1->lpVtbl->GetParameterElement(effect1, "vs_arr2", i);
6908 ok(!!param_child, "GetParameterElement failed.\n");
6909 hr = effect1->lpVtbl->GetVertexShader(effect1, param_child, &vshader1);
6910 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6911
6912 test_effect_shared_vs_arr_compare_helper(effect2, param_child, vshader1, i, FALSE);
6913 test_effect_shared_vs_arr_compare_helper(effect3, param_child, vshader1, i, FALSE);
6914 test_effect_shared_vs_arr_compare_helper(effect4, param_child, vshader1, i, FALSE);
6916 }
6917
6918 effect3->lpVtbl->Release(effect3);
6919 effect4->lpVtbl->Release(effect4);
6920
6921 fval[0] = 1.0f;
6922 hr = effect1->lpVtbl->SetFloatArray(effect1, "arr1", fval, 1);
6923 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6924 fval[0] = 0.0f;
6925 hr = effect2->lpVtbl->GetFloatArray(effect2, "arr1", fval, 1);
6926 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6927 ok(fval[0] == 91.0f, "Unexpected value %g.\n", fval[0]);
6928
6929 param = effect1->lpVtbl->GetParameterByName(effect1, NULL, "arr2");
6930 ok(!!param, "GetParameterByName failed.\n");
6931 param2 = effect2->lpVtbl->GetParameterByName(effect2, NULL, "arr2");
6932 ok(!!param, "GetParameterByName failed.\n");
6933 ok(param != param2, "Got same parameter handle unexpectedly.\n");
6934 param_child = effect1->lpVtbl->GetParameterElement(effect1, param, 0);
6935 ok(!!param_child, "GetParameterElement failed.\n");
6936 param_child2 = effect1->lpVtbl->GetParameterElement(effect2, param2, 0);
6937 ok(!!param_child2, "GetParameterElement failed.\n");
6938 ok(param_child != param_child2, "Got same parameter handle unexpectedly.\n");
6939
6940 fval[0] = 33.0f;
6941 hr = effect1->lpVtbl->SetFloatArray(effect1, "arr2", fval, 1);
6942 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6943 fval[0] = 0.0f;
6944 hr = effect1->lpVtbl->GetFloatArray(effect1, "arr2", fval, 2);
6945 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6946 ok(fval[0] == 33.0f && fval[1] == 93.0f, "Unexpected values %g, %g.\n", fval[0], fval[1]);
6947 fval[0] = 0.0f;
6948 hr = effect2->lpVtbl->GetFloatArray(effect2, "arr2", fval, 2);
6949 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6950 ok(fval[0] == 33.0f && fval[1] == 93.0f, "Unexpected values %g, %g.\n", fval[0], fval[1]);
6951
6952 hr = effect1->lpVtbl->Begin(effect1, &passes_count, 0);
6953 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6954
6955 hr = effect2->lpVtbl->Begin(effect2, &passes_count, 0);
6956 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6957
6958 hr = effect1->lpVtbl->BeginPass(effect1, 0);
6959 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6960
6961 fvect.x = 1.0f;
6962 fvect.y = fvect.z = fvect.w = 0.0f;
6964
6965 hr = effect1->lpVtbl->BeginPass(effect2, 0);
6966 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6967
6968 fvect.x = 91.0f;
6970 fvect.x = 33.0f;
6972
6973 fval[0] = 28.0f;
6974 fval[1] = -1.0f;
6975 hr = effect1->lpVtbl->SetFloatArray(effect1, "arr2", fval, 2);
6976 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6977
6979
6980 hr = effect1->lpVtbl->CommitChanges(effect1);
6981 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6982
6983 fvect.x = 28.0f;
6985 fvect.x = -1.0f;
6987
6989
6990 hr = effect1->lpVtbl->CommitChanges(effect1);
6991 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6992
6995
6996 hr = effect2->lpVtbl->CommitChanges(effect2);
6997 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6998
6999 fvect.x = 28.0f;
7001 fvect.x = -1.0f;
7003
7004 fval[0] = -2.0f;
7005 hr = effect2->lpVtbl->SetFloat(effect2, "arr2[0]", fval[0]);
7006 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7007 hr = effect1->lpVtbl->CommitChanges(effect1);
7008 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7009
7010 fvect.x = -2.0f;
7012 fvect.x = -1.0f;
7014
7015 fvect.x = fvect.y = fvect.z = fvect.w = 1111.0f;
7016 hr = effect2->lpVtbl->SetVector(effect2, "g_Pos1", &fvect);
7017 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7018
7019 hr = effect1->lpVtbl->CommitChanges(effect1);
7020 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7022
7023 hr = effect1->lpVtbl->CommitChanges(effect2);
7024 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7026
7027 hr = effect1->lpVtbl->End(effect1);
7028 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7029
7030 hr = effect2->lpVtbl->End(effect2);
7031 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7032
7033 if (0)
7034 {
7035 refcount = pool->lpVtbl->Release(pool);
7036 ok(refcount == 2, "Unexpected refcount %lu.\n", refcount);
7037
7038 refcount = pool->lpVtbl->Release(pool);
7039 ok(refcount == 1, "Unexpected refcount %lu.\n", refcount);
7040
7041 refcount = pool->lpVtbl->Release(pool);
7042 ok(!refcount, "Unexpected refcount %lu.\n", refcount);
7043
7044 /* Native d3dx crashes in GetFloat(). */
7045 effect2->lpVtbl->GetFloat(effect2, "arr2[0]", &fvect.x);
7046 }
7047
7048 effect1->lpVtbl->Release(effect1);
7049 effect2->lpVtbl->Release(effect2);
7050
7051 refcount = pool->lpVtbl->Release(pool);
7052 ok(!refcount, "Effect pool was not properly freed, refcount %lu.\n", refcount);
7053}
#define test_effect_shared_vs_arr_compare_helper(...)
Definition: effect.c:6737
#define test_effect_shared_parameters_compare_vconst(...)
Definition: effect.c:6758
static const DWORD test_effect_shared_parameters_blob[]
Definition: effect.c:6682

Referenced by START_TEST().

◆ test_effect_shared_parameters_compare_vconst_()

static void test_effect_shared_parameters_compare_vconst_ ( unsigned int  line,
IDirect3DDevice9 *  device,
unsigned int  index,
const D3DXVECTOR4 *  expected_fvect,
BOOL  todo 
)
static

Definition at line 6760 of file effect.c.

6762{
6763 D3DXVECTOR4 fvect;
6764 HRESULT hr;
6765
6767 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
6769 ok_(__FILE__, line)(!memcmp(&fvect, expected_fvect, sizeof(fvect)),
6770 "Unexpected constant value %g, %g, %g, %g.\n", fvect.x, fvect.y, fvect.z, fvect.w);
6771}
GLuint index
Definition: glext.h:6031

◆ test_effect_shared_vs_arr_compare_helper_()

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

Definition at line 6739 of file effect.c.

6742{
6743 struct IDirect3DVertexShader9 *vshader2;
6744 D3DXHANDLE param_child2;
6745 HRESULT hr;
6746
6747 param_child2 = effect->lpVtbl->GetParameterElement(effect, "vs_arr2", element);
6748 ok_(__FILE__, line)(!!param_child2, "GetParameterElement failed.\n");
6749 ok_(__FILE__, line)(param_child != param_child2, "Got same parameter handle unexpectedly.\n");
6750 hr = effect->lpVtbl->GetVertexShader(effect, param_child2, &vshader2);
6751 ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
6753 ok_(__FILE__, line)(vshader1 == vshader2, "Shared shader interface pointers differ.\n");
6754 if (vshader2)
6756}

◆ test_effect_skip_constants()

static void test_effect_skip_constants ( IDirect3DDevice9 *  device)
static

Definition at line 7247 of file effect.c.

7248{
7250 HRESULT hr;
7251 ID3DXEffect *effect;
7252 unsigned int passes_count;
7253 D3DXVECTOR4 fvect;
7254 unsigned int i;
7255
7257 NULL, NULL, "v3", 0, NULL, &effect, NULL);
7258 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7260 NULL, NULL, "v4", 0, NULL, &effect, NULL);
7261 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7263 NULL, NULL, "v1;v5;v4", 0, NULL, &effect, NULL);
7264 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7265
7267 NULL, NULL, " v1#,.+-= &\t\nv2*/!\"'v5 v6[1]", 0, NULL, &effect, NULL);
7268 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7269
7270 hr = effect->lpVtbl->GetDesc(effect, &desc);
7271 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
7272 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
7273 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
7274 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
7275 ok(desc.Parameters == 6, "Unexpected value %u.\n", desc.Parameters);
7276
7277 ok(!effect->lpVtbl->IsParameterUsed(effect, "v1", "tech0"),
7278 "Unexpected IsParameterUsed result.\n");
7279 ok(!effect->lpVtbl->IsParameterUsed(effect, "v2", "tech0"),
7280 "Unexpected IsParameterUsed result.\n");
7281 ok(effect->lpVtbl->IsParameterUsed(effect, "v3", "tech0"),
7282 "Unexpected IsParameterUsed result.\n");
7283 ok(effect->lpVtbl->IsParameterUsed(effect, "v4", "tech0"),
7284 "Unexpected IsParameterUsed result.\n");
7285 ok(!effect->lpVtbl->IsParameterUsed(effect, "v5", "tech0"),
7286 "Unexpected IsParameterUsed result.\n");
7287 ok(!effect->lpVtbl->IsParameterUsed(effect, "v6", "tech0"),
7288 "Unexpected IsParameterUsed result.\n");
7289
7290 hr = effect->lpVtbl->SetFloat(effect, "v1", 28.0f);
7291 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7292 hr = effect->lpVtbl->SetFloat(effect, "v2", 29.0f);
7293 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7294 hr = effect->lpVtbl->SetFloat(effect, "v3", 30.0f);
7295 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7296 hr = effect->lpVtbl->SetFloat(effect, "v4", 31.0f);
7297 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7298 hr = effect->lpVtbl->SetFloat(effect, "v5", 32.0f);
7299 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7300
7302
7303 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
7304 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7305 hr = effect->lpVtbl->BeginPass(effect, 0);
7306 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7307
7308 fvect.y = fvect.z = fvect.w = 0.0f;
7309 fvect.x = 30.0f;
7311 for (i = 1; i < 4; ++i)
7313 fvect.x = 31.0f;
7315 for (i = 5; i < 256; ++i)
7317
7318 hr = effect->lpVtbl->EndPass(effect);
7319 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7320 hr = effect->lpVtbl->End(effect);
7321 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7322
7323 effect->lpVtbl->Release(effect);
7324}
static const DWORD test_effect_skip_constants_blob[]
Definition: effect.c:7205

Referenced by START_TEST().

◆ test_effect_state_manager()

static void test_effect_state_manager ( IDirect3DDevice9 *  device)
static

Definition at line 6490 of file effect.c.

6491{
6492 static const struct test_state_manager_update expected_updates[] =
6493 {
6494 {2, 0, 0},
6495 {2, 1, 0},
6496 {2, 2, 0},
6497 {2, 3, 0},
6498 {2, 4, 0},
6499 {2, 5, 0},
6500 {2, 6, 0},
6501 {2, 7, 0},
6502 {3, 0, 0},
6503 {3, 1, 0},
6504 {3, 2, 0},
6505 {3, 3, 0},
6506 {3, 4, 0},
6507 {3, 5, 0},
6508 {3, 6, 0},
6509 {3, 7, 0},
6510 {4, 28, 0},
6511 {4, 36, 0},
6512 {4, 38, 0},
6513 {4, 158, 0},
6514 {4, 159, 0},
6515 {5, 0, 0},
6516 {5, 259, 0},
6517 {7, 0, 5},
6518 {7, 0, 6},
6519 {7, 1, 5},
6520 {7, 1, 6},
6521 {7, 257, 5},
6522 {7, 257, 6},
6523 {7, 258, 5},
6524 {7, 258, 6},
6525 {7, 259, 5},
6526 {7, 259, 6},
6527 {10, 0, 0},
6528 {11, 0, 34},
6529 {14, 0, 0},
6530 {15, 0, 14},
6531 {16, 0, 1},
6532 {17, 0, 6},
6533 };
6534 static D3DLIGHT9 light_filler =
6535 {D3DLIGHT_DIRECTIONAL, {0.5f, 0.5f, 0.5f, 0.5f}, {0.5f, 0.5f, 0.5f, 0.5f}, {0.5f, 0.5f, 0.5f, 0.5f}};
6536 struct test_manager *state_manager;
6537 unsigned int passes_count, i, n;
6538 ID3DXEffect *effect;
6539 ULONG refcount;
6540 HRESULT hr;
6541
6542 state_manager = calloc(1, sizeof(*state_manager));
6543 test_effect_state_manager_init(state_manager, device);
6544
6545 for (i = 0; i < 8; ++i)
6546 {
6547 hr = IDirect3DDevice9_SetLight(device, i, &light_filler);
6548 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6549 }
6550
6552 NULL, NULL, 0, NULL, &effect, NULL);
6553 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6554
6555 hr = effect->lpVtbl->SetStateManager(effect, &state_manager->ID3DXEffectStateManager_iface);
6556 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6557
6558 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
6559 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6560
6561 hr = effect->lpVtbl->BeginPass(effect, 0);
6562 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6563
6564 hr = effect->lpVtbl->EndPass(effect);
6565 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6566
6567 hr = effect->lpVtbl->End(effect);
6568 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6569
6570 effect->lpVtbl->Release(effect);
6571
6572 qsort(state_manager->update_record, state_manager->update_record_count,
6573 sizeof(*state_manager->update_record), compare_update_record);
6574
6575 ok(ARRAY_SIZE(expected_updates) == state_manager->update_record_count,
6576 "Got %u update records.\n", state_manager->update_record_count);
6577 n = min(ARRAY_SIZE(expected_updates), state_manager->update_record_count);
6578 for (i = 0; i < n; ++i)
6579 {
6580 ok(!memcmp(&expected_updates[i], &state_manager->update_record[i],
6581 sizeof(expected_updates[i])),
6582 "Update record mismatch, expected %s, %lu, %lu, got %s, %lu, %lu.\n",
6583 test_effect_state_manager_state_names[expected_updates[i].state_op],
6584 expected_updates[i].param1, expected_updates[i].param2,
6585 test_effect_state_manager_state_names[state_manager->update_record[i].state_op],
6586 state_manager->update_record[i].param1, state_manager->update_record[i].param2);
6587 }
6588
6589 for (i = 0; i < 8; ++i)
6590 {
6592
6594 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
6595 ok(!memcmp(&light, &light_filler, sizeof(light)), "Light %u mismatch.\n", i);
6596 }
6597
6598 refcount = state_manager->ID3DXEffectStateManager_iface.lpVtbl->Release(
6599 &state_manager->ID3DXEffectStateManager_iface);
6600 ok(!refcount, "State manager was not properly freed, refcount %lu.\n", refcount);
6601}
@ D3DLIGHT_DIRECTIONAL
Definition: d3d8types.h:658
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
static int compare_update_record(const void *a, const void *b)
Definition: effect.c:6478
static const char * test_effect_state_manager_state_names[]
Definition: effect.c:6456
unsigned int update_record_count
Definition: effect.c:6245

Referenced by START_TEST().

◆ test_effect_state_manager_init()

static void test_effect_state_manager_init ( struct test_manager *  state_manager,
IDirect3DDevice9 *  device 
)
static

Definition at line 6419 of file effect.c.

6421{
6422 static const struct ID3DXEffectStateManagerVtbl test_ID3DXEffectStateManager_Vtbl =
6423 {
6424 /*** IUnknown methods ***/
6425 NULL,
6428 /*** ID3DXEffectStateManager methods ***/
6447 };
6448
6449 state_manager->ID3DXEffectStateManager_iface.lpVtbl = &test_ID3DXEffectStateManager_Vtbl;
6450 state_manager->ref = 1;
6451
6453 state_manager->device = device;
6454}
static HRESULT WINAPI test_manager_SetTextureStageState(ID3DXEffectStateManager *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD value)
Definition: effect.c:6347
static HRESULT WINAPI test_manager_SetLight(ID3DXEffectStateManager *iface, DWORD index, const D3DLIGHT9 *light)
Definition: effect.c:6317
static HRESULT WINAPI test_manager_LightEnable(ID3DXEffectStateManager *iface, DWORD index, BOOL enable)
Definition: effect.c:6326
static HRESULT WINAPI test_manager_SetNPatchMode(ID3DXEffectStateManager *iface, FLOAT num_segments)
Definition: effect.c:6359
static HRESULT WINAPI test_manager_SetVertexShader(ID3DXEffectStateManager *iface, struct IDirect3DVertexShader9 *shader)
Definition: effect.c:6371
static HRESULT WINAPI test_manager_SetRenderState(ID3DXEffectStateManager *iface, D3DRENDERSTATETYPE state, DWORD value)
Definition: effect.c:6335
static HRESULT WINAPI test_manager_SetMaterial(ID3DXEffectStateManager *iface, const D3DMATERIAL9 *material)
Definition: effect.c:6311
static ULONG WINAPI test_manager_Release(ID3DXEffectStateManager *iface)
Definition: effect.c:6271
static HRESULT WINAPI test_manager_SetPixelShaderConstantI(ID3DXEffectStateManager *iface, UINT register_index, const INT *constant_data, UINT register_count)
Definition: effect.c:6407
static HRESULT WINAPI test_manager_SetTransform(ID3DXEffectStateManager *iface, D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix)
Definition: effect.c:6305
static HRESULT WINAPI test_manager_SetVertexShaderConstantI(ID3DXEffectStateManager *iface, UINT register_index, const INT *constant_data, UINT register_count)
Definition: effect.c:6383
static HRESULT WINAPI test_manager_SetPixelShaderConstantF(ID3DXEffectStateManager *iface, UINT register_index, const FLOAT *constant_data, UINT register_count)
Definition: effect.c:6401
static ULONG WINAPI test_manager_AddRef(ID3DXEffectStateManager *iface)
Definition: effect.c:6264
static HRESULT WINAPI test_manager_SetFVF(ID3DXEffectStateManager *iface, DWORD format)
Definition: effect.c:6365
static HRESULT WINAPI test_manager_SetPixelShaderConstantB(ID3DXEffectStateManager *iface, UINT register_index, const BOOL *constant_data, UINT register_count)
Definition: effect.c:6413
static HRESULT WINAPI test_manager_SetVertexShaderConstantB(ID3DXEffectStateManager *iface, UINT register_index, const BOOL *constant_data, UINT register_count)
Definition: effect.c:6389
static HRESULT WINAPI test_manager_SetSamplerState(ID3DXEffectStateManager *iface, DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value)
Definition: effect.c:6353
static HRESULT WINAPI test_manager_SetTexture(ID3DXEffectStateManager *iface, DWORD stage, struct IDirect3DBaseTexture9 *texture)
Definition: effect.c:6341
static HRESULT WINAPI test_manager_SetPixelShader(ID3DXEffectStateManager *iface, struct IDirect3DPixelShader9 *shader)
Definition: effect.c:6395
static HRESULT WINAPI test_manager_SetVertexShaderConstantF(ID3DXEffectStateManager *iface, UINT register_index, const FLOAT *constant_data, UINT register_count)
Definition: effect.c:6377
LONG ref
Definition: effect.c:6241

Referenced by test_effect_clone(), and test_effect_state_manager().

◆ test_effect_states()

static void test_effect_states ( IDirect3DDevice9 *  device)
static

Definition at line 3135 of file effect.c.

3136{
3137 static const D3DMATRIX test_mat =
3138 {{{
3139 -1.0f, 0.0f, 0.0f, 0.0f,
3140 0.0f, 0.0f, 0.0f, 0.0f,
3141 0.0f, 0.0f, 0.0f, 0.0f,
3142 0.0f, 0.0f, 0.0f, 0.0f
3143 }}};
3144 static const D3DMATRIX test_mat_camera =
3145 {{{
3146 4.0f, 0.0f, 0.0f, 0.0f,
3147 0.0f, 0.0f, 0.0f, 0.0f,
3148 0.0f, 0.0f, 0.0f, 0.0f,
3149 0.0f, 0.0f, 0.0f, 6.0f
3150 }}};
3151 static const D3DMATRIX test_mat_world1 =
3152 {{{
3153 2.0f, 0.0f, 0.0f, 0.0f,
3154 0.0f, 0.0f, 0.0f, 0.0f,
3155 0.0f, 0.0f, 0.0f, 0.0f,
3156 0.0f, 0.0f, 0.0f, 4.0f
3157 }}};
3158
3159 IDirect3DVertexShader9 *vshader;
3161 ID3DXEffect *effect;
3162 UINT byte_code_size;
3163 D3DXVECTOR4 fvect;
3164 void *byte_code;
3166 D3DMATRIX mat;
3167 UINT npasses;
3168 DWORD value;
3169 HRESULT hr;
3170 BOOL bval;
3171
3173 NULL, NULL, 0, NULL, &effect, NULL);
3174 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3175
3176 hr = effect->lpVtbl->GetDesc(effect, &desc);
3177 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3178 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
3179 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
3180 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
3181 ok(desc.Parameters == 3, "Unexpected value %u.\n", desc.Parameters);
3182
3183 hr = effect->lpVtbl->End(effect);
3184 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3185
3186 hr = effect->lpVtbl->BeginPass(effect, 0);
3187 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
3188
3189 /* State affected in passes saved/restored even if no pass
3190 was performed. States not present in passes are not saved &
3191 restored */
3193 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3195 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3196
3197 hr = effect->lpVtbl->Begin(effect, &npasses, 0);
3198 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3199 ok(npasses == 1, "Unexpected npasses %u.\n", npasses);
3200
3202 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3204 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3205
3206 hr = effect->lpVtbl->End(effect);
3207 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3208
3210 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3211 ok(value == 1, "Unexpected value %lu.\n", value);
3213 ok(value == 2, "Unexpected value %lu.\n", value);
3214
3215 /* Test states application in BeginPass. No states are restored
3216 on EndPass. */
3218 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3220 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3221
3223 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3224 if (hr == D3D_OK)
3225 ok(!bval, "Unexpected bval %#x.\n", bval);
3226
3228 hr = effect->lpVtbl->Begin(effect, NULL, 0);
3229 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3230
3232 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3233 ok(!memcmp(mat.m, test_mat.m, sizeof(mat)), "World matrix does not match.\n");
3234
3236
3237 hr = effect->lpVtbl->BeginPass(effect, 0);
3238 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3239
3241 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3242 ok(!memcmp(mat.m, test_mat_world1.m, sizeof(mat)), "World matrix does not match.\n");
3243
3245 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3246 ok(!memcmp(mat.m, test_mat_camera.m, sizeof(mat)), "View matrix does not match.\n");
3247
3249 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3250 ok(value == 2, "Unexpected value %lu.\n", value);
3251
3253 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3254 ok(vshader != NULL, "Unexpected vshader %p.\n", vshader);
3255 hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size);
3256 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3257 byte_code = calloc(1, byte_code_size);
3258 hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
3259 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3260 ok(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size);
3262 "Incorrect shader selected.\n");
3263 free(byte_code);
3265
3267 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3268 ok(bval, "Unexpected bval %#x.\n", bval);
3270 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3271 ok(light.Position.x == 4.0f && light.Position.y == 5.0f && light.Position.z == 6.0f,
3272 "Unexpected light position (%.8e, %.8e, %.8e).\n", light.Position.x, light.Position.y, light.Position.z);
3273
3274 /* Testing first value only for constants 1, 2 as the rest of the vector seem to
3275 * contain garbage data on native. */
3277 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3278 ok(fvect.x == 3.0f, "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3279 fvect.x, fvect.y, fvect.z, fvect.w);
3281 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3282 ok(fvect.x == 1.0f, "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3283 fvect.x, fvect.y, fvect.z, fvect.w);
3284
3286 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3287 ok(fvect.x == 2.0f && fvect.y == 2.0f && fvect.z == 2.0f && fvect.w == 2.0f,
3288 "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3289 fvect.x, fvect.y, fvect.z, fvect.w);
3290
3292 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3293 ok(fvect.x == 4.0f && fvect.y == 4.0f && fvect.z == 4.0f && fvect.w == 4.0f,
3294 "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3295 fvect.x, fvect.y, fvect.z, fvect.w);
3297 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3298 ok(fvect.x == 0.0f && fvect.y == 0.0f && fvect.z == 0.0f && fvect.w == 0.0f,
3299 "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3300 fvect.x, fvect.y, fvect.z, fvect.w);
3302 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3303 ok(fvect.x == 0.0f && fvect.y == 0.0f && fvect.z == 0.0f && fvect.w == 0.0f,
3304 "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3305 fvect.x, fvect.y, fvect.z, fvect.w);
3307 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3308 ok(!memcmp(&fvect, &fvect_filler, sizeof(fvect_filler)),
3309 "Got unexpected vertex shader constant (%.8e, %.8e, %.8e, %.8e).\n",
3310 fvect.x, fvect.y, fvect.z, fvect.w);
3311
3312 hr = effect->lpVtbl->EndPass(effect);
3313 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3315 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3316 ok(value == 2, "Unexpected value %lu.\n", value);
3317
3319 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3320 ok(value, "Unexpected value %lu.\n", value);
3321
3323 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3324 ok(value == D3DTEXF_LINEAR, "Unexpected sampler 1 mipfilter %lu.\n", value);
3325
3327 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3328 ok(value == 4, "Unexpected texture stage 3 AlphaOp %lu.\n", value);
3329
3330 hr = effect->lpVtbl->End(effect);
3331 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3332
3334 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3335 ok(!memcmp(mat.m, test_mat.m, sizeof(mat)), "World matrix not restored.\n");
3336
3338 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3339 ok(!bval, "Unexpected bval %u.\n", bval);
3340
3341 /* State is not restored if effect is released without End call */
3343 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3344
3345 hr = effect->lpVtbl->Begin(effect, &npasses, 0);
3346 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3347
3349 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3350
3351 effect->lpVtbl->Release(effect);
3352
3354 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
3355 ok(value == 3, "Unexpected value %lu.\n", value);
3356}
@ D3DRS_ZENABLE
Definition: d3d8types.h:729
@ D3DRS_ALPHAFUNC
Definition: d3d8types.h:741
@ D3DRS_BLENDOP
Definition: d3d8types.h:802
@ D3DTEXF_LINEAR
Definition: d3d8types.h:872
@ D3DTSS_ALPHAOP
Definition: d3d8types.h:915
@ D3DTS_VIEW
Definition: d3d8types.h:955
#define D3DTS_WORLDMATRIX(index)
Definition: d3d8types.h:89
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1379
#define IDirect3DDevice9_GetTransform(p, a, b)
Definition: d3d9.h:1380
#define IDirect3DDevice9_GetLightEnable(p, a, b)
Definition: d3d9.h:1389
#define IDirect3DDevice9_GetTextureStageState(p, a, b, c)
Definition: d3d9.h:1401
@ D3DSAMP_MIPFILTER
Definition: d3d9types.h:1239
#define TEST_EFFECT_STATES_VSHADER_POS
Definition: effect.c:3119

Referenced by START_TEST().

◆ test_effect_unsupported_shader()

static void test_effect_unsupported_shader ( void  )
static

Definition at line 7393 of file effect.c.

7394{
7395 IDirect3DVertexShader9 *vshader;
7396 unsigned int passes_count;
7398 UINT byte_code_size;
7399 ID3DXEffect *effect;
7400 void *byte_code;
7401 ULONG refcount;
7402 HWND window;
7403 HRESULT hr;
7404
7405 if (!(device = create_device(&window)))
7406 return;
7407
7409 NULL, NULL, NULL, 0, NULL, &effect, NULL);
7410 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7411
7412 hr = effect->lpVtbl->ValidateTechnique(effect, "missing_technique");
7413 ok(hr == D3DERR_INVALIDCALL, "Got result %#lx.\n", hr);
7414 hr = effect->lpVtbl->ValidateTechnique(effect, "tech0");
7415 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7416
7417 hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7418 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7419 hr = effect->lpVtbl->SetInt(effect, "i", 1);
7420 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7421 hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7422 ok(hr == E_FAIL, "Got result %#lx.\n", hr);
7423 hr = effect->lpVtbl->SetInt(effect, "i", 0);
7424 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7425 hr = effect->lpVtbl->ValidateTechnique(effect, "tech1");
7426 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7427
7428 hr = effect->lpVtbl->SetTechnique(effect, "tech0");
7429 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7430 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
7431 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7432 hr = effect->lpVtbl->BeginPass(effect, 0);
7433 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7434
7436 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK).\n", hr);
7437 ok(!vshader, "Got non NULL vshader.\n");
7438
7439 hr = effect->lpVtbl->EndPass(effect);
7440 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7441 hr = effect->lpVtbl->End(effect);
7442 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7443
7444 hr = effect->lpVtbl->SetTechnique(effect, "tech1");
7445 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7446 hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
7447 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7448 hr = effect->lpVtbl->BeginPass(effect, 0);
7449 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7450
7452 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK).\n", hr);
7453 ok(!!vshader, "Got NULL vshader.\n");
7454 hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size);
7455 ok(hr == D3D_OK, "Got result %lx.\n", hr);
7456 byte_code = calloc(1, byte_code_size);
7457 hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
7458 ok(hr == D3D_OK, "Got result %lx.\n", hr);
7460 "Got unexpected byte code size %u.\n", byte_code_size);
7461 ok(!memcmp(byte_code,
7463 byte_code_size), "Incorrect shader selected.\n");
7464 free(byte_code);
7466
7467 hr = effect->lpVtbl->SetInt(effect, "i", 1);
7468 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7469 hr = effect->lpVtbl->CommitChanges(effect);
7470 ok(hr == D3D_OK, "Got result %#lx.\n", hr);
7472 ok(hr == D3D_OK, "Got result %lx.\n", hr);
7473 ok(!vshader, "Got non NULL vshader.\n");
7474
7475 effect->lpVtbl->Release(effect);
7476
7477 refcount = IDirect3DDevice9_Release(device);
7478 ok(!refcount, "Device has %lu references left.\n", refcount);
7480}
#define TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_LEN
Definition: effect.c:7391
#define TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_POS
Definition: effect.c:7390

Referenced by START_TEST().

◆ test_effect_variable_names()

static void test_effect_variable_names ( IDirect3DDevice9 *  device)
static

Definition at line 2743 of file effect.c.

2744{
2746 ID3DXEffect *effect;
2747 ULONG count;
2748 HRESULT hr;
2749 D3DXHANDLE parameter, p;
2750
2752 sizeof(test_effect_variable_names_blob), NULL, NULL, 0, NULL, &effect, NULL);
2753 ok(hr == D3D_OK, "D3DXCreateEffect failed, got %#lx, expected %#lx\n", hr, D3D_OK);
2754
2755 hr = effect->lpVtbl->GetDesc(effect, &desc);
2756 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
2757 ok(!strcmp(desc.Creator, "D3DX Effect Compiler"), "Unexpected creator %s.\n", desc.Creator);
2758 ok(!desc.Functions, "Unexpected value %u.\n", desc.Functions);
2759 ok(desc.Techniques == 1, "Unexpected value %u.\n", desc.Techniques);
2760 ok(desc.Parameters == 6, "Unexpected value %u.\n", desc.Parameters);
2761
2762 /*
2763 * check invalid calls
2764 * This will crash:
2765 * effect->lpVtbl->GetAnnotationByName(effect, "invalid1", "invalid2");
2766 */
2767 p = effect->lpVtbl->GetParameterByName(effect, NULL, NULL);
2768 ok(p == NULL, "GetParameterByName failed, got %p, expected %p\n", p, NULL);
2769
2770 p = effect->lpVtbl->GetParameterByName(effect, NULL, "invalid1");
2771 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2772
2773 p = effect->lpVtbl->GetParameterByName(effect, "invalid1", NULL);
2774 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2775
2776 p = effect->lpVtbl->GetParameterByName(effect, "invalid1", "invalid2");
2777 ok(p == NULL, "GetParameterByName failed, got %p, expected %p\n", p, NULL);
2778
2779 /* float a; */
2780 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "a");
2781 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2782
2783 p = effect->lpVtbl->GetParameterByName(effect, "a", NULL);
2784 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2785
2786 /* members */
2787 p = effect->lpVtbl->GetParameterByName(effect, NULL, "a.");
2788 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2789
2790 p = effect->lpVtbl->GetParameterByName(effect, "a.", NULL);
2791 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2792
2793 p = effect->lpVtbl->GetParameterByName(effect, "a", ".");
2794 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2795
2796 p = effect->lpVtbl->GetParameterByName(effect, NULL, "a.invalid");
2797 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2798
2799 p = effect->lpVtbl->GetParameterByName(effect, "a.invalid", NULL);
2800 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2801
2802 p = effect->lpVtbl->GetParameterByName(effect, "a", ".invalid");
2803 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2804
2805 p = effect->lpVtbl->GetParameterByName(effect, "a.", "invalid");
2806 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2807
2808 p = effect->lpVtbl->GetParameterByName(effect, "a", "invalid");
2809 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2810
2811 /* elements */
2812 p = effect->lpVtbl->GetParameterByName(effect, NULL, "a[]");
2813 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2814
2815 p = effect->lpVtbl->GetParameterByName(effect, "a[]", NULL);
2816 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2817
2818 p = effect->lpVtbl->GetParameterByName(effect, NULL, "a[0]");
2819 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2820
2821 p = effect->lpVtbl->GetParameterByName(effect, "a[0]", NULL);
2822 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2823
2824 p = effect->lpVtbl->GetParameterByName(effect, "a", "[0]");
2825 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2826
2827 p = effect->lpVtbl->GetParameterElement(effect, "a", 0);
2828 ok(p == NULL, "GetParameterElement failed, got %p\n", p);
2829
2830 /* annotations */
2831 p = effect->lpVtbl->GetParameterByName(effect, NULL, "a@");
2832 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2833
2834 p = effect->lpVtbl->GetParameterByName(effect, "a@", NULL);
2835 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2836
2837 p = effect->lpVtbl->GetParameterByName(effect, "a", "@invalid");
2838 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2839
2840 p = effect->lpVtbl->GetParameterByName(effect, "a@", "invalid");
2841 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2842
2843 p = effect->lpVtbl->GetParameterByName(effect, NULL, "a@invalid");
2844 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2845
2846 p = effect->lpVtbl->GetParameterByName(effect, "a@invalid", NULL);
2847 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2848
2849 p = effect->lpVtbl->GetAnnotationByName(effect, "a", NULL);
2850 ok(p == NULL, "GetAnnotationByName failed, got %p\n", p);
2851
2852 p = effect->lpVtbl->GetAnnotationByName(effect, "a", "invalid");
2853 ok(p == NULL, "GetAnnotationByName failed, got %p\n", p);
2854
2855 p = effect->lpVtbl->GetAnnotation(effect, "a", 0);
2856 ok(p == NULL, "GetAnnotation failed, got %p\n", p);
2857
2858 /* float b[1]; */
2859 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "b");
2860 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2861
2862 p = effect->lpVtbl->GetParameterByName(effect, "b", NULL);
2863 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2864
2865 /* elements */
2866 p = effect->lpVtbl->GetParameterByName(effect, NULL, "b[]");
2867 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2868
2869 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "b[0]");
2870 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2871
2872 p = effect->lpVtbl->GetParameterByName(effect, "b[0]", NULL);
2873 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2874
2875 p = effect->lpVtbl->GetParameterElement(effect, "b", 0);
2876 ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter);
2877
2878 p = effect->lpVtbl->GetParameterByName(effect, "b", "[0]");
2879 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2880
2881 p = effect->lpVtbl->GetParameterByName(effect, NULL, "b[1]");
2882 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2883
2884 p = effect->lpVtbl->GetParameterElement(effect, "b", 1);
2885 ok(p == NULL, "GetParameterElement failed, got %p\n", p);
2886
2887 /* float c <float d = 3;>; */
2888 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "c");
2889 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2890
2891 p = effect->lpVtbl->GetParameterByName(effect, "c", NULL);
2892 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2893
2894 /* annotations */
2895 p = effect->lpVtbl->GetParameterByName(effect, "c", "@d");
2896 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2897
2898 p = effect->lpVtbl->GetParameterByName(effect, "c@", "d");
2899 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2900
2901 p = effect->lpVtbl->GetParameterByName(effect, NULL, "c@invalid");
2902 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2903
2904 p = effect->lpVtbl->GetParameterByName(effect, "c@invalid", NULL);
2905 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2906
2907 p = effect->lpVtbl->GetAnnotationByName(effect, "c", NULL);
2908 ok(p == NULL, "GetAnnotationByName failed, got %p\n", p);
2909
2910 p = effect->lpVtbl->GetAnnotationByName(effect, "c", "invalid");
2911 ok(p == NULL, "GetAnnotationByName failed, got %p\n", p);
2912
2913 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "c@d");
2914 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2915
2916 p = effect->lpVtbl->GetParameterByName(effect, "c@d", NULL);
2917 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2918
2919 p = effect->lpVtbl->GetAnnotationByName(effect, "c", "d");
2920 ok(parameter == p, "GetAnnotationByName failed, got %p, expected %p\n", p, parameter);
2921
2922 p = effect->lpVtbl->GetAnnotation(effect, "c", 0);
2923 ok(parameter == p, "GetAnnotation failed, got %p, expected %p\n", p, parameter);
2924
2925 p = effect->lpVtbl->GetAnnotation(effect, "c", 1);
2926 ok(p == NULL, "GetAnnotation failed, got %p\n", p);
2927
2928 /* struct {float e;} f; */
2929 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "f");
2930 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2931
2932 p = effect->lpVtbl->GetParameterByName(effect, "f", NULL);
2933 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2934
2935 /* members */
2936 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "f.e");
2937 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2938
2939 p = effect->lpVtbl->GetParameterByName(effect, "f.e", NULL);
2940 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2941
2942 p = effect->lpVtbl->GetParameterByName(effect, "f", "e");
2943 ok(parameter == p, "GetParameterByName failed, got %p, expected %p\n", p, parameter);
2944
2945 p = effect->lpVtbl->GetParameterByName(effect, "f", ".e");
2946 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2947
2948 p = effect->lpVtbl->GetParameterByName(effect, "f.", "e");
2949 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2950
2951 p = effect->lpVtbl->GetParameterByName(effect, "f.invalid", NULL);
2952 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2953
2954 p = effect->lpVtbl->GetParameterByName(effect, NULL, "f.invalid");
2955 ok(p == NULL, "GetParameterByName failed, got %p\n", p);
2956
2957 /* float g <float h[1] = {3};>; */
2958 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "g@h[0]");
2959 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2960
2961 p = effect->lpVtbl->GetAnnotationByName(effect, "g", "h[0]");
2962 ok(parameter == p, "GetAnnotationByName failed, got %p, expected %p\n", p, parameter);
2963
2964 p = effect->lpVtbl->GetParameterElement(effect, "g@h", 0);
2965 ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter);
2966
2967 p = effect->lpVtbl->GetParameterElement(effect, effect->lpVtbl->GetAnnotation(effect, "g", 0), 0);
2968 ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter);
2969
2970 /* struct s {float j;}; float i <s k[1] = {4};>; */
2971 parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "i@k[0].j");
2972 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2973
2974 p = effect->lpVtbl->GetAnnotationByName(effect, "i", "k[0].j");
2975 ok(parameter == p, "GetAnnotationByName failed, got %p, expected %p\n", p, parameter);
2976
2977 p = effect->lpVtbl->GetParameterByName(effect, effect->lpVtbl->GetParameterElement(effect, "i@k", 0), "j");
2978 ok(parameter == p, "GetParameterElement failed, got %p, expected %p\n", p, parameter);
2979
2980 /* technique t <s l[1] = {5};> */
2981 parameter = effect->lpVtbl->GetAnnotationByName(effect, "t", "l[0].j");
2982 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2983
2984 /* pass p <s m[1] = {6};> */
2985 parameter = effect->lpVtbl->GetAnnotationByName(effect, effect->lpVtbl->GetPassByName(effect, "t", "p"), "m[0].j");
2986 ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
2987
2988 count = effect->lpVtbl->Release(effect);
2989 ok(!count, "Release failed %lu\n", count);
2990}

Referenced by START_TEST().

◆ test_isparameterused_children()

static void test_isparameterused_children ( unsigned int  line,
ID3DXEffect *  effect,
D3DXHANDLE  tech,
D3DXHANDLE  param 
)
static

Definition at line 5262 of file effect.c.

5264{
5266 D3DXHANDLE param_child;
5267 unsigned int i, child_count;
5268 HRESULT hr;
5269
5270 hr = effect->lpVtbl->GetParameterDesc(effect, param, &desc);
5271 ok_(__FILE__, line)(hr == D3D_OK, "GetParameterDesc failed, result %#lx.\n", hr);
5272 child_count = desc.Elements ? desc.Elements : desc.StructMembers;
5273 for (i = 0; i < child_count; ++i)
5274 {
5275 param_child = desc.Elements ? effect->lpVtbl->GetParameterElement(effect, param, i)
5276 : effect->lpVtbl->GetParameter(effect, param, i);
5277 ok_(__FILE__, line)(!!param_child, "Failed getting child parameter %s[%u].\n", desc.Name, i);
5278 ok_(__FILE__, line)(!effect->lpVtbl->IsParameterUsed(effect, param_child, tech),
5279 "Unexpected IsParameterUsed() result for %s[%u].\n", desc.Name, i);
5280 test_isparameterused_children(line, effect, tech, param_child);
5281 }
5282}
static void test_isparameterused_children(unsigned int line, ID3DXEffect *effect, D3DXHANDLE tech, D3DXHANDLE param)
Definition: effect.c:5262

Referenced by test_isparameterused_children(), and test_isparameterused_param_with_children_().

◆ test_isparameterused_param_with_children_()

static void test_isparameterused_param_with_children_ ( unsigned int  line,
ID3DXEffect *  effect,
ID3DXEffect *  effect2,
D3DXHANDLE  tech,
const char *  name,
BOOL  expected_result 
)
static

Definition at line 5286 of file effect.c.

5288{
5290
5291 ok_(__FILE__, line)(effect->lpVtbl->IsParameterUsed(effect, (D3DXHANDLE)name, tech)
5292 == expected_result, "Unexpected IsParameterUsed() result for %s (referenced by name).\n", name);
5293
5294 if (effect2)
5295 param = effect2->lpVtbl->GetParameterByName(effect2, NULL, name);
5296 else
5297 param = effect->lpVtbl->GetParameterByName(effect, NULL, name);
5298 ok_(__FILE__, line)(!!param, "GetParameterByName failed for %s.\n", name);
5299
5300 ok_(__FILE__, line)(effect->lpVtbl->IsParameterUsed(effect, param, tech) == expected_result,
5301 "Unexpected IsParameterUsed() result for %s (referenced by handle).\n", name);
5302
5304}

◆ test_manager_AddRef()

static ULONG WINAPI test_manager_AddRef ( ID3DXEffectStateManager *  iface)
static

Definition at line 6264 of file effect.c.

6265{
6266 struct test_manager *state_manager = impl_from_ID3DXEffectStateManager(iface);
6267
6268 return InterlockedIncrement(&state_manager->ref);
6269}
#define InterlockedIncrement
Definition: armddk.h:53
static struct test_manager * impl_from_ID3DXEffectStateManager(ID3DXEffectStateManager *iface)
Definition: effect.c:6251

Referenced by test_effect_state_manager_init().

◆ test_manager_LightEnable()

static HRESULT WINAPI test_manager_LightEnable ( ID3DXEffectStateManager *  iface,
DWORD  index,
BOOL  enable 
)
static

Definition at line 6326 of file effect.c.

6328{
6329 struct test_manager *state_manager = impl_from_ID3DXEffectStateManager(iface);
6330
6332 return test_process_set_state(iface, 3, index, 0);
6333}
#define IDirect3DDevice9_LightEnable(p, a, b)
Definition: d3d9.h:1388
GLboolean enable
Definition: glext.h:11120
static HRESULT test_process_set_state(ID3DXEffectStateManager *iface, unsigned int state_op, DWORD param1, DWORD param2)
Definition: effect.c:6284

Referenced by test_effect_state_manager_init().

◆ test_manager_Release()

static ULONG WINAPI test_manager_Release ( ID3DXEffectStateManager *  iface)
static

Definition at line 6271 of file effect.c.

6272{
6273 struct test_manager *state_manager = impl_from_ID3DXEffectStateManager(iface);
6274 ULONG ref = InterlockedDecrement(&state_manager->ref);
6275
6276 if (!ref)
6277 {
6278 free_test_effect_state_manager(state_manager);
6279 free(state_manager);
6280 }
6281 return ref;
6282}
#define InterlockedDecrement
Definition: armddk.h:52
static void free_test_effect_state_manager(struct test_manager *state_manager)
Definition: effect.c:6256
Definition: send.c:48

Referenced by test_effect_state_manager_init().

◆ test_manager_SetFVF()

static HRESULT WINAPI test_manager_SetFVF ( ID3DXEffectStateManager *  iface,
DWORD  format 
)
static

Definition at line 6365 of file effect.c.

6367{
6368 return test_process_set_state(iface, 9, 0, 0);
6369}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetLight()

static HRESULT WINAPI test_manager_SetLight ( ID3DXEffectStateManager *  iface,
DWORD  index,
const D3DLIGHT9 *  light 
)
static

Definition at line 6317 of file effect.c.

6319{
6320 struct test_manager *state_manager = impl_from_ID3DXEffectStateManager(iface);
6321
6322 IDirect3DDevice9_SetLight(state_manager->device, index, light);
6323 return test_process_set_state(iface, 2, index, 0);
6324}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetMaterial()

static HRESULT WINAPI test_manager_SetMaterial ( ID3DXEffectStateManager *  iface,
const D3DMATERIAL9 *  material 
)
static

Definition at line 6311 of file effect.c.

6313{
6314 return test_process_set_state(iface, 1, 0, 0);
6315}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetNPatchMode()

static HRESULT WINAPI test_manager_SetNPatchMode ( ID3DXEffectStateManager *  iface,
FLOAT  num_segments 
)
static

Definition at line 6359 of file effect.c.

6361{
6362 return test_process_set_state(iface, 8, 0, 0);
6363}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetPixelShader()

static HRESULT WINAPI test_manager_SetPixelShader ( ID3DXEffectStateManager *  iface,
struct IDirect3DPixelShader9 *  shader 
)
static

Definition at line 6395 of file effect.c.

6397{
6398 return test_process_set_state(iface, 14, 0, 0);
6399}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetPixelShaderConstantB()

static HRESULT WINAPI test_manager_SetPixelShaderConstantB ( ID3DXEffectStateManager *  iface,
UINT  register_index,
const BOOL *  constant_data,
UINT  register_count 
)
static

Definition at line 6413 of file effect.c.

6415{
6416 return test_process_set_state(iface, 17, register_index, register_count);
6417}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetPixelShaderConstantF()

static HRESULT WINAPI test_manager_SetPixelShaderConstantF ( ID3DXEffectStateManager *  iface,
UINT  register_index,
const FLOAT *  constant_data,
UINT  register_count 
)
static

Definition at line 6401 of file effect.c.

6403{
6404 return test_process_set_state(iface, 15, register_index, register_count);
6405}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetPixelShaderConstantI()

static HRESULT WINAPI test_manager_SetPixelShaderConstantI ( ID3DXEffectStateManager *  iface,
UINT  register_index,
const INT *  constant_data,
UINT  register_count 
)
static

Definition at line 6407 of file effect.c.

6409{
6410 return test_process_set_state(iface, 16, register_index, register_count);
6411}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetRenderState()

static HRESULT WINAPI test_manager_SetRenderState ( ID3DXEffectStateManager *  iface,
D3DRENDERSTATETYPE  state,
DWORD  value 
)
static

Definition at line 6335 of file effect.c.

6337{
6338 return test_process_set_state(iface, 4, state, 0);
6339}
static int state
Definition: maze.c:121

Referenced by test_effect_state_manager_init().

◆ test_manager_SetSamplerState()

static HRESULT WINAPI test_manager_SetSamplerState ( ID3DXEffectStateManager *  iface,
DWORD  sampler,
D3DSAMPLERSTATETYPE  type,
DWORD  value 
)
static

Definition at line 6353 of file effect.c.

6355{
6356 return test_process_set_state(iface, 7, sampler, type);
6357}
GLuint sampler
Definition: glext.h:7283

Referenced by test_effect_state_manager_init().

◆ test_manager_SetTexture()

static HRESULT WINAPI test_manager_SetTexture ( ID3DXEffectStateManager *  iface,
DWORD  stage,
struct IDirect3DBaseTexture9 *  texture 
)
static

Definition at line 6341 of file effect.c.

6343{
6344 return test_process_set_state(iface, 5, stage, 0);
6345}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetTextureStageState()

static HRESULT WINAPI test_manager_SetTextureStageState ( ID3DXEffectStateManager *  iface,
DWORD  stage,
D3DTEXTURESTAGESTATETYPE  type,
DWORD  value 
)
static

Definition at line 6347 of file effect.c.

6349{
6350 return test_process_set_state(iface, 6, stage, type);
6351}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetTransform()

static HRESULT WINAPI test_manager_SetTransform ( ID3DXEffectStateManager *  iface,
D3DTRANSFORMSTATETYPE  state,
const D3DMATRIX *  matrix 
)
static

Definition at line 6305 of file effect.c.

6307{
6308 return test_process_set_state(iface, 0, state, 0);
6309}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetVertexShader()

static HRESULT WINAPI test_manager_SetVertexShader ( ID3DXEffectStateManager *  iface,
struct IDirect3DVertexShader9 *  shader 
)
static

Definition at line 6371 of file effect.c.

6373{
6374 return test_process_set_state(iface, 10, 0, 0);
6375}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetVertexShaderConstantB()

static HRESULT WINAPI test_manager_SetVertexShaderConstantB ( ID3DXEffectStateManager *  iface,
UINT  register_index,
const BOOL *  constant_data,
UINT  register_count 
)
static

Definition at line 6389 of file effect.c.

6391{
6392 return test_process_set_state(iface, 13, register_index, register_count);
6393}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetVertexShaderConstantF()

static HRESULT WINAPI test_manager_SetVertexShaderConstantF ( ID3DXEffectStateManager *  iface,
UINT  register_index,
const FLOAT *  constant_data,
UINT  register_count 
)
static

Definition at line 6377 of file effect.c.

6379{
6380 return test_process_set_state(iface, 11, register_index, register_count);
6381}

Referenced by test_effect_state_manager_init().

◆ test_manager_SetVertexShaderConstantI()

static HRESULT WINAPI test_manager_SetVertexShaderConstantI ( ID3DXEffectStateManager *  iface,
UINT  register_index,
const INT *  constant_data,
UINT  register_count 
)
static

Definition at line 6383 of file effect.c.

6385{
6386 return test_process_set_state(iface, 12, register_index, register_count);
6387}

Referenced by test_effect_state_manager_init().

◆ test_process_set_state()

static HRESULT test_process_set_state ( ID3DXEffectStateManager *  iface,
unsigned int  state_op,
DWORD  param1,
DWORD  param2 
)
static

Definition at line 6284 of file effect.c.

6286{
6287 struct test_manager *state_manager = impl_from_ID3DXEffectStateManager(iface);
6288
6289 if (state_manager->update_record_count == state_manager->update_record_size)
6290 {
6291 if (!state_manager->update_record_size)
6293 else
6294 state_manager->update_record_size *= 2;
6295 state_manager->update_record = realloc(state_manager->update_record,
6296 sizeof(*state_manager->update_record) * state_manager->update_record_size);
6297 }
6298 state_manager->update_record[state_manager->update_record_count].state_op = state_op;
6299 state_manager->update_record[state_manager->update_record_count].param1 = param1;
6300 state_manager->update_record[state_manager->update_record_count].param2 = param2;
6301 ++state_manager->update_record_count;
6302 return D3D_OK;
6303}
#define realloc
Definition: debug_ros.c:6
#define INITIAL_UPDATE_RECORD_SIZE
Definition: effect.c:6249
unsigned int update_record_size
Definition: effect.c:6246

Referenced by test_manager_LightEnable(), test_manager_SetFVF(), test_manager_SetLight(), test_manager_SetMaterial(), test_manager_SetNPatchMode(), test_manager_SetPixelShader(), test_manager_SetPixelShaderConstantB(), test_manager_SetPixelShaderConstantF(), test_manager_SetPixelShaderConstantI(), test_manager_SetRenderState(), test_manager_SetSamplerState(), test_manager_SetTexture(), test_manager_SetTextureStageState(), test_manager_SetTransform(), test_manager_SetVertexShader(), test_manager_SetVertexShaderConstantB(), test_manager_SetVertexShaderConstantF(), and test_manager_SetVertexShaderConstantI().

◆ test_refcount()

static void test_refcount ( void  )
static

Definition at line 7913 of file effect.c.

7914{
7915 IDirect3DTexture9 *texture, *cur_texture, *managed_texture, *sysmem_texture;
7916 unsigned int passes_count;
7918 ID3DXEffect *effect;
7919 ULONG refcount;
7920 HWND window;
7921 HRESULT hr;
7922
7923 if (!(device = create_device(&window)))
7924 return;
7925
7927 ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
7928
7931 D3DXFX_DONOTSAVESTATE, NULL, &effect, NULL);
7932 ok(hr == D3D_OK, "Failed to create effect, hr %#lx.\n", hr);
7933
7934 hr = effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)texture);
7935 ok(hr == D3D_OK, "Failed to set texture parameter, hr %#lx.\n", hr);
7936
7937 hr = effect->lpVtbl->Begin(effect, &passes_count, D3DXFX_DONOTSAVESTATE);
7938 ok(hr == D3D_OK, "Begin() failed, hr %#lx.\n", hr);
7939
7940 hr = effect->lpVtbl->BeginPass(effect, 0);
7941 ok(hr == D3D_OK, "BeginPass() failed, hr %#lx.\n", hr);
7942
7943 IDirect3DDevice9_GetTexture(device, 0, (IDirect3DBaseTexture9 **)&cur_texture);
7944 ok(cur_texture == texture, "Unexpected current texture %p.\n", cur_texture);
7945 IDirect3DTexture9_Release(cur_texture);
7946
7948 effect->lpVtbl->CommitChanges(effect);
7949
7950 IDirect3DDevice9_GetTexture(device, 0, (IDirect3DBaseTexture9 **)&cur_texture);
7951 ok(cur_texture == NULL, "Unexpected current texture %p.\n", cur_texture);
7952
7953 hr = effect->lpVtbl->EndPass(effect);
7954 ok(hr == D3D_OK, "EndPass() failed, hr %#lx.\n", hr);
7955
7956 hr = effect->lpVtbl->BeginPass(effect, 0);
7957 ok(hr == D3D_OK, "BeginPass() failed, hr %#lx.\n", hr);
7958
7959 IDirect3DDevice9_GetTexture(device, 0, (IDirect3DBaseTexture9 **)&cur_texture);
7960 ok(cur_texture == texture, "Unexpected current texture %p.\n", cur_texture);
7961 IDirect3DTexture9_Release(cur_texture);
7962
7963 hr = effect->lpVtbl->EndPass(effect);
7964 ok(hr == D3D_OK, "EndPass() failed, hr %#lx.\n", hr);
7965 hr = effect->lpVtbl->End(effect);
7966 ok(hr == D3D_OK, "End() failed, hr %#lx.\n", hr);
7967
7968 IDirect3DDevice9_GetTexture(device, 0, (IDirect3DBaseTexture9 **)&cur_texture);
7969 ok(cur_texture == texture, "Unexpected current texture %p.\n", cur_texture);
7970 IDirect3DTexture9_Release(cur_texture);
7971 refcount = get_texture_refcount(texture);
7972 ok(refcount == 2, "Unexpected texture refcount %lu.\n", refcount);
7973
7974 hr = effect->lpVtbl->OnLostDevice(effect);
7975 ok(hr == D3D_OK, "OnLostDevice() failed, hr %#lx.\n", hr);
7976 refcount = get_texture_refcount(texture);
7977 ok(refcount == 1, "Unexpected texture refcount %lu.\n", refcount);
7978
7980 &managed_texture, NULL);
7981 ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
7982 effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)managed_texture);
7983
7984 refcount = get_texture_refcount(managed_texture);
7985 ok(refcount == 2, "Unexpected texture refcount %lu.\n", refcount);
7986 hr = effect->lpVtbl->OnLostDevice(effect);
7987 ok(hr == D3D_OK, "OnLostDevice() failed, hr %#lx.\n", hr);
7988 refcount = get_texture_refcount(managed_texture);
7989 ok(refcount == 2, "Unexpected texture refcount %lu.\n", refcount);
7990
7992 &sysmem_texture, NULL);
7993 ok(hr == D3D_OK, "Failed to create texture, hr %#lx.\n", hr);
7994 effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)sysmem_texture);
7995
7996 refcount = get_texture_refcount(managed_texture);
7997 ok(refcount == 1, "Unexpected texture refcount %lu.\n", refcount);
7998 IDirect3DTexture9_Release(managed_texture);
7999 refcount = get_texture_refcount(sysmem_texture);
8000 ok(refcount == 2, "Unexpected texture refcount %lu.\n", refcount);
8001 hr = effect->lpVtbl->OnLostDevice(effect);
8002 ok(hr == D3D_OK, "OnLostDevice() failed, hr %#lx.\n", hr);
8003 refcount = get_texture_refcount(sysmem_texture);
8004 ok(refcount == 2, "Unexpected texture refcount %lu.\n", refcount);
8005
8006 effect->lpVtbl->Release(effect);
8007
8008 refcount = get_texture_refcount(sysmem_texture);
8009 ok(refcount == 1, "Unexpected texture refcount %lu.\n", refcount);
8010 IDirect3DTexture9_Release(sysmem_texture);
8011
8012 IDirect3DDevice9_GetTexture(device, 0, (IDirect3DBaseTexture9 **)&cur_texture);
8013 ok(cur_texture == texture, "Unexpected current texture %p.\n", cur_texture);
8014 IDirect3DTexture9_Release(cur_texture);
8015 refcount = get_texture_refcount(texture);
8016 ok(refcount == 1, "Unexpected texture refcount %lu.\n", refcount);
8018
8019 refcount = IDirect3DDevice9_Release(device);
8020 ok(!refcount, "Device has %lu references left.\n", refcount);
8022}
@ D3DPOOL_SYSTEMMEM
Definition: d3d8types.h:711
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
#define IDirect3DDevice9_GetTexture(p, a, b)
Definition: d3d9.h:1399
#define IDirect3DDevice9_SetTexture(p, a, b)
Definition: d3d9.h:1400
static unsigned int get_texture_refcount(IDirect3DTexture9 *iface)
Definition: effect.c:7907

Referenced by START_TEST().

Variable Documentation

◆ blob

Definition at line 1152 of file effect.c.

◆ blob_size

◆ comment

const char* comment

Definition at line 4464 of file effect.c.

◆ d3dxinclude_vtbl

const struct ID3DXIncludeVtbl d3dxinclude_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3dxinclude_close(ID3DXInclude *iface, const void *data)
Definition: effect.c:8106
static HRESULT WINAPI d3dxinclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes)
Definition: effect.c:8024

Definition at line 8112 of file effect.c.

Referenced by test_create_effect_from_file().

◆ effect_desc

const char effect_desc[]
static
Initial value:
=
"Technique\n"
"{\n"
"}\n"

Definition at line 232 of file effect.c.

Referenced by test_create_effect_and_pool(), test_create_effect_compiler(), and test_effect_find_next_valid_technique().

◆ fvect_filler

◆ res

◆ res_count

UINT res_count

Definition at line 1155 of file effect.c.

Referenced by test_effect_parameter_value().

◆ result

Definition at line 4466 of file effect.c.

Referenced by test_effect_preshader_ops().

◆ temp_path

char temp_path[MAX_PATH]
static

Definition at line 175 of file effect.c.

Referenced by create_directory(), create_file(), delete_directory(), and delete_file().

◆ test_effect_null_shader_blob

const DWORD test_effect_null_shader_blob[]
static
Initial value:
=
{
0xfeff0901, 0x000000b4, 0x00000000, 0x00000010, 0x00000004, 0x00000020, 0x00000000, 0x00000002,
0x00000001, 0x00000002, 0x00000007, 0x615f7376, 0x00007272, 0x00000002, 0x00000000, 0x0000004c,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000002, 0x00000069, 0x00000000,
0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000003,
0x00003070, 0x00000006, 0x68636574, 0x00000030, 0x00000003, 0x00000010, 0x00000004, 0x00000000,
0x00000000, 0x00000000, 0x00000003, 0x00003070, 0x00000006, 0x68636574, 0x00000031, 0x00000002,
0x00000002, 0x00000005, 0x00000004, 0x00000004, 0x00000018, 0x00000000, 0x00000000, 0x0000002c,
0x00000048, 0x00000000, 0x00000000, 0x0000007c, 0x00000000, 0x00000001, 0x00000074, 0x00000000,
0x00000001, 0x00000092, 0x00000000, 0x00000058, 0x00000054, 0x000000a8, 0x00000000, 0x00000001,
0x000000a0, 0x00000000, 0x00000001, 0x00000092, 0x00000000, 0x0000008c, 0x00000088, 0x00000002,
0x00000001, 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000001, 0x00000000, 0xffffffff,
0x00000000, 0x00000002, 0x000000e4, 0x00000008, 0x615f7376, 0x00007272, 0x46580200, 0x0023fffe,
0x42415443, 0x0000001c, 0x00000057, 0x46580200, 0x00000001, 0x0000001c, 0x00000100, 0x00000054,
0x00000030, 0x00000002, 0x00000001, 0x00000034, 0x00000044, 0xabab0069, 0x00020000, 0x00010001,
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4d007874, 0x6f726369,
0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
0x392e3932, 0x332e3235, 0x00313131, 0x0002fffe, 0x54494c43, 0x00000000, 0x000cfffe, 0x434c5846,
0x00000001, 0x10000001, 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000004,
0x00000000, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff,
}

Definition at line 7502 of file effect.c.

Referenced by test_effect_null_shader().

◆ test_effect_parameter_value_blob_float

const DWORD test_effect_parameter_value_blob_float[]
static

Definition at line 506 of file effect.c.

Referenced by test_effect_parameter_block().

◆ test_effect_parameter_value_blob_int

const DWORD test_effect_parameter_value_blob_int[]
static

Definition at line 811 of file effect.c.

◆ test_effect_parameter_value_blob_object

const DWORD test_effect_parameter_value_blob_object[]
static
Initial value:
=
{
0xfeff0901, 0x00000100, 0x00000000, 0x00000004, 0x00000004, 0x0000001c, 0x00000000, 0x00000000,
0x00000001, 0x00000002, 0x00000073, 0x00000004, 0x00000004, 0x00000040, 0x00000000, 0x00000002,
0x00000002, 0x00000003, 0x00000004, 0x00325f73, 0x00000007, 0x00000004, 0x00000060, 0x00000000,
0x00000000, 0x00000004, 0x00000004, 0x00786574, 0x00000010, 0x00000004, 0x00000080, 0x00000000,
0x00000000, 0x00000005, 0x00000002, 0x00000076, 0x00000010, 0x00000004, 0x000000a4, 0x00000000,
0x00000002, 0x00000006, 0x00000007, 0x00000004, 0x00325f76, 0x0000000f, 0x00000004, 0x000000c4,
0x00000000, 0x00000000, 0x00000008, 0x00000002, 0x00000070, 0x0000000f, 0x00000004, 0x000000e8,
0x00000000, 0x00000002, 0x00000009, 0x0000000a, 0x00000004, 0x00325f70, 0x00000002, 0x00000070,
0x00000002, 0x00000074, 0x00000007, 0x00000001, 0x00000007, 0x0000000b, 0x00000004, 0x00000018,
0x00000000, 0x00000000, 0x00000024, 0x00000038, 0x00000000, 0x00000000, 0x00000048, 0x0000005c,
0x00000000, 0x00000000, 0x00000068, 0x0000007c, 0x00000000, 0x00000000, 0x00000088, 0x0000009c,
0x00000000, 0x00000000, 0x000000ac, 0x000000c0, 0x00000000, 0x00000000, 0x000000cc, 0x000000e0,
0x00000000, 0x00000000, 0x000000f8, 0x00000000, 0x00000001, 0x000000f0, 0x00000000, 0x00000000,
0x0000000a, 0x00000000, 0x00000009, 0x00000000, 0x0000000a, 0x00000000, 0x00000008, 0x00000000,
0x00000006, 0x00000000, 0x00000007, 0x00000000, 0x00000005, 0x00000000, 0x00000004, 0x00000000,
0x00000002, 0x00000006, 0x74736574, 0x00000031, 0x00000003, 0x00000006, 0x74736574, 0x00000032,
0x00000001, 0x00000005, 0x74736574, 0x00000000,
}

Definition at line 1069 of file effect.c.

Referenced by test_effect_setvalue_object().

◆ test_effect_parameter_value_blob_special

const DWORD test_effect_parameter_value_blob_special[]
static
Initial value:
=
{
0xfeff0901, 0x00000150, 0x00000000, 0x00000003, 0x00000001, 0x0000002c, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0xc0466666, 0x43193333, 0x438da666, 0x00000003, 0x00003366, 0x00000003,
0x00000001, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0xc1f8cccd, 0xc1f9999a,
0xc1fa6666, 0x00000006, 0x696d3366, 0x0000006e, 0x00000003, 0x00000001, 0x00000090, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x43a00ccd, 0x43a0199a, 0x43a02666, 0x00000006, 0x616d3366,
0x00000078, 0x00000003, 0x00000001, 0x000000c8, 0x00000000, 0x00000000, 0x00000004, 0x00000001,
0xc0833333, 0x431a3333, 0x438e2666, 0x4209999a, 0x00000003, 0x00003466, 0x00000003, 0x00000001,
0x000000fc, 0x00000000, 0x00000000, 0x00000004, 0x00000001, 0xc2246666, 0xc224cccd, 0xc2253333,
0xc225999a, 0x00000006, 0x696d3466, 0x0000006e, 0x00000003, 0x00000001, 0x00000134, 0x00000000,
0x00000000, 0x00000004, 0x00000001, 0x43d20ccd, 0x4228cccd, 0x43d22666, 0x43d23333, 0x00000006,
0x616d3466, 0x00000078, 0x00000002, 0x00000070, 0x00000002, 0x00000074, 0x00000006, 0x00000001,
0x00000001, 0x00000001, 0x00000004, 0x00000020, 0x00000000, 0x00000000, 0x00000034, 0x00000050,
0x00000000, 0x00000000, 0x00000068, 0x00000084, 0x00000000, 0x00000000, 0x0000009c, 0x000000b8,
0x00000000, 0x00000000, 0x000000d0, 0x000000ec, 0x00000000, 0x00000000, 0x00000108, 0x00000124,
0x00000000, 0x00000000, 0x00000148, 0x00000000, 0x00000001, 0x00000140, 0x00000000, 0x00000000,
0x00000000, 0x00000000,
}

Definition at line 1113 of file effect.c.

◆ 

const struct { ... } test_effect_parameter_value_data[]
Initial value:
=
{
}
#define ADD_PARAMETER_VALUE(x)
Definition: effect.c:1143

Referenced by test_effect_parameter_value().

◆ test_effect_parameter_value_result_float

const struct test_effect_parameter_value_result test_effect_parameter_value_result_float[]
static

Definition at line 625 of file effect.c.

◆ test_effect_parameter_value_result_int

const struct test_effect_parameter_value_result test_effect_parameter_value_result_int[]
static

Definition at line 930 of file effect.c.

◆ test_effect_parameter_value_result_object

const struct test_effect_parameter_value_result test_effect_parameter_value_result_object[]
static
Initial value:
=
{
{ "s", D3DXPC_OBJECT, D3DXPT_STRING, 0, 0, 0, sizeof(void *) },
{ "s_2", D3DXPC_OBJECT, D3DXPT_STRING, 0, 0, 2, 2 * sizeof(void *) },
{ "tex", D3DXPC_OBJECT, D3DXPT_TEXTURE2D, 0, 0, 0, sizeof(void *) },
{ "v", D3DXPC_OBJECT, D3DXPT_VERTEXSHADER, 0, 0, 0, sizeof(void *) },
{ "v_2", D3DXPC_OBJECT, D3DXPT_VERTEXSHADER, 0, 0, 2, 2 * sizeof(void *) },
{ "p", D3DXPC_OBJECT, D3DXPT_PIXELSHADER, 0, 0, 0, sizeof(void *) },
{ "p_2", D3DXPC_OBJECT, D3DXPT_PIXELSHADER, 0, 0, 2, 2 * sizeof(void *) },
}

Definition at line 1090 of file effect.c.

◆ test_effect_parameter_value_result_special

const struct test_effect_parameter_value_result test_effect_parameter_value_result_special[]
static
Initial value:
=
{
{ "f3", D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 12, { .f = { -3.1f, 153.2f, 283.3f }} },
{ "f3min", D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 12, { .f = { -31.1f, -31.2f, -31.3f }} },
{ "f3max", D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 3, 0, 12, { .f = { 320.1f, 320.2f, 320.3f }} },
{ "f4", D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 16, { .f = { -4.1f, 154.2f, 284.3f, 34.4f }} },
{ "f4min", D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 16, { .f = { -41.1f, -41.2f, -41.3f, -41.4f }} },
{ "f4max", D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 0, 16, { .f = { 420.1f, 42.20f, 420.3f, 420.4f }} },
}

Definition at line 1133 of file effect.c.

◆ test_effect_preshader_bconsts

const BOOL test_effect_preshader_bconsts[]
static

◆ test_effect_preshader_effect_blob

◆ test_effect_preshader_fvect_v

const D3DXVECTOR4 test_effect_preshader_fvect_v[]
static

Definition at line 4545 of file effect.c.

Referenced by test_effect_commitchanges(), and test_effect_preshader_compare_vconsts_().

◆ 

const struct { ... } test_effect_preshader_op_expected[]
Initial value:
=
{
{"1 / op", {FALSE, FALSE, FALSE, FALSE}, {0x7f800000, 0xff800000, 0xbee8ba2e, 0x00200000}},
{"rsq", {FALSE, FALSE, FALSE, FALSE}, {0x7f800000, 0x7f800000, 0x3f2c985c, 0x1f800001}, 1},
{"mul", {FALSE, FALSE, FALSE, FALSE}, {0x00000000, 0x80000000, 0x40d33334, 0x7f800000}},
{"add", {FALSE, FALSE, FALSE, FALSE}, {0x3f800000, 0x40000000, 0xc0a66666, 0x7f7fffff}},
{"lt", {FALSE, FALSE, FALSE, FALSE}, {0x3f800000, 0x3f800000, 0x00000000, 0x00000000}},
{"ge", {FALSE, FALSE, FALSE, FALSE}, {0x00000000, 0x00000000, 0x3f800000, 0x3f800000}},
{"neg", {FALSE, FALSE, FALSE, FALSE}, {0x80000000, 0x00000000, 0x400ccccd, 0xff7fffff}},
{"rcp", {FALSE, FALSE, FALSE, FALSE}, {0x7f800000, 0xff800000, 0xbee8ba2e, 0x00200000}},
{"frac", {FALSE, FALSE, FALSE, FALSE}, {0x00000000, 0x00000000, 0x3f4ccccc, 0x00000000}},
{"min", {FALSE, FALSE, FALSE, FALSE}, {0x00000000, 0x80000000, 0xc0400000, 0x40800000}},
{"max", {FALSE, FALSE, FALSE, FALSE}, {0x3f800000, 0x40000000, 0xc00ccccd, 0x7f7fffff}},
{"sin", {FALSE, FALSE, FALSE, TRUE}, {0x00000000, 0x80000000, 0xbf4ef99e, 0x3f792dc4}},
{"cos", {FALSE, FALSE, FALSE, TRUE}, {0x3f800000, 0x3f800000, 0xbf16a803, 0xbe6acefc}},
{"den mul",{FALSE, FALSE, FALSE, FALSE}, {0x7f800000, 0xff800000, 0xbb94f209, 0x000051ec}},
{"dot", {FALSE, FALSE, FALSE, FALSE}, {0x00000000, 0x7f800000, 0x41f00000, 0x00000000}},
{"prec", {FALSE, FALSE, TRUE, FALSE}, {0x2b8cbccc, 0x2c0cbccc, 0xac531800, 0x00000000}},
{"dotswiz", {FALSE, FALSE, FALSE, FALSE}, {0xc00ccccd, 0xc0d33334, 0xc10ccccd, 0}},
{"reladdr", {FALSE, FALSE, FALSE, FALSE}, {0xc00ccccd, 0x3f800000, 0, 0x41200000}},
{"reladdr2", {FALSE, FALSE, FALSE, FALSE}, {0, 0, 0x447ac000, 0x40000000}},
}

Referenced by test_effect_commitchanges(), and test_effect_preshader_op_results_().

◆ test_effect_preshader_ops_blob

const DWORD test_effect_preshader_ops_blob[]
static

Definition at line 5008 of file effect.c.

Referenced by test_effect_preshader_ops().

◆ test_effect_shared_parameters_blob

const DWORD test_effect_shared_parameters_blob[]
static

Definition at line 6682 of file effect.c.

Referenced by test_effect_shared_parameters().

◆ test_effect_skip_constants_blob

const DWORD test_effect_skip_constants_blob[]
static

Definition at line 7205 of file effect.c.

Referenced by test_effect_skip_constants().

◆ test_effect_state_manager_state_names

const char* test_effect_state_manager_state_names[]
static
Initial value:
=
{
"SetTransform",
"SetMaterial",
"SetLight",
"LightEnable",
"SetRenderState",
"SetTexture",
"SetTextureStageState",
"SetSamplerState",
"SetNPatchMode",
"SetFVF",
"SetVertexShader",
"SetVertexShaderConstantF",
"SetVertexShaderConstantI",
"SetVertexShaderConstantB",
"SetPixelShader",
"SetPixelShaderConstantF",
"SetPixelShaderConstantI",
"SetPixelShaderConstantB",
}

Definition at line 6456 of file effect.c.

Referenced by test_effect_state_manager().

◆ test_effect_states_effect_blob

const DWORD test_effect_states_effect_blob[]
static

Definition at line 3060 of file effect.c.

Referenced by test_effect_isparameterused(), and test_effect_states().

◆ test_effect_unsupported_shader_blob

const DWORD test_effect_unsupported_shader_blob[]
static
Initial value:
=
{
0xfeff0901, 0x000000ac, 0x00000000, 0x00000010, 0x00000004, 0x00000020, 0x00000000, 0x00000002,
0x00000001, 0x00000002, 0x00000007, 0x615f7376, 0x00007272, 0x00000002, 0x00000000, 0x0000004c,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000002, 0x00000069, 0x00000003,
0x00000010, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00003070, 0x00000006,
0x68636574, 0x00000030, 0x00000004, 0x00000010, 0x00000004, 0x00000000, 0x00000000, 0x00000000,
0x00000003, 0x00003070, 0x00000006, 0x68636574, 0x00000031, 0x00000002, 0x00000002, 0x00000006,
0x00000005, 0x00000004, 0x00000018, 0x00000000, 0x00000000, 0x0000002c, 0x00000048, 0x00000000,
0x00000000, 0x00000074, 0x00000000, 0x00000001, 0x0000006c, 0x00000000, 0x00000001, 0x00000092,
0x00000000, 0x00000058, 0x00000054, 0x000000a0, 0x00000000, 0x00000001, 0x00000098, 0x00000000,
0x00000001, 0x00000092, 0x00000000, 0x00000084, 0x00000080, 0x00000002, 0x00000002, 0x00000001,
0x00000038, 0xfffe0300, 0x05000051, 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
0x0200001f, 0x80000000, 0xe00f0000, 0x02000001, 0xe00f0000, 0xa0e40000, 0x0000ffff, 0x00000002,
0x00000038, 0xfffe03ff, 0x05000051, 0xa00f0100, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
0x0200001f, 0x80000000, 0xe00f0000, 0x02000001, 0xe00f0000, 0xa0e40100, 0x0000ffff, 0x00000001,
0x00000000, 0xffffffff, 0x00000000, 0x00000002, 0x000000e4, 0x00000008, 0x615f7376, 0x00007272,
0x46580200, 0x0023fffe, 0x42415443, 0x0000001c, 0x00000057, 0x46580200, 0x00000001, 0x0000001c,
0x00000100, 0x00000054, 0x00000030, 0x00000002, 0x00000001, 0x00000034, 0x00000044, 0xabab0069,
0x00020000, 0x00010001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x4d007874, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
0x656c6970, 0x2e392072, 0x392e3932, 0x332e3235, 0x00313131, 0x0002fffe, 0x54494c43, 0x00000000,
0x000cfffe, 0x434c5846, 0x00000001, 0x10000001, 0x00000001, 0x00000000, 0x00000002, 0x00000000,
0x00000000, 0x00000004, 0x00000000, 0xf0f0f0f0, 0x0f0f0f0f, 0x0000ffff, 0x00000000, 0x00000000,
0xffffffff, 0x00000000, 0x00000001, 0x0000000a, 0x615f7376, 0x315b7272, 0x0000005d,
}

Definition at line 7363 of file effect.c.

Referenced by test_effect_find_next_valid_technique(), and test_effect_unsupported_shader().

◆ test_effect_variable_names_blob

const DWORD test_effect_variable_names_blob[]
static
Initial value:
=
{
0xfeff0901, 0x0000024c, 0x00000000, 0x00000003, 0x00000000, 0x00000024, 0x00000000, 0x00000000,
0x00000001, 0x00000001, 0x40066666, 0x00000002, 0x00000061, 0x00000003, 0x00000000, 0x0000004c,
0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000002, 0x00000062, 0x00000003,
0x00000000, 0x0000009c, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x40400000,
0x00000003, 0x00000000, 0x00000094, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002,
0x00000064, 0x00000002, 0x00000063, 0x00000000, 0x00000005, 0x000000dc, 0x00000000, 0x00000000,
0x00000001, 0x00000003, 0x00000000, 0x000000e4, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
0x00000000, 0x00000002, 0x00000066, 0x00000002, 0x00000065, 0x00000003, 0x00000000, 0x00000134,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x40400000, 0x00000003, 0x00000000,
0x0000012c, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000002, 0x00000068, 0x00000002,
0x00000067, 0x00000003, 0x00000000, 0x000001a4, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
0x00000000, 0x40800000, 0x00000000, 0x00000005, 0x00000194, 0x00000000, 0x00000001, 0x00000001,
0x00000003, 0x00000000, 0x0000019c, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002,
0x0000006b, 0x00000002, 0x0000006a, 0x00000002, 0x00000069, 0x40a00000, 0x00000000, 0x00000005,
0x000001e4, 0x00000000, 0x00000001, 0x00000001, 0x00000003, 0x00000000, 0x000001ec, 0x00000000,
0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x0000006c, 0x00000002, 0x0000006a, 0x40c00000,
0x00000000, 0x00000005, 0x0000022c, 0x00000000, 0x00000001, 0x00000001, 0x00000003, 0x00000000,
0x00000234, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x0000006d, 0x00000002,
0x0000006a, 0x00000002, 0x00000070, 0x00000002, 0x00000074, 0x00000006, 0x00000001, 0x00000001,
0x00000001, 0x00000004, 0x00000020, 0x00000000, 0x00000000, 0x0000002c, 0x00000048, 0x00000000,
0x00000000, 0x00000054, 0x00000070, 0x00000000, 0x00000001, 0x00000078, 0x00000074, 0x000000a4,
0x000000d8, 0x00000000, 0x00000000, 0x000000ec, 0x00000108, 0x00000000, 0x00000001, 0x00000110,
0x0000010c, 0x0000013c, 0x00000158, 0x00000000, 0x00000001, 0x00000160, 0x0000015c, 0x00000244,
0x00000001, 0x00000001, 0x000001b0, 0x000001ac, 0x0000023c, 0x00000001, 0x00000000, 0x000001f8,
0x000001f4, 0x00000000, 0x00000000,
}

Definition at line 2714 of file effect.c.

Referenced by test_effect_compilation_errors(), and test_effect_variable_names().

◆ test_two_techniques_blob

const DWORD test_two_techniques_blob[]
static
Initial value:
=
{
0xfeff0901, 0x000000ac, 0x00000000, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000001, 0x00000003, 0x00003070, 0x00000006, 0x68636574, 0x00000030,
0x00000001, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
0x00000001, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
0x00000003, 0x00003070, 0x00000006, 0x68636574, 0x00000031, 0x00000000, 0x00000002, 0x00000002,
0x00000001, 0x0000004c, 0x00000000, 0x00000001, 0x00000044, 0x00000000, 0x00000002, 0x00000091,
0x00000000, 0x00000008, 0x00000004, 0x0000000e, 0x00000000, 0x00000028, 0x00000024, 0x000000a0,
0x00000000, 0x00000001, 0x00000098, 0x00000000, 0x00000002, 0x00000091, 0x00000000, 0x0000005c,
0x00000058, 0x0000000e, 0x00000000, 0x0000007c, 0x00000078, 0x00000000, 0x00000000,
}

Definition at line 8332 of file effect.c.

Referenced by test_effect_find_next_valid_technique().

◆ todo

◆ ulps